Skip Navigation

[Resolved] Shortcode for True / False

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.

Our next available supporter will start replying to tickets in about 0.29 hours from now. Thank you for your understanding.

This topic contains 14 replies, has 2 voices.

Last updated by Pete 2 months ago.

Assigned support staff: Waqar.

Author
Posts
#2378389
aa TS Filter.jpg

Hi there,

We use a URL feed to populate a new site of custom post types. This has custom fields added to the site by the feed, not taxonomies.

Is there a way of using one of these custom feeds to filter one of these, swimming pools...using a shortcode added to what we already use?

The value in the custom post type is True or False and this is what I can't work out.

We use this to display Views:
[wpv-form-view name="holidays-sub-feat-pages" wpvarea="spain" target_id="self"]

Ideally I would like to add something like wpvpools="true"

However can't work out what to add to the View filter.

Worth an ask. Thank you.

#2378609

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

In the view's query filter settings, you can either set the source of the filtering value to a 'shortcode attribute' or a 'URL parameter' but not both, at the same time.
( screenshot: hidden link )

The "Swimming Pool" is being used as a custom taxonomy and not a custom field on your website. For filtering by this, you can include a taxonomy filter and set it to link to the shortcode attribute, similar to how the filters for the "Area" and "Collections" taxonomy, are seen in your screenshot.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2378633
aa TS 2 see.jpg

Hi Waqar, hope you had a nice weekend.

When selected this adds it to the filter, however I done know what to do to make this work so I can include it in a shourcode, just like we do all the time (example below).

[wpv-view name="holidays-sub-feat-pages" wpv-area="lake-district" wpv-collection="dog-friendly" view_display="layout"]

And it needs to work so we can use 'true'.

Or, is this not possible? Thank you.

#2378715

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Note: Your screenshot is still showing the "Swimming Pool" added as a custom field filter and not the taxonomy filter.

Assuming that you've added a taxonomy filter for the taxonomy "Swimming Pool", with the target term's slug coming from the shortcode attribute 'wpvswimmingpool', the view shortcode will look like this:


// For True:
[wpv-view name="holidays-sub-feat-pages" wpv-area="lake-district" wpv-collection="dog-friendly" view_display="layout" wpvswimmingpool="true"]

// For False:
[wpv-view name="holidays-sub-feat-pages" wpv-area="lake-district" wpv-collection="dog-friendly" view_display="layout" wpvswimmingpool="false"]

You can see this taxonomy filter and view the shortcode attribute in action on a test page named "Test view from TS support" ( {yourwebsite.com}/test-view-from-ts-support/ ) that uses a test view named "Test view from TS support".

#2378739
AA TS see this in Tax Filter.jpg

This what I keep on showing you...."Swimming Pool" is a custom field, 'not' a taxonomy.

I get this what you say....wpvswimmingpool="true"

However this isn't working with a custom field?

#2378827

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

If you'll check the edit screen of the "Portfolio" post type, you'll not see any custom field for the "Swimming Pool", but there is a taxonomy for it.
( screenshot: hidden link )

In the Post Field Control section at WP Admin -> Toolset -> Custom Fields -> Post Field Control (button at the bottom), you'll see that there is an abandoned custom field "swimming-pool", but none of the "Portfolio" posts have any value for this field.

screenshot back-end: hidden link
screenshot back-end: hidden link

To use this custom field for filtering, you can restore it from the Post Field Control section and then add some custom field values with this field in the "Portfolio" posts.

#2378847

Waqar,

I mentioned at the beginning, the Swimming Pool Taxonomy isn't the one we are targeting...this not the one used by our partner feed.

The import of 95% of custom post types is added to the site via a URL...everything set in it is by the partner (not us).

So again....the taxonomy 'isn't' what we can use...this does not include 95% of the posts.

What does contain 95% of the custom post types (swimming pools) is as I have shown the custom field for Swimming Pools.
This and this alone is what we've bee n trying to use.

#2378861

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I totally get it that you want to use a custom field and not a taxonomy for the swimming pool. But, I'd respectfully like to reiterate what I shared in my last reply:

> In the Post Field Control section at WP Admin -> Toolset -> Custom Fields -> Post Field Control (button at the bottom),
> you'll see that there is an abandoned custom field "swimming-pool", but none of the "Portfolio" posts have any value for this field.
> screenshot back-end: hidden link
> screenshot back-end: hidden link

> To use this custom field for filtering, you can restore it from the Post Field Control section and
> then add some custom field values with this field in the "Portfolio" posts.

