Change it up a bit and use have_posts method to check if there are any results:
<?php
$args = array(
'post_type' => 'questions',
'posts_per_page' => '3',
'tax_query' => array(
array(
'taxonomy' => 'types',
'field' => 'slug',
'terms' => 'customer-service'
)
)
);
$loop = new WP_Query( $args );
if ($loop->have_posts()){
?>
<h4>Frequently Asked Questions</h4>
<ul class="faq">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li><a href="https://wordpress.stackexchange.com/questions/112118/<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php }
Related Posts:
- Meta query with boolean true/false value
- Get Posts in a Custom Post Type category
- How to check if I’m on a custom post type archive in the admin area
- How to put custom post types on front page
- Add custom post type items from frontend
- How to add multiple images to a custom post type single post?
- Query Custom Post Type taxonomy type based on page
- Counting Posts of a Given Post Type Having a Specific Taxonomy?
- Listing posts with wp-cli
- Custom permalink with pagination
- Custom wp_query pagination – next_posts_link() or wp_pagenavi() always empty
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- How to create posts (not post template) to be displayed on projects page?
- WP_Query post at custom position
- Adding a span when custom post type is updated
- Re-order posts in query after
- Search tags in CPTs
- How to filter by custom post type in taxonomy archive pages
- How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()
- Custom query form submission pagination
- Paginated Taxonomy Term Archive including one post per term
- Exclude the parent custom post-type posts only
- Woocommerce query specific product from specific category
- Help Structuring Query for Archive Pages
- tax_query returning all posts instead of selective posts in WP_Query
- wp_query to find posts by year and month
- Get custom posts with certain ids in a custom loop using a shortcode
- Query custom post type in the loop
- Including Custom Meta with posts_where query
- Very Slow Page – How to Optimize # of Queries?
- Show custom post type filtered by category
- Filtering WP_Query
- Get latest 3 posts from multiple CPT in one query
- Display upcoming Events for next 7 Days
- Orderby CPT custom fields not working
- Custom post taxonomies as tax_query terms?
- Query custom post type with ACF Date
- Custom WP Query on custom meta and sort by multiple meta keys value
- Woocommerce search pagination not working
- How to order WP_Query by parent for hierarchical Custom Post Type?
- Custom post type ‘articles’ ignores posts_per_page, reserved post_type?
- WordPress request fiter order by related post’s post_title
- Order Custom Post Type by Custom Field Value
- WP_Query custom post type query not showing the exact post type
- Change sort order when using ‘orderby’ => ‘type’
- Add Custom Post Type of specific Custom Taxonomy to regularly blog loop
- Can I display custom post types in home.php or need page template?
- Sort posts in loop by the WooCommerce Membership of the author
- Pagination doesn’t function properly for archive of a custom post type set as the front page
- How to get specific post meta by title or id
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- How to properly rewrite pagination rules for a CPT to avoid 404 error on /page/2
- $post->post_meta not pulling any post in wordpress/php
- WP_Query of custom post type sorted by meta_key has unexpected results
- display posts of custom post type with custom taxonomy
- How to query for posts (hierarchical custom post type) that have children but are NOT top level?
- Create a WP_Query where if the first value of the first row is equal to the second compare other value
- Pagination for search results of custom post type [duplicate]
- Custom Plugin – Query CPT – Display Results
- Sorting by meta_key different to search criteria?
- Shortcode / WP_Query in post changes context
- All blog posts are not showing up
- How to fetch posts that are stored in the different table than (default) wp_posts?
- WP_Query order custom post type with certain meta key value by post modified date
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
- Custom post-type custom query – show all posts
- Display custom-post type based on the Title matching the current selected value
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- Pagination in custom post type archive.php not working
- WP Query: If field X is empty, show posts based on field Y
- Sort custom post column by generated value?
- How to search through all child taxonomies using WP_Query?
- Numeric pagination custom post type
- Filter posts by their related field’s custom field
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Query a Custom Post Type using SELECT that has ACF fields to compare dates
- How to get post by meta value
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- How do I get all authors posts of a custom post type outside loop
- Filter custom WP_Query by first letter of a custom field – hopefully using Search and Filter Pro?
- WP Query filter search. Result show all posts instead just custom post type
- Display posts of a hierarchical custom post type excluding parent posts
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- WordPress loop add heading before first of type
- get_post_meta for Custom Post Type ( CPT )
- WP_Query for CPT with filter by another WP_Query
- Is it possible to add query parameters on the archive page?
- How to query posts by meta keys AND under specific category?
- Shortcode display CPT Query only showing 1 post?
- Query stopped working
- How can I base a query off of the current page post type AND a meta value from another custom post type
- WP_Query and two custom fields returns no posts
- Storing/querying custom date data
- Fallback if statement based on the number filtered from it
- Custom Post-type not returning the right child_of
- How do I hide single category post on my post page
- Get images only from a certain post type
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- WP Query – Can’t get posts with specific taxonomy