• rahulkapoordelhi86

    (@rahulkapoordelhi86)


    Hi GP Team,

    How to hide featured image on child pages of a specific parent page using filter.

    I look forward to your reply.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Elvin

    (@ejcabquina)

    Hi there,

    You’ll need a PHP snippet for that.

    add_filter( 'option_generate_blog_settings', function($options){
    	global $post;
    	if ( $post->post_parent == '2' ) {
    		$options['single_post_image'] = false;
    	}
    	return $options;
    });

    change ‘2’ to the ID of the parent page.

    Thread Starter rahulkapoordelhi86

    (@rahulkapoordelhi86)

    Hi @ejcabquina , thanks for your reply BUT the given snippet is not working. is that a reason you have used “single_post_image”, I want to remove the featured images from Child PAGES of the Parent PAGE.

    I changed the parent page ID from 2 to 12139 and also cleared the cache, still no luck.

    Pls check again.

    Elvin

    (@ejcabquina)

    Can you link us to a sample page in question?

    For the “child pages” were you pertaining to their thumbnails? Is this “parent page” an archive?

    Thread Starter rahulkapoordelhi86

    (@rahulkapoordelhi86)

    Hi @ejcabquina, Let me explain a bit …

    I am creating child pages under a parent page (set the parent page from page attribute options on child pages), now I don’t want featured images to appear on all child single pages (that are under that particular parent page).

    No, the parent page is not an archive page… I am talking about the featured image that appears above page title (h1) on single pages.

    ying

    (@yingscarlett)

    Hi there,

    Give this PHP snippet a try:

    add_action( 'wp', function() {
    	global $post;
    	if (  $post->post_parent == '2'  ) { 
        remove_action( 'generate_after_header', 'generate_featured_page_header', 10 );
    	}
    } );

    Replace the 2 with the parent page ID.

    Let me know if this helps ??

    Thread Starter rahulkapoordelhi86

    (@rahulkapoordelhi86)

    Hi @yingscarlett,

    Your PHP Snipped worked, thanks.

    Can you also help me how to add multiple parent pages (parent page ID 2, 3, 4, etc) and also how to hide featured images on those parent pages as well.

    Look forward to your help.

    ying

    (@yingscarlett)

    Try this:

    add_action( 'wp', function() {
    	global $post;
    	if (  $post->post_parent == '2'|| $post->post_parent =='3' || $post->post_parent =='4' || is_page( array( 2, 3, 4 ))  ){ 
        remove_action( 'generate_after_header', 'generate_featured_page_header', 10 );
    	}
    } );
    • This reply was modified 3 years ago by ying.
    • This reply was modified 3 years ago by ying.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to hide featured image on child pages of a specific parent page’ is closed to new replies.