Alright Shane, maybe I'll just end up doing that. Will the WPV fields (Taxonomy titles,etc work at least? If we need the views to be separate then the wpv fields should work OK on both page types regardless?) - because I am losing the ability to display the taxonomy title for a view set to "Taxonomy where this View is inserted" for archive pages. It's not working
The sidebar is a view, it's ID is 5819
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marie,
Since both views will be taxonomy views then yes your taxonomy fields will still work.
Your views will remain the same, the only difference is that you will now have two of them with 2 different filters.
However I see the issue you are having. I might have a workaround for you that will allow you to keep only 1 view and 1 filter.
Could you let me know exactly where the sidebar was added from.
I'm looking in the Widgets options for wordpress and i don't think i'm in the right place . Looking forward to hearing from you soon.
Also please send a screenshot.
Thanks,
Shane
Hi Shane,
I have modified my theme's functions.php file to output a custom sidebar for all pages of that custom post type and its taxonomy archives (I use genesis theme so it was just a matter of unhooking the original sidebar and hooking my custom one which is also set from the widgets area)
I just have a question about why this suddenly stopped working after the Views update? It was fine for months before and with the new update it just broke it and now I have to duplicate the view as per your recommendations (and then if I have to change something I have to change it for both of them? which is maybe a bit counterproductive)
Edit: OK I think I'll just use a conditional statement - could you please tell me what conditional to use to detect what kind of page (taxonomy archive / single post) it is before it outputs anything? Is this possible (In PHP it is, right? could we also do that in Toolset as a wpv-condition)? Please let me know, thank you!
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marie,
For the conditional you can check by using the is_archive or is_single functions.
https://developer.wordpress.org/reference/functions/is_archive/
https://developer.wordpress.org/reference/functions/is_single/
So they both return a boolean, this means if the page is an archive it will return true.
Example.
if(is_archive()){
do something
}
elseif (is_single()){
do something
}
I'm not sure why your filter was working before but it seems to have been a bug. How it functions in the newest version is how it should work, because a page and an archive are different and the data they provide are different.
I see that you have is working a bit now, so its just the conditional you need to add.
Please let me know if what i sent helps.
Thanks,
Shane
This works! Thank you very much Shane!
Oh wait sorry I closed it by mistake - will this work in Views (I've only used it on PHP files and Genesis Hooks)? Do I need to do something to apply it to a wpv-conditional wrap?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marie,
No this php code won't work inside a view.
What you can do is to wrap the is_archive() and is_single() into shortcodes.
Then you can use them in the [wpv-conditional]
Would you like for me to wrap them in shortcodes for you ?
Ah yes please! I've always wondered how to to that, if you could wrap them in shortcodes and tell me how to apply it I would appreciate the assist and learn from it as well, thank you so much!
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marie,
I use this tool here to generate my shortcodes.
hidden link
Here are the shortcodes.
// Add Shortcode
function check_archive() {
return is_archive();
}
add_shortcode( 'check_archive', 'check_archive' );
// Add Shortcode
function check_post() {
return is_single();
}
add_shortcode( 'check_post', 'check_post' );
So they are [check_archive] and [check_post] both will return 1 if they hold true.
To use them in you views conditionals you will need to add the shortcode names to the view 3rd party shortcode arguments.
An example usage would be.
[wpv-conditional if="( '[check_post]' eq '1' )"]
Do something
[/wpv-conditional]
Please let me know if this helps.
Thanks,
Shane
Thank you Shane! I was able to apply the shortcode and it does return a 1 / nothing depending on the page type, but the conditionals aren't working even if the conditions are true, do you have any advice on how to go with this?
Thanks!
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marie,
Could you add the debug = 'true' attribute and send a screenshot of the debug data on the frontend let me see.
Thanks,
Shane
Oh it's alright, I figured it out - I registered the shortcodes in the conditional views window.
Thank you so much!