cabrerahector/wordpress-popular-posts

FR: Wrap output render into a block with class, defineable in shortcode attribut

X-Raym opened this issue · 2 comments

X-Raym commented

Is your feature request related to a problem? Please describe.

Hi,

currently, the output of [wpp] isn't contained in a HTML block element,
so if you output header + list, these are just put inside the post content.
This prevent usage of some table of content plugin, for which we exclude certain class, and this makes theming a bit difficult.

Describe the solution you'd like

It would be nice if we could have a wrapper shortcode attribute to be able to say the tag and the classes in which we want the shortcode output to be encapsulated.

At minima, one class shortcode, and a wrapping inside basic divs.

Thx!

Hi @X-Raym,

The shortcode already provides three parameters specifically for this, namely wpp_start, post_html, and wpp_end (see Parameters. For your use case, the ones you need are wpp_start and wpp_end:

  • wpp_start sets the opening wrapper(s) for the popular posts list, by default it's <ul class="wpp-list">
  • wpp_end sets the closing wrapper(s) for the popular posts list, by default it's </ul>

If you wanted, for example, to wrap your popular post list in a <div> with some specific classes (eg. foo bar) then you can do something like this:

[wpp wpp_start='<div class="foo bar"><ul class="wpp-list">' wpp_end='</ul></div>']

Hope that helps!

X-Raym commented

@cabrerahector It does help thx a lot ! 😉 I somehow miss it in the doc, while searching for 'class' keyword