Skip Navigation

[Résolu] Using conditional display of wpv-post-author in archive template

This support ticket is created Il y a 5 années et 2 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 5 réponses, has 2 voix.

Last updated by webD-3 Il y a 5 années et 1 mois.

Assisted by: Diego Pereira.

Auteur
Publications
#1186847

I wish to hide the "author" of posts if the author is the "staffreport" user.

This works on the single post:

[wpv-conditional if="( '[wpv-post-author] info='user_login'' ne 'staffreport' )"]<div class="author">[wpv-post-author]</div>
[/wpv-conditional]

However, if I add the same on the archive, I cannot get the condition to match. Nothing prints for any item.

[wpv-conditional if="( '[wpv-post-author] info='user_login'' ne 'staffreport' )"]<br />by [wpv-post-author][/wpv-conditional]

Is there something that I must do differently to test for the post author when it's the current item in the loop rather than the page being viewed?

#1186890

Diego Pereira
Supporter

Hello @webd-3, welcome to the Toolset support Forum!

I did a quick test on my test website and it worked. If you remove the conditional fields, does it display the name of the author (wpv-post-author shortcode)? Have you added the shortcodes inside the loop (and not outside of it)?

If possible please send us some screenshots of the back-end of the view.

All the best,
Diego

#1186892
webd3-wpv-post-author-archive.png
webd3-wpv-post-author-article.png

Diego, thank you for the reply.

The content displays as expected when the conditional field is removed.

As an additional step, I copied the code from the working single post content template and pasted it into the archive content template, to make sure I didn't have any extraneous characters or other errors. This is the code:

[wpv-conditional if="( '[wpv-post-author] info='user_login'' ne 'staffreport' )"]<div class="author">[wpv-post-author]</div>
<div class="title">[types usermeta='staff-title' user_is_author='true'][/types]</div>[/wpv-conditional]

Screenshots of the two content templates are attached.

Thank you for your assistance.

#1186939

Diego Pereira
Supporter

Hi there,

Please send us access to your WordPress dashboard (website URL, login and password) I'll check and do some tests. - Please use the private field to send the sensitive data - do not post if you do not see it.

It would be better if you give me a test site rather than the live site.

IMPORTANT Please backup a working copy of site files and database before.

Please also send us a link to the view and to the page with the issue (archive).

Kind regards,
Diego

#1188120

Diego Pereira
Supporter

Hi there,

I was able to fix this by using the author name in the conditional tag (instead of the author login):

[wpv-conditional if="( '[wpv-post-author]' ne 'Staff Report' )"]
<div class="author">[wpv-post-author]</div>
  <div class="title">[types usermeta='staff-title' user_is_author='true'][/types]</div>
[/wpv-conditional]

After that, it works as expected on both single/archive pages:
- hidden link
- hidden link
- hidden link

If you need more help just let me know.

Kind regards,
Diego

#1193291

My issue is resolved now. Thank you!

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