• Hello,

    I’m trying to make a child theme, but I can’t get /inc/extras.php in it. I need this because i’m using a form inside the Call for Action section. I made a functions.php with the following code:

    <?php
    /**
     * Custom functions that act independently of the theme templates.
     */
    require get_template_directory() . '/inc/extras.php';
    }

    But no succes.

    Can you please help me.

    Greets

Viewing 10 replies - 1 through 10 (of 10 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    So you’ve modified the /inc/extras.php file from the parent theme?

    Thread Starter Hindrik

    (@hindrik)

    So you’ve modified the /inc/extras.php file from the parent theme?

    Yes, I tried it and it worked like a charm. So now I would like to put that piece of code in my child theme extras.php. I have the edited version of the extras.php but when I use the given code for the functions, it gives me a blank page.

    So I guess the functions I use for the child theme are wrong.

    Thanks for the quick response!

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    To modify this within a Child Theme you do it through your functions.php file.

    You remove filters and then add filters of your own, e.g.:

    remove_filter( 'get_search_form', 'dazzling_wpsearch' );
    
    /**
     * Search form styling
     */
    function child_theme_dazzling_wpsearch($form) {
        $form = '
            <form method="get" class="form-search" action="' . home_url( '/' ) . '">
              Lorem ipsum
            </form>';
        return $form;
    }
    
    add_filter( 'get_search_form', 'child_theme_dazzling_wpsearch' );

    Thread Starter Hindrik

    (@hindrik)

    May I ask why there is a form included in the code? I made my own search form, so it has nothing to do with the in-build search function. ??

    I just woud like to use the modified extras.php file to work in my child theme.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I have to guess the modification you made, I’m not familiar with your site so I gave an example modification in the code above.

    You said you made your own search form, but then why did you modify the extras.php file?

    Thread Starter Hindrik

    (@hindrik)

    Hi Andrew,

    I just use the following code:

    <form>
                                    <input type="text" placeholder="Zoek & Bestel" required>
    </form>

    Just so it appears, after I put it in the child theme, I can modify it for my needs.

    I had to modify the extras.php because I want the search form to appear in the Call For Action section. Normally you can place a piece of text here with a button. You can put that text there in the theme settings, but it doesn’t support HTML.

    Thats why I searched for the Call For Action in the editor, and I located it at extras.php.
    I to update the theme when I have to, so I made a child theme. But since extras.php is in the /inc folder, it’s not overwritten by the child theme.

    So thats why I have to make a function in my child theme which includes the /inc folder.

    I would like to learn how to make a functions.php in a child theme which calls the /inc folder to overwrite the parent one.

    Thanks!

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can you tell us exactly what you changed in your extras.php file? If not, copy all of the code from that file and paste it into PasteBin and link us that: https://pastebin.com .

    Thread Starter Hindrik

    (@hindrik)

    This is the edited file of extras.php
    Pastebin

    The only thing I replaced is THIS:
    <span class="cfa-text">'. of_get_option('w2f_cfa_text').'</span>

    with THIS:

    <span class="cfa-text"><form>
    <input type="text" placeholder="Zoek & Bestel" required>
    </form></span>

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Okay so all you need to do is put this in your Child Theme functions.php file:

    /**
     * Call for action button & text area
     */
    function dazzling_call_for_action() {
      if ( is_front_page() && of_get_option('w2f_cfa_text')!=''){
        echo '<div class="cfa">';
          echo '<div class="container">';
            echo '<div class="col-md-8">';
              echo '<span class="cfa-text"><form>
                    <input type="text" placeholder="Zoek & Bestel" required>
                    </form></span>';
              echo '</div>';
              echo '<div class="col-md-4">';
              echo '<a class="btn btn-lg cfa-button" href="'. of_get_option('w2f_cfa_link'). '">'. of_get_option('w2f_cfa_button'). '</a>';
              echo '</div>';
          echo '</div>';
        echo '</div>';
      } else; {
      //Do nothing
      }
    }

    Thread Starter Hindrik

    (@hindrik)

    Hello Andrew,

    I copied the given code but it just puts the text above the header. So I think there is something missing.

    Thanks again for the help!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Child Theme’ is closed to new replies.