Skip Navigation

[Resolved] Query Filter on A View

This support ticket is created 6 years, 8 months 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 5 replies, has 2 voices.

Last updated by WillL606 6 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#906512
Screen Shot 2018-05-30 at 4.38.58 PM.png
Screen Shot 2018-05-30 at 4.39.30 PM.png

Tell us what you are trying to do?
I am trying to create a View that I can use on posts. I created a custom field (a Post Reference) on a custom post type (Essay). If this custom field for the post is filled (the url reference to another related post), I want that link to be available. For example, This essay is related to: <link to related essay>. The problem might be that the custom field does not seem to be working properly. I can search/select another essay in the the field, but when I save it reverts to one of my categories- not the referenced essay. See images below.

Is there any documentation that you are following?
I am puzzled about how to set the Query filter for a custom field.

Is there a similar example that we can see?
No.

What is the link to your site?
This is an essay that should display the View called "riPOSTe Link" but doesn't. hidden link

#906822

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screen Shot 2018-05-31 at 13.54.41.png

Hi Will

If you add a post reference field to a post type, then when editing a post you should be able to choose the post (of a different type) you want to connect it to.

This field will store the post ID of the related field in wp_postmeta for the current post.

You don't need to create a View to display this connection.

In the content template for your first post type insert the field you want for the related post, and when inserting it via the Fields and Views button use the post selection tab to specify that you want to display a field of the related post not the current post (see my screenshot).

I have tested this and it seems to work fine.

What I don't understand is where you say after saving a post with a related post chosen, it reverts to a category.

That's not clear from your screenshot, could you clarify? And is this on the front end or the back end?

#907206

I misunderstand: "you should be able to choose the post (of a different type) you want to connect it to." This is an essay (post type) connecting to another essay. By your explanation, I think that post reference is not what I want. Which explains why I didn't understand what was being store in this custom field. What is stored is a reference id and not the link to the essay.

We have certain essays on our blog which are responses to other essays ( we call them riPOSTes). I want a custom field with an option to select another essay to which the current essay is a response.
In the content template for any essay, I would like a something like: This essay is a response to: <link to essay> only if this custom field is filled. What type of custom field should I use in this case?

Thanks,
Will

#907208

I figured it out! Thanks for your help.
W

#907209

Sorry. I have one more question. In the content template, I have everything working, but I wanted to have the text: "A riPOSTe to: <link to essay>" only appear if the field is filled in - only if there is a post reference. Right now the text appear on all essays. Would I create a View in this case?

Thanks
W

#907213

I went digging and found my answer. Again, apologies.
W