Custom taxonomy terms in widget
-
Hi, Héctor!
Thank you for the awesome plugin! It works perfect as it is and your FAQ section is very detailed and helpful! But I’m trying to move to the next level and I can’t do it on my own =(
So what I want is to display widget this way: thumb + title + stats (pageviews and comments for 2 different sidebars) + custom taxonomy terms.
What I did: on Monday I tried your advice from this thread with old version of plugin, and I managed to get nedeed data, but it was displayed outside of
<ul></ul>
tags.
Yesterday I updated WPP and tweaked the code from Filters on the Wiki, but my custom taxonomy terms are outside of list again =(Here is my code:
/// get custom taxonomy using the post ID outside the loop. function get_year_by_id($post_id){ $the_post = get_post($post_id); $terms = the_terms( $the_post, 'god', ' ', ', ', ' ' ); return $terms; } /// add 'year' to WPP widget function my_custom_popular_posts_html_list( $mostpopular, $instance ){ $output = '<ul class="wpp-list">'; foreach( $mostpopular as $popular ) { $output .= "<li><a href=\"" . get_the_permalink( $popular->id ) . "\" title=\"" . esc_attr($popular->title) . "\"><br>{$popular->title}</a> <span class=\"wpp-stats\">{$popular->pageviews}</span>" . get_year_by_id( $popular->id ) . "</li>" . "\n"; } $output .= '</ul>'; echo $output; } add_filter( 'wpp_custom_html', 'my_custom_popular_posts_html_list', 10, 2 );
Could you please take a look and tell me if there’re any mistakes or is it simply not possible to make custom tax terms appear inside of the list?
Regards,
Helenhttps://www.ads-software.com/plugins/wordpress-popular-posts/
- The topic ‘Custom taxonomy terms in widget’ is closed to new replies.