How get the 10 most viewed pages (not post)

If you want to query pages you have to choose post_type=page – of course. Another “problem” is that the commen count isn’t exactly representing post/page views. If you really want page views – not comment count – try something like the function below – I got that from here: http://wpsnipp.com/index.php/functions-php/track-post-views-without-a-plugin-using-post-meta/. function getPostViews($postID){ $count_key = ‘post_views_count’; … Read more

Create custom post order (with custom post type meta)

Save your data in a single field as either YYYY-MM-DD or UNIXTIME. Then query like this: $args = array( ‘post_type’ => ‘POST_TYPE_NAME’, ‘meta_key’ => ‘date-key-name’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ); $query = new WP_Query( $args ); You should get an order, unless I am having a bad morning, of Day -> Month -> … Read more

My Query is getting the wrong data

$the_args = array ( ‘post_type’ => ‘jobs’, the_field(‘job_category’) ); The trouble here is that the_field( ‘job_category’ ) prints data, so using it to build an array is pretty much useless. You’re left with literally post_type = job. However, the real problem is that you actually need to grab the category options, not the posts that … Read more

the_post_thumbnail unless video id is added

I think all you need is this: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> if (get_field(‘channel’) == ‘Youtube’) { echo get_field(‘youtube_video_id’); } elseif (get_field(‘channel’) == ‘Vimeo’) { echo get_field(‘vimeo_video_id’); } elseif ( has_post_thumbnail()) { the_post_thumbnail(); } That should use a Youtube video, then a Vimeo video, then the thumbnail, … Read more

Nested loop called with shortcode duplicating the content above the main loop

You have few errors in your code. Below you can see how it should look like: function cd_random_testimonial($atts) { // EXAMPLE USAGE: // [loop the_query=”showposts=1&post_type=testimonials&orderby=rand”] // Defaults extract(shortcode_atts(array( ‘the_query’ => ” ), $atts)); // de-funkify query $the_query = preg_replace(‘~&#x0*([0-9a-f]+);~ei’, ‘chr(hexdec(“\\1”))’, $the_query); $the_query = preg_replace(‘~&#0*([0-9]+);~e’, ‘chr(\\1)’, $the_query); // query is made $my_query = new WP_Query( $the_query … Read more

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