It looks like wp_list_categories($args)
will output directly when you call it, which is why the output comes out in a weird place. and ideally what you need is to capture the output and return
it, but luckily wp_list_categories allows you to do this with the ‘echo’ parameter. Try:
$args['echo'] = FALSE;
return wp_list_categories($args);
Note the extra ‘return’
Related Posts:
- Possible to display shortcode based on the category?
- Display a list of random terms from custom taxonomy with shortcode
- Solution to render Shortcodes in Admin Editor
- Use AJAX in shortcode
- Include PHP file in Content using [shortcode]
- Shortcode producing headers already sent error
- How to add classes to images based on their categories?
- current_cat_ancestor Alternatives
- Enabling shortcodes for custom fields
- Add body class of category parent
- How to use get_media_embedded_in_content function
- Shortcode with parameters inside parameters
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- What is wrong with this Shortcode? I get it in a wrong place inside the content
- How to set child post categories to parent post categories when updating parent post?
- Display a text message if the shortcode is found?
- Make Categories a Dropdown Menu in Media Library
- Programmatically Create Category and sub Category
- Attach parent category template to all subcategories
- exclude a category from a search on a specific page
- Check child/parent categories if exists
- Custom HTML in specific category single page and its descendant categories
- Display first name of logged in user?
- Shortcode pagination not advancing
- Having issues with a foreach inside of a shortcode with ACF gallery
- Shortcode inserts paragraphs before and after executing shortcode
- Ordering posts by publish date not working?
- How to filter $content in shortcode function
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- Categories as main menu items and subcategories as nested lists
- Add button to kitchen sink toggle
- Redirect to another page using contact form 7? [closed]
- Need help “sanitizing” a custom function that pulls category slug into body class
- Help With Creating Shortcode
- Setting a default text for excerpts of a particular category
- How to fix get_the_category function returning incorrect slug?
- Shotcode argument issues
- Shortcode parse error – wrong syntax
- Exclude category from shortcode
- get_pages() Returns Only One Item
- Adding an option to a shortcode
- How to use author meta in shortcode?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Use a shortcode to display custom meta box contents
- How to rewrite wordpress search to work on specific category
- Woocommerce checkout field
- How can I pass a shortcode value to the head in wordpress functions.php
- Native gallery custom html output
- Exclude Category ID in function
- dynamic site link for future migration in echo do_shortcode()
- Tracking the number of shortcodes for a list?
- Need a method to prevent WP from adding in between my shortcodes
- Load scripts for do_shortcode( ‘ [ my_shortcode ] ‘ )
- Can I include a custom PHP function in a WordPress function?
- How to create a shortcode out of a php function
- Shortcode of a function
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- Display ACF category image on archive and single template files
- Using One Function To Create Two Different Shortcodes
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- get category in list of posts // shortcode for custom related posts
- Return all Tags and Categories in Separate List
- How to add if statement on WordPress shortcode output
- Pagination not working – FrontPage
- Display link to category over featured image
- page shows short code not output
- Function to function shortcode help [closed]
- I want to display the sku in the product pages of my EDD website
- Adding new Category does not refresh the backoffice
- How do i tweak my wp Post title base on category of the post
- Shortcode to insert default text and change one word throughout it?
- use add_action in a shortcode (gravity form – WordPress)
- Menu and category highlighting for a single post
- i can’t use wordpress functions in ajax loaded php file
- Shortcode displaying outside the div [duplicate]
- Drop down list code for sidebar
- Shortcode Initialization in a Custom Theme
- Shortcode with pagination advancing multiple queries
- Show users last read posts for each user?
- Get shortcode attribute value to another function
- How to retrieve image IDs from shortcode content?
- Hide disclaimer from summary excerpts
- Function not receiving string from shortcode
- require_once() Causing categories and tag pages on dashboard to not refrsh
- How To Show Shortcodes In WordPress Custom Fields?
- Shortcode to eliminate and replace with
- Problem in outputting shortcode
- Shortcode to output get_header not working
- restrict access to specific urls on a specific period of time
- How to get tags and categories?
- using enqueue_script in a shortcode isn’t working
- How to Insert A List of Posts in A Category Written by the Author into the Author Archive
- Add title & subtitle to shortcodes
- Shortcodes not outputting in correct divs
- 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
- Get category of post inside save_post hook