• Resolved Criis87

    (@criis87)


    Hello, how are you? I need help to show related post in my Attachments page. When clicking in a picture of my image galleries you will be redirected to
    the attachment page. This Attachments are placed in image.php inside my theme.

    Is there any way to show related post below? Now I am showing related posts with google related content, but I would like to use jectpacks.

    Here is an example page: Have a nice day images.

    Thanks in advance.

    • This topic was modified 2 years, 8 months ago by Criis87.

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Dan (a11n)

    (@drawmyface)

    Hi there

    Related posts won’t show by default on attachment pages, but you can add them using this filter:
    https://developer.jetpack.com/hooks/jetpack_relatedposts_filter_enabled_for_request/

    Note that you’ll need to edit the code there to use is_attachment() instead of is_page().

    Thread Starter Criis87

    (@criis87)

    Thanks for reply Dan. I applied this code but didnt work.

    function jeherve_allow_pages_for_relatedposts( $enabled ) {
    if ( is_attachment() ) {
    $enabled = true;
    }
    return $enabled;
    }
    add_filter( ‘jetpack_relatedposts_filter_enabled_for_request’, ‘jeherve_allow_pages_for_relatedposts’ );`

    Hello @criis87

    Could you confirm which file did you add the function, please?

    Let me know if you have any questions.

    My best regards,

    Michelle C.

    Thread Starter Criis87

    (@criis87)

    Hello Michelle, I added to functions.php

    Plugin Contributor Dan (a11n)

    (@drawmyface)

    Hi @criis87

    Related post content is automatically generated based on the content of the post and any tags or categories if they exist.

    By default, attachment pages don’t have categories/tags, and don’t contain any text content, so that’s probably why Jetpack is not adding any related posts.

    It looks like you’re already using an alternative related posts plugin on your attachment pages, so you may want to continue using that, otherwise you’d need to try customizing your theme’s attachment.php file to add more text content the attachment pages.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show Related Post in Attachments page’ is closed to new replies.