Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM › Add new tabs to display custom post type
Tagged: tab; custom post type
- This topic has 2 replies, 2 voices, and was last updated 4 years, 6 months ago by Sushobhan.
- AuthorPosts
- May 20, 2020 at 4:24 am #133316ceo3Participant
Create a snippet with this code to add a new image to the custom post type “artists”. I’ve already made changes to the code, but we only show products.
I took this source code to add a new tab here in the forum.
I need to add two custom tabs, one for the “artists” cpt and one for the “exhibitions” cpt.
add_filter( 'wcfmmp_store_tabs', 'custom_wcfmmp_store_tabs2',90,2); function custom_wcfmmp_store_tabs2($store_tabs, $vendor_id) { $store_tabs['newtab'] = __( 'Artistas', 'wc-multivendor-marketplace' ); return $store_tabs; } add_filter( 'wcfmp_store_default_query_vars', 'wcfm_store_events_default_query_var2' ); function wcfm_store_events_default_query_var2( $query_var ) { global $WCFM, $WCFMmp; if ( get_query_var( 'newtab' ) ) { $query_var = 'newtab'; } return $query_var; } add_filter( 'wcfmp_store_tabs_url', 'new_wcfmp_store_tabs_url2',10,2); function new_wcfmp_store_tabs_url2($store_tab_url, $tab) { switch( $tab ) { case 'newtab': $store_tab_url = $store_tab_url.'newtab'; break; } return $store_tab_url; } add_action( 'wcfmmp_rewrite_rules_loaded', 'new_register_rule2', 8 ); function new_register_rule2($wcfm_store_url) { global $WCFM, $WCFMmp; add_rewrite_rule( $wcfm_store_url.'/([^/]+)/'.$WCFMmp->wcfmmp_rewrite->store_endpoint('newtab').'?$', 'index.php?post_type=artistas&'.$wcfm_store_url.'=$matches[1]&'.$WCFMmp->wcfmmp_rewrite->store_endpoint('newtab').'=true', 'top' ); add_rewrite_rule( $wcfm_store_url.'/([^/]+)/'.$WCFMmp->wcfmmp_rewrite->store_endpoint('newtab').'/page/?([0-9]{1,})/?$', 'index.php?post_type=artistas&'.$wcfm_store_url.'=$matches[1]&paged=$matches[2]&'.$WCFMmp->wcfmmp_rewrite->store_endpoint('newtab').'=true', 'top' ); } function wcfm_vendor_profile_custom_endpoint2() { global $WCFM, $WCFMmp,$WCFMu; $wcfm_store_url = get_option( 'wcfm_store_url', 'store' ); add_rewrite_endpoint( 'newtab', EP_ROOT | EP_PAGES ); } add_action( 'init', 'wcfm_vendor_profile_custom_endpoint2',12 );
I appreciate your help to resolve.
- May 20, 2020 at 12:36 pm #133437SushobhanKeymaster
Hi,
In that topic, there was some additional information-Create “wcfmmp-view-store-newtab.php” file in your active theme’s
/wcfm/store/wcfmmp-view-store-newtab.php. In this file add your custom content. Also, you haven’t mentioned how the store is related to these custom post types? Are the vendors set as the author of these posts (artists)? Based on that information we will need to change your ‘new_register_rule2’ function.
Let me know. Thanks!
*edit- I wasn’t even aware of the fact that you were using WCFM CPT plugin. Because you told that to some other topic but forget to mention here!
- May 20, 2020 at 12:45 pm #133443SushobhanKeymaster
Hi,
As I can see, you are already discussing this on some other threads
https://wclovers.com/forums/topic/how-to-add-custom-post-types-to-your-store-manager-dashboard/#post-131114
https://wclovers.com/forums/topic/request-custom-tabs-manager-in-vendor-store-page/#post-133188
Please, don’t create duplicate entries. It becomes hard to track and also engage multiple support personnel to solve same issue. Which can’t be a good thing.
I’m closing this thread as well.
- AuthorPosts
- The topic ‘Add new tabs to display custom post type’ is closed to new replies.