Add new options to any wordpress theme in the Customize panel

Let’s say that you need a second logo image to be added in your header. And let’s assume that this should be editable feature. The easiest way to manage this task is to make a new option in the Customize panel (Appearance -> Customize) to upload a logo image and add a link to it. This tutorial will show you how you can do this.

On the back end we have tree different steps to make: we need to register a section, we need to set settings to the controls of this section, and of course we need to set the controls. All this is going to use the customize_api and will be hooked to customize_register.

First we have the $wp_customize->add_section($id, $args) more details here.

Second $wp_customize->add_setting($id, $args) for more references here.

And last $wp_customize->add_control($id, $args) check this details.

Now we have all these options in the Customize panel but how can we use them in the code. The way I get them from the database is by using get_theme_mods(). In our case we will have the following code to get the settings and assign them to some variables.


Registring widget area and how to use it later

To register a widget area for you theme you should  use the register_sidebar function in your theme’s function.php.

This function will register the widget’s area through the ‘widgets_init’ hook.

For more specification on register_sidebar please see here.

Next step is to set the place where we want to see the widgets to be displayed. Put the following code in your html code where you want to have to widget’s block to appear.

Now you can go to your admin panel Appearance – >Widgets and navigate through your new widget area.


BuddyPress forum topics don’t show up

As the last year’s Vlado was not wise enough to blog about this little problem that occurs after BuddyPress updates or server migrations, he is doing it one year later, when he comes again to such a problem.

  • all forum topics are missing;
  • creating a forum topic doesn’t show up;
  • checking topics from a specific group/user profile doesn’t show any results.

Simply you’ve got a mistake in your bb-config.php file, which should be located in the root folder of your WordPress installation. In case of server migration you should check your database credentials (db name, host, user and pass) and in case you have been a wise-ass and have changed your database tables prefix, you’ll have to update these manually in the the same file.

Next thing you’ll see are all your lovely forum topics coming back home.

Getting the BuddyPress user profile link

For an author’s profile link, use

to get the URL, and

to get an HTML link element, including display name.

For the xprofile data, use

$field can be either the name of the field (like ‘Biography’) or the numerical field id.

Getting a specific URL parameter in jQuery


Post don’t get sticky

I had this case that posts couldn’t get sticky after I check them to be sticky. Saving the changes says they are sticky, but when reloading the page, this turns out to be a big fat lie. Trying to remove “stickiness” from other posts wasn’t working either.

Probably I must mention that this is a large WordPress site on a dedicated server, without a dedicated system administrator. Having in mind I didn’t change anything in the system, it was kind of obvious that something must be wrong with the environment. Optimizing the DB with “Optimize Database after Deleting Revisions” gave the output that wp_options table has crashed and automatic repair couldn’t fix it.

Following is the list of the commands I used to login to the server and repair it:

Actually the issue could be seen in /var/log/syslog as some error messages from the automatic repair attempts. Just have this in mind.