WordPress.org

Ready to get started?Download WordPress

Forums

PHP for taxonomy title with number (2 posts)

  1. lifesgood
    Member
    Posted 8 months ago #

    A big thank you in advance to anyone who may be able to help me with this...

    I have a custom post type called RESOURCES which I used to create a directory of resources on my website. This CPT has the taxonomy called PRICES (and the terms for each post are free, free trial, premium).

    So, when someone's viewing my directory and they see in the sidebar PRICES with those options underneath, they could click on (for example) FREE and see 18 different free resources listed.

    What I want is for that FREE page (mysite.com/price/free) to have the headline "18 free resources" instead of just "Free"

    What PHP do I use to display that? I am assuming there are three parts: First: the number, Second: the taxonomy term and Third: text that simply reads "resources" at the end.

    My knowledge of PHP is limited, but I have been able to work it out enough to do other things such as showing author names where I want them to etc. I just need the php - I know where to put it etc.

  2. Boite Mails
    Member
    Posted 8 months ago #

    It's difficult to find help about custom post !
    You can add a new custom post type called "Free"

    Exemple :

    <?php
       $value = get_post_meta($post->ID, "prices", true);
       echo $value;
    ?>">Price :
    <?php
       $value = get_post_meta($post->ID, "free", true);
       echo $value;
    ?> FREE !!

    The better way : you can also add a tag "free" to every post/product free.
    And display it with :

    <?php if (has_tag('free')) : ?>FREE
    <?php elseif (has_tag('paid')) : ?>Delivrey cost 5$
    <?php endif; ?>

Reply

You must log in to post.

About this Topic