• Deon

    (@deon-b)


    Hi,
    can I exclude the current post from the list of related posts?

    So lets say I have an article: “how to wash a cat”
    I insert at the bottom the shortcode [display-posts category=”cats”]

    and its displaying all posts in that category, but also “how to wash a cat” which is the current post.

    Any way to exclude that current post automatically?

    Also, second question does this work on “pages”?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Bill Erickson

    (@billerickson)

    You can use the exclude_current parameter for that:

    [display-posts category=”cats” exclude_current=”true”]

    Plugin Author Bill Erickson

    (@billerickson)

    And yes, this does work for pages. The default post type is ‘post’, but you can query for pages like so:

    [display-posts post_type=”page”]

    Here’s a full list of the available parameters: https://displayposts.com/docs/parameters/

    Thread Starter Deon

    (@deon-b)

    Hi,
    I already pasted the shortcode in over 200 posts, how can I set current post excluded by default in functions.php?

    Thread Starter Deon

    (@deon-b)

    Hi,
    problem solved, I added this

    `’exclude_current’=> “true”,
    ‘orderby’ => ‘rand’,`

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude current post?’ is closed to new replies.