Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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

    #1297850

    Hi mosaic,

    Please check this thread: https://kriesi.at/support/topic/transparent-header-as-default/
    Hope it helps.

    Best regards,
    Nikko

    #1297999

    Thanks, 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

    #1298003

    Hey,

    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,
    Yigit

    #1298252

    Hi 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!

    #1298258

    Hi,

    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,
    Yigit

    #1298746

    Hi 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

    #1299589

    Hi,

    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,
    Ismael

    #1299606

    Right! 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?

    #1300096

    Hi,

    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,
    Ismael

    #1301042

    Could you show me how to use this? I don’t quite understand what I need to do. Thanks!

    #1301262

    Hi,

    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

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.