Author: ShairyPortfolio

  • WordPress Even odd Post Logic

    WordPress Even odd Post Logic

    <?php while (have_posts()): the_post() ?> <?php if ($wp_query->current_post % 2 == 0): ?> even <?php else: ?> odd <?php endif ?><?php endwhile ?>

  • Dropdown Menu Parent link Clickable

    Dropdown Menu Parent link Clickable

    Change the CSS dropdown:hover .dropdown-menu {  display: block;} Add Jquery Code $(‘.dropdown-toggle’).click(function() {    var location = $(this).attr(‘href’);    window.location.href = location;    return false;}); Change in the nav walker class //$atts[‘href’] = ‘#’;                $atts[‘href’] = ! empty( $item->url ) ? $item->url : ”;             // $atts[‘data-bs-toggle’] = ‘dropdown’;               $atts[‘data-bs-hover’] = ‘dropdown’;

  • Navbar Fixed JS Code Logic
  • innerHTML vs createElement in DOM

    innerHTML vs createElement in DOM

    Following Example explain the differences between innerHTML and createElement when it comes to creating new elements. Example of create Element <body>    <div class=”container”></div> <script> let div = document.querySelector(‘.container’); let p = document.createElement(‘p’); p.textContent = ‘JS DOM’; div.appendChild(p);     </script> </body> Example of Inner HTML <body>    <div class=”container”></div> <script> let div = document.querySelector(‘.container’); div.innerHTML…