• Resolved rogabriel

    (@rogabriel)


    Hi,

    I have a post with the title “Lorem ipsum” and it’s slug is “lorem-ipsum”.
    In order to be able to make a particular layout for it, I made a specific page “Lorem ipsum” where I call and display the post. The page has the same slug: “lorem-ipsum”. I put the link to the page into the navbar and everything is fine, except that both appear on the search results page.
    Is there a method to exclude page from search query, given that the page content is loaded anyway when the link is visited?

    • This topic was modified 2 years, 5 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 2 replies - 1 through 2 (of 2 total)
  • Panos

    (@panoshostinger)

    Hey there!??

    When you say “search results” page, you mean your own website’s search function, right?

    You can try using the plugin Search Exclude:
    https://prnt.sc/ROaKlTqTe5WW

    Direct link can be found here:
    https://www.ads-software.com/plugins/search-exclude/

    You can easily exclude specific posts or pages from the search results of your website, by just checking this:
    https://prnt.sc/8ggiQ7IzJUTL

    I’ve tested it on latest WordPress version and it works great!

    Give it a try, I’m pretty sure this will help you!

    Thread Starter rogabriel

    (@rogabriel)

    Hi Panos,

    Thank you for your help, it’s a great idea, I will try it.
    In the mean time I modified the code manually, adding a condition after
    “while ( have_posts() ) :”
    “if( get_post_type() === ‘post’ ) {”
    But it seems that your solution is more flexible, thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to deal with post and page with same slug?’ is closed to new replies.