Community Forums › Forums › Archived Forums › Design Tips and Tricks › Masonry is not showing all posts for a category
Tagged: masonry
- This topic has 4 replies, 2 voices, and was last updated 7 years, 4 months ago by yashitamittal11.
-
AuthorPosts
-
July 31, 2017 at 1:35 am #209740yashitamittal11Member
Hello
1. I am using Masonry layout to display posts on the page Products belonging to the category Company.
But only 6 posts are getting displayed on the page. There are close to 14-15 posts belonging to this category.
Here is the code to output masonry layout:/** Replace the standard loop with our custom loop */ remove_action( 'genesis_loop', 'genesis_do_loop' ); // Add our custom loop add_action( 'genesis_loop', 'mgtools_masonry_layout' ); function mgtools_masonry_layout() { global $paged; // current paginated page $args = array( 'category_name' => 'company', // category slug 'order' => 'ASC', 'paged' => $paged, ); $loop = new WP_Query( $args ); if( $loop->have_posts() ) { echo '<h1>featured <span class="styleProduct">Products</span></h1>'; echo '<div class="row masonry">'; // loop through posts while( $loop->have_posts() ): $loop->the_post(); echo '<div class="ms-item">'; if (has_post_thumbnail()) : echo '<figure class="article-preview-image">'; the_post_thumbnail('large'); echo '</figure>'; endif; echo '<h2 class="post-title"><a href="<?php the_permalink(); ?>" class="post-title-link"><?php get_the_title(); ?></a></h2>'; //the_excerpt(); echo '<div class="clearfix"></div>'; echo '</div>';// ms-item endwhile; echo '</div>';//masonry div }//if loop echo '<div class="clearfix"></div>'; wp_reset_postdata(); }
2. I am using get_the_title(); function in the code above to display post title beneath the featured post. But somehow title is not displaying. When I go and check in the Inspect window, get_the_title(); is commented.
Please advice
http://greeninvites.com/product/July 31, 2017 at 4:58 am #209748Victor FontModeratorThis question has nothing to do with the Genesis Framework or your child theme. You are limiting yourself by the number of "Blog pages show at most" you have setup in the WordPress/Reading menu. If you want all posts to show for this query add $posts_per_page => -1 to the $args array.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?July 31, 2017 at 11:33 pm #209801yashitamittal11MemberThanks,
I have added posts_per_page => -1 to the $args array. It is now showing all the posts.
There is one more issue that I am facing.
I am using get_the_title(); function in the code above to display post title beneath the featured post in the masonry. But somehow title is not displaying. When I go and check in the Inspect window, get_the_title(); is commented.
Please advice.
August 2, 2017 at 1:03 am #209881yashitamittal11MemberHello,
The problem with the post title not displaying has been fixed. There was issue in the markup.
Now I have another problem in the masonry on Products page.
The last masonry item in the first column is spilling to 2nd column. The post title 'YG1 Tools' is at the beginning of 2nd column.
I am having hard time fixing this.What changes I need to make to fix this.
August 7, 2017 at 10:21 pm #210102yashitamittal11MemberThere was extra margin under each masonry item which was causing the issue.
Removing that solved the issue -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.