This will probably not work, or work in unexpected way. Shortcodes should probably be displayed only on a “post” single page. Using a shortcode in the way you want will either make the breadcrumbs not to be displayed on archive pages or have them displayed there multiple times or wrong places.
What you should do is a minimal modification to the theme. Insert a do_action('show_bc
); at the appropriate place in the header file (“fork” it in a child theme if you use one). Then add something like add_action('show_bc','breadcrumb_trail');
in the theme’s functions.php
or in a plugin.
As for the exact problem you have in your code, it is because shortcode handlers are supposed to return HTML, and not to output it. If the BC function do not have an option to return the HTML instead of echo-ing, you will have to do output buffering around its call.
Related Posts:
- How do I use Shortcodes inside of HTML tags?
- WordPress Shortcode and Dynamic CSS
- How to create shortcodes that pull custom field data from general settings
- Creating a WordPress shortcode
- the_title() & the_content() are retrieving Post details inside a Page, after calling a shortcode
- Get list of shortcodes from content
- Audio tags around Mp3 URL in content
- has_shortcode() – how to detect nested shortcode
- Wrap each shortcode in array to div
- How do I turn a shortcode into PHP code?
- Put php variable in shortcode
- How to return a foreach inside a shortcode
- Placing raw HTML inside a WordPress shortcode
- How do I add text in a shortcode?
- Template part inside shortcode, unexpected reult
- Shortcode Inside Class Not Working
- Shortcode content output but not in correct place
- Shortcode API: How to get name that matched shortcode RegEx?
- Shortcode content filter?
- How to display posts by current user in a drop down
- Get value from shortcode to do something
- Colon is Missing In My Website Url in WordPress
- Custom shortcode outputs plain text instead of HTML at top of post
- Pass php dynamic variable to shortcode
- wordpress 4.4 self hosted video (html5) doesn’t show
- Shortcode returns values in the wrong order
- Embedding PHP in shortcode $content
- Shortcode with PHP issue “Undefined index”
- Multiple do_shortcode in page template
- get_posts works in the page template but not in a shortcode
- How can I include shortcodes within PHP?
- $wpdb returns duplicate posts
- Syntax error in a shortcode function
- Shortcode to find and replace URL
- How to put a form with php code into a variable or shortcode?
- Help with WordPress function inside a shortcode
- Short code template + ajax
- WordPress shortcode returns the data before
- Shortcode to embed Edit Account form not working
- Handling PHP/HTML inside the output of a shortcode function
- Need to Modify a WordPress Shortcode with another wordpress shortcode
- Split shortcodes to array of shortcodes
- Shortcodes showing in excerpt despite using strip_shortcodes
- PHP error with a shortcode: “no suitable wrapper” for file_get_contents
- How to make a conditional statement within $output in shortcodes.php?
- Shortcode for a Series of Elevating Image Files, Excluding a Range?
- Shortcode won’t execute
- How to get my [shortcode] rendered on the home page, other pages are fine
- Shortcode displaying at the top of the page [duplicate]
- AJAX function not working [closed]
- Can ‘Custom Field’ data be inserted into this Short Code?
- Why wp_remote_get() fetches certain web pages while it doesn’t work for my localhost?
- How to exclude labels from certain categories in a shortcode?
- Set document title through shortcode plugin
- Trying to call dynamic content into a 3rd party shortcode
- Shortcode in Shortcode/HTML Graphics and Pictures
- Why is the current page loaded in the pop-up window and not the specified one?
- How to search order using database frontend short code WordPress
- How do I reopen the (Popup Maker) after entering the correct password for a password protected page?
- Not able to remove caption shortcode from the content
- How to add a shortcode which runs a .php file for the current post
- Block error message in foreach loop when looping through ACF field
- Get title of page containing post grid within the posts
- PHP multiple forms, same page, isset($_POST[]) not working?
- Shortcodes not processing inside post content
- Gravity Forms: How to add PHP function to confirmation conditional shortcode?
- wpdb->query returns different value to phpMyAdmin
- shortcodes, custom php and their errors
- I want to hide “sold by” on certain pages with id page 43
- How to add a PHP scripts into WordPress
- How to return html as a string from php for WordPress
- Changing Date Format on Custom Meta Data w/shortcode call
- Why my Ajax events are no longer detected after dynamic change of shortcode content
- Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields
- Replacing entire tag with shortcode – JavaScript [duplicate]
- Get posts by id using shortcode
- Shortcode just with a php code
- How can i iterate through this shortcode array?
- Custom fields changes the formatting of metabox input
- Shortcode is not outputting all of the desired markup
- Run PHP Results inside WP Shortcode
- Contact form field in wordpress menu
- Serializing URL via wp add_shortcode to auto select from option list onload
- php string inside shortcode does not work
- Limit the number of successful logins
- Shortcodes (with a space) added to php Sample
- On selecting shortcode generate selected shortcode table inside page editor worrdpress
- Show contact 7 form in popup
- How can I put a custom field as the link of a button shortcode?
- Custom field within shortcode
- Problem using explode inside add_shortcode() callback funciton [closed]
- Php inside the shortcode is getting commented
- My title is showing after the shortcode
- Display Current Time using shortcode
- Set variable in javascript and using in my shortcode
- How to create shortcode of this PHP code
- Gutenberg – render_callback does not pass ToggleControl value on frontend
- HTTP 500 Error after Creating Shortcode
- How call WordPress shortcode inside function file
- How to execute a shortcode within a custom field?