-
AuthorPosts
-
May 2, 2021 at 11:17 am #1297774
I’m using header transparency – transparent & glassy header for all my posts and pages. Everytime I make a new post I have to set this manually. Is there any way to make the default setting for all new posts and pages ‘transparent & glassy header’ rather than ‘no transparency’. Thanks
May 3, 2021 at 5:36 am #1297850Hi mosaic,
Please check this thread: https://kriesi.at/support/topic/transparent-header-as-default/
Hope it helps.Best regards,
NikkoMay 3, 2021 at 2:06 pm #1297999Thanks, could you show me how to adapt that code so that the default header on every page/post is transparent & glassy header? The post you showed is for transparent only and I’d like it glassy. Thank you very much
May 3, 2021 at 2:20 pm #1298003Hey,
Please use the code as following instead
add_action( 'after_setup_theme', 'enfold_customization_product_switch' ); function enfold_customization_product_switch(){ add_filter('avf_builder_elements', 'avf_builder_elements_mod'); } function avf_builder_elements_mod($elements) { $counter = 0; foreach($elements as $element) { if($element['id'] == 'header_transparency') { $elements[$counter]['std'] = 'header_transparent header_glassy '; } $counter++; } return $elements; }
Regards,
YigitMay 4, 2021 at 12:18 pm #1298252Hi Yigit, thanks for your response. I added that code but when I create a new page, the header is set to ‘no transparency’ and the glassy header doesn’t show.
When you create a new page the ‘Header Visibility and transparency’ option is automatically set to ‘no transparency’. I’m hoping to make it so that all pages default to ‘transparent and glassy header’ so I don’t have to manually change it every time. Thanks!
May 4, 2021 at 12:51 pm #1298258Hi,
I tested the code before posting and once again just now but it is working fine on my end.
Could you please create temporary admin logins and post them here privately so we can look into it? :)
Best regards,
YigitMay 6, 2021 at 10:39 am #1298746Hi Yigit, all the details in private content. Thank you! I’ve now removed the code as it was having no effect so you’ll need to add it back. I’ve also linked a page in the private content section below that has the header transparency set to its default option ‘no transparency’. Please check this page once you’ve added the code to check if it works. Hopefully it should have a glassy header! When I add the code myself, the test page is unchanged. Thanks
May 11, 2021 at 8:26 am #1299589Hi,
Thank you for the inquiry.
We added the code again and it is working as expected. Please note that the new default option will only be applied to new pages, and not on pages that previously exist, which have their header settings already set.
Best regards,
IsmaelMay 11, 2021 at 9:21 am #1299606Right! Okay I understand how it’s working. This isn’t quite what I want to achieve. All my pages are set to have a glassy header. I am hoping to be able to control the header globally using code so that if I want to change the header transparency in the future I don’t have to change all of my existing pages manually. Is this possible?
May 13, 2021 at 10:52 am #1300096Hi,
The option is saved as a post meta info or as a custom field named header_transparency, so if you want to automatically set the settings for existing pages, then you have to update the header_transparency value. You should be able to do it using the update_post_meta function.
// https://developer.wordpress.org/reference/functions/update_post_meta/
Best regards,
IsmaelMay 18, 2021 at 4:57 pm #1301042Could you show me how to use this? I don’t quite understand what I need to do. Thanks!
May 20, 2021 at 3:30 am #1301262Hi,
Sure. Try to add this code in the functions.php file, then refresh the page once or twice. Remove it again afterwards.
add_action("init", function() { $pages = get_pages(array("meta_key" => "header_transparency")); foreach($pages as $page) { if($page->ID == 3255) { update_post_meta($page->ID, "header_transparency", ""); } } }, 9999);
This should update the header_transparency of the page with the ID 3255. If you want to update all pages, just remove the if statement.
if($page->ID == 3255) { update_post_meta($page->ID, "header_transparency", ""); }
Replace it with:
update_post_meta($page->ID, "header_transparency", "");
IMPORTANT: Create a site backup first before using the code above.
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.