TransWikia.com

How do I make a shortcode to display the shop name on Dokan?

WordPress Development Asked by Sean Taylor on December 5, 2020

I’m trying to create a shortcode to display the name of the store selling the product on the single product page. However, the shortcode doesn’t show up in the single product page. I am using the Dokan Pro plugin. Here’s the code I have so far, I put it in the functions.php:

// "store name" Shortcode

add_shortcode('storename', 'shortcode_storename');

global $product, $woocommerce;
function shortcode_storename () {
    return get_shop_name ( $store_user->ID, 40);
}

One Answer

There doesn't seem to be anything wrong with your code. First thing to check is whether it is evaluated at all by adding something like echo "WPSE!!" in the function and see if that string turns up in the source code.

If it does turn up, the problem must be in get_shop_name returning empty. That would be a problem with WooCommerce rather than WordPress proper.

If it does not turn up, the problem most likely is that shortcodes are not evaluated at all in the input field where you are using it. Only in the content field and the default text widget shortcodes are evaluated automatically. In other cases you must specify it like this:

add_filter ( 'input_field_name', 'do_shortcode' );)

Answered by cjbj on December 5, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP