X theme search feature showing shortcodes

Hey guys!

I’ve got a site that is ready to launch, except we have a problem. The shortcodes I’m using in the “short product description” field of WooCommerce isn’t rendering as a button in the search results…it just looks like junk code and the client isn’t happy.

Can we do anything about this??

Hi there,

Please install and activate Cornerstone.

Hope this helps.

Cornerstone is installed and activated. I just updated it but it was up and running prior to this issue.

This screenshot it taken moments ago, after updating to the latest version of Cornerstone:

Same problem.

Hey There,

Would you mind providing us with login credentials so we can take a closer look? Please provide following information:

Set it as Secure Note

  • Link to your site
  • WordPress Admin username / password
  • FTP credentials

All the best!

Hi There,

Sorry for the confusion. By default, search result page and other archive pages are displaying excerpts of post/pages/portfolio. Excerpts disable the behavior of any code and shortcode and display them as simple text. So, using a shortcode in a post/product/portfolio and this case short product description will only appear as normal text in your blog or category archive pages or search result page. On post or pages there’s an option to add manual excerpts. On Product Short Description, it is different, we’re not supposed to use shortcodes, it should contain plain text because it will be shown on search result and if you share your product on social media. You can use shortcode there but at least some of the text at first should be plain text so that it comes up in search result and social share as a short summary. You can use the product description area to place any text, shortcode you want.

So it sounds like the short of it is that I can’t use short codes in the product short description? This is going to change quite a few things for us seeing as every product page has a shortcode button that gets copied every time a new product is added.

What’s the character cut off for the search results short product description? How many more characters of plain text do I need to add so the shortcode drops below the view? That might be the fastest “hack”.

Hi,

Do you need to add it in all products?

If that’s the case you can try adding the code below in your child theme’s functions.php


function add_button() {
     global $post;
  if((is_search() && get_post_type( $post->ID ) == 'product') || is_product()) {     
      echo do_shortcode('[x_button shape="square" size="large" float="none" href="/Dev/literature/" info="none" info_place="top" info_trigger="hover" style="color: #fff; background-color: #a3d55f;"]LITERATURE[/x_button]');
  }
}

add_action( 'x_before_the_excerpt_end', 'add_button', 10 );
add_action( 'woocommerce_before_add_to_cart_form', 'add_button', 10 );

Then remove all button shortcode in your product description.

Hope that helps.