I want to add some "dependencies" (Bootstrap and CanvasJS) to my WordPress website. Therefore I wrote such code in functions.php file:
function basic_enqueue_style() { /*Bootstrap*/ wp_enqueue_script('popper', 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js', ['jquery']); wp_enqueue_script('bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js', ['jquery', 'popper']); wp_enqueue_style('bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css'); /*Personal CSS*/ wp_enqueue_style('main', get_template_directory_uri() . '/css/main.css'); /*CanvasJS*/ wp_enqueue_script('canvasjs', get_template_directory_uri() . '/js/canvasjs.min.js'); } add_action('wp_enqueue_scripts', 'basic_enqueue_style');
As "dependencies" they should be loaded from header
not footer
thus I did not indicated $in footer
as true
(default false
) parameter.
Documentation says:
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer);
The error information I get after adding "dependencies":
Shall I change something in index.php
file? Which now looks like this:
<?php get_header(); ?>
<?php if (is_user_logged_in()): ?>
<?php $expensesFormPage = get_page_by_title('formularz wydatkow'); ?>
<?php wp_redirect(get_permalink($expensesFormPage->ID)); ?>
<?php else: ?>
<a href="<?php echo wp_registration_url(); ?>">Zarejestruj sie!</a>
<?php wp_login_form(); ?>
<?php endif; ?>
<?php get_footer(); ?>
Many thanks for any help!!
wp_redirect
won’t work after output has started