Ok…So, I was able to find an example that helped:
function faq() {
$output="";
$query = new WP_Query( 'post_type=faqs' );
if ( $query -> have_posts() ) :
while ( $query -> have_posts() ) : $query -> the_post();
$output .= '<h3>'.get_the_title().'</h3>';
$output .= '<p>'.get_the_content().'</p>';
endwhile;
endif;
wp_reset_postdata();
return $output;
}
add_shortcode( 'faqs', 'faq' );
This puts everything in the right order and wraps the title tags in an <h2>
tags. If I didn’t do something right, or someone has a better suggested solution, please let me know!
** Minor correction to using the_title();
and the_content();
is get_the_title();
and get_the_content();
because if you don’t use those and try and put tags around them the tags show up underneath the text…the issue went away with get_the_title();
and get_the_content();
Thanks,
Josh
Related Posts:
- Pagination not working with custom loop
- How to use a custom post type as front page?
- Custom Select Query with Custom Post Types
- IF statement in a do_shortcode
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- How would I create a shortcode to display a custom post within a page or regular post?
- Is it possible to create a shortcode that will query a post based on taxonomies?
- Custom Post Type Loop within Shortcode
- Am unable to reset a query properly
- Get next and previous 3 posts in a term in single post page
- get_post_meta is not working inside shortcode
- the_post() is printing titles in page footer
- Listing custom post types on archive page with array
- Shortcode leaves no space for other elements?
- How to conditionally add Custom Post Type to Front Page
- Custom Post Type not showing in main loop
- posts within custom post type all share the same content in the front-end
- Shortcode to return single custom post based on post taxonomy
- Custom Post type showing up in loop, regular posts are not showing up
- Changing WordPress sort order for returned child pages
- Add custom post type to query
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- Update query based on CPT / Post Type, show all sorted by date
- How can I use javascript in specific posts without relying on a plugin?
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- Is it possible to add query parameters on the archive page?
- $post breaking container loop
- Multiple Queries and Loops within CPT Archive
- Pagination not working with custom loop
- Nested loop called with shortcode duplicating the content above the main loop
- Pagination not working with custom loop
- Pagination not working with custom loop
- Pagination not working with custom loop
- Listing custom post type items from a couple of custom taxonomies
- Pagination not working with custom loop
- How to loop through a custom post type using a shortcode and output each element in the loop using shortcodes
- Query Multiple Post Types and Paginate Newly Created List
- SOLVED: Shortcode to display Divi project filtered by tag in WP Query loop
- Making certain categories of CPT not publicly queryable
- How do i calculate the total of values of custom fields in custom post types?
- Search / Filter posts on Title/Content OR Tags
- Multiple Loops On Custom Post Type Template?
- Custom loop with multiple taxonomy queries
- Get parse_query filter to return slug instead of id
- I would like to have different styles for my posts based on the content of each post
- Checking if Post Title is Unique as Loop Criteria
- Custom post type not displaying content from single-{custom post type} page
- Querying both pages and posts
- Custom post type multiple loop by taxonomy term
- List custom taxonomy specific to one custom post type
- Show a Category X’s custom post type on Category X archive page?
- Paging doesn’t work?
- Meta query for custom post type ignored in main query
- Sort by alphabetical order archive.php page
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Custom Tag Description unable to display just below and outside of the Loop
- Querying Two Custom Post Types with OR Not Working
- How do I move/order posts with a tag to the end?
- Display all taxonomy terms, add class if term applies to current post
- Return the latest post from a custom Taxonomy and Post Type
- Changing wordpress publication date to ACF date and time picker date not working
- Displaying CPT and custom taxonomy side by side in Bootstrap 4 component
- Group CPT posts by custom taxonomy
- creat filter with wp_query
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Best way to style first post differently?
- A to Z List of Custom Post Type in three columns
- Custom post type, organized by categories
- What’s the WP way to load remaining custom posts?
- Specific query for custom post type
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- How to render a custom post type template with custom fields using shortcode
- Form action/link to render a plugin in WordPress front-end
- WP Query with categories only shows one post and ignores the category
- Send notifications to custom post author when custom post is edited
- What to and how to proceed with CPT to make DB small and efficient?
- custom post type category count shortcode
- Display Child Pages of Custom Post Type Parent Page
- Post ID randomly printing on page
- A custom post within a custom post
- Display Custom Taxonomy Alphabetically
- Full Custom Post Type List Organised by two Taxonomies
- Displaying Custom Posts on a Page
- Shortcode not working with post counter
- Shortcode to display Staff post type based on Location post type and Specialty post type
- Problem: wp_query outputs all images on site
- Display post content with respect to its title?
- Get custom post type’s fields in a while loop as variables
- Custom Post Type within the Loop on Homepage (Page Template)
- First custom field value (out of several) displayed twice after query
- wp_reset_postdata() and wp_reset_query() inside shortcode are not working to reset original page query
- Shortcode for CPT post content in a page
- The loop seems stuck to a single (now deleted) post
- Prioritize posts in query by meta keys?
- Posts per row on archive page (custom post type)
- What’s the equivalent of Hide From Menus on MODX on WordPress?
- How do I know the ‘meta_key’ for ordering my custom post type
- Next Post links not working in custom post type shortcode
- Foreach inside shortcode not working as planned
- WP_Query orderby and tax_query