Setting a Default ‘Theme Location’ When Creating a Menu

You need to first collect the menu locations, then set the primary menu location with the menu id. // Set the menu to primary menu location $locations = get_theme_mod( ‘nav_menu_locations’ ); $locations[‘primary’] = $primary_nav_menu_id; set_theme_mod ( ‘nav_menu_locations’, $locations ); Here I assume ‘primary’ is theme location referring to ‘Primary Navigation’.

Passing array in add_option()

I think that you have added bguru_options option before. If bguru_options already exists, add_option() does nothing. To modify the value of existing options you should use update_option() instead. EDIT I confirm what I thought. You are running add_option(‘bguru_options’, $default_options); in every admin_init. bguru_options option was added to database in the first run and subsequent calls … Read more

one time popup after theme activation

After delving into the codex and hacking around I figured out how to do this. Short answer – use thickbox (http://codex.wordpress.org/ThickBox). Longer answer…. Hooking into after_setup_theme isn’t ideal for inserting any content into the admin page, as it runs on each page load when that theme is active. As suggested by kaiser we can use … Read more

Wrong path for theme assets

Turns out the problem was with WP_CONTENT_URL, defined inside wp-config.php: define( ‘WP_CONTENT_URL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/lab/WordPress-Skeleton/content’ ); It seems that $_SERVER[‘HTTP_HOST’] is returning an incomplete path (only localhost without the folder). Since I’m using version control and using a local-config.php to define some local dev variables (like database credentials), I also placed this on … Read more

Array Chunks and Inserting Varying HTML in WP_Query

That’s a pretty complicated approach you’re taking. Why not simply add a counter? Like this: $i=1; echo ‘<div class=”row full”>’; if( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); if ($i < 3) $class = “large-6 medium-6 small-12 columns” else “large-4 medium-4 small-12 columns”; echo ‘<div class=”‘ . $class . ‘”>’ … output your … Read more

Dequeue script in template isn’t working

Move your project_dequeue_unnecessary_scripts() function to your functions.php file and add a conditional statement to determine if the appropriate template is being loaded. E.g.: // Remove Mobile Header function project_dequeue_unnecessary_scripts() { if ( is_page_template( ‘name-of-template.php’ ) ) { wp_dequeue_script( ‘enterprise-responsive-menu’ ); wp_deregister_script( ‘enterprise-responsive-menu’ ); } } add_action( ‘wp_print_scripts’, ‘project_dequeue_unnecessary_scripts’ ); I suspect that your function is … Read more