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

How to get custom image size for image uploaded in Customizer

Apparently, your mod is storing the complete path to the image as a string. That leaves you little alternative but to do a search and replace on the string: $img = get_theme_mod(‘image-1’); if (!empty ($img)) { $img = preg_replace (‘.(jpg|jpeg|png|gif)$’,’-525×350$0′); if (!file_exists($img)) $img = get_template_directory_uri().’/images/default.jpg’; } else if (!file_exists($img)) $img = get_template_directory_uri().’/images/default.jpg’; In words. Get …

Read more

Change display of featured image for pages in twenty seventeen theme

You are struggling with wrong files. You can find post files in theme-folder/template-parts/post/content.php file. You’ll find this code you can add your classes or whatever in your child theme. <article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> <?php if ( is_sticky() && is_home() ) : echo twentyseventeen_get_svg( array( ‘icon’ => ‘thumb-tack’ ) ); endif; ?> <header …

Read more