24

Didn't work for me, but I found a nice fix. In your header.php use the wordpress function to query if the toolbar is displayed, and then create an empty div below the navbar div: <div class="navbar navbar-inverse navbar-fixed-top"> <?php // Fix menu overlap if ( is_admin_bar_showing() ) echo '<div style="min-height: 32px;"></div>'; ...


17

How to prevent the WordPress admin bar from overlapping with your Twitter Bootstrap navigation bar. In response to: WordPress admin bar overlapping twitter bootstrap navigation Asked by: @TheWebs If you are using Twitter Bootstrap with WordPress and have an issue with the WordPress admin bar overlapping with your navigation bar, you're probably pretty ...


10

To add that last list item, you don't need a custom Walker. There is a hook that will allow you to tack that on. function add_last_nav_item($items) { return $items .= '<li><a href="#myModal" role="button" data-toggle="modal">Contact</a></li>'; } add_filter('wp_nav_menu_items','add_last_nav_item'); It wouldn't be start_el and ...


10

I just ran into this issue as well, the cause of this is that at 600 pixels wide the admin bar goes from being position:fixed to position:absolute; When fixed, it is locked to the top of the screen (top:0) When absolute it is locked to the top of the closest container that contains it. This is the html element by default, but if a parent is defined to have ...


9

