• Resolved StandOutSites

    (@standoutsites)


    I have created a simple CPT “listings” as part of Contact Directory. has_archive is set to TRUE and custom archive URL is set to “directory”. there’s a template archive-listings.php that show a list of these posts. right now I made the posts publicly queryable for testing purposes and you can see that one can see a single listing at https://www.cityofpasadena.net/public-health/listing/tuberculosis-clinic/ (you will only see the title as the rest of the post are ACF custom fields).
    However, when one attempts to see the archive of these posts https://www.cityofpasadena.net/public-health/directory, it redirects to the home page. It’s refusing to pick up the archive template with the set “directory” rewrite. however, you can still see the archive using query parameters, https://www.cityofpasadena.net/public-health/?post_type=listings
    Why is archive rewrite not working? Also, originally I had publicly-queryable set to false, so that one couldn’t see sinlge post item, but only archive and it worked fine. This stopped working overnight with no changes to CPT settings. can you point me to what I am not considering.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Here’s what I see when I visit https://www.cityofpasadena.net/public-health/directory/

    https://cloudup.com/czKHnQUyJKD

    No redirect triggered for me or anything. Is this what I should be seeing?

    Thread Starter StandOutSites

    (@standoutsites)

    Yes, that’s exactly what you should be seeing, why am I not seeing this. I get redirected to the home page. that’s bizarre. I just did this in an incognito/private browser window and it worked just fine. Question, can I set the publicly queryable to FALSE, so that single listings cannot be viewable as there’s not template for a single-listings.php.

    Thread Starter StandOutSites

    (@standoutsites)

    After thorough browser cache cleaning, everything seems to be working fine

    Thread Starter StandOutSites

    (@standoutsites)

    Actually, I have to report this issue is not going away. So the link works in IE fine, but not in Chrome or Firefox, unless I go into an incognito/private browsing mode window. I did clear server cache and browser cache. Any ideas on what may be causing this?

    Thread Starter StandOutSites

    (@standoutsites)

    Ok, so setting publicly_queryable variable to false disables archive pages for the posts because archive pages usually use the loop and not a custom query. I guess it makes sense since queryable variable enables the following queries per WP documentation (https://codex.wordpress.org/Function_Reference/register_post_type)

    
    Note: The queries affected include the following (also initiated when rewrites are handled)
     ?post_type={post_type_key}
     ?{post_type_key}={single_post_slug}
     ?{post_type_query_var}={single_post_slug}
    

    but how then can I disable single post view yet keep the archive template? please advise.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hard for me to say why non-private windows isn’t showing what’s expected, unless you somehow have something cached.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Forgot to refresh my tab.

    I would probably end up doing some sort of callback on the template_redirect hook to check if trying to view a single post in the post type, and send them elsewhere. Not a feature we have as part of CPTUI, but all in all should be possible.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Archive for CPT refuses to show posts’ is closed to new replies.