• I’m starting in wordpress and I’ve created a child theme, I’m trying to add a modal but it does not work out, the steps I took were:
    -Add the function.php in the subject-child

    <? php
    function enqueue_styles_child_theme () {
    
    $ parent_style = 'twentyseventeen-style';
    $ child_style = 'twentyseventeen-child-style';
    
    wp_enqueue_style ($ parent_style,
    get_template_directory_uri (). '/style.css');
    
    wp_enqueue_style ($ child_style,
    get_stylesheet_directory_uri (). '/style.css',
    array ($ parent_style),
    wp_get_theme () -> get ('Version')
    );
    wp_enqueue_style ($ child_style,
    'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
    array (),
    null,
    true
    );
    }
    
    add_action ('wp_enqueue_scripts', 'enqueue_styles_child_theme');
    
    function twentyseventeen_child_js () {
    wp_enqueue_script ('jQ',
    'https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js',
    array (),
    null,
    true
    );
    
    wp_enqueue_script ('bootstrap',
    'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',
    array (),
    null,
    true
    );
    
    }
    
    add_action ('wp_enqueue_scripts', 'twentyseventeen_child_js');
    
    - Copy the footer to the child theme Include the modal file after
    <? php wp_footer (); ?> Like this:
    
    <! - Include modal ->
    <? php include 'modal.php'; ?>

    – create the file modal.php

    <! - Modal ->
      <div class = "modal fade" id = "myModal" role = "dialog">
        <div class = "modal-dialog">
    
          <! - Modal content ->
          <div class = "modal-content">
            <div class = "modal-header">
              <button type = "button" class = "close" data-dismiss = "modal"> & times; </ button>
              <h4 class = "modal-title"> Modal Header </ h4>
            </ div>
            <div class = "modal-body">
              <p> Some text in the modal. </ p>
            </ div>
            <div class = "modal-footer">
              <button type = "button" class = "btn btn-default" data-dismiss = "modal"> Close </ button>
            </ div>
          </ div>
    
        </ div>
      </ div>

    – Finally add an entry with the button that the modal must call:

    <! - Modal Bootstrap ->
    <button class = "btn btn-info btn-lg" type = "button" data-toggle = "modal" data-target = "# myModal"> Open Modal </ button>

    But does not it come out? What do you think I’m failing?

    I have verified and upload the files of js and css. Any ideas?

    The page I need help with: [log in to see the link]

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

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    There could be many things wrong and rabbit holes we could fall into. If you show us the Webpage with the problem we can get straight to the point.

    There is a weird bit at the end of the functions.php file, after the final “add_action” is a block of code that looks like it should be a comment, but is not. This could be derailing your task.

    Have you enabled debugging ?

    Have you verified the php files ?
    An online verifier: https://www.piliapp.com/php-syntax-check/

    Thread Starter cmherreraa89

    (@cmherreraa89)

    200/5000
    thanks for answering, in this link you can find the code http://webdepruebacindy.byethost7.com/pruebas/twentyseventeen-child/
    I think I’m not importing the bootstrap and jQuery libraries.
    Thank you very much

    Moderator bcworkz

    (@bcworkz)

    You cannot use the googleapis version of jQuery because twentyseventeen loads the site’s local jQuery and the two will conflict. Remove the googleapis reference entirely and simply enqueue the local jQuery with wp_enqueue_script('jquery');

    Twentyseventeen does the same, so you don’t really need to enqueue at all, but it doesn’t hurt to do so more than once. As long as the correct handle is specified, there will only be one script reference no matter how many times it’s enqueued.

    There may remain other issues, but this is certainly a problem. The theme code you linked to is helpful, but Andrew and others here are looking for a live page exhibiting your issue. We realize this is not always possible, but it is something that can be very helpful in solving mysterious issues, so we always ask.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘theme children’ is closed to new replies.