Exclude post ID from wp_query

I suppose this was heavy, but to answer your original question, I’ve collected all of the posts id’s in an array in the first loop, and excluded those posts from the second loop using ‘post__not_in’ which expects an array of post id’s <?php $args1 = array(‘category_name’ => ‘test-cat-1’, ‘order’ => ‘ASC’); $q1 = new WP_query($args); … Read more

Pagination when using wp_query?

Replace <!– WHAT GOES HERE?????? –> with the pagination code below: <div class=”pagination”> <?php echo paginate_links( array( ‘base’ => str_replace( 999999999, ‘%#%’, esc_url( get_pagenum_link( 999999999 ) ) ), ‘total’ => $query->max_num_pages, ‘current’ => max( 1, get_query_var( ‘paged’ ) ), ‘format’ => ‘?paged=%#%’, ‘show_all’ => false, ‘type’ => ‘plain’, ‘end_size’ => 2, ‘mid_size’ => 1, ‘prev_next’ … Read more

meta_query with meta values as serialize arrays

No, it is not possible, and could even be dangerous. Serialised data is an attack vector, and a major performance issue. I strongly recommend you unserialise your data and modify your save routine. Something similar to this should convert your data to the new format: $args = array( ‘post_type’ => ‘my-post-type’, ‘meta_key’ => ‘_coordinates’, ‘posts_per_page’ … Read more

How to get post id of static front page?

WordPress has a few useful options. You can get the homepage ID by using the following: $frontpage_id = get_option( ‘page_on_front’ ); or the blog ID by using: $blog_id = get_option( ‘page_for_posts’ ); Here’s a list of many useful get_option parameters.

How to get an array of post data from wp_query result?

You should read the function reference for WP_Query on the WordPress codex. There you have a lot of examples to look at. If you don’t want to loop over the result set using a while, you could get all posts returned by the query with the WP_Query in the property posts. For example $query = … Read more

wp query to get child pages of current page

You have to change child_of to post_parent and also add post_type => ‘page’: WordPress codex Wp_query Post & Page Parameters <?php $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘post_parent’ => $post->ID, ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order’ ); $parent = new WP_Query( $args ); if ( $parent->have_posts() ) : ?> <?php while ( … Read more

WP_Query with “post_title LIKE ‘something%'”?

I would solve this with a filter on WP_Query. One that detects an extra query variable and uses that as the prefix of the title. add_filter( ‘posts_where’, ‘wpse18703_posts_where’, 10, 2 ); function wpse18703_posts_where( $where, &$wp_query ) { global $wpdb; if ( $wpse18703_title = $wp_query->get( ‘wpse18703_title’ ) ) { $where .= ‘ AND ‘ . $wpdb->posts … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş