title: Weird problem on if statement

text: I'm facing a weird issue trying to do what I'm going to explain now. **Context**   **Plugins I'm using:** Custom Post Type UI / Advanced Custom Fields Functionality: I have a custom post type called "vendors". Within this post type I have several custom fields made on ACF. One of these fields is Called "Promote to Homepage" which is set as a checkbox. So the idea is simple, if that checkbox is checked show that post on the homepage. So this seemed to work fine, but when I tried to change that "Highlighted Vendor" to another one (unchecked current, checked desired to avoid conflicts I found that the post I was setting as featured wasn't showing, nothing was shown. I started testing then trying with other vendor posts, to find that this behavior is completely random, some of them published correctly to homepage, some others not. I tried to find out a pattern to identify what might be causing it and failed. Also tried to replicate the settings of a vendor that was failing to publish within a vendor that was publishing fine, and even setting the exact same things the vendor was still publishing. Finally I should mention that I have a page where I'm listing some kind of "directory" where all vendors are being shown. I added a simple code to check if the "promote_to_homepage" output was correct, something like "if the checkbox is checked, say hi" and found that the posts that aren't showing on homepage, pass the test on directory page. I'm running out of ideas about what this could be, that's why I'm trying here if someone can bring me some help. The code I'm using in the homepage is simple:               <?php query_posts('post_type=vendors');     while (have_posts()):the_post();      $featured = get_field('promote_to_homepage', $post -> ID, true);     if ($featured){?><!-- show the content here -->     <?php }; endwhile; ?>      That's all. Thanks in advance to anyone that can help me on this. Juan.-


title: wp_page_menu not working right?

text:
I try to create simple menu in custom theme. WordPress version is 3.9.1 So I taking code from here http://codex.wordpress.org/Function_Reference/wp_nav_menu, just change menu and container class / id for better debuging.               <?php                 wp_nav_menu(                     array(                         'theme_location'  => '',                         'menu'            => '',                         'container'       => 'div',                         'container_class' => 'container_class',                         'container_id'    => 'container_id',                         'menu_class'      => 'menu_class',                         'menu_id'         => 'menu_id',                         'echo'            => true,                         'fallback_cb'     => 'wp_page_menu',                         'before'          => '',                         'after'           => '',                         'link_before'     => '',                         'link_after'      => '',                         'items_wrap'      => '
%3$s
',                         'depth'           => 0,                         'walker'          => ''                     )                 );             ?>      But it creates this code:

                 Пример страницы

      Instead of expected this:

                 Пример страницы

      What i do wrong? Thank you. **UPDATED** I already has this code at fuctions.php:               <?php          function bd_setup() {         register_nav_menu( 'primary', __( 'Primary Menu' ) );     }          add_action( 'init', 'bd_setup' );      **SOLVED** After creation Menu in Appearance->Menu and assignation it in Appearance->Menu->Manage Locations I got expected code.


title: echo is just displaying the word 'array', rather than the array

text: I'm trying to see the structure of an array, but when I try to `echo` the array, all it says is 'array'. Please can someone explain how I can see the structure of an array?               add_shortcode('book', 'ac_post_meta_shortcode' );       function ac_post_meta_shortcode() {                $mpdata = get_post_meta( 31, 'custom_repeatable', true );            echo $mpdata;       }


title: How To extend WP_Customize_Control

text:
I'm looking for a way to add a new kind of control to the customize _live preview_ panel. I have seen how to add new sections to the panel using `add_action( 'customize_register'...` The control I want to implement is a different kind of color picker. In a previous post, we see how to extend core classes to add widgets, but what I lack here is a hook that will enable me to bring my object into scope - WP_Customize_Palette_Control. At You can see the beginnings of the code here. This code is in the `functions.php` file of my theme. Thanks for any help. Rob Just updated the code. Now I have `require_once` to bring in the classes. So now I have no PHP errors but my new control HTML does not appear.               <?php          require_once( ABSPATH . WPINC . '/class-wp-customize-setting.php' );     require_once( ABSPATH . WPINC . '/class-wp-customize-section.php' );     require_once( ABSPATH . WPINC . '/class-wp-customize-control.php' );          class WP_Customize_Palette_Control extends WP_Customize_Image_Control {               public $type    = 'palette';             public $removed = '';             public $context;                  public function enqueue() {                     //wp_enqueue_script( 'wp-plupload' );             }                  public function to_json() {                     parent::to_json();                          $this->json['removed'] = $this->removed;                          if ( $this->context )                             $this->json['context'] = $this->context;             }                  public function render_content() {                     ?>                                                  <?php echo esc_html( $this->label ); ?>
                                     <?php _e( 'Upload' ); ?>                                     <?php _e( 'Remove' ); ?>
                                          <?php             }     }          //new WP_Customize_Palette_Control();               //add_action('customize_controls_init', 'WP_Customize_Palette_Control');          // add an option to the customize panel          function sci_customize_controls_init($wp_customize) {         $wp_customize->add_section( 'themename_color_scheme', array(             'title'          => __( 'Color Scheme', 'themename' ),             'priority'       => 35,         ) );              $wp_customize->add_setting( 'themename_theme_options[color_scheme]', array(         'default'        => 'some-default-value',         'type'           => 'option',         'capability'     => 'edit_theme_options',     ) );               $wp_customize->add_control( 'themename_color_scheme', array(         'label'      => __( 'Color Scheme', 'themename' ),         'section'    => 'themename_color_scheme',         'settings'   => 'themename_theme_options[color_scheme]',         'type'       => 'palette',         'choices'    => array(             'value1' => 'Choice 1',             'value2' => 'Choice 2',             'value3' => 'Choice 3',             ),     ) );          }          add_action( 'customize_register', 'sci_customize_controls_init' );


title: static front page ONLY for certain themes?

text: A theme I am developing depends on there being a static front page. However, there seems to only be one global option to change if front page is static. So when I go to preview the theme, it won't work because the front-page option is off. But I don't want to change the front-page option because the live site will be affected. Is there a way to change that setting only when certain themes are being viewed?


title: How do I use wp_query for WordPress search?

text: I would like to create a custom search form to search posts based on the values of about 4 custom fields. I tried using wp_query to achieve this but so far my biggest problem is that the I don't get any results when searching for data in custom fields - even for data that I am sure exists. Also, I can't figure out how to remove the normal WordPress "keyword" search box and use just my four combo boxes. Here is the code from my search.php file: http://pastie.org/private/jhgsmaolvjyswyhsfphlfa   and here's the code from my searchform.php: pastie.org/private/o3hrtqajh8hbkiht1nyoba   Here is an image of the form layout: http://i.stack.imgur.com/N8ncg.png Thanks.


title: Wordpress Plugin Look & Feel

text: Is there a list of the ID's and Classes I can give HTML elements in the admin panel in order to closely mimic the wordpress look and feel?


title: Is there any good way to use SVN for uploads directory?

text: We just got our servers set up with SVN which works great. Wordpress upgrades and plugin installations are managed manually, which all goes through SVN as well, but I can't work out a good way to version control upload directories. The best solution I can think of is to periodically go into the folders, look through the images to make sure they are legitimate (no self-unpacking shell scripts, etc) and commit them... either that or svn:ignore the entire folder. Is there a better way to do this? All the discussion I can find on Google has to do with using SVN for Wordpress installs, not dynamically managed assets.


title: Specify a Page as the parent to the CPT Archive

text: I have an "About Us" page on my site with some child pages. I have created a "History" custom post type, where the rewrite slug is 'history'. I use archive-cpt_history.php as the template file for that CPT. Everything works exactly as its configured, I can go to website.com/history/ to see my CPT loop in all its glory. The issue is, I need this history CPT to be a child of About Us. How can I rewrite the slug to be /about-us/history so that it works with the archive / landing page? I can do this:               'rewrite' => array( 'slug' => '/about-us/history', 'with_front' => false ),      But that only works with the single posts, not the archive / landing page. Any help would be greatly appreciated. Also, in case this is relevant, once I have solved this issue single- cpt_history.php will simply use " header( 'Location: ' . site_url('') ); " to redirect users back home. There is never any permalink to the individual History post. The design just doesn't work like that. The History landing page will always show all posts in the CPT.


title: Posts limit on homepage (genesis framework)

