- This topic has 19 replies, 4 voices, and was last updated 6 years, 2 months ago by
Tom.
-
AuthorPosts
-
July 15, 2016 at 3:27 am #209925
Dani
How can I setup this taxonomy pages:
http://espaipiscines.finismedia.com/tipus-producte/piscines/To be like this single taxonomy page (merge with header and transparent menu) ?
http://espaipiscines.finismedia.com/productes/piscina-obra-mosaic-blau/In the single, I have the controls to setup this, but i can have control in taxonomy pages… Can I change the header with any add_action hook?
Thank you!
July 15, 2016 at 9:52 am #210031Tom
Lead DeveloperLead DeveloperInteresting – is that a page you can edit in the Dashboard? It looks like you’re using the Page Header metabox on it?
Typically, using the Page Header metabox isn’t possible on archives/blogs, so I’m curious how you got it to work so far.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJuly 18, 2016 at 12:44 am #210733Dani
add_action( 'generate_after_header', 'fm_titol_projectes'); function fm_titol_projectes() { $queried_object = get_queried_object(); if ( is_tax("tipus_producte") && !is_front_page()) { echo '<div class="page-header-content parallax-enabled generate-page-header generate-content-header" style="background-image: url('. get_stylesheet_directory_uri() .'/images/back-header-piscines.jpg);background-size:cover"> <div class="inside-page-header-container inside-content-header grid-container grid-parent "> <div class="inside-page-header"> <h1 style="margin:0;text-shadow: 0 0 6px rgba(0,0,0,.6)">'. $queried_object->name .'</h1> </div> </div> </div>'; } }
I’ve wrote this function. But i’d like to merge with header this taxonomy archive pages, like in this page http://espaipiscines.finismedia.com/contacte/
Thank you!
July 18, 2016 at 10:38 am #210903Tom
Lead DeveloperLead DeveloperHmm, you would need to split it up into two functions:
add_action( 'generate_before_header', 'fm_titol_projectes_before'); function fm_titol_projectes_before() { $queried_object = get_queried_object(); if ( is_tax("tipus_producte") && !is_front_page()) { echo '<div class="page-header-content parallax-enabled generate-page-header generate-content-header" style="background-image: url('. get_stylesheet_directory_uri() .'/images/back-header-piscines.jpg);background-size:cover"> <div class="inside-page-header-container inside-content-header generate-merged-header grid-container grid-parent ">'; } } add_action( 'generate_after_header', 'fm_titol_projectes'); function fm_titol_projectes() { $queried_object = get_queried_object(); if ( is_tax("tipus_producte") && !is_front_page()) { echo '<div class="generate-combined-content grid-container grid-parent"> <div class="generate-inside-combined-content"> <h1 style="margin:0;text-shadow: 0 0 6px rgba(0,0,0,.6)">'. $queried_object->name .'</h1> </div> </div> </div> </div>'; } }
Not 100% sure it will work at all, but worth a shot π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJuly 19, 2016 at 7:19 am #211226Dani
Very very good!
This function inspired me! This is what I wanted. Now, I have this:
http://espaipiscines.finismedia.com/tipus-producte/piscines/
Thank you!
PD: It would be great, to implement this somehow….. with the WP metaboxes…. Maybe a plugin…
July 19, 2016 at 9:01 am #211267Tom
Lead DeveloperLead DeveloperGreat!
It’s tough to add as an option, as taxonomy/archives pages like this don’t have an “edit page” area to add the options to.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 10, 2016 at 10:00 am #243309Marc
Hey Tom,
I’m about to implement this workaround for a client, but I’m a bit worries about the sustainability. For instance, if you update the HTML structure of the page header in future GeneratePress updates, won’t this workaround break?
Is there an alternative solution to this or should I stick to placing this code in the GP Hooks for now?
Thanks man!
-Marc
November 10, 2016 at 10:01 am #243310Tom
Lead DeveloperLead DeveloperThe next update to GP Premium has a filter so we can tell GP to place the Blog Page Header (built in the Customizer) wherever we live.
If you’d like to shoot me an email I can send you the latest version to try it out π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 10, 2016 at 10:31 am #243323Marc
Wow, thanks! Just sent you an email…excited to see if this works. π
November 10, 2016 at 10:37 am #243326Tom
Lead DeveloperLead DeveloperJust sent it to you.
This is what you would do:
add_filter( 'generate_get_blog_page_header','tu_global_page_header' ); function tu_global_page_header() { // Add your conditional to show the blog page header - is_home() is default if ( is_home() ) return true; // If the conditional isn't true, set it to false return false; }
Note to others: This will work as of GP Premium 1.2.92.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 10, 2016 at 10:39 am #243328Marc
Thanks, Tom – I’ll tinker around with this and see what I come up with!
November 10, 2016 at 10:42 am #243330Tom
Lead DeveloperLead DeveloperNo problem! Let me know how it works π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 10, 2016 at 10:52 am #243336Marc
Alright, looks like I’m able to put the blog page header on the page archives now. Wooo!
Had to make some small changes to the code (for the archive):
add_filter( 'generate_get_blog_page_header','tu_global_page_header' ); function tu_global_page_header(){ // Add your conditional to show the blog page header - is_home() is default if ( is_archive() ) return true; // If the conditional isn't true, set it to false return false; }
Going to try tinkering a bit more to make the blog page header more flexible (will pull archive descriptions when the page is an archive, etc.).
Ideally, something like this would exist in the GenerarePress settings (with a menu for each new custom post type the user creates). Obviously this would take quite a while to implement, just some food for thought.
Thanks for all your help here Tom!
November 10, 2016 at 10:58 am #243339Tom
Lead DeveloperLead DeveloperGlad it’s working!
Options for stuff like this can get a little too crazy. Filters are awesome for complex stuff π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 29, 2016 at 3:36 am #249179Igor
I’ll wait to 1.2.92 to get this working, looks nice. But also I’d like to know which is the best way to put a page header for example in a custom post type archive or a custom taxonomy term page. I could make something like this:
add_action('generate_after_header', 'my_custom_generate_after_header', 0); public function my_custom_generate_after_header(){ if(is_post_type_archive('my-custom-post-type')){ $html = ' <div class="page-header-content parallax-enabled generate-page-header generate-content-header"> <div class="inside-page-header-container inside-content-header grid-container grid-parent "> <div class="generate-inside-page-header-content"> <div class="inside-page-header"> <h2>Title for mi custom post type archives</h2> </div> </div> </div> </div>'; echo $html; } }
But it is not a clean solution. Any ideas? Could be possible to create a Page Header dinammically for example with a shortcode and its attributes?
-
AuthorPosts
- You must be logged in to reply to this topic.