How to add posts to wp_query result?

Here’s a hack for the main post query in wp-admin that should do the trick: /** * Modification of the wp-admin main (post) query: * If current user has the “client” role then * show client’s posts OR posts where the “client” meta value is the client id. * * @see http://wordpress.stackexchange.com/a/173967/26350 */ function wpse_pre_get_posts( … Read more

How to get any tag ID

In your admin, go to Posts > Tags and then click edit for the tag you’re after – the URL in your browser address bar will look like: http://example.com/wp-admin/edit-tags.php?action=edit&taxonomy=post_tag&tag_ID=X&post_type=post See the part where tag_ID=X – that X is your tag ID.

Get attached media only

All media (somewhat incorrectly) in the $wpdb->posts table will be “attachments” whether actually attached or not. “Attachments” that are actually attached will have a post_parent other than 0, so what you need are all of the attachments that have a 0 in the post_parent column, if I understand you. $args = array( ‘post_type’ => ‘attachment’, … Read more

Finding the next 5 posts

The integral part is using a date_query in a custom WP_Query to fetch the adjacent posts according to the parameters passed to it. Here is an idea coming from a plugin I’m busy with To accomplish what you need, you’ll need the following The current post object to get the post_date and ID The categories … Read more

Thumb rating for wordpress – top user

there are varaiables in gd rating to sort query. you can use in URL like : http://www.gdstarrating.com/?gdsr_sort=rating&gdsr_order=desc http://www.gdstarrating.com/?gdsr_sort=review&gdsr_order=desc http://www.gdstarrating.com/category/tutorials/?gdsr_sort=votes&gdsr_order=asc or pass to a query query_posts(“gdsr_sort=rating”); query_posts(“gdsr_sort=review&sort_order=asc”); query_posts(“gdsr_sort=rating&gdsr_multi=3”); query_posts(“gdsr_sort=votes&sort_order=asc&gdsr_multi=3”); you can find more info here : http://www.gdstarrating.com/2009/07/03/how-to-reorder-posts/

Set div columns in a loop by post count

$post_count is a WP_Query variable. You need $the_query->post_count if( $the_query->have_posts() ): ?> <h1>Partners<h1><hr> <?php while( $the_query->have_posts() ) : $the_query->the_post(); if($the_query->post_count=1){ // … Otherwise it looks like it should work though I am not in a position to test this right now.

All sticky posts are returned in custom query

This is default behavior when the post__in parameter is used. If you read the docs, you will see that you should set ‘ignore_sticky_posts’ => 1 to eliminate sticky posts being queried EDIT Your query arguments should look like this $recommended_args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 3, ‘post__in’ => get_option(‘sticky_posts’), ‘orderby’ => ‘date’, ‘ignore_sticky_posts’ … Read more

Pagination not working on static page

Dear I have wasted my week on this problem, basically when you select static page as your home page in setting->reading of wordpress the complete behavior of listing things are changed, basically static pages are never meant for pagination the fact is when you call the $paged variable it will always return zero even if … Read more