WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have many custom templates for different post types, and I am manually inserting a social share bar inside the 'entry-meta' footer in each of those templates. I need a simple centralized way to disable the social share bar without hacking into the plugin.

Basically I have this setup so far:

In functions.php:

update_option( 'show_social_bar', 'true' );

In my templates I have this check:

if( get_option( 'show_social_bar' ) === 'true' ) {
  // show my social share links 

If I need to turn the bar off, I just set the option to 'false' in functions.php. This somehow seems inefficient. Is there a more sensible way?

share|improve this question
Are you looking to do this on a per-post basis? – 5t3ph Feb 2 '12 at 17:37
@5t3ph: more on a per-template basis. – montrealist Feb 2 '12 at 18:09
up vote 0 down vote accepted

It's a bad practice to update an option on every page load. You should use a constant instead.

define('SHOW_SOCIAL_BAR', true); //functions.php

    //Do Something
share|improve this answer
Perfect! Thank you. – montrealist Feb 2 '12 at 18:08

I think I would make it a checkbox on a settings page, that way you're not setting something every load (because MySQL writes are slow) and you have a user-friendly way to make the change.

share|improve this answer
Never done it before but would be willing to try. Any nice tutorials come to mind? – montrealist Feb 3 '12 at 15:37
This one is pretty solid. – mor7ifer Feb 4 '12 at 3:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.