• Resolved nanciizhang

    (@nanciizhang)


    Hello,

    I own a online e-commerce store, I wanted to keep my visitors engaged with related content at the bottom of each post so I turned on “Show related content after posts” button In the Traffic Setting Tab in my Jetpack plugin, but I do not what this Related content to show in my product pages since I am using a theme that already contains Related Products at the end of the page and having this turned on from my Jetpack plugin would cause duplicated sections. However, I would want this to be turned on for journals and articles that I post in my website.

    Could you pleas let me know how I can have this turned on for posts and articles only but not on the product pages so I don’t have a duplicated section in my product pages?

    Thank you!
    Nancy

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Animesh Gaurav (a11n)

    (@bizanimesh)

    Hi @nanciizhang

    You can use the below code to remove related posts from products:

    function jetpackme_exclude_jetpack_related_from_products( $options ) {
        if ( is_product() ) {
            $options['enabled'] = false;
        }
     
        return $options;
    }
    add_filter( 'jetpack_relatedposts_filter_options', 'jetpackme_exclude_jetpack_related_from_products' );

    In order to make the code work on the site, you can use Code Snippets plugin.

    Thanks!

    Thread Starter nanciizhang

    (@nanciizhang)

    Thank you so much @bizanimesh !

    The code you provided is to turn off the related posts from my product pages but I can still see the related posts from my posts/blog pages right?

    Also, will this code work if I add to my CSS codes? or it has to work with the Code Snippets plugin?

    Thank you!
    Nancy

    Plugin Support MadHatter (a11n)

    (@madhattersez)

    Nancy,

    Correct, this would only be removing them from the product pages.

    And you would want to use this in a Code Snippets plugin rather than CSS.

    Please let us know if you have any other questions!

    Thread Starter nanciizhang

    (@nanciizhang)

    Thanks for the quick reply @madhattersez!

    I am not very familiar with using Code Snippets, sorry im not very techy into codes. Wonder if there is another way this could work or any way that I can use CSS code and still works properly?

    Thanks!
    Nancy

    Plugin Contributor Dan (a11n)

    (@drawmyface)

    Hi Nancy

    With CSS you could only hide the related posts on you product pages, so they would still be loaded, but not displayed. To do that you can add the following CSS:

    .single-product .jp-relatedposts {
        display: none !important;
    }

    If you want to remove them completely so they are not loaded at all on product pages, you would need to either add the code Animesh mentioned to your theme’s functions.php file, or by using the Code Snippets plugin. The plugin is generally easier if you’re not familiar with coding. There’s an example here so you can see how it works:
    https://jetpack.com/support/adding-code-snippets/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to Turn “Related Content” on for Post pages only but not Product pages.’ is closed to new replies.