Skip Navigation

[Resolved] Problems when using the post title shortcode inside a view shortcode

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

Problem: I'm trying to use the post title as a shortcode attribute in a View filtered by term name. When I write the title out, the View works as expected. When I use the wpv-post-title shortcode, the filter does not show the correct results.

Solution: Some characters in the post title are being interpreted differently in the shortcode attribute. We have proposed a temporary workaround in a custom shortcode here in the ticket, but if the problem appears again please report the problem in a new ticket for additional investigation and mention this ticket as a related issue.

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

Last updated by AtefR7377 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#679442

Hi Christian,

Following on from my question before here:

https://toolset.com/forums/topic/how-to-create-a-taxonomy-view-that-uses-the-post-title-automatically/

Now I have a CPT called "sermons", and a custom taxonomy called "Series".

some sermons will be individual posts, and some sermons will be grouped under the "series" taxonomy. (e..g a series about the book of Genesis, can have 5 posts, all have the custom taxonomy "Genesis").

I will create a post (from the same sermons CPT) for the series. the post title will be identical to the series name. however, slug will not be identical as slug is governed by the 256 characters, and the Arabic characters get encoded in the slug).

that's why the slug solution will not work in this case.

I want to create a view that takes the post title and use it automatically to create a view of the sermon posts that have this taxonomy term.

The code I used doesn't give anything. I have the code wrapped in a conditional, but even without the conditional, it still doesn't give any results.

here are the code variation I tried:

[wpv-conditional if="( '[wpv-post-type]' eq 'sermon' ) AND ( $(wpcf-is-this-a-series) eq '1' )"]
[wpv-view name="series-view" wpvseries="[wpv-post-title]"]
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-type]' eq 'sermon' ) AND ( $(wpcf-is-this-a-series) eq '1' )"]
[wpv-view name="series-view" wpvseries="[wpv-post-title id='$current_page']"]
[/wpv-conditional]

Here is the result, an empty page:
hidden link

while if I used the post title directly, th e correct posts (2 posts) show. so the view itself works:

hidden link

can you please help me identifying why my codes don't work?

thanks in advance

#679813

How is the Series View's Query Filter configured? Is there a term search filter, or a term ID filter? Please take a screenshot in wp-admin so I can see the configurations.

#680226
Screenshot_20180418-004812_Samsung Internet.jpg
Screenshot_20180418-001356_Samsung Internet.jpg
Screenshot_20180418-001345_Samsung Internet.jpg
Screenshot_20180418-001325_Samsung Internet.jpg
Screenshot_20180418-001303_Samsung Internet.jpg
Screenshot_20180418-001240_Samsung Internet.jpg

Hi Christian,

This view doesn't have a search query
It is built using a filter that filters the posts based on the taxonomy term title

Then I am using shortcode to display the results.

I took screenshots of the view.

Please let me know if you require more information.

Thanks

#680360

May I log in and look at your wp-admin area to see how you have your taxonomy, terms, and slugs set up? Private reply fields are active here.

#687590

Hi, I'm not able to see an obvious problem here so I've asked an Arabic-speaking team member, to take a look. We will update you soon.

#687879

I'd like to make a clone of your site so we can run some tests. If it's okay with you, I can install the Duplicator plugin to create a site clone and download it to install locally. Let me know if you approve and I can begin.

#689646

Hi Christian,

No problems. can you please proceed with any steps required for testing?

Also, can you please do me a favor and provide the clone you will do to your colleague Luo Yang as he wanted from me the database dump and i don't know how to do it?

this is in regards to my other question here:
https://toolset.com/forums/topic/row-width-not-followed-and-video-appears-bad-on-mobiles/

Very much appreciated.

#689853

Hi Christian,
I think that the problem happens when the post title is more than one work in Arabic.

here is a summary of my tests on another wp installation i have:

When post title is:
- one word in Arabic: the shortcode works
- one word in English: the shortcode works
- multiple words in English: the shortcode works
- multiple words in Arabic: the shortcode doesn't work and gives (no posts found).

(by the way, the view on my live website that you are testing on, doesn't show anything becasue i had removed the words "no posts found" in the view output).

hope this help investigating

#692633

Thanks for the additional info, I am in the process of cloning the site now and I will provide a copy to Luo.

#693187

Okay I have run some additional tests but I'm still not clear why this isn't working as expected, so I'm passing your information to my 2nd tier support team for further investigation. Please stand by and I will update you soon.

#735554

Hi, it appears that some characters are being interpreted differently in the shortcode. Please add this code to functions.php:

add_filter('wpv_filter_wpv_get_view_shortcodes_attributes', 'ts_shortcode_dash_replacement');
function ts_shortcode_dash_replacement($attributes)
{
    foreach ($attributes as $key => $attribute) {
        if (strpos($attribute, '–') !== false) {
            $attributes[$key] = str_replace('–', '-', $attribute);
        }
    }
    return $attributes;
}

Let me know if the problem is not resolved. In my local tests, I was able to use the wpv-post-title slug effectively in a filter.

#739091

Thanks Christian for such awesome support level that you provide every single time. I can't thank you enough.