How to conditionally add a wp_filter

Edit — fixed the if() statement. function add_nav_class( $output ) { $menu_obj = get_term_by( ‘slug’, ‘footer_menu’, ‘nav_menu’ ); // $menu_obj = get_term_by( ‘name’, ‘Footer Menu’, ‘nav_menu’ ); // if the ‘slug’ version doesn’t work, try the ‘name’ version // Just make sure you’re using the correct name if( ‘footer_menu’ == $menu_obj->name ) ) { return … Read more

How to make sure relative URL works when site is not on root domain?

Make use of the functions wordpress offers to determine paths and URLs – see Determining Plugin and Content Directories. For example use: get_template_directory to Retrieves the absolute path to the directory of the current theme, without the trailing slash. or get_stylesheet_directory to Retrieve stylesheet directory Path for the current theme/child theme. You find more information … Read more

How to Grab first Image from some Chosen Categories

Your solution seems overly complicated to me. WP_Query can do nearly all of the work, you just need to construct a meta_query to look for thumbnails. The code is slightly truncated but here is the idea: $categories = array(1,2,3); // your specific category IDs $first_thumb = new WP_Query( array( ‘posts_per_page’ => count($categories), ‘category__in’ => $categories, … Read more

Seeting Active Nav for Bootstrap in WordPress

Looks like its just your PHP formatting, you have the right idea! try this: <pre class=”prettyprint”><code class=”language-php”> <?php if (is_page( ‘Home’ ) { $class=”active”; } elseif (is_page( ‘About’ ) { $class=”active”; } else { $class=””; } ?> <li class=”<?php echo $class; ?>”Home</li> <li class=”<?php echo $class; ?>”About</li> </code></pre>

Need advice on theme customizer and child themes

I would comment if able. If your theme variations consist solely of style modifications you can add the variation stylesheets @ inc/css/ and then here is an example of the references to make it all tick. @ \options\options-core.php: $fields_list[] = array( ‘name’ => __(‘Select a Skin Color’, ‘mytheme’), ‘id’ => ‘mytheme_skin_color’, ‘std’ => ‘default’, ‘type’ … Read more

How can I assign separate stylesheets to different pages?

The correct method is to enqueue the stylesheets, via callback hooked into wp_enqueue_scripts. You can add the contextual conditionals inside the callback: function wpse124258_enqueue_scripts() { if ( ! is_admin() ) { // Conditionally enqueue if ( is_front_page() ) { // Front page stylesheet wp_enqueue_style( ‘front-page-style’, get_template_directory_uri() . ‘/front-page-stylesheet.css’ ); } else if ( is_page() ) … Read more

tag__in does not return posts

Re: my comment, I am assuming ‘item_tags’ are a custom taxonomy. tag__in only works for WP Core’s Tag taxonomy. Replace your tag__in line with the following: ‘tax_query’ => array( array( ‘taxonomy’ => ‘item_tags’, ‘field’ => ‘id’, ‘terms’ => $tag_ids ) )

All pages are the same

Problem solved. Here is what I did: I Thought: the only custom post type that is showed correctly on back-end is the cpt “Informazione”. So maybe the problem is here I’ve disabled this custom post type and effectively everything come back to work as aspected Searching on the web I found that other users had … Read more

Using Foundation 5 off-canvas-menu with WordPress

Reading the example on Zurb’s docs, I get the impression that you would take this code and break it up into smaller templates like how the _s theme does it. Starting in your header.php <div class=”off-canvas-wrap”> <div class=”inner-wrap”> Then using get_template_part() for example a template named tab-bar could be: <nav class=”tab-bar”> <section class=”left-small”> <a class=”left-off-canvas-toggle … Read more