get_posts is duplicating

First you need to save the IDs of the posts from first loop you want to exclude in second loop into an array, and the use that array to exclude the posts. Also, always reset post data after query. Here’s your code with the modification. <div class=”row”> <?php $args = array( ‘posts_per_page’ => 1, ‘offset’ … Read more

Create a variable with string, array or multiple values

the last $file takes priority over the previous That’s because you assign the new value to the $file variable at every line. The only way I see you can do it by using the array: <?php // define directory list $directories = array( ‘home’, ‘pages’, ‘blog’, ‘single-posts’, ‘products’, ‘templates’, ‘products’ ); // run through directories … Read more

Custom Theme Building & Permalinks

The Action Reference may give you some insight into what’s going on when you visit a front-end page in WordPress and help you to understand things a bit better. Actions are events that occur in the process of loading a page, they let you “hook” into the process to run your own code at specific … Read more

How to add custom nav_menu_css_class to certain menu only?

You just need the third argument $args, of which one of it’s properties is theme_location: function wpse_218377_nav_menu_css_class( $classes, $item, $args ) { if ( ! empty( $args->theme_location ) && $args->theme_location === ‘custom-menu’ ) { $classes[] = ‘footer–menu-item’; } // ALWAYS return, not from inside the if return $classes; } add_filter( ‘nav_menu_css_class’ , ‘wpse_218377_nav_menu_css_class’ , 10, … Read more