Support

Account

Home Forums General Issues Help with disabling a group field on a specific page

Solving

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 
      }
    ?>
    
    
Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.