Override Current Theme Setting in wp_config.php

Drop this in a plugin & activate. I should note this doesn’t take into account things like child themes – it’s purely for toggling which theme renders based on SOME_FLAG. add_filter( ‘stylesheet’, ‘switch_ma_theme’ ); add_filter( ‘template’, ‘switch_ma_theme’ ); function switch_ma_theme() { // Return the theme directory name return SOME_FLAG ? ‘theme-1’ : ‘theme-2’; }

Display all search results

The quick and dirty way to do it would be to use query_posts again, doubling the number of database calls. <?php if (have_posts()) : ?> <?php query_posts(‘showposts=999’); ?> Better would be to add this to functions.php, altering the original query before it is executed: function change_wp_search_size($query) { if ( $query->is_search ) // Make sure it … Read more

Reorder custom submenu item

Got it, thanks to cjbj‘s help, I was able to get the final solution: add_filter( ‘custom_menu_order’, ‘submenu_order’ ); function submenu_order( $menu_order ) { # Get submenu key location based on slug global $submenu; $settings = $submenu[‘options-general.php’]; foreach ( $settings as $key => $details ) { if ( $details[2] == ‘blogging’ ) { $index = $key; … Read more

How to find out if option exists but is empty?

Basically to distinguish between false boolean value and ” empty string you must use more strict comparison operator. var_dump( ” == false ); // this is ‘true’, treated like two ’empty()’ values var_dump( ” === false ); // this is ‘false’, because values are both ’empty()’ BUT of different type But there is more. Since … Read more

Get Content From Blog Page

You are using get_the_content() wrong, it can’t take a ID, which is what get_option(‘page_for_posts’) does return, and generally gets the content of the current post inside the loop, in which it has to be used. To get the actual content of that page you can do: $page_for_posts_id = get_option( ‘page_for_posts’ ); $page_for_posts_obj = get_post( $page_for_posts_id … Read more

How much string content can I store in an option?

Look at the table schema in wp-admin/includes/schema.php: // regular blog tables CREATE TABLE $wpdb->options ( option_id bigint(20) unsigned NOT NULL auto_increment, option_name varchar(64) NOT NULL default ”, option_value longtext NOT NULL, autoload varchar(20) NOT NULL default ‘yes’, PRIMARY KEY (option_id), UNIQUE KEY option_name (option_name) ) $charset_collate; // Multisite options CREATE TABLE $wpdb->sitemeta ( meta_id bigint(20) … Read more