Get date of last update outside of loop

It is unclear if you are looking for the last updated post or for the last updated date for some particular post. The answer by @PatJ assumes the former. To do the latter: $qry = new WP_Query(array(‘p’=>1)); var_dump($qry->posts[0]->post_modified); Or… $date = $wpdb->get_var(“SELECT post_modified FROM {$wpdb->posts} WHERE ID = 1”); var_dump($date); Of course you need to … Read more

Insert image or ad script after 3 posts using the loop

instead of a post counter, you could use the variable $wp_query->current_post – which starts with 0 for the first post in the loop; for some output after the third post, use for instance this before the line with endwhile;: <?php if( $wp_query->current_post == 2 ) { ?> DO SOMETHING <?php } ?>

Skip post in loop and mixin later

What about an approach like this: $first_category_args = array( // category id ‘cat’ => 123, // get all from cat ‘posts_per_page’ => -1, // don’t prepend sticky ‘ignore_sticky_posts’ => 1, // only return ids ‘fields’ => ‘ids’ ); // array of ids $first_category_query = new WP_Query( $first_category_args ); $first_category_ids = $first_category_query->posts; $second_category_args = array( // … Read more

Order posts by ID in the given order

Starting in WordPress 3.5, the orderby parameter will allow the value post__in to sort by the order of the post__in parameter, just like in your example. It may not be ideal to wait or require 3.5+, but this will almost certainly be the best and easiest way to do what you’re looking to do. Here’s … Read more

How to control output of custom post type without modifying theme?

There’re two very often forgotten action ref arrays: loop_start/_end(). Just turn on output buffering and you’re ready to go. add_action( ‘loop_start’, ‘wpse75307_plugin_loop’ ); add_action( ‘loop_end’, ‘wpse75307_plugin_loop’ ); /** * Callback function triggered during: * + ‘loop_start’/`have_posts()` after the last post gets rendered * + ‘loop_end’/`the_post()` before the 1st post gets rendered * @param object \WP_Query … Read more

How to get order of posts?

Found the answer from the WordPress docs. For what the query is ordered by, I use: global $wp_query; echo $wp_query->get(‘orderby’); For the order by which the posts are queried: global $wp_query; echo $wp_query->get(‘order’);

get custom post type by tag

You’ll need to setup the post for the query by changing the following line to get rid of the infinite loop. <?php while ($query->have_posts()) : $query->the_post(); ?> If your looking for a custom post type, you’ll need to specify that in the query arguments: <?php $query = new WP_Query( array( “post-type” => “yourposttype”, “tag” => … Read more

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