Default query parameters changing on same template... (1 post)

  1. ryansigg
    Posted 2 years ago #

    Hello all,
    This is a hard issue to explain (and really hard one to search and see if someone has had a similar issue...

    We're having a problem that seems to stem from WordPress changing the default query between different page of the same custom post type.
    So, this issue was spotted when two posts having the same title were showing up on the same page...

    I thought this was strange, as their permalinks are quite different (one has a parent page) though their slug is the same because they share the same title:
    Post 1: cruise/chattanooga-to-memphis/
    Post 2: cruise/civil-war-cruise/chattanooga-to-memphis/

    Both posts were showing up on Post 2's page, so I dig some digging and used echo $GLOBALS['wp_query']->request; to display the query used.

    Post 1's query:
    SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_name = 'chattanooga-to-memphis' AND wp_posts.post_type = 'cruise' ORDER BY wp_posts.post_date DESC

    Post 2:
    SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND (wp_posts.ID= '3329') AND wp_posts.post_type = 'cruise' ORDER BY wp_posts.post_date DESC

    Notice that Post 1 is looking @ the post's permalink slug (wp_posts.post_name) and Post 2 is looking for the post ID (which seems to make more sense).

    Anyone know why WordPress would change from looking from a post ID to a post permalink slug?
    Is there a difference because the one post has a parent?

    I would think that WordPress would generate a different permalink slug for the second post, but it didn't...
    But that seems separate from the question of why WordPress is changing the query for the same type of post(?).

Topic Closed

This topic has been closed to new replies.

About this Topic