Forum Replies Created

Viewing 10 replies - 16 through 25 (of 25 total)
  • Hope it isn’t… of all the FAI plugins out there, only this one (so far) lets you select which posts to publish or not publish and my employers need/want that. There was a bug fix due over a week ago back when updates came every 2-3 days. So, hoping they got busy with stuff and they’ll be back shortly…

    Meanwhile, I’m off to start coding my own because we can’t wait.

    Thread Starter andyaffleck

    (@andyaffleck)

    Weird… our dev site (same content, if a bit older as the database dump is from a few months back) is now working (showing article content) but the production site still isn’t. So, maybe it’s a fluke and we still need to wait 2-3 days for the code that really fixes this. Thanks

    -A

    Thread Starter andyaffleck

    (@andyaffleck)

    It seems to be already fixed in the update you just pushed in the last hour or so!

    I’m getting duplicate images (the first paragraph of each post is an image) but that’s more our problem than yours and I understand from another post you’ve made elsewhere that a feature to NOT include the featured image is in the works…

    Anyway, thanks!!!

    -A

    Thread Starter andyaffleck

    (@andyaffleck)

    Upgraded to the latest version and also installed it on our a secondary server (running the same content/theme) and same problem. The RSS feed has everything you’d expect except the article content. The small mobile preview next to the article also does not show the article. Just the header, image, title, and the share button.

    If I can provide any further info, let me know.

    Thread Starter andyaffleck

    (@andyaffleck)

    The only error appearing is:

    PHP Warning: DOMDocument::saveHTML() expects exactly 0 parameters, 1 given in /var/www/vhosts/thepoliticalinsider.com/wp-content/plugins/pagefrog/admin/class-pagefrog-instant-articles-parser.php on line 977

    I should note that AMP articles DO have the article content. So it’s not a question of Pagefrog not being able to see/find it. AMP has the article content and FIA doesn’t.

    Thanks again

    -A

    Thread Starter andyaffleck

    (@andyaffleck)

    Cloudflare is fully set up per their instructions (and has been for over a year). So that should not be an issue.

    As for logs, there is nothing showing up in apache, nginx, or varnish logs having anything to do with the plugin.

    -A

    I do. The query-build part is from someone else (and right now my mind is blanking on whether it was a consultant we’d hired or something I’d found online). I stripped it down (it was much longer and complicated) and added in the bit at the end where I build the array of the IDs in order (#2 in my earlier post). It includes the capability of time boxing the results though I currently only use it for all posts on my sites.

    function get_popular_post_ids($args) {
    
    	global $wpdb;
    	$prefix = $wpdb->prefix . "popularposts";
    	$where = "";
    	$now = current_time('mysql');
    
    	/* Build the Query */
    	$fields = "p.ID AS 'id', p.post_title AS 'title', p.post_date AS 'date', p.post_author AS 'uid', v.pageviews AS 'pageviews'";
    
    	$from = "{$prefix}data v LEFT JOIN {$wpdb->posts} p ON v.postid = p.ID";
    
    	switch( $args['range'] ){
    		case "yesterday":
    			$where .= " AND p.post_date > DATE_SUB('{$now}', INTERVAL 1 DAY) ";
    			break;
    
    		case "daily":
    			$where .= " AND p.post_date > DATE_SUB('{$now}', INTERVAL 1 DAY) ";
    			break;
    
    		case "weekly":
    			$where .= " AND p.post_date > DATE_SUB('{$now}', INTERVAL 1 WEEK) ";
    			break;
    
    		case "monthly":
    			$where .= " AND p.post_date > DATE_SUB('{$now}', INTERVAL 1 MONTH) ";
    			break;
    
    		default:
    			$where .= "";
    			break;
    	}
    
    	$where .= " AND p.post_type = 'post'";
    	$where .= " AND p.post_password = '' AND p.post_status = 'publish'";	
    
    	$orderby = "ORDER BY pageviews DESC";
    
    	$query = "SELECT {$fields} FROM {$from} {$where} {$orderby};";
    
    	$result = $wpdb->get_results($query);
    
    	$counter = 0;
    	$myIDs = array();
    
    	foreach ($result as $aPost) {
    		$theID = $aPost->id;
    
    		if ( !$theID == "" ) {
    			$myIDs[$counter] = $theID;
    			$counter++;
    		}
    	}
    
    	return($myIDs);
    }

    Hope this helps!

    I ended up doing the following:

    1. Build a query (similar to the two previous posts) that grabs the N most popular posts (in descending order).
    2. Loop through the results and build an array that is just those IDs in order
    3. Pass those ids into a WP_Query as follows:
      $args = array(
      	'order' => 'DESC',
      	'orderby' => 'post__in',
      	'post__in' => $popularIDs, // my array of IDs
      );
      $posts_query = new WP_Query($args);
    4. Then I can do the usual WP Loop fun with the returned posts. The key is keeping them in order by using the proper orderby argument above (post__in).

    I was just coming here to search for this exact thing. So, I second this!

    Thread Starter andyaffleck

    (@andyaffleck)

    Ah! It didn’t even occur to me to look and see if was an actual page set up IN wordpress. I just assumed it was outside of the CMS.

    In the end, I fixed it by changing the items tracked from post,page to just post. (We don’t care about page views, just post views).

    But thanks!

    -A

Viewing 10 replies - 16 through 25 (of 25 total)