To filter the posts by a custom field for example "XYZ" it is important that a custom field record with some value exists for all the posts, as posts without that custom fields record will be ignored by the filtering query.
( we've discussed this point in the other recent ticket too: https://toolset.com/forums/topic/make-custom-post-types-sticky/ )

So, to summarize:

1. Make sure that the custom field 'swimming-pool' is defined/restored
2. Make sure that the import process stores some values e.g. yes/no or true/false for this custom field 'swimming-pool'.

Once these two parts are taken care of the custom filtering in the view will work.

#2378865

Hi there,

To be honest I've never seen this before:
> Post Field Control (button at the bottom)

Ok I see this however see no way to 'restore' this:
> To use this custom field for filtering, you can restore it from the Post Field Control section and

Now you say here....
2. Make sure that the import process stores some values e.g. yes/no or true/false for this custom field 'swimming-pool'.

Remember, we have 'no control' over the import, we can set up as many fields as we want however the Import will not use them.
The import has created the custom post types (swimming pools) and we do use this to display items on the from end using conditional block.

Still unsure what to do here Waqar

#2379491

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

> Ok I see this however see no way to 'restore' this:
- When you'll hover over the field, you'll see an options menu as can be seen in this screenshot:
hidden link

> Remember, we have 'no control' over the import, we can set up as many fields as we want however the Import will not use them.
- Ok, if your import/feed is not bringing in any information about the 'swimming pool', you can programmatically set a default value 'no', '0', or 'false' for this custom field after the import is processed.
( please refer to the custom code from this reply: https://toolset.com/forums/topic/make-custom-post-types-sticky/#post-2372715 )

As a result, a default 'no', '0' or 'false' value will be saved for all the posts and you'll be able to manually change it to 'yes', '1', or 'true', for the selective posts.

I hope this makes it clearer.

#2379523

Hi Waqar,

Thank you very much for explaining this.

Ref:
s a result, a default 'no', '0' or 'false' value will be saved for all the posts and you'll be able to manually change it to 'yes', '1', or 'true', for the selective posts.

This all very well however if we go and set these as you suggest, when we run the import to refresh to feed and properties on this...it will override this and undo this.

I'm seeing no way round this which to be honest I did suspect.

The Import does create a Custom Field Swimming Pools and as mentioned before...we do use this with a conditional block.
A shame we cant utilise what the Import does create, the custom filed is created and there...just seems we cant use this for 'filtering' however we can for other things.

#2379575

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

> This all very well however if we go and set these as you suggest, when we run the import to refresh to feed and properties on this...it will override this and undo this.

- That custom only adds the default values for the custom field for the posts, where it doesn't already exist. This means that it will not override the values for the posts where you've manually added/changed them. Your changes to that custom field won't be undone/lost.

> The Import does create a Custom Field Swimming Pools and as mentioned before...we do use this with a conditional block.
> A shame we cant utilise what the Import does create, the custom filed is created and there...just seems we cant use this for 'filtering' however we can for other things.

- Can you please share the link to the page where this working conditional block can be seen?

#2379585
AA View for pool page.png
AA Swimming Pool Custom Post Type Template.jpg

Hi there,

Ok on a typical custom post: hidden link
We have this conditional block setup (see AA Swimming Pool Custom Post Type Template attachment)

I set up a Swimming pool page: hidden link
Using this:
[wpv-form-view name="holidays-sub-feat-pages" wpvarea="spain" wpvswimmingpool="true" target_id="self"]
[wpv-view name="holidays-sub-feat-pages" wpvarea="spain" wpvswimmingpool="true" view_display="layout"]

Also see View settings (AA View for pool page).

Hope this helps, I am grateful for your time and patience.

#2380247

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

For some reason, I'm locked out of the website's admin area, which was accessible till yesterday.

In both your screenshots, the condition, and the query filter both are using the taxonomy and not a custom field for the "swimming pool".

Screenshot from your Conditional block screenshot: hidden link
Screenshot from your Query filter screenshot: hidden link

So in presence of this custom taxonomy setup where you can already filter the view by wpvswimmingpool="true", I see absolutely no benefit/value of switching to a custom field.

Note: if you just want to change the attribute name from "wpvswimmingpool" to "wpvpools", you can change that in the query filter's settings.
( screenshot: hidden link )

After this change the shortcode will need to be changed from:


[wpv-form-view name="holidays-sub-feat-pages" wpvarea="spain" wpvswimmingpool="true" target_id="self"]

To:


[wpv-form-view name="holidays-sub-feat-pages" wpvarea="spain" wpvpools="true" target_id="self"]

#2380259

My issue is resolved now. Thank you!