How to add class to anchor using wp_nav_menu

WordPress does in fact add a current class by default: check where it says: <li id=”menu-item-1688″ class=”current-menu-item”> Within your source code. Now as for the other item, this is a bit tricky. There is two ways to do it assuming that you need the last item for styling. Option #1 is with pure CSS using … Read more

wordpress add field to post_class

I would first store your field value in a variable after your loop just before the posts HTML tags start: <?php $size = the_field( “size” ); ?> And then add this variable to the post class function: <?php post_class($size); ?>

Add a class to post if it has been recently updated

You’re right. The code you had didn’t use any logic to determine whether to add the CSS class or not. Try this: function skips_add_update_status($classes) { //Instantiates the different date objects $created = new DateTime( get_the_date(‘Y-m-d g:i:s’) ); $updated = new DateTime( get_the_modified_date(‘Y-m-d g:i:s’) ); $current = new DateTime( date(‘Y-m-d g:i:s’) ); //Creates the date_diff objects … Read more