Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Styling of Posts Archive using Block Element Loop

  • I have a Block Element Loop Template element that I would like to style my post archive pages. (It looks like this: https://thelorax.smugmug.com/JudithPond/n-pG6JxF/i-S5srRdp/A) I have it set to display on Post Archive.

    I would like archive pages each to have only one category of posts. How can I create those archive pages to use this element but have only one category per page? I had this working before by putting a separate query loop on each page, but it was difficult to style many pages in that way to all have the same formatting. The Block element looks like a better way to do it.

    An example is this page (https://www.judithpond.ca/poetry/), which is currently using a separate query loop. It’s displaying the right posts, but I want them to look like the above template.

  • Hi there,

    if you create a GP Block Element – Loop template.
    And set its Display Rules Location to Category Archives -> All Categories
    Then add a the Query Loop, DO NOT add Parameters, and just check the Inherit Query from Template option.
    This one element will display across all your category archives that match the current query.

  • So I would not make individual pages for each category? How can I access those pages?

    In my site above, I tried manually adding “category” to the URL for the poetry category, but it just took me back to the page I linked.

    Thanks.

  • I finally found a WordPress tutorial that explained I could access the category archive pages by clicking View on a category.

    For this to work, I also had to correct a couple of element settings. And I also had one wrong ACF field title, which was further impeding having my posts look right.

    I’ve been using GPPremium/GBPro for nearly five years and WordPress for ten. But I haven’t used the blog features much, and I’d never had a reason to need posts with separate category pages. Some features that seem obvious once you’re using them all the time can be difficult to figure out the first time.

  • It was kind of working, but then when I tried to get my Custom Post Type working, now it’s not.

    Checking off “Inherit Query from Template” gives me no posts at all on any of the category archive pages.

    If I uncheck that, I think all of them are showing up on all the category archive pages.

    I thought maybe the Custom Post Type was the problem, so I tried adding tags to the regular posts, adding an online text as a post instead of as an Online Reading Custom Post, and then excluding the ones that need the different template (online readings) via a tag.

    What I want is this structure:

    Published
    Poetry
    Novels
    Flash Fiction

    Online
    Poetry
    Novels
    Flash Fiction

    With the posts for the right category only showing up on the linked page.

    Edit: Now it’s showing the right posts, but they’re duplicated.

  • Hi there,

    the duplication is happening because you a GP Block Element – Content Template, with a Query Loop inside oit.
    So for every post that the Content Template would return is now displaying another loop.

    Change the Element Type to a Loop Template:

    https://docs.generatepress.com/article/block-element-loop-template/

    And in the Query Loop block, DO NOT add any Parameters, you can check the Inherit Query from Template then each archive will display the relevant posts.

  • I can’t see which one you’re referring to.

    What you’ve said is what I found when I searched for help on duplicate posts before I inquired. But both the elements “Post Archive Cards” and “Online Reading Archive Cards” were already set to Block – Loop Template.

    My single post elements were not, but those don’t have a query loop in them. I’ve changed those to loop template anyway, and I still see duplicate posts after clearing the browser cache.

    I am puzzled.

  • Both of your loop templates named “Post Archive Cards” and “Online Readings Archive Cards” are assigned to the same location which is “Online reading category archive”. That’s why the loop appears twice.

    Make sure only 1 loop template is assigned to a location.

    By the way, the locations you added to the exclude list won’t work, as the location set to archive, but you are excluding single posts, the single posts were not included in the first place.

  • That’s odd. When I would go in to edit “Online Readings Archive Cards,” it was set to “Online Readings Category Archive.” But in the listing of all elements, it did say Post Archive. I tried going in and saving, even though it was showing “Online Reading Category Archive” and then going back to the listing several times, but it didn’t change from Post Archive.

    (Originally when I tried to set it to Online Readings Archive, that wasn’t an option; only Category was there. But it’s there now, so I’ve now been able to set it to that.)

    Thank you very much. My duplicate posts are no longer duplicated. Now to figure out the custom post type archive.

  • But in the listing of all elements, it did say Post Archive
    For the custom post type category archive, it does not show the CPT name, just simply shows Post category archive.

    Glad the issue is fixed 🙂

  • How can I see my category archive pages for my Custom Post Type?

    Clicking on view in the Category listing produces a blank page. (e.g., Flash Fiction O, which has two entries.) https://www.judithpond.ca/online-oo/flash-fiction-o/

    I thought maybe I’d registered my Custom Post Type incorrectly, so I’ve tried a few ways (manually following the GP instructions; automatically with Custom Post UI plugin), but no joy. Archive is turned on for that post type.


    It really seems like a bug. If I set the Loop Element to appear on Online Readings Category Archive, it changes to Post Category Archive when I save it and then duplicates my regular posts in their categories. I don’t actually see any archive where my Online Readings Posts become visible; I created entirely separate categories for them, but their archives are just blank. (e.g., the Flash Fiction page I linked above.)

  • The two loop template elements look the same, do you consider keeping just one of them and assigning it to all archives?

    I don’t actually see any archive where my Online Readings Posts become visible;

    If you disable the loop templates, any posts be shown on the archive? If not, then it’s not the loop template’s issue, it’s related to how you set up your CPT and taxonomies.

    I went to posts and select the category Flash Fiction O, no posts were found:
    https://app.screencast.com/1xVlkzvIEbKe5

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.