A code that I could not fully grasp related to foreach & count_user_posts()

Those parameters are optional, as the codex states: $post_type (string) (optional) Post type to count the number of posts for. Default: “post” So it’s optional, not required. If it isn’t passed in, then the default value is “post”. Optional parameters are a part of PHP, e.g. function print_number( $number=5 ) { echo $number; } print_number( … Read more

Display all the terms within a custom taxonomy

get_terms() creates a WP_Term_Query() and then passed the $args to it. It also applies the get_terms filter to the terms before they’re returned. get_terms() is, in this case, a convenience function, to use if you don’t need all the bells and whistles a WP_Term_Query might provide. As far as the_title() and the_permalink(), those functions are … Read more

WordPress posts loop not displaying all posts on blog

if anyone else is having the same problem as me, here is the solution. The problem that was causing this was <?php echo get_permalink(the_post()); ?> Honestly, I have no idea why I went with this instead of just the_permalink() , was having a problem with my read more button it was sending me to a … Read more

Adding a second loop breaks everything

The root problem here is a missing endif; on the second loop. But, there are a few changes we can make to improve this and make things work, this loop, will work a lot better: <h3>Other standards</h3> <div class=”row”> <div class=”col-12″> <?php $query = new WP_Query( [ ‘post_type’ => ‘page’, ‘post_parent’ => 27, ‘posts_per_page’ => … Read more

Loop two different category WP_Query

Your final outlook is a bit tricky to achieve using traditional way. Lets assume both category has at least 6 post. Now first grab the posts using get_posts() not WP_Query $side_news = get_posts(array( ‘post_type’ => ‘post’, ‘category_name’ => ‘category-slug-1’, ‘posts_per_page’ => 6 )); $side_news2 = get_posts(array( ‘post_type’ => ‘post’, ‘category_name’ => ‘category-slug-2’, ‘posts_per_page’ => 6 … Read more