how to make an array of post id’s in is_single
You must set it the ids in a array like: if ( is_single( array( ‘11717’, ‘11723’) ) ) { }
You must set it the ids in a array like: if ( is_single( array( ‘11717’, ‘11723’) ) ) { }
Try something like the following. Notice that the hide_empty argument is set to false. $args = array( ‘orderby’ => ‘id’, ‘hide_empty’=> false, ); $cats = get_categories($args); foreach ($cats as $cat) { // Your code to populate new array here } And then assign your newly created array to values.
Just set a flag to check for a new value, and only display the date if the new value does not match the flag, like so: <?php $args = array( ‘post_type’ => ‘tv-schedule’, ‘posts_per_page’ => -1, ‘orderby’ => ‘date’, ‘order’ => ‘ASC’, ‘post_status’ => array(‘publish’, ‘future’), ); $posts_array = query_posts($args); $flag = ”; // set … Read more
$meta_query_args = array( ‘meta_query’ => array( ‘relation’ => ‘OR’, // Optional, defaults to “AND” array( ‘key’ => ‘_my_custom_key’, ‘value’ => ‘Value I am looking for’, ‘compare’ => ‘=’ ), array( ‘relation’ => ‘AND’, array( ‘key’ => ‘_my_custom_key_2’, ‘value’ => ‘Value I am looking for 2’, ‘compare’ => ‘=’ ), array( ‘key’ => ‘_my_custom_key_3’, ‘value’ => … Read more
If it is post-thumbnail, it will return the ID:- <?php $post_thumbnail_id = get_post_thumbnail_id( $post_id ); ?> try this.
When I first started working with foreach loops, this particular syntax seemed mysterious to me, too, and it wasn’t until I needed it that its usefulness became obvious. Works that way for a lot of “things you see in code.” Anyway, to answer the question, in the sample code, using as $key => $value makes … Read more
if you are adding the custom query into the single template, try working with get_the_category() to get the cat_id for your query; also, get_posts() does not work with if( have_posts() ) etc. example code, using a custom query: <?php $cat = get_the_category(); $cat_id = $cat[0]->term_ID; $cpt_match_query = new WP_Query( array( ‘posts_per_page’ => 2, ‘post_type’ => … Read more
Each of your code blocks will overwrite the previous, you need to add to the array rather than replace it: $args[‘tax_query’][] = array( ‘taxonomy’ => ‘region’, ‘field’ => ‘id’, ‘terms’ => $_POST[‘region_filter’] ); relation is AND by default, so you can just omit it, but if you wanted to explicitly set it: $args[‘tax_query’][‘relation’] = ‘AND’;
You can achieve this using get_users function and its meta_key argument as displayed below. $users = get_users(array( ‘meta_key’ => ‘blocking_users’, )); var_dump( $users ); To retrieve it for current user and print it, please use below code. $user_id = get_current_user_id(); $key = ‘blocking_users’; $single = false; $blocking_users = get_user_meta( $user_id, $key, $single ); echo ‘<p>The … Read more
You can use meta_key or meta_query to fetch users where get_user_meta() ‘val’ == 1 Option 1: $users = get_users(array( ‘meta_key’ => ‘val’, // your_meta_key ‘meta_value’ => ‘1’, // value you want to compare ‘meta_compare’ => ‘=’, )); Option 2: $args = array( ‘meta_query’ =>array( array( ‘key’ => ‘val’, //your_meta_key ‘value’ => 1, // value of … Read more