Desktop version is providing the correct url for example: http://test.local/test/category/featured/ but the mobile version is not providing the correct url: http://test.local/test/featured/ it’s dropping the /category/
Here is my desktop version of code:
<div class="category-filter full">
<span class="filter-text"><i class="far fa-filter"></i> <?php esc_html_e( 'Filter by:', 'test-wp' ); ?></span>
<ul class="category-list">
<?php
// only display "Featured" if a Featured post is present in the blog
$query = new WP_Query(array(
'post_type' => 'post',
'field' => 'slug',
'category_name' => 'featured',
'ignore_sticky_posts' => 1,
));
if( $query->have_posts() ){
echo '<li><a href="'. get_site_url() .'/category/featured/">Featured</a></li>';
}
wp_reset_postdata(); // Restore original Post Data
?>
<?php
foreach ( $terms as $term ) {
printf( '<li><a href="%1$s">%2$s</a></li>',
esc_url( get_category_link( $term->term_id ) ),
esc_html( $term->name )
);
}
?>
</ul>
</div>
And here is my mobile version of code:
<div class="category-filter mobile">
<select id="custom-select" onchange="location = this.value;" style="outline:none;border:1px solid #777;font-size:20px;height:30px;color:#777;">
<?php
foreach ( $terms as $term ) {
printf( '<option><a href="%1$s">%2$s</a></option>',
esc_url( get_category_link( $term->term_id ) ),
esc_html( $term->name )
);
}
?>
</select>
</div>