Site logo

Archived topic

Custom taxonomy as a page with custom content

19 replies · Started by Alberto on March 18, 2020

Viewing posts 1–15 of 20

Hello
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!

Hi Tom
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!

You would copy the archive.php file, then adjust the HTML in the template to match the layout you're wanting to achieve.

Hi Tom!
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

Regards

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.

Hi Tom!
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).

Regards

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?

Hi Tom!
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

Regards

Hi Tom!
Does that mean I have to use the WP Show Posts plugin?

Regards

Hi there,

no - the Function provided on the WPSP site will work without WP Show Posts.

Hello
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.

Regards

This archived topic is closed to new replies.