How to have post count after each listed category

For showing category count on your loop – foreach($categories as $category) { echo ‘<li><a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in: %s” ), $category->name ) . ‘” ‘ . ‘>’ . $category->name.'</a>&#32;&rsaquo; (‘. $category->count .’)</li>’; } And for showing count with wp_get_archives function, use show_post_count in argument … Read more

Have multiple loops on a page appear after/between page content

Use buffer to simply do that with ob_start() & ob_get_clean(). function custom_summary($atts) { extract(shortcode_atts(array( “category” => “”, “posts” => “” ), $atts)); ob_start(); $my_query = new WP_Query(“category_name=$category&posts_per_page=$posts”); while ($my_query->have_posts()) : $my_query->the_post(); // Do all the things. endwhile; wp_reset_postdata(); return ob_get_clean(); } add_shortcode(‘summary’, ‘custom_summary’);

How to display thumbnail if post is assigned one otherwise not

you just need to clean up the if statement: <?php if ( has_post_thumbnail() ) { ?> <div class=”col-md-3″> <?php the_post_thumbnail(); ?> </div> <?php } ?> here’s the whole bit cleaned up: <?php query_posts(‘posts_per_page=1’) ?> <?php while ( have_posts() ) : the_post(); ?> <div class=”jumbotron”> <?php if ( has_post_thumbnail(); { )?> <div class=”col-md-3″> <?php the_post_thumbnail(); ?> … Read more

Loops in category description

What you want to do is to group fruits by color. In WordPress term appropriate mechanism for that is taxonomy (categories and tags are examples of taxonomy). I would create a custom taxonomy “fruit color” where terms would be individual colors and assigned to fruits. Then your display logic would be to: retrieve all fruit … Read more

ACF loop and php formatting

If it can be explicetly defined as the_title, then this should work for you: $pages = get_pages(array (‘sort_column’ => ‘menu_order’)); foreach ($pages as $page_data) { $fields = get_fields($page_data); if( $fields ) { echo ‘<div class=”the_title”>’ .$fields[‘the_title’] . ‘</div>’; echo ‘<div class=”container”>’; foreach( $fields as $field_name => $value ) { $field = get_field_object($field_name, false, array(‘load_value’ => … Read more

Buddypress Group Activity Loop Filter activity type [closed]

I have created this function in bp-custom.php page. function filtering_activity_default( $query ) { if ( empty( $query ) && empty( $_POST ) ) { $query = ‘action=activity_update,joined_group’; } return $query; } add_filter( ‘bp_ajax_querystring’, ‘filtering_activity_default’, 999 ); This is working for me as expected.