Skip Navigation

[Resolved] Yoast breadcrumbs custom shortcode issue

This support ticket is created 7 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by guyA-2 7 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#524433
Screen Shot 2017-05-15 at 21.43.02.png
Screen Shot 2017-05-15 at 21.41.00.png
Screen Shot 2017-05-15 at 21.40.13.png
Screen Shot 2017-05-15 at 21.40.03.png

Hi there,

I am trying to: Add a breadcrumb shortcode to my theme using Yoast SEO and a custom shortcode that I've inserted into my header parent layout.

I've enabled breadcrumbs in yoast and created a custom breadcrumb shortcode.

But when I insert my shortcode into my layout it's just coming up with square brackets... this makes me think there's something wrong with my shortcode.

If you take a look at hidden link - you'll see a white band above the blue header. This is incorrect and seems to be inserted by Yoast after I turned on their breadcrumb functionality.

Then below the header you see my shortcode.
It seems like Yoast is inserting the breadcrumb (that says home on every page - without actually showing the breadcrumb trail.)

See my attached screengrabs of:

  • how the header should look (no home breadcrumb above the header)
  • my custom shortcode
  • functions file
  • my layout in edit mode

Thanks in advance for your support.

Guy

#524462

Hi, did you test your shortcode without Types and Layouts enabled? I don't quite understand your setup, but I don't think it's coded correctly:

add_shortcode('yoast_breadcrumb', 'wildheart_breadcrumb');

This indicates that you are creating a new shortcode, 'yoast_breadcrumb'. When this shortcode is rendered, WP will look for the function 'wildheart_breadcrumb' and execute that function. However, I do not see this function anywhere in the code you have provided. Am I missing something?

More info about the shortcode API here:
https://codex.wordpress.org/Shortcode_API

if ( function exists('yoast_breadcrumb')) {
  yoast_breadcrumb('<p id="breadcrumb">', '</p>');
}

I'm not sure what this is supposed to do, or how it is supposed to relate to the shortcode. Here's an example of the shortcode implementation I use:

// custom shortcode to display results count based on View ID passed in as shortcode attribute
add_shortcode( 'ts_view_num_results', 'ts_view_num_results_func');
function ts_view_num_results_func($atts)
{
  $view_id = intval($atts['viewid']);
  $results = get_view_query_results( $view_id );
  return count($results);
}

Then I use the shortcode like this:

[ts_view_num_results viewid="123"]
#525093

Thanks Christian,

I spent another hour on this but couldn't get it working. I've never created a shortcode before so been muddling through it.

I've found a plugin that add the Yoast breadcrumb shortcode to our site.

I wanted to avoid using another plugin and also don't like the markup that this shortcode generates. But I need to keep moving forward.