text: in home.php               // NOT working     query_posts('show_posts=3');          // NOT working     add_action( 'pre_get_posts',  'set_posts_per_page'  );     function set_posts_per_page( $query ) {              $query->set( 'posts_per_page', 3 );              return $query;          }          genesis();      I searched a lot, almost always they say the 2nd solution. But i does not work for me, maybe because its genesis. Or is this outdated? I don't want to use the custom grid stuff i just want to limit the posts on one page (the homepage in this example) solution thx to @Milo: its just working in functions.php and there i need a additional if is_home               /** reduce number of posts on homepage **/     add_action( 'pre_get_posts',  'set_posts_per_page'  );     function set_posts_per_page( $query ) {              if ( is_home() )             $query->set( 'posts_per_page', 3 );              return $query;     }


title: How to make WP_Query not to show irrelevant posts?

text: I'm using the following `WP_Query` arguments array:               $args = array(  'post_type' => POST_TYPE,                                 'tax_query' => array(                                     'taxonomy' => TAX,                                     'field' => 'slug',                                     'terms' => TERM                                 ),                                 'posts_per_page' => 2                             );      The problem is this query displays all the posts from `POST_TYPE` which have a `TAX` (any `TAX`) assigned to them but it's not limiting it to the `TERM` (particularly one term) taxonomy!   I just want the posts from the specific `TERM` taxonomy and nothing more!


title: Make assigning post to a specific category equivalent to assigning it to all categories

text: _Allow me to explain with an example, for the sake of clarity. Please take the time to **read it all to get a good idea** of what I am exactly after._ On my WordPress site categories are used as **Editions** and there are 4 of them — Category (slug):   * US (main)   * UK (uk)   * India (in)   * International (intl) The permalink structure is `/%category%/%year%/%monthnum%/%day%/%postname%/`. With this permalink structure in place, a post assigned to more than 1 category will be accessible via any of the category slugs in the permalink. For example, if a post is assigned to US and UK categories, it'll be accessible via both of these URLs (no redirection):               http://example.com/main/2013/11/01/sample-post/     http://example.com/uk/2013/11/01/sample-post/      **Points of note:**   1. The permalink will still only include the slug of the category with the lowest ID.   2. If you try using the slug of a category that the post is not assigned to, it'll redirect back to the permalink. For instance, these two (note `intl` and `in`):              http://example.com/intl/2013/11/01/sample-post/     http://example.com/in/2013/11/01/sample-post/      Will redirect back to the permalink, i.e.              http://example.com/main/2013/11/01/sample-post/      **The problem:** For those posts that I want to be shown in all Editions (categories in my case), I can check all categories when publishing the post. But that'd cause problems later on when I add more editions, i.e. the old posts won't be shown under the new Editions/categories. So I use this custom function to suit my needs:               add_filter('pre_get_posts','better_editions_archive');     function better_editions_archive( $query ) {         if ( $query->is_tax( 'category' ) && $query->is_main_query() ) {             $query->set( 'post_type', array( 'post' ) );             $query->set( 'tax_query',                 array(                     'relation' => 'OR',                     array(                         'taxonomy' => 'category',                         'field' => 'slug',                         'terms' => 'intl',                         'operator' => 'IN'                     )                 )             );         }         return $query;     }          /*      * Based on:      * http://wordpress.stackexchange.com/a/90573/10691      */      With that function in place, when I want a post to be displayed in all Editions (categories), I can simply assign the post to _International (intl)_ category and voila! The problem is, now the post is only accessible via **its** permalink i.e. `http://example.com/intl/2013/11/01/sample-post/`. But I want it to be accessible (with no redirection) via all the category slugs, i.e.               http://example.com/main/2013/11/01/sample-post/     http://example.com/uk/2013/11/01/sample-post/     http://example.com/in/2013/11/01/sample-post/      * * * _**Reason:** In each Edition (category) archive, I want all the posts' links to start with that specific category's slug i.e. if the archive URL is `http://example.com/uk/`, I made sure that all post URLs'd look like this:_               http://example.com/uk/2013/11/01/sample-post-1/     http://example.com/uk/2013/11/01/sample-post-2/     http://example.com/uk/2013/11/01/sample-post-3/      _I used`str_replace()` for this, just so it's clear._ * * * Now, the question is, when a post is assigned to _International (intl)_ category, how can I make sure that it's accessible, without any redirection whatsoever, via all category slugs, **as if the post were assigned to all the categories**? Precisely, how do I make assigning a post to a specific category equivalent to assigning it to all categories?


title: How to allow Category Title to use <b> tags?

text: I'd like to be able to use               <b></b>      within my Category Title in Wordpress but the admin strips them out. I realise I can make the whole title bold using css but I only want it to apply to certain words. Is there a way of enabling this? Thanks for any help in advance.


title: How to show recents topics below the forum's title (Wordpress + bbPress plugin)?

text:
I'm not very familiar with the bbPress plugin. I would like to list two or three recent topics below the title of the forum (as well as the number of their replies): ![enter image description here](http://i.stack.imgur.com/RXZYB.png) This is **loop-bbp_forums.php** :               <?php          /**      * Forums Loop      *      * @package bbPress      * @subpackage Theme      */          ?>          <?php if ( bbp_has_forums() ) : ?>

                     <?php _e( 'Forum', 'bbpress' ); ?>	                     <?php _e( 'Topics', 'bbpress' ); ?>	                     <?php _e( 'Replies', 'bbpress' ); ?>	                     <?php _e( 'Freshness', 'bbpress' ); ?>

 <?php // @todo - Moderation links ?>

                      <?php while ( bbp_forums() ) : bbp_the_forum(); ?>                          <tr id="bbp-forum-<?php bbp_forum_id(); ?>" <?php bbp_forum_class(); ?>>                                                           <a class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?>" title="<?php bbp_forum_title(); ?>"><?php bbp_forum_title(); ?>                                  <?php bbp_list_forums(); ?>
<?php the_content(); ?>
                         	                              <?php bbp_forum_topic_count(); ?>	                              <?php bbp_forum_reply_count(); ?>	                                                                <?php bbp_forum_freshness_link(); ?>
                                      <?php bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'size' => 14 ) ); ?>

                      <?php endwhile; ?>
          <?php endif; ?>


title: How to create a custom nested loop in bbPress (Wordpress + bbPress plugin)

text: This is how you do it for Wordpress posts:                  $my_query = new WP_Query( "cat=3" );        if ( $my_query->have_posts() ) {             while ( $my_query->have_posts() ) {                 $my_query->the_post();                the_content();            }        }        wp_reset_postdata();      I would like to know how to do that in bbPress (say, listing topics).


title: How to replace standart comment count with Disqus?

text: in my blog comments show 0, and not real numbers of comment count. Now this is my code: `<?php comments_number('0 Comment', '1 Comment', '% Comments'); ?>` How to fix that?


title: How to hide woocommerce theme support notice

text: I have Woocommerce installed in a Wordpress Network, and a demo network website has theme Twenty Fourteen activated. I see the notice: > Your theme does not declare WooCommerce support – if you encounter layout > issues please read our integration guide or choose a WooCommerce theme :) > > Theme Integration Guide | Hide this notice. I have already created a woocommerce.php file in the Twenty Fourteen theme, and uploaded it, but this notice remains. I want new network users to not have to see this notice when a woocommerce.php file has already been uploaded to the active theme's folder. How do I do this? Is the "hide notice" variable controlled by the presence of woocommerce.php? Is it a cookie generated by clicking on "hide notice" link? Is it a setting saved in wp_options? **Update:** I removed all site cookies, and the Woocommerce notice did not reappear. In wp_options, there is an entry:   * option name = woocommerce_theme_support_check   * option value = twentyfourteen   * autoload = yes Deleting this option does not make the Woocommerce notice reappear. It reappeared in the database after refreshing the Themes page in the Wordpress site, which had Twenty Fourteen as the active theme. I wonder if I just run an SQL script when a new network site is created, to generate an option for each theme, like the twentyfourteen entry above?


title: How to trigger 404 for custom query var?

text: How can you trigger a 404 when using custom query vars? I've got re-write rules written for a custom query var, but if you were to request a URL for the query var that should technically be a 404 it returns a normal WP page, but no content, because nothing technically exists for the URL.


title: Doing action based on input from options menu

text:
This is my first time writing plugin. I have managed to get options menu with the html form:               <?php     add_action('admin_menu', 'menu');     function menu(){         add_options_page("poster","poster",'manage_options',"poster",'option_page_html');     }     function option_page_html(){         ?>
             <form action="wp-content/plugins/poster/post-video.php" method="post">

Paste video url

                 <input type="text" size="100" name="url" />
                 <input type="submit" value="Post"/>             </form>
         <?php     }     ?>      I want to make a script which `insert_post` from the url I paste in the `input` field. It's not autoblogger, I just want to make it easier to embed some related videos which I now do manually. The problem is in the `form action="wp-content/plugins/poster/post-video.php"` part. It seems that wordpress search for that file only in `wp-admin` folder so it becomes `http://example.com/wp-admin/wp-content/plugins/poster/post-video.php` when I try to post, with error 404. I have tried `form action="<?php echo __DIR__."/post-video.php"?>"`, but when I post it goes to `http://example.com/var/www/wordpress/wp- content/plugins/poster/post-video.php"` How to get the right path for the `post-video.php` script inside plugin folder? Or is there some other method, built-in function?


