Learn Tutorials Point - LTP > WordPress > How to create bootstrap header ACF field with active class menu in wordpress
How to create bootstrap header ACF field with active class menu in wordpress
To create a Bootstrap header with an active class menu using Advanced Custom Fields (ACF) in WordPress, you’ll need to follow several steps. This involves creating custom fields for your menu items, retrieving the values in your WordPress theme, and adding the active class to the current menu item.
$post->ID This is page ID.
<?php if( have_rows('treatments_menu', 'option') ): ?> <?php while( have_rows('treatments_menu', 'option') ) : the_row(); ?> <li class="nav-item"> <?php $link = get_sub_field('menu_link'); if( $link ): $link_url = $link['url']; $link_title = $link['title']; $link_target = $link['target'] ? $link['target'] : '_self'; ?> <a <?php if( $post->ID == 258) { echo 'class="nav-link active"'; } else { echo 'class="nav-link"'; } ?> href="<?php echo esc_url( $link_url ); ?>" target="<?php echo esc_attr( $link_target ); ?>"><?php echo esc_html( $link_title ); ?></a> <?php endif; ?> </li> <?php endwhile; ?> <?php endif; ?>
Author: Learn Tutorials Point
We Well organized and easy-to-understand Interactive tutorials With lots of examples of how to use Tutorials WordPress, PHP, Bootstrap, Bootstrap 4, HTML, CSS, AJAX, jQuery, Woocommerce, Post, Database, Javascript, Theme, Responsive, Templates.
Trending Posts
Tags
ACF
Ading custom columns
admin
Bootstrap
Cart Price
categories
Change Price
class
Code
comments
Create
Creating custom post Type
CSS
current
custom
Customizing
Custom Post
Custom Post Type
Custom Taxonomy
database
Date
Fatch
form
function
HTML
Image
Install
javascript
jQuery
Menu
PHP
Post
Post Type
Price
product
responsive
Resular price
Single product
Table
taxonomy
Theme
Title
woocommerce
Wordpress
Wordpress Code
Hello to all, the contents present at this site are in fact amazing for people
knowledge, well, keep up the nice work fellows.
I am regular visitor, how are you everybody? This paragraph posted at this website is
actually pleasant.
Your style is so unique in comparison to other folks I have read stuff from.
Many thanks for posting when you’ve got the opportunity,
Guess I will just bookmark this web site.