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

Can't get embed videos/pictures to show #351

Closed peq42 closed 1 year ago

peq42 commented 1 year ago

Can't get videos embed in the post(youtube) and pictures posted in the middle to show on the list

Steps to reproduce it

  1. Make a post
  2. Gets popular and goes to the list
  3. Doesn't show pictures or embed videos

Expected behavior

Obvious

Environment

cabrerahector commented 1 year ago

Hi @peq42,

Out of the box, WordPress Popular Posts doesn't show video embeds though so I'm not sure what's this "obvious" expected behavior :P

So, how do I reproduce this issue exactly? Are you using some custom code with your popular posts list?

peq42 commented 1 year ago

Oh I'm sorry, thought it was supposed to show embed vids and pictures by default.

Any way I could do it tho?

cabrerahector commented 1 year ago

Oh I'm sorry, thought it was supposed to show embed vids and pictures by default.

Where did you get that idea from? The plugin doesn't mention anywhere that it can show videos embeds. It's possible if you're familiar with WordPress & PHP development in general (see How can I use my own HTML markup with WordPress Popular Posts), however it's not a feature that the plugin offers out of the box. You'd need to code that in yourself and/or find someone to assist you with that.

As for pictures, yes, the plugin can show images related to each post, like Featured Images for example (see How does WordPress Popular Posts pick my posts' thumbnails? for more details.)

For your popular posts list to show thumbnails you first need to enable and configure all the related thumbnails settings, like so for example:

image

image

peq42 commented 1 year ago

Is there any way to display the post as "full" instead of excerpt or summary? I've another plugin that lists the newest posts in a separate page that have all those 3 options and when using "full" it works fine

again sorry, I'm a bit new to this

cabrerahector commented 1 year ago

Is there any way to display the post as "full" instead of excerpt or summary?

Yep, that's doable too. It's not a feature included with the plugin though but -as I suggested before- the plugin provides tools to customize the HTML markup of your popular posts so virtually anything you can think of is possible.

Have a look at the link I shared above to learn more about customizing your popular posts list and if you have any questions please feel free to ask.

peq42 commented 1 year ago

I tried looking into the documentation but i'm honestly lost..

I tried adding the following code to functions.php

function wpp_parse_fullhtml_in_popular_posts($html, $post_id) {

    if ( false !== strpos($html, '{posthtml}') ) {

            $html = str_replace('{posthtml}', $post_html, $html);

    }

    return $html;

}
add_filter('wpp_parse_custom_content_tags', 'wpp_parse_fullhtml_in_popular_posts', 10, 2);

Then made post HTML Markup into this:

<li class="{current_class}"><div class="wpp-item-data">{title}</div><div class="taxonomies">{taxonomy}</div><div class="wpp-item-data">{posthtml}</div> </li>

but now the post list is just, the title and that's it, its not incorporating the HTML/page content

cabrerahector commented 1 year ago

Hi @peq42,

Sorry for the late reply. I've been busy these days.

About your code, well, it doesn't seem to do anything? The $post_html variable isn't defined anywhere, but then you're trying to use it with str_replace()? Is this your complete code?