Dokan vendor add shortcode to each vendor - wordpress

I have created e-commerce site with dokan.
I want to add each vendor their own livechat.
I have configured everything and just need to add short code to each vendor, but Dokan don't create new pages for vendors and I can't figure out how to do it.
I sniffed around in Dokan manuals, but can't find this specific field/place to enter shortcode
Can anybody point me into right directon?

You can use the dokan_store_profile_frame_after hook which runs only in the store page to add your shortcode. This hook is run just after the store profile. If you want to exclude certain stores, you can use the $store_user and $store_info to filter out the stores. You can add the following code the functions.php file of the theme.
add_action( 'wp_footer', function() {
$store_user = dokan()->vendor->get( get_query_var( 'author' ) );
$store_info = $store_user->get_shop_info();
if ( dokan_is_store_page() ) {
echo do_shortcode( '[contact-form-7 id="64" title="Contact form 1"]');
}
});

You can try using TalkJs. As per their website they support Dokan.
https://wordpress.org/plugins/talkjs/
https://talkjs.com/knowledge-base/article/does-talkjs-work-with-support/

Related

Wordpress Shortcode for keywords?

So, I know you can put:
function page_title_sc( ){
return get_the_title();
}
add_shortcode( 'page_title', 'page_title_sc' );
Into function.php to fetch the page title and get a [page_title] shortcode within Wordpress, but is it possible to do exactly that for keywords?
I put a focus keyword down in Yoast SEO and I would like to have a shortcode for that.
Or another idea: is there a way to have a custom shortcode field in every page? So that I only have to put something into that once and can use it as a shortcode within the whole page?
If you want a shortcode for Yoast to output the keyphrase automatically:
function wpso_61018203_output_yoast_keyphrase() {
// Make sure Yoast is installed/active.
if ( class_exists( 'WPSEO_Meta' ) ) :
// Hold the global post object.
global $post;
return WPSEO_Meta::get_value( 'focuskw', $post->ID );
endif;
}
add_shortcode('yoast_kw', 'wpso_61018203_output_yoast_keyphrase' );
You can then do this ['yoast_kw'] in your content, or use echo do_shortcode('[yoast_kw]'); in your template.
Use get_post_meta and grab _yoast_wpseo_focuskw:
function page_focus_keyword( ){
return get_post_meta(get_the_ID(), '_yoast_wpseo_focuskw');
}
add_shortcode( 'focus_keyword', 'page_focus_keyword' );
WordPress filters all content to make sure that no one uses posts and page content to insert malicious code in the database. This means that you can write basic HTML in your posts, but you cannot write PHP code.
And you want to use Wordpress shortcode for focus keyword.
Possible solution given on Wordpress.org Yoast SEO plugin support query on similar query, and checkout the linked solution
insert the below php snippet in functions.php
if(!function_exists('wpseoFocusKW'))
{
function wpseoFocusKW()
{
$focuskw = wpseo_get_value('focuskw', $post->ID);
echo $focuskw;
}
}
And to use the shortcode in another page for focused keyword, insert the below shortcode in any pages with yoast-seo plugin :
Shortcode for focus keyword
[<?php wpseoFocusKW();?>]

How to remove wordpress date archive pages?

I have developed my own wordpress theme, and learning all kinds of programming stuff, but my priority is the content, not the programming knownledge. I need to know how to remove archive date listing from wordpress?
Question 1: The google search results displayed like this: virmodrosti.com/2017/05/
I don't want any kind of date archive option, how do you disable that?
I also don't use any kind of plugin, and always like to do it on my own.
Question 2: I don't know why older entries doesn't work anymore
virmodrosti.com/zdravje/ this page works fine
virmodrosti.com/zdravje/page/2/ it redirects to 404 error page
I only choose option in wordpress to hide that annoying /category/ with dash . inside editor at permanlinks, Category base. Maybe somehow these stuff is kinda fighting with each other and doesn't work properly.
Thank you.
This is code from Digital Nomad theme I maintain:
function digitalnomad_remove_date_archives() {
//if we are on date archive page
if ( is_date() ) {
// theme sets alternatine archive page with table like list of all posts
$archive_page = get_option( 'digitalnomad_archive_page' );
if ( $archive_page ) {
// redirs to alternatine archive page if configured (good for SEO)
wp_redirect( esc_url( get_page_link( $archive_page ) ) );
die();
} else {
// otherwise error 404 is displayed
global $wp_query;
$wp_query->set_404();
}
}
}
add_action( 'template_redirect', 'digitalnomad_remove_date_archives' );
Use the smart Archive Page Remover wordpress plugin
or visit your theme's functions.php file
then insert this code
/* Register template redirect action callback */
add_action('template_redirect','makes_remove_wp_archives');
/* Remove archive*/
function makes_remove_wp_archives(){
// if we are on category or tag or date or author archive
if(is_category()|| is_tag()||is_author()){
global $wp_query;
$wp_query->set_404();
}
}

Wordpress Add_filter Priority Issue On 2 Different Custom Plugins (Metaboxes)

