I converted my HTML single page site to WordPress and now I have problems with the navigation. My site has 4 different sections with matching menu links.
In the original HTML version, clicking menu items would smoothly scroll to the right section. After converting to WordPress, everything displays correctly but the menu links stopped working.
Here’s my WordPress code:
<!-- Navigation area -->
<div class="col-lg-8 col-md-10 col-xs-4 navigation-menu text-right">
<ul class="primary-menu hidden-sm hidden-xs">
<?php
global $current_page;
$page_args = array('post_type'=>'page','orderby'=>'menu_order','order'=>'ASC');
$page_list = get_posts($page_args);
foreach($page_list as $current_page) : setup_postdata($current_page);?>
<li><a href="#<?php echo $current_page->post_name; ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
<a href="#" class="mobile-toggle visible-sm visible-xs"><i class="fa fa-menu"></i></a>
</div>
<!-- Content Section -->
<div class="page-section" id="<?php echo $current_page->post_name; ?>">
<div class="wrapper">
<div class="row">
<div class="section-header col-md-12 text-center">
<h2>Our Services</h2>
</div>
</div>
<div class="row">
<?php
global $current_page;
$service_args = array('post_type'=>'service','orderby'=>'menu_order','order'=>'ASC');
$service_list = get_posts($service_args);
foreach($service_list as $current_page) : setup_postdata($current_page); ?>
<div class="col-lg-3 col-sm-6">
<div class="service-box" id="service-item-1">
<div class="service-image">
<i class="fa fa-<?php echo $service_icon; ?>"></i>
</div>
<div class="service-text">
<div class="service-inner">
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
What could be causing this issue with the anchor links not working in WordPress?