22 votes

get_option() vs get_theme_mod(): Why is one slower?

The answer that yes, the theme_mod functions will be slower, but not significantly, and the benefits outweigh the differences. Theme mods are stored as options. So, in essence, the theme_mod ...
user avatar
  • 32.1k
9 votes
Accepted

What WP folder can I use to write files to?

Best place is the uploads directory - it'll be writable by the server, and it's the defacto directory for storing any user-generated/uploaded files: $dirs = wp_upload_dir(); $path = $dirs['basedir']; ...
user avatar
  • 35.7k
9 votes
Accepted

How to remove menus section from WordPress theme customizer

Try nav_menus instead of menus with remove_panel() function mytheme_customize_register( $wp_customize ) { //All our sections, settings, and controls will be added here $wp_customize->...
user avatar
8 votes

Adding a description to theme customizer controls

For anyone who comes across this after WordPress 4.0 is released, custom controls are no longer necessary. This functionality is baked right into WordPress: https://core.trac.wordpress.org/ticket/...
user avatar
8 votes

How to export/import theme customizer settings?

For anyone still interested in customizer export/import functionality, we just released a new plugin on the wordpress.org repo that does exactly that! https://wordpress.org/plugins/customizer-export-...
user avatar
8 votes
Accepted

What is the meaning of WordPress's recommended css classes and where are they applied?

These classes are generated by WordPress. For instance, if a user inserts an image in his post and says it must be aligned right, WP will generate code like this in the post: <img class="...
user avatar
  • 13.8k
6 votes

How to remove menus section from WordPress theme customizer

The correct way to disable nav menus in the customizer is via the customize_loaded_components filter as documented on its hook reference page: /** * Removes the core 'Menus' panel from the ...
user avatar
  • 3,930
6 votes
Accepted

Add a dropdown to theme customizer

Add Section to Theme Customizer: $wp_customize->add_section( 'parsmizban_options', array( 'title' => __( 'Theme Options', 'parsmizban' ), //Visible title of section 'priority' ...
user avatar
5 votes
Accepted

Add a page outside of the current theme?

Edit: Updated with the added context from your comment. You could do this with a custom Page template. In your theme, create a new file. In this example, my theme will be "mytheme2015," my new file ...
user avatar
  • 2,939
5 votes

Does uninstalling a Wordpress theme delete its database values?

It depends on the theme itself. A theme may store some data in the database. For example, a theme may have an option called "Social Accounts" section in settings page and a field "Facebook Page URL" ...
user avatar
  • 1,197
4 votes
Accepted

Using update_option() and get_option() is echoing escaped strings

You can use PHP's stripslashes() command: <?php echo stripslashes( get_option( 'myOption' ) );
user avatar
4 votes
Accepted

Option Tree integration of Custom CSS

never* execute code outside of hooks as you are more likely to call a function or use a variable before they were declared and initialized. your code should be function css() { if (...
user avatar
  • 22.8k
4 votes

What WP folder can I use to write files to?

The only directory with guaranteed write access is the upload directory. Everything else might be protected. Nowadays, we deploy sites with Composer, keep everything under version control and create ...
user avatar
  • 105k
3 votes

get_option() vs get_theme_mod(): Why is one slower?

get_theme_mod is just a wrapper around get_option. In theory because it is another layer of abstraction it will work slower but in practice the difference should not be big enough to be noticed by a ...
user avatar
  • 22.8k
3 votes
Accepted

How to reset (clear) theme settings

I've found the solution, maybe it'll be useful to anyone: function reset_mytheme_options() { remove_theme_mods(); } add_action( 'after_switch_theme', 'reset_mytheme_options' );
user avatar
  • 49
3 votes

Adding a description to theme customizer controls

The description argument adds a description under the control. If you want to add something above the control title, like an extra header or something, you can use the customize_render_control_{id} ...
user avatar
  • 1,218
3 votes
Accepted

Theme options WP Editor

In theme options, I had to define wp_editor_settings. So, just in options.php, I used: //WP_editor settigs $wp_editor_settings = array( 'wpautop' => true, // Default '...
user avatar
  • 85
3 votes

Cannot find the code for "Edit This" link in posts in a specific theme

I dont know thoses theme, but in wordpress normaly you use: edit_post_link() edit_comment_link() edit_tag_link() edit_bookmark_link() in your templates, inside your loops maybe some themes use ...
user avatar
3 votes
Accepted

Change WordPress header color using customizer

You have to inline the css into your theme. CSS is read-only and can't updated to use the update hex colors for your header. <?php echo get_theme_mod( 'header_textcolor' );?> 100%);"> So ...
user avatar
2 votes
Accepted

Which settings/options are saved on a theme-basis and how does this affect theme-switching?

After doing some research this answer became a bit longer than expected, but this is the essence: TL;DR: Menu placement and Widget placement/order is saved on a Theme basis and can therefore be ...
user avatar
  • 5,480
2 votes
Accepted

How to make javascript work on theme options page

The problem with your code is, as we found out in the comments on the question, that you're using $, which is either undefined or has a conflict (in any case, it's not pointing to jQuery). Using ...
user avatar
  • 3,286
2 votes
Accepted

What's the proper way to include inlined javascript-source?

To print JavaScript code to your page, you have several paths to choose from. The most obvious would be the wp_footer action. Just hook a function to it and make it print your JavaScript/jQuery code, ...
user avatar
  • 9,046
2 votes
Accepted

How to create dependent field in Customizer?

You can get and check the value of your theme mod as you normally do anywhere. This code is tested and working (the code inside cyb_customizer() is exactly the code you posted in the question, only ...
user avatar
  • 19.8k
2 votes
Accepted

Category select options for plugin settings

I think this is what you are looking for . $cats = get_terms('category'); $blog_cats = array("all" => "All"); foreach ($cats as $cat) { $blog_cats[$cat->name] = $cat->name;} Then to show ...
user avatar
  • 591
2 votes

max_input_vars: how many am I using?

max_input_vars is the limit on the total number of GET, POST, and COOKIE vars. To determine how many there are you can just count them. Here's a quick example in a WordPress context: function ...
user avatar
  • 76.3k
2 votes

after_setup_theme, Global Variable and Theme Customizer

If you look at WordPress Codex :: Actions Run During a Typical Request, you will notice that the action hook after_setup_theme is fired significantly earlier on than that of the action hook wp. What ...
user avatar
2 votes
Accepted

after_setup_theme, Global Variable and Theme Customizer

The issue is that WP customizer submits the changes, but has not processed these yet at that point in time. If you cant wait for WP customizer to do it's thing by using a later action, here is a ...
user avatar
2 votes

Theme options WP Editor

I think you mean the font color inside the TinyMCE editor. The wp_editor() function have the settings parameter, there you reference to an var like ``. This parameter need a array and this array can ...
user avatar
  • 16.7k
2 votes

Disable Theme API / Front end (for API only environment)

There is the constant WP_USE_THEMES which when set to false in wp-config.php disables the theme system on the backend, though it does not completely disable the theme subsystem. I think that is a ...
user avatar
  • 63.7k
2 votes
Accepted

Cannot find the code for "Edit This" link in posts in a specific theme

This should be located in the entry-meta.php file of the parent theme (kuorinka). Here is the code: <?php if ( 'post' == get_post_type() ) : ?> <div class="entry-meta"> <!--...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible