‘echo’ statement will not work in shortcode function. shortcode function is just returning the variable; So your code will be like this:
if(get_field('group')) {
$html="";
$html.= "<ul class="sponsors"><h2>" , get_the_title() , "</h2>";
while(has_sub_field('group')) {
$attachment_id = get_sub_field('image');
$size="sponsorimage";
$image = wp_get_attachment_image_src( $attachment_id, $size , false );
$link = get_sub_field('link');
$html.= "<li>";
$html.= "<a href="" , $link , "" target="_blank">";
$html.= "<img src="" , $image[0] , "" />";
$html.= "</a>";
$html.= "</li>";
}
$html.= "</ul>";
}
endwhile; endif; wp_reset_query();
return $html;
Related Posts:
- How to manually fix the WordPress gallery code using PHP in functions.php?
- Build a content and excerpt grid loop with paging and options for # of posts
- Shortcode putting html such as
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Shortcode created to check language not works
- Add/echo div with Analytics-Code to function in functions.php
- How to add 2 posts under another post? Formatting should be intact
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- How can I default to all WordPress roles when parameter is not included in shortcode?
- WordPress menu deletes when trying to add a hook
- Recent post display using shortcode
- Nested shortCode functions in the functions.php file
- Making Quote Plugin more efficient
- Shortcode content output but not in correct place
- Use wp_get_recent_posts with search term
- Remove query string specific key value
- is_page “range” for if statement?
- PHP code inside shortcodes
- Use WP_Query in shortcode
- Trigger popup in a php if/else statement
- How to output a PHP file values by shortcode?
- Showing content from one page on another
- Get value from shortcode to do something
- How to prevent WP_Query function from returning all posts when empty?
- Display a specific category of products in shop page and disable code for specific actions
- Get users that likes the post
- Pass php dynamic variable to shortcode
- How to Reference/Echo Variable from Another PHP Function
- Redirect to another page using contact form 7? [closed]
- Security for data obtained from the database
- Shortcode with PHP issue “Undefined index”
- Shortcode from a function not working
- Display Data in Table from External Database in WP using Shortcodes
- Is it possible to return content, and then also continue to do other things?
- ::before on open/close function [closed]
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- Creating WordPress Shortcode with Variable
- Help with WordPress function inside a shortcode
- calling a custom field value inside functions.php
- List all blogs, but exclude the main site
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- Shortcode for Listing Users from Meta Value?
- change the default order of posts only for specific categories
- Cant display an image via PHP in wordpress
- Post not populating for custom post type based on category selection
- Custom query vars filters problem with pagination
- How to return a string that has a jQuery and Ajax inside in a shortcode?
- How to get post category list as select in front-end?
- Create special button on WP Tiny MCE Posts Editor for Shortcodes
- Displaying Event within two given time frames
- AJAX function not working [closed]
- Let current user know pending posts counts using wp_query
- Output product category link from WP_Query
- How to work Woocommerce pagination inside shortcode?
- Updating Metadata with Shortcode
- “pre_get_posts” orderby custom date field in different format?
- Display logged in user name and lastname on page
- Create shortcode for metabox gallery
- How to exclude meta no index pages from wp_list_pages
- Display Visual Composer shortcode if a post belongs in specific categories
- How do I reopen the (Popup Maker) after entering the correct password for a password protected page?
- Ajax filter with loadmore button
- How can I prevent a shortcode div from extending beyond its boundaries?
- posts_per_page displays only 2 posts instead of 4 posts
- Gravity Forms: How to add PHP function to confirmation conditional shortcode?
- Display a custom name when the user has no name settle in his account
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- Delete post meta by serialized meta value
- Display current user metadata on WordPress page
- Reload page with a different shortcode when a user selects from a dropdown
- Modify post image in full size
- How Can I Display the Last Modified Date for User Profiles on WordPress?
- Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- WP_Query To Display Product Of Brand On Taxonomy Page
- Offset with ajax load more posts duplicates
- Shortcode’s output to use as other shortcode’s parameter
- Custom Post type Ajax search results
- Open/closed function [closed]
- Need to Echo A Url path to show on a wordpress page
- Wrapping shortcode content in a span or link
- My query keeps looping infinitely ! how to stop it?
- Need help with PHP functions
- How can I display a query in a page?
- Weird Behaviour: Not all WordPress Posts appearing
- How to have Function of a plugin using global vars into a shortcode?
- List sibling pages widget, exclude current page
- Overwriting a Shortcode
- How to get category pages to look like a certain archive page?
- Shortcoding with Divs
- Whats wrong with my code? Need To add String to shortcode? [closed]
- My title is showing after the shortcode
- How to modify this function to exclude also the post belonging to a specific category?
- A next page function with shortcode?
- Shortcode to include PHP file, pass various parameters to include?
- WP Custom tables query
- Display terms on product page with shotrcode
- How call WordPress shortcode inside function file
- /page/2/ redirect to 404
- Add adjacent post function inside custom recent post function