I´m doing this since last year and i´m getting the shortcodes working:
function my_code() {
ob_start();
get_template_part('loop_logos');
return ob_get_clean();
}
add_shortcode( 'logos', 'my_code' );
where get_template_part loads the file loop_logos.php and logos is the name shortcode [logos].
HINT
When I started to do this I used to name all equal to avoid mistakes, Ex:
function loop_logos() {
ob_start();
get_template_part('loop_logos');
return ob_get_clean();
}
add_shortcode( 'loop_logos', 'loop_logos' );
So I had to worry about to upload the loop_logos.php on the right folder. and call the shortcode with [loop_logos]
Related Posts:
- WordPress loop add heading before first of type
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- Conditional to modify query results
- wp_query to find posts by year and month
- Create a random unique 6 digit number as custom field for custom post type
- Very Slow Page – How to Optimize # of Queries?
- WP_Query orderby modified to include custom meta changes
- How to make sure content doesn’t display if selection is empty
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- How can I group posts by months and years?
- Loop increase number
- Using wp_query to modify the loop in index.php for a CPT
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Get data from PHP to JavaScript to set position of each post on front page
- foreach loop inside the loop creating duplicates in output
- How do I list a custom field and custom taxonomies for each result in a loop?
- Page that lists publications by classifying them by taxonomy
- Alike Shortcode using in Custom Shortcode
- Query custom post type that has a serialized relational advanced custom field value
- Sort custom post column by generated value?
- when looping through custom post data not appearing
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- sorting in wp query based on custom field value
- WordPress query in which condition uses custom field
- Error in WP Query. If variable is empty it is displaying previous post value
- Strange behavior on WP_query
- get_post_meta for Custom Post Type ( CPT )
- Order by custom field attribute
- Query Custom Post Type by Tag
- How do I filter a custom post type loop by a field?
- How to append element after thumbnail
- How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()
- Display posts if a custom field value is equal to another custom field value
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Sort by two dates. Default entry date and custom field if present
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Display custom post on home page based on a metabox selection
- Impossible to get Attachments Outside WordPress?
- WP_Query search posts by custom post type and custom taxonomy
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Unable to get post content from custom post type loop
- Lists Posts from CPT that match the Title of the Page
- Help Structuring Query for Archive Pages
- Display custom field of specific post where post title matches variable
- Loop on front-page.php
- Filtering by Post Meta Custom Fields – Performance
- WP_Query is printing out only one post when posts_per_page is set to multiple
- WP Query to displaying date and posts for that date?
- WP Query—Relationship between two custom post types and their fields
- How to dynamically attach pictures to a carousel
- Remove duplicated values from a loop
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Custom Post Type Loop within Shortcode
- How to insert content from another Custom Post type into Post?
- Using several custom fields as custom post title
- Get all Posts If has same custom field values in Posts
- Can’t get order_by meta_value_num to work properly
- WP_Query | ‘post_type’ doesn’t work
- How to connect two custom post types with nested loops
- Filter by custom taxonomy slug on a custom post type
- Custom Post type and Custom Field WP_Query
- Query custom post type in the loop
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Loop through Custom Post Type, and then show children within each iteration
- Including Custom Meta with posts_where query
- how do i remove posts from a WP_Query so the pagination is right?
- Can I create a loop with multiple post types and specify different $args for each post type?
- Display CPT posts based on specific taxonomy
- WP_Query: include custom post type only with specific meta value
- Custom Post Type Loop throws 500 error when used in widget
- WordPress custom loop filter by meta_key and value with serialize data
- Returning a list of custom post types excluding those without a specific meta_value
- Show one item per category of a custom post type
- Meta Key Value in current-user-only loop
- Calculate all custom field values in the post loop
- CPT + CMB2: data not displaying for only first post in loop
- Replace text in post from cvs
- wp_query check if integer exists in custom field’s array
- How do i calculate the total of values of custom fields in custom post types?
- Custom loop with multiple taxonomy queries
- 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
- Query & Order posts by custom fields
- 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
- How can I get the number of custom post type posts that have a specific attachment image set?
- Problem querying Custom post type by custom fields
- Orderby CPT custom fields not working
- WP_Query order by custom field, then randomly order some of results
- get_post_meta not working on publishing
- creat filter with wp_query
- Query custom post type with ACF Date
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Using custom field content as expression in IF statement [closed]
- Including metaboxes from custom post types in global search — continued
- Query Multiple Custom Posts by Custom Fields
- What’s the WP way to load remaining custom posts?
- Get Posts by multiple custom fields is not working
- WP Query with categories only shows one post and ignores the category