• Resolved Xaib Aslam

    (@lahorimela)


    Hello i have created a CPT with name of names then i create taxonomy with name of christian_boy_names hierarchical is False.

    So now i open any value taxonomy, it will open a page with link https://mydomain.com/names/christian/boy/michael

    So i want show this kind of thing on Michael page.

    Siblings of that name (10 names)
    Similar of that name (10 names)
    Starting names with M (10 names)

    Can you help me to give me an example code.

    Regards

    • This topic was modified 1 year, 11 months ago by Xaib Aslam.
Viewing 15 replies - 16 through 30 (of 37 total)
  • Thread Starter Xaib Aslam

    (@lahorimela)

    and any about this thing…

    ok, I want to know how I can add PHP code inside this code…

    taxonomy' => 'christian_boy_name', 
    'hide_empty' => false, 
    'order' => 'ASC

    Like this…

    taxonomy' => '<?php echo ($row->name_religion); ?>_boy_name', 
    'hide_empty' => false, 
    'order' => 'ASC'
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I think you figured out the previous issue, I’m not sure what you’re trying to do with the new issue with the taxonomy specifying and hide_empty and order.

    I’m guessing you’re trying to query for all terms in a given taxonomy to use somehow?

    Thread Starter Xaib Aslam

    (@lahorimela)

    Yes, thankyou for the previous issue.
    I am trying to do that…

    <?php $alphabets = get_terms( array('taxonomy' => 'christian_alphabets', 'hide_empty' => false, 'order' => 'ASC') );foreach ($alphabets as $alpha) { ?>
        <a href="https://lahorimela.com/names/christian-names-starting-with/<?php echo strtolower ($alpha->name); ?>/">
          <?php echo $alpha->name ?>
        </a>
    <?php } ?>

    I just want to make it a little dynamic, so in taxonomy => want to add PHP code echo $row->name_religion so how is it possible?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Pretty much the way you’ve tried already. The question I’d be asking is are you getting term results returned, and if not, is your $row-name_religion matching what you’re expecting, or is it off somehow. If off, where else in your code can you fetch the intended dynamic part.

    Thread Starter Xaib Aslam

    (@lahorimela)

    Hello,
    ok, let me explain more…

    this code is working perfectly.

    <?php $alphabets = get_terms( array('taxonomy' => 'christian_alphabets', 'hide_empty' => false, 'order' => 'ASC') );foreach ($alphabets as $alpha) { ?>
        <a href="#"><?php echo $alpha->name ?></a>
    <?php } ?>

    Now I want to add PHP add inside this code… what I want to change see this code…

    <?php $alphabets = get_terms( array('taxonomy' => '<?php echo $row->name_religion ?>_alphabets', 'hide_empty' => false, 'order' => 'ASC') );foreach ($alphabets as $alpha) { ?>
        <a href="#"><?php echo $alpha->name ?></a>
    <?php } ?>

    As you can see that I change christian_alphabets and I add PHP code <?php echo $row->name_religion ?>_alphabets to show the value christian. please see the part taxonomy =>

    In order to add this type of code inside the PHP code, as described above, I need to add it inside the PHP code.

    Also, I am trying to add like this…
    get_terms( array('taxonomy' => ". $row->name_religion ._alphabets", 'hide_empty' => false

    Thread Starter Xaib Aslam

    (@lahorimela)

    OK I figured put the solution…

    thanks

    array('taxonomy' => ''.strtolower ($row->name_religion).'_alphabets', 'hide_empty' => false

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I’m pretty sure you were doing a bit too much with your earlier attempts, this should have been enough:

    <?php
    $alphabets = get_terms(
        array(
            'taxonomy' => strtolower( $row->name_religion ) . '_alphabets',
            'hide_empty' => false,
            'order' => 'ASC'
        )
    );
    foreach ($alphabets as $alpha) { ?>
        <a href="#"><?php echo $alpha->name ?></a>
    <?php
    }
    

    I mixed part of the 2nd to last reply with the strtolower usage.

    Thread Starter Xaib Aslam

    (@lahorimela)

    Thank you very much, Michael. Please accept my apologies for asking questions outside the box. It’s just that I need such a small piece of code. My first step is to do lots of research before I ask the question. I ask you guys if I am unable to find the answer.

    Even I am working on CPT first time.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

    Thread Starter Xaib Aslam

    (@lahorimela)

    this code working fine.
    $sql = "SELECT * FROM wp_names_christian WHERE name_english LIKE ?";

    When I add more tables it is not working. I do multiple examples but failed.

    $sql = "SELECT * FROM wp_names_christian, wp_names_muslim, wp_names_hindu WHERE name_english LIKE ?";

    $sql = "SELECT * FROM wp_names_christian UNION ALL wp_names_muslim UNION ALL wp_names_hindu WHERE name_english LIKE ?";

    $sql = "SELECT * FROM wp_names_christian CROSS JOIN wp_names_muslim CROSS JOIN wp_names_hindu WHERE name_english LIKE ?";

    Also, try some other stuff, can you help me that what I am doing wrong?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not sure what to tell you with that part and what needs to be changed. Sorry. This has also evolved beyond the scope of the parts that CPTUI functionality centers around.

    Thread Starter Xaib Aslam

    (@lahorimela)

    Ok and can you help me with the VIEWS counter system, how we can implement the views system in CPT?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    At best we can attempt to help point you in correct directions, or quickly brainstorm on a possible way how to do something, but we can’t help actually implementing the ideas every step of the way.

    CPTUI isn’t an end-all be-all solution for how people use content types, but we can be a solution in at least getting the content types registered and ready for usage and display.

    Thread Starter Xaib Aslam

    (@lahorimela)

    Actually, I am trying to add this but it’s not working.

    function wpb_get_post_views($postID){
        $count_key = 'wpb_post_views_count';
        $count = get_post_meta($postID, $count_key, true);
        if($count==''){
            delete_post_meta($postID, $count_key);
            add_post_meta($postID, $count_key, '0');
            return "0 View";
        }
        return $count.' Views';
    }

    <?php echo wpb_get_post_views(get_the_ID()); ?>

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not working in what way? If you’re in the loop, are you actually passing in a post ID to the function? Or are you passing in an empty value? what does $count initially read after your get_post_meta? is it returning anything?

Viewing 15 replies - 16 through 30 (of 37 total)
  • The topic ‘How to get list custom taxonomy’ is closed to new replies.