Unable to edit categories in custom post type

CPT capabilities do not cover taxonomies. Each taxonomy has its own capabilities. If you want to use default Categories, unfortunately you must give user “Edit Posts” capability. There is no easy way around it, especially with Gutenberg. Best solution would be to create custom taxonomy “Event Categories” with matching capability requirements, for example, mapping all … Read more

How to exclude subscriber from the list in wordpress

working code ..thx @michael <?php $number = 10; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $offset = ($paged – 1) * $number; $users = get_users(); $query = get_users(‘&offset=”.$offset.”&number=”.$number.”&role__not_in=’.subscriber); $total_users = count($users); $total_query = count($query); $total_pages = intval($total_users / $number) + 1; echo ‘<ul id=”list-mitra”>’; foreach($query as $q) { ?> <li class=”bullet-arrow”> <a href=”#mitra<?php echo get_the_author_meta( … Read more

Conditional post thumbnail based on logged status and post tag

Hey you have to use the below logic to handle the above conditions, it will work. if (!is_user_logged_in() && has_tag(‘private’)) { ?> <a href=”https://wordpress.stackexchange.com/questions/368246/<?php the_permalink(); ?>” title=”<?php the_title_attribute(); ?>”> <img src=”<?php bloginfo(‘template_directory’); ?>/img/default-login.jpg” alt=”<?php the_title(); ?>” /> </a> <?php } else if( is_user_logged_in() && has_tag(‘private’) ) { // show the actual featured image // check … Read more

Add User Role: Pre-saved in User-Meta [SOLVED]

That’s because you’re not passing an actual ID to get_user_meta, but merely a string of id: $get_portal_number = get_user_meta(‘id’, ‘portal_number’, false); In addition, the third parameter is set to false, which will return an array. You’re passing that value straight to $user->add_role, but that expects a string. You either have to loop over your post … Read more

Load user by specific role

One possible way is by using the role__not_in parameter like so which excludes all other roles except subscriber: // Include only the following role(s): $roles_in = array( ‘subscriber’ ); $roles_not_in = array_diff( array_keys( wp_roles()->get_names() ), $roles_in ); $args = array( ‘role__not_in’ => $roles_not_in, ); $subscribers = get_users( $args ); But of course, if you know … Read more

Custom shortcode for displaying user based on a role parameter

First, you’ll have to get shortcode parameter(s). Change function’s declaration to: function display_user_roles( $atts ) { Your shortcode will be either [hw_display_users] or [hw_display_users role=”roletopass”]. The first (no parameter) will use role specified in $args array. Second will replace $args->role with parameter passed. Add if ( !empty( $atts[‘role’] ) ) $args[‘role’] = $atts[‘role’]; before $users … Read more

Recent posts on homepage: different thumbnail based on logged in status and post category

If you want to use the the_ functions (e.g. the_permalink() and the_title()) and including in_category() (without specifying the second parameter) outside of The Loop (the standard one which calls the_post()), you should access the global $post variable and call setup_postdata() to set up global post data and after your foreach ends, call wp_reset_postdata() to restore … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)