[Resolved] How to hide posts from homepage that are on WP Show Posts Pro

Home Forums Support How to hide posts from homepage that are on WP Show Posts Pro

  • This topic has 6 replies, 2 voices, and was last updated 3 months ago by David.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1327837
    Elio Martinez

    Hi,

    Currently my homepage is:

    1. One list made with WP Show Post Pro showing 4 posts inside an Element in the Header Hook.
    2. My last posts.

    Is there a way to not show on my last posts the posts that are on the WP Show Post Pro?

    Thanks.

    #1328165
    David
    Staff
    Customer Support

    Hi there,

    this stack overflow provides the PHP functions to offset the first 4 posts in the blog:

    https://stackoverflow.com/questions/37636667/wordpress-exclude-first-4-post-from-query/37638758#37638758

    #1328190
    Elio Martinez

    Hi David,

    If I add that function to my child functions I get a weird homepage: the 4 posts shown in WP Show Posts Pro (via tag or category because they are not the 4 last posts, they are the 4 last post with a specific tag or category) get shown in the lasts posts too and if someone clicks on “load more” posts on home page get the same posts every time he or she clicks on “load more”.

    #1328200
    Elio Martinez

    Ok, I got resolved this with this function:

    add_filter('pre_get_posts', 'excludeCat');
    function excludeCat($query) {
          if ( $query->is_home ) {
                $query->set('cat', '-3936');
          }
          return $query;
    }

    If I want to change this function to exclude a tag it must be like this?:

    add_filter('pre_get_posts', 'excludeTag');
    function excludeCat($query) {
          if ( $query->is_home ) {
                $query->set('tag', 'XXX');
          }
          return $query;
    }
    #1328268
    David
    Staff
    Customer Support

    aah ok – yes that query looks correct for Tags.

    #1328269
    Elio Martinez

    Great. Thanks!

    #1328303
    David
    Staff
    Customer Support
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.