The best way to include bootstrap in your theme is to enqueue bootstrap CSS and JS in your functions.php file. This is how you can enqueue bootstrap CSS and JS from CDN hosted version. function my_scripts_enqueue() { wp_register_script( 'bootstrap-js', '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js', array('jquery'), NULL, true ); ...


8

PHP way: Add the following to your functions.php file. Filter nav_menu_link_attributes: add_filter( 'nav_menu_link_attributes', 'my_menu_atts', 10, 3 ); function my_menu_atts( $atts, $item, $args ) { // Provide the id of the targeted menu item $menu_target = 123; // inspect $item if ($item->ID == $menu_target) { // original post used a ...


8

You can add bootstrap in WordPress by following function in functions.php You can change url as you need if you have cdn. <?php /** * Enqueue scripts and styles */ function your_theme_enqueue_scripts() { // all styles wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/css/bootstrap.css', array(), 20141119 ); ...


7

I know this question is quite old but since there is no answer yet an there are many similar questions on the WordPress support forums, I'll better share my findings and maybe help someone. The issue of disappearing menu may be caused by code in plugin or theme incorrectly modifying global $wp_query object using pre_get_posts filter hook. I discovered that ...


6

After taking a deeper look in to this, I realised that the responses that are displayed are produced via the Contact Form 7 AJAX. So, following the Contact Form 7 documentation on DOM Events, I was able to get this working how I wanted with the following JS code: /* Validation Events for changing response CSS classes */ document.addEventListener( '...


5

You will need to write a custom walker extending Walker_Nav_Menu, more or less like so: class My_Custom_Nav_Walker extends Walker_Nav_Menu { function start_lvl(&$output, $depth = 0, $args = array()) { $output .= "\n<ul class=\"dropdown-menu\">\n"; } function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { ...


5

Here you go.. function xobamax_resources() { wp_enqueue_style('bootstrap', get_template_directory_uri() . 'css/bootstrap.min.css'); wp_enqueue_style('style', get_stylesheet_uri()); wp_enqueue_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js', array('jquery'), '3.3.4', true ); } add_action('...


5

Your theme should not depends on any external link library. There is no guarantee when that library can be taken down. That's the reason all of your theme assets should be package with theme, to prevent the future risk.


5

Mostly the parent theme might be enqueing the child theme's style.css, if so you can dequeue it by using handle and then enqueue with proper dependency. If the child theme's handle is child-theme-style, then dequeue it using wp_dequeue_style('child-theme-style') then enqueue it as needed like so. wp_enqueue_style('child-theme-dep',get_stylesheet_uri(),...


4

For a copy paste solution check this custom Walker out: http://goodandorgreat.wordpress.com/2012/01/12/update-2-using-twitter-bootstrap-dropdown-menus-with-wordpress/ It's missing one or two things like data-toggle="dropdown" and <b class="caret"></b>. It should be quite easy to figure that out, but here's my modified version: https://gist....


4

Almost. Put the bootstrap stuff in your theme, and include it on the front end using wp_enqueue_style and wp_enqueue_script in functions.php e.g. for the bootstrap js: function my_scripts_method() { wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery') ); } add_action('...


4

You can do it in two ways.... Solution One: <?php add_action( 'wp_head', 'myscript' ); function myscript(){ echo '<!--[if lt IE 9]><script src="your_js_file_path"></script><![endif]-->'; }; ?> Solution Two: <?php global $wp_scripts; wp_register_script( 'jsFileIdentifier', 'YourJsFilePath', array(), '3.6.2' ); $...


3

The above looks correct, however, you need to specify your script to enqueue after bootstrap by adding the bootstrap-min handle to the third, dependencies parameter. function register_css() { wp_register_style( 'bootstrap-min', get_template_directory_uri() . '/css/bootstrap.min.css' ); wp_register_style( 'custom-css', get_template_directory_uri() . '...


3

As mentioned on the wp_register_script() codex page the handle: Should be unique as it is used as a handle for later use with wp_enqueue_script(). You are using the same handle for all your scripts, which won't work. Besides that, if those scripts are depending on bootstrap, you have to at least register bootstrap before and add it as dependency to ...


3

There was a trac ticket requesting improvements to the function since it was inflexible, yet required for themes hosted in official repository. It had been resolved, adding much needed wp_link_pages and wp_link_pages_link filters, so now output can be cleanly modified without need to use custom function. I went through quite a few takes on this over years ...


3

you can try this: .navbar-fixed-top { top: 0px; } body.admin-bar .navbar-fixed-top { top: 28px !important; } if that does work for you (which it should!), then you'll have to move the wp admin bar to the bottom by sticking the code below into a plugins folder or your functions.php file: function fb_move_admin_bar() { echo ' <style type=...


3

Your options are the following: Extend the walker and change the output (override start_el function) Here is an example of the Walker, assuming you are using this bootstrap walker. Usage: 'walker' => new se150102_bootstrap_walker() Walker: class se150102_bootstrap_walker extends wp_bootstrap_navwalker { /** * This walker is identical to the ...


3

You can make use of featured images as suggested by @gmazzap in comments. This featured image will not be included in post content. However, if you already have your images included in post content, then you need to strip the post content down in two parts, as you've said in your question. I have two functions, one that returns all the images (or any html ...


3

Ideally, using WP methods to enqueue bootstrap JS dependencies you can just set jQuery as a requirement and WordPress will take care of the rest. <?php wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/bootstrap/js/bootstrap.js', array( 'jquery' ) ); ?>


3

Good news. This is an easy fix. WordPress allows you to declare dependencies when registering scripts and stylesheets. Simply list the assets you wish to load earlier as dependencies for the later assets. https://codex.wordpress.org/Function_Reference/wp_register_style This works for both scripts and styles and is the recommended way to control load ...


3

You could add a filter on post_type_link, which allows modification of custom post type permalinks before they are output. The filter passes the custom post object as the 2nd argument, so we can use that to get the ID and form the new permalink: function wpd_list_pages_permalink_filter( $permalink, $page ){ return '#' . $page->ID; } Then you can ...


3

Adding the dependency should work. You are not calling your theme styles file correctly though. You need to move your theme-style.css file down to the root folder of the theme itself and name it style.css. So your function should look as follows: function my_enqueues() { wp_enqueue_style( 'bootstrap-css', '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/...


3

The proper way to add a style, as in a template or in a theme, is to use the wp_enqueue_style function. See https://developer.wordpress.org/reference/functions/wp_enqueue_style/ . One of the parameters in the function is a version number, which you can change if you make changes to the CSS in the file. That will force WP into loading the new version, and ...


3

You can use action hook and enqueue script and style to the site. function my_scripts() { wp_enqueue_style('bootstrap4', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css'); wp_enqueue_script( 'boot1','https://code.jquery.com/jquery-3.3.1.slim.min.js', array( 'jquery' ),'',true ); wp_enqueue_script( 'boot2','https://cdnjs....


3

The following answer is a solution for Bootstrap 4 and centering images in a <figure> tag. WordPress generated default: <figure class="wp-block-image"> <img src="http://localhost:8888/time.png" alt="alt text" class="wp-image-1391"/> <figcaption>This is an image test.</figcaption> </figure> Using the preg_replace(...


2

use do_shortcode($content) instead of $content in first function(collapsegroup)


Only top voted, non community-wiki answers of a minimum length are eligible