WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How can I display all categories added under my custom taxonomy (30 posts)

  1. dinesh786
    Member
    Posted 1 year ago #

    Hello All,

    I registered my custom taxonomy 'topic' and added categories in that

    register_taxonomy('topic', 'post',
     			array('hierarchical' => true, 'label' => 'Topic', 'query_var' => true, 'rewrite' => true )
    		);

    Now how can I display those categories those added under topic from backend.

    Thanks a lot in advance for for help me

  2. David Beja
    Member
    Posted 1 year ago #

    To list all categories from topic taxonomy:

    <ul>
    <?php wp_list_categories( 'taxonomy=topic' ); ?>
    </ul>

    If you want to show all the categories, even the ones that are empty add the parameter hide_empty=0.

    More details here: WP List Categories

  3. dinesh786
    Member
    Posted 1 year ago #

    Thanks for reply dbeja,

    But it display "No categories"

  4. dinesh786
    Member
    Posted 1 year ago #

    Thank a lot dear dbeja,

    Its working fine

    I missed hide_empty=0. in hurry

    Thanks again

    [ Signature moderated and please do not post your email address on the forums. ]

  5. dinesh786
    Member
    Posted 1 year ago #

    Now its displaying all my terms under Topic taxonomy
    like:

    Topic1
    Topic2
    Topic3

    and its have links like /?taxonomy=Topic&term=topic1

    when categories display and we click on those, it take us to category.php and display posts of those categories.

    for custom taxonomy, how can we display post of that taxonomy term, when click.I created taxonomy.php in my theme, but not works,

    Please Help me!

    Thanks
    Dinesh

  6. David Beja
    Member
    Posted 1 year ago #

    yes, it should go to taxonomy.php.
    you can also create a taxonomy-topic.php, if you want to create a template only to topic taxonomy.

    What is happening? Nothing shows up or another template is being loaded?

  7. dinesh786
    Member
    Posted 1 year ago #

    Hi dbeja,

    it redirecting me on 404.php

  8. dinesh786
    Member
    Posted 1 year ago #

    I am using twentyten theme, should I change this theme for that?

  9. David Beja
    Member
    Posted 1 year ago #

    Do you have an url where I can see that?

  10. dinesh786
    Member
    Posted 1 year ago #

    sir now its on local,
    I upload it and give u url

  11. dinesh786
    Member
    Posted 1 year ago #

    Hi sir, I uploaded the site
    BUt I am showing another issue on server,

    http://client.ocularconcepts.us/welead/wp-admin

    in my local pc, not any problem
    please help me!

  12. David Beja
    Member
    Posted 1 year ago #

    You shouldn't never put you login here!!!
    It's a big risk... anyone can read this forum and do some harm to your site/server.

    Please change your password!

  13. dinesh786
    Member
    Posted 1 year ago #

    no problem, I have backup
    I will change pwd also

    u pl send ur mail id sir for next time if i have to send any confidental info,

    but sir pl check waht is the prob here

  14. David Beja
    Member
    Posted 1 year ago #

    About the other problem, if you're talking about the warning errors with the header, usually is because you have some extra spaces before an opening <?php tag or after a closing ?> tag. It generally happens in wp-config.php.

    Check this link: http://codex.wordpress.org/FAQ_Troubleshooting#How_do_I_solve_the_Headers_already_sent_warning_problem.3F

  15. David Beja
    Member
    Posted 1 year ago #

    About the other problem of the taxonomies, in what pages can I check that problem?

  16. dinesh786
    Member
    Posted 1 year ago #

    for Warnings: its also not allow me to edit or filter anything

    for taxonomy: http://client.ocularconcepts.us/welead/category/resource_library/articles/

    this is the page
    in right side bar under the "Filter by Topic" showing all terms of topic.

    I have one post under the "Employee motivation" term

  17. David Beja
    Member
    Posted 1 year ago #

    I think it's related to the way you are writing the urls.

    The links of the topics should be somethink like this:
    http://client.ocularconcepts.us/welead/topic/personal-leadership/

  18. dinesh786
    Member
    Posted 1 year ago #

    Thank you so much for help me sir

  19. dinesh786
    Member
    Posted 1 year ago #

    Great Sir!

    But can we set this type of url
    I used code for display theses

    wp_list_categories( 'taxonomy=topic&hide_empty=0&title_li=&orderby=id' );

    my permalinks setting checked Post name:

    http://client.ocularconcepts.us/welead/sample-post/

    if I checked custom structure and save it, it will again select Post name.

    and I added a taxonomy.php in my theme

  20. dinesh786
    Member
    Posted 1 year ago #

    Can I redirect it to this format (http://client.ocularconcepts.us/welead/topic/personal-leadership/)
    in 404.php using those term name i geeting in url?

    Is it the right way?, i think its not, but can I do this?

  21. David Beja
    Member
    Posted 1 year ago #

    No, that's a wrong approach.

    Where did you define the function wp_list_categories? In what file?

  22. dinesh786
    Member
    Posted 1 year ago #

    Sir I defined in resourcesidebar.php, in theme twentyten

    using

    Filter By Topic
    <ul class="search-category">
    <?php
    wp_list_categories( 'taxonomy=topic&hide_empty=0&title_li=&orderby=id' );
    ?>

  23. dinesh786
    Member
    Posted 1 year ago #

    resourcesidebar.php is included in my category.php that displaying articles

  24. David Beja
    Member
    Posted 1 year ago #

    it seems the problem is that wp_list_categories is writing the taxonomy name with the first letter capitalized. If it's not capitalized it works ok:

    http://client.ocularconcepts.us/welead/?taxonomy=topic&term=employee-motivation

    But I don't understand why it's happening.

  25. David Beja
    Member
    Posted 1 year ago #

    Try to remove the the query_var parameter when you are registering the topic taxonomy.

    The possible values of query_var should be false or a string.
    If you don't define query var it defaults to taxonomy's name.

  26. dinesh786
    Member
    Posted 1 year ago #

    Ok Sir, I am trying,

    But I am very thanks full to you for help me,
    You are such a nice person,

    Thanks a lot.
    I am leaving office, meet tomorrow thanks :)
    fb.com/dks786

  27. dinesh786
    Member
    Posted 1 year ago #

    Hi Sir, Good Morning,

    $args=array(
      'orderby' => 'name',
      'order' => 'ASC',
      'taxonomy' => 'topic',
      'hide_empty' => 0
      );
    
    $categories=get_categories($args);
    
    foreach($categories as $category) {
    echo '<li><a href="'.get_bloginfo('url').'/topic/'.$category->slug.'">'.$category->name.'</a></li>
    ';
    }

    I am using this code for display taxonomy.

    If I want to display articles post those also associated with Topics (from custom taxonomy)

    can we give the custom url for that using above code method and redirect to category page with term ID and display articles of that term ID.
    (Means pass the term id in url and display articles of that topics)

    Is it correct way to doing this, or any other method?

  28. David Beja
    Member
    Posted 1 year ago #

    yes, you could do like that. it should work.
    but did you try also to remove the query_var parameter?

  29. dinesh786
    Member
    Posted 1 year ago #

    Yes sir, I tried this
    I removed the query_var from register_taxonomy
    and I also tried to make query_var false but didn't work, and its showing the same result as previous with first letter Caps of taxonomy etc

    Thanks Sir:)

  30. dinesh786
    Member
    Posted 1 year ago #

    Sir,

    but when we clicked on any topic its display that topic as heading
    and did not activate the main navigation
    like article

    I wrote this for navigation

    $cat = get_the_category();
    $curr_cat = $cat[0]->cat_ID;
    
    $args = array(
    			'child_of' => '21',
    			'hide_empty' => 0,
    			'title_li'   => __( '' ),
    			'current_category' => $curr_cat,
    		);
    
    wp_list_categories($args);

    but i want when we are on article page and click on any topic, the article remain highlighted and display post of that article which have also selected that topic(that clicked)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.