Skip Navigation

[Resolved] Same filter produces different results on different views

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

Problem:
You are using ShortCodes in HTML as attributes, which is strictly disreccommended by WordPress:
https://make.wordpress.org/core/2015/07/23/changes-to-the-shortcode-api/

Solution:
In order to use this not recommended approach, Views actually adds a own ShortCode parser to allow things like this, but you have to be careful with brackets and outputs.

What is sure, your URL's will not work with double apostrophes.

""

Example which will break:

<a href = "http://site.com/page/?author-filter=[wpv-user field="user_login"]&toc=1">Emails:</a>

Example which can work:

<a href = "http://site.com/page/?author-filter=[wpv-user field='user_login']&toc=1">Emails:</a>
This support ticket is created 8 years, 2 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.

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.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Beda 8 years, 2 months ago.

Assisted by: Beda.

Author
Posts
#367145
List of CVs.png
Count of CVs.png

I have two different views using the same date filter on the same type which produce different results.

I have a type called 'CVs Sent', which has a field 'Date'.

I have a page which displays a count of CVs Sent by each user in the last 7 days by calling a view of CVs Sent with the following filters:

Select posts with the author set by the parent View.
Select posts with custom field:
Date is a number greater than or equal PAST_DAY(7)

This also has a link to another view where you can see a list of the posts counted by the previous view. This second view has the following filters:

Select posts with the author's username determined by the URL parameter "author-filter"
Select posts with custom field:
Date is a number greater than or equal PAST_DAY(7)

The second view is called by the following anchor:

<a href = "hidden link field="user_login"]">CVs Sent:</a>

The 'counting' view shows only one post by this author with a date within the last 7 days (this is correct).

When I click on the link to list the posts, it brings up 3 posts. (All posts by this author, not just the ones in the last 7 days). I don't understand. The filter is the same?

Please enable me to send you login details with a private message.

#367223

You are using ShortCodes in HTML as attributes, which is strictly disreccommended by WordPress:
https://make.wordpress.org/core/2015/07/23/changes-to-the-shortcode-api/

If you do this, you will eventually have unexpected output.
Also, if you do this, all inner ShortCodes must hold a single bracket as in 'shortcode argument' instead of double bracket "shortcode argument"

This is just regarding the way you call your View.

Now, in regard to the Filters, I suggest to debug this as follows:

1. Add those 2 Views to each a page
2. Remove the Filters and add them again, one by one
3. Ensure that you filter by the exact same parameters
4. Then begin to change the parameters in each View and see when the issue comes back.

This DOC can be helpful to set Views Query Filters:
https://toolset.com/documentation/user-guides/filtering-views-query-by-date/
https://toolset.com/documentation/user-guides/filtering-views-query-by-author/
https://toolset.com/documentation/user-guides/passing-arguments-to-views/

Please don't hesitate to inform me in case the issue persists

Thank you for your patience.

#367462

Hi Beda

Thanks man. I didn't realise I couldn't use a shortcode in the URL attributes. In fact this was a recommended solution by Luoy to another problem I was having where the URL attribute was passing the users nickname instead of username:

https://toolset.com/forums/topic/view-stopped-working-after-cloning/

Maybe you can tell me a better way to do this. I have a view which loops through all the users on the site, and for each user, there are counts of various things, and then links to open up a list of the posts counted. So I need to be able to somehow pass the user as a URL attribute, to filter by the particular user for the other view. Here is the existing loop output:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
          
          [wpv-conditional if="('[types usermeta="location"][/types]' eq check_user_from_same_location())"]
          <div class = "row"> <strong>[wpv-user field="display_name"]</strong></div><br>
          <div style = "border:solid black 1px; padding : 20px;">
          <div class = "row">
            <p>Last 7 days</p>
          </div>
          <div class = "row">
             <div class = "col-xs-4 col-md-2">
            <a href = "<em><u>hidden link</u></em> field="user_login"]&toc=1">Emails:</a> [wpv-view name="bm-comms-7-days" toc = "1"]</div>
          <div class = "col-xs-4 col-md-2">
           <a href = "<em><u>hidden link</u></em> field="user_login"]&toc=2">Phone:</a> [wpv-view name="bm-comms-7-days" toc = "2"]</div>
            <div class = "col-xs-4 col-md-2">
              <a href = "<em><u>hidden link</u></em> field="user_login"]&toc=3">Meetings:</a> [wpv-view name="bm-comms-7-days" toc = "3"]</div></div><br>
          
          <div class = "row">
            <div class = "col-xs-4 col-md-2">
              <a href = "<em><u>hidden link</u></em> field="user_login"]&days=7">New Jobs:</a> [wpv-view name="bm-new-jobs-by-days" days = "7"]</div>
            <div class = "col-xs-4 col-md-2">
               <a href = "<em><u>hidden link</u></em> field="user_login"]">CVs Sent:</a> [wpv-view name="bm-cvs-sent-7-days"]</div>
            <div class = "col-xs-4 col-md-2">
              <a href = "<em><u>hidden link</u></em> field="user_login"]">Lost Jobs:</a> [wpv-view name="bm-lost-jobs-7-days"]</div>
            <div class = "col-xs-4 col-md-2">
                <a href = "<em><u>hidden link</u></em> field="user_login"]">1st Interview:</a> [wpv-view name="bm-1st-interview-7-days"]</div>
            <div class = "col-xs-4 col-md-2">
                 2nd Interview:
               [wpv-view name="bm-2nd-interview-7-days"]</div>
            <div class = "col-xs-4 col-md-2">
                 Placements:
               [wpv-view name="bm-placements-7-days"]</div>
          </div><br>
          </div><br>
          <div style = "border:solid black 1px; padding : 20px;">
          <div class = "row"> 
          <p>Last 30 days</p>
            </div>
          <div class = "row">
           <div class = "col-xs-4 col-md-2">
          
          <a href = "<em><u>hidden link</u></em> field="user_login"]&toc=1">Emails:</a> [wpv-view name="bm-comms-30-days" toc = "1"]</div>
          <div class = "col-xs-4 col-md-2">
            <a href = "<em><u>hidden link</u></em> field="user_login"]&toc=2">Phone:</a> [wpv-view name="bm-comms-30-days" toc = "2"]</div>
            <div class = "col-xs-4 col-md-2">
              <a href = "<em><u>hidden link</u></em> field="user_login"]&toc=3">Meetings:</a> [wpv-view name="bm-comms-30-days" toc = "3"]</div></div><br>
          <div class = "row">
            <div class = "col-xs-4 col-md-2">
               <a href = "<em><u>hidden link</u></em> field="user_login"]&days=30">New Jobs:</a> [wpv-view name="bm-new-jobs-by-days" days = "30"]</div>
            <div class = "col-xs-4 col-md-2">
                 CVs Sent:
               [wpv-view name="bm-cvs-sent-30-days"]</div>
            <div class = "col-xs-4 col-md-2">
                <a href = "<em><u>hidden link</u></em> field="user_login"]">Lost Jobs:</a> [wpv-view name="bm-lost-jobs-30-days"]</div>
            <div class = "col-xs-4 col-md-2">
                1st Interview:
               [wpv-view name="bm-1st-interview-30-days"]</div>
            <div class = "col-xs-4 col-md-2">
                 2nd Interview:
               [wpv-view name="bm-2nd-interview-30-days"]</div>
            <div class = "col-xs-4 col-md-2">
                 Placements:
               [wpv-view name="bm-placements-30-days"]</div>
          </div>
            </div>
              <br>
          [/wpv-conditional]
         
		</wpv-loop>

	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]
#367500

It's not that you can not, it's just disreccommended by WordPress.
Views actually adds a own ShortCode parser to allow things like this, but as stated, you have to be careful with brackets and outputs.

What is sure, your URL's will not work with double bracket ""

Example which will break:

<a href = "<em><u>hidden link</u></em> field="user_login"]&toc=1">Emails:</a>

Example which can work:

<a href = "<em><u>hidden link</u></em> field='user_login']&toc=1">Emails:</a>

Please can you try this form of HTML?

Also, please try to look at your HTML when you view that View on the Front end.

Check how the Links are parsed in the HTML console, to see if that is producing a fine URL Query.

Please don't hesitate to inform me in case the issue persists

Thank you for your patience.

#367879

Argh. What an idiot. Just took another look and my date filter was missing. Must not have saved it the other day. That's why it wasn't working. Sorry for wasting your time.

Just one thing though - these are not brackets: ""

These are brackets: () [] {}

I call these "" inverted commas or quotation marks. I have replaced them with apostrophes though '' and will try remember that in future.

Thanks for the help Beda.

#367900

Thank you Gavin, I apologize deeply my lack of technical knowledge / Accuracy in English Language in this case.
Of course I meant apostrophes / inverted commas / quotation marks and not brackets.

I am happy you could solve the issue correctly despite the confusing info.

Thank you for your understanding.

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