Using Custom-meta boxes(CMB) to create an Admin Theme Options Page

I've created a Theme Options page using CMB, but the values don't seem to save. I've included the php class in my functions.php, and the theme options page loads fine, with all custom meta boxes exactly the way I want it. But the fields reappear empty after adding some value and clicking save. What am I missing here? Code:               <?php     /**      * CMB Theme Options      * @version 0.1.0      */     class myprefix_Admin{              /**          * Option key, and option page slug          * @var string          */         protected static $key = 'myprefix_options';              /**          * Array of metaboxes/fields          * @var array          */         protected static $theme_options = array();              /**          * Options Page title          * @var string          */         protected $title = '';              /**          * Constructor          * @since 0.1.0          */         public function __construct() {             // Set our title             $this->title = __( 'Madame Noire Options', 'myprefix' );         }              /**          * Initiate our hooks          * @since 0.1.0          */         public function hooks() {             add_action( 'admin_init', array( $this, 'mninit' ) );             add_action( 'admin_menu', array( $this, 'add_page' ) );         }              /**          * Register our setting to WP          * @since  0.1.0          */         public function mninit() {             register_setting( self::$key, self::$key );         }              /**          * Add menu options page          * @since 0.1.0          */         public function add_page() {             $this->options_page = add_menu_page( $this->title, $this->title, 'manage_options', self::$key, array( $this, 'admin_page_display' ) );             add_action( 'admin_head-' . $this->options_page, array( $this, 'admin_head' ) );         }              /**          * CSS, etc          * @since  0.1.0          */         public function admin_head() {             // CSS, etc         }              /**          * Admin page markup. Mostly handled by CMB          * @since  0.1.0          */         public function admin_page_display() {             ?>