title: Wordpress User Profile Upload - If page is saved file reset

text:
I have various different extra profile fields which I have set in functions.php however with the upload one if a user uploads an image and saves the form the image is set, however if they go back and edit another field it sets the image field to null. Here is the code I have in my functions.php file. Any help would be really appreciated.                    <?php          add_action( 'show_user_profile', 'extra_user_profile_fields' );     add_action( 'edit_user_profile', 'extra_user_profile_fields' );          function extra_user_profile_fields( $user ) {           $r = get_user_meta( $user->ID, 'picture', true );         ?>
<?php _e("Public Profile - Gallery", "blank"); ?>

             Picture	             <input type="file" name="picture" value="" />                      <?php //print_r($r);                      if (!isset($r['error'])) {                         $r = $r['url'];                         echo "";                     } else {                         $r = $r['error'];                         echo $r;                     }                 ?>

                     <?php     }          add_action( 'personal_options_update', 'save_extra_user_profile_fields' );     add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );          function save_extra_user_profile_fields( $user_id ) {          if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }          $_POST['action'] = 'wp_handle_upload';     $r = wp_handle_upload( $_FILES['picture'] );     update_user_meta( $user_id, 'picture', $r, get_user_meta( $user_id, 'picture', true ) );          }          }          add_action('user_edit_form_tag', 'make_form_accept_uploads');     function make_form_accept_uploads() {         echo ' enctype="multipart/form-data"';     }


title: Super post cleaner, could this be category specific?

text: I've used this plugin on many sites, and it works fine. It stops duplicate posts from being created, but the site I'm working on now is a pinterest clone, and it won't work with repins. The plugin is no longer supported, is why I'm here asking. Could this be made to work on only one category? I have one category that works as the blog, the rest of the categories are for the pinterest side of the site                function superPostCleaner(){              global $wpdb;              $prefix = $wpdb->prefix;                        $wpdb->query("DELETE a.*                   FROM ".$prefix."posts AS a                   INNER JOIN (SELECT Greater1.post_title, Titles.ID, Greater1.MinID FROM (SELECT post_title, MIN(ID) AS 'MinID', MAX(ID) AS 'MaxID' FROM ".$prefix."posts WHERE post_type = 'post' AND post_status = 'publish'                   GROUP BY post_title HAVING COUNT(post_title)>1) AS Greater1                   LEFT JOIN (SELECT post_title, ID FROM ".$prefix."posts) AS Titles                   ON Greater1.post_title = Titles.post_title WHERE ID > MinID) AS b ON a.ID = b.ID WHERE a.ID = b.ID");          }          add_action('publish_post', 'superPostCleaner');


title: WooCommerce Product Search Error

text:
I wanted to display product category,in product catalog on my WooCommerce site.I asked another question earlier to make this code working.I added this code on my content-product.php file.                   <?php        $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );        $parents = get_the_terms($term->parent, get_query_var('taxonomy') );             echo "
";        echo "In"." "." ";        foreach( $parents as $parent ) {        echo ''.$parent->name.'';         }       echo "
";       ?>      Everything is working perfectly on product catalog,but whenever i do a search i am getting this error " Invalid argument supplied for foreach()" . I am not that good with programming,i managed make the code working for product catalogs but it is not working with search.Please if anyone can help me,it will be greatly appreciated.


title: Recommended Post Structure for DB Storage

text: I'm trying to write a plugin that would help my local little league manage their league, and though I've read the New Table vs Post Meta question, it's still a bit unclear and I'm hoping someone here might be able to help. I have the CPT's (Teams, Players and Matches) as well as the taxonomies (seasons, divisions and positions) created, but my main concern is historical data and querying that data. Is the best way to store player statistics and things of that nature in a separate database table? Is there a scenario anyone could envision where storing that in post_meta would be superior?


title: user-new.php less detailed after WP3.1; how to revert?

text: I updated WP to 3.1, and one issue my organization (which uses WP in Network Mode) is having is the Add New User page in wp-admin is now much less detailed -- before it was more like profile.php, with the ability to set username, password and much more. Now, it's only username, password and role. Any idea how to revert this back? Our organization generally creates accounts for people instead of vice-versa? Thanks!


title: wp_verify_nonce doesn't return true on server when it matches the nonce

