Display all existing members

You can use get_users(). $args = array( ‘fields’ => ‘all_with_meta’, ); $users = get_users( $args ); foreach( $users as $user ) { // your display code here var_dump( $user ); // so you can see what’s in $user } all_with_meta will get the user and all the associated meta, if I’m reading the Codex page … Read more

trying to write a variable into a wp_query, need help!

Using get_posts(): <?php $category = get_category_by_slug($post->post_name); $template = $category->term_id; $taskarr = array( ‘post_type’ => ‘listing’, ‘post_status’ => ‘publish’, ‘category’ => $template, ‘order’ => ‘ASC’, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘listing_date’ ); $tasks = get_posts($taskarr); foreach( $tasks as $task ) { echo ‘<li>’; echo $task->post_title; echo $task->post_excerpt; echo get_post_meta( $task->ID, ‘location’, ‘single’); echo ‘<li>’; } ?> … Read more

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