Get a page ancestor from a most viewed list

get_ancestors will return array form value. So if you talking about how to get and display that ancestors with link: <?php $arrAncestors = get_ancestors( $post->ID, ‘page’); $cntAncestors = COUNT($arrAncestors); if($cntAncestors > 0) { $parentPostId = $arrAncestors[$cntAncestors – 1]; $parentPageLink = get_permalink($parentPostId); $parentTitle = get_the_title($parentPostId); print ‘<li><a href=”https://wordpress.stackexchange.com/questions/243836/<?php $parentPageLink ?>” title=”<?php $parentTitle; ?>”><?php $parentTitle; ?></a></li>’; } … Read more

How to Display Most View Post in the template file?

The function getPostViews() is retrieving the total number of views for each post while setPostViews() increases the post views counter each time post is viewed. You need to call setPostViews() somewhere in your single.php and then use below code to retrieve posts on basis of posts view count. $args = Array( ‘post_type’ => ‘post’, ‘posts_per_page’ … Read more

Popular Post By Month in WordPress

I’ve tested your code on my installation and it is working just fine. So the code in not an issue. There are two possible reasons why this is not showing any posts. 1) You do not have any posts for that month 🙂 2) You haven’t any metadata ‘wpb_post_views_count‘ in database so it returns nothing. … Read more

popular post for week and month

Unless you’re storing that data, you can’t. It looks like posts_views_count is just a running total, so unless you’ve stored per month/week data, it simply does not exist. What’s more, you’re storing that data in a post meta value, which has a lot of performance and accuracy problems. It’s: incompatible with any form of page … Read more

How to display the top 5 popular links in the header?

Put this in your functions.php file function k99_post_hits( $id, $action ) { $dl_HitMetaField = ‘_dl_post_hits’; // hidden Custom field that stores the views $dl_PostHits = get_post_meta($id, $dl_HitMetaField, true); switch ($action) { case ‘count’ : if ( $dl_PostHits ==” ) { $dl_PostHits = mt_rand(10,20);//just for debug-test – remove for real count delete_post_meta( $id, $dl_HitMetaField); add_post_meta( $id, … Read more

Get the most commented posts for the last x days

You can do this using the orderby parameter of WP_Query. If you set it to comment_count, you can get the most popular. You will probably need to filter the WHERE parameter to set your date on the query (unless you want the last week or the last month or something simple like that) though.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)