How can I embed a view via shortcode into wp widget that show on the buddyboss group pages and get the author of the page, by url or by someother way?
Hi there
Can you clarify "get the author of the page"?
What page?
The URL in your screenshot for managing members doesn't look like it is a "page", and wouldn't have a post author.
Oops, I mean this page: lien caché.
Where 'Brandon' is the usersname. I presume we can derive the wordpress user, from the url. Your instruction knowledge base, https://toolset.com/documentation/legacy-features/views-plugin/filtering-views-query-by-author/Using author usernames
/page/?xxxx=John Foo or /page/?xxxx[]=John Foo will show posts by the author whose username is John Foo. If no such author exists, no posts will be shown.
/page/?xxxx[]=John Foo&xxxx[]=Peter Bar will show posts by both the authors whose usernames are John Foo and Peter Bar. If one exists, his posts will be listed; if none exist, no posts will be displayed.
Note that if the URL parameter is missing or empty, all posts will be listed and no author filtering is done.
Makes it seem that we can only find the username as a constant, but not as a variable.
How can we derive the username from this url 'lien caché'?
when querying a view: https://toolset.com/wp-content/uploads/2024/04/2695088-Screen_Shot_2024_04_29_at_11.13.20_PM.png
Like this: lien caché, but that view is not getting the author from the url.
Hi,
Thank you for sharing these details.
I would create a custom shortcode ( ref: https://codex.wordpress.org/Shortcode_API ), that can get the current URL, extract the last part (i.e. /brandon/ ) to get the username, and then return that username.
You can then set the view's post-author filter to get the target author from the view's shortcode attribute 'author', as shown in the attached screenshot.
And the output of that custom shortcode can be passed in the view's shortcode, for example:
[wpv-view name="view-name" author="[customshortcode]"]
regards,
Waqar