text: $.ajax({         type: "POST",         dataType: "text",         url: ajaxurl,         data: {                 action: "more_news",                 nonce: nonce,                 offset: offset         },         success : function(data, textStatus, jqXHR){             console.log( nonce );             console.log( data );             console.log( textStatus );         }     });      Checking for this AJAX request nonce locally works perfectly. As seen below, my console prints my nonce, "Awesome", and then "success".               9a91a5fdca     Awesome     success      When on my server, my console prints my nonce TWICE (thus proving to me they're exactly the same), then success.               e2ca4eca80     e2ca4eca80     success      I'm… confused… to say the least. How is this possible? and how do I solve it?               add_action( 'wp_ajax_more_news', 'more_news' );     add_action( 'wp_ajax_nopriv_more_news', 'more_news' );          function more_news(){         if ( !wp_verify_nonce($_POST['nonce'], 'more_news_nonce') ){             exit($_POST['nonce']);         }         echo 'Awesome';         die();     }


title: How to upload multiple images on frontend to ACF gallery using update_field

text: I'm trying to save images submitted on a frontend form in a way that they are accessible via the ACF backend. In how to upload an image on ACF with update_field on wordpress, someone provided a solution for a single image upload (and consequently a single ACF image field). I thought it should be pretty easy extending this to a multi image upload (and a ACF gallery field), but I get an error I can't track down: `Cannot redeclare wp_crop_image() in /../travel/wp-admin/includes/image.php on line 25` **in functions.php**               function RemapFilesArray($name, $type, $tmp_name, $error, $size)     {         return array(             'name' => $name,             'type' => $type,             'tmp_name' => $tmp_name,             'error' => $error,             'size' => $size,         );     }          function my_update_attachment($f,$pid,$t='',$c='') {       wp_update_attachment_metadata( $pid, $f );       if( !empty( $f['name'] )) { //New upload         require_once( ABSPATH . 'wp-admin/includes/file.php' );         include( ABSPATH . 'wp-admin/includes/image.php' );              $override['test_form'] = false;         $file = wp_handle_upload( $f, $override );              if ( isset( $file['error'] )) {           return new WP_Error( 'upload_error', $file['error'] );         }              $file_type = wp_check_filetype($f['name'], array(           'jpg|jpeg' => 'image/jpeg',           'gif' => 'image/gif',           'png' => 'image/png',         ));         if ($file_type['type']) {           $name_parts = pathinfo( $file['file'] );           $name = $f['name'];           $type = $file['type'];           $title = $t ? $t : $name;           $content = $c;                $attachment = array(             'post_title' => $title,             'post_type' => 'attachment',             'post_content' => $content,             'post_parent' => $pid,             'post_mime_type' => $type,             'guid' => $file['url'],           );                     foreach( get_intermediate_image_sizes() as $s ) {             $sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => true );             $sizes[$s]['width'] = get_option( "{$s}_size_w" ); // For default sizes set in options             $sizes[$s]['height'] = get_option( "{$s}_size_h" ); // For default sizes set in options             $sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options           }                $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );                foreach( $sizes as $size => $size_data ) {             $resized = image_make_intermediate_size( $file['file'], $size_data['width'], $size_data['height'], $size_data['crop'] );             if ( $resized )               $metadata['sizes'][$size] = $resized;           }                $attach_id = wp_insert_attachment( $attachment, $file['file'] /*, $pid - for post_thumbnails*/);                if ( !is_wp_error( $attach_id )) {             $attach_meta = wp_generate_attachment_metadata( $attach_id, $file['file'] );             wp_update_attachment_metadata( $attach_id, $attach_meta );           }             return array(       'pid' =>$pid,       'url' =>$file['url'],       'file'=>$file,       'attach_id'=>$attach_id        );         }       }     }      **on my form.php:**               <input type="file" name="upload_attachments[]">     <input type="file" name="upload_attachments[]">      **in process-form.php**               if ($_FILES['upload_attachment']){           $files = array_map('RemapFilesArray',      $_FILES['upload_attachment']['name'],      $_FILES['upload_attachment']['type'],      $_FILES['upload_attachment']['tmp_name'],      $_FILES['upload_attachment']['error'],      $_FILES['upload_attachment']['size']     );          $gallery=array();          foreach ($files as $file){ //loop through each file         $att = my_update_attachment($file,$site_id);         array_push($gallery,$att['attach_id']);     }     update_field('field_1231242',$gallery,$site_id);          }      I appreciate your help and ideas!


title: Disable title link in the backend for non-admins

text: I need to make posts not editable by non-admins in the backend, is there a way to disable the link in the title of the posts when they view the list of post published? Thanks!


title: Pushing stored procedure to a multisite database in WordPress

text: I am given a WordPress multisite and need to extract information from the site. I have written a stored procedure that recursively builds a tree relationship for posts of a certain kind. Now I am wondering how to push the stored procedure to the databases of all the sites.(Since this is a multisite configuration, each site(subdomain in this case) has a separate database.) Please help me in this regard. WordPress version: 3.5.1 Multisite config type: subdomains               //code needs refinement          DELIMITER //     CREATE PROCEDURE getPath(IN post_id INT, IN return_path TEXT)          BEGIN           DECLARE done INT DEFAULT 0;      DECLARE a INT;      DECLARE b TEXT;      DECLARE cur1 CURSOR FOR (SELECT * FROM TempTable112);           DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;      DROP TABLE IF EXISTS TempTable112;           SET max_sp_recursion_depth := 10;           CREATE TEMPORARY TABLE TempTable112 AS SELECT id,post_title FROM wp_101_posts WHERE post_parent = post_id and post_status='publish';           SET @s = CONCAT('SELECT * INTO OUTFILE ',"'", CONCAT('Sample',FLOOR(1000+RAND()*9999)),'.txt',"'",' FROM TempTable112');     PREPARE stmt2 FROM @s;     EXECUTE stmt2;     DEALLOCATE PREPARE stmt2;              OPEN cur1;          read_loop: LOOP         FETCH cur1 INTO a,b;         IF done = 1 THEN           LEAVE read_loop;         END IF;              SET return_path = CONCAT('/',return_path,b);          CALL getPath(a, return_path);       END LOOP;       CLOSE cur1;     END //          DELIMITER ;


title: Filter all queries with a specific taxonomy

text: Is there any way to filter all post queries and add a specific taxonomy? Case in point, I have a taxonomy object of "Region" with terms like "Global", "Americas", "Europe", etc. (Users designate their region in their user profile through custom fields which is stored as a usermeta value and added the user cache object.) The idea being that as the signed-in user navigates the site, they'd only see content designated within their region. Obviously I could write a custom query per page to include their region, but I was wondering if there was a way to tap into the query object and add the taxonomy requirement regardless of what the query was for (e.g, post, custom post type, archive page, etc.). Any help would be much appreciated! Thanks.


title: Help with wordpress custom query and advanced custom fields plugin

text: first of all sorry for my bad english. Let me explain what I`m trying to do: I have a column inside a SQL table with a string using the following format: yy-mm-dd The thing is, it doesn`t use a dateformat type. So, I have my query, where I need to capture all fields with the following specification: value <= '{$thisyear}-{$thismonth}-{$last_day}' any way that I can do that withoung having to change the field format? As long as the tables are generated by the plugin. Any help will be really appreciated, thank you guys!


title: Allowing style tag in TinyMCE editor

text: In cases i want to add individual styles for an element its easy i just add inline styles inside p tags, because _wp_add_global_attributes has style attribute.... but when i want to add tag itslef to target/select multiple elements TinyMCE editor removes it entirely... so I got inside core and found filter tiny_mce_before_init but i don't know how to add style tag to allowed tags array!!!!!!!


title: Add comment meta

text: I need to add my custom meta to the new comments. Here is what I've done :               /************************************************************************/     /*  Add meta to comments     /************************************************************************/     // Save field     add_action ('comment_post', 'add_meta_settings', 1);          function add_meta_settings($comment_id) {         add_comment_meta($comment_id, 'comment_section', $_POST['comment_section'], true);     }      This work when I create a new comment. But if I post a comment using the "Reply" (to another comment) link, the meta is not saved... After further investigation : On the same page, I have 3 comment threads. Each comment has a meta that tells in which tread they have to be displayed in. At the end of each thread, I have a form to post a comment in this specific thread and it adds the right meta. The problem is when I click the “Reply” link, it adds a form under the comment, but not the good form. It adds the first form that appears in the page, event if I reply a comment from the third thread. So the meta that is added with my new comment is not the good one… Is there a way to tell WordPress which form to use when I click the “Reply” link ? Could you help me ? Thanks !


title: Mechanism to send to users of secured WordPress install new notifications by SMS or email?

text: I have a family website, private, requires a WordPress account, in WordPress. Some of my family members would like to get the option for notifications of new posts by email or text message. Email seems easy enough, there are plugins and services for that. But I'm concerned about text messages because we are geographically spread out, and I would like the option to queue the messages so that they are sent to users only within hours they choose. External services or services based off RSS are not a great fit because the RSS feeds are not public and I'd like to keep it that way. Is there a plugin suited to these specific requirements?


title: Is there a way to hide WordPress behind a web visible directory?

text: Is there a way to hide WordPress behind a web visible directory for extra security using a symlink?


title: Splitting WordPress theme CSS into multiple files, good or bad?

text: I'm developing a WordPress theme framework. I want organize CSS for each section into separate files for the following reasons.   1. Developers can easily deregister styles by parent theme and load their own styles.   2. Easy to maintain.   3. I can load only the required styles based on the options selected by the user. Disadvantages Extra http requests => more load on the server. This disadvantage can be taken care by combining all the CSS files before they are served to the user using plugins like wp-minify. But, will this combining process out weigh the above advantages.


title: Filter my home page posts by category or by tag

text: Would like to filter my home page posts by category **OR** by tag. i.e. only posts that are in category "X" or have tag "B" appear on the home page. Have used code below successfully to filter (include/exclude) just by category               function exclude_category($query) {     if ( $query->is_home ) {     $query->set('cat', '3');     }     return $query;     }     add_filter('pre_get_posts', 'exclude_category');      then tried to add the tag filter by replacing `$query->set('cat', '3');` with `$query->set(('cat', '3')||(is_tag('urgent'));` no good - did not work. Can this be done ? How ? Any ideas, help or advice much appreciated


title: Database custom table issues - incorrect result displayed

text:
First things first: I've spent most of today going over these forums; the stackoverflow forums; the php.net manual; and a bunch of random sites I found through Google Search - so, if I've missed the answer and it seems like I'm asking an already answered question I'm sorry. I've probably just been looking at the same problem for way too long and nothing is making sense. The background: We've inserted some custom tables into the wordpress database, so I can connect to these tables through $wpdb. The code for the working connections is as follows:               global $wpdb;     // get list of localities     $localityRow = $wpdb->get_results( "SELECT * FROM tblYBSLocality ORDER BY Name ASC" );     // get list of schools     $schoolRow = $wpdb->get_results( "SELECT * FROM tblYBSSchool ORDER BY Name ASC" );     // get school ID if form has been submitted     $SelectedSchoolID = $_GET['schools'];     // get location ID if form has been submitted     $SelectedLocationID = $_GET['localities'];      Then later in my page I make it do stuff (scorcery!)               // Create a drop down box for the user to select their location (and one has been done     // for school but I left that out because you get the idea     <select name="localities" style="width: 300px">     <?php     foreach ($localityRow as $locality) {     $LocalityID = $locality->LocalityID;     $LocalityName = $locality->Name;     ?>          <option value=<?php echo $LocalityID; ?> <?php if(isset($SelectedLocationID) &&     $SelectedLocationID == $LocalityID) print(" selected")?>><?php echo $LocalityName;?>     </option>     <?php     }     ?>     </select>      Note - Yes I know using * is bad, I'll fix that later - right now I just want it to work. Using this I can then go through and generate a bunch of stuff using the following:               // get school ID if form has been submitted     $SelectedSchoolID = $_GET['schools'];     // get location ID if form has been submitted     $SelectedLocationID = $_GET['localities'];      This isn't really important to the rest of my issue, so I'll move on. The issue: I'll start with the code. This is supposed to connect to some other tables and do stuff - based on the connections and data retrieved above:               $selectedSchoolName = $wpdb->get_results( "SELECT Name FROM tblYBSSchool WHERE     SchoolID=".$SelectedSchoolID );     // get selected location name     $selectedLocationName = $wpdb->get_results( "SELECT Name FROM tblYBSLocality WHERE     LocalityID=".$SelectedLocationID );     // get route ID     $getRouteID = $wpdb->get_results( "SELECT * FROM tblYBSRoute WHERE RouteID IN ( SELECT     RouteID FROM tblYBSRouteSchool WHERE SchoolID     =".$SelectedSchoolID.")".$SelectedLocationID);      Now, I THINK the issue comes with the ".$SelectedSchoolID ); part (and the location one but this is already getting tldr). What I want to do later in the page (once the user has made their selections and submitted the form), is get results (fancy that!). There are 2 parts to the results: 1st I want to say "Search results for routes between:" the location name and the school name. 2nd, I want to display those results. But I can't even get past the 1st point, so let's fix that first. I have tried 3 different approaches:               // FIRST APPROACH     // This kinda works, it echoes the last locality name from the table     // which is better than nothing     <?php echo $LocalityName;?> and <?php echo $SchoolName;?>
          // SECOND APPROACH     // This gives me the white page of death. Which is hilarious because it's pretty     // much the exact same as what was used in the option - which worked     <?php if(isset($SelectedLocationID) && $SelectedLocationID == $LocalityID) echo     $LocalityName;?> and <?php if(isset($SelectedSchoolID) && $SelectedSchoolID ==     $SchoolID) echo $SchoolName;?>          // THIRD APPROACH     // This also gives me the white page of death. And now I'm out of ideas.     <?php if(isset($SelectedLocationID) && $selectedLocationName == $LocalityName     echo $LocalityName ;?> and <?php if(isset($SelectedSchoolID) &&     $selectedSchoolName == $SchoolName echo $SchoolName ;?>      In my head (HAH!) the last 2 should work. Am I correct in thinking that it's the ".$SelectedSchoolID ); part? Or have I forked something else up entirely? Sorry for the TLDRness, but I thought I should provide as much detail as possible. Any and all help is greatly appreciated. I'm going to go smack my head into the desk a few times now :P


title: WP Query posts__in not working with array

text: I am using the following code to generate a specific list of posts with `WP_Query`               $args = array (         'post__in'   => $cookie_array,         'post_type'  => 'tyre',         'post_status'    => 'publish',         'posts_per_page' => '100',     );      `$cookie_array` is an array I generate based on some values in a cookie (post id's). The problem is that for some reason the WP_Query won't display the post that corresponds to the last value in the array. For example if the array consists of 1,2,3 then my WP_Query only gets the posts with the id's 1 and 2. I've printed out the values of the array, right before I call the argument list shown above and there's definitely 1 more value listed than WP_Query is getting. Any ideas what's going on? ## Edit As per request the result of `var_dump($cookie_array)` \- to confirm only 3 items are shown through my WP_Query when the array is set as below:               array(4) { [0]=> string(5) "15829" [1]=> string(5) "22728" [2]=> string(5) "22734" [3]=> string(5) "22725" }       **`var_dump($getposts->request)` outputs:**                string(230) "SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (15829,22728,22734,22725) AND wp_posts.post_type = 'tyre' AND ((wp_posts.post_status = 'publish')) ORDER BY wp_posts.post_date DESC LIMIT 0, 100"


title: Any way to use a custom Parameter for youtube embed without using an iframe?

text: I do not want to display the titles of videos I embed on my wordpress site. The way I've been doing this is using the embed link, inserting the iframe in the wordpress post and adding the custom Parameter "showinfo=0" to the end of the url. This has worked well, until I decided to change the design of my site. I have had to use some custom css to change all the videos (almost 200) that I've done that to in order to fit the new design. If I would have known of a way just to drop the link into wordpress (like most people do) I wouldn't have had to use an iframe and wordpress would have adjusted the size of the video based on the setting entered in the media section. I'm hoping there is a better way to embed a Youtube video than the way I've been doing it (It would be great to just drop the link into wordpress instead of having to go through so many different steps in order to get the video to show up. Does anyone have any ideas how (of if it's even possible) to do this? I post a video every day, so it would really help my process if there was a way to do this. Thanks. `               <?php     load_theme_textdomain('standardtheme', get_template_directory() . '/lang');     $locale = get_locale();     $locale_file = get_template_directory() . '/languages/$locale.php';     if(is_readable($locale_file)):         require_once($locale_file);     endif;     add_theme_support('post-thumbnails');     require_once('admin/functions.php');     require_once('lib/standardtheme.php');     require_once('lib/pro-photo/pro-photo.php');          function Oembed_youtube_no_title($html,$url,$args){         $url_string = parse_url($url, PHP_URL_QUERY);         parse_str($url_string, $id);         if (isset($id['v'])) {             return '<iframe width="'.$args['width'].'" height="'.$args['height'].'" src="http://www.youtube.com/embed/'.$id['v'].'?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>';         }         return $html;     }     add_filter('oembed_result','Oembed_youtube_no_title',10,3);          ?>


title: AJAX returns response 0

text:
I'm trying to get user profile values using an AJAX call, but the response is always 0. Here's my PHP:               wp_enqueue_script( // Add JS to          'cc-author-change-post-author',         plugins_url( 'assets/js/change-post-author.js', dirname( __FILE__ ) ),         'jquery'     );     wp_localize_script( // Localize script for AJAX calls         'cc-author-change-post-author', // Name of script call being localized         'authorchange', // AJAX object namespace, used to call values in the JS file         array(             'ajaxurl'   => admin_url( 'admin-ajax.php' ), // URL for admin AJAX calls             'nonce'     => wp_create_nonce( 'cc-author-change-author-nonce' ) // Nonce to authenticate request         )     );          function cc_author_change_postauthor_callback() {         $nonce = $_POST['nonce']; // Assign a local variable for nonce              if ( ! wp_verify_nonce( $nonce, 'cc-author-change-author-nonce' ) ) { // If the nonce doesn't check out, fail the request             exit( 'Your request could not be authenticated' ); // Error message for unauthenticated request         }              if ( current_user_can( 'edit_others_posts' ) || current_user_can( 'edit_others_pages' ) ) { // Check for proper permissions before handling request             $author = $_POST['authorID']; // Assign local variable for submitted post author                  if ( $author ) { // If an author ID was provided, get the user's details                 $authordata = get_userdata( $author ); // Retrieve the selected user's data from their profile                      $authormeta = json_encode( array( // Encode data as JSON                     'display_name'  => $authordata['display_name'], // Display name from profile                     'description'   => $authordata['description'] // Biographical info from profile                 ) );             }             else { // If no author ID was provided, send back an error message                 $authormetaerror = 'No user ID provided. Please try again.'; // Error message to send back                 $authormeta = json_encode( array( // Encode as JSON                     'display_name'  => $authormetaerror,                     'description'   => $authormetaerror                 ) );             }                  echo $authormeta; // Return the values retrieved from the database         }              exit; // End response. Required for callback to return a proper result.     } // cc_author_change_postauthor_callback()     add_action( 'wp_ajax_cc_author_change_postauthor', 'cc_author_change_postauthor_callback' );      And here is my JavaScript:               jQuery( document ).ready( function( $ ) { // Don't execute anything until the page is loaded         $( "#cc_author_postauthor" ).change( function() { // If the author dropdown value is changed, execute the script             /* Data to pass to the server. Called below during $.post() */             var data = {                 action : 'cc_author_change_postauthor',             // Action hook for the server-side callback                 nonce : authorchange.nonce,                         // Nonce received from server to authenticate request                 authorID : $( "#cc_author_postauthor" ).val()       // author ID for retrieving profile data             };                  /* Send request to the server and process response */             $.post(                 authorchange.ajaxurl,                               // URL to send the request to the server                 data,                                               // Data to send to the server, stored in var data                 function( jsonString ) {                            // Script to execute upon successful response from server                     var authormeta = $.parseJSON( jsonString );     // Parse the JSON received from the server response                          $( "#cc_author_meta\\[0\\]\\[display_name\\]" ).val( authormeta.display_name ); // Change the value of the author display name to the value received from the server                     $( "#cc_author_meta\\[0\\]\\[description\\]" ).val( authormeta.description );   // Change the value of the author bio to the value received from the server                 } // function( jsonString )             ); // $.post         }); // $( "#cc_author_postauthor" ).change()     });      Here's the meta box where the form item is located:               function cc_author_metabox( $post ) {         /* Retrieve current values if they exist */         $cc_author_meta = get_post_meta( $post->ID, '_cc_author_meta', true ); // Author meta data (stored as an array)         $postauthorid = $post->post_author; // Get the user ID of the post author              /* If any of the values are missing from the post, retrieve them from the author's global profile */         if ( !$cc_author_meta ) {                    $postauthor = get_userdata( $postauthorid ); // Retrieve the details of the post author                  $cc_author_meta = array(); // Initialize main array             $cc_author_meta[0] = array( // Nested array for author data                 'display_name'  => $postauthor->display_name, // Set display name from post author's data                 'description'   => $postauthor->description // Set bio from the post author's data             );         }              /* Display the meta box contents */         ?>

Changes made to this information will only apply to this post, and will not be saved to the user's profile.
             <?php             if ( current_user_can( 'edit_others_posts' ) || current_user_can( 'edit_others_pages' ) ) { // Check the capabilities of the current user for sufficient privileges                 wp_dropdown_users( array(                     'name'          => 'cc_author_postauthor', // Name for the form item                     'id'            => 'cc_author_postauthor', // Class for the form item                     'selected'      => $postauthorid // Select the post's author to be displayed by default                 ) );                 ?>                                      You have JavaScript disabled. If you change the post author in the dropdown, you will need to save the post for the fields below to update. Please enable JavaScript for a better experience.
<img id="cc_author_postauthor_loading_img" class="cc_author_postauthor_loading_img" src="<?php echo plugins_url( 'assets/img/loading.gif', dirname( __FILE__ ) ); ?>" width="20px" style="width: 20px;">
                 <input type="hidden" name="cc_author_currentpostauthor" value="<?php echo $postauthorid; ?>">                 <?php             }             ?>             Name             <input type="text" name="cc_author_meta[0][display_name]" id="cc_author_meta[0][display_name]" value="<?php echo esc_attr( $cc_author_meta[0]['display_name'] ); ?>" />                  Bio                  <?             $descEditor = new ccAuthorDescEditor( $cc_author_meta[0]['description'], 'cc_author_meta[0][description]' ); // Create the bio editor object             echo $descEditor->editor(); // Display the editor             ?>
         <?php     }      I'm sure the answer is right in front of me, but this is my first time using the WordPress AJAX API. What am I doing wrong? You can see the entire plugin code at its Github repository.


title: Tools for Converting an Existing Website Design to a WordPress Template?

text: I know how to do it manually, but is there any tool to help me with that?


title: Home page of blog says "NOTHING FOUND It seems we can’t find what you’re looking for"

text: I'm using the Illustratr theme. On the home page of my blog it says:               "NOTHING FOUND. It seems we can’t find what you’re looking for. Perhaps searching can help.",       This appears since I created it. It only shows on that first page, which is static, and where I have only a gallery. Also when I post other content on that page, it stays there. I don't know much about the coding, so changing the template is not really an option... Thank you!


title: Use the WP media uploader dialog for uploading a form attachment (non-admin). Offering progress and drag and drop feedback

text: I am building a simple contact form (non-admin) that has an attachment field. Of course I can just handle the upload via WP's wp_handle_upload function. However, I would like to give my visitors a more user friendly experience and manage the upload via wp's media upload "pop-up". Offering them upload progress feedback, drag'n drop etc. I know that this is normally admin only but is there a way to use this upload dialog for normal (non-registered, non- logged in) users? I'm quite amazed that apparently no one really did this (after quite some searching). Thanx!


title: Changing pagination list class

text:
`paginate_links()` function returns unordered list with class named "page- numbers". How can I change this class? EDIT Currently, I am using the band-aid method below.               $return = paginate_links( $arg );     echo str_replace( "
", '
', $return );      Is there any better way?


title: How to set up year view for datepicker in The Events Calendar plugin?

text: I've installed this plugin: http://wordpress.org/plugins/the-events-calendar/ Everything is great except one thing, I can't find where I can change datepicker view. On front-end "Events-In" has this view when you click on it: http://screencast.com/t/eLUeN5tB How can I set up to year view like this: http://screencast.com/t/5z02EpQFCRod ?


title: Getting data from a table using a query

text: I’m starting with WordPress and I have a lot of problems and doubts. I’m trying to display on a page data stored in a table of my database. I have a table named Customers (id, name, surname, phone). Im adding code to the main page of the website: [php] $idCon = mysql_connect('localhost','user','password'); if(!$idCon){ echo "Error connecting database."; exit; } mysql_select_db("database",$idCon); $query = "SELECT * FROM CUSTOMERS"; global $respuesta = $wpdb->get_results($query); foreach( $respuesta as $row ) {                   echo $row->nombre;     }      $reg = mysql_fetch_row($res); mysql_close($idConn); [/php] But nothing is displayed in the page. Can you help me? By the way, how can i debug code in wordpress ? That should help me a lot. Thanks


title: Problem with correctly registering query variable

text: I have an admin page for my plugin, which lists records from database. I want to sort them under some conditions. To call different sorting options, I've decided to use query string. > Step 1: At the beginning of plugin code I have registered my query var `'bpc_sortby'` with:               add_filter( 'query_vars', 'add_query_vars_filter' );     function add_query_vars_filter( $qvars ){         $qvars[] = 'bpc_sortby';         return $qvars;     }      just like Codex said it should be done. > Step 2: On said admin page, I have created two links targetting the same page, but with an addition of query string to address:               Product ID     Name      > Step 3: When page is loaded it should check `if (isset($wp_query->query_vars['bpc_sortby']))` and if it's set, it should do some sorting stuff. Else, it should spit out 'Not working'. And, uhm, well... when I click one of links, it spit's out 'Not working' despite query args being added to links (well, at least they are visible in page address). And nope, I didn't forget about setting `global $wp_query`. I have spent last two days searching for working answer and I believe query_var from **step 1** is not getting registered, or it does, but for some reason it's removed somewhere later. What I have already tried and failed (all with DEBUG on):   * switching to one of default wordpress themes,   * playing with query var name,   * disabling all other plugins,   * deactivating and activating my plugin,   * `print_r( $wp_query->query_vars);` \- returns empty array(),   * `echo get_query_var( 'bpc_sortby' );` \- returns nothing,   * checking if query_var has been registered correctly, with help of function:              function qv_isset($var_name) {       $array = $GLOBALS['wp_query']->query_vars;       return array_key_exists($var_name, $array);     }     qv_isset ('bpc_sortby');      ...returns `FALSE` \- that's why I guess it's problem with `add_filter`, but I have no clue why it doesn't work as it should. **Question** : any idea why it doesn't work or what should I check? PS. I know that sorting can be done with some jquery/js magic, but I want to avoid using detours when there is a straight road ahead (just with some bumps). PS2. `echo $_GET['bpc_sortby']` returns proper value (`prodid` or `prodname`), but I've heard that I should avoid using $_GET directly and use query vars instead. Can anyone confirm it, or maybe it's not a problem as long as I use them on page which is available only for users with admin permissions? Cheers and sorry for my english, but It's not my native.


title: Cannot Save User Roles - Set a Role, says Updated, but no Change

text: thanks for reading my question. I have a Wordpress Site with Delicious Magazine Theme installed. In Users --> Edit User, I want to change a specific user's role to Contributor. When I make the change and save, I get the message "User Updated" but the role does not change. I even tried a new user registration. By default, it gets set to "No Role for this Site" and when I change it to Contributor and click Save, it just reverts back to "No Role for this Site." Anyone have any idea what's up here? Thanks!


title: How to populate custom tables with rows of data

text: I'm trying to populate a custom table called countries, with two rows of data. The custom table is created when the plugin is activated. The rows need to be added when the plugin is activated. The code for the custom table is fine, & the custom table is created. My code so far:               register_activation_hook( __FILE__, 'mp_insert_countries_rows' );     function mp_insert_countries_rows(){          global $wpdb;     $mp_insert_country = $wpdb->prefix . 'countries';          $insert_country_rows = $wpdb->insert(          $mp_insert_country,     array(     'id' => '1',     'name' => 'UK',     'labour_cost' => '20',     'overheads' => '0.45',     'profit' => '0.22'          ),          array(     'id' => '2',     'name' =>'China',     'labour_cost' => '6',     'overheads' => '0.27',     'profit' => '0.17'       ));             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );      dbDelta(  $insert_country_rows );     }      How should I correct this? Thanks


title: Can I use two different domain names with wordpress multsite network

text: I am currently running a DV server with MediaTemple and would like to have my domains: abc.com and cba.com mapped to the subdomains I set up with the WP network one.mydomain.com and two.mydomain.com. The goal is keep the urls: abc.com and cba.com viewable in the browser but the zone files are just referencing the subdomains I have set up. Sorry if this kinda of confusing, it is a major headache. Any help would great!


title: Walker customization - submenu & HTML description

text: I'm working on a site created by another person who used this customization to display a HTML description (img) in the menu. Now, I'd like for only a menu item to display the subpages, but I can. Someone can give me a tip on how to do it? Thanks a lot


title: How to add fields to _wp_attachment_metadata?

text: I'm developing a `custom metabox` with the possibility to upload images and give the user the possibility of deciding whether those images are to be displayed on the front end or not, instead of having to set up an additional metakey/value for each image id, i would like to add a field to the existing metakey in which image metadata is stored `_wp_attachment_metadata` which reads 'public' and give it a bolean value. One of the main reasons i dont't want to have to add other metakeys is it would create additional work removing those if the image is deleted. Theory works fine but upon saving wp wraps everything in arrays and nothing works. The following is the code i've got so far, any help or suggestions is appreciated.               $a = get_post_meta( $thumb_id, '_wp_attachment_metadata' );     // ChromePhp::log('original _wp_attachment_metadata', $a);          $a[0]['image_meta']['public'] = true;     // ChromePhp::log('modified object', $a);          update_post_meta( $thumb_id, '_wp_attachment_metadata', $a );          $b = get_post_meta( $thumb_id, '_wp_attachment_metadata' );     // ChromePhp::log('updated metakey', $b);      PS. the ChromePhp stuff is just a debugger i use for Chrome (https://github.com/ccampbell/chromephp) Thanks


title: Saving a post ID to use in a form elsewhere on website

text: I am trying to save a certain queried post's ID to pass on in a form outside of my loop. To be more specific. I have one file named **review.php** , this file contains a Wordpress Loop which queries one post at a time. In my **sidebar.php** I have a form setup which will only display if the user is currently on the **review.php** page. This form should pass along the queried post's ID from **review.php** in a hidden field. This ID will later be used to make changes to that post after form submission. (It's a reviewing system for posts) How do I store the post's ID in **review.php** so that I can later echo it in my **sidebar.php**?


title: Display Past Events in All-in-One Event Calendar

text: I'm a Wordpress noob, so I need some help! I'm working on a website for a radio program and I'm using the All-in-One Event Calendar to schedule my shows. I already have the Agenda view on my homepage via shortcode so that it only shows 3 events. On my actual event page, I have the Agenda view hidden and have the posterboard view as default. What I'd like to do is keep my Agenda view on the home page to show the 3 upcoming events. But, I'd like the posterboard view to show past events, from today and back. I've been searching all around, but as I said, I'm a Wordpress noob. I found the following code:               <?php              // Gets localized time         $time = $ai1ec_events_helper->gmt_to_local( Ai1ec_Time_Utility::current_time() );         $bits = $ai1ec_events_helper->gmgetdate( $time );              // Sets start time to today         $start = gmmktime(0,0,0,$bits['mon'],$bits['mday'],$bits['year']);              // Sets end time to a year from today i.e. $bits['year']+1         $end = gmmktime(0,0,0,$bits['mon'],$bits['mday'],$bits['year']+1);              // Look in class-ai1ec-calendar-helper.php for details         $get_events = $ai1ec_calendar_helper->get_events_between($start, $end, $filter, $spanning = false);              date_default_timezone_set('America/Toronto'); // Match timezone settings in WP              // For each event         foreach($get_events as $event) {                  // Event ID             $eventID = $event->post->ID;                  // Event Title             $eventTitle = $event->post->post_title;                  // Event URL             $eventURL = $event->post->guid . $event->instance_id;                  // Event Date             $eventMonth = date( 'M', $event->start );             $eventDay = date( 'd', $event->start );                  // Event Image             $imgID = get_post_thumbnail_id( $eventID );                  // Event Time             if( $event->allday == 1 ) {                 $timeSpan = 'All Day';             } else {                 $startTime = date( 'g:ia', $event->start );                 $endTime = date( 'g:ia', $event->end );                 $timeSpan = $startTime . ' - ' . $endTime;             }                  $attr = array(                 'alt' => get_post_meta( $imgID , '_wp_attachment_image_alt', true ),                  'data-name' => $eventTitle,                  'data-month' => $eventMonth,                 'data-day' => $eventDay,                 'data-time' => $timeSpan,                 'data-url' => $eventURL             );             echo get_the_post_thumbnail( $eventID, 'full', $attr );         }     ?>      Which seems like it would be the correct thing, or at least it's on the correct path. Problem is, since I'm a noob, I don't know where to put this code! How do I implement it? And please, spell it out for me as I'm a noob. Thank you immensely for any help!


title: Code a Slider into an Archive Loop

text: I have created a custom archive page for my custom taxonomy.   I want each post to display a slider for its images. I know I have to write some custom code for this work but I can't find any tutorials to push me in the right direction. Where should I start, what files do I have to change?


title: One Domain, Two Installs of WordPress

text: I'm looking into an upcoming project of a redesign of an existing website. The plan is to install one single installation of WordPress at domain.com. The admin area will be locked down and accessible only to individuals inside the organization's network. There is a subsection of the site that needs to exist to allow for other individuals outside of the organization to create and publish content. I'd like to set up a separate multisite install of WordPress at subdomain.domain.com. This multisite would be installed with subdirectories so each site will be at subdomain.domain.com/site1 and subdomain.domain.com/site2, etc. As far as I've read, all of this should work fine with WordPress. The reason we would like to keep two separate installs is simply for security so the base install of wordpress on domain.com isn't accessible in anyway from external sources. I'm just curious if anyone has any experience with this set up or sees any potential pitfalls.


title: Taxonomy Meta Box in User Profile?

text: Is it possible to have users populate a taxonomy meta box(es), using the post_tag or any custom taxonomies I create? The idea is to include users in a network into the taxonomy schema, which would bring the community together in a better way. I guess a more specific way to ask this is how would I add taxonomy meta boxes to the user interface. Obviously anything's possible if I'm willing to go far enough. Is this something that can be done using existing WP API's etc? Thanks.


title: How would I compare and remove hacks to core?

text: I have been put in charge of a site that have a lot (and i mean it) of core hacks, some are pretty easy, some are really hard to spot (like removing a do_action on `the_content`. So, my question is , how i would and remove the hacks the previous maintaners did, while adding the new features requested. Should i go and fix as soon as i spot them, or actively search for any hack in the core? (Side-Effect of the core hacks,can not update wordpress or it will completely break and a lot of features will be "removed" effectively putting the site down)


title: How to set posts per page using WP_Query()

text: I'm trying to set the number of posts_per_page dynamically using my own variable. This code works fine:               query_posts( $query_string  . "&posts_per_page=" . $myvar )     // then display the loop using get_template_part( 'loop' );      That works fine, but I would like to know how to do it using $wp_query instead of query_posts. However, this does not work:               $wp_query->set('posts_per_page', $myvar)     // then display the loop using get_template_part( 'loop' );      That has no effect on the number of posts displayed. Am I using the set method incorrectly, or is there something I'm missing?


title: Have users created automatically when a network site is created

text: Trying to figure out how to have users created automatically when a network site is created. So currently when a new user registers, their account is created and their network site is created. That gives that new site one user already (the site's admin). But when that's created I'd like to also have 3 more users automatically created to each new network site on creation.


title: How do I order pages and categories by ID or name in the same query?

text: I would like to query most of my pages and categories on the homepage. So far I am able to get the pages and category (posts), but I cannot order the list the way I want to. I want to be able to get a custom order like page, posts from a category, another page, and posts from another category. I am using the following:                       <?php             $args = array(                  'cat' => $current,                 'post_type' => array(                      'page', 'post'),                 'orderby' => 'ID' && array(2,4,1),             );             query_posts( $args );             while ( have_posts()) : the_post(); ?>                 <?php // Include the page content template.                 if ( is_page() ):                     get_template_part( 'content', 'page' );                 else:                     get_template_part( 'content', 'post' );                 endif;                 ?>             <?php endwhile;              ?>      by the way I am using twentyfourteen and I don't want to have multiple queries to that job unless it doesn't put a burden on the web server. I want to save memory as much as I can.


title: custom fields wordpress

text: I am trying to add a value assigned in the custom field by doing a post in these following steps: I make a new post, add a new custom field where i specify a name and a value. **PHP** I add the following scripts to index.php loop exactly below where the **while** and its parameter begins and to the HTML where I want the field added respectively               <?php while ( have_posts() ) : the_post(); ?>     <?php the_meta();?>               <?php echo get_post_meta(get_the_ID(), 'key');?>      The hard part for me to understand if i am doing right is the HTML. when i launch the site using firefox and firebug, I detect the post and find the html where the field is supposed to be added. But I noticed that WP automatically generates paragraph tags for the original post, so i honestly dont know where i am supposed to add the get_post_meta for it to be added into my post.


title: When WordPress Does Not Provide an .htaccess File for New Multisite Sites because of CPanel Fantastico Auto-Installer?

text: I have installed WordPress via an auto-installer and later configured it as multisite. But whenever I create the WordPress site using auto-installer it doesn't give me the `.htaccess` file by default. So I've created an empty file with the name `.htaccess` in CPanel and pasted this code in to it:               RewriteEngine On      RewriteBase /     RewriteRule ^index\.php$ - [L]          # uploaded files      RewriteRule ^files/(.+)wp-includes/ms-files.php?file=$1 [L]          RewriteCond %{REQUEST_FILENAME} -f     [OR] RewriteCond %{REQUEST_FILENAME} -d      RewriteRule ^ - [L]      RewriteRule . index.php [L]      Is it a right method ?


title: Sharing Ad Revenue among Users of a Multisite in a Collaborative Model?

text: Is anyone aware of some functionality to share the revenue among the users of a Multisite? A multisite lets other people create and mainatain their own blogs. The Multisite owner should able to share some percentage, say N% (like 20%) of revenue on the sub-sites hosted. **Example:** > You are that owner of a Multisite on xyz.com and offer blogs to your > "friends" User1, User2 and so on. User1 and User2 use adsense or adbrite on > their blog. The functionality would ensure that you get 20% from the revenue > they earn. I have seen the author-advertising-plugin (Wordpress Plugin) which shares the revenue within a single site among multiple authors. I do not know if it supports Multisite because for me it would be better. If I have the possibility to share the revenue Multisite-wide. I would like to know If that plugin suits perfectly to Multisite installation or not.


title: Can I use AdSense on a free wordpress blog?

text: Is it possible to use AdSense on a free .wordpress.com blog? I can't see any way of doing this in the configuration. There are options to add text widgets etc, but nothing for adds?


title: Load new Posts on Scroll on Page

text: See this reference site: http://alwaysjudging.com/archive/ It's loading new posts on scroll down, similar to Infinte Scroll plugin. (But I'm unable to get the Jetpack Infinite Scroll plugin to work on a static "archive" page using a query of posts, so I saw this instead.) **Ho would I implement this feature on a page?** When I view the source of the referne site above, it shows the script is loaded here: http://alwaysjudging.com/assets/js/scripts.min.js **It appears that the selector involves ".post-nav" and ol li tags.** I'm a front end developer, so my knowledge of actually writing Javascript and PHP is very limited. If you can explain how I can use this to work on my website single page it would be greatly appreciated. I think it would also be useful for all those people who can't use Infinte Scroll plugin to load posts on an Archive page also. Thank you for any guidance you can offer.


title: Formatting Code Snippets on Free WordPress.com Account?

text: I've got a WordPress blog on WordPress.com. When posting something I'm including some sample Java code in the `<code` tags, is there any way I can have this formatted better? Such as syntax highlighting and line numbers etc? An example of what I have is here, even though I have the code tags it doesnt seem to make it any more readable than normal text Am I limited in choices as I've gone for the free option?


title: Username was changed to "admin"

text: I suspect a hacking incident in my wordpress site. My username was changed to "admin". How to revert back my username safely? Thanks


title: url - ajax loaded but no JS

text: I have this url to call the taxonomy.php by pressing the button with the code beneath to show filtered posts:               http://myurl/?meta_key=post_views_count&orderby=meta_value&order=ASC      This is the JS I am using:                   $(document).ready(function(){     $.ajaxSetup({cache:false});     $("#hot a").click(function(){              var post_id = $(this).attr("rel")         $(".postbox_wrapper").html('<img src="<?php bloginfo ('template_directory'); ?>/images/287.gif">');         $(".postbox_wrapper").load(jQuery(this).attr("href") + " .postbox_wrapper")         return false;     });      }); The call works perfectly - the content show up without pagereload - as I wish. The problem is, that JS is not loaded on the ajaxloaded pages and I really don't get it to load. I tried out many versions, I found on stackexchange, but nothing worked out. For example this needs to be loaded into the ajaxed call: `http://myname.disqus.com/count.js?ver=3.4.1` Has anybody an idea? Thanky you very much. AD


title: Sort by posts that have a featured image?

text: I'd like to sort posts on the index page to show those that have a featured image first. I've done this in functions.php:                  add_filter( 'pre_get_posts', 'my_get_posts' );             function my_get_posts( $query ) {          if ( is_home() || is_archive() ) {            $query->set('orderby', 'meta_value');            $query->set('meta_key', '_wp_attached_file');          }        }      The causes no posts to be shown on the index page. What should I be doing here?


title: How to rename  'TAG' to 'TOPIC'

text: i want to rename TAG to TOPIC and url it should be wordpress.stackexchange.com/tag/ to wordpress.stackexchange.com/topic/ is it possible ?


title: Where does WordPress store version number?

text: Easy question. Where does the self-hosted WordPress store version information?


title: special characters after saving draft interpreted as �

text: I am trying to create posts in hindi language. These characters `UÉeÉMÑüqÉÉU` after saving/publishing are interpreted as `U�e�M��q��U`. Though, the special characters are stored with no change in the mysql database. The `�` symbol is only during retrieving. I'm stuck here. The post editor is modified to intake multiple posts. http://www.farinspace.com/multiple-wordpress-wysiwyg-visual- editors/ I tried commenting these lines in wp-config.php. But none worked.               /** Database Charset to use in creating database tables. */     define('DB_CHARSET', 'UTF-8');          /** The Database Collate type. Don't change this if in doubt. */     define('DB_COLLATE', '');      Also, placed `mysql_query("SET NAMES utf8");` in wpdb class constructor of wp- db.php. Negative, even this didn't work How do i overcome this?


title: How to list all custom post types in a custom widget?

text:
I tried the Following (whihc lists custom post types called Static Content):                <?php          add_action("widgets_init", array('Widget_name', 'register'));     class Widget_name {       function control(){             $custom_posts = new WP_Query();             $custom_posts->query('post_type=page_content&page_sections=Lastest');             while ($custom_posts->have_posts()) : $custom_posts->the_post();         ?>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
             <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>

         <?php endwhile;       }       function widget($args){         echo $args['before_widget'];         echo $args['before_title'] . 'Your widget title' . $args['after_title'];         echo $args['after_widget'];       }       function register(){         register_sidebar_widget('Widget name', array('Widget_name', 'widget'));         register_widget_control('Widget name', array('Widget_name', 'control'));       }     }          ?>      But no luck. There's nothing displayed in the widget. Any suggestions?


title: How to list custom post types in a secondary sidebar?

text:
I have a custom post type called "Static Content." I would like to list those posts in the following secondary sidebar: **sidebar-secondary:**
         <?php             // A second sidebar for widgets, just because.             if ( is_active_sidebar( 'secondary-widget-area' ) ) : ?>
                     <?php dynamic_sidebar( 'secondary-widget-area' ); ?>
              <?php endif; ?>
      Any suggestions?


title: What action hook updates post meta?

text: Is there an straight-forward example anywhere of using wp_update_post() to edit post_meta on the front end? I have not been able to find any good learning resources. What I want to do is display post meta in an input field and when a user clicks _submit_ trigger `wp_update_post();`. ![post meta in input field with save button](http://i.stack.imgur.com/uR70A.png) Thanks!


title: Global, network-wide shortcodes or text replace functions

text: What I'm trying to achieve is a simple text-replace functions, that would be available to any site in my Wordpress Network. Basically I want to:   1. Change `[--]` into `—` (--),   2. Be able to link to my own posts using only their titles -- `[internallink post=title]` or anything similar. I found simple example of solving this using shortcodes. But I don't know, where to put my custom shortcodes definition, so it would be available to any site in my Wordpress Network. I'm always looking into solutions as simple as possible, so I would like to know, if I have to use shortcodes to solve these two tasks or:   1. Is there an easy way to define global search & replace mechanism, so any occurence of just `--` would be changed to `—` in any post or page on any site in the network?   2. Is there anyway to define global shortcode function, that would convert any `[post title]` into link poiting to post titled "Post Title"? Thank you in advance for any help here?


title: Last posts from custom taxonomy

text: How can I post last posts from custom_taxonomy? I tried this like, but it doesn't works.               $terms=get_terms('tax_name');     $request=array();      if(count($terms)>0)      {       foreach($terms as $t)        {            $request[]=$t->slug;          }       }       query_posts(       array(         'tax_query' =>     array(                  'taxonomy' => 'tax_name',                  'field' => 'slug',                  'terms' => $request,                  )         )       );       while ( have_posts() ):the_post();