Home Forums Weaver Xtreme Theme Is it possible to replace header image depending on post category?

Topic Resolution: Answered

This topic contains 50 replies, has 3 voices, and was last updated by  Weaver 1 year, 11 months ago.

Viewing 16 posts - 1 through 16 (of 51 total)
  • Author
    Posts
  • #20013
    Answered

    Rinaldo
    Participant

    Something like: If category XYZ replace header image with img URL… ?
    I think that could be interesting for many woo users.

    #33029

    Weaver
    Keymaster

    That doesn’t sound a whole lot different than the FI as Header Image on a per post basis. And it won’t get any better than that.

    And I assume you must mean only the Single View page? The current FI as header replacement is the only feasible to implement option I can think of.

    #33030

    scrambler
    Moderator

    Are you speaking about WordPress Automatic Category pages, or the single post pages belonging to a specific category?

    If the later, then as weaver mentioned there is a way to do that with the current FI as header replacement in single posts pages.

    If the former, the only way to do that right now is to recreate the category pages using a page with posts so that you can use the XTreme option for this page. 

    @weaver As I had mentioned in a separate Emails, Options to customize WordPress Category pages would be a nice addition.

    @rinaldo changing header image in specific pages is possible using Actions & FIlter (requires Plus) as explained below
    https://forum.weavertheme.com/discussion/8405/actions-filters-tips-and-examples-part1

    But @weaver, the Tips above was for Weaver II, is the syntax the same for Xtreme ?

    #33031

    Rinaldo
    Participant

    No,  sorry, I meant Woo product categories, but I assume that makes not much of a difference.
    The Woo single product image is the post FI.
    It cant be a header image replacement.
    This product category replacement would save me a lot of time …

    #33032

    scrambler
    Moderator

    If you have “Plus”, Experiment with the article I referenced above

    @rinaldo changing header image in specific pages is possible using Actions & FIlter (requires Plus) as explained below
    https://forum.weavertheme.com/discussion/8405/actions-filters-tips-and-examples-part1

    #33033

    Rinaldo
    Participant

    @scrambler, these code samples look very interesting, if they also work for Xtreme. I will have a closer look tomorrow. Thanks!

    #33034

    scrambler
    Moderator

    We need @weaver to give us the modified syntax for Xtreme, as The one from weaver II does not seem to work

    I tried

    add_filter(‘theme_mod_header_image’, ‘my_header_image_filter’);
     function my_header_image_filter($image_url) {
     if (is_category(‘category-name’))
         $image_url = “Image-Url“;
       return $image_url;
     }

    and I got the error
    Parse error: syntax error, unexpected ‘my_header_image_filter’ (T_STRING) in /…./wp-content/plugins/weaver-xtreme-plus/includes/weaver_xplus_runtime_lib.php(151) : eval()’d code on line 2

    EDIT: I actually tried the code on Weaver II and it also failed with the same error, so I am not sure what is going on, as I do remember this working.
    May be WP4.7 has changed something there, hopefully weaver can enlighten us 🙂

    #33035

    Rinaldo
    Participant

    Of course there is a plugin that is supposed to do exactly what I need, unfortunately it is also not working with Xtreme.

    #33036

    Rinaldo
    Participant

    Actually, Joy’s code works for Woo product categories:

    add_filter(‘theme_mod_header_image’, ‘my_header_image_filter’);
     function my_header_image_filter($image_url) {

     if ( is_product_category( ‘category slug’ ) )
         $image_url = “http://theimageYouwantforcategorypages“;
       return $image_url;
     }
    Thank you very much @scrambler! and Happy New Year!

    Now I only need to figure out how to replace a menu, depending on category. 🙂

    #33037

    Weaver
    Keymaster

    Menu stuff is really much harder than most WP items as the filtering is not quite as flexible. I think this is one main reason you can’t find plugins for menu replacement.

    The new Per Page menu options available in Weaver Xtreme Plus 3.0 (to be released next week) relies on an intimate knowledge of how Weaver interacts with WP menus.

    BUT, that does mean that if you can tweak PHP, it would be possible to build a child theme that overrides the primary, secondary, or header mini menu. Those are implemented as WP templates which can easily be overridden in a child theme. The code would be somewhat specialized, but since adding the Per Page replacement, the logic for using an alternate menu is now available to adapt.

    #33038

    scrambler
    Moderator

    Glad the code work for is product, but I still would like to know why the original code mentioned above generates the PHP error.

    @weaver, any insight??

    #33039

    Rinaldo
    Participant

    @weaver, the fixed header widget with xmenu inside doesnt work well on phones.

    Also, I  get the impression that “.is-phone” is not equal to “if is phone”?
    .is-phone .woocommerce div.product div.images div.thumbnails{display:none!important} doesn’t work.

    #33040

    scrambler
    Moderator

    Please be more specific, we do not read minds  🙂

    1- What do you mean exactly by “the fixed header widget with xmenu inside doesnt work well on phones.”
    Can you explain what you mean by “does not work well” and give us a link to the page showing what issue you have on phones

    2- First , you need a space before !important
    {display:none !important}

    Second, Where is the selector .woocommerce ?
    If it is on the body tag, then it needs to be attached to .is-mobile, as is-mobile is a class of the body tag too. the rule would need to be as shown below

    .is-phone.woocommerce div.product div.images div.thumbnails{display:none !important}

    #33041

    scrambler
    Moderator

    For #1, if the site is
    http://irinaafrica.tours/product-category/self-drive-safaris/
    and if the issue is that the extra menu in the fixed header widget area does not properly switch to a proper slide open mobile menu (always open and no hamburger icon), then something is definitely messing up that menu script

    First thing to do is create a test page, insert the exact same extra menu shortcode as what you have in the header widget area in the page content, publish and view the page, and see if when reducing the browser the menu switches to a proper slide open menu.
    If it does not, provide a link to the page and the exact shortcode you are using.

    next thing to try will be to clear and deactivate any cache plugin, and see if that fixes the issue.
    next will be to deactivate ALL non weaver plugins, and see if that fixes the problem.

    #33042

    Rinaldo
    Participant

    Hi,
    I am talking about all the pages using the X menu inside the header widget,  with standard primary styling,
    also http://irinaafrica.tours/
    The menu appears on my iphone as a vertical  menu, and since the menu BG is almost transparent, one gets very confused. 50% of the phone screen is covered by header and menu. So, the menu should not be fixed to the top on phones. How can I do that please??
    I found the Pro solution, where I could unfold the menu much better. I assume that would be the Accordion styling?

    Re. the “if is phone” rule:
    I have the equivalent rule in the Pro sites: .weaver-mobile .woocommerce div.product div.images div.thumbnails{display:none!important} and this works! Please check http://irinaafrika.de/reise/kapstadt-garden-route-tour/

    But I c&p your code anyway, and it makes no difference.

    I believe the category pages were messed up by this category banner image plugin. It was much worse. I used a db cleaner.

    Thanks for your help!

    #33043
    Best Answer

    scrambler
    Moderator

    This reply has been accepted as the best answer.

    1- First and as I mentioned in my last mail, the menu in the header widget area are BROKEN

    When Switching to the mobile menu, they should display close with a hamburger icon and slide open when we click on the hamburger icon.
    The fact that on mobile your menu is always open means something is interfering with the menu script, you need to figure out what that is following what I mentioned in my last post, or else you may have many bigger issues lurking.

    2- Once the mobile menu is fixed, it will be closed by default when you scroll. That said, About the transparent background when it is opened, you have two possibility.
    Unfix it on mobile following the tutorial below
    https://guide.weavertheme.com/menus-alternate-transition-for-fixed-on-scroll-menus/

    Or make the menu white on mobile with the rule below
    .is-mobile .menu-secondary .wvrx-menu > li > a {background-color:white;}

    3- Abut your is-mobile rule.
    Give me a link to the page that has the rule in place so I can see why it is not working

Viewing 16 posts - 1 through 16 (of 51 total)

You must be logged in to reply to this topic.