by Garth | May 8, 2018 | PHP, Wordpress
<?php
$user_id = get_current_user_id();
if (!empty($user_id)) {
$user = wp_get_current_user();
$role = ( array ) $user->roles;
// echo $role[0];
if ($role[0] == 'free-client' OR $role[0] == 'administrator') {
//code here...
}
}
?>
by Garth | May 4, 2018 | PHP, Wordpress
// Custom Post 1
register_post_type( 'courses',
array(
'labels' => array(
'name' => __( 'Courses' ),
'singular_name' => __( 'Course' )
),
'public' => true,
'has_archive' => true,
'supports' => array('title', 'editor', 'thumbnail'),
'show_ui' => true
)
);
register_taxonomy('courses_categories', 'courses', ['label' => 'Courses Categories','hierarchical' => true]);
NB! (The hierarchical array item is Important)
,’hierarchical’ => true
by Garth | May 4, 2018 | Debugging, Wordpress
Add this line of code at the top of your child theme function. It should get rid of your error. If not good luck debugging 🙂
wp_enqueue_script('jquery');
by Garth | May 3, 2018 | PHP, Wordpress
<?php echo do_shortcode("[shortcode]"); ?>
by Garth | May 3, 2018 | PHP, Wordpress
Inside your themes functions.php add the below snippet and fill out the placeholders.
############################################################################
//////////////////////////////////////
// This is your shortcode. You reference it like you see below with the square brackets.
// [shortcode_name_here]
//////////////////////////////////////
function echo_shortcode_function_name(){
ob_start();
include '/path to our file';
return ob_get_clean();
}
add_shortcode( 'shortcode_name_here', 'echo_shortcode_function_name');
############################################################################
Now reference your shortcode and it should load no issues if your file references are correct.
by Garth | May 3, 2018 | Wordpress
<?php /* Template Name: any_name.php */ ?>