Instead of query_posts()
, use WP_Query()
:
function shortcode_eventi() {
$loop = new WP_Query(array(
'post_type' => 'eventi'
));
?>
<?php if ($loop->have_posts()) : ?>
<?php while ($loop->have_posts()) : $loop->the_post(); ?>
<small><?php the_time('F jS, Y') ?></small>
<?php endwhile; ?>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center"><?php _e("Sorry, but you are looking for something that isn't here."); ?></p>
<?php endif; ?>
<?php
}
Related Posts:
- 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?
- Custom Post Type Loop within Shortcode
- get_post_meta is not working inside shortcode
- Shortcode leaves no space for other elements?
- posts within custom post type all share the same content in the front-end
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- Shortcode with loop stacks output
- Nested loop called with shortcode duplicating the content above the main loop
- How to loop through a custom post type using a shortcode and output each element in the loop using shortcodes
- SOLVED: Shortcode to display Divi project filtered by tag in WP Query loop
- Group CPT posts by custom taxonomy
- 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?
- 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
- 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
- Get custom post type’s fields in a while loop as variables
- Custom Post Type within the Loop on Homepage (Page Template)
- 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
- Posts per row on archive page (custom post type)
- 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
- Custom Theme With Custom Loops
- Custom Post Types strange pagination problem
- Custom post type conditional in loop
- Listing all term items alphabetically / sorting loop
- Display related custom taxonomy posts in sidebar
- pagination not working for category.php (custom post types in categories)
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- How do I control the output of a custom post type in the loop?
- Display custom post type posts first, then default posts
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Three Most Recent Posts, One Per Term
- Targeting custom post type
- Does WP have a global of $id?
- WordPress Loop if/else
- get_the_title() is returning results from previous loop
- Custom Post Loop pulling all custom posts, not just one
- Conditional for a Single Post That Belongs to a Category?
- Wrapping x posts in html without leaving empty html
- Can a shortcode included in post content add styles to the ?
- WP Query post__in not returning correct results
- How to retrieve category of a post in have_post loop?
- Custom Post Type single.php template only shows the latest post
- Sort posts in loop by the WooCommerce Membership of the author
- Including all post id’s of a custom post type into an array
- How to include custom post type posts on a page?
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Tag page only display 10 posts
- Checking if looped item has a parent inside a shortcode
- How can I group posts by months and years?
- Pagination Error : Duplicate argument being outputted
- get_post_type is always post
- Multiple Custom Post Type queries, how to DRY it up
- Custon Content within WordPress Loop
- Trying to Create a PHP Variable for post_type that can be referenced Site Wide
- Bootstrap accordion looping through posts incorrectly
- Main query not querying any posts in custom taxonomy template
- Loop increase number
- Custom post type showing same Post on all Pages
- Using wp_query to modify the loop in index.php for a CPT
- Custom WP_Query doesn’t display all posts
- Query & the_content() is showing in the header
- Create Array from custom post type to display a slider
- Move Genesis Single Page/Single Post Title
- get parent content inside child posts
- 3 random images from custom post type, each in a div with a diffrent class
- Two column layout with alphabetical ordering
- Post loop count is not in order
- Control content before and after custom post type loop
- Listing custom post types on archive page with array
- get_pagination not working on a custom post type query (using WP_Query)
- How to Make infinite loop of post
- Add custom attributes to a post
- WP_Query with custom post type ID
- Displaying multiple post types on home page
- looping though custom post types and only return results in a given taxonomy
- How to conditionally add Custom Post Type to Front Page
- Dynamically insert code to custom post type loop