Filtering custom post type query

Yes, you can do that. Just remove the first foreach and give the General category ID and change the code like below- // Initiating shortcode. Place this code to any of your page to get your desired output. add_shortcode( ‘faq_page_content’, ‘the_dramatist_faq_page_content’); /** * Rendering function */ function the_dramatist_faq_page_content() { echo ‘<ul>’; $posts = get_posts( array( … Read more

get_posts() seemingly ignoring post_type

I built a workaround for now, but would really love to know what is causing this. The workaround was obtained by removing changing “suppress_filters” to true and then adding a function that adds to the where clause of the SQL… But I would rather know how to fix this at the root rather than a … Read more

get excerpt without images

Use the_excerpt(); wordpress function to show only text. That function will filter out some html tags such as <img> , <a>. A useful alternative to show only plain text. Note – The the_excerpt() function internally uses get_the_excerpt() to get excerpt and return a new string by filtering tags such as <img>, <a> tags. It also … Read more

use get_posts to get custom field data, but in one array

You can alter your foreach loop as following to get concert date and city pair in single multidimentional array as following. $concert_query = array(); $i = 0; foreach($c_query as $post) : setup_postdata($post); $concert_query[$i][‘concert_date’] = get_post_meta(get_the_ID(), ‘concert_date’, true); $concert_query[$i][‘concert_city’] = get_post_meta(get_the_ID(), ‘concert_city’, true); $i ++; endforeach; print_r($concert_query);

Get all posts without tags

A WP_Query where ‘tax_query’ has all tag terms and operator ‘NOT IN’: $tags = get_terms(‘post_tag’, array(‘fields’=>’ids’) ); $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘id’, ‘terms’ => $tags, ‘operator’ => ‘NOT IN’ ) ) ); $untagged = new WP_Query( $args );

get_posts cannot grab from specific category

Edit In response to OP’s answer: So you use post_type and add cat at the end. Like [tribe_events][_cat]=[value] This is absolutely incorrect. WordPress does not automatically create custom taxonomies in this manner. From the OP’s comment: I’m using tribe Events calendar. Check it there. Here is the relevant PHP file from the The Events Calendar … Read more

Loop through two different sets of custom fields

Your question literally doesn’t quite sound like “combining” loops, that’s usually different thing in WP terminology. Following it literally you already know the part that outputs artist name you want — the_field(‘artist_name’). What probably confuses it in first context is that it’s not really a normal WP loop. Note how that call doesn’t specify which … Read more

Post Loop not Returning Permalink

You have made the mistake in getting the post link in your code. Missing <?php global $post; ?> – Initialization at the start of the loop After setting up the post data your query becomes like normal Wp_Query so that you can get the permalink() in normal method itself using the_permalink() instead of get_permalink($post->id). Since … Read more