Home Forums Weaver Xtreme Theme Split: Weaver Xtreme 5 and Child Themes

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #70285
    victor50
    Participant

    I just made a child theme for php (to logout without nagging WooCommerce “do you really want to logout”), but somehow (some?) settings of the main theme are not retained it shows the default header picture and only “home” in the menu, maybe other things are missing…

    I could restore from backup in the child, but that didn’t help

    #70290
    scrambler
    Moderator

    We can’t really debug PHP on this forum, but at the minimum, you need to be a lot more detailed about what you did, what files you changed, how you created the child etc….

    You also need to clarify what you mean by “I could restore from backup in the child, but that didn’t help” Because if you undid the child changes and the issue is still there, then the issue comes from somewhere else.

    Have you tried deactivating the child and reverting to the main Xtreme Theme? Does that fix the issue?

    You may also want to provide a link to the pubic site.

    #70307
    victor50
    Participant

    Did some more testing. Downloaded the settings from the theme and uploaded them to the subtheme (tried both the complete and limited settings), removed all settings before downloading, Didn’t help (menu consisted of “home”, default headerimage with mountains). I created the child theme as instructed, by copying the themes folder and then renaming it.  As a test I added a second child theme. Same result. Both children display in the live view the complete menu but with the default headerimage.

    I added code to the php file. The code worked. Result:

    <?php
    if ( ! defined( ‘ABSPATH’ ) ) {
    exit;
    } // Exit if accessed directly
    /* This is the main function.php override file – it controls most of the stuff happening with the theme */

    /* Anything you need to actively do, put here. This is the first code that will get run whenever the
    child theme is activated and used. This example just re-defines a function, but you could do anything.
    */

    function weaverx_continue_reading_link() {
    /* very simple example – override the read more text… */

    $msg = ‘[CLICK TO READ MORE]’;

    return ‘ ‘ . $msg . ‘‘;
    }

    /* Added by Victor: (removed extra emtpy lines only here)

    add_action(‘check_admin_referer’, ‘logout_without_confirm’, 10, 2);
    function logout_without_confirm($action, $result) {
    /**
    * Allow log out without confirmation
    */
    if ($action == “log-out” && !isset($_GET[‘_wpnonce’])) {
    $redirect_to = isset($_REQUEST[‘redirect_to’]) ?
    $_REQUEST[‘redirect_to’] : ”;
    $location = str_replace(‘&amp;’, ‘&’, wp_logout_url($redirect_to));;
    header(“Location: $location”);
    die();}
    }

    #70308
    victor50
    Participant

    Now I set the correct menu and header image (hard to find where btw). Don’t now yet of other things are changed.

    #70310
    Weaver
    Keymaster

    Two notes about the example code you posted.

    1. The posted code is incorrect. You have an unclosed comment above the add_action that will mean nothing happens.
      /* Added by Victor: (removed extra emtpy lines only here)
    2.  If that is all you were trying to do in the child, then it is completely unnecessary to have a child just to add an action (or several actions).
      You can use the Customizer -> HTML Injection (has slightly different wordings in What vs Where interface) -> Site <HEAD> Section.

    That option is intended for exactly that purpose. Or you could also used a plugin like: https://wordpress.org/plugins/head-footer-code/

    In the long run, it is best to avoid child themes if you can, especially with Weaver Xtreme which has so many features that usually make a child unnecessary.

    #70320
    victor50
    Participant

    (1) The /* comment was not really in the code 🙂 but added here FYI

    (2) I will have look at the HTML Injection later. Implementing WooComerce is rather problematic. You can’t do very much about how things look. All kind of add-ons add further complexity and can’t do what you want in the free version and I don’t look forward to try the even more complex paid versions for my limited “shop” containing only a few books. There is some code  I found that seems to do things well  so I will keep the child theme for some time. Hope that updates of Weaver won’t reset header image and main-menu.

     

    #70332
    Weaver
    Keymaster

    Once you have a working child and keep using it, updates to the main theme (whatever one it is) should not affect the child theme. Weaver Xtreme 5 is the first time a new Weaver Xtreme version has broken child themes.

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