WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Overwrite Category URL with static Page URL (3 posts)

  1. gabestah
    Member
    Posted 1 year ago #

    Hello,

    I imagine I'm far from the first to ask this question, but I'm unable to find an answer so hopefully someone can point me in the right direction.

    I would like to retain the current URL structure of domain.com/stories/article-title/ when viewing Posts, but simultaneously ensure that domain.com/stories/ displays a specific, static Page called "stories" rather than showing the default Post list filed under the stories Category. As you may have guessed, I'm using Yoast SEO to strip the /category/ base from the URL to retain the nice URL structure mentioned above.

    When I have both a category named "stories" and a static Page named "stories", WordPress defaults to the category listing for domain.com/stories/. Is it possible to force WordPress to instead prefer to show the static Page for /stories/ instead?

    Any help or tips would be much appreciated and thanks!

    -Gabe-

  2. TCR
    Member
    Posted 1 year ago #

    I had a similar problem on a clients website, i overcame this by using the 'is_category();' function on a custom template file, if it was it displayed the latest posts in that category if not it displays alternative information (in my case a list of all the categories and the number of posts within) but there is no reason why that logic couldn't display the post information from your static page.

    hope this helps

  3. gabestah
    Member
    Posted 1 year ago #

    Thanks for the quick reply TCR!

    I did end up resolving this eventually by following the steps outlined in this very handy post.

Topic Closed

This topic has been closed to new replies.

About this Topic