How do I output a database option that is an array into a get_posts array?

You could use wp_parse_id_list() to sanitize your comma seperated list of post IDs. It’s defined as: function wp_parse_id_list( $list ) { if ( !is_array($list) ) $list = preg_split(‘/[\s,]+/’, $list); return array_unique(array_map(‘absint’, $list)); } where we can see that it returns unique array values as well. Note that absint() is defined in core as abs( intval() … Read more

Show post only if match all categories

Here’s an updated version of your code that will get posts that have the Post Format Video and that have the same Categories as the current post in the loop. You’ll call wpse_get_video_posts_with_matching_categories() to execute the function. function wpse_get_video_posts_with_matching_categories() { $categories = get_the_category( get_the_ID() ); if ( empty ( $categories ) ) { return; } … Read more

attachments with tags and get_posts

From this page in the codex, i see that this parameter requires an array so i’d try this way: $vidArgs = array( ‘tag__in’ => array(5), ‘post_type’ => ‘attachment’, ‘post_parent’ => $post->ID, ‘post_mime_type’=>’video/quicktime’, ‘posts_per_page’=>20 ); $videos = get_posts($vidArgs); foreach ($videos as $vid) { ///….

How do I combine these 2 queries

I wouldn’t combine the queries, primarily since they’re keying on different meta keys and values. The WP Query API is very powerful, but you’re trying to do some very advanced searching and sorting here. One option would be to write a raw SQL query by hand and pass it into $wpdb->get_results(), but that won’t necessarily … Read more

How to get 4 Posts after the 5 most recent ones

Simple. WordPress provides a function called get_posts() that lets you get posts in any order. Basically, get_posts() will retrieve the 5 most recent posts by default. To get 4 posts, ignoring the 5 most recent, you’d set the numberposts and offset parameters – offset tells the function how many posts to skip. $args = array( … Read more