Add new tabs to display custom post type

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM Add new tabs to display custom post type

Viewing 2 reply threads
  • Author
    Posts
    • #133316
      ceo3
      Participant

      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.

    • #133437
      Sushobhan
      Keymaster

      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!

    • #133443
      Sushobhan
      Keymaster

      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.

Viewing 2 reply threads
  • The topic ‘Add new tabs to display custom post type’ is closed to new replies.