Archive page not working with slug
-
HI I have installed CPT UI and all is well and upgraded also however I cannot get the archive-slugname.php to work it always defauts to either just the archive.php or to the index page. Can you plerase help? Its urgent.
-
What’s the slug you’re trying with and what’s the filename exactly? You’d want it to match the first field specified in our settings, for each post type trying with. It wouldn’t be the rewrite value provided, for example, if you’ve provided a value for that setting.
Hi Michael
Thanks for the quick reply. The slug I am using is hotelsdetail and the file name I am using is archive-hotelsdetail.php. As I said working with just archive.php or even category.php but not with the slug at the end which is what I need because I will need several templates for different post types.
Great plugin by the way have used it alot.
Cheers
In advance.
Hi Michael
By the way the single-hotelsdetail.php is working fine its just the archive results.
Cheers
J
Can you paste your Import/Export area post types settings? I’m a bit curious why this isn’t taking, and if I can recreate it on my own site.
No reason I can think of that it’s not finding the files, unless you’re putting the files in the wrong theme directory :D.
Hi Michael
See below and there are in the right theme directory I am only using one theme:
{“result_content”:{“name”:”result_content”,”label”:”Results page”,”singular_label”:”Results page”,”description”:””,”public”:”true”,”publicly_queryable”:”true”,”show_ui”:”true”,”show_in_nav_menus”:”true”,”show_in_rest”:”false”,”rest_base”:””,”has_archive”:”false”,”has_archive_string”:””,”exclude_from_search”:”false”,”capability_type”:”post”,”hierarchical”:”false”,”rewrite”:”true”,”rewrite_slug”:””,”rewrite_withfront”:”true”,”query_var”:”true”,”query_var_slug”:””,”menu_position”:””,”show_in_menu”:”true”,”show_in_menu_string”:””,”menu_icon”:””,”supports”:[“title”,”editor”,”thumbnail”],”taxonomies”:[“category”,”post_tag”],”labels”:{“menu_name”:””,”all_items”:””,”add_new”:””,”add_new_item”:””,”edit_item”:””,”new_item”:””,”view_item”:””,”search_items”:””,”not_found”:””,”not_found_in_trash”:””,”parent_item_colon”:””,”featured_image”:””,”set_featured_image”:””,”remove_featured_image”:””,”use_featured_image”:””,”archives”:””,”insert_into_item”:””,”uploaded_to_this_item”:””,”filter_items_list”:””,”items_list_navigation”:””,”items_list”:””},”custom_supports”:””},”hotelsdetail”:{“name”:”hotelsdetail”,”label”:”Hotels”,”singular_label”:”Hotel”,”description”:””,”public”:”true”,”publicly_queryable”:”true”,”show_ui”:”true”,”show_in_nav_menus”:”true”,”show_in_rest”:”false”,”rest_base”:””,”has_archive”:”true”,”has_archive_string”:”hotelsdetail”,”exclude_from_search”:”false”,”capability_type”:”post”,”hierarchical”:”true”,”rewrite”:”true”,”rewrite_slug”:”hotelsdetail”,”rewrite_withfront”:”true”,”query_var”:”true”,”query_var_slug”:””,”menu_position”:””,”show_in_menu”:”true”,”show_in_menu_string”:””,”menu_icon”:””,”supports”:[“title”,”editor”,”thumbnail”],”taxonomies”:[“category”,”post_tag”],”labels”:{“menu_name”:””,”all_items”:””,”add_new”:””,”add_new_item”:””,”edit_item”:””,”new_item”:””,”view_item”:””,”search_items”:””,”not_found”:””,”not_found_in_trash”:””,”parent_item_colon”:””,”featured_image”:””,”set_featured_image”:””,”remove_featured_image”:””,”use_featured_image”:””,”archives”:””,”insert_into_item”:””,”uploaded_to_this_item”:””,”filter_items_list”:””,”items_list_navigation”:””,”items_list”:””},”custom_supports”:””,”cpt_to_category_archive”:[“1”]}}
Not managing to recreate the issue on my local install, using twentysixteen. I’m having to believe there’s something in the theme that is overtaking the hierarchy selection for this case. Not sure what all to tell ya here.
Ummmm ok Michael
Not sure if this helps but the query when going from the category list is: https://papion.eprefix.com/category/countries/mexico/
Is that the URL you are testing with for the template selection in this case? Asking because that’d be a category term archive, and not a post type archive. This would be the URL to use for testing the archive-hotelsdetail.php template: https://papion.eprefix.com/hotelsdetail/
Hi Michael
I have tested that URL and it works however I am doing a query via a Category list and if I send the URL for instance https://papion.eprefix.com/hotelsdetail/type/beach I get a 404 error?.
Can you help with a category query please?.
Very much appreciated?.
Cheers
J
If I’m not mistaken, that’s treating it like a nested child post type post, it’s looking for a post that’s titled “beach”, that’s a child post of a post titled “type”. Essentially looking for a single post, but since there is none, it returns a 404 instead.
For that url, what is “type” a custom taxonomy, with “beach” being a term in the taxonomy? I do see https://papion.eprefix.com/category/beach/ working and returning results, but that’s going to be the category term archive for the term “beach”, and out of box would only show posts from the “post” post type. You’ll need to do some extra code, that I have documentation for, to get the hotelsdetail posts included.
I’m having the same problem, but wasn’t sure if I should start a new thread. The CPT is artists. I’ve created archive-artists.php, but the site is using index.php. Even if I modify archive.php, it still accesses index.php.
Not sure @lschatzkin.
Quickest thing I have is if your post type is set to true for has_archive. Otherwise, something with the queries is causing it to select other templates. Do you happen to have a page slug named “artists”, as that could interfere as well.
Any followup for either of you, @jameszxr and @lschatzkin
- The topic ‘Archive page not working with slug’ is closed to new replies.