0
votes

I am trying to link bootstrap into advisor theme in Wordpress. Wordpress 4.9.6 Bootstrap 4.1.1

In my child theme folder wp-content/themes/restaurant-advisor-child/

Is a functions.php file, in which is this script:

 <?php

add_action('wp_enqueue_scripts', 'your_child_theme_enqueue_styles');
function your_child_theme_enqueue_styles()
{

    $parent_style = 'restaurant-advisor';


    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_enqueue_style('bootstrap', get_stylesheet_directory() . '/bootstrap/css/bootstrap.min.css');
    wp_enqueue_script('bootstrap', get_stylesheet_directory() . '/bootstrap/js/bootstrap.min.js');
}

As you can see, I link the bootstrap in last two lines. This code generates me this link:

https://pizza-zdice.cz/data/web/virtuals/150076/virtual/www/domains/pizza-zdice.cz/wp-content/themes/restaurant-advisor-child/bootstrap/css/bootstrap.min.css?ver=4.9.6

And:

https://pizza-zdice.cz/data/web/virtuals/150076/virtual/www/domains/pizza-zdice.cz/wp-content/themes/restaurant-advisor-child/bootstrap/js/bootstrap.min.js?ver=4.9.6

These links, give me 404. The folder is in wp-content/themes/restaurant-advisor-child/bootstrap/

How should I change my links, to get into the folder with files? Thank you for help.

1

1 Answers

0
votes

get_stylesheet_directory() is used to get the path (useful for including PHP files), you're looking for the get_stylesheet_directory_uri() function instead, since it rather returns the URI (useful for enqueueing scripts and stylesheets).

add_action('wp_enqueue_scripts', 'so_50882380_enqueue_styles');
function so_50882380_enqueue_styles(){
    $parent_style = 'restaurant-advisor';

    wp_enqueue_style( 'restaurant-advisor', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ) );
    wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/bootstrap/css/bootstrap.min.css' );

    wp_enqueue_script( 'bootstrap', get_stylesheet_directory_uri() . '/bootstrap/js/bootstrap.min.js' );

}