<?php echo esc_html( get_admin_page_title() ); ?>
                 <?php cmb_metabox_form( $this->option_fields(), self::$key ); ?>
             <?php         }              /**          * Defines the theme option metabox and field configuration          * @since  0.1.0          * @return array          */         public static function option_fields() {                  // Only need to initiate the array once per page-load             if ( ! empty( self::$theme_options ) )                 return self::$theme_options;                  self::$theme_options = array(                 'id'         => 'theme_options',                 'show_on'    => array( 'key' => 'options-page', 'value' => array( self::$key, ), ),                 'show_names' => true,                 'fields'     => array(                     array(                         'name' => __( 'Test Text', 'cmb' ),                         'desc' => __( 'field description (optional)', 'cmb' ),                         'id'   => $prefix . 'test_text',                         'type' => 'text',                     ),                     array(                         'name'    => __( 'Test Color Picker', 'cmb' ),                         'desc'    => __( 'field description (optional)', 'cmb' ),                         'id'      => $prefix . 'test_colorpicker',                         'type'    => 'colorpicker',                         'default' => '#ffffff'                     ),                 )             );             return self::$theme_options;         }              /**          * Make public the protected $key variable.          * @since  0.1.0          * @return string  Option key          */         public static function key() {             return self::$key;         }          }     // Get it started     $myprefix_Admin = new myprefix_Admin();     $myprefix_Admin->hooks();          /**      * Wrapper function around cmb_get_option      * @since  0.1.0      * @param  string  $key Options array key      * @return mixed        Option value      */     function myprefix_get_option( $key = '' ) {         return cmb_get_option( myprefix_Admin::key(), $key );     }


Save Plugin Version Number as Option?

I seem to recall seeing a tip somewhere saying that it was a best practice to save a plugin's version number as an option. I'm working through releasing a plugin, and I'm considering whether to do it, but since all the plugin does is make a widget (right now, it literally has no other options), I'm struggling to understand what I would ever do with that option. I'm already setting a constant with the version number for use in a couple places (mostly `wp_enqueue_*`). Can someone either point me to a good resource or explain the use cases for saving the version number as an option?


WordPress Category Question

I cannot figure out how to use the wp_list_categories function to do what I need it to:               <?php if(is_page('realisations')) { ?>

Les secteurs
         <?php wp_list_categories('child_of=3&title_li='); ?>
     <?php }; if(is_category() or is_single()) { ?>

Les secteurs
         <?php wp_list_categories('child_of=3&title_li='); ?>
     <?php }; ?>      I hope this doesn't come off as too convoluted. It does what I need it to do, despite not being very elegant. I have it set up so that all of the project categories are child categories of the a main category (`child_of=3`) This is to avoid conflicts with the news section of the site. The problem is that I need the category the post is in to highlight when viewing the single.php page template, but I don't know how to accomplish that. When on a category page the category view highlights correctly because I styled the class that WordPress adds into the generated list `.current-cat`. This is a crosspost from the normal StackExchange site, it was suggested that I submit the problem here.


Firing page_publish where page is child page

I'm having difficulty getting a function to fire when publishing a new page. I'd like it to fire when a new page is being published or edited but ONLY when that page has a parent. Here's what I've got               function myFunction(){         global $post;          if($post->post_parent > 0){             // do stuff         }        }     add_action( 'publish_page', 'myFunction' );      So far this works when I'm updating a page, but not when I'm publishing one for the first time, it's not recognising that it has a parent at that point I suppose?


How to customize the default HTML for Wordpress Attachments

I'm using Wordpress 3.0.1 (most recent as of now) and working around the Whiteboard theme. It seems that for attachments (images, specifically), Wordpress generates the HTML automatically and it looks something like this:

Area Map Improvments

      I understand that some of these attributes can be changed in the editing screen itself - however I want to change the default HTML code structure so that I can insert additional tags, CSS classes etc. I need a method to achieve this without editing any files outside the wp- content folder - in other words, there must be a template-based way to do this.. any ideas?


Obtaining user table for one site on multisite set up

I'm trying to select only users that are registered for a specific site on my multisite set up and see that the table for the users has collected everyone that is on the network. Is there away I can get only the users on a specific site? Or only select the users from that specific site?


Get custom field from page, in a post?

I'm not quite sure how it works, if you're on a post (single.php), does it count page.php as the page it's on? What i need to do, is get a custom field assigned to a page, from a blog post. I need it because i want the user to be able to change the "Read more" text in the post excerpt. I could get the custom field by just using a static page id, but if the user decides to change things up the id might change, i need it to be dynamic. What would be the best way to go about this?


$wpdb->get_results() returns good result only in first foreach iteration

I've got strange issue when I am using $wpdb->get_results() in content- single.php in Twenty Eleven theme. `$wpdb->get_results()` returns proper values only in first loop iteration. I've got simple function in `functions.php` called               function get_product_data($postid)     {         global $wpdb;              $meta_table = $wpdb->prefix.'postmeta';         $product_table = $wpdb->prefix.'_features';              $eans = get_post_meta($postid, '_bs_prod_sym');         $eans = explode(';', $eans[0]);              print_r($eans); // returns Array ( [0] => abcde [1] => abcd )         foreach($eans as $ean)         {             $features = $wpdb->get_results("SELECT feature_name FROM $product_table WHERE product_id = '$ean'", ARRAY_A);                    print_r($features);// returns Array ( [0] => Array ( [feature_name] =>  feature name 1 ) [1] => Array ( [feature_name] => feature name 2 ) [2] => Array ( [feature_name] => feature name 3 ) )                   foreach($features as $feature)              {                   print_r($feature); // returns single element of $features array             }         }     }      And here is the place in content-single.php where I am calling `get_product_data()`.
             <?php the_content(); ?>                  <?php get_product_data(get_the_ID()); ?>                  <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'twentyeleven' ) . '', 'after' => '
' ) ); ?>
      Query in `$features` variable returns proper values only in first foreach iteration. If I change values in array `$eans` to `Array ( [0] => abcd [1] => abcde )` (before it was `Array ( [0] => abcde [1] => abcd )`) I get proper values also only once. I am sure that queries are good and data in database are also ok.


register_post_type - rewrite / feeds, what's it for?

The codex page for register_post_type seems to suggest that it should be possible to disable feed generation for custom post types:                rewrite         (boolean or array) (optional) Triggers the handling of rewrites for this post type.          To prevent rewrites, set to false.     ...          $args array     ...         'feeds' => bool Should a feed permalink structure be built for this post type.              Defaults to has_archive value.       I read that as meaning this:                register_post_type('People', array('rewrite' => array('feeds' => false)));      would result in my 'People' archive page _not_ having this:               <link rel="alternate" type="application/rss+xml" title="My Site » People Feed"         href="http://mysite.com/people/feed/" />      in its head. However, the above is output in the HTML. Have I misunderstood, or done something wrong? I do not want a feed to be generated. Any help much appreciated. Toby


Register custom query args parameter for WP_Query()

I have written a plugin which can store a table of technical specifications for each post (product) in an own database table. For the search function of the site I want to add a custom parameter to the array passed to `WP_Query()`. I have no clue where to register this custom parameter so that it is handled by the plugin as soon as `WP_Query()` executes the search. Is there a hook that I can use in the plugin to restrict the posts found by `WP_Query()` to a certain set matching the specs given? Or do I eventually have to build the entire query using SQL? See the following example: next to "standard"-parameters I have a custom parameter `_spec` its value I want to be parsed in some way by the plugin.               <?php          new WP_Query(         array(                  's' => 'some keyword', //keyword criterion             'category' => 'some category', //taxonomy criterion                  '_spec' => 'year_min=1980;year_max=2010', //custom criterion to be handled by the plugin              )     );          ?>


Categories and products in random order

What I'm trying to do is getting Woocommerce categories and products randomly displayed on one page. The normal settings allow to display categories and products on the same page, but first come the categories and afterwards the products. This is the case because the categories come with the function `woocommerce_product_subcategories()` and afterwards the product loop starts. What I want to to is something like this:                   $args = array(         'post_type' => array('product', 'post'),         'orderby' => 'rand',          'posts_per_page' =>-1,         'post_status' => 'publish'     );          $query = new WP_Query($args);      but i have no clue how to get the categories in there. to elaborate on my question: i was able to randomize the output of the categories by adding:               shuffle( $product_categories );      to the function `woocommerce_product_subcategories()` or to be excact to the template i created, but i more or less copied the code from the function there just thought that might help somebody, found it here: http://core.trac.wordpress.org/ticket/21875 but that is only a solution for just the categories or as metioned above, if the categories are shown before the products they will be shuffeled, but of course still not with the products * * * ok, inspired by @s_ha_dum answer i manged to get a solution:               //this 1. part is out of the woocommerce-template.php and part of the woocommerce_product_subcategories()     $product_cat = get_term_by( 'slug', $product_cat_slug, 'product_cat' );     $product_category_parent = $product_cat->term_id;          $pcat_args = array(     'child_of'  => $product_category_parent,     'hide_empty'    => 1,     'hierarchical'  => 1,     'taxonomy'      => 'product_cat',     'pad_counts'    => 1     );     $product_categories = get_categories( $pcat_args  );          //grab things by post_type product     $prod_args = array(     'post_type' => array('product'),     'orderby' => rand,      'posts_per_page' =>-1,     'post_status' => publish     );     $ng_query = get_posts($prod_args);          //combines, merge the arrays     $merge_query = array_merge( $ng_query, $product_categories );          //make the order random     shuffle($merge_query);          //iterate merged arrays     foreach( $merge_query as $mqp ) {      setup_postdata($mqp);     if ( $mqp->taxonomy == product_cat ) {     echo $mqp->category_nicename;     echo "
";     } else {     echo $mqp->post_title;     echo "
";     }     }      this gives me a randomized list of categories and products! like @s_ha_dum said it is neccessray to differ between the arrays/object-types merged together. i did that, for this simplified solution, by checking for taxonomy - not sure if that is a good way for more complex outputs. (1st) EDIT: i now implemented it with all the specific formating and its still working well - so looking for the taxonomy »product_cat« is a good solution for my scenario! (2nd) EDIT: i ran into the problem that the price and the add-to-cart-button wouldnt show up and the iteration would break, the solution for that was to add `setup_postdata();` - i added that into the code above


Unicode Problem

I am just in the test phase to launch our News Portal in Hindi Language. For writing the posts in hindi, I've installed Indic IME plugin which translates my english word to hindi format (like google transliterate does). Plus, I also use Google transliterate to write posts and then paste it in post box and publish it. The problem is - To 75% of the users the Hindi that is being displayed on site is same as I want, but on rest it changes to either other words or square boxes. I also commented //define(‘DB_CHARSET’, ‘utf8′); //define(‘DB_COLLATE’, ”); in wp-config as suggested on some site. But no avail. The official launch is being postponed of this reason only. Please revert back if you have any solution. Any clue, thanks a ton.


Get multiple tags by slug

The following code works fine for me:               $term = get_term_by('slug', ‘foo’, 'post_tag');            $args = array (        'posts_per_page' => 5,        'paged' => $paged,       'post__not_in' => get_option( 'sticky_posts' ) ,       'tag__not_in' => $term     );      I'd now like to `get_term_by` multiple tags, e.g., 'foo' and 'bar' (I'm trying to display all posts _except_ those tagged 'foo' or 'bar'). I realize this is probably elementary, but I'm not sure how to go about it. Ideas?


Add a new post status in the post progression

I run a site with about 30 authors and 3 editors. Authors submit posts for review, and editors schedule or publish them. It would be useful to have another post status of "Editing" between Pending Review and Scheduled/Published. I realize there's a warning when someone else is editing a post, and that's probably significant enough, but I'd like to explore adding a new status level. So, current post progression:               Draft --> Pending Review --> Scheduled/Published      Desired post progression:               Draft --> Pending Review --> Under Review --> Scheduled/Published      Thoughts?


How do I change site url to my new domain?

So, i need to change domain name. Here´s what I have tried. First I changed the name servers on my new domain towards the web hotel I'm using. Second, I logged in to c-panel and parked the new domain. Then I went to WordPress adminpanel - settings - general and changed the site url. After this i thought the only thing left would be to update the permalinks. What happens is the new url does work (it was redirected in the first place) but the site looks broken up, which i took as something that would maybe happen before the permalinks where changed. But I can't log in to the adminpanel, mu hosting said there where no debug messages sp they didn't know what was going on. changed back the site url in cpanel. and tried again with all plugins deactivated, same thing. How do i see of my domain has propagated correctly after change of name servers? Did a trace route, the ip´s doesn't match my name servers exactly. Should it? Have I missed something?


iframe not showing in post (with "allow php in posts" plugin activated)

$width = 560;     $height = 315;     $code = "I8M_uCnxhwY";          $homepage = "/";     $currentpage = $_SERVER['REQUEST_URI'];     if($homepage!=$currentpage) {     echo '<iframe width=".$width." height=".$height." src="http://www.youtube.com/embed/'.$code.'" frameborder="0" allowfullscreen></iframe>';     }        So, that's my current code. I'm trying to display a YouTube embedded video in an iframe within a PHP script that shows said iFrame only if it is not on the home page. (i.e. is a blog post) If anyone could assist me that would be great. It seems to acknowledge something should be there, but doesn't show it. I get no errors. Thanks!


How to add multiple images to custom post type?

I would like to create a simple plugin to add multiple images to a custom post type. I have created a plugin to add a single image to a custom post type, but I am unable to figure out how to add multiple. ![enter image description here](http://i.stack.imgur.com/MtPox.png) this is where I'm at. js file-                   jQuery(document).ready(function($) {              // add image uploader functionality             var meta_image_frame;                $('.meta-image-button').live('click', function(e){                 e.preventDefault();                      if( meta_image_frame ){                     wp.media.editor.open();                     return;                 }                      meta_image_frame = wp.media.frames.file_frame = wp.media({                     title: 'Portfolio Image Gallery Selection Window',                     button: {text: 'Add to Gallery'},                     library: { type: 'image'},                       multiple: false                 });                      meta_image_frame.on('select', function(){                     var media_attachment = meta_image_frame.state().get('selection').first().toJSON();                             var url = '';                          $('#meta-image').val(media_attachment.url);                           });                      meta_image_frame.open();                });                $('#add-input').click(function(event){                      add_input()             });                   function add_input(){                           var input = "
Add Project Image"                                   +"<input type='text' name='meta-image' id='meta-image' value='' />"                                   +"<input type='button' class='meta-image-button button' value='Upload Image' />"                                   +"<input type='button' class='meta-image-button button remove-button' value='Remove Image' />
";                      $('#images-container').append(input);                  }          }); //end main jquery function      this is my php file-                   <?php          /*----------------------------------------------------------                            Create Post Type     ------------------------------------------------------------*/          function portfolio_create_post_type(){         $labels = array(                 'name' => __('Portfolio', 'portfolio'),                 'singular_name' => __('Project', 'portfolio'),                 'add_new' => __('New project', 'portfolio'),                 'add_new_item' => __('Add new project', 'portfolio'),                 'edit_item' => __('Edit project', 'portfolio'),                 'new_item' => __('New project', 'portfolio'),                 'view_item' => __('View project', 'portfolio'),                 'search_item' => __('Search project', 'portfolio'),                 'not_found' => __('No products Found', 'portfolio'),                 'not_found_in_trash' => __('No products found in trash', 'portfolio')             );         $args = array(                 'labels' => $labels,                 'public' => true,                 'supports' => array(                         'title',                         'thumbnail',                         'editor',                     ),                 'taxonomies' => array('post_tag', 'category')             );         register_post_type('Portfolio', $args);     }          add_action('init', 'portfolio_create_post_type' );               /*----------------------------------------------------------                            Create Meta Box     ------------------------------------------------------------*/               function portfolio_meta_box(){         add_meta_box( 'portfolio_gallery', 'Project Gallery', 'project_meta_box_cb','Portfolio', 'normal', 'high' );     }//portfolio_meta_box          add_action( 'add_meta_boxes', 'portfolio_meta_box' );          /*----------------------------------------------------------                       Meta Box Fields     ------------------------------------------------------------*/          function project_meta_box_cb(){                     wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );                     $prfx_stored_meta = get_post_meta( $post->ID );                          ?>
                     <input type="button" id="add-input" value="Add Image">

                     <?php                 }          /*----------------------------------------------------------                       Save the Data     ------------------------------------------------------------*/     function project_meta_save( $post_id ) {                  // Checks save status             $is_autosave = wp_is_post_autosave( $post_id );             $is_revision = wp_is_post_revision( $post_id );             $is_valid_nonce = ( isset( $_POST[ 'prfx_nonce' ] ) && wp_verify_nonce( $_POST[ 'prfx_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';                  // Exits script depending on save status             if ( $is_autosave || $is_revision || !$is_valid_nonce ) {                 return;             }                  // Checks for input and sanitizes/saves if needed            if( isset( $_POST[ 'meta-image' ] ) ) {             update_post_meta( $post_id, 'meta-image', $_POST[ 'meta-image' ] );              }     }          add_action( 'save_post', 'project_meta_save' );          /*----------------------------------------------------------                       Load Javascript File     ------------------------------------------------------------*/     function project_image_enqueue() {         global $typenow;         if( $typenow == 'portfolio' ) {             wp_enqueue_media();                  // Registers and enqueues the required javascript.             wp_register_script( 'meta-box-image', plugin_dir_url( __FILE__ ) . 'meta-box-image.js', array( 'jquery' ) );             wp_localize_script( 'meta-box-image', 'meta_image');             wp_enqueue_script( 'meta-box-image' );         }     }     add_action( 'admin_enqueue_scripts', 'project_image_enqueue' );          ?>


Is it possible to insert images directly from the server?

I've uploaded images directly to my WordPress server through FTP. I want to add these images to a post, so right now I'm using the Add from Server plugin that allows me to browse images on the server and add them to the media library. The only thing I don't like about this is that adding an image to the media library generates two smaller versions of the image that are used for thumbnails. Is it not possible to completely bypass the media library and add images directly from the server?


Possible to hide the search engine indexing disabled prompt/error message?

In Wordpress Settings >> Reading (../wp-admin/options-reading.php) there is an option called "Discourage Search Engines from Indexing This Site". If you check this, a notification error message will nag at you telling your your site cannot be searched by search engines... _"This site discourages search engines from indexing the pages, which will affect your SEO efforts. You can fix this here"_ Does anyone know how to disable this notification? I could use css by hiding display of the error class, but I'm afraid it may affect other error messages which may be useful.


html lang="" instead of lang="en-us" - why?

In a few installations of wordpress, the beginning of the html tag looks like               <html lang="en-US" ...      despite that in wp-config no language is specified.               define('WPLANG', '');      Hovever, in one installation the tag is               <html lang=" " ...      how would i change that to `<html lang="en-us" ...`, without changing the wp- config file I'm talking about the front end, not the admin dashboard. The code in header.php looks like this:               <!DOCTYPE html>     <html <?php language_attributes(); ?>>     <head>      and the HTML render looks like this:               <!DOCTYPE html>     <html lang=" " prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#" class="no-js">     <head>     ...


How can I use a different default admin menu icon for custom post type?

For a particular custom post type I'm setting, I simply want to change the default icon to the wordpress pages icon (menu-icon-page). I know I could upload my own pages icon and point to it, but can I just tell wordpress to use the default pages icon? Here's what I'm using               register_post_type( 'intranet-pages',  // creates the custom admin panel         array(           'labels' => array(            ...             'menu_icon' => menu-icon-page,      I've tried to do different variations and can't figure it out. Thoughts? If I have to upload my own I will. Just don't want to duplicate if it's not necessary. Thanks! UPDATE: According to this, it can't be done: How to use a WordPress' existing admin icon? At least not this simply. Does this still apply? Looks like I'll be uploading it. UPDATE 2: See below for a more elegant solution. Simply uploading and using menu_icon => doesn't allow for the nice hover effects or the 32px icon on the edit screen.


wp_get_nav_menu_items order doesn't work

I am using this function               $args = array (        'order' => 'DESC',     );          $items = wp_get_nav_menu_items( $custom_menu, $args );      then, if I change args to               $args = array (        'order' => 'ASC',     );      and the result is still the same. Anybody have suggestion?


Need help with custom PHP plugin

I'm trying to write a small plugin to use for testing login credentials to use with some games I'm making. But I keep running into issues with the script I can't figure out. The issue I'm having is that when hitting the file, it doesn't seem to get past the `$user = get_user_by( 'email', $email );` line. I did several echo debug tests, and found that everything worked fine, up until that line. If I enter incorrect information it returns the number I entered there (402) correctly. The other issue is that on all my Wordpress pages, the stuff on the page is replaced by the error code (402). Here is my script, I'm still quite new to PHP, so please feel free to give advise :).               <?php     require_once(dirname(__FILE__).'/../../../wp-includes/class-phpass.php');          global $wpdb;          $DecryptCode = "XXXXXXXXXXXXXXXX";          if (sizeof($_GET) > 1 && $_GET["user"] != null && $_GET["password"] != null && $_GET["uid"] != null && $_GET["uid"] == $DecryptCode) {          echo "valid information";          $email = $_GET["user"];          echo "got user var";          $pass = $_GET["password"];          echo "got pass var";          $user = get_user_by( 'email', $email );          echo "got user".$user->first_name;               if ( $user && wp_check_password( $pass, $user->data->user_pass, $user->ID) )               echo "That's it";          else               echo "Nope";     } else{          echo "402";     }     ?>      The Decrypt code is a method I'm working on to help stop people from hacking, and using this for their own things. Also as a method of later on, further encrypting the passwords so it's not sent in plain test. My plugin structure is: ![Plugin Structure](http://i.stack.imgur.com/LHb9b.png) And the code in the WordpressAuth file is:               <?php          /**      * Plugin Name: Wordpress Auth      * Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates      * Description: Allows me to authorize my unity games with my Wordpress user database      * Version: 1.0      * Author: Keith M      */               include dirname( __FILE__ ) .'/Auth.php';          ?>      I would use a file in the wordpress root, but I don't have access to the file on the server, so I need to go with a plugin instead.


Wordpress Local to Live and The Missing Widgets!

I have just finished my local dev of a wordpress woo theme for a client which has extensive sidebar customization and widgets. Ive done a full mysql export and import via phpmyadmin. However when I go to the demo site there are no widgets assigned to the sidebars that are registered using traditional wordpress methods and the woo theme sidebar manager has no sidebars. Im a little confused!


trying to get thumbnail to appear before post

http://news-test.gnome.org/original-posts/ I would like the thumbnail to appear before the title of the post here. I have tried making a list-category-posts folder right under my theme folder, with a new template file called thumb-before-title.php. The only thing I changed from default.php was I placed the //Post Thumbnail $lcp_display_output .= $this->get_thumbnail($single); right after "Start a list item for each post..." and right before "Show the title and link..." I then added template=thumb-before-title to my shortcode, but I get an empty page. If I add template=thumb-before-title.php, I get a page of posts, but the thumbnail still appears after the title. I have tried several other ways to make this work, all to no avail. What do you suggest? Thank you so very much!


How to create menu spread over four lines including images

I would like to create a dynamic WordPress menu using `wp_nav_menu()` divided over four lines or rows as the static website. I think I should either force the menu to do this using CSS and width limitations or PHP. I do think PHP is needed as certain menu items will be followed by images before the menu continues again - see site. Is it possible to use a dynamic WordPress menu for this situation or should I just go for dynamic sidebars or static blocks? If it is possible to use WordPress dynamic menus how would I do this given the fact that the menu should be on four lines and is interrupted by images every now and then? Update: Perhaps I should just use three menus to solve the splitting of the menu into three pieces, but then I still have the issue with the images in between. Update 2: Decided to go with a few sidebars with several widgets inside. For each menu item I will use a text widget. So basically I am doing what @Webord recommended


How to add a custom metabox to the Menu Management admin screen?

Although I am very thankful to the wordpress core team that they have finally integrated native menu management capabilities I get frustrated with some key elements which I would like to change. I need a way of showing pages which is hierarchical in the same way hierarchical categories are displayed instead of being in a list and I need a way of manually including links which can be added to a menu. How can this be done? Thanks in advance **UPDATED** So, here are the two things I am trying to do. Currently if you go to the default wordpress "menu management" admin screen you can select to display the "pages" metabox on the left. The problem here is that when you click on the "view all" tab NONE of the pages are ordered correctly and they are not indented if applicable. **CURRENT DEFAULT LAYOUT:** ![CURRENT DEFAULT WP ORGANIZATION](http://i.stack.imgur.com/NEpXi.png) **DESIRED LAYOUT:** (please note that I just indented them to show the parent relationship, the items should also be sorted based on their sort order). ![what i would like](http://i.stack.imgur.com/7GulS.png) Additionally, within this list (or if easier then within its own metabox) I need some way of hard coding links which should be presented in the form of a checkbox list so one can click elements and include them within the menu. The reason for this is that instead of having to manually add these elements using the "custom links" I would prefer to select them from a list.


How to organise via Custom Fields on Category Page

I have a custom field named: eventdate The posts are all in the standard post type. I want to order by this field ascending. I have tried over 15 different solutions but no joy . Every post simply gets turned into a list of all posts. I have tried all solutions both before and after the following.               if(have_posts()){      while (have_posts()) : the_post();      Please help, I have been trying to sort this for at least 14 hours.


What is wrong with my wp query, cant exclude the category that i want

query('showposts='.$display_count.'&orderby=comment_count&category__not_in=14'); It wont exclude the category that i want. Posts still show up


Does switch_to_blog support array or other ways to show all posts on a network install?

I have a WordPress network install and I'm looking for a way to display all posts on the front page. I'm using switch_to_blog and it works but it only works for showing one blog. Does switch_to_blog support multiple blogs? If not, what's the best way to show posts from multiple blogs without a plugin? I tried the sitewide plugin and I kept getting errors. Thanks, Gregory S.


Widget's container?

I have some custom-made widgets:               echo $before_widget;        if ( $title )           echo $before_title . $title . $after_title;     echo $output;     echo $after_widget;       Let's assume the $title is "Widget's Title" and the output is "Hello world". I'm getting something like: > Widget's Title > > Hello world Now, I don't know where it comes, but there's container wrapping every one of my widgets, it looks like:

$title

$output

      Any ideas how to change the first "li" into "section" or a "div"? :)


How to run WordPress from other location on the same domain

Hi I have a domain running in WordPress, the path to WordPress installation is `/subdomain/mywordpress/` and I can access these in `mywordpress.mysite.com`, Now I wish to load the index page on my main domain, ie When I goto `mysite.com` I want to load the Index page of the WordPress, I know if that possible, the links are always pointing to `mywordpress.mysite.com`, but that is what I need know. because I dont want to remove the `mywordpress.mysite.com`. I just need to display all posts on my main site, with same design(that is why I prefer to load the Index file of wordpress)


A function like is_page() but returns true if on any sub page of given page

In my header I use this code:               if(is_page("stores")) {         // Do something     }      I run some code if on the page `stores` but what I want to do is run that code if the page is `stores` or any page that is a sub page of stores. Not only that, but is recursive so if we are on a sub sub sub page of `stores` the code still runs.


WP-FB-AutoConnect: Unable to login with administrator account

I just bought and installed the WP-Facebook-AutoConnect plugin but I am unable to login. Below is the debug log I got by email.               ---LOG:---     Starting login process (Client: 178.156.161.15, Version: 2.0.4, Browser: Chrome 13.0.782.15 for Mac)     PREMIUM: Premium Addon Detected (#671, Version: 22)     WP: nonce check passed     WP: Found redirect URL (http://blog.i18n.ro/wp-admin/)     FB: Initiating Facebook connection via the new API...     FB: Connected to session (uid 685872843)     FB: Got user info (Sorin Ionuț Sbârnea)     FB: Email privilege granted, but only for an anonymous proxy address (apps+116692738389663.685872843.060155133d98d19b8fa5f9c49090e749@proxymail.facebook.com)     WP: Searching for user by meta...     FP: Searching for user by email hashes (8 candidates of 8 total users)...        Checking Users #0-7        WARNING: Could not register hashes with Facebook (connect_registerUsers generated an exception).  Hash lookup will cease here.     WP: No user found. Automatically registering (FB_685872843)     PREMIUM: Autoregistration is Disabled; redirecting to /.          ---REQUEST:---     Array     (        [redirectTo] => http://blog.i18n.ro/wp-admin/        [rememberme] => 1        [_wpnonce] => 3786067e30        [_wp_http_referer] => /wp-login.php     )


Setting higher upload limit

How can I change the standard 7MB upload limit? I have full shell and admin access to my Wordpress blog.


Jetpack Connection Broken

I've upgraded from 2.8.4 to 3.1.2. There were a number of issues, which are now largely resolved. But Jetpack continues to be problematic. I keep getting this error message in the stats block on the dashboard: > unknown_token: It looks like your Jetpack connection is broken. Try > disconnecting from WordPress.com then reconnecting. I've found no references to this issue on the web. (Except for a Greek translation in Automattic's svn archive.) So, I tried logging in and out of WordPress.com. I also cleared out the cookies in my blog and in wordpress.com. All to no avail. Has anybody seen this error? Any idea how to resolve this? Thanks for your help.


Single dash converted to double dash

As the title says, if a single dash is used with a space between each side eg. 'Die Hard - Action Film' is written in to a WordPress post, once published it comes out as 'Die Hard -- Action Film'. If no spaces are used around the dash it works, but obviously this isn't desired. I've obviously found out it's not something that happens with a default install of Wordpress but I can't seem to pinpoint what the cause is in my theme.


Running the Loop outside of WordPress

I have a static website and WordPress installed at mywebsite.com/blog. I have a page on my external static website which displays a list of all posts [per the codex][1] using the following code

       <?php       $args = array( 'numberposts' => 10,    'post_status'=>"publish",'post_type'=>"jobs",'orderby'=>"post_date");       $postslist = get_posts( $args );       foreach ($postslist as $post) : setup_postdata($post); ?>

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>

<?php the_date(); ?>

<?php the_excerpt(); ?>

       <?php endforeach; ?>
      I then have tried to create a page which can display a single post with               <?php     // Include WordPress      define('WP_USE_THEMES', false);       require('/server/path/to/your/wordpress/site/htdocs/blog/wp-blog-header.php');      query_posts('showposts=1');     ?>
              <?php while (have_posts()): the_post(); ?>
<?php the_title(); ?>
         <?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>" class="red">Read more...
         <?php endwhile; ?>
      The bit I'm missing is getting the Title on the first page (which lists all posts) to link to the right single post. Basically I'm trying to avoid having to go to the wordpress blog at all but always running the loop outside of WordPress. Is this possible and could anyone help me fill in this gap!? Cheers


Single Domain/Multiple Domain installation restrictions allowed for plugins?

From what I have read, I have come to understand that all WordPress plugins,(including premium ones) should be GPL licensed. If this is the case, can the installation be limited to a single domain? As far as I understand, GPL allows you to reuse the code. Doesn't it? I'm asking this because I have seen some premium plugins have single site/multi site licenses. Please correct me if this question is wrong.


How do I set a custom base URL for standard posts?

Currently, permalinks are set to /%postname%/. I'd like to prefix "blog" before all standard posts. I'm using several custom post types, each with their own rewrite rules in the setup. How can I setup a custom prefix for my standard WordPress posts?


User Defined order on get_categories?

Below is some basic code to call specficic categories to our front page post loop. It works fine, except my client wants the categories displayed in a particular order. I know there are other posts about this on the internet, but I didn't see any that addressed it the way my client is asking. Can I take the $categories variable, created in the code below, and just call those objects into a new array? In this instance the objects all have a number in front of them, like :               [0] => values     [1] => values     [2] => values     ....      when the output is dumped. Can I take that output and just call them in the order I want them? (ex: 1,3,4,2,5,0) **Current code:** `                   wp_reset_postdata();                 /* top stories end */                          $args = array(                  'child_of'                 => 0,             'parent'                   => '',             'hide_empty'               => 1,             'hierarchical'             => 1,             'orderby'                  => 'id',             'order'                    => 'ASC',             'include'                  => '12,13,14,15,16,1',         );                $categories = get_categories( $args );      ?>          <?php         echo '
';          foreach( $categories as $cat)          {             $slug = $cat->slug ;             echo '
';              echo ''.$cat->name.'cat_ID ).'" title="'.$cat->name.'">Show all '.$cat->name.'';             echo do_shortcode('[blog number_posts="6" cat_slug="'.$slug.'" exclude_cats="1" title="" thumbnail="" excerpt="" excerpt_words="20" meta_all="no" meta_author="" meta_categories="" meta_comments="" meta_date="" meta_link="" paging="" scrolling="" strip_html="" blog_grid_columns="" layout="medium"][/blog]');             echo '
';               }          echo '
';          echo '
';      ?>      `


Cannot strip JW Player shortcode?

On the WordPress archive template I am using a custom excerpt function that includes a reference to `strip_shortcodes()`. For some reason, shortcodes are being rendered and displayed in the archive. Example: http://arisehub.org/blog/page/2/ Scroll down to "Sing a New Song with Joshua Cunningham" Notice the script code showing up. That's a shortcode reference to JW Player, showing up rendered. Here's the code I'm using for the custom excerpt function.               function custom_excerpt($length, $more_text) {          global $post;              $text = get_the_content();          $text = strip_shortcodes( $text );             $text = apply_filters('the_content', $text);           $text = str_replace(']]>', ']]>', $text);           $text = strip_tags($text, ',
, , , ');                   if(!empty($length)){             $excerpt_length = apply_filters('excerpt_length', $length);          } else {             $excerpt_length = apply_filters('excerpt_length', 180);          }              if(!empty($more_text)){             $excerpt_more = apply_filters('excerpt_more', ' ' . '…
id).'" class="more-link">'.$more_text.'');         } else {              $excerpt_more = apply_filters('excerpt_more', ' ' . '…id).'" class="more-link">+ more');         }              $words = preg_split('/()|\n|\r|\t|\s/', $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE );           if ( count($words) > $excerpt_length ) {               array_pop($words);               $text = implode(' ', $words);               $text = $text . $excerpt_more;           } else {               $text = implode(' ', $words);           }           $output = '
'.$text.'
';         echo $output;       }       Any ideas?


What is a short code?

I am new to WordPress and I've seen this term passed around.


How do I get the title of a category in a custom loop?

I am using the following code to display a list of posts within a category, but I want to display the title in it's own h2 tag above the list.
     <?php     $weightloss = new WP_Query();     $weightloss->query('showposts=5&include=4');          while ($weightloss->have_posts()) : $weightloss->the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>
     <?php endwhile; ?>
      * * * EDIT: So I tried using `single_cat_title` , however, the title is coming up for the parent category for all the sub category divs. Here's an example of a div that I am replicating multiple times, where the query is pulling posts from different sub categories. I would like the title for each sub category above the posts. I realize it's not working because I'm returning the parent category with that function, I'm just can't figure out the php...

<?php single_cat_title(); ?>
                     <?php                     $weightloss = new WP_Query();                     $weightloss->query('showposts=5&cat=4');                          while ($weightloss->have_posts()) : $weightloss->the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>
                     <?php endwhile; ?>


Toggle Sidebar Display

I'm developing a WordPress theme that allows users to toggle the visibility of the sidebars using Javascript in the same way that wikis allow users to show or hide a table of contents. When a user clicks the link to hide a sidebar I have a toggle() javascript toggle function that sets the visibility of the sidebar to "none" and also sets a document cookie so that the next time the users visits that page, the sidebar will remember the last toggle state. I have another javascript function setToggleFromCookie() that gets the cookie and sets the visibility based on that cookie. This all works except: If a sidebar is hidden (i.e. visibility of the sidebar div = "none" and the document cookie hidesidebar = 1), when the page is loaded, the sidebar appears briefly before the javascript overrides the visibility = "block" with visibility = "none." I have put setToggleFromCookie() in jQuery(document).ready(function(), but the page still seems to load and display the sidebar BEFORE setToggleFromCookie() jumps in to hide it...


How to use get_categories() with Event Organiser plugin

I want to display my categories in tabs. All is good, except my "Upcoming Events", created with Event Organiser (awesome plugin at http://wordpress.org/extend/plugins/event-organiser/), are not being treated like a normal category, so they don't appear. In essence, get_categories() is not returning the events category. How can I fix this display?               $args = array('type'=> 'post', 'order' => 'ASC', 'hide_empty' => 1 );     $categories = get_categories( $args );     foreach($categories as $category) {         echo '
term_id).'" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'
';         array_push($cat_list,"$category->term_id");     }


Hide a page in the admin end without a plugin?

I'm creating a series of pages with iFrames embedded in them, but it seems the only way to do this within Wordpress (i.e. using the templating system) is to create pages in the admin end and then create individual templates for each of those pages. Is it possible to hide those pages from the admin without a plugin? I see no need for the client to see those pages when they can't edit anything in them. Thanks, osu


post_id always wrong in plugin

I am trying to make two plugins work together where one of them puts a tag around every title with a filter function. I want it to exclude posts of another plugin that have custom post_type (ai1ec_event). But I can't get the post type if the id is wrong.               add_filter('the_title', 'mealingua_title_filter', 10);     function mealingua_title_filter($title) {        $post_id = get_the_ID();        #some stuff        if (is_front_page() OR is_single() OR is_page()) {             return '' . $title . '';         } else {             return $title;         }      }      But the post_id is always wrong in some places. One is the nav_menu at the top. The other is the plugin that I want to fix. There the id is always the one of the last post from the site. I tried the following to alternatives without success:               global $post;     $post_id= $post->ID;     global $wp_query;     $post_id = $wp_query->post->ID;      How can I work around this? What can I do? I am willing to mess with the code of either plugin but although I know PHP I have no experience with wordpress plugin coding. Thanks for any help.


How to change theme header to support multiple nav menus?

I'll try to be brief.... I have a theme that only supports one navigation menu. At this point I'd like to add 2 or 3 more menus. I have successfully registered my menus in functions.php with register_nav_menus and I am able to switch the header.php code manually between my different menus. My problem... Since my theme uses a single header (header.php) I can't assign my pages or posts the navigation menu I want without changing all the other pages navigation menus. Can anyone help me out on this? Thanks in advance. Greg


Get first post from wp_query

How can I get the first post from a WP_Query result?               $connected = new WP_Query( array(     // Arguments     ));          // This doesn't work..     echo $connected[0]->post_name;


Dynamic page.php template for custom post types

I have a couple of custom post types registered. I would like to display all "posts" from each custom post type on its own page, and these pages must be visible in the nav menu. It would be great to only have one `page-custom.php` template as to a page template for each custom post type. Is it possible to create something like this?


Converted posts to a CPT, 301 redirects necessary?

I had about 300 posts, sitting inside of the default post post type. I have since created two seperate CPTs, and transferred those posts to the new CPT's. Do I need to set up 301 redirects for these posts? and if so what would be the most efficient way? Thanks.


Wordpress ultra slow if I click on posts?

I have 5000 posts on my website, which I have uploaded from a `CSV` file. This all went well and the website is fast on the back-end and frankly on any other page. There is one exception: if I click on a post, it takes 8 to 9 seconds to open a post, which is very disturbing. I am using _year/month/year/post-name_ as the `permalink structure` and have edited the **.htaccess** file with the code that is outputted by Wordpress on the `settings` page. What should I do? I have used WP-Minify, but that did not have any effect at all. FYI: it's a self hosted website, running on a fast server. The website is very fast, except at clicking on a post. Than it changes suddenly.


Change image link in excerpt to point to post

By default, images included in an article link to the full-size-image url. Having such an image in an excerpt shown on the start-page, because the more- tag was added after the image (which is intended), the image-thumbnail still links to the image URL. **Which action has to be taken to make it link to the article?**   While keeping it pointing to the image url in the specific article-pages? (For my Fancybox) Clarification: I don't mean Post-Thumbnails, just Images in the articles as shown in the specific article-page.


PHP script from functions php is loaded via admin-ajax to div...and the result is 0, not the desired content

I wish to use accordion menu http://wordpress.org/plugins/jquery-vertical- accordion-menu/ via function that is loading different menu based on page template. What is more, I wish to ajaxify that element. Below is all scripts from functions.php:               function get_left_menu() {     if (is_page_template('page-akademia-biznesu.php')) {         echo do_shortcode('[dcwp-jquery-accordion menu="Business menu" auto_close="true" event="click" save="true" disable="false" count="false" expand="false" disable_class="disabled"]');     } elseif (is_page_template('page-forum-wiedzy-oze.php')) {         echo do_shortcode('[dcwp-jquery-accordion menu="OZE menu" auto_close="true" event="click" save="true" disable="false" count="false" expand="false" disable_class="disabled"]');     } elseif (is_page_template('page-o-nas.php')) {         echo do_shortcode('[dcwp-jquery-accordion menu="About menu" auto_close="true" event="click" save="false" disable="false" count="false" expand="false" disable_class="disabled"]');     } elseif (is_page_template('page-program-ambasadorski.php')) {         echo do_shortcode('[dcwp-jquery-accordion menu="Ambassador menu" auto_close="true" event="click" save="true" disable="false" count="false" expand="false" disable_class="disabled"]');     } elseif (is_page_template('page-program-edukacyjny.php')) {         echo do_shortcode('[dcwp-jquery-accordion menu="Aside menu" auto_close="true" event="click" save="true" disable="false" count="false" expand="false" disable_class="disabled"]');     }     die();     }     add_action("wp_ajax_nopriv_get_left_menu", "get_left_menu");     add_action("wp_ajax_get_left_menu", "get_left_menu");          function reload_menu_via_ajax()     {      wp_enqueue_script( 'function', get_template_directory_uri().'/library/js/menuReload.js', 'jquery', true);      wp_localize_script( 'function', 'left_menu_reload', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );     }     add_action('template_redirect', 'reload_menu_via_ajax');      And here we have jquery ajax script (menuReload.js):               jQuery(document).ready(function($) {     $(function() {         $('nav ul li').click(function() {             $('#left-menu').empty();             setTimeout(function() {                 $.ajax({                     method : "POST",                     url : left_menu_reload.ajaxurl,                     data : ( {                         action : 'get_left_menu()'                     }),                     success : function(data) {                         $("#left-menu").html(data);                     }                 });             }, 2000);         });     });     });      I am not quite skilled if it comes to an ajax calls, so please forgive me if this is some obvious thing. But I am really desperate lately with this and please - help.


Two Wordpress installations: One in root and one in sub directory - no images in subdir installation

**The setup:**   I have two Wordpress installations. One in the root of the Server and one in a subdirectory, every installation has it's own database. The subdirectory installation is connected with a subdomain. **The problem:**   In the subdirectory installation, no images show up - even in the admin menu. I checked the paths and they were correct. I also checked for writing permissions, everything is fine. So the images are all in place, the upload also works but when trying to access the images, I get the 404 page of the subdirectory install (/blog is the folder name). **What I think:**   My guess is that the .htdocs file in the root actually blocks access to the /blogs subdirectory or something like that.   Of course I already did a Google search, but that didn't help much. The Codex article Giving WordPress Its Own Directory actually seems helpfull, but I can't move the subdirectory's index.php into the root as this would clash with the Wordpress installation there.   How to fix my problem? **Edit** At the moment I am not so sure about the .htaccess anymore. When I try to access blog.mydomain.com/wp-content/uploads/2013/06/logo.jpg (blog.mydomain.com is the subdomain) I get a 404. But accessing mydomain.com/blog/wp-content/uploads/2013/06/logo.jpg everything is fine. So maybe I just have to set Wordpress to a different path somehow?


Query menu_order custom post types

I added `'supports' => 'page-attributes'` to my custom post type, and now i have the meta box for page ordering. When i use the argument `'sort_column' => 'menu_order'` with `get_pages()` on my custom post type, everything orders properly. So why do the custom pages not order properly when i query the posts using `query_posts(array('orderby' => 'menu_order'))` And what can i do to get them to order by the menu order? Here is the query im using incase anyone wants to see it.               <?php          $current_term = ($wp_query->query_vars['section'] <> '') ? $wp_query->query_vars['section'] : $menu_arr[0];          query_posts(array(  'post_type' => 'module',              'orderby' => 'menu_order',             'tax_query' => array(array( 'taxonomy' => 'section',                                          'field' => 'slug',                                          'terms' => $current_term )),             'post_parent' => 0 ));     ?>


Content DISAPPEARS when simply adding normal text for ONE POST ONLY

This is the oddest thing I've ever seen on wordpress. Here's my problem: I have a whole ton of text. But the last few lines I have this: > < blockquote>[Laughs] I'm doing the exact same thing I'm doin' live. Plug > in, turn it up, turn on the machine and play. I don't overdub anything. I > ain't going back and redoing solos. I ain't going back and redoing vocals. > It's all live. If you listen, you can hear the guitar pick clicking on the > strings while I'm singing! So I'm playing it live just as if I was in front > of an audience. And that's the way it feels in the studio when everybody's > playing together and you're not going back and fixing anything. Because you > know I'm really kind of a stickler for that. IF I add this line next (without the quotes)... "I try to keep anybody from having to go back and fix anything so it makes them have to play it now, you know?" **The entire body of the post disappears.** Only the title shows up. If I remove that line, the text comes back. If I add "asdf", the body stays. If I add a random line, the body disappears. I thought maybe it was a phantom html tag hidden in there or something, so I copied and pasted into notepad to clear any potential underlying formatting and it's still doing it. I've never seen anything like it. I've been poking at this thing for hours. I even tried moving the entire contents to a new post. No dice. I erased and rewrote the entire offending section and then some... nothing. We've got several hundred posts and this has never happened. There's a good 20 blockquotes in this post and everything works fine. We don't really have any plugins that scan text or anything that would be screwing with this thing. For the life of me, I can NOT figure out what in the world is going on........ Does ANYBODY have ANY ideas?!


Disable Outbound Web Requests

I've setup wordpress on AWS. I want to reduce as much network traffic as possible. What services/jobs do I need to disable in Wordpress?


How can I get a list of plugins and which blogs are using them?

I'm about to upgrade my Wordpress MU installation to wordpress 3 Before I update, I want to find out which blogs use which plugins. I don't see a way to do that in the UI, is there? What about a query of the mysql database? Thanks


Help making my pagination plugin better

I'm not sure if this is the right place to ask for this kind of help since is not an actual question but hopefully I can learn a thing or two. I'm developing a plugin (my first one) inspired in the Infinite Scroll Plugin, but instead of showing older posts when scrolling down, I'm showing them when you click a "Show more" link. My intention is to make it public but I know there are a lot of things on it that I can improve before doing so, I tested it a bit in a couple themes and it worked fine but I'm not sure how it'll behave in the real world. Here's a link to it on github: https://github.com/javiervd/Click-and-Load-Pagination Some concerns at the top of my head are: - How to handle users including and external jQuery library instead of the WP one? I'm currently queuing WP's jQuery but I'm not sure how good is this. - Simplicity? As I said this plugin is based on the Infinite Scroll Plugin so I used a similar but much simpler approach to set the options, hopefully this can be optimized as well. - Best practices? This is my first "real" plugin I'm sure I'm not following the best practices out there :( I hope some of you guys can help me, I'll make sure to mention everyone who does when I release it, feel free to fork/request pulls if you wish. Thanks in advance!


How to use 'depth'?

I wanna use 'depth' in a sidebar menu to only display the first child page, and I wonder where in my code I should insert depth? I wanna be able to only show the first child page and not all child pages. I have tried to insert 'depth' under this if conditon               if ( $item->current_item_ancestor && $item->menu_item_parent == '0' )     {         $last_parent = $item,         'depth' => 1     }          /* ------------------------------------------------------------------- */          function myproject_nav_menu_objects_start_in( $sorted_menu_items, $args )     {             switch ( $args->menu_id )        {            case 'sidebar-menu' :                 $current = false;            $last_parent = false;            $menu = array();                 foreach( $sorted_menu_items as $item )            {                if ( $item->current_item_ancestor && $item->menu_item_parent == '0' )                    $last_parent = $item;                     if ( $item->current )                    $current = $item;            }                 if ( $current )             {                $keys = array();                $last_parent = ( ! $last_parent ) ? $current : $last_parent;                     $children = _myproject_submenu_get_children_ids( $last_parent->ID, $sorted_menu_items );                     foreach ( $sorted_menu_items as $key => $item )                 {                    if ( ! in_array( $item->ID, $children ) )                        unset( $sorted_menu_items[$key] );                }                 }            else            {                $sorted_menu_items = array();            }                 break;             }        return $sorted_menu_items;     }     add_filter( 'wp_nav_menu_objects', 'myproject_nav_menu_objects_start_in', 10, 2 );


Easiest way to make post private by default

I don't know how to make a plugin so I can't do what's suggested here How can I make it so the Add New Post page has Visibility set to Private by default? so what's alternative ?


How do I hook into WordPress to save an uploaded photo as an alternate size to an existing photo?

I have image resizing disabled in media settings by setting thumbnail, medium and large size dimensions all to 0. For every photo on my blog, I **upload** the same photo in three sizes:   1. large/full-size watermarked image for use in FancyBox, with all metadata intact      * _filename_ **_large**.jpg (1200x800)   2. thumbnail image, no watermark, all metadata stripped using ImageOptim     * _filename_.jpg (180x120)   3. retina-thumbnail, no watermark, all metadata stripped using ImageOptim     * _filename_ **_x2**.jpg (360x240)   4. maybe more sizes later... Currently, each one of these take up separate entries in the **wp_posts** and **wp_postmeta** table. I've hooked into the media uploader to add a _"Title Thumbnails"_ button which takes the title from the large photo and adds it to the two thumbnails with _" – Thumbnail"_ appended. **What I would like is to have only one entry in the database for all of these images – it's the same photo after all, just in different sizes.** As it is, I'm already hooking into the add_attachment action to move the IPTC caption to the proper field as follows:               // fix our uploads by moving the caption to the proper field     add_action('add_attachment', function ($post_ID) {         // this is triggered after an attachment is uploaded and before the attachment form gets displayed         $post = get_post($post_ID);         $post->post_excerpt = $post->post_content;         $post->post_content = NULL;              wp_update_post($post);     });      **My question is, how do I hook into WordPress so that when I upload a photo, (say foo.jpg, or foo_x2.jpg) it checks if foo_large.jpg already exists and if so, just adds a new size to that photo's '_wp_attachment_metadata' key in the wp_postmeta table instead of creating a new entry in the library/database?** For what it's worth, I can see from the wp_posts table in the database that the _large.jpg file is always uploaded first, followed by the thumbnails. (Keep in mind, the large photo is the one with all the metadata (caption, title, exif info, IPTC, etc.) I'm also not concerned about making this retroactive, just a solution that will apply to all uploads going forward. Thanks!


Get file headers in custom file

in my one of my plugins i have modules (kind of like plugins in a plugin), is there a function like `get_plugin_data()` or `wp_get_theme()` that will allow me to get the header section of a custom file (by passing the path as a parameter)? By heading section i mean               /*         Plugin Name: Name Of The Plugin         Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates         Description: A brief description of the Plugin.         Version: The Plugin's Version Number, e.g.: 1.0         Author: Name Of The Plugin Author         Author URI: http://URI_Of_The_Plugin_Author         License: A "Slug" license name e.g. GPL2     */      Thanks to @toscho the correct solution was               $default_headers = array(         'Module Name' => 'Module Name',         'Test Header' => 'Test Header',         );          $file_data = get_file_data(dirname(__file__).'/some-file.php', $default_headers);          print_r($file_data);


WordPress Query String: get_posts('cat=5') vs WP_Query( 'cat=5') vs URL: /site/?cat=5

We can filter our posts with a URL query string: `http://mysite.com/?cat=5` We can also use a similar syntax for `get_posts('cat=5')` and `new WP_Query('cat=5')`.** `get_posts('param=value');` just passes the string to `new WP_Query('param=value');`, so it follows that these work the same. While these all seem to have the same syntax, the URL query string supports different parameters.   * I don't see `subpost` or `subpost_id` documented anywhere in the WP_Query class, yet it seems to do something with the URL (although I can't figure out exactly what)   * `category__in` doesn't work with the URL query string. After much searching, I finally found this site that lists the supported URL query string variables, but not sure what all of them do. Where is the documentation for these URL query string variables? WP_Query supports many more parameters that don't seem to be supported in the URL query. Why doesn't the URL query string just get passed directly to WP_Query?


Should I create multiple sidebars, or use or one dynamic sidebar with logic to determine it's abilities?

I am wondering what the standard procedure for Sidebars in WordPress. My theme needs to have 3 different types of sidebars, to be used on three different pages. I am wondering if I should create a seperate sidebar for each of these pages or use logic, to determine which form it will take? As stated earlier each sidebar will have different uses for each page template it is on.


Require login for specific templates

I have specific templates to request login. I tried these three versions on functions.php file. ## `#`1 This is not working. I had to do `add_action( 'wp_head', 'template_login_permit' );` Because I put template directory? if I put 'wp_head', auth_redirect(); is not working.               function template_login_permit() {     if (          is_page_template('templates/tpl-aa.php') ||          is_page_template('templates/tpl-bb.php') ||           is_page_template('templates/tpl-cc.php') ||           is_page_template('templates/tpl-dd.php') ||           is_page_template('templates/tpl-ee.php') ||           is_page('shop')         ) {               //echo "ok";         //auth_redirect();              if ( !is_user_logged_in() ) {                  //wp_redirect('/login');                  auth_redirect();                  echo "ok";              }     }          }        add_action( 'init', 'template_login_permit' );      ## `#`2 `add_action( 'wp', 'login_redirect' );` wp are for all of templates, right? then how can I setup for only specific templates?                   // Redirect users who arent logged in...     function login_redirect() {       // Current Page       global $pagenow;       // Check to see if user in not logged in and not on the login page       if(!is_user_logged_in() && $pagenow != 'wp-login.php')             // If user is, Redirect to Login form.             //auth_redirect();           echo "";      }      // add the block of code above to the WordPress template       add_action( 'wp', 'login_redirect' );      ## `#`3 This for just testing for custom Login page I have.               add_action('init','possibly_redirect');          function possibly_redirect(){      global $pagenow;     if( 'wp-login.php' == $pagenow ) {      wp_redirect('/login');      exit();        }       }      * * * Is there any way to request "login"(I have custom login page) for specific templates?


Wordpress no longer holding post formatting

When creating a new post, by entering either manually or pasting from another document, TinyMCE (the default WordPress editor) does not seem to hold any type of formatting. For instance I create a two paragraph entry. When viewing it on the page it will come through as a single chunk of text within `<div class="entry-content">`. It's forcing me to have to revisit posts quite a bit and manually entering paragraph tags `<p>`. I'm unsure what's causing this issue. Any help would be appreciated.


Getting metabox value?

I have a custom metabox made using the code from Wordpress Reference: http://codex.wordpress.org/Function_Reference/add_meta_box               <?php     /* Define the custom box */          // WP 3.0+     // add_action('add_meta_boxes', 'myplugin_add_custom_box');          // backwards compatible     add_action('admin_init', 'myplugin_add_custom_box', 1);          /* Do something with the data entered */     add_action('save_post', 'myplugin_save_postdata');          /* Adds a box to the main column on the Post and Page edit screens */     function myplugin_add_custom_box() {         add_meta_box(              'myplugin_sectionid',             __( 'My Post Section Title', 'myplugin_textdomain' ),             'myplugin_inner_custom_box',             'post'          );         add_meta_box(             'myplugin_sectionid',             __( 'My Post Section Title', 'myplugin_textdomain' ),              'myplugin_inner_custom_box',             'page'         );     }          /* Prints the box content */     function myplugin_inner_custom_box() {            // Use nonce for verification       wp_nonce_field( plugin_basename(__FILE__), 'myplugin_noncename' );            // The actual fields for data entry       echo '';            _e("Description for this field", 'myplugin_textdomain' );       echo ' ';       echo '<input type="text" id="myplugin_new_field" name="myplugin_new_field" value="whatever" size="25" />';     }          /* When the post is saved, saves our custom data */     function myplugin_save_postdata( $post_id ) {            // verify this came from the our screen and with proper authorization,       // because save_post can be triggered at other times            if ( !wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__) ) )           return $post_id;            // verify if this is an auto save routine.        // If it is our form has not been submitted, so we dont want to do anything       if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )            return $post_id;                 // Check permissions       if ( 'page' == $_POST['post_type'] )        {         if ( !current_user_can( 'edit_page', $post_id ) )             return $post_id;       }       else       {         if ( !current_user_can( 'edit_post', $post_id ) )             return $post_id;       }            // OK, we're authenticated: we need to find and save the data            $mydata = $_POST['myplugin_new_field'];            // Do something with $mydata        // probably using add_post_meta(), update_post_meta(), or        // a custom table (see Further Reading section below)             return $mydata;     }     ?>      And I'm not sure how to display it's value on each page?               <?php               $meta = get_post_meta($post->ID, 'myplugin_new_field');               var_dump($meta);          ?>      Gives: > array(0) {} In addition, metabox field doesn't update it's value after clicking updating post/or page. That's because input value="whathever" while it should be something like the code above. Any ideas? Thank you! [edit] Final code that is not updating inputs value:               /* Define the custom box */     add_action('add_meta_boxes', 'myplugin_add_custom_box');          // backwards compatible     add_action('admin_init', 'myplugin_add_custom_box', 1);          /* Do something with the data entered */     add_action('save_post', 'myplugin_save_postdata');          /* Adds a box to the main column on the Post and Page edit screens */     function myplugin_add_custom_box() {         add_meta_box(              'metabox_sidebar_select',             __( 'My Post Section Title', 'myplugin_textdomain' ),             'myplugin_inner_custom_box',             'post'          );         add_meta_box(             'metabox_sidebar_select',             __( 'My Post Section Title', 'myplugin_textdomain' ),              'metabox_sidebar_select',             'page'         );     }          /* Prints the box content */     function myplugin_inner_custom_box() {            // Use nonce for verification       wp_nonce_field( plugin_basename(__FILE__), 'myplugin_noncename' );            // The actual fields for data entry       echo '';            _e("Description for this field", 'myplugin_textdomain' );       echo ' ';       echo '<input type="text" id="myplugin_new_field" name="myplugin_new_field" value="'.get_post_meta($post->ID, 'myplugin_new_field',true).'" size="25" />';       }          /* When the post is saved, saves our custom data */     function myplugin_save_postdata( $post_id ) {            // verify this came from the our screen and with proper authorization,       // because save_post can be triggered at other times            if ( !wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__) ) )           return $post_id;            // verify if this is an auto save routine.        // If it is our form has not been submitted, so we dont want to do anything       if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )            return $post_id;                 // Check permissions       if ( 'page' == $_POST['post_type'] )        {         if ( !current_user_can( 'edit_page', $post_id ) )             return $post_id;       }       else       {         if ( !current_user_can( 'edit_post', $post_id ) )             return $post_id;       }            // OK, we're authenticated: we need to find and save the data            $mydata = $_POST['myplugin_new_field'];            // Do something with $mydata        // probably using add_post_meta(), update_post_meta(), or        // a custom table (see Further Reading section below)            global $post;       update_post_meta($post->ID, myplugin_new_field, $mydata);             return $mydata;     }


Premium theme licensing of php called through AJAX

So, I've read through this question about licensing of PHP code under the GPL v2. As well as the compromise of the Thesis theme developer, as far as licensing all PHP under the GPL, but copyrighting js, css, images, etc. My question is does **ALL** php have to be GPL? Consider this scenario: >   * the php that generates the wp content/layout is under GPL >   * the JS is copyrighted (similar to the question linked above) >   * the JS makes AJAX requests to php code that generates certain data >   * this data-generating php code uses it's own datalayer (not wordpress's) > and uses no wordpress code. > Can the data-generating php (separated into a different folder within the theme) be licensed other than GPL?


update_post_meta and update_field ony working when saving the post

I use Advanced Custom Fields (ACF) to store data in a custom field. I had latitude and longitude information stored separately, but I they need to be in one custom field so I made the function below. `$query` just queries all the relevant posts.               <?php      $query = query_custom_posts(); if($query->have_posts()):      while ($query->have_posts()): $query->the_post();     if(get_field('map_lat') && get_field('map_lng')):          $lat = get_field('map_lat');     $long = get_field('map_lng');     $coord = $lat.','.$long;     $post_id = get_the_ID();          update_post_meta($post_id, 'map_coor', $coord);               endif; endwhile; wp_reset_query(); endif;          ?>      Now the function above works. The field map_coor gets populated with the lat and long separated by a comma (I can see the information in the field). The weird thing is that if I use `get_field('map_coor')` on the front-end nothing shows up. If I save the corresponding post, then the info DOES show up. In the function above I also tried to use the function `update_field` (from ACF) like this: `update_field($post_id, 'map_coor', $coord)` but the problem is still there. So my question is; do I need to alter the function above or just run a function which saves all posts? If the latter is the case; how do I do that? I've found the hook `save_posts` but I'm not sure how to let it run through all the posts.


dsIDX Pro Plugin and Juicebox Xml Error.

am having some issues with a dsIDX plugin and a file not found error. The plugin searches properties and lists them on a page, when you select to view the details of a property there is supposed to be a slideshow of the property. Instead I get this error: "Juicebox Error: Config XML file not found." I contacted support and was told that the reason is: > "We're calling plugins_url() which is located in wp-includes/link- > template.php. The function plugins_url() is what sets the pluginUrl based on > their configuration. So they or their developer can look at plugins_url() > and backtrack from there, why the pluginUrl is being set to an empty string > instead of the actual URL to the plugins directory." I echoed the plugins_url and it seems to be pointing to the correct plugin path location, so am not sure that's the issue. I am pretty stumped and don't know what this could be. I've google'd it and it's popped up in the forum quite a bit, and some solutions work like www.domain.com vs domain.com (without the www.) seem to be the issue. I am working off the ip address of the site and have yet to forward the domain to the location, so maybe that's the issue, but I doubt it since EVERYTHING else works, except the file not found. This is the part of the PLUGIN code that builds the slideshow               static function SlideshowXml() {                  $uriSuffix = '';                  if (array_key_exists('uriSuffix', $_GET))                      $uriSuffix = $_GET['uriSuffix'];                            $urlBase = $_GET['uriBase'];                            if (!preg_match("/^http:\/\//", $urlBase))                      $urlBase = "http://" . $urlBase;                  $urlBase = str_replace(array('&', '"'), array('&', '"'), $urlBase);                            header('Content-Type: text/xml');                  echo '<?xml version="1.0"?><gallery><album lgpath="' . $urlBase . '" tnpath="' . $urlBase . '">';                  for($i = 0; $i < (int)$_GET['count']; $i++) {                      echo '<img src="' . $i . '-medium.jpg' . $uriSuffix . '" tn="' . $i . '-medium.jpg' . $uriSuffix . '" link="javascript:dsidx.details.LaunchLargePhoto('. $i .','. $_GET['count'] .',\''. $urlBase .'\',\''. $uriSuffix .'\')" target="_blank" />';                  }                  echo '</album></gallery>';              }      Any ideas are appreciated.


How to disable the single view for a custom post type?

I created a custom post type:               register_post_type('sample_post_type',array(         'labels' => array(             'name' => _x('Sample Posts', 'post type general name'),             'singular_name' => _x('Sample Post', 'post type singular name')         ),         'public' => true,         'show_in_nav_menus' => false,         'exclude_from_search' => true     ));      How can i disable the single post view for this specific post type? Displaying a simple 404 is fine, or redirecting to the homepage. This is inside a plugin, so i can't create a single-sample_post_type.php file to setup an empty page.


Creating a navigation menu of all posts of a custom post type and their children posts?

I have a drop down menu that displays a link (the permalink) to all of the posts of a custom post type (county) and would simply like to display their children too this is the code I have so far but get_children is not working...
         <?php $menu = new WP_Query( array(             'post_type' => 'county',             'post_status' => 'publish',             'posts_per_page' => -1,             'order' => 'desc'         ) );         while ( $menu->have_posts() ) : $menu->the_post(); ?>
             <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                 <?php get_children(); ?>

         <?php endwhile; ?>
      this is the code that allows me to assign on custom post type as the parent of another               function show_parent_metabox() {         parent_select('county');     }          function parent_select ($parent_type) {         global $post;         global $wpdb;         $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = '{$parent_type}'         AND post_status = 'publish' ORDER BY post_title";         $results = $wpdb->get_results($query, OBJECT);         echo '<select name="parent_id" id="parent_id">';         echo '<option value = "">None</option>';         foreach ($results as $r) {             echo '<option value="', $r->ID, '"', $r->ID == $post->post_parent ? '    selected="selected"' : '', '>', $r->post_title, '</option>';         }         echo '</select>';     }


Wordpress SQL JOIN query

**Hi** Im trying to run 2 querys in the same query call.                       // send the query          global $wpdb;     $commentQ = "SELECT * FROM $wpdb->comments " . $whereClause . $orderBy;     $comments = $wpdb->get_results( $commentQ, ARRAY_A);      So far it works , but when i try to run 2 querys it fails. What I wanna do is i want to run:               **SELECT *     FROM `wp_88_commentmeta`     ORDER BY `wp_88_commentmeta`.`meta_value` ASC     LIMIT 0 , 30**      Im trying to get the meta_value only from that table. So my question is , how can i call 2 querys in the same call, and if theres i a better way to do that? **EDIT:** I want to JOIN $wpdb->comments with commentmeta. Im only trying to get the field "meta_value".                   global $wpdb;     $commentQ = "SELECT * FROM $wpdb->comments " . $whereClause . $orderBy;     $comments = $wpdb->get_results( $commentQ, ARRAY_A);          // build the string          $commentString = "";     $count = 0;     if( $comments ){         $first = true;         foreach( $comments as $row ){             if( $first ){                 // column labels                 foreach ( $row as $col => $value ){                         //$commentString .= $col . chr( 9 );      **After i join the tables i want to get "meta_value" from wp_commentmeta_88 and insert it instead of "comment_author"**                                   // Column Author                     if($col == 'comment_author') {                     $commentString .= 'User Meta        ';                     }                                 // Column IP                 if($col == 'comment_author_IP') {                     $commentString .= '   IP    ';                 }                             // Column date                 if($col == 'comment_date') {                     $commentString .= '                Datum    ';                 }                         // Column comment                 if($col == 'comment_content') {                     $commentString .= '                Meddelande   ';                 }                                                                 }                 $commentString .= chr( 13 );                 $first = false;             }


Get latest post revision with wp-query

How can I retrieve the latest revision post using wp-query? I am trying to replicate the behaviour as when a user updates a published post and clicks on preview. So far I've tried editing wp-query to return drafts, this works for unpublished posts but after the post is published I can not get any further edits. I've also looked at get children, though this did not return anything useful.


Managing users / external login

I've secured a new client who requires user login functionality but I've never done this sort of thing before so need some advice or recommendations of what plugins to use or if I need custom functionality. It will be a private quiz website where invited users will be asked to log in to a website so they can complete the quiz. The results of the quiz must be stored and must relate to that users login info. I don't want to use Wordpress's built in user accounts manager because I don't want quiz participants to be able to login to the CMS. How would I manage this, are there any good plugins you'd recommend?


Which template holds what to display when search returns nothing

Question is clear I guess. Normally, which template is returned when no search results are found. I would say search.php, but my parent theme's (twenty thirteen) search.php looks like this (slightly edited):               <?php if ( have_posts() ) : ?>
<?php printf( __( 'Search Results for: %s', 'twentythirteen' ), get_search_query() ); ?>
                       <?php /* The loop */ ?>         <?php while ( have_posts() ) : the_post(); ?>             <?php get_template_part( 'content', get_post_format() ); ?>         <?php endwhile; ?>              <?php twentythirteen_paging_nav(); ?>          <?php else : ?>         <?php get_template_part( 'content', 'none' ); ?>     <?php endif; ?>      So, what is the `none` after `content` in the third last line? What exactly is fetched from `content.php` then?


How to make CSS load live based on options clicked in the theme customizer?

I have a problem. I am trying get the theme customizer load a different CSS file based on what radio input in clicked, **live!** It works so far right now that option is saved when I click "Save & Publish" it only loads up when manually reload the entire customizer page. The preview panel is refreshed on select but not loads the selected CSS up and I don't know what actually makes Twenty Eleven do this but I like to have it this say too. I have looked at the Twentyeleven theme to code this. The differences are:   * The theme uses `option` for the settings and not `theme_mod` for it    * It has some settings handling but I think that's for its separate theme options page, I do not want that.   * It uses `enqueue scripts` to add its 'dark' theme on top of the normal theme and it's actually applied live if one clicks it, this is what I like to have too. How would I do this? Not sure how this actually works, it seems to store the option temporary only for the customizer and refresh it with the enqueued dark theme. I would be glad if you could help me figure out how to apply the CSS on the Customizer preview. For reference: Twentyeleven theme-options.php Here is the slimmed down version of of my plugin.               <?php     /**      * Plugin Name: S Skins      * Plugin URI:       * Description:       * Version: 1.0      * Author:       * Author URI:       * License: GPLv3+      */          add_action( 'plugins_loaded', array( 'S_Color_Themes', 'get_instance' ) );          class S_Color_Themes {              /**          * Plugin version, used for cache-busting of style and script file references.          *          * @since   2.6.0          *          * @var     string          */         const VERSION = '1.0.0';              /**          * Unique identifier for your plugin.          *          *          * The variable name is used as the text domain when internationalizing strings          * of text. Its value should match the Text Domain file header in the main          * plugin file.          *          * @since    1.0.0          *          * @var      string          */         protected $plugin_slug = 's-color-themes';              public $color_themes = array();              /**          * Instance of this class.          *          * @since    1.0.0          *          * @var      object          */         protected static $instance = null;              /**          * Initialize the plugin by setting localization and loading public scripts          * and styles.          *          * @since    2.6.0          */         private function __construct() {                  $this->get_color_themes();                  if ( is_admin () ) {                 add_action( 'customize_register', array( $this, 'wp_customize_register' ) );             }                  add_filter( 'stylesheet_uri', array( $this, 'stylesheet_uri' ), 10, 2 );         }              /**          * Return the plugin slug.          *          * @since    1.0.0          *          *@return    Plugin slug variable.          */         public function get_plugin_slug() {             return $this->plugin_slug;         }              /**          * Return an instance of this class.          *          * @since     1.0.0          *          * @return    object    A single instance of this class.          */         public static function get_instance() {                  // If the single instance hasn't been set, set it now.             if ( null == self::$instance ) {                 self::$instance = new self;             }                  return self::$instance;         }              public function stylesheet_uri( $stylesheet, $dir_uri ) {                  $color_theme = apply_filters( 's_color_theme', get_theme_mod( 's_skin' ) );                  if ( empty( $color_theme ) || 'default' == $color_theme || ! is_file( get_stylesheet_directory() . "/style-$color_theme.css" ) ) {                 return $stylesheet;             }                  return "$dir_uri/style-$color_theme.css";         }              public function wp_customize_register( $wp_customize ) {                  #remove_theme_mod( 's_skin' );                  $wp_customize->add_setting(                  's_skin',                  array(                     'default'    => '',                     'type'       => 'theme_mod',                     'capability' => 'edit_theme_options',                 )             );                  #show($color_theme_names);                  $schemes = array();             $choices = array();             foreach ( $this->color_themes as $color_theme ) {                      $schemes[$color_theme] = array(                     'value' => $color_theme,                     'label' => ucfirst( $color_theme ),                     'thumbnail' => get_template_directory_uri() . '/images/color-theme-thumbnails/' . $color_theme . '.png'                 );                      $choices[ $color_theme ] = ucfirst( $color_theme );             }                  $wp_customize->add_section(                 's-color-themes',                 array(                     'title'     => 'Color Themes',                     'priority'  => 1,                 )             );                  $wp_customize->add_control( 's_skin', array(                 #'label'    => __( 'Color Scheme', $this->plugin_slug ),                 'section'  => 's-color-themes',                 'settings' => 's_skin',                 'type'     => 'radio',                 'choices'  => $choices,                 #'priority' => 5,             ) );              }              public function get_color_themes() {                  $color_theme_files = glob( get_stylesheet_directory() . "/style-*.css" );                  if ( empty( $color_theme_files ) ) {                 return false;             }                  $this->color_themes = array( 'default' );                  foreach ( $color_theme_files as $file ) {                 $this->color_themes[] = str_replace( array( get_stylesheet_directory() . '/style-', '.css' ), '', $file );             }         }     }


WP Super Cache separate cache for mobile

I'm using the WP Super Cache plugin and inside my theme I have code that executes differently if the site is viewed on a mobile device (iOS, Android) than a desktop browser. How do make WP Super Cache create a separate cache for each, most likely via the user agent? Right now, I have use mod_rewrite to serve cache, which I believe WP Super Cache will cache the pages as html files to be served. Since the cache is saved from the desktop browser, the mobile browser is seeing that as well. I'd like WP Super Cache to generate two separate caches, one of mobile devices and another for desktop browser. Is this something WP Super Cache can handle or is there a better cache plugin I should be using to make this work? Thanks!


Modify the array of selected images in media modal

I'm creating a plugin which checks for duplicate media items on upload. If a file is uploaded, and it already exists in the media library, I'm presenting the user with the option to delete the uploaded file and insert the existing file instead. In the modal media window (the one that appears when clicking "Add Media" above the post editor) I've got everything working to detect the duplicate file, and offer a checkbox the user can click to delete the duplicate (via 'wp_ajax_save-attachment-compat'). After the user has deleted the new file, I need to find a way to modify the JavaScript array of currently selected media items, to replace the post ID of the deleted file with the post ID of the duplicate, so when the user clicks "Insert Into Post", the correct image will get inserted. Here's the scratch code I'm currently using. This is firing whenever a new selection is made in the default media modal.               ( function( $ ) {              var _AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay;         wp.media.view.Settings.AttachmentDisplay = _AttachmentDisplay.extend({             render: function() {                 _AttachmentDisplay.prototype.render.apply(this, arguments);                 selection = this.controller.state().get('selection').first().toJSON();                 //selection = this.controller.state().get('selection');                      filename = selection.filename;                      attachment = wp.media.attachment(id);  // get attachment with id                      console.dir(filename);                 console.dir(selection);             }         });          } )( jQuery );


Getting post-thumbnails from another WP site

I have two WordPress installations, one at http://inversekarma.in and the other at http://inversekarma.in/photos. The latter is a photoblog, and its theme uses the standard WP post thumbnails ( **EDIT:** featured images, to be precise!). Is there a way to show the most recent thumbnails from the second site on my first site's sidebar?


Infinite loop problem with the WordPress MU Domain Mapping plug-in

When I'm logged out, everything works fine. When I'm logged in, I'm unable to visit the front-end of my site. My main page is actually located in a sub-folder of my multisite installation: http://beta.eamann.com/mindshare/. I'm mapping a domain to this installation: http://mindsharestrategy.com/. When I'm logged in, the front-end of my site keeps bouncing back and forth between these two domains. I can still get to the admin side just fine ... but not the front-end. If I log out, I can view the front-end of things just fine. I'm using the development version of the plug-in, as I was instructed to do by several conversations with the developers. Ideas? I should also note that the other sites on this network are not having this issue. They are working properly:   * http://eamann.com -> http://beta.eamann.com/portfolio/   * http://prosepainting.com -> http://beta.eamann.com/creative/ There is no infinite redirect loop here. What can I check to fix the problem?