Theme Options: If There is No Input, Don’t Display?

Check if get_option returns a value and if it is not blank, then output the links. This should work for you: <?php if(get_option(‘to_facebook’) && get_option(‘to_facebook’) != ”) { ?> <a href=”https://wordpress.stackexchange.com/questions/34948/<?php echo get_option(“to_facebook’); ?>”></a> <?php } if(get_option(‘to_google_plus’) && get_option(‘to_google_plus’) != ”) { ?> <a href=”https://wordpress.stackexchange.com/questions/34948/<?php echo get_option(“to_google_plus’); ?>”></a> <?php } ?>

Create placeholder text for wordpress search box [closed]

Placeholder by itself will not disappear when you click the text field. I guess you need a bit of Javascript to achieve that. <input type=”text” onfocus=”if(this.value=='<?php _e( ‘Search here..’ ); ?>’){this.value=””;}” onblur=”if(this.value==”){this.value=”<?php _e( “Search here..’ ); ?>’;}” value=”<?php _e( ‘Search here..’ ); ?>”>

How do I test PHP files in WordPress?

The WordPress Codex documentation on Installing WordPress and Editing Files give you pretty much all information you need. You will need a web server to test the code and changes. So you can either do this on your web server (assuming you have some sort of hosting package, because you mention ‘upload’), or on your … Read more

How to display posts of specific category using a custom Query in WordPress?

the recommended way is: <?php $query = new WP_Query(‘category_name=Category&posts_per_page=4’); if($query->have_posts()) : while($query->have_posts()) : $query->the_post(); if (has_post_thumbnail()) { ?> <a href=”https://wordpress.stackexchange.com/questions/162985/<?php the_permalink(” ‘) ?>” title=”<?php the_title(); ?>”><?php the_post_thumbnail(); ?></a> <?php } ?> <h2><a href=”https://wordpress.stackexchange.com/questions/162985/<?php the_permalink(” ‘) ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a></h2> <?php the_excerpt(); // or the_content(); for full post content endwhile;endif; ?>

1+1 php counter inside the update_post_meta

If you’re trying to update the number stored in the meta table, you need to load that value and increment it. $count = get_post_meta( $bid_id, ‘draftnumber’, true ); if ( ! $count ) { $count = 0; // if the meta value isn’t set, use 0 as a default // We’ll be incrementing this right … Read more

how to get the value of time left for a transient

The problem here is that if the site is actually using something like Redis, or any other supported “external cache” then nothing is going to actually be set in the options table (which can be checked with wp_using_ext_object_cache) Storage in the options table is just how WordPress handles transients outside of any external caching (or … Read more

register_activation_hook isn’t adding table to DB

Note that the $file in register_activation_hook( $file, $callback ), should be equal to path to the main plugin file, but when you have it in a sub file as __FILE__ then it’s not the same! That means your callback is never called. I would also recommend prefixing the function’s name to avoid possible name collision … Read more