Home › Forums › General Issues › Help with disabling a group field on a specific page
Hi guys,
Would it be possible to disable a particular custom field on a page. If you look at this particular page on my site, my site developers have a custom CTA at the top of the page aswell as a Page Title and Text Beside Title that I would like to disable just on this store page.
Any help would be really appreciated.
Many thanks and all the best
Michael
If you want to remove them from one page on the front end then you need to alter the code of the template that is displaying the fields, detect what page it is and add a conditional so that they are not shown.
Many thanks for your reply John.
I know what page I don’t want them to be seen on and have set a rule group to what I think should hide them there however they still show.
Do I need to actually alter the template code of my theme?
Many thanks again in advance.
Removing a field group form a page does not remove the data in those fields from the database.
There is no way for me to know what exactly you need to do. It could be as simple as deleting the content of those fields which would mean having the field on the page and deleting the content. Or could be that you actually need to alter the code in the template. All of this depends on the fields and the code used to show them.
No problem thanks a million for your help anyway John.
I usually do my own slight editing of my site with content and WooCommerce etc but I think I better get my actual developers to have a look.
All the best
Sorry John I found the following code in my template for this group, do you know how I could edit it so that this group doesn’t display on my /online-store page too ?
Many thanks!
<?php
$pageid = null;
if( is_home() && !is_front_page() ) {
$pageid = get_option('page_for_posts');
} else {
$pageid = $post->ID;
}
?>
<div class="header-default-top-section">
<div class="container">
<div class="row">
<div class="col-md-9">
<div class="content-box">
<?php if( get_field('main_title', $pageid ) ) : ?>
<h1><?php the_field('main_title', $pageid ); ?></h1>
<?php endif; ?>
<div class="parting"></div>
<?php if( get_field('text_beside_title', $pageid ) ) : ?>
<p><?php the_field('text_beside_title', $pageid ); ?></p>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
This would remove the entire header on a specific page
<?php
$pageid = null;
if( is_home() && !is_front_page() ) {
$pageid = get_option('page_for_posts');
} else {
$pageid = $post->ID;
}
// replace number with id where you don't want it shown
if ($pagid != 1234) {
?>
<div class="header-default-top-section">
... the rest of your header code here
<?php
}
?>
You must be logged in to reply to this topic.
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.