• Resolved stl99

    (@stl99)


    Hi there,

    Great plugin! I’m wondering if there’s a “simple” way to incorporate the popular posts feature into a WP query. Let’s say I’d like to show posts with my themes’ (StudioPress Genesis) regular archive layout, is there something I could use to only show posts from the last 24 hours sorted by the most popular (based on WPP’s date)?

    Right now I’m using a custom template with the various WPP shortcodes but it sometimes breaks, e.g. when there’re YouTube or similar embed codes included in the content part used for the excerpt.

    Cheers,
    Thomas

    https://www.ads-software.com/plugins/wordpress-popular-posts/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi Thomas!

    Check this, it might be what you’re looking for (or at least help you get started).

    Right now I’m using a custom template with the various WPP shortcodes but it sometimes breaks, e.g. when there’re YouTube or similar embed codes included in the content part used for the excerpt.

    What exactly happens? How does it break? I’m curious.

    Thread Starter stl99

    (@stl99)

    Hi Hector,

    Thanks! I might keep my current version though as it seems a bit more flexible. Here’s what I use:

    $post_html = '<h3><a class=\'weekly-popular-list\' title=\'{text_title}\' href=\'{url}\'>{text_title}</a></h3>{thumb}{summary} <a href=\'{url}\'>Read more ?</a>';
    
    	ob_start();
    	wpp_get_mostpopular('range=weekly&post_type=post,content,guide,review&freshness=1&limit=20&wpp_start="<div class=\'weekly-popular-posts\'>"&wpp_end="</div>"&post_html="'.$post_html.'"&excerpt_length=80&excerpt_by_words=1&thumbnail_width=740&thumbnail_height=425');
    	$output = ob_get_clean();
    
    	$output = str_replace( 'class="wpp-thumbnail wpp_imgeditor_thumb wpp_featured', 'class="alignleft post-image entry-image', $output );
    
    	$output = $intro_html . "\n" . $output;

    If a post excerpt has a YouTube embed code included it breaks the output for some reason. Also sometimes accidentally added characters do the same as well as changes to the WPP code (e.g. to the image classes).

    Using the regular archives and excerpts would make things a lot easier and reliable, that’s why I hoped there would be a “simple” solution to use WPP to query & sort by a specific time window….

    Cheers,
    Thomas

    Thread Starter stl99

    (@stl99)

    BTW: the function to add a view count to posts for a specific interval looks promising. As stated it’s probably not the ideal solution for high traffic sites. I hoped that you could access the WPP data for that purpose…

    Cheers,
    Thomas

    Plugin Author Hector Cabrera

    (@hcabrera)

    Alright, I’ll look into the Youtube issue as soon as I can.

    Using the regular archives and excerpts would make things a lot easier and reliable, that’s why I hoped there would be a “simple” solution to use WPP to query & sort by a specific time window….

    This is the closest thing to what you’re looking for. With some extra tweaks, it could also list popular posts from a given time range.

    Thread Starter stl99

    (@stl99)

    Thanks!

    Cheers,
    Thomas

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Simple post/archive query (Genesis theme) with WPP data possible?’ is closed to new replies.