Having trouble in Javo Directory WordPress theme? Currently the PHP class code that manage all the templating system of the Javo Directory WordPress theme. I’ll have a sample code on how to add new dashboard page using Javo Directory WordPress theme.
In my case I’d like the `Add Listing` page to be displayed within dashboard pages. To do that, please follow the steps below.
Step 1: Open your functions.php of your current theme and paste the `define` codes below. You need this on the file template path.
define( 'OC_CHILD_APP_PATH', get_stylesheet_directory() ); define( 'OC_CHILD_SYS_DIR', OC_CHILD_APP_PATH."/library"); define( 'OC_CHILD_DSB_DIR', OC_CHILD_SYS_DIR."/dashboard");
Step 2: Create a sub page `add-listing` using `jvfrm_spot_dashboard_slugs` filters.
add_filter( 'jvfrm_spot_dashboard_slugs', 'ac_jvfrm_spot_dashboard_slugs', 10, 3 );
function ac_jvfrm_spot_dashboard_slugs( $pages ){
$pages['JVFRM_SPOT_ADD_LISTING_SLUG'] = 'add-listing';
return $pages;
}
Step 3: Replace the template directory if the current sub page slug is `add-listing` using `jvfrm_spot_dashboard_custom_template_url`.
add_filter( 'jvfrm_spot_dashboard_custom_template_url', 'ac_jvfrm_spot_dashboard_custom_template_url', 10, 3 );
function ac_jvfrm_spot_dashboard_custom_template_url( $template_url, $query_var ){
if( $query_var == 'add-listing' ){
return OC_CHILD_DSB_DIR . '/type-c/mypage-' . get_query_var( 'sub_page' ) . '.php';
}
return $template_url;
}
Step 4: Create a folder path from your child theme my-child-theme > library > dashboard > type-c > mypage-add-listing.php
Step 5: Inside the `mypage-add-listing.php` copy and paste the codes below.
<?php
global $jvfrm_spot_curUser, $manage_mypage;
$is_allowed_read = is_user_logged_in() && ( current_user_can( 'manage_options' ) || jvfrm_spot_getDashboardUser()->ID == get_current_user_id() );
require_once JVFRM_SPOT_DSB_DIR . '/mypage-common-header.php';
get_header( 'mypage' );
?>
<div class="row my-add-listing">
<div class="col-md-12">
<div class="card">
<div class="card-header"><h4 class="card-title">Add Listing</h4></div>
<div class="card-block">
<div class="my-add-listing-box text-center"><?php echo do_shortcode( "[lava_directory_form]" ); ?></div>
</div>
</div>
</div>
</div>
<?php
get_footer( 'mypage' );
Step 6: Then that’s it. You have the `Add Listing` page within your dashboard page.