Echo all category names, apart from one

the_category echos content. You will not be able to use string manipulation. No strings are returned that you could manipulate. They are just echoed immediately. You could completely filter out a particular category, which seems to be an option, with this: function cat_filter_wpse_137596($categories) { foreach ($categories as $k => $c) { if (‘uncategorized’ === $c->slug) … Read more

Multiple filter conditions for WP_Query

Run first query las 10 posts, than use array_rand PHP function on posts array: $args = array( ‘posts_per_page’ => 10, ‘post__not_in’ =>array( $post->ID ), ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’ ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { if ( $query->post_count > 4 ) { $query->posts = array_rand( $query->posts, 4 ); … Read more

Using My Own Classes On Wp Unit Tests

6 . Added this 2 lines to /wordpress-develop/tests/phpunit/includes/functions.php require_once(‘src/wp-content/themes/THEMENAME/include/PostType.php’); require_once(‘src/wp-content/themes/THEMENAME/include/Konser.php’); That is the problem. The get_post() function doesn’t exist, becuase the phpunit/includes/functions.php file is included before WordPress is loaded. That is actually part of the reason that it exists as a separate file: so it can be included in your own phpunit bootstrap (if you … Read more