• Resolved pott121

    (@pott121)


    Hello, I’d like to add the Related posts feature on multiple pages (not posts)

    I used this code to show the feature on pages:

    function jetpackme_allow_pages_for_relatedposts( $enabled ) {
        if ( is_page() ) {
            $enabled = true;
        }
     
        return $enabled;
    }
    add_filter( 'jetpack_relatedposts_filter_enabled_for_request', 'jetpackme_allow_pages_for_relatedposts' );

    And it worked for all pages. Now I would like to remove it for specific ones.

    The code suggested on the support website is:

    function jetpackme_no_related_posts_onpages( $options ) {
        if ( is_page( 11 ) ) {
            $options['enabled'] = false;
        }
        return $options;
    }
    add_filter( 'jetpack_relatedposts_filter_options', 'jetpackme_no_related_posts_onpages' );

    But this only works on one page, i tried modifying it but with my restricted programming knoledge i could not make it do what I wanted

    I also tried using this one, based on the code suggested on the support website to hide the feature on multiple posts:

    function jetpackme_no_related_posts_onpages( $options ) {
        if ( 
    		is_single( 
    			array( 547, 2384 ) 
    		) 
    		) {
            $options['enabled'] = false;
        }
        return $options;
    }
    add_filter( 'jetpack_relatedposts_filter_options', 'jetpackme_no_related_posts_onpages' );

    But it didnt work either.
    So is it possible to remove the feature on multiple pages?
    Thank you

Viewing 1 replies (of 1 total)
  • Thread Starter pott121

    (@pott121)

    I solved it by changing is_single to is_page in the last code I shared

Viewing 1 replies (of 1 total)

The topic ‘Hide related posts on multiple pages’ is closed to new replies.