Query string form $_GET[‘value’] is not working as meta value in wp_query
Are you sure the $_GET[‘q’] param is set? Try: $s_string = ( isset($_GET[‘q]) && !empty($_GET[‘q’]) ) ? sanitize_text_field($_GET[‘q’]) : ”;
Are you sure the $_GET[‘q’] param is set? Try: $s_string = ( isset($_GET[‘q]) && !empty($_GET[‘q’]) ) ? sanitize_text_field($_GET[‘q’]) : ”;
The pre_get_posts hook can be used to modify queries before they’re run. You can use $query->set() to set arguments on the WP_Query object, and $query->is_main_query() in the callback to limit your changes to the main query: add_action( ‘pre_get_posts’, function( $query ) { if ( ! is_admin() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, 12 ); } … Read more
I don’t think ACF has a built-in function to do what you want. You can use get_field to retrieve a value from any post, but it requires a post ID if you want the value from anything other than the current post. So instead, we can query posts using WP_Query and pass the meta key … Read more
while ( $loop->have_posts() ) : $loop->the_post(); //Edit Width post type $categories = get_the_terms(get_the_ID(), ‘services’); $separator=”, “; if ( ! empty( $categories ) ) { foreach( $categories as $category ) { echo ‘<a class=”cat_item” href=”‘ . esc_url( get_category_link( $category->term_id ) ) . ‘” alt=”‘ . esc_attr( sprintf( __( ‘%s’, ‘your-themes’ ), $category->name ) ) . ‘”>’ … Read more
Your sorting parameter should be: ‘orderby’ => ‘title’
If you have your data in separate table adding support for it in query is somewhat messy. Basically you will need to filter posts_where and posts_join to modify raw SQL query so that your custom table is joined and checked against your custom values. As per [faster :)] anu’s suggestion it would make sense to … Read more
I just wrote this up so I have not tested it but this is how I would go about forcing one post to be at the end. In the first loop it excludes the posts by its ID number and in the second loop it only includes the post by the ID number, essentially you … Read more
Ok, this is your original meta conditions that describe that you want all posts where key with name from $hideFromHome equals (meta_compare is = by default) true (actually 1 since you concatenate boolean value with string). ‘&meta_key=’ . $hideFromHome .’&meta_value=” . true What you got in second snippet defines key name as pr_hidehome, value as … Read more
This is hard to answer – you’re asking us to look in the minds of the WP developers who wrote this code 🙂 It is possible that they thought the only place where you need to query for posts of all types is when you are doing a search, and thus they named it that … Read more
You can use the $post->post_author, so before your loop add $agent=””; then inside the loop add $agent = $post->post_author; and then create a second query after you loop ends: $agent_query = NEW WP_Query(array(‘post_type’ => ‘agent’, ‘author’ => $agent)); while ($agent_query->have_posts()){ $agent_query->the_post(); //do your agent loop here } wp_reset_postdata();