Remove from a div by class name from post page if post author role is not administrator

Basically you are asking a function to check the post author role. You can use user_can() function. if(user_can(‘administrator’)) { //Write your code if the admin } current_user_can() : https://codex.wordpress.org/Function_Reference/current_user_can user_can() : https://codex.wordpress.org/Function_Reference/user_can

Slider Thumbnail Size Issue [closed]

You are on a good track. You first define your thumbnail sizes in your functions.php Make you upload big high-quality images but still good enough for the web You then need to regenerate your thumbnail, I recommend this plugin: https://wordpress.org/plugins/regenerate-thumbnails/ In you new code, you need to call your desired thumbnail based on the size … Read more

How to echo the translated custom field?

can you do this: get_post_meta(get_the_ID(), ”, true); print_r($meta); or get_post_meta(get_the_ID(), ‘my_custom_field’); print_r($meta); the first will pull all custom post type on the current post, and the second restricts to the field. You should get an array and then you’ll know which item in your array is the field title you’re looking to pull. then you … Read more

Trim excerpt to first paragraph

You can match this with regEx and easily choose the amount of paragraphs to return. // in context function triangle_x_excerpt( $text, $raw_excerpt ) { $content = apply_filters( ‘the_content’, get_the_content() ); $text = ( preg_match( sprintf( ‘~(<p>.+?</p>){%d}~i’, 1 ), $content, $matches ) ) ? $matches[ 0 ] : $content; return preg_replace( “/<img[^>]+\>/i”, “”, $text ); } … Read more

Problem with custom WP_Query and underlying pagination/posts_per_page

Stop overriding the default loop and use pre_get_posts instead. Like this: function wpse_247208_custom_category_query( $query ) { // Return early for any situation you aren’t interested in. if ( is_admin() || ! $query->is_main_query() || !is_category() ) { return; } $query->set( ‘posts_per_page’, 6 ); // Don’t use a global; create a function to populate this value // … Read more