[Resolved] Custom taxonomy as a page with custom content

Home Forums Support [Resolved] Custom taxonomy as a page with custom content

Home Forums Support Custom taxonomy as a page with custom content

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #1198058
    Alberto

    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!

    #1198578
    Leo
    Staff
    Customer Support

    Hi there,

    This isn’t something the theme can control.

    You might need to look into modifying the Permalink settings handled by WordPress:
    https://wordpress.org/support/article/settings-permalinks-screen/

    Or a plugin like YoastSEO to set the URL.

    #1198651
    Alberto

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

    Regards

    #1198921
    Tom
    Lead Developer
    Lead 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.

    #1199133
    Alberto

    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!

    #1199715
    Tom
    Lead Developer
    Lead Developer

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

    #1199726
    Alberto

    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

    #1200050
    Tom
    Lead Developer
    Lead 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.

    #1200203
    Alberto

    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

    #1200823
    Tom
    Lead Developer
    Lead 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?

    #1200898
    Alberto

    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

    #1201109
    Tom
    Lead Developer
    Lead 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 category_name with term, but I’m not 100% sure.

    #1201511
    Alberto

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

    Regards

    #1201668
    David
    Staff
    Customer Support

    Hi there,

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

    #1207046
    Alberto

    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

Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.