Set WordPress Default Template

The better, cleaner solution would be not to use custom page templates to define page layouts*, but rather to use custom post meta to define page layouts. To implement: Create a Theme Option for Default static page layout, that includes all possible page layout options Create a _page_layout custom post meta for Page Layout, that … Read more

How can I insert some extra validation into the theme options’ validation function using add_filter?

You want to manipulate and return the same input you have coming into the function. In your case that is $input. That is how filters work. function add_validation( $input ) { // here I want to add some validation for a simple field named ‘example’ if ( isset( $input[‘example’] ) && !empty( $input[‘example’] ) ) … Read more

Choose To Display Post Views With An Options Panel

So this goes in your themes functions.php file. This adds a metabox on the right side of your editscreen within posts called “Enable Post Views on this Post”: // Hook into WordPress add_action( ‘admin_init’, ‘add_custom_metabox’ ); add_action( ‘save_post’, ‘wpse_16722_save_post_views_value’ ); /** * Add meta box */ function add_custom_metabox() { add_meta_box( ‘enable_post_views’, __( ‘Enable Post Views … Read more

For best DB performance should I serialize all theme options together or by type?

All options with autoload = yes (default) are fetched very early in one query. So the number of options does affect performance only marginally. Split options if you don’t need everything on every page load. With … add_option( ‘option_name’, ‘option_value’, ”, ‘no’ ); … you can set options that aren’t loaded before you actually call … Read more

Putting PHP variables into javascript [duplicate]

Use wp_localize_script: wp_enqueue_script(‘YOUR_SCRIPT_HANDLE’); $object = array( ‘zoom’ => get_option(‘map_zoom’), ‘longitude’ => get_option(‘map_longitude’), ‘latitude’ => get_option(‘map_latitude’), ); wp_localize_script(‘YOUR_SCRIPT_HANDLE’, ‘JSObject’, $object); And then use it in your JS file like JSObject.zoom and the like.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)