Skip Navigation

[Resolved] Filter content to show user page user's posts only

This support ticket is created 3 years, 3 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
- 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 5 replies, has 2 voices.

Last updated by joelK-5 3 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#2339345
user page.jpg

Hi Team,

I have a Toolset View that shows custom post types and it is used on a user page (i.e. hidden link).

I have followed some of the help articles on the Toolset site and filtered view content to:

Select posts which author's id is set by the View shortcode attribute "author" eg. [wpv-view name="view-name" author="1"]

In my theme function.php file I have added the following code:

function get_author_id_in_archive_func($atts) {
  $author_id = 0;
  $author_id = um_get_requested_user();
  return $author_id;
}
add_shortcode("get_author_id_in_archive", "get_author_id_in_archive_func");

um_get_requested_user(); is shortcode used by the Ultimate Member plugin that gets the requested user for that user page. I have added shortcode:

Author ID: [get_author_id_in_archive]

to the page and it shows the correct user ID for the user being displayed so I know that the function added to the functions.php file is working and getting the right user ID.

However, when I add the shortcode to display the Toolset View:

[wpv-view name="Author-Archive-View" author="get_author_id_in_archive"]

the view shows no posts when I know it should show one. You can see this by the attached image.

I would appreciate any suggestions that you might have?

Kind regards,
Joel

#2339387

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

To use custom shorted you created as view's shortcode attribute, first you will have to register your shortcode at:
=> Toolet => Settings => click the Front-end Content tab => add your shortcode name in the Third-party shortcode arguments section.

You can use the shortcode with your view as given under (you will have to keep the opening and closing brackets) as you can see with the following example):

[wpv-view name="Author-Archive-View" author="[get_author_id_in_archive]"]

More info:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/how-to-create-a-custom-shortcode/#using-the-custom-shortcode

#2339465
error.jpg

Hi Minesh,

Thanks for your reply. I forgot to mention that I had already added the shortcode name to the thirdparty section of Toolset. I have now updated the WPV shortcode as per your reply but now the view is showing all posts, not just the author's posts. You can also see that there is the following characters shown after the posts

"]

You can see on the attached image that it is the last two characters of the shortcode.

Kind regards,
Joel

#2339475

Minesh
Supporter

Languages: English (English )

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

Can you please share problem URL and admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2340163

Minesh
Supporter

Languages: English (English )

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

First of all, I've set the setting to use both Toolset Blocks and Views from your settings page:
=> hidden link

More info:
- https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/

Then, I've created the following content template and added the view you display to it:
=> hidden link

[wpv-view name="Author-Archive-View" author="[get_author_id_in_archive]"]

And then I've added the shortcode to display the above content template to your Elementor's shorcode module:
=> hidden link

[wpv-post-body view_template="ct-for-author-archive-view"]

I can see not its working as expected:
- hidden link

Can you please confirm it works at your end as well.

#2340289

Hi Minesh,

Thank you so much for your help 🙂 That works perfectly.