wp_nav_menu: check if the list item has children and add a class to anchor link

I was able to add a “parent” CSS class to the anchor tag of menu items who have children by following this answer: Add ‘has_children’ class to parent li when modifying Walker_Nav_Menu Here’s an example: class Main_Nav extends Walker_Nav_Menu { /** * @see Walker::start_el() * @since 3.0.0 * * @param string $output Passed by reference. … Read more

How to use the_posts_navigation for wp_query and get_posts?

the_posts_navigation() is simply a wrapper function for get_the_posts_navigation() which issimply a wrapper function for paginate_links. The first two functions uses the the same exact parameters that is being used by paginate_links and actually passes it to the latter function as well get_the_posts_navigation() and the_posts_navigation() is good new functions as it eliminates a lot of custom … Read more

How to modify navigation menu of the “My Account” page in WooCommerce

For that, you do not need to modify the woocommerce/templates/myaccount/navigation.php. The best way to customize the “My Account” navigation menu items is to use: woocommerce_account_menu_items filter hook to add new items to the menu. array_slice() to reorder them the way you want. This way, by using woocommerce_account_menu_items filter hook, you integrate perfectly your own items … Read more

How to add CSS Class to previous_post_link or get previous/next post link URL

You can use the more native function that is “below” the previous_/next_post_link();: # get_adjacent_post( $in_same_cat = false, $excluded_categories=””, $previous = true ) $next_post_obj = get_adjacent_post( ‘”https://wordpress.stackexchange.com/questions/17218/,”‘, false ); $next_post_ID = isset( $next_post_obj->ID ) ? $next_post_obj->ID : ”; $next_post_link = get_permalink( $next_post_ID ); $next_post_title=”&raquo;”; // equals “»” ?> <a href=”https://wordpress.stackexchange.com/questions/17218/<?php echo $next_post_link; ?>” rel=”next” class=”pagination pagination-link … Read more