sorry i used archive-custom.php just as an example, it was archive-case-study.php. I’ve ended up just creating a custom loop on a custom page template which fullfills my needs until i learn more about archive pages. many thanks for the help
Hi John,
Thanks for response. Apologies if not explained myself clearly, i’m confusing myself,! I think i need to learn more about basic template hierarchy foremost. B
Basically i want to pick the page that loops through the casestudies. Currently that page is a archive-custom.php file and works ok. But i think i might need to create a custom page template that loops through that archive page instead.
Ah ok so i worked out it easy to do with page link but then i havent got the same capabilities of the post object field. Does anyone know how to do it with the post object?
Hi James,
Many thanks for the feedback.
This post https://support.advancedcustomfields.com/forums/topic/hide-layout-option-in-flexible-content/#post-41421 is exactly what i wanted.
Thanks petercarsater,
This is just what i needed!
The code you have shown is all a bit advanced for me, trying to understand it. I kind of want to be a bit freestyle in what i hide and don’t hide so i bodged your code to echo the page-id to the admin’s body class so i can be really detailed with what pages see what:
if ($post->post_type == "page") : // set 'page' for page postypes
echo 'var $template_name = "page";';
else :
// Just get the template name
echo 'var $template_name = $("#page_template").val();';
endif;
?>
// Add classes to body
window.UpdateACFView = function($template_name) {
if ($template_name == "page") {
$('body').addClass('<?php global $post; echo "pageid-".$post->ID; ?>');
}
Can you let me know if this is the best practice to achieve this? Seems to work though.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.