WP_Query about meta_key and its array value

Try this $args = array( ‘post_type’ => ‘book’, ‘posts_per_page’ => -1, ); $query = new WP_Query($args); while($query->have_posts() ) : $query->the_post(); $date = get_post_meta( get_the_ID(), ‘date_all’, true ); if($date[‘year’] >= 2018 && $date[‘month’] == 3){ the_title(); } endwhile; wp_reset_query();

Order WordPress Query by Custom Field While Still Using Tax_query Argument

You can use a meta_query in addition to your tax_query : https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters I have in which if statement you want to use it so I put it in the of the code. $names = array( ‘fields’ => ‘names’ ); $prac_names = get_terms(‘attorney-practice’, $names); $prac_matches = array_shift(preg_grep (‘(‘. $search .’)’, $prac_names)); $off_names = get_terms(‘office-location’, $names); $off_matches … Read more

How to make async query in wordpress?

Is any way to make asynchronius query to wordpress, where i can use wordpress functions? Yes, but it’s: super fragile and easy to break a big security problem I strongly advise against it, and would consider the fix needed to make it work irresponsible to share. Instead, save yourself a world of pain and use … Read more

Query Posts to display all posts with category “custom field value”

If you are creating artists as categories then their single page template will be category.php , in category.php add the following code :- $category_id = get_cat_id( single_cat_title(“”,false) ); $cat_name = get_cat_name($category_id); $new=query_posts(‘post_type=news_album&cat=”.$category_id.”&post_status=publish&orderby=ID&order=DESC&posts_per_page=-1’); if( have_posts()) : while(have_posts()) : the_post(); echo get_the_title($post->ID); echo get_the_content($post->ID); endwhile; else: echo “No posts added for this category!”; endif; wp_reset_query();

Show 5 posts and than 3 posts offset with pagination

under settings – reading, set ‘blog pages show at most’ to 8 then use conditional statements based on the current post number in the loop; <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <?php //conditionally outputting the opening tags for the first section if( $wp_query->current_post == 0 ) { ?> <div class=”posts-wrap”> … Read more

Add option to query string before get_posts() is called on archive.php

function rpf_add_query_var_not_to_show_user_request_product($query) { $post_type = $query->get( ‘post_type’ ); if ( ! is_null($post_type) && $post_type == ‘product’ ) { $query->set( ‘meta_key’, ‘_user_request’ ); $query->set( ‘meta_value’, ‘no’ ); $query->set( ‘meta_compare’, ‘=’ ); // default } } add_action( ‘pre_get_posts’, ‘rpf_add_query_var_not_to_show_user_request_product’, 100, 1 ); yes, pre_get_posts is heaven! and $query->set(), $query->get() are angels!

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