Skip Navigation

[Resolved] Exclude results from homepage

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 6 months, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2708684
Screenshot 2024-07-22 at 09.39.08.png

Hello guys.

I've created a view for the sidebar that displays the information of a custom field in all blog posts (custom field name: keyword-for-dynamic-field). And if that is empty, it should display the taxonomy. And is working fine.

However, there is one issue. It also displays on the homepage, when it shouldn't. So, at the moment it is populating the field on the homepage, based on the last blog post published.

How can I keep the information being displayed (as now is) on the blog posts, but excluded it from the home page. For the homepage I just want a general text to display. For example, on the homepage I just want it to say "Book your place for your next trip" (with a link).

The code I have at the moment is this:

Book your place in[types field='keyword-for-dynamic-field' output='raw'][/types][wpv-conditional if="( empty($(keyword-for-dynamic-field)) )"][wpv-taxonomy-title][/wpv-conditional]

Thanks!

#2708715

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share the code you have again as it's malformed.

However - what if you try to add the Post ID query filter to your view and try exclude the home page post Id and see if that help you to resolve your issue.
- https://toolset.com/documentation/legacy-features/views-plugin/filtering-views-query-by-post-id/#include-or-exclude

If that does not help, please share the code you have.

#2708722

Hello. Here's the code again.

<p>Book your hotel in [types field='keyword-for-dynamic-field' output='raw'][/types][wpv-conditional if="( empty($(keyword-for-dynamic-field)) )"][wpv-taxonomy-title][/wpv-conditional]</p>

The link you gave doesn't help me, because when I check the view there is no option to filter by post id

The code doesn't go through here in the help form correctly. It's not accepting the href, but consider the code above enclosed in a "href".

Cheers

#2708755

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - you can try the following conditional shortcode and add your desired content:

Navigate to: Toolset → Settings page and click the Front-end Content tab.
There, add your function name is_front_page to the Functions inside conditional evaluations section.

[wpv-conditional if="( is_front_page() eq 1 )" ]
<h1> This is HOME page.  </h1>
[/wpv-conditional]

[wpv-conditional if="( is_front_page() ne 1 )" ]
<h1> This is NOT HOME page.  </h1>
[/wpv-conditional]

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/#syntax

#2708766

Perfect! All done. Thanks for your help, Minesh.