Build a string instead of directly outputting the contents.
$str="";
foreach ($postslist as $post) : setup_postdata($post);
$str .= '<div class="events">';
$str .= '<p><strong>'.get_the_date().'</strong></p>';
$str .= '<p><a href="'.get_permalink().'" title="'.esc_attr(get_the_title()).'">'.get_the_title().'</a></p>';
$str .= '</div>';
endforeach;
Related Posts:
- Solution to render Shortcodes in Admin Editor
- Include PHP file in Content using [shortcode]
- ajax live search for post title
- Enabling shortcodes for custom fields
- Shortcode with parameters inside parameters
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- how to create shortcode in wordpress
- What is wrong with this Shortcode? I get it in a wrong place inside the content
- Display random text from a file with the WP built-in AJAX API
- Set first oembed in post to a global variable or function
- Formatting post content to exclude gallery
- Remove images from get_the_excerpt
- Problem with extract() with custom shortcode
- Using locate-template & shortcodes doesn’t appear to work
- Displaying a random user with a shortcode
- Adding body class when post contains a specific shortcode
- Function to show only first instance of shortcode
- creating shortcode to pull json array
- Pass Shortcode Attribute to footer Script
- Detect Safari desktop browser and include the detection in a shortcode
- My simple custom shortcode is not longer working (possibly due to upgrade to WordPress 4.4 ?)
- Placing raw HTML inside a WordPress shortcode
- Display gallery on top before content
- List child pages of specific page using shortcode
- WordPress shortcode attributes for database SELECT?
- create shortcode to list users with specific meta key value
- Variable if post is sticky in functions.php
- Shortcode inserts paragraphs before and after executing shortcode
- Using Schema with `the_excerpt`
- Scripts not appending to element in AJAX call – why?
- How can I make a widget shortcode to control all the widgets?
- Custom shortcodes not inserting into visual composer columns
- Setting youtube size in functions.php
- Adding a colorbutton in tinymce dialog with current api
- Passing variable as add_shortcode argument
- Excerpts are not displayed by a shortcode on category pages
- shortcode help require
- Optimizing a WordPress site
- Shortcode parse error – wrong syntax
- wp_nonce_field is breaking form for reasons unknown
- echo custom fields with AJAX
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- Using multiple line variable inside a function?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Echoing function into WordPress NextGen gallery
- Output loop to function return?
- How to echo the value of an array element using a function via a shortcode
- Wp-query Order By problem
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- How to include any template using Shortcode fuction?
- Need to convert image url to a Base_64 data url with wordpress function..
- dynamic site link for future migration in echo do_shortcode()
- Shortcode question
- Shortcode to get featured image of specific id post
- Modify shortcode to work with custom post types
- shorthand syntax for custom fields
- Creating multiple category drop down
- show all the posts thumbnails
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- Load templates, pass arguments, and render output from functions.php
- How to add if statement on WordPress shortcode output
- Passing function arguments via a shortcode
- Pagination not working – FrontPage
- Customizing the wp_video_shortcode output with add_filter
- Probleme shortcode with list author
- how to check if an element in an html file exists in another html file? [closed]
- Function to function shortcode help [closed]
- I want to display the sku in the product pages of my EDD website
- Shortcode to output category description by passing ID
- How do I make a custom “Read More Blogs” button for my blog page
- Help using ShortCodes to style whole chunks of the post
- Shortcode to insert default text and change one word throughout it?
- Images with overlay
- use add_action in a shortcode (gravity form – WordPress)
- Shortcode displaying outside the div [duplicate]
- Add schema to Search result page’s body. Tried using is_search
- Shortcode Initialization in a Custom Theme
- Show users last read posts for each user?
- Get shortcode attribute value to another function
- Hide disclaimer from summary excerpts
- Function not receiving string from shortcode
- Some code is added automatically to my site’s header – what is it?
- Shortcode to eliminate and replace with
- Automatic add space if user enters number(any digit)
- Problem in outputting shortcode
- Problem in shortcode outputting content
- Pull random comment from specific post, display on homepage with shortcode
- Set thumbnail from URL, by grabbing image in functions.php
- Shortcode to output get_header not working
- using enqueue_script in a shortcode isn’t working
- Gallery Shortcode Function Help
- Echo custom field value in shortcode function
- Shortcodes not outputting in correct divs
- trouble with passing class method data to outside function
- Get term count on a category page
- PHP error in shortcode [closed]
- Can’t find function which is called in a wordpress theme