How to display pending posts on the homepage only for editors

I would filter pre_get_posts. function allow_pending_posts_wpse_103938($qry) { if (!is_admin() && current_user_can(‘edit_posts’)) { $qry->set(‘post_status’, array(‘publish’,’pending’)); } } add_action(‘pre_get_posts’,’allow_pending_posts_wpse_103938′); That should show pending posts to your editors for all of your queries on the front end. You can, of course, restrict is more if you’d like. I’d add some code to mark the pending posts so your … Read more

Exclude page name from loop

An alternative way is putting the unwanted pages in an array. Useful for storing them in a option or in a serialized custom field. $exclude_pages = array(‘music’, ‘contact’); // can be something like this: $exclude_pages = get_option(‘exclude_pages’); if ( have_posts() ) : while ( have_posts() ) : the_post(); if ( is_page() && ! empty($exclude_pages) && … Read more

Unable to change the “Read more” text inside the_excerpt

Try making the post object accessible using global and use get_permalink($post->ID) function new_excerpt_more( $more ) { global $post; return ‘<a class=”read-more” href=”‘. get_permalink($post->ID) . ‘”>Custom text</a>’; } add_filter( ‘excerpt_more’, ‘new_excerpt_more’ ); Ensure the code is in your functions.php file.

Get 1 more post in loop

You should probably add a meta query to your WP_Query() args: $loop = new wp_query( array( ‘posts_per_page’ => 3, // Meta Query ‘meta_query’ => array( array( ‘key’ => ‘skip_me’, ‘value’ => ‘true’, ‘compare’ => ‘!=’ ) ) ) ); Or you could perhaps go with the simpler version in this case: $loop = new wp_query( … Read more

Single.php different behaviour from admin to non-admin

Per a comment, the problem was due to the use of query_posts which clobbers the main query. Please don’t use query_posts. It should be noted that using this to replace the main query on a page can increase page loading times, in worst case scenarios more than doubling the amount of work needed or more. … Read more

why does wordpress ignore the post args?

There is no category argument: cat (int) – use category id. category_name (string) – use category slug (NOT name). category__and (array) – use category id. category__in (array) – use category id. category__not_in (array) – use category id. You want to be using the category_name argument– note that it takes the slug not the name–, though … Read more

Tag page only display 10 posts

The problem is query_posts(). It is stomping on the default query, and killing your pagination. Don’t use query_posts(). Filter $wp_query at pre_get_posts instead: function wpse123674_pre_get_posts( $query ) { // Only modify the main query on the tag archive index if ( $query->is_main_query && $query->is_tag() ) { $query->set( ‘post_type’, array(‘post, cool_tools, tribe_events’) ); } } add_action( … Read more