• Resolved gl_SPICE

    (@gl_spice)


    Hi!

    I have several dashboards that should have diferent templates by post_type. So I have to hack plugin files to reach this. I add new function to wpuf-functions.php:

    function wpuf_load_dashboard( $args = array() ) {
    
        if ( $args && is_array( $args ) ) extract( $args );
    
    	$file = locate_template( array( 'wpuf/dashboard-' . $post_type . '.php', 'wpuf/dashboard.php' ) );
        $wpuf_dir = WPUF_ROOT . '/templates/';
    
        if ( file_exists( $file ) ) {
            include $file;
        } else {
            include $wpuf_dir . $file;
        }
    
    }

    and change wpuf_load_template in frontend-dashboard.php with this:

            wpuf_load_dashboard( array(
                'post_type' => $post_type,
                'userdata' => wp_get_current_user(),
                'dashboard_query' => $dashboard_query,
                'post_type_obj' => $post_type_obj,
                'post' => $post,
                'pagenum' => $pagenum
            ) );

    Now I can create files in my template directory like this “dashboard-works.php” and code dashboard only for “works” post type.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author weDevs

    (@wedevs)

    @gl_spice, If you want to display a specific post type, you need to mention that. For example, if you want list event instead of post, you can use [wpuf_dashboard post_type=”event”].

    Reference:
    https://docs.wedevs.com/docs/wp-user-frontend-pro/getting-started/user-dashboard/

    You can create the different page with different page template & include that shortcode including custom post type.

    Thread Starter gl_SPICE

    (@gl_spice)

    Hi, weDevs Support!

    Thank you for the reply! Ofcause I use this shortcode, and I specify post_type in it. But I need different looking templates for different post_types! And its better for me to use different template files for this. Now I have separate dashboard files for some post types like “dashboard-event.php” or “dashboard-works.php” and default “dashboard.php” for everything else!

    This is useful feature, I think it should be implement in feature versions =). It’s easy to code and usefull in some cases.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How I implement Dashboard templates’ is closed to new replies.