You’re close but not quite.
do_shortcode
expects a string so give it one!
If function()
returns a string you can
echo do_shortcode( '[shortcode]' . function() . '[/shortcode]' );
If function()
directly outputs, you can capture its output using output buffering
//start the buffer
ob_start();
function(); //i.e pdf_print_popup();
//store out output buffer
$string = ob_get_contents();
//clear the buffer and close it
ob_end_clean();
and then use the string we stored
echo do_shortcode( '[shortcode]' . $string . '[/shortcode]' );
Related Posts:
- How to check if feed URL was requested?
- problem with ajax and the path to the php page
- How to return a string that has a variable inside in a shortcode?
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- Saving metabox repeatable fields
- Targeting single page with JS
- Remove General Tab and Plugin Tab in Settings in Woocommerce
- WooCommerce – Display variation custom field value [closed]
- How to start a script from cli within wordpress
- How to group 2 radio buttons in a widget?
- Featured image fallback link to permalink
- Facebook “like” open graph meta in header.php
- Working with a modified WordPress & Theme and updating WordPress
- Missing sidebar parameter “fix” – before_content
- Automatically add custom CSS to new posts using a category template
- How can I reuse the code to capture a param in a URL and place in a value in a hidden form?
- Different Minimum Order Amounts based on Shipping Zone [closed]
- Don’t insert if permalink is the same?
- PHP errors in class-wp-query
- Store a default value for a transient on plugin activation
- Change “add to cart” button color based on Woocommerce product category [closed]
- Let Users Choose Post Categories
- $wpdb->wp_users returning empty value for
- WordPress Custom field Colors
- Display most popular posts of category
- How to correctly add Javascript to this PHP ‘Page Not Found’ Page?
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- Warning message (re. php) on the blog page
- List taxonomy term slugs within shortcode (do_shortcode)
- get taxonomy thumbnail and use it as a variable in code
- Get html data with javascript to php array and store to wordpress database
- retain querystring values when savincustom options in admin
- Use post ID in functions.php file adminside
- How to show childs of certain custom post type in option list?
- How to edit HTML of my website on WordPress? [closed]
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- wpdb Cannot Update column in Database
- Change default gallery images – Currently they are displaying full size imagese
- Custom Registration username_exists / email_exists
- How can I search all plugins for composer’s vendor/autoload.php?
- How do I prepare strings for insertions as values into a MySQL table?
- Custom posts password protect
- How to get post category list as select in front-end?
- How to pick “full/thumbnail” images in the loop?
- Search.php gets metadata from first post
- How to remove the two duplicate values
- AJAX function running TWICE with WordPress admin-ajax.php
- OOP PHP class extends TwentyTwenty_Customize in Child Theme
- PHP using external anonymous function inside class
- How to make Subdomain work for product_tag?
- Woocommerce – Exclude variation attribute on specific variation
- Sort new column in Users wp-admin
- How to spell out a word in products/posts?
- How do I add a function to parent theme
- call to undefined function mysql_connect
- Can’t pass var from php wp_ajax into ajax script : result undefined or null
- Custom PHP form needs refresh to load page correctly
- Child-Theme Category View with modified permalinks (%category% removed)
- Log out without confirmation request (nonce)
- Add Pre-Defined Value to Click Counter in WordPress
- Create a WordPress Contact Form to call a POST AWS API Gateway and send user data
- Show data obtained from a function and place it in a shortocode function
- Confuse between forms and tables
- Get WordPress username to customize url
- Delete empty title_tags, find a h1 heading and echo it
- Get posts from year from URL
- HELP: cannot log into wordpress. PHP error
- WordPress is setting from header wrongly in wp_mail
- How to edit content in WordPress and the Polylang – plugin? – with demosite
- Add post title as a link parameter
- Help with find a bit of code to move from functions.php
- Search for images that width and height is more than 500
- How do I get object if class is instantiated only like this new classname()
- How to create a php page to collect information from a html page
- Default Image not showing up in Customizer for WP_Customize_Cropped_Image_Control
- I need help implement a Javascript code into the PHP file
- Passing different content to template parts
- Filtered table in wordpress
- Run insert if no entry otherwise run update with ajax
- Hide cart when empty [closed]
- How to redirect unattached image attachments
- Overwriting a Shortcode
- WordPress changing single quotes to double quotes in title and content
- Easier URL to an image
- Post Title Not showing up
- MySQL database migration to WordPress
- Is this WordPress code causing page weirdness? Can’t scroll to bottom
- Search result page – display values from the result’s metaboxes
- Parse error: syntax error, unexpected ‘}’ in
- WordPress add parameters with friendly url structure
- Different behaviour between “include_once” and directly echoing out html code?
- please on skin.php on theme wordpress option fix on theme option to not print empty variables and empty
- How to cut a section of a URL from a string with a regular expression?
- Too few arguments at registering new templates in my plugin
- inner-wrap div pushing custom table far down on page
- Remove Woocommerce product from cart with ajax/fetch
- Custom nav with bootstrap dropdown
- Limit a search box by CPT + taxonomies, in only one page
- How to edit a widget code?
- Hide ‘Downloadable’ and ‘Virtual’ checkbox options from Woocommerce Variations?