Add a CSS class based on categroy id to archive pages

the link you gave has category class “category-26”, so therefore to add custom styling to this specific page you just have to define class .category-26 before any of your custom style, example of adding custom css to specific your category page : .category-26 article { background: #9999; } You can find specific category key with … Read more

How can I restrict image upload dimensions for non-admin WordPress users?

I’ve modified this answer from brasofilo. Modify the width and height values in the following line in the below code to your needs… $maximum = array( ‘width’ => 500, ‘height’ => 700 ); … and then add the code to your theme’s functions.php file. add_action( ‘admin_init’, ‘wpse_371740_block_authors_from_uploading_large_images’ ); function wpse_371740_block_authors_from_uploading_large_images() { if( !current_user_can( ‘administrator’) ) … Read more

wp_get_post_terms is difference obj model than the one in rest api response

I got fixed my problem by using the method prepare_item_for_response in WP_REST_Terms_Controller function custome_posts_response(WP_REST_Response $data, WP_POST $post, WP_REST_Request $request) { $newspapers = wp_get_post_terms($post->ID, ‘newspaper’); $categories = wp_get_post_terms($post->ID, ‘category’); $tags = wp_get_post_terms($post->ID, ‘post_tag’); $newspaper_ctrl = new WP_REST_Terms_Controller(‘newspaper’); $category_ctrl = new WP_REST_Terms_Controller(‘category’); $tags_ctrl = new WP_REST_Terms_Controller(‘post_tag’); $newspapers = array_map(function( WP_TERM $newspaper ) use ($newspaper_ctrl, $request) { return … Read more