Support » Plugin: Jetpack by WordPress.com » Jetpack related posts filter for turning off related posts broken i WP 5.x

  • Resolved jarledb

    (@jarledb)


    Using the following code the related posts are no longer removed.
    function jetpackme_no_related_posts( $options ) {
    if ( is_single( array( 17, 19, 1, 11 ) ) ) {
    $options[‘enabled’] = false;
    }
    return $options;
    }
    add_filter( ‘jetpack_relatedposts_filter_options’, ‘jetpackme_no_related_posts’ );

    Even just returning $options[‘enabled’] = false; does not work.

    The filter is documented here:
    https://jetpack.com/support/related-posts/customize-related-posts/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support lizkarkoski

    (@lizkarkoski)

    Good morning –

    Please let me know what trouble shooting steps you’ve already taken. Have any recent changes or updates been made to the site? Last thing, please share the URL of the site involved here so we can take a look at it. Thanks!

    Chris

    (@abilenedistrict)

    Hi jarledb and lizkarkoski

    I’m having the same issue (the only difference is that I’m using WooCommerce’s is_product conditional tag).

    The related post began appearing on product pages after installing Jetpack’s last update.

    I’ve also taken the same troubleshooting step mentioned by jarledb (removing the conditional so that filter should apply to all post).

    The following link will take you to one of our product pages.
    https://sandbox.paperandsage.com/premades/id0811201701-just-call-my-name/

    Also, like jarledb I’m using the code recommended by filter documentation at:
    https://jetpack.com/support/related-posts/customize-related-posts/

    Here is my implementation:

    // remove related post from product page
    function exclude_jetpack_related_from_products( $options ) {
        if ( is_product() ) {
            $options['enabled'] = false;
        }
    
        return $options;
    }
    
    add_filter( 'jetpack_relatedposts_filter_options', 'exclude_jetpack_related_from_products' );

    Here it is again without the conditional:

    // remove related post from product page
    function exclude_jetpack_related_from_products( $options ) {
        $options['enabled'] = false;
        return $options;
    }
    
    add_filter( 'jetpack_relatedposts_filter_options', 'exclude_jetpack_related_from_products' );
    Plugin Contributor James Huff

    (@macmanx)

    Volunteer Moderator

    That should definitely still work: https://jetpack.com/support/related-posts/customize-related-posts/#woocommerce

    And the filter is still valid: https://developer.jetpack.com/hooks/jetpack_relatedposts_filter_options/

    I’ve asked a developer to take a quick look.

    Plugin Author Brandon Kraft

    (@kraftbj)

    Code Wrangler

    Howdy y’all,

    It does look like 7.1 had a change impacted specifically the ‘enabled’ option. We’ve opened a code change request at https://github.com/Automattic/jetpack/pull/11560 for us to discuss reverting this back to the previous behavior.

    We have it pegged for the 7.2 release which is targeted for the first Tuesday of April.

    I’m sorry for the hassle and appreciate y’all bringing it to our attention!

    Chris

    (@abilenedistrict)

    Hi everyone,

    I’m still having an issue here after the update Jetpack 7.2.

    Same code as before

    // remove related post from product page
    function exclude_jetpack_related_from_products( $options ) {
        if ( is_product() ) {
            $options['enabled'] = false;
        }
    
        return $options;
    }
    
    add_filter( 'jetpack_relatedposts_filter_options', 'exclude_jetpack_related_from_products' );

    This time my product pages are returning the following (note the duplication):

    <div id="jp-relatedposts" class="jp-relatedposts">
    	<h3 class="jp-relatedposts-headline"><em>Related</em></h3>
    </div>
    <div id="jp-relatedposts" class="jp-relatedposts">
    	<h3 class="jp-relatedposts-headline"><em>Related</em></h3>
    </div>

    The product I posted before has been removed from the site, but you can still see the issue by visiting https://sandbox.paperandsage.com/premades/ and clicking through to an individual product page.

    Yes, having the same problem. Filter correctly removes the related posts but not the entire “jp-relatedposts-headline” HTML and title “Related”

    Plugin Contributor James Huff

    (@macmanx)

    Volunteer Moderator

    Thanks for checking!

    I have reached out to our developers at https://github.com/Automattic/jetpack/issues/11546#issuecomment-481030346 and we’ll let you know if we hear anything back.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.