Skip Navigation

[Resolved] user description, post name, date format, performance toll

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to display the standard User description field ("biographical information" in the User profile) in a Content Template for posts and also in a posts archive.
Solution:
Use the wpv-post-author shortcode in a View of posts or a Content Template for some post type to display the User's description information:

[wpv-post-author format="meta" meta="description"]

In an author archive outside the loop, you can use the wpv-user shortcode with a custom shortcode attribute that grabs the author's User ID.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/

This support ticket is created 3 years, 11 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by blueS-2 3 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#2101305

Hello
I need help with 4 things in views/archives/content templates using blocks.

The site is being developed but publicly accessible, uses the latest versions of toolset, wordpress, woocommerce, relevanssi and kadence theme and blocks. It's a corporate site, with a services catalog (ask for price/information), static pages (about us, governance, why us,...), news (2500 blog posts) and an area for more insightful posts (a cpt made with types), plus some extra cpt's for specific information (old projects, press releases, customers). Site is in portuguese (pt-pt).

1) User Description: I'm trying to get the "user description" in a content template for a types CPT (CPT has post like properties, but want to use in in a different area of the site, not in the blog area) and also in the author archive, but such field doesn't show up in blocks standard fields options and when using the fields&text I can select such option but the result is blank. Already tried with the shortcode [wpv-user field="description"], also with no output (blank).
You can see here (content template) hidden link and here (author archive) hidden link.
User description works well in the standard post (here) hidden link

2) Localized Post name in search archive: created an archive for search results, using relevanssi for indexing, the search archive shows all cpt's of the website, however the translated post type names do not show up. Site is in portuguese (pt-pt), but woocommerce products keep showing up as "product" and not "produto" and posts as "post" not "artigo". Used a conditional for the posts to show up as "noticia", but am afraid of having more nested conditional having a toll in performance. Tried loco translate, but it does not find the .po/.mo for toolset/blocks/woo blocks, tried "say what" plugin with toolset and woo text domains, but no substitutions are made. Is there a way of blocks/views use the localized version of wordpress/woocommerce?
You can see an example here hidden link

3) Localized date in content templates and archives: post date in content templates and archives shows up in english, although when using the default theme post & archives is correctly in portuguese. Tried the shortcode [wpv-post-date format="j \d\e F, Y"] to show the date in the same way wordpress is configured, but the escape codes of "de" don't seem to work. Saw in a forum post that the unlocalized date format was a bug to be fixed. My question is if it has already been fixed or what are the correct escape codes to use inside the shortcode (can't find it in shortcode reference).

4) Performance toll: the development is being made in a VPS with production specs (32G dedicated, octacore Xeon dedicated, SSD, ubuntu 16 with latest versions of everything, php 7.4 FPM with 1G RAM limit). The site has around 2500 posts plus 250 services (it's a catalog, using woocommerce for the filtering features, prices and checkout not being used) and some 30 insight (the CPT created). When running the standard post loops or woocommerce, everything runs smoothly, server processor doesn't even flinch. When trying to design views or archives the interface becomes sluggish, server processor spykes and I get timeouts and database connection lost. Tried in several browsers and with all addons off, sluggishness in all. On the user end, my computer running the browser is a R7/16GB, so no issues on the PC side. Used this VPS for developing even more demanding sites and even for medium traffic production sites, and this never happened. Is there a way of optimizing this?

Thanks in advance and best regards
Alex

#2101589

Hello, I'm splitting off some separate threads to address each your concerns individually. Our support policy is one issue per ticket to help keep the forum organized and make it easier to search for similar problems and find solutions quickly. I'll address the first issue here, regarding the User Description field. You will receive notifications about the new tickets as I create them.

1) User Description: I'm trying to get the "user description" in a content template for a types CPT...and also in the author archive, but such field doesn't show up in blocks standard fields options and when using the fields&text I can select such option but the result is blank.
User Description: you are referring to the information stored in the User Profile as "Biographical Info", correct? If so, the wpv-user shortcode should be able to display this information. I have a test setup in my local environment, and some screenshots attached here. There could be an issue of ambiguity, depending on which User's information are you trying to display - the current logged-in User, or the author of the CPT post displayed in this Content Template, or another, arbitrary User?

By default, the wpv-user shortcode will display information about the current, logged-in User unless it is placed inside a View of Users. In that case, the wpv-user shortcode will display information from the User in the current loop of Users. If you want to display information about an arbitrary User, you can specify a User ID in the id attribute like so:

[wpv-user id="12345" field="description"]

In the Content Template for some post type, you can display the post author's description field using the wpv-post-author shortcode:

[wpv-post-author format="meta" meta="description"]

In an author archive, you could use the wpv-post-author shortcode again in the loop of posts to display the post author's description field. Outside of the loop, you can use the wpv-user shortcode but you must specify the author's User ID because, as I mentioned before, the default behavior is to display the current, logged-in User's information outside of a View of Users. To get the author's ID, you need a custom shortcode. You can add the following code to your child theme's functions.php file, or to a new custom code snippet in Toolset > Settings > Custom Code. If you create a snippet in wp-admin, set it to run everywhere and be sure to activate the snippet after you save it.

function get_author_id_in_archive_func($atts) {
  $author_id = 0;
  if (is_author()){
    $author = get_queried_object();
    $author_id = $author->ID;
  }
  return $author_id;
}
add_shortcode("get_author_id_in_archive", "get_author_id_in_archive_func");

Register get_author_id_in_archive in Toolset > Settings > Front-end Content > 3rd-party shortcode arguments, then you can use it like so:

[wpv-user id="[get_author_id_in_archive][/get_author_id_in_archive]" field="description"]
#2101603
Screen Shot 2021-06-28 at 3.18.32 PM.png
Screen Shot 2021-06-28 at 3.18.48 PM.png
Screen Shot 2021-06-28 at 3.18.59 PM.png

Forgot to attach the screenshots, sorry!

#2101971

Hi Christian
Thanks for your help, it worked.

My issue is resolved now. Thank you!