Can’t display shortcuts
-
Hi, I’m trying to add an image to a tab with image description, but only a broken shortcut for caption will appear.
How can I fix so that it is possible to use shortcuts in custom tabs?
-
Hi @kennyecodisplay,
It sounds like the HTML is broken. Can you send me a URL to a page with one of these images so I can inspect the HTML?
Thank you,
Kevin.Hi @kennyecodisplay,
Are you talking about the
[caption id="attachment_23655" align="aligncenter" width="50"]part of your main product area?First, this is not a custom tab area so it isn’t an issue with custom tabs (and this isn’t the appropriate forum for this question).
However, I can tell you that the issue appears to be WooCommerce is not running shortcodes for this section (i.e. shortcodes aren’t being executed).
How are you adding this code? Are you adding it directly to the template?
Let me know.
Cheers,
Kevin.Thanks for the quick response!
Yes exactly. I have only moved custom tabs to [woocommerce_single_product_summary] and I use other shortcodes there without any problems
You can use a shortcode in a custom tab but you can’t use it everywhere on a page.
I’m not sure the best way to add a shortcode to the main product summary but I think you’ll need to edit the template (i.e. the underlying PHP file).
Cheers,
Kevin.hmm, could it have something with the custom tab shortcode I found in a support thread that you had created?
Sorry for my bad knowledge!
I use this code:function yikes_custom_product_tabs_shortcode( $args ) {
global $post;// Define our default values
$defaults = array(
‘product_id’ => $post->ID,
);// Let the user-defined values override our defaults
$values = is_array( $args ) ? array_merge( $defaults, $args ) : $defaults;// Make sure we have a product ID and that the product ID is for a product
if ( empty( $values[‘product_id’] ) || ! empty( $values[‘product_id’] ) && get_post_type( $values[‘product_id’] ) !== ‘product’ ) {
return;
}// Fetch our tabs
$tabs = get_post_meta( $values[‘product_id’], ‘yikes_woo_products_tabs’, true );// Debug statement to show all tab data. Feel free to remove.
// echo ‘'; var_dump( $tabs ); echo '
‘;
$html = ”;
// Loop through the tabs and display each one
foreach( $tabs as $tab ) {
$html .= ‘<p>’ . $tab[‘content’] . ‘</p>’;
}// Make sure to return your content, do not echo it.
return $html;
}add_shortcode( ‘custom_product_tabs’, ‘yikes_custom_product_tabs_shortcode’ );
and put it out with this function:
function move_custom_tab_content() {
echo do_shortcode(‘<div class=”product-icon-block”>[custom_product_tabs]</div>’);
}
add_action(‘woocommerce_single_product_summary’, ‘move_custom_tab_content’, 2 );Hi @kennyecodisplay,
Okay, I think I see what you’re doing.
First, you can’t pass HTML into the
do_shortcode()function.So try this…
function move_custom_tab_content() { echo '<div class="product-icon-block">' . do_shortcode( '[custom_product_tabs]' ) . '</div>'; } add_action('woocommerce_single_product_summary', 'move_custom_tab_content', 2 );Let me know once that change has been added.
Thank you,
Kevin.-
This reply was modified 7 years, 5 months ago by
yikesitskevin.
-
This reply was modified 7 years, 5 months ago by
yikesitskevin.
Unfortunately it did not work. I also tried to move the tab out of “summery” but no luck there either
Show me how/where it isn’t working.
Also, are you trying to execute a shortcode that has a shortcode inside of it?
https://ecodisplay.se/produkt/backdrop-eco-textil/
I’m just trying to add a picture description but I only get a broken shortcode instead.
It works well when I do not move custom tabs with the shortcodeI don’t understand why you’re trying to use a custom product tabs shortcode…
Instead of doing
function move_custom_tab_content() { echo '<div class="product-icon-block">' . do_shortcode( '[custom_product_tabs]' ) . '</div>'; }Why don’t you just do…
function move_custom_tab_content() { echo '<div class="product-icon-block">' . do_shortcode( '[caption id="attachment_23655" align="alignnone" width="55"]Test[/caption]' ) . '</div>'; }Why are you trying to move a custom tab when you can just insert the content directly?
-
This reply was modified 7 years, 5 months ago by
yikesitskevin.
because I use different information on each product and want to use this field to add information up there and eventually even among the regular tabs
The shortcode that you copied from the other thread tries to echo all of the custom tabs. I don’t think this is what you’re looking for.
For this product, https://ecodisplay.se/produkt/backdrop-eco-textil/, which custom tab are you trying to echo?
Actually, I just want to move one specific tab but is not so important at the moment, as I will only use one tab and it will be in summery.
My goal is to get an extra field in the summery, which is easy to edit on each product. I use Custom tabs because I felt I could benefit from it on more occasions.
I know i use custom tabs a little wrong but still thought this was a good solution because i will then use 1 plugin for two things and everything will be edited in the same place.
Everything works great and simple but it’s just that I can not use shortcodes in the tab
-
This reply was modified 7 years, 5 months ago by
The topic ‘Can’t display shortcuts’ is closed to new replies.