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
- Use AJAX in shortcode
- Include PHP file in Content using [shortcode]
- functions.php inject inline css
- Shortcode producing headers already sent error
- How to add attributes to a shortcode
- Insert a field with PREG_REPLACE – strange behaviour
- Perform function on publish AND save (not just save)
- Shortcode of a function
- 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?
- Problem with shortcode inside a shortcode
- Display ACF category image on archive and single template files
- Featured Image and Tags problem
- Need help making a short code work
- Using One Function To Create Two Different Shortcodes
- Override a Post’s URL with Advanced Custom Fields Function
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- WordPress Function Assistance with Loop
- How to show ACF value under post/page title in wp-admin
- How to display an image before title text in menu items
- 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
- Pagination not working – FrontPage
- Customizing the wp_video_shortcode output with add_filter
- Filter works on last selection but no others
- page shows short code not output
- How to update an image attachment’s alt text from a custom field when saving a post?
- Probleme shortcode with list author
- Function to function shortcode help [closed]
- Last updated posts shortcode in functions.php
- Help with with my function for wordpress
- I want to display the sku in the product pages of my EDD website
- 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?
- ACF Date Form in Custom Admin Field
- use add_action in a shortcode (gravity form – WordPress)
- Assign IDs to headings in ACF using functions.php
- Reference multiple style sheets, clearing styles for permalink page, custom fields for css
- 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 displaying outside the div [duplicate]
- Shortcode Initialization in a Custom Theme
- Echo a String Based On Geolocation? [Woocommerce || ACF]
- Shortcode with pagination advancing multiple queries
- Comment function for page
- ACF Filter return value
- Show users last read posts for each user?
- Get shortcode attribute value to another function
- How to retrieve image IDs from shortcode content?
- Display list of pages that contain a certain string within the slug
- Hide disclaimer from summary excerpts
- HowTo: Add wrapper to columns shortcode?
- Function not receiving string from shortcode
- How To Show Shortcodes In WordPress Custom Fields?
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Return ACF Field value function
- Custom shortcode with do_shortcode and substr
- Providing fallback function and allow override by plugin
- Shortcode to eliminate and replace with
- Different body image backgrounds on different pages, posts and categories
- Can I use a function to return HTML and the result of another function?
- update_post_meta not working in function
- 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
- How to display data from custom fields in my custom shortcode?
- Modify function Shortcode_atts
- 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
- restrict access to specific urls on a specific period of time
- using enqueue_script in a shortcode isn’t working
- Run function from parent on child site
- does acf_save_post cause endless loop?
- Gallery Shortcode Function Help
- Add title & subtitle to shortcodes
- Echo custom field value in shortcode function
- Shortcode Variations?
- Shortcodes not outputting in correct divs
- shortcode inside post called by ID does not render as expected
- Call ACF data from functions.php [closed]
- Custom shortcode not being included in content paragraph [duplicate]
- trouble with passing class method data to outside function
- Get term count on a category page
- How do grab the main loop, with conditions, and output via shortcodes
- Display function from functions.php in tag.php
- Creating mixture of shortcodes to use in the visual/text editor
- PHP error in shortcode [closed]
- multible shortcodes (for differnt values) with one function
- Update post meta with wp cron
- post_content return zero!
- warning: trying to access array offset on value of type bool ACF field image group
- How to make my logged-in user-role shortcode displaying name instead of slug?
- Uploading images via ACF update_field function