Post count and sort order of archive page posts

My goal is to create an archive page for a specific post category, and on that page show posts that belong to that category.

I’ve created a Layout Archive set to “Community Taxonomy is City”. Community being my custom post type and City being a category within that post type.

I’ve created a 4 column layout with the column being the Looper Consumer and the content of that column pulling in data from the post, like Featured Image and Post Title.

I have my preview set to a specific Community City.

The problem is that I’m not seeing all of the posts that are assigned to the city category.
Here is a page for example that should be showing 25 posts: http://54.227.57.214/livemodern/cities/downtown-west-palm-beach/

I have figured out that when I add Post Pagination to the layout, I can see all of the posts across 3 different pages.

What I need is to show all of the posts on one page without pagination, and I also need to be able to sort them alphabetically, but I don’t see any options to do that.

Thanks for your guidance on this.

Hi @marketfresh,

Thanks for reaching out!

I suggest in your Layout Archive go to your posts element and enable the Looper Provider. Then choose Query Builder as type, Community as your posts, City as taxonomies, Title/Ascending as orderby, then 25 or more as your posts count. See the example below.

Hope that helps.

Thank you.

This doesn’t work because:

  1. CITY is not an option in the dropdown, only the categories within the CITY taxonomy.
  2. I read elsewhere that there should be no looper provider on an archive page. The fact that it is an archive page with assignment condition set to “Community Taxonomy is City” is already doing the job of pulling in the correct posts.

The issue is that there is no control over the sort order or number posts shown. There must be a way to control this on an archive page, right?

I figured it out.
I added this code to my functions.php file and it’s working now:

add_action( 'pre_get_posts', 'city_taxonomy_archive_display' );
function city_taxonomy_archive_display ( $query ) {
    if (($query->is_main_query()) && (is_tax('cities'))){
           
    $query->set( 'posts_per_page', '50' );
    $query->set( 'orderby', 'title' );
    $query->set( 'order', 'ASC' );
}
}

Hi @marketfresh,

We’re glad that you’re able to figure it out. If you have any other concerns regarding our theme features, feel free to open up a new thread.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.