Customising HTML
-
Hi,
Is there any other tutorials for customising HTML output of the WP Popular Posts plugin?
I am trying to achieve a certain style’ but I am having some trouble.
Essentially, the HTML output should be nice and simple like this.
<ul> <li> <a href="https://link-to-the-popular-post"><img src="show the thumbnail image in a predefined size 180x85"><span>The title of the popular post</span></a> </li> </ul>The list of posts should look something like this https://imgur.com/CmKwAQ7
I did take a look at the filters tutorial, but that is way too complex and way too much code for what I need and it doesnt show how to get the thumbnail to display.
I also read the grid of popular posts tutorial, not exactly what I am looking for but possibly could be altered.
Is there any other tutorials to try and get what I am looking for?
Thanks.
-
Customizing the HTML output of the widget is quite simple, actually.
For a simple HTML markup like the one you posted above, using the widget’s built-in features is enough:
- Go to Widgets and expand the WordPress Popular Posts widget to access its settings.
- Under Posts settings, enable the Display post thumbnail checkbox and hit the Save button to apply changes. Then, set your desired thumbnail’s width & height.
- Under HTML Markup settings, enable the Use custom HTML Markup checkbox and hit the Save button to apply changes.
- Set the Before / after Popular Posts fields to
<ul>and</ul>, respectively. - Set the Post HTML Markup field to:
<li> <a href="{url}">{thumb_img}<span>{text_title}</span></a> </li>Notice the use of Content Tags (
{url},{thumb_img}and{text_title}). Find more via Settings > WordPress Popular Posts > Parameters, under post_html. - Finally, hit the Save button once again to apply changes.
Hi,
super fast support and a perfect solution as always.
Your code worked like a charm.
Thank you.
Don’t mention it. Glad I could help 🙂
The topic ‘Customising HTML’ is closed to new replies.