At first – do not use extract
. It’s very bad code style and is also depracated in core.
Every time your foreach loop run, you override content of $output
because you assign to this variable new content. What you want is to concatenate new list item with existing ones. This can be done using concatening assignment operator:
$output .= '<li class="text-center"> <img src="' . $carouselimage['url'] . '" title="' . $carouselimage['title'] . '" alt="' . $carouselimage['alt'] . '" /></li>';
$output
variable should be defined before your foreach
statement. Just assign to it an empty string.
Related Posts:
- Solution to render Shortcodes in Admin Editor
- functions.php inject inline css
- Enabling shortcodes for custom fields
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- Creating a table from shortcode avoiding wpautop for each row
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Stripping shortcode from custom excerpt function
- how to create shortcode in wordpress
- Display random text from a file with the WP built-in AJAX API
- Formatting post content to exclude gallery
- Remove images from get_the_excerpt
- Problem with extract() with custom shortcode
- Shortcode to insert menu in page body?
- Using locate-template & shortcodes doesn’t appear to work
- Displaying a random user with a shortcode
- Function to show only first instance of shortcode
- How to use max and min values of custom fields
- creating shortcode to pull json array
- Pass Shortcode Attribute to footer Script
- Detect Safari desktop browser and include the detection in a shortcode
- Display gallery on top before content
- List child pages of specific page using shortcode
- How to extract the variables out from “add_shortcode” function?
- create shortcode to list users with specific meta key value
- Variable if post is sticky in functions.php
- Retrieve tags data in post body
- Run function when WordPress new multisite is created or ACF field is updated
- Shortcode inserts paragraphs before and after executing shortcode
- 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
- Add button to kitchen sink toggle
- 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
- 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
- Add php code to wp_print_scripts?
- Wp-query Order By problem
- Access category within rss2_head hook?
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- Compare meta key to current date in pre get post
- How to include any template using Shortcode fuction?
- How can I pass a shortcode value to the head in wordpress functions.php
- Native gallery custom html output
- 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
- Insert a field with PREG_REPLACE – strange behaviour
- show all the posts thumbnails
- Display ACF category image on archive and single template files
- Featured Image and Tags problem
- Override a Post’s URL with Advanced Custom Fields Function
- Display a list of random terms from custom taxonomy with shortcode
- 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
- Customizing the wp_video_shortcode output with add_filter
- How to update an image attachment’s alt text from a custom field when saving a post?
- Probleme shortcode with list author
- Help with with my function for wordpress
- Shortcode to output category description by passing ID
- Help using ShortCodes to style whole chunks of the post
- Shortcode to insert default text and change one word throughout it?
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- get_field() with ID in one signal filter not working
- Shortcode Initialization in a Custom Theme
- Comment function for page
- ACF Filter return value
- Show users last read posts for each user?
- Hide disclaimer from summary excerpts
- Function not receiving string from shortcode
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Custom shortcode with do_shortcode and substr
- Shortcode to eliminate and replace with
- Problem in outputting shortcode
- Problem in shortcode outputting content
- Expanding a function to call a plugin or show a link
- Trying to the deduce shortcode from a function
- Pull random comment from specific post, display on homepage with shortcode
- Set thumbnail from URL, by grabbing image in functions.php
- using enqueue_script in a shortcode isn’t working
- Run function from parent on child site
- Gallery Shortcode Function Help
- Echo custom field value in shortcode function
- Shortcodes not outputting in correct divs
- PHP error in shortcode [closed]
- multible shortcodes (for differnt values) with one function