Archive Page for Custom Post Type

Hi team,

I am creating a couple of page layouts for the custom post type “messages.”

A) The first is a page (page name is Messages) that shows the first instance of a post for each “messages” category type. I’m basically recreating this page - https://lifefellowship.tv/series and am struggling with how to set up the looper so that it works how I would like it to. I’m trying to achieve three things:
*A1) - When a new messages category is created, the featured image for the first messages post will automatically appear in the bottom section of the page like in the above example page
*A2) - Below the image the category name (ie; the message series name) will appear like on the example page
*A3) - When you click the image and/or category name, it links to the archive page for that category

B) The second is an archive page layout that will be an archive page for each “messages” category type. I have created this layout and have a couple of questions:
*B1 - I’m getting an error and this page won’t display, despite the fact that I have set the assignment conditions (error says: It appears whatever you were looking for is no longer here or perhaps wasn’t here to begin with. You might want to try starting over from the homepage to see if you can find what you’re after from there.)
*B2 - is there a way for a new archive page to auto-create every time a new messages category is created, just like what would happen when a new blog category is created?

And some other random questions:

  1. on the “sermon series archive” layout, i’ve played with all sorts of different combinations of settings, but how i can get the featured image to not get cut off. It will always be a 16:9 ratio, or I could make it so that it’s always a 1:1 ratio.

  2. I have custom field “message summary”. I know i can limit the number of characters the client can input, but is there a way that I can can truncate what they type like you would with the excerpt. Ie. can I do this, “{{dc:post:excerpt length=“40”}}” but with my custom field?

Thanks so much team!!

1 Like

Hey @texaskiwi13,

The credentials you posted do not work. We can’t get past the htaccess login.

image

Also, we kindly ask that you post 1 question or we solve 1 problem at a time or per thread. Posting multiple questions often results in confusion so it is not good for alll forum users including the support staff. With that said, please post the other questions separately.

Let’s start with problem A. This will require the activation of the Looper Consumer Rewind experimental feature to achieve Looper Provider nesting. Also, you will need to be comfortable working with Loopers. If you’re new to Loopers, please first learn from the video tutorials here.

The nesting setup would look like this:

Main Looper Provider: All Terms
  Main Looper Consumer: Message Category Name and Link to Category Archive
     Sub Provider: Query String Displaying Message Post utilizing the Category Name
       Sub Consumer: Image Element getting the featured image of the latest post of the current category in the looper.

Now to activate the Looper Consumer Rewind feature, go to Preferences and enable the Dev Toolkit option then follow the rest of the steps below.

image

  1. Set up a Looper Provider and Looper Consumer with All Terms being the main provider.
  2. Click the Consumer then click on the tool icon.
    image
  3. In the Dev Toolkit, search for “rewind” and set the looper_consumer_rewind to true by clicking on the false button.
  4. Set up another set of Looper Provider and Consumer under the main consumer setup. Set the sub provider as a Query String that’ll display message posts of the current message category. If this is hard, please post the correct login information so we can provide an example. Please just note that you ultimately need to do your own Query Strings and that means getting good at using WP Query setups.
  5. Add an Image element to be the sub consumer under the sub provider
  6. Set the main consumer as a link by chaning the HTML tag to <a>. Then set the URL to this Dynamic Content {{dc:term:url}}.
    image
    image
  7. Add a Headline element as one of the main consumer and use this DC in the Primary Text {{dc:term:name}}

I believe that’s a hand full just for problem A that’s why it’s best we solve this first before going through your other questions.

Thanks.

Thanks so much Christian! I think I got there save the query string. Can you please have a look and let me know if I’ve done it correctly and if not, what needs to change? And also give me a bit more direction on the query string so that it just returns one featured image (the first instance) of each category (and exclude uncategorized)?

Note it’s the dark navy section I’m working with what you outlined above.

Regarding the password, I put both sets of credentials in the secure note and have just double checked that it works. I’ll repost again though just in case.

Thanks so much!!

Hi @texaskiwi13,

The login credentials worked but didn’t find the page where you have added the Query String. Can you please specify the exact page for further investigation?

Thanks

Hi,

As I stated in my original question, the page name is “Messages” and the layout template i’ve built is called “all sermons”

Thanks!

Hi @texaskiwi13,

I have already checked that Layout you mentioned but there is no Query String to check in the Looper Provider. The Query Builder and the Category term have been used for all the Looper Provider in the specified Layout. Can you please specify the section where you have used the Query String to check?

Please let me know if you are trying to point out something else.

Thanks

Hi,

As stated above, I think I got everything setup correctly, based on what support outlined, except for the query string. I was asking 1) can you please double check that I did do it correctly and 2) can you provide additional help with the query string as Christian talked about in his response.

Thanks,
Ashley

Hey Ashley,

First, your main looper should be All Terms for Message Category. You currently have it set to Categories.

image

Next, the Query String comes from a WP Query and the WP Query you’d need is this:

 array(
    'post_type' => 'messages',
    'tax_query' => array(
        array(
            'taxonomy' => 'message_series',
            'field'    => 'slug',
            'terms'    => 'message-term',
        ),
    ),
);

To get the Query String version of that, you need to http_build_query that like taught in this other thread.

It would return something like this:

post_type=messages&tax_query%5B0%5D%5Btaxonomy%5D=message_series&tax_query%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Bterms%5D=message-term

message-term in that code is just a place holder. It actually should be the Dynamic Content {{dc:term:name}} so the end Query String would be below.

post_type=messages&tax_query%5B0%5D%5Btaxonomy%5D=message_series&tax_query%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Bterms%5D={{dc:term:name}}

Lastly, you just need to move your Headline element just above the Sub Provider.

All that should result like the screenshot below. Please do all those steps above for you to learn the setup so eventually you get good at this.

Remember that I’ve mentioned previously that you need to get good using WP Query. That is because we do not provide further assistance developing the query. I’ve provided the query only to get you started but further query requests would be outside the scope of our theme support as that is actually a WordPress topic which we can continue on answering in our One premium support.

Hope that helps and thank you for understanding.

Thanks so much for outlining that! I learn by doing, so this is a great jumping off point and will give me enough to go on to then google and learn more.

One more question though, if it ends up looking like the screenshot you provided above, that still isn’t what I’m after. I want just the first post from each category to display. ie. “call to community introduction” and just the oldest post from James. Eventually we’ll have 30 categories, and I just want one from each category showing on this main page. Is there some sort of filter you can apply in the query to only return the oldest post, or one post, from each category? I’ve tried googling it, but I’m not sure if I’m using the correct language.

Thanks!

Ashley

Hey Ashley,

The setup I’ve shown above already lists posts per category. You just have to limit the post to 1. To limit the post to 1, you can set the Consumer to consume 1 post only.

image

Limiting the number of post and show the oldes post are also available in the WP Query. You can check what you can do with the WP Query here: https://developer.wordpress.org/reference/classes/wp_query/

Remember that we can’t continue on providing specific WP Query codes. You will need to learn how to generate your own WP Query. Or, subscribe to our One premium support where we can provide answers to WordPress topics including the WP Query.

Thank you for understanding.

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