- This topic has 19 replies, 4 voices, and was last updated 1 year, 6 months ago by Tom.
March 18, 2020 at 1:42 am #1198058Alberto
This is my scenario: I’m working with custom taxonimies and I want to display a custom page, not the archive page, when I go to http://www.my_domain.com/my_custom_category_slug.
I’m working with ACF so in WP admin area, I want to enter the information in the fields showed when I go into my CPT -> Custom Category.
You can see an example at https://arenatours.com/en/india-country/ where india-country is a custom category but in that URL you can see a single page, not an archive page.
I hope I’ve made myself clear.
Thanks in advance!March 18, 2020 at 8:02 am #1198578LeoStaffCustomer Support
This isn’t something the theme can control.
You might need to look into modifying the Permalink settings handled by WordPress:
Or a plugin like YoastSEO to set the URL.March 18, 2020 at 9:15 am #1198651Alberto
I’m not talking about the permalinks but the templates (https://developer.wordpress.org/themes/template-files-section/taxonomy-templates/). I’d like to know what’s the file I must use as taxonomy-pais.php to get something like the diplayed in https://arenatours.com/en/india-country/ where india-country is my custom taxonomy.
RegardsMarch 18, 2020 at 3:58 pm #1198921TomLead DeveloperLead Developer
I think that’s exactly what you’d need to do: https://developer.wordpress.org/themes/template-files-section/taxonomy-templates/#custom-taxonomy
Set up a custom taxonomy archive where you can control the content/layout of the archive.March 19, 2020 at 12:40 am #1199133Alberto
Thanks a lot for your reply!
I’m not totally sure I understand. I’m working with a child theme of GP so I think I must copy a file from generatepress folder and rename it as taxonomy-country.php Is it the index.php file?
Thank you so much!March 19, 2020 at 9:22 am #1199715TomLead DeveloperLead DeveloperMarch 19, 2020 at 9:34 am #1199726Alberto
Thanks for replying!
But the archive.php is for a kind of list of posts with that custom tag, isn’t it? What I need is a singular page (a kind of simple post), as you can see in https://arenatours.com/en/india-country/ (another one will be https://arenatours.com/en/sri-lanka, https://arenatours.com/en/japan, and so)
In my CPT there’s only one entry tagged india-country, that’s why I’m not sure that archive.php file is the one I need to edit and use as taxonomy-country.php
RegardsMarch 19, 2020 at 4:10 pm #1200050TomLead DeveloperLead Developer
Our archive.php file is just a basic loop, you can rename it to taxonomy-country.php and then add content along with the loop etc..
Otherwise, you can use a plugin like WP Show Posts to include posts on a static page, but that won’t use the taxonomy URL.
Basically, the only way to add static content along with posts on the taxonomy archive is to build out the template that way.
To do something like those example, I would go the WP Show Posts route.March 20, 2020 at 12:33 am #1200203Alberto
Sorry, I’m not sure I’m explaining myself properly.
I don’t want to include posts on a static page. I only want static pages that correpond to the terms of my custom category (the countries). One page with the content os India, one page with the content of Sri Lanka, and so on. So, I need to edit the appropriate file to get taxonomy-country.php No loops needed, only the static content usually added on the custom category editing page (WP admin).
RegardsMarch 20, 2020 at 9:20 am #1200823TomLead DeveloperLead Developer
I’m still not sure I understand, sorry!
So you’re wanting to display a regular static page in place of a taxonomy archive? So if the user goes to the archive, they see static content instead of a list of posts?March 20, 2020 at 10:57 am #1200898Alberto
Yes, you are right!
As I told you, india-country is my custom taxonomy, but as you can see in https://arenatours.com/en/india-country what i want to show is a page with the content entered in that taxonomy (in wp admin and also working with ACF)
I don’t want to show a list of posts. I want to show a page, so I’m wondering what’s the file I must edit to get my taxonomy-country.php
Hope I’ve made myself clear
RegardsMarch 20, 2020 at 4:34 pm #1201109TomLead DeveloperLead Developer
Hmm, I’m not entirely sure what the best method would be.
You could try something like this: https://docs.wpshowposts.com/article/use-static-pages-as-category-archives/
You might need to replace
term, but I’m not 100% sure.March 21, 2020 at 3:58 am #1201511Alberto
Does that mean I have to use the WP Show Posts plugin?
RegardsMarch 21, 2020 at 6:37 am #1201668DavidStaffCustomer SupportMarch 23, 2020 at 1:16 am #1207046Alberto
I’ve tried what you’re telling me and it seems to work when it concerns solving the urls, so it shows the page I’ve created.
But I’m not entirely sure that’s the solution for this.
As I told you, I’m using ACF in my custom categories (please, see this image: https://prnt.sc/rl1lvn), so I need to edit the appropriate file to enter the get_fields() for it (Unless there’s another way).
In the actual website (arenatours.com) if I click on “Ver país” (see the image above), I can see arenatours.com/sri-lanka with the information entered in that admin page (the sri-lanka term page). This is because there is a taxonomy-pais.php file. I mean, I guess if I had a taxonomy-pais.php file I could work with the info entered in the term admin page. But, as I told you, I don’t want to show a list of posts. I want to show it as a page.
Excuse me if I don’t make myself clear.
- You must be logged in to reply to this topic.