Last active
February 26, 2025 00:01
-
-
Save nayemDevs/1fc0c4840fc6da5ce08c8ac5d0bcd721 to your computer and use it in GitHub Desktop.
Creating a shortcode to show vendor biography anywhere on your page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Dokan Vendor Biography Shortcode | |
*/ | |
add_shortcode( 'dokan_vendor_bio', 'dokan_vendor_bio_shortcode' ); | |
function dokan_vendor_bio_shortcode() { | |
$vendor = dokan()->vendor->get( get_query_var( 'author' ) ); | |
$store_info = $vendor->get_shop_info(); | |
if ( empty( $store_info['vendor_biography'] ) ) { | |
return; | |
} | |
printf( '%s', apply_filters( 'the_content', $store_info['vendor_biography'] ) ); | |
} | |
// user vendor bio shortcode on single product page | |
add_shortcode( 'dokan_vendor_bio_single', 'dokan_vendor_bio_shortcode_single' ); | |
function dokan_vendor_bio_shortcode_single() { | |
global $product; | |
$seller = get_post_field( 'post_author', $product->get_id()); | |
$author = get_user_by( 'id', $seller ); | |
$vendor = dokan()->vendor->get( $seller ); | |
$store_info = dokan_get_store_info( $author->ID ); | |
if ( !empty( $store_info['vendor_biography'] ) ) { ?> | |
<span class="details"> | |
<?php printf( $vendor->get_vendor_biography() ); ?> | |
</span> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We tried your update and it doesn't work either. The entire function is faulty.