Skip Navigation

[Resolved] Field value in view is not what it ought to be

This support ticket is created 5 years, 4 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by josephC-5 5 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1336927

Hi there,

I have a custom post type named Artist. The post type has a layout for its archive page with two views on it: a textual listing of the names of the artists, and a visual grid of images (one per artist).

The names in the textual listing and the images in the grid are links to an individual artist's page. When a visitor clicks a name, the template for a single Artist displays. This page contains the same view of the textual listing of the names of the artists; the name of the current artist is boldfaced. The formatting is accomplished by comparing the title of the current page to the title of the post in the view. If it's a match, the name is boldfaced. These settings are stored in a view named "View of Artist Listing (Text)," and the content template named "Loop item in View of Artist Listing (Text)."

Here's the issue: on the archive page, the name of the artist Josh Steinbauer is boldfaced. What should happen is that no artist names should be boldfaced (since we're only viewing the index, not a specific artist's page).

You can view the issue here:
hidden link

Note: there is HTTP-authorization on this site. I have input the credentials in the FTP details in the ticket.

The code in the content template looks like this:

[wpv-conditional if="( '[wpv-post-title]' eq '[wpv-post-title item="$current_page"]' )"]
<a class="current_page_artist" href="[wpv-post-url]">[wpv-post-title]</a>
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-title]' ne '[wpv-post-title item="$current_page"]' )"]
<a href="[wpv-post-url]">[wpv-post-title]</a>
[/wpv-conditional]

What do you think is going on?

Saul

#1337255

Hello,

Thanks for the details, I can log into your website and see the problem, the problem is in that archive page, the shortcode [wpv-post-title item="$current_page"] outputs value "Josh Steinbauer", so it conducts the problem you mentioned above.

I suggest you try to check if it is in archive page within [wpv-conditional] shortcode, for example:
1) Dashboard-> Toolset-> Settings-> Front-end Content
in section "Functions inside conditional evaluations", add WordPress function name: is_archive

2) Change the [wpv-conditional] shortcode as below:

[wpv-conditional if="( (is_archive() ne '1') AND ('[wpv-post-title]' eq '[wpv-post-title item="$current_page"]') )"]
<a class="current_page_artist" href="[wpv-post-url]">[wpv-post-title]</a>
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-title]' ne '[wpv-post-title item="$current_page"]' ) OR (is_archive() eq '1')"]
<a href="[wpv-post-url]">[wpv-post-title]</a>
[/wpv-conditional]

Please test again, check if it is fixed. thanks

More help:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/
https://codex.wordpress.org/Function_Reference/is_archive

#1337899

Luo,

This did the trick. Thank you!

Should this be considered a bug? If so, I'm happy to provide more details to fix this for good.

Saul