• Resolved dinesh786

    (@dinesh786)


    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

Viewing 14 replies - 16 through 29 (of 29 total)
  • I think it’s related to the way you are writing the urls.

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

    Thread Starter dinesh786

    (@dinesh786)

    Thank you so much for help me sir

    Thread Starter dinesh786

    (@dinesh786)

    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:

    https://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

    Thread Starter dinesh786

    (@dinesh786)

    Can I redirect it to this format (https://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?

    No, that’s a wrong approach.

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

    Thread Starter dinesh786

    (@dinesh786)

    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’ );
    ?>

    Thread Starter dinesh786

    (@dinesh786)

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

    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:

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

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

    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.

    Thread Starter dinesh786

    (@dinesh786)

    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

    Thread Starter dinesh786

    (@dinesh786)

    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?

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

    Thread Starter dinesh786

    (@dinesh786)

    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:)

    Thread Starter dinesh786

    (@dinesh786)

    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)

Viewing 14 replies - 16 through 29 (of 29 total)
  • The topic ‘How can I display all categories added under my custom taxonomy’ is closed to new replies.