I recently developed 2 seperate wordpress plugins for one of my projects
Partners
Resource Library
Both plugins create custom post types fsb_partners and fsb_resource_library. And in both plugins I have created different metaboxes (partners plugin metabox contains one file field i.e. Logo and resource library plugin creates metabox with two file fields i.e. Audio and PDF).
I used following code to create metabox in each plugin:
add_filter( 'cmb_meta_boxes', array($this, "fsb_partners_metaboxes"), 999); ---> Partners Plugin
add_filter( 'cmb_meta_boxes', array($this, "fsb_resource_library_metaboxes"), 999); ---> Resource Library Plugin
Now only metabox at resource library plugin is visible and other is not. If I change the priority of partner plugin metabox to 9999 then it shows up but at the same time resource library plugins goes off.
I know it's wordpress's add_filter hook's priority issue, but am unable to get hands on it. Any help?
Fixed it myself. Just created a separate (common) function in my theme's functions.php as follows:
add_filter('cmb_meta_boxes', function( array $metaboxes = array() ) {
global $fsb_resource_library, $fsb_partner;
if( class_exists('fsb_resource_library') && is_object($fsb_resource_library) ) {
$metaboxes += $fsb_resource_library->fsb_resource_library_metaboxes();
}
if( class_exists('fsb_partners') && is_object($fsb_partner) ) {
$metaboxes += $fsb_partner->fsb_partners_metaboxes();
}
return $metaboxes;
});

Wordpress Page ID within Shortcode

I am using a plugin called: InPost Gallery. I have added the shortcode to a template file but the shortcode needs the post ID to find the images related to the page. Is it possible to get the post id added to a shortcode in a template file?
This is what I have at the moment:
<?php echo do_shortcode("[inpost_nivo slide_width='600px' slide_height='auto' thumb_width='75' thumb_height='75' post_id="28" skin='light' transition_effect='random' transition_speed='600' autoslide='5000' control_nav='1' control_nav_thumbs='1' direction_nav='1' direction_nav_hide='0' controlNavThumbs='0' random_start='0' pause_on_hover='1' show_description='1' box_rows='4' box_cols='8' slices='15' start_slide='0' id='' random='0' group='0' show_in_popup='0' album_cover='' album_cover_width='200' album_cover_height='200' popup_width='800' popup_max_height='600' popup_title='Gallery' type='nivo'][/inpost_nivo]"); ?>
You can see the post_id is set to 28. This needs to change depending on the page currently being viewed.
If this is possible it would be a great help to hear your suggestions.
Many thanks
If it's within the loop, you can for example use:
<?php
// Display shortcode for current post:
$s = sprintf( '[inpost_nivo post_id="%d"]', get_the_ID() );
echo do_shortcode( $s );
?>
You could also try to skip the post_id attribute, and see if it has the same default setup.

Wordpress; Vantage theme & ACF plugin?

I have repeatedly been trying to implement the Advanced Custom Fields (ACF) plugin in the Vantage theme (from AppThemes), but without any success. I've had extensive contact with the admin of ACF, on this subject, but unfortunately we did not succeed. He advised to ask here, maybe seek for a (paid) developer, to solve this problem.
Ok, so what am i trying?
I have created a custom field group and want to implement that field group within the listing form of Vantage. To do so i have read several docs, including: http://www.advancedcustomfields.com/resources/tutorials/creating-a-front-end-form/. To be complete, based on this i did the following in the Vantage theme folder:
I created 2 custom field groups, with the id's: 88 & 139.
In Wrapper.php i added the code: <?php acf_form_head(); ?>
In form-listing.php i created 2 custom hooks, 'product_custom' and 'product_custom2': <?php do_action( 'product_custom' ); ?> <?php do_action( 'product_custom2' ); ?>
In fuctions.php i created 3 functions:
add_action( 'wp_print_styles' , 'my_deregister_styles' , 100 );
function my_deregister_styles() {
wp_deregister_style( 'wp-admin' );
}
add_action( 'product_custom' , 'productfields' );
function productfields() {
$options = array(
'field_groups' => array('post' => '88' ),
'form' => false,
);
acf_form( $options );
}
add_action( 'product_custom2' , 'productfields2' );
function productfields2() {
$options2 = array(
'field_groups' => array('post' => '139' ),
'form' => false,
);
acf_form( $options2 );
}
This actually made the custom field group show up in the listing form of Vantage. However the following things keep going wrong:
Both field groups have a WYSIWYG field. However for some reason the WYSIWYG buttons and media button stop working
I cannot fill in any text in the first WYSIWYG field. Only the second one works for that matter.
No data is stored at all after saving the listing form. On advise of the ACF admin, i tried the following in the acf-master/core/api.php file:
// run database save first
if( isset($_POST['acf_save']) )
{
$txt="Hello world!";
echo $txt;
die();
However the string does not display after saving the listing form. So the if statement is not used...
4. To display the dataon the frontend, once they are saved, I guess the default wordpress codex can be used..
I tried to be as complete as possible;) Is there anybody who can help me any further? Paid assistance is also negotiable..
Thanks a lot in advance!
Robbert
I have succeed on implementing ACF with vantage themes.
I add ACF form at vantage listing form and combine the vantage form with ACF form. with one button.
The data has been saved to database and can be called to displayed in listing area. Only add image button is not working from front-end but in back-end the button is working.
Adding <?php acf_form_head(); ?> to wrapper.php
Do this tutorial front end form help
Eliminate default vantage submit button in form-listing.php
Add this code in ACF api.php in function acf_form_head()
// allow for custom save
$post_id = apply_filters('acf_form_pre_save_post','va_after_create_listing_form', $post_id);
That's it, hope it work in your site.
Is that you want when someone visits the website that they are able to send info via the page they visits eg www.yoursite.com/listing/listing-name like probably an email or contact for more info relating to that business?
If not then you can simply add in the ACF data from the back-end i.e. dreamweaver etc onto single-listing.php and use the ACF tutorial on working with fields.
Hope this helps somewhat
Cheers

Resources