I am trying to:
Related to a previous issue with conditionals on a View. I have a View called "riposte to" which is now working - NOT displaying an essay when no value is set in a custom field. You had given me a script for functions.php to get a list the essays in the dropdown menu custom field and a conditional to show only if an essay is selected in the dropdown using this:
<wpv-loop>
[wpv-conditional if="( '[wpv-post-field name='wpcf-riposte-to']' ne '0' )"]
[wpv-post-body view_template="Loop item in riPOSTe to"]
[/wpv-conditional]
</wpv-loop>
What I have done is replicate the script and and the conditional for two similar Views: "riposte from" and "riposte from other".
These both select essays the are responses (ripostes) about the current essay, whereas the previous "riposte to" selects an essay for which the current essay is response.
I think the problem is that I have not made the proper adjustments to the scripts in the function.php file to replicate the first functionality. Not sure what the number are in the function parameters.
Link to a page where the issue can be seen: hidden link
This page has no essays selected to any of the three riposte views.
I expected to see:
On this essay, there should be no sidebar riposte views displayed.
Instead, I got:
The three sidebar views are showing with a link to the current essay.
Hello. Thank you for contacting the Toolset support.
Well - do you mean that there is no entry set for any essay post for both of the fields "riposte from" and "riposte from other" so it should work same as the "riposte to" field - correct?
Minesh,
On this essay - hidden link for example - there is no entry set for "riposte to", "riposte from" or "riposte from other" and yet on the right sidebar it is displaying all three of these Views with a link to itself. There should be nothing displayed.
Another essay, for example - hidden link - is only a "riposte to" another essay. Only this field is set, and yet it is also displaying "riposte from" itself. It should only display "riposte to".
I think the issue must be in how I have copied and adjusted the filters:
// to display ripostes that essay is to
add_filter( 'wpv_filter_query', 'func_display_current_essay_post', 10, 3 );
function func_display_current_essay_post( $query_args, $view_settings, $view_id ) {
global $post;
if ($view_id == 5197) {
$query_args['post__in'] = array($post->ID);
}
return $query_args;
}
// to display riposte about
add_filter( 'wpv_filter_query', 'func_display_current_essay_post_from', 10, 3 );
function func_display_current_essay_post_from( $query_args, $view_settings, $view_id ) {
global $post;
if ($view_id == 5199) {
$query_args['post__in'] = array($post->ID);
}
return $query_args;
}
// to display another riposte about
add_filter( 'wpv_filter_query', 'func_display_current_essay_post_other_from', 10, 3 );
function func_display_current_essay_post_other_from( $query_args, $view_settings, $view_id ) {
global $post;
if ($view_id == 5272) {
$query_args['post__in'] = array($post->ID);
}
return $query_args;
}
Well - that was happening because you did not updated the Essay entry as we added those custom fileds after you created the essay entry. It will not have any issue with newly created entries.
As you can see with the link - its showing correct output: hidden link
Now - what I suggest to test this is test by creating new essay entry and for existing essay entry just click on update button once.
Another issue was you were using wrong field name with view "riPOSTe from other":
=> hidden link
I've corrected the filed name for above view as given under:
Thanks Minesh,
These changes have fixed some of the problems. But the big one I am noticing since these changes is that ALL essays that have not been updated are getting these fields populated with links to itself. I can see that these go away when the essays are update, but that means going back to each essay - there are over 900 essays. I don't think this was happening before. That is, essays without these fields selected did not show anything in the sidebar.
Is there a solution to this? As I said, those essays that are updated are working fine.
Ok - to overcome that issue - Logically we need to check that if field has any value and if it has any values that should be greater than 0.
I've adjusted all of your views:
=> hidden link
=> hidden link
=> hidden link
If you will check the loop output section - you will see the adjusted [wpv-conditional] shortcode with AND condition. could you please check and confirm it works for you now for all of your posts.