Get posts by list of post IDs ordered by those IDs?
You could use post__in as a parameter in your WP_Query, like: $favourite_posts = new WP_Query( array( ‘post__in’ => array( 111, 222, 333 ), ‘orderby’ => ‘ID’ ) );
You could use post__in as a parameter in your WP_Query, like: $favourite_posts = new WP_Query( array( ‘post__in’ => array( 111, 222, 333 ), ‘orderby’ => ‘ID’ ) );
Try this, $categories_array = array(); $categories = get_categories(); foreach( $categories as $category ){ $categories_array[] = $category->term_id; } array( ‘param_name’ => ‘category_id’, ‘type’ => ‘dropdown’, ‘value’ => $categories_array, // here I’m stuck ‘heading’ => __(‘Category filter:’, ‘overmax’), ‘description’ => ”, ‘holder’ => ‘div’, ‘class’ => ” ),
The $wpdb class properties You can use all the default WordPress tables like this: $GLOBALS[‘wpdb’]->postmeta so no need to use prefix, etc. meta_query As you can see from the Custom field parameter documentation, there’s nothing like the <> (or in other words: “not equal to”) operator. The equivalent operator in WP should be != (human … Read more
global $wpdb; $excludeposts = “SELECT * FROM $wpdb->posts WHERE $wpdb->posts.post_status=”publish” AND meta_key NOT LIKE %aa_% ORDER BY post_date DESC “; $main_query = new WP_Query( array( ‘post__not_in’ => $excludeposts, ‘paged’ => $paged ) ); while ($main_query->have_posts()) : $main_query->the_post(); //Stuff… endwhile; //hope this helps
This function will give you the ids of blocked users get_user_meta( $user_id, ‘_block’, true ); here $user_id is yours
not sure where the code snippet is placed, and where you are trying to access it from. A simple (but ugly) solution might simply be to set this array to be global. Something like $GLOBALS[‘leftids’] = $leftids; and then from the other code use global $leftids; echo $leftids[0];
Using shortcode to display array in array
At first glance, I would think your query isn’t correct. Are you echoing out the variables to make sure they are correct? If you are setting ‘post_per_page’ => 4 and you are getting 5 posts, then something seems a bit off. Where it is a number, I believe you can leave off the quotes around … Read more
I believe that you’re looking for the get_bookmarks() function, which returns an array of bookmark objects. You could then implement this into your code: <?php // Get RSS Feed(s) include_once(ABSPATH . WPINC . ‘/feed.php’); $bookmarks = get_bookmarks(); $rsslist = array(); foreach ( $bookmarks as $bm ) { if ( $bm->link_rss ) $rsslist[] = $bm->link_rss; } … Read more
I hate writing “you can’t do that” answers, but you can’t. That is the strict answer to your question about whether you can do this with a single WP_Query. You can’t limit post type counts individually in the same query using WP_Query (You are actually using query_posts. Please don’t. It is not the right tool … Read more