What causes WordPress to take precedence over Bootstrap?

Trying to integrate a Bootstrap theme I created into WordPress, but encountering issues. Despite enqueuing all necessary style sheets without errors in the console, WordPress is interfering with the layout. The rounded circles with images are appearing square and borders are showing around elements. How can this unwanted behavior be prevented?

<?php
    
     function load_stylesheets(){
    
      wp_enqueue_style('bootstrap4', 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap-grid.min.css');
    
      wp_enqueue_style('fontawesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css');
    
      wp_enqueue_style('magnificpopup', 'https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css');
    
        wp_register_style('custom', get_template_directory_uri() . '/css/bsite.css', array(), 1, 'all');
      wp_enqueue_style('custom');
    
      /*wp_register_style('custom', get_template_directory_uri() . '/custom.css', array(), 1, 'all');
      wp_enqueue_style('custom');*/
     }
     add_action('wp_enqueue_scripts', 'load_stylesheets');
    
     
     function addjs(){
        wp_enqueue_script( 'boot1','https://code.jquery.com/jquery-3.5.1.slim.min.js', array( 'jquery' ),'3.5.1', true );
    
        wp_enqueue_script( 'boot2','https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.6.0/umd/popper.min.js', array( 'jquery' ),'2.6.0', true );
    
        wp_enqueue_script( 'boot4','https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js', array( 'jquery' ),'1.1.0', true );
    
        wp_enqueue_script( 'boot3','https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/js/bootstrap.min.js', array( 'jquery' ),'4.5.3', true );
    }
    add_action( 'wp_enqueue_scripts', 'addjs' );
     
        ?>
        <?php get_header(); ?>
  
  

    <body>
        <nav class="navbar navbar-expand-lg px-3" id="navBar">
          <a href="#" class="navbar text-uppercase"> sites by bryan </a>
          <button
            class="navbar-toggler"
            type="button"
            data-toggle="collapse"
            data-target="#myNav"
          >
            <span class="navbar-icon">
              <i class="fas fa-bars"></i>
            </span>
          </button>
          
          <div class="collapse navbar-collapse" id="myNav">
            <ul class="navbar-nav mx-auto">
              <li class="nav-item active">
                <a href="#navBar" class="nav-link">home</a>
              </li>
              <li class="nav-item">
                <a href="#skills" class="nav-link">skills</a>
              </li>
              <li class="nav-item">
                <a href="#contact" class="nav-link">contact</a>
              </li>
            </ul>
          </div>
        </nav>
        
        <!-- headder section -->
        <header class="header" id="header">
          <div class="container-fluid">
            <div class="row height-max align-items-center">
              <div class="col col-md-9 ml-auto text-right pr-5">
                <h1 class="text-uppercase my-2 title">sites by bryan</h1>
                <h3 class="text-uppercase">what can i do for you?</h3>
              </div>
            </div>
          </div>
        </header>
        
        <!-- skills section -->
        <section class="skills py-5" id="skills">
          <div class="container">
            <div class="row mb-5">
              <div
                class="col d-flex flex-wrap text-uppercase justify-content-center"
              >
                <h1 class="font-weight-bold align-self-center mx-1">my</h1>
                <h1 class="section-title--special mx-1">skills</h1>
              </div>
            </div>
            <div class="row">
             
              <!-- code continues... -->

Answer №1

After testing, the code below should be operational. A CDN check has been added along with a fallback option and the necessary attributes (integrity and crossorigin). It is essential to place this in your function.php file as you cannot enqueue the file on the front end like in your given example.

Ensure that you update the fallback path accordingly.

<?php
add_action( 'wp_enqueue_scripts', 'theme_scripts' );
function theme_scripts() {
  if( ! is_admin() ) {

    // Deregister Wordpress jquery core version
    wp_deregister_script( 'jquery' );

    // Register and enqueue jquery_js
    $test_jquery_js = @fopen( 'https://code.jquery.com/jquery-3.5.1.min.js', 'r' );
    if( $test_jquery_js !== false ) {
      wp_register_script( 'jquery_js', '//code.jquery.com/jquery-3.5.1.min.js', array(), '3.5.1', false );
    } else {
      // Fallback location: edit "path/to/fallback/"
      wp_register_script( 'jquery_js', trailingslashit( get_template_directory_uri() ) . 'path/to/fallback/jquery-3.5.1.min.js', array(), '3.5.1', false );
    };
    wp_enqueue_script( 'jquery_js' );
    add_filter( 'script_loader_tag', 'data_jquery_js', 10, 3 );
    function data_jquery_js( $tag, $handle, $src ) {
      if( $handle === 'jquery_js' ) {
        $integrity = 'sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=';
        $tag = str_replace(
          array(
            "<script",
            "></script>",
          ),
          array(
            "<link rel='preload prefetch' href='" . esc_url( $src ) . "' as='script' integrity='" . $integrity . "' crossorigin='anonymous' />" . PHP_EOL . "<script",
            "integrity='" . $integrity . "' crossorigin='anonymous' async></script>",
          ),
          $tag
        );
      };
      return $tag;
    };

    // Continue with the rest of the script...

  };
}; ?>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Vue component should trigger the display of data in a Bootstrap modal based on the row of the button that was

Here is a sample code snippet demonstrating how data is fetched from the database: <table class="table table-bordered"> <thead> <tr><th>User ID</th><th>Account Number</th><th>Accou ...

Icon in the footer of Bootstrap

This is the foundation of most of my web projects that I enjoy creating. I am interested in incorporating image links instead of relying on local files. Any assistance would be greatly appreciated. <!DOCTYPE html> <html lang="en"&g ...

Using session variables in MVC with jQuery's Ajax post functionality

I am currently developing a web application using ASP.Net MVC 5 and incorporating jQuery into the project. My application functions as a single page application where I utilize the index action to set a session variable and display the view. Additionally, ...

Any ideas on how to create a fading effect for a background image while scrolling using jQuery?

I am looking to create a fading background image that changes as I scroll down my page. I remember seeing something similar with two divs that fade using opacity. It looked like this: <div class="background1"></div> <div class="background2 ...

Having trouble implementing an onClick event to change a button's CSS to href in Vue.js

When working with a SinglePageApp and using UIKit (UKit), I have found that I need to use a <button> tag instead of an <a> tag. Previously, the <a> tag was written like this: <a type="button" class="uk-button uk-button-link" href="#e ...

Expansive menu that stretches the full height of the webpage

I'm having difficulty making my side spry menu extend the full length of the webpage. I tried using this code: $("nav").css({ "height" : $("nav").height() }); but it still isn't working as expected. I just want the grey color, like ...

Bootstrap 5.5.2 facing transition issues on bundle.js

Recently, I attempted to incorporate zoom.js into my project to enable image zoom functionality similar to that of the medium website. After linking both the CSS and JS files, it seemed to be working properly. However, I encountered an issue where the tra ...

Having trouble selecting a URL tag that was dynamically created using JQuery by its class?

While working on implementing a TagCloud for my website, I encountered an issue with using JQuery to alert me about the selected link. Even though the links are being generated correctly and assigned the 'tagLink' class, when I attempt to determi ...

The CSS grid functionality seems to be malfunctioning on a specific page, yet it operates perfectly on other

I'm currently working on my Portfolio application, but I'm facing an issue on the home page where the grid layout is not functioning properly. The different div tags are overlapping each other instead of displaying correctly. https://i.sstatic.n ...

Tips for preloading icon font in Angular server-side rendering (SSR)

Is it possible to preload icons and fonts before the HTML content is rendered? I have been using a preload strategy to try and achieve this. index.html <!doctype html> <html lang="en"> <head> <meta charset="utf-8&quo ...

Is it possible to fill an array with the children of an element using

Just a quick question for the sake of simplicity... At the moment, my code looks like this: var categoryList = []; $('#share').children().each(function() { categoryList.push($(this).html()); }); I was wondering if there is a more efficient ...

Remove Specific HTML Tags Using Free Pascal

Is it possible to exclude a specific HTML tag from a string? I am looking to remove tags that start with <img>. However, all the content within <img ...> should be deleted as well. This is necessary because I need to eliminate images from the ...

Incorporating PHP Code within HTML

Could you please advise me on how to use a variable instead of a constant in this scenario? For example, I currently have this statement: <link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/abc.css')?>"/> ...

When utilizing jQuery in DOM, a JSON array may display a combination of undefined values and actual data

Although I am new to JS and jquery, I attempted to load some basic JSON data into my HTML page. In previous projects, I managed this without any issues, but in this case, multiple data fields are displaying as undefined. JSON DATA: {"employment": [ ...

Navigating the Complexities of Ajax POST and Stringify

As I delve into the world of POST with Ajax, one common trend I've noticed is the use of stringify on static arrays in many examples. In my specific case, I am constructing an array using jQuery objects extracted from <input> values. The Power ...

What is the best way to ensure that text fields remain hidden upon page load until the appropriate drop down option is chosen?

Is it possible to initially hide text fields and only reveal them when a specific drop down option is selected? The current JavaScript code somewhat achieves this, but I would like the input fields to remain hidden by default. <script language=" ...

Pagination in the jQuery datatables plugin is not functioning as expected

Help Needed I am using the datatables jQuery Plugin to display a table, but I am facing an issue where all entries are shown without any pagination. Can someone please assist me with this problem? Below is my index.cshtml code: @{ Layout = null; } & ...

Setting the width of an image within an iframe: A step-by-step guide

Is there a way to adjust the width of an image within an iframe? Typically, if an image with high resolution is placed inside an iframe, the iframe becomes scrollable by default. ...

gijgo datepicker - Selecting Only Months and Years

I am trying to customize the Gijgo datepicker so that it displays the format "January 2019" without showing the days on the calendar. https://i.sstatic.net/1jr66.png <div class="col-sm-3"> <input id="datepicker" class="form-control" name="date ...

The functionality of JQuery's `.on("click"... is sporadically functioning

I have a code block that dynamically generates elements and includes event handling. However, the event handling sometimes works and other times it doesn't. I'm not sure how to debug this issue. Can someone help me figure out what might be causin ...