Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Ajay

    (@ajay)

    Could you please clarify what you question is?

    Hi Ajay,
    I am not sure about that, but I think he needs the same thing as me.

    I would like to display the category of each element of the top list next to the title.
    On the widget, I see that I can display the author, the date or the excerpt. It’s really good, but there is a way to display the post/page category?

    I would prefer not editing your code, but I can do it if needed.

    You can see how my plugin looks now here: http://www.acordscatala.cat/ (on your right, “Cançons més populars”)

    Thank you very much,

    noobhome

    Plugin Author Ajay

    (@ajay)

    Hi,

    right now you could create a filter function that filters ‘tptn_before_list_item’ that could help you add the category.

    You’ll find it defined on line 420 of top-10.php

    https://plugins.trac.wordpress.org/browser/top-10/trunk/top-10.php#L420

    Alternatively, filter tptn_after_list_item

    I’m sorry but I’m not sure about how to do that. How can I exactly use that function so that I can display the category?

    (Sorry for my low level, I don’t have much experience yet).

    Thank you,
    noobhome

    Plugin Author Ajay

    (@ajay)

    You need to add a function like this to your functions.php of your theme file.

    function filter_tptn_after_list_item( $after_list_item, $ID ) {
    
    $categories = get_the_category( $ID );
    
    $output = '';
    $separator = ' ';
    
    if ( $categories ) {
    	foreach( $categories as $category ) {
    		$output .= '<a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
    	}
    }
    
    return $output.$after_list_item;
    
    }
    apply_filters( 'tptn_after_list_item' , 'filter_tptn_after_list_item', 10, 2);

    Ok, done!

    Then, with this function added, where and what should I insert in the plugin?

    I mean, in the plugin options –> Output options –> HTML to display after each element of the list?

    Or in the custom css?

    Sorry I’m still a beginner…
    Thank you very much again

    Plugin Author Ajay

    (@ajay)

    Custom CSS is for any styles you want to add.

    The function above should be sufficient to display the categories. Please note I haven’t had a chance to test it yet.

    I introduced the function above to my functions.php, but nothing happened.

    I tried to F5 and Cntrl+R. Do I need to change something in the code above? I’m a bit frustated with that!

    Thanks

    Please, I insist if you could help me with that as it’s quite important for my website. I manage good enough with styles but I have problems in this kind of things.

    I added the function but nothing happens.

    I also use custom fields (Types plugin) for each page. There is a field which is always exactly the same as the category, so I could also make the list get that field instead of the category, if it is easier, but I don’t know how too.

    Thank you very much… I would really apreciatte if you could spend 5 minutes with this.

    Plugin Author Ajay

    (@ajay)

    Hi, it’s definitely more than 5 minutes of work on this one.

    I will need to look at this in detail since it isn’t a quick integration solution.

    Also, i am not in a position to provide support on the integration with Types plugin and custom fields it adds, unless for sure there is a standard approach that it produces.

    Any news about this? It’s very important for me, so I’m looking forward to finding a solution.

    Thank you.

    Plugin Author Ajay

    (@ajay)

    Hi,

    I haven’t found a solution for this yet. I’m also not in a position to replicate your site structure or the Types plugin outputs which makes it very difficult to test.

    I can try to find a generic solution, but, it won’t be easy.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Modify Output Include Cat Name Above Title…’ is closed to new replies.