As Milo noticed, shortcodes should return
content instead of echo
ing it. So change
while($query1->have_posts()) : $query1->the_post();
echo '<div class="menu-thumb">';
the_post_thumbnail( );
echo '</div>';
echo '<div class="menu-title">';
the_title( );
echo '</div>';
echo '<div class="menu-content">';
the_content( );
echo '</div>';
endwhile;
to
while($query1->have_posts()) : $query1->the_post();
$div = '<div class="menu-thumb">';
$div .= get_the_post_thumbnail( );
$div .= '</div>';
$div .= '<div class="menu-title">';
$div .= get_the_title( );
$div .= '</div>';
$div .= '<div class="menu-content">';
$div .= get_the_content( );
$div .= '</div>';
return $div;
endwhile;
(replace echo
with return
and also anywhere there is a the_something()
replace it with get_the_something()
so that at the very end, it return
s the whole chunk of output.)
Related Posts:
- How to customise the output of the WP image gallery shortcode from a plugin?
- Custom media upload content for inserting custom post shortcode
- Gutenberg disallow certain custom blocks but keep all core blocks?
- Checking if an attribute exists in a shortcode
- All shortcodes not working on custom theme
- enqueue script only if it is not already enqueue
- Shortcode output appears before post body [duplicate]
- How to disable Gutenberg editor?
- Is their any way to Extend WPDB class and Overwrite the Default Query Function
- How to parse nested shortcodes?
- How to call shortcode function directly and pass $atts
- change plugin shortcode function [closed]
- Dynamic HTML not displaying at respective place
- Gutenberg: Difference between “import” and “const” for dependencies
- Gurenberg Block: How to migrate from el-Functions to JSX elements?
- Short code for Venues
- Difference between register_block_type & wp.blocks.registerBlockType
- Can I share predefined fonts from theme_support with a gutenberg component?
- How do I store information in a dynamic block in WordPress?
- Can’t get custom posts of taxonomy to show
- Shortcode doesn’t work if I directly paste its function in a template file?
- How to create custom embed block in gutenberg wordpress
- Getting RGBA colour from gutenberg colourpicker
- Add custom variable in Contact Form 7 mail body
- get shortcode value
- How to generate CSS from a shortcode within a plugin
- Storing Options in a Shortcode
- How to remove html code in excel downloads using phpspreadsheet with wordpress plugins shortcode
- How can I create a custom shortcode that will return a custom post type by ID?
- Plugin Handle URL With Custom Theme
- how to disable blockrenderAppender inside all Innerblocks?
- Cannot find a list of data selectors for Gutenberg editor
- AddToAny shortcode in the loop
- How to fix wrong attribute error for Visual Composer Grid Builder?
- Making a Template for a CPT created by a plugin
- Use gutenberg block editor on plugin page (outside of a post)
- Using SVN to upload plugin created with gutenberg blocks
- Shortcode Plugin to dynamically build a shortcode via `do_shortcode` not working
- Inject HTML meta tag inside wordpress tag using add_shortcode
- Gutenberg: Block SelectControl saves attributes but after a reload of Gutenberg it loads its defaults. Why?
- WooCommerce search products between price range using WP_Query
- My plugin won’t return anything [closed]
- Shortcode to update user meta
- Why is the ‘Gutenberg’ Plugin generating an ‘Inconsistent File Permissions’ error when other Plugins, with the same permissions, do not?
- Why am I unable to load scripts in head in plugin?
- Deactivate JS Script in Plugin Shortcode
- Where to find the code used to render a page that has a shortcode and a template defined?
- Shortcode not working after move wordpress website files
- convert more tag to shortcode
- Plugin that provides the [edit] shortcode?
- How to find out whether a plugin is used in pages or posts?
- Return multiple values in a shortcode attribute
- How to change shortcode’s default theme?
- Override/ignore CSS from active theme as not to interfere with my custom CSS
- Is there a way to convert shortcodes to html content?
- How to use template inside plugin shortcode with variables for big HTML code
- Loop returns the current page’s permalink and guid instead of the post in the loop
- How to use apply_filters?
- Shortcode and variable
- Elementor Pro display featured image on section -> style -> image using shortcode
- Elementor Combined all Sections into 1 Text Editor
- Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
- How to make if statement in react plugin?
- How to resolve warning for `unstableOnSplit` prop on a DOM element in block editor
- Shortcode show error while editing post
- Get Shortcode output to database for static post_content
- Issue Saving Posts That Contain Shortcode
- Using Shortcode Result In Custom HTML Block (Using Google Sheet JQuery Result As NumScroller data-max)
- After Update Advanced Gutenberg Plugin – advgb/container site does not support block
- How to use plugin’s shortcode in custom design? [closed]
- WP Plugin CSS not being applied to page
- How to add HTML to a template only when user is logged out/ not registered
- Multiple calling javascript from shortcode in one page
- Is it possible to get a shortcode generated by a plugin, then, using a function, create a new post using that shortcode?
- Find all strings between an enclosing shortcode
- Hide some shortcodes on posts from back-end
- Trouble implementing python on WordPress
- Is there a function to search for a wildcard value when calling a shortcode?
- How to display single arbitrary facebook post with a shortcode?
- Multiple level shortcodes
- Custom shortcode with dynamic rewrite
- apply_filters to content but ignore shortcodes
- Proper way to trigger a MySQL query via link in a plugin
- How to load a plugin when doing an Ajax call? [duplicate]
- Is it right way to create shortcode?
- Trying to override/intercept a PhotoMosaic gallery link in WordPress using jQuery
- WP-Snap too slow (caused by WP_Query?)
- Creating Features List in WordPress Post
- I am experiencing difficulty fulfilling client request
- Custom gutenberg block image preview not working
- How can I utilize the same “show more” functionality that I see in superuser on my own WordPress site?
- Gutenberg Block to Select Category Term
- cURL External API request displays content above other content on page
- How do I set register_meta for a specific CPT?
- Update Content for a Custom Block Toolbar Button
- thumbnail_width not working in wordpress most popular post plugin
- How can I display an attribute from each post inside foreach($latest_posts1 as $post )
- Wrong block appender button showing
- How to get custom setting from get_option and pass it in getEntityRecords in gutenberg block?
- Display file contents within Plugin