• Resolved motk88

    (@motk88)


    Hallo,

    is there a way to create a custom header, that is only used on single blog posts?

    I know that I can switch the header in each post to a custom header but I would like to have a default header for every post.

    Thanks in advance!

    • This topic was modified 4 weeks, 1 day ago by motk88.
Viewing 7 replies - 1 through 7 (of 7 total)
  • 4thhubbard

    (@4thhubbard)

    You can apply a different Header type for each of your blog posts using OceanWP Metabox Settings.

    Go to Appearance > Customize > Blog > Single Post. Depending on your version, you can select a default header template for single posts or customize it with different variations.

    Thread Starter motk88

    (@motk88)

    Thanks for your answer!

    However, I cannot find the option you mentioned in the customizer. I can only customize the layout of the posts, but cannot choose a header layout. I’m using version 4.0.1

    • This reply was modified 4 weeks ago by motk88.
    Shahin

    (@skalanter)

    Hello @motk88,

    Thank you for reaching out,

    There’s no direct option for this, but there are several ways to achieve what you want.

    One way is to use a sample code from here https://docs.oceanwp.org/article/375-altering-header-style-by-page

    Instead of setting it for a page, you’ll need to configure it for posts or post archives.

    Another approach could be customizing the blog code itself.

    You could also explore plugins that allow you to assign different headers and footers to CPTs or posts (search here: wp.org/plugins/).

    The last option, as you know, is to individually modify each blog post; here is the related article about it: https://docs.oceanwp.org/article/830-header-oceanwp-settings.

    I hope it helps.
    Best Regards

    Thread Starter motk88

    (@motk88)

    Thanks, I’ve tried the first option and got it to work so far, but only with the predefined header styles of the theme. Here is my code:

    function my_posts_header_style( $style ) {
    if ( is_single() && in_category('archiv') ) {
    $style = 'transparent';
    }
    return $style;
    }
    add_filter( 'ocean_header_style', 'my_posts_header_style' );

    Now I would like to know how I can assign a specific custom header instead of the transparent header. Can you help me with that?

    Hello @motk88

    Thank you for reaching out,

    You can try something like the following code, the first function shows the custom header, and the second one will assign the template to the custom.

    function only_on_single_posts( $style ) {
    	if ( is_single() ) {
    		$style = 'custom';
    	}
    	return $style;
    }
    add_filter( 'ocean_header_style', 'only_on_single_posts' );
    
    function set_custom_header_template_only_on_single_posts( $template ) {
    	if ( is_single() ) {
    		$template = 191;
    	}
    	return $template;
    }
    add_filter( 'ocean_custom_header_template', 'set_custom_header_template_only_on_single_posts' );

    Links:
    https://docs.oceanwp.org/article/375-altering-header-style-by-page
    https://docs.oceanwp.org/article/893-choose-custom-header-type-template

    Please let me know if you have any questions about the above steps.

    I hope it helps.
    Best Regards

    Thread Starter motk88

    (@motk88)

    Thanks for your help. I finally got it to work ??

    You’re welcome.
    I’m glad that the solution was helpful.

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