You can also use output buffering to catch all output you generate. Use it like following:
function fl_aries_co_today_shortcode() { global $wpdb; $results = $wpdb->get_results("SELECT horoscope FROM wpaa_scope_co WHERE date = CURDATE() AND sign = 'aries'"); ob_start(); foreach($results as $r) { echo "".$r->horoscope."
"; } $content = ob_get_contents(); ob_end_clean(); return $content; } add_shortcode( 'fl_aries_co_today','fl_aries_co_today_shortcode' );
Related Posts:
- PHP code inside shortcodes
- How to display data from custom table in wordpress phpmyadmin
- Calculating a large number of MYSQL queries as customshort codes, slow
- $wpdb returns duplicate posts
- MySQL Query Returns Array () In Shortcode
- Conditional formatting on data fetched from MYSQL
- Add two or multiple functions in WordPress Post or Page
- Using the same shortcode to show any table from the database
- Display total count of products in orders of a specific order status
- MySQL column count doesn’t match value count at row 1 [closed]
- Fatal error: Call to undefined function mysql_connect()
- the_date() not working
- How to return number of found rows from SELECT query
- Return HTML Template Page with PHP Function
- How to make WordPress plugin check for database changes and then do something?
- ob_get_clean returns empty string, ob_get_flush outputs string
- Problems migrating WordPress to localhost
- error importing localhost export file to server
- How to sort results from a custom database table
- Add/echo div with Analytics-Code to function in functions.php
- Update some database fields when post is saved
- sql query to put quotes around numbers in img tag
- How can I default to all WordPress roles when parameter is not included in shortcode?
- PHP contact form returns warning in text widget [closed]
- How to find the output of contact form 7 shortcode? [closed]
- Listing and displaying WooCommerce Shipping Zones in the frontend? [closed]
- Recent post display using shortcode
- Need to turn this php into WP shortcode
- Strange wordpress slowness
- custom shortcode will not display the wrapped content
- Setting All Drafts to ‘exclude-from-catalog’ in WooCommerce
- Trigger popup in a php if/else statement
- Append HTML Using Shortcode
- How to output a PHP file values by shortcode?
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- database sent to a JSON file
- Get URL from shortcode tag
- multiple where condition in result query
- echo something inside a shortcode
- Shortcode from a function not working
- Is it possible to return content, and then also continue to do other things?
- Creating WordPress Shortcode with Variable
- Catchable fatal error: Object of class stdClass could not be converted to string
- Could use some help with Shortcodes
- Should I use WordPress to skin a database website?
- WordPress Custom SQL Table with UserID Filter for results
- How can I add a new row in a separate database when someone registers via WordPress?
- Shortcode for Listing Users from Meta Value?
- I can’t update my data through $wpdb
- How to use mysql LIKE with wpdb?
- Shortcodes showing in excerpt despite using strip_shortcodes
- How to use AJAX in WordPress in MYSQL query?
- Calling PHP Titles inside Javascript Markup
- Use variable in SQL statement
- Processing ajax call to php to insert into mysql database
- How to get my [shortcode] rendered on the home page, other pages are fine
- WordPress Custom Query: Combining Two Functions
- Show Featured Image Dimensions and size frontend with shortcode
- How to get woocommerce orders with get_posts method in a shortcode
- Counting number of posts in multiple (sub)categories using shortcode
- Passing in MySQL prepare statement parameter separately throwing error
- Database SQL query error
- MYSQL TIMESTAMP when adding DATE_FORMAT then the output is blank, PHP conflict?
- Updated Php version from 5.4 to 7.2 and getting “PHP installation missing the MySQL extension needed by WordPress”
- how to get data from two different table from wordpress database
- Display a custom name when the user has no name settle in his account
- How to optimize and reduce excessive database queries
- Store GA Client ID in User DB
- Echo short code syntax
- custom taxonomies not working
- How to return html as a string from php for WordPress
- Changing Date Format on Custom Meta Data w/shortcode call
- Add the shortcodes from the enfold theme to the other theme
- PHP 7.2.18 | Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Need help with format of nested array in MySQL
- Offset with ajax load more posts duplicates
- Inserting other fields to existing registration form in a WordPress theme
- Advanced WordPress SQL Query
- Splitting table data to pages with numbers
- How can i iterate through this shortcode array?
- Site doesnt work once PHP changed to 7.1
- How to detect if a revision was made by woocommerce or wordpress?
- Shortcode in a $output statement
- Need help with PHP functions
- WordPress WPDB::insert 13th param is always blank (only if format)
- Ajax not updating to database
- can’t delete a row from post_meta table
- When using shortcode, content stops generating after the_content
- MySQL query in WordPress with AJAX
- PHP Shortcode – 500 error
- Run PHP Results inside WP Shortcode
- retrieve wordpress post-meta using php not wordpress functions
- On selecting shortcode generate selected shortcode table inside page editor worrdpress
- Splash pages on a high traffic site
- My title is showing after the shortcode
- Shortcode to include PHP file, pass various parameters to include?
- Submit cf7 form to cfdb as pdf/BLOB [closed]
- How to send push notification in android using php? [closed]
- Redirect loop upon installation of my plugin
- Can’t insert into a database wordpress