cabrerahector / wordpress-popular-posts

WordPress Popular Posts - A highly customizable WordPress widget that displays your most popular posts.
https://wordpress.org/plugins/wordpress-popular-posts/
GNU General Public License v2.0
280 stars 82 forks source link

How to add attribute "theme" in shortcode wpp #382

Closed pojoksoft closed 5 months ago

pojoksoft commented 5 months ago

hi

i want to add theme "TIles" in shortcode. I try this but not working

[wpp header='Popular Posts' range='all' limit=5 stats_views=1 order_by='views' thumbnail_width=320 thumbnail_height=160 taxonomy=\'category\' theme='tiles']

and for HTML markup in "Before / after title" & "Before / after Popular Posts" I also couldn't find a way to add the shortcode

thank you

cabrerahector commented 5 months ago

Hi @pojoksoft,

The shortcode doesn't have a theme parameter as using themes with it isn't technically possible - at least not in the same way as you could with, for example, the WPP block or the classic widget.

To replicate the "Tiles" theme with the shortcode you would need to use the following parameters (in addition to the ones you already have):

So your shortcode would look something like this now:

[wpp header_start='<h2 class="widgettitle">' header='Popular Posts' header_end='</h2>' range='all' limit=5 thumbnail_width=320 thumbnail_height=160 stats_category=1 wpp_start='<ul class"wpp-list wpp-tiles">' post_html='<li class="{current_class}">{thumb}<div class="wpp-post-data">{taxonomy} {title}</div></li>' wpp_end='</ul>']

That would take care of the HTML side of things.

You also need to add Tiles' CSS rules to your theme as well, either via Appearance > Customize > Additional CSS or by adding these CSS rules to your theme's stylesheet.