Skip Navigation

[Resolved] Setting a query within a Content Template View

This support ticket is created 3 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 2 voices.

Last updated by barryG-4 3 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1947581
Screenshot 2021-02-14 at 17.30.51.png

Tell us what you are trying to do?

I am trying to create a Content Template with a View to display a vertical list of banner images in the footer of a website. The source of the banner images is data from a custom post type called Banners.

I have managed to cobble something together by trial and error but I am stuck on two things:

1. How I can filter the query so that only posts with the custom taxonomy ‘home page’ ticked are shown?

2. How can I get the banners aligned centrally on the page? I’ve already set align to centre in an advanced tab.

Here’s the general idea of what I’m trying to do:

The display needs to show a vertical list of hyperlinked images. Each image is being created from custom field data. The banner image is either:

1. A single image added to a custom field called ‘banner image’ combined with the URL from a custom field called ‘Banner URL’ or….
2. Code added to a custom field called ‘banner code’.

If an advertiser provides code for a banner then the banner image and banner URL fields will not have data added to them.

The Banners custom post type has two custom taxonomies assigned, Home Page and Links Page. These are to determine where the banners will be displayed.

I want to create a view to show on the home page that shows all banners with the taxonomy ‘Home Page’ selected and order them by ‘Priority’ which is a Banners custom field (number) and ordered high to low so that a banner with a priority of 10 will show in the list before a banner with a priority of 2 for example.

I’ve set the custom fields in Banners as follows:

Banner URL
Banner Image
Banner Code
Banner Alt Text
Banner Priority

As mentioned before the custom Taxonomies for banners are:

Home Page (to be displayed in a custom footer created using Elementor that is already working)
Links Page (this page is not created yet)

I’ve created the Toolset Content Template called Banners - Home Page and within it created a View. I can’t remember what the view was called but ‘Views’ is not in my list of Toolset plugins that I can install and therefore it’s not listed in the Toolset menu. I therefore cannot delete any older failed test views I created and I am forced to see these in a list when I am adding a Toolset View from within Elementor. It’s very frustrating.

Anyway, I have added 3 banner posts and assigned the taxonomy ‘Home Page’ to all of them. One with only banner code and 2 with an image and a URL.

I have added a Single Field block in the view firstly for Banner Code and the only banner with code shows and is perfectly centred on the home page in the footer. This is the ‘Punternet’ banner you see.

I then added another single field block and selected Post Source: Current Banner, Source: Banners Field Group, Field: Banner Image. I can only see one of the image based banner post entries on the edit screen (screenshot attached) with the code based Punternet banner below it, but after saving I can see both the red and blue test banner images and the Punternet banner on the home page in the footer.

In the edit page, the Punternet banner is aligned left and the image based banner perfectly centred. On the Home page this is reversed. Both blocks are set to align centre in the advanced tab though.

I am finding the Content Template edit page unbearable. Nothing seems to work or appear as I think it should do. I can only see what the results are by adding the view to a page and viewing it there. I’m very unhappy with how this is. I’m spending days doing something that should take a few minutes.

So, I have been able to get the images displayed, whether there is a code based image or a physical banner image. That’s great. What I can’t do is align the image based banners to the centre of the container even though in the advanced tab I’ve set the align setting to centre. Nor can I set a query to only display banner posts that have the ‘home page’ taxonomy ticked.

Can you please help me. I will add log in details when a private window is offered in this support ticket.

Many thanks,
Barry.

Is there any documentation that you are following? No

Is there a similar example that we can see? No

What is the link to your site? Please scroll down to the footer and look at the three banner images there. hidden link

#1947959

1. How I can filter the query so that only posts with the custom taxonomy ‘home page’ ticked are shown?
You can add a term Query Filter in the Content Selection panel of the View editor screen as described here: https://toolset.com/course-lesson/creating-a-view/#filter-the-list-of-posts

2. How can I get the banners aligned centrally on the page? I’ve already set align to centre in an advanced tab.
I think I would need to log in and take a look at how the image/url/code-based options are implemented. I'll activate private reply fields here so you can share a login.

I therefore cannot delete any older failed test views I created and I am forced to see these in a list when I am adding a Toolset View from within Elementor. It’s very frustrating.
You can activate the legacy Views experience in Toolset > Settings > General tab. There is an option to enable both the blocks experience and the legacy editor. Choose that option, and a Views menu item will appear in the main Toolset menu area. You can delete old Views from this dashboard if you'd like.

#1949393

Hi Christian,

Just in case I haven't mentioned it, the Content Template in question is:

Toolset > Content Templates > Banners - Home Page

Many thanks,
Barry.

#1951639

Hi Christian,

Perhaps I should give up using Content Blocks and views within them for now? Out of desperation I enabled the legacy Views plug in and have created a simple view there directly without Blocks, called Banners View - Home Page Only initially to try out something else. I've replaced it with the view that this ticket was opened for and it's working beautifully and took less then 30 mins even with adding a conditional option which I've never used before. All banners are centre aligned and the query works too.

So I don't think it's fair to waste your time but I still cannot use Content Blocks and views within them but can easily do the same thing from the legacy views which I find a bit odd. Surely if someone like me can understand and use views, but content blocks and views within them are just so confusing why would Toolset want to move forwards with the new way of doing it. Pulling various toolset custom field and custom taxonomy data and using it in post grids and other things is critical to my workflow and without the old way of doing it I'd be out of business. Anyway, do you agree there's no point to prolonging the agony with this ticket?

Many thanks,
Barry.

#1951669

Sorry, there was a public holiday in the US yesterday and I was not available. If you're confident using the legacy Views editor and prefer that approach, I think we can close out here. If you'd like to continue discussion of the block editor approach, we can continue. It's up to you.

#1951705

Hi Christian,

Thanks for your help. I’ll use legacy views and will try to set up a site for testing content blocks on specifically when I get time. Many thanks, Barry.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.