Best and Cleanest way to remove /category/ from category permalinks?

> **Possible Duplicate:**   >  Remove parent category from permalink? Basically only have the child > category? We've seen plugins to do this, and a lot of people with different code modifications. We really would like to achieve this the cleanest and simplest way possible, without worrying about out-dated plugins or causing problems with too many mods.


change set_post_thumbnail_size according to post type admin page

I have a few custom thumbnail sizes and obviously one of them is used in the set_post_thumbnail_size, what directly affects the interface in the admin area. What I'm looking to do is to intercept which admin page (for post-type) I'm in and set a different size in the above function, so basically I'd like to have that:               function setup_the_theme() {              add_theme_support( 'post-thumbnails' );                  if ($post_type == 'type_A'){                 set_post_thumbnail_size( 298, 167, true ); //portrait             } else {                 set_post_thumbnail_size( 192, 108, true ); //landscape             }              add_image_size( 'top_articles', 298, 167, true ); //portrait         add_image_size( 'article_thumb', 203, 114, true ); //portrait         add_image_size( 'featured_articles', 60, 200, true ); //landscape          }     add_action( 'after_setup_theme', 'setup_the_theme' );      I suspect its too early in the cycle to know which post type i'm editing.


WooCommerce - How to Add a Custom Field to Cart Items and Cart Totals

I am using WooCommerce plugin and have the following query: Within the single product page, I have a product where based on certain selections by the buyer, a shipping cost value is calculated, which I then need to pass/include as part of the cart items as a new column, "Shipping Cost" when viewing your cart. The thing is though, the buyer might decide to buy say three different products where each of these three products might have varied shipping cost calculations, after pressing the "Add to Cart" button three times. For example:               Product A selections calculates a Shipping Cost of $2.00     Product B selections calculates a Shipping Cost of $4.00     Product C selections calculates a Shipping Cost of $6.00      So based on the above, when the buyer has finished shopping and presses "View Cart", I want them to see:               Item                       Price      Shipping Cost      Quantity          Total          ---------------------------------------------------------------------------------------     Product A                      $10        $2                     1                 $10     Product B                      $5         $4                     1                 $5     Product C                      $15        $6                     1                 $15      It is the "Shipping Cost" custom field column I would like to add to the cart, which is what I am unsure how to do. Further to the above, I also want to add to the "Cart Totals" below, another custom field of "Shipping Cost" which would total $12, which would then beed added to overall Product Total, i.e.               Cart Totals          Cart Subtotal       $30     Shipping Cost       $12          Order Total         $42      Some of the code that I have used for the Cart Total shipping cost is:               function woo_add_cart_fee() {       global $woocommerce;       $woocommerce->cart->add_fee( __('Shipping Cost', 'woocommerce'), 100 );     }     add_action( 'woocommerce_before_calculate_totals', 'woo_add_cart_fee');      So, I need to know how to add the "Shipping Cost" to both the Cart Product Details as well as to the Cart Totals. Any coding help would be much appreciated. Thanks.


How do I restart my loop with get_next_post()?

I'm looking for a succinct method of making `get_next_post()`   double back to the beginning once it hits the last post.   Currently, it stops once it hits the final post. Here are a few lines of code from the codex   for context that are similar to what I'm using:                   <?php $next_post = get_next_post();         if (!empty( $next_post )): ?>         <a href="<?php echo get_permalink( $next_post->ID ); ?>">                 <?php echo $next_post->post_title; ?>         </a>         <?php endif; ?>      http://codex.wordpress.org/Function_Reference/get_next_post Thanks in advance for your suggestions.


Get a count of how many times a term or a category is used in posts

I need to find out the number of times a term/tag or category is used in a post in WordPress. I wrote the below SQL query.               SELECT t.name , count(*)FROM wp_terms t     JOIN wp_term_taxonomy tt ON tt.term_taxonomy_id = t.term_id     JOIN wp_term_relationships tr ON tr.term_taxonomy_id = tt.term_taxonomy_id     JOIN wp_posts p ON p.id=tr.object_id     Where t.name='3d'      This gives me a count of '1011' I know this is wrong because I randomly checked the posts which I got and the term was not used. Please advice where I might be going wrong?


wp_get_referer not working properly after wp_redirect

Thank you for reading! There's a lot redirecting going on on the site I'm creating. For example,   * if not logged in user access a "private" page, he will be redirected to a custom login page.   * if the user logs in, he will be redirected to the last page he visited before accessing the login form. Let's call the pages "Profile" and "LogIn". So, if everything goes well should be: > -> not logged try to access **Profile** -> redirect to **LogIn** -> if OK > redirect to **Profile** However, when **LogIn** calls wp_get_referer(), it does NOT return **Profile**. Instead it goes "2 pages" back. Is like "wp_get_referer()" is not seing **Profile** as the referer because is acting as a redirection. Just like the "Back" button in the browser would. **If you go to the LogIn through any 'public' page (clicking the link) the redirect after login in works fine.** **page-profile.php**               if( !is_user_logged_in() ) {             wp_redirect( get_permalink(37) ); //id 37 = page-login.php         exit;     }      **page-login.php**               //Set referer     $referer = wp_get_referer();     if( !$referer || referer_is_login_page($referer) )         $referer = get_bloginfo('url');     simpleSessionSet('login_referer', $referer);          ...      //Log the user in      ...          if ( is_wp_error($user_id) )                     $errores = TRUE;     else          wp_redirect( simpleSessionGet('login_referer', '') );


Best hook for a function which adds shortcodes to the system?

I have a plugin released, and one of my customers was reporting a problem where the plugin was outputting ads in the header area of their website. I have a function defined which contains my shortcode definitions, for example, the function contains a few of these `add_shortcode( 'myshortcode', 'my_function' ); ` I am executing the function via the following command `add_action( 'init', 'add_my_shortcodes');` Doing it thisway causes a conflich with my plugin (which outputs adsense ads) and the google analytics in the header). I was testing different hook positions for my add_action, and it appears that `add_action( 'loop_start', 'add_my_shortcodes');` If my plugin is for outputting of ads, what is the best place to hook? I need it to be available anywhere in the template, or content. For example, they can put it in posts, sidebar widgets, or straight hard coded into the theme via a `do_shortcode` in their template files. In order to ensure my shortcode is registered before any content is generated, but AFTER their header scripts, I moved my way down this list http://codex.wordpress.org/Plugin_API/Action_Reference until the ads worked properly. I ended up landing on the hook `loop_start` which doesn't sound like an ideal place to hook into. Can anyone suggest the best hook location so that it is executed before any output, but after the opening `<body>` tag? I'm assuming I need to get as close to the `<body>` tag as possible, but I could be wrong.


Sort posts by category name and title

Trying to figure out how I can output my posts based on category title (a–z) and secondly, the title of the posts within the category: A CATEGORY   – A post beginning with a   – Because I want to be output second   – Come on, and output me already   B CATEGORY   – Another post beginning with a   – Bollocks, can't come up with another title on B   – I guess you get the point   How do I achieve this? Thanks.


How to modify press-this.php to post to a certain category

I want to use the the PressThis bookmarklet to save items to a category called "readlater". I would like that it always posts to this category and that I never have to select a category before posting. It's ok if the category box is removed or replaced with something else as I won't ever need to use it. Could someone show me what to modify to make this happen? Here is the section within press-this.php that pertains to categories:                   <?php $tax = get_taxonomy( 'category' ); ?>
         <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>">

<?php _e('Categories') ?>

<?php echo $tax->labels->all_items; ?>

<?php _e( 'Most Used' ); ?>

                     <?php $popular_ids = wp_popular_terms_checklist( 'category' ); ?>

                     <?php wp_terms_checklist($post_ID, array( 'taxonomy' => 'category', 'popular_cats' => $popular_ids ) ) ?>

                  <?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
<?php _e('You cannot modify this Taxonomy.'); ?>
             <?php endif; ?>             <?php if ( current_user_can($tax->cap->edit_terms) ) : ?>

                                                      <?php printf( __( '+ %s' ), $tax->labels->add_new_item ); ?>

                         <?php echo $tax->labels->add_new_item; ?>                         <input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" aria-required="true"/>                                                      <?php echo $tax->labels->parent_item_colon; ?>                                                  <?php wp_dropdown_categories( array( 'taxonomy' => 'category', 'hide_empty' => 0, 'name' => 'newcategory_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —' ) ); ?>                         <input type="button" id="category-add-submit" data-wp-lists="add:categorychecklist:category-add" class="button category-add-submit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" />                         <?php wp_nonce_field( 'add-category', '_ajax_nonce-add-category', false ); ?>

             <?php endif; ?>

      Link to full press-this.php


How to keep a check box in custom meta box for custom post type checked by default for add new post?

In my custom plugin, I have a custom post type and have a custom meta box for it. I have few fields in it, one of it is a check box. I want this check box to be checked by default when I go for a `add new post` and then proceed with the selection of the user ie checked/not checked. I am adding the related codes ie: for the metabox and how I am saving it.               function coupon_add_metabox() {         add_meta_box( 'coupon_details', __( 'Coupon Details', 'domain' ), 'wpse_coupon_metabox', 'coupons', 'normal', 'high' );     }          function wpse_coupon_metabox( $post ) {              // Retrieve the value from the post_meta table         $coupon_status   = get_post_meta( $post->ID, 'coupon_status', true );              // Checking for coupon active option.         if ( $coupon_status ) {             if ( checked( '1', $coupon_status, false ) )                 $active = checked( '1', $coupon_status, false );         }              // Html for the coupon details         $html = '';              $html .= '
';         $html .= __( 'Active', 'domain' );         $html .= '';         $html .= '<input type="checkbox" id="coupon-status-field" name="coupon-status-field" value="1"' . $active . ' />
';              echo $html;     }          function wpse_coupons_save_details( $post_id ) {         // If this is an autosave, our form has not been submitted, so we don't want to do anything.         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )              return $post_id;              // Check the user's permissions.         if ( ! current_user_can( 'activate_plugins' ) )             return $post_id;              $coupon_status   = sanitize_text_field( $_POST['coupon-status-field'] );              // Update the meta field in the database.         update_post_meta( $post_id, 'coupon_status', $coupon_status );     }     add_action( 'save_post', 'wpse_coupons_save_details' );


Rewrite Rule & Regex - Extract 'cat-name' and 'page-number' from http://domain.com/custom-post-type/category/cat-name/page/page-number

I have an URL formatted so: `http://domain.com/custom-post-type/category/cat-name/page/page-number` I need to extract: `cat-name` and `page-number` So that in my `functions.php`, I can create the custom rewrite rule:               function my_insert_rewrite_rules( $rules ) {       $newrules = array();       $newrules['projects/category/(.+)/page/(\d+)/?$'] = 'index.php?post_type=project&project_cat=$matches[1]&paged=$matches[2]';       return $newrules + $rules;     }      I am trying to use the expression: `projects/category/(.+)/page/(\d+)/?$` Which seems to work appropriately (escaping the forward slashes) in this example: http://rubular.com/r/5rzECsTexy However, this never seems to work, the URL: `http://domain.com/projects/category/print` and `http://domain.com/projects/category/print/page/2` always seem to 404. My previous rewrite rule of `projects/category/(.*/?)$` worked for the category, but did not pull the page number properly. **Edit** Custom Post Type registration code (in my theme's `function.php`)               // Custom Post Types     add_action( 'init', 'create_post_type' );     function create_post_type() {         register_post_type( 'project',             array(                 'labels' => array(                     'name' => __( 'Projects' ),                     'singular_name' => __( 'Project' )                 ),             'public' => true,             'has_archive' => true,             'taxonomies' => array('category'),             'rewrite' => array('slug' => 'projects')             )         );     }


Changing Gallery images size?

I'm grabbing URLs of my Gallery images:               $gallery = get_post_gallery_images( $post );          foreach($gallery as $thumbnail) {        echo $thumbnail_slideshow;     }         The problem is all I'm getting are thumbnails:               image1-150x150.jpg     image2-150x150.jpg     image3-150x150.jpg      And I want to get:               image1-600x100.jpg     image2-600x100.jpg     image3-600x100.jpg      Of course I have my custom image_size defined in functions.php:               add_image_size( 'mysize', 660, 100, true );       And I'm wondering if it is possible to do the easy way using `get_post_gallery( $post )` or should create some kind of a loop? Here's a great answer by Otto, unfortunately it doesn't work for me (I'm trying to make it work in single-customposttype.php, it displays nothing, replacing `$post->ID` with `$page->ID` or `$parent->ID` displays EVERYTHING from Media Library ). # UPDATE Looks like I don't understand something right. I took a snippet I've seen around in many places, also in Otto's post above:               $gallery_images = new WP_Query(array(             'post_parent' => $post->ID,             'post_type' => 'attachment',             'post_mime_type' => 'image',             'post_status' => 'inherit',     ));          while ( $gallery_images->have_posts() ) : $gallery_images->the_post();             the_title();              the_content();              the_permalink();     endwhile;      I pasted it into content.php of Twenty Thirteen and guess what? It returns NOTHING, and of course this post HAS gallery and get_post_gallery_images($post) work on it flawlessly. What am I doing wrong? Of course when I UPLOAD image to the gallery code above works, because the image is uploaded / attached directly to this post. All of my other images are of course "(Unattached)" and this might be a problem... # UPDATE II Got it, finally. Looks like Gallery images used to be attached to posts in WP pre-3.5, now it doesn't work this way. Here's it well explained. So the question is - is this solution good and is it safe to use it for the future? Of maybe it's possible to play with get_post_gallery_images sizes? To be honest this function would be so much more powerful if it would load all image sizes in multidimensional array...


GoDaddy hosting wp-admin problem

I'm having a big issue with /wp-admin login page on GoDaddy Hosting Account (Windows). I can't log in if I visit the following url. I get re-directed to the login page again.   * domain.com/wp-admin I can log in if I use the following urls.   * domain.com/wp-admin/ (with the forward slash on the end)   * domain.com/admin   * domain.com/login I pointed the domain I want to use to the installation of my wordpress, which is under a sub-directory of the root.   * Disabled permalinks (removed web.config which is I guess .htaccess for windows)   * Disabled plug-ins   * Verified Site URL in the database (It doesn't contain an extra forward slash) When I log into wp-admin I am redirected to. domain.com/wp-login.php?redirect_to=http%3A%2F%2Fdomain.com%2F **sub- directory** %2Fwp-admin%2F&reauth=1 The url is incorrect and the sub-directory should not be there. Visiting wp-admin/ with the forward slash directs me to the correct url. domain.com/wp-login.php?redirect_to=http%3A%2F%2Fdomain.com%2Fwp- admin%2F&reauth=1 GoDaddy Support does not see an issue here.


orderby:date not working

I have been searching for an answer and it seems like there are a lot of answers for the opposite issue. I am trying to sort by publish date, not by date modified, using this code:               query_posts($query_string . '&orderby=date&order=DESC&posts_per_page=-1');      But it is still sorting on date modified not publish date, can anyone help? Thanks in advance!


Each custom image size in custom upload directory?

I want to upload my custom image sizes in custom folders. The folder should have the name of the selected width. For example: If I add these custom sizes...               add_image_size('custom-1', 300, 9999);     add_image_size('custom-2', 400, 9999);      It would be nice the uploaded images are uploaded like this:               http://www.my-site.com/wp-content/uploads/300/my-image.jpg     http://www.my-site.com/wp-content/uploads/400/my-image.jpg      Is this possible? I've only found that I can change the global upload folder with the upload_dir filter.


Why is a wordpress login session limited to one domain

I have a wordpress installation on my virtual host, where the document root is accessible as both "somesite.com" as well as "www.somesite.com". If I set up site_url as "http://somesite.com", then when I access "www.somesite.com" then wordpress thinks I am not logged in (and I can't see private posts and such), while if I set site_url to "http://www.somesite.com", then the same problem happens with "somesite.com". I would really like both variations to be acceptable.


Hyperlink to execute PHP

Below is code that will add a column called Printed to Gravity Forms and display a green or red dot representing if the form has been printed. If the form has not been printed, I am trying to a) toggle the color b) print the page. How can I invoke both the PHP code to toggle and print the page?               add_action("gform_entries_column", "add_icon", 10, 5);     function add_icon($form_id, $field_id, $value, $lead, $query_string){          //targeting form 190 only.     if($form_id != 2)         return;          //targeting field 5 only     if($field_id != "printed")         return;          $lead_id = $lead['id'];          if($value == "Yes"){         echo " ";     }     else{         echo " ";         //echo " ";     }          // reset meta data for testing     //gform_update_meta($lead_id, "printed", "No");           if (isset($_GET['print'])) {              $print = $_GET['print'];         $lid = $_GET['lid'];              if ($print == "true") {                  gform_update_meta($lid, "printed", "Yes");              }          }             }


What is better to use, user meta, custom taxonomies or new database structure?

I am looking for some advice. I will be working on user follow system (like twitter) for my site. I expect it to have a large number of users using this system. So, I would like to know what is better to use to store all the data for this system. Should I use user meta, custom taxonomies or should I work directly with the database? I was thinking about creating some user meta, so each user has meta for followers and a meta for following, each would be filled with users' ids. Is there a better way from the stanpoint of scalability? Thanks!


Does WordPress require that your submitted theme supports multiple menu levels?

As the title says I'm wondering if WordPress requires that your submitted theme supports multiple menu levels. I can't seem to find any info on this. However the Theme Unit Test does include hierarchical pages. There's no information in the Theme Unit Test if this is required or not.


Is it possible to orderby multiple meta_keys when using meta_value_num?

Reading through the order & orderby documentation, it's not clear to me whether there is any support to order based on multiple `meta_key` values. Obviously, using `meta_query` I can return posts based on multiple key-value pairs, but I want to be able to control the order that these results are returned based on multiple `meta_keys`. For example, I have pages that have multiple categories and each category has a numerical rank. If a user is searching for pages that are in one of three different categories, I can return all the necessary posts with the following:               $query = array(       'order' => 'DESC',       'orderby' => 'meta_value_num',       'meta_query' => array(         'relation' => 'OR',         array( 'key' => 'cat1', 'type' => 'numeric' ),         array( 'key' => 'cat2', 'type' => 'numeric' ),         array( 'key' => 'cat3', 'type' => 'numeric' )       );     );      However, once those are returned, I would like them to be ordered based on the highest numerical value across any one of the categories that results were returned on. In other words, posts with a `9` value in `cat1` would appear around the same order as posts with a `9` value in `cat3`. Looking at this answer it seems that a `meta_key` isn't even necessary for `'orderby' => 'meta_value_num'`, but that doesn't match the documentation for `meta_value`, which is far more documented than `meta_value_num`... Any clarification would be useful. Thanks!


get comments by current user inside page template

I want to add a page template inside my custom post type and retrieve inside that page the comments posted by current user. I have this code for getting the current user:                         <?php          global $current_user;     get_currentuserinfo();          echo 'Username: ' . $current_user->user_login . '
';     echo 'User email: ' . $current_user->user_email . '
';     echo 'User first name: ' . $current_user->user_firstname . '
';     echo 'User last name: ' . $current_user->user_lastname . '
';     echo 'User display name: ' . $current_user->display_name . '
';     echo 'User ID: ' . $current_user->ID;     ?>      The code for getting the comments of the current user:                    <?php      $args = array(     'user_id' => 1, // use user_id         'post_type' => 'my-CPT',      );     $comments = get_comments($args);     foreach($comments as $comment) :         echo($comment->comment_author . '
' . $comment->comment_content);     endforeach;          ?>      And the code for listing the comments:
                 <?php                     wp_list_comments( array( 'callback' => 'outbox_comment' ) );                 ?>
      And this is how my **page-commentsbyuser.php** is looking:               <?php          /**      * The template for displaying a list of comment from the current user      *      */          get_header();              ?>

                  <?php     global $current_user;     get_currentuserinfo();     echo 'Username: ' . $current_user->user_login . '
';     echo 'User email: ' . $current_user->user_email . '
';     echo 'User first name: ' . $current_user->user_firstname . '
';     echo 'User last name: ' . $current_user->user_lastname . '
';     echo 'User display name: ' . $current_user->display_name . '
';     echo 'User ID: ' . $current_user->ID;     ?>                   <?php      $args = array(     'user_id' => 1, // use user_id         'post_type' => 'my-CPT',      );     $comments = get_comments($args);     foreach($comments as $comment) :         echo($comment->comment_author . '
' . $comment->comment_content);     endforeach;          ?>
                 <?php                     wp_list_comments( array( 'callback' => 'outbox_comment' ) );                 ?>

      This is not working and also I don't know how can I get the comments of the current user. Any suggestions on how I can retrieve the comments from the CPT of the current user inside this page template ?


How to limit the number of results for all query_posts on mysite

I have a huge number of posts and the pagination with no limits eats my server CPU and ram so I need a function to limit the number of posts for all `query_posts` on my site and I need this function to work in the admin area too if possible, any suggestions??               function limit_posts {     $args = array(         'posts_per_page' => 10,         'post_type' => 'job_listing',     );          global $wp_query;     $wp_query = new WP_Query( $args );


Getting post by specific date in Advance Custom Field

How can i get movies there are today in cinema, for example my code display the movies in time that shoud apear 16 January,17 January..., how can i display only the movies in this day. Ex: today is Wensday 16 January 2013, how can i get only the posts(movies) that shoud apear only today If i have 2 movies that premiere is on 16 i want to display only that. For the meta key i use a custom field -'meta_key' => 'premiera_cinema' - with this i select the day.                  <?php // Get today's date in the right format         $todaysDate = date('Ymd');         ?>          <?php $loop = new WP_Query( array(     'post_type' => 'post',     'posts_per_page' => 3,     'meta_key' => 'premiera_cinema',     'meta_compare' => '>=',     'meta_value' => $todaysDate,     'orderby' => 'meta_value',     'order' => 'ASC'     ) ); ?>          <?php while ($loop->have_posts()) : $loop->the_post(); ?>


Converting a theme to a child theme in a network

I'm converting a few themes to children of another theme. I want the themes to have the same name as before, and I'd like the change to be transparent to the users of my blog network. When I replace the themes' folders with child themes in the wp-content/themes directory, the blogs in my network do not work properly until I:   1. Access wp-admin/themes.php for each, which automatically disables the new child theme (it says that it has an error or is invalid) and sets the theme to the network default.   2. Manually reactivate the child theme. My blog network is pretty large. Is there a way to automate whatever is happening above so that I don't have to do it manually for every blog in the network?


Custom wp_query differs on index page and category page

I've been banging my hand against the wall for a little while now trying to figure this out. Can anyone explain to me why this custom wp_query prduces two different sql statements, one for the index page (which is correct) and one for the category page (which is wrong)               function myFunction( $category )     {         if(!$category) return;              $query = array(             'post_type' => 'download',         );              $query['tax_query'][] = array(             'taxonomy' => 'download_category',             'terms' => explode( ',', $category ),             'field' => 'slug'         );              $downloads = new WP_Query( $query );              return intval($downloads->found_posts);     }      Index sql (correct):               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (20) ) AND wp_posts.post_type = 'download' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'refunded' OR wp_posts.post_status = 'failed' OR wp_posts.post_status = 'revoked' OR wp_posts.post_status = 'abandoned' OR wp_posts.post_status = 'active' OR wp_posts.post_status = 'inactive' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10      Category sql (wrong):               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (15) ) AND wp_posts.post_type IN ('nav_menu_item', 'post', 'eddset') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'refunded' OR wp_posts.post_status = 'failed' OR wp_posts.post_status = 'revoked' OR wp_posts.post_status = 'abandoned' OR wp_posts.post_status = 'active' OR wp_posts.post_status = 'inactive' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10      It is ignoring the post_type but can't figure out why? Any help much appreciated.


Custom columns for multiple custom post types

I currently have 2 issues with Custom Post Types... First of all I'm trying to setup custom columns in Admin to display and act correctly. I have a Custom Post Type called 'acme_products' and a Taxonomy called 'product_type'. I have followed the Yoast tutorial http://yoast.com/custom-post-type-snippets/ (amongst others!) which has almost got me there... The problem is under the column 'Product type' instead of displaying the 'product_type' Taxonomy it simply says 'Array', and links to localhost:8888/wp-admin/Array. I don't actually mind if it doesn't link anywhere, so long as the Taxonomy displays correctly. Code is below plus an explanation of what I changed:               // Add columns to the overview page for a Custom Post Type          function change_columns( $cols ) {         $cols = array(             'cb'       => '<input type="checkbox" />',             'title' => __( 'Product', 'trans' ),             'product_type' => __( 'Product Type', 'trans' ),             'date'     => __( 'Date', 'trans' ),         );         return $cols;     }     add_filter( "manage_acme_products_posts_columns", "change_columns" );               // Give these new columns some content          // Below I changed 'get_post_meta' to 'get_the_terms'     // This was taken from a further tutorial to target taxonomies rather than post_meta          function custom_columns( $column, $post_id ) {         switch ( $column ) {             case "product_type":                 $product_type = get_the_terms( $post_id, 'product_type', true);                 echo '' . $product_type. '';                 break;         }     }     add_action( "manage_posts_custom_column", "custom_columns", 10, 2 );               // Make these new columns sortable          function sortable_columns() {         return array(             'title' => __( 'title' ),             'product_type' => __( 'product_type' ),             'date'     => __( 'date' ),         );     }     add_filter( "manage_edit-acme_products_sortable_columns", "sortable_columns" );      Further to this problem, I have a second Custom Post Type called 'acme_courses' with a Taxonomy of 'course_locations'. How would I go about applying the custom columns to a second (and potentially 3rd & 4th) Custom Post Type? If I duplicate the code above, and change bits to reflect the new Custom Post Type and Taxonomy, it breaks everything! I get a white screen both in admin and on the site. Thanks in advance!!!


Problem with isset and $_POST

I have another question. Why I cant get into this 'isset' $_POST["zapisz"] in this code ? What is wrong ?                   function ow_display_user() {         ?>
         <?php if ($_SERVER['REQUEST_METHOD'] === 'POST') var_dump($_POST); ?>
         <?          wp_enqueue_script('jquery-ui-datepicker');         wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');              global $wpdb;         $results = $wpdb->get_results ("SELECT adres FROM wp_ow_adres;");         ?>     <form name="one" method="post" action="">

                     Adres zamieszkania	                     <select id="adres" name="adres">                             <option value="">Wybierz swój adres</option>                             <?php                              foreach ( $results as $result ) {                 echo '<option>'.$result->adres.'</option>';             }             ?>                     </select>

                     <input type="submit" name="ok" value="Wybierz" />

     </form>     <?php      $adres = $_POST["adres"];          if (isset($_POST['ok'])){         $spr_liczbe_wodo = $wpdb->get_var("select liczba_wodomierzy from wp_ow_adres where adres='$adres'");              if ($spr_liczbe_wodo == 4) {         ?>             <form name="two" method="post" action="http://localhost.local/">

             Adres zamieszkania:	             <?php $adres?>

             Woda ciepła (kuchnia):	             <input type="text" id="woda_ciepla_kuchnia" name="woda" />

             	             <input type="submit" id="zapisz" name="zapisz" value="Zapisz" />

             </form>         <?                  if(isset($_POST['zapisz']))             {             $woda_ciepla_kuchnia=1;             $data_odczytu = '0013-00-00 22:00:00';                          $data = array(                     'id' => '',                     'adres' => 'dasd',                     'data_odczytu' => $data_odczytu,                     'woda_ciepla_kuchnia' => 1,                          );                          $wpdb->insert(wp_ow_odczyty, (array)$data);                                      }                                 }              }          }


Who To Create Option Page For This Simple Plugin

I know how to write WordPress plugins but I have no idea how we could create an option page for our plugin. I read lot of tutorials but I still have no idea about creating option pages. So just for learning, I want to create an Option Page with one input field "Favicon URL" which will update **FAVICON IMAGE URL** part in the below code:               add_action('admin_head', 'show_favicon');     function show_favicon() {     echo '<link href="FAVICON IMAGE URL" rel="icon" type="image/x-icon">';     }      Please help guys :)


User post upload plugin buddypress

I am using `buddypress` for my website. I am searching for a plugin which allows members to `post articles, stories and poems`. It is good if the member can upload documents with it. I have searched a lot but couldn't find suitable one which works with buddypress. Any suggestions?


What is the purpose of adding a .po file?

I added the below code to the `function.php` of a **.po** file and finished localization and edited the `webconfig.php` to add Arabic language but nothing happened. I want to know what should happen. Will the site include the new language - in my situation Arabic, or what? Now the website is in English and I want to add an Arabic version.               <?php load_theme_textdomain('themename', TEMPLATEPATH.'/language'); ?>


How to add a route?

I'm writing a wordpress plugin. I want to add a route to frontend, for example `mysite.com/myroute/` that runs a php file( located in `wp- content/plugin/myplugin/my_route_handler.php`). I need to load layout and every wordpress specifics in this route. Is this possible? How to do this?


Practical Solutions to HTML5 Video on WordPress

I was directed here from Stack Overflow -- We work with clients who have WordPress sites and one thing we keep struggling with is implementing HTML5 video across all browsers and devices in the WordPress environment. We've tried multiple plugins (JW Player, MediaElement, Sublime Video). It seems like each one has its own bugs, and are difficult to implement video play-lists on (Not to mention having a good UI for the client to manage/add videos themselves). What is a solid, reliable solution to HTML5 video on WordPress? Something that can support up to 4 file types at once (.mp4, .webm, ogg, flash) and possible have a playlist functionality. Should I ditch the plugin solution entirely and write the code myself?


Create a shortcode that creates a form for users to edit their information

I want to make it so that logged in users can edit their information on a page in my site, so that I can avoid having them go to the admin side all together. I was thinking that I could create a shortcode (in functions.php) that would create the correct table and insert it into the page. I am just starting out with PHP/WordPress so I'm not sure if this is the right path to follow - are there any good resources out there to point me in the right direction?


PHP displaying wrong custom taxonomy images

I'm using the Taxonomy Images plugin to try to pull in the category images for custom categories on a page that displays all the categories my site has. For some reason, this code outputs the correct names and descriptions, but will only show one category image. I'd like the images to do what the other category features do, populate with the appropriate data for each category and display all the categories on the page. If I use `echo wp_get_attachment_image( $imgs[$id], 'thumbnail' );` it publishes all of the images, but if I change that from `echo` to make it a variable, it only displays one image.               $imgs = get_option( 'taxonomy_image_plugin' );     $categories = get_terms('portfolio_category', array('orderby' => 'id', 'hide_empty' => 0));     foreach ( $categories as $category ) {         $id = $category->term_id;         $img = wp_get_attachment_image( $imgs[$id], 'thumbnail' );     }         for($i=0; $i<count($categories); $i++)          {          echo('
'.$categories[$i]->name.'
');          echo($img);          echo('
'.$categories[$i]->description.'
');     }      I guess that I'm just confused as how to add a counter like `[$i]` so that this code outputs the correct category images. Any help would be much appreciated.


How is Wordpress child related to Buddypress child theme

I am new to both. I have installed and created twentytwelve on my local server. I am about to use Buddypress and create its child theme, too. Question is, how these child themes are related to each other now, in terms of editing? What happens if I edit one of them? I have difficulties grasping this concept (I understand the child theme creation, though).


How to find a callback attached to a bbpress hook?

bbpress has a large number of callbacks attached to various hooks. I am familiar with this feature at the wordpress level but I am unable to locate where bbpress registers a large number of these callbacks. Specifically I would like to change the behaviour of the callback which is triggered via:               do_action( 'bbp_template_before_forums_loop' );      If someone could help me locate this callback so that I can change the HTML it outputs that would be greatly appreciated.


Orderby custom date fields with meta_query broken on OR relation

I have an 'event' post type that has custom start and end date fields. In a block on the home page, I'm trying to show only upcoming or ongoing events. So, to achieve this, I'm doing a meta_query that compares the two date fields to today's date with the intent of showing events with start or end date equal to today's date or later. After getting the returned events, I'm sorting by the start date. One important note, some events have end dates, while some are merely one day events with just a start date.               <?php /* Start the loop */     $args = array(         'post_status' => 'publish',         'post_type' => 'event',         'posts_per_page' => 5,         'meta_key' => '_venh_start_date',         'orderby' => 'meta_value',         'order' => 'ASC',         'meta_query' => array(             'relation' => 'OR',             array(                 'key' => '_venh_start_date',                 'value' => date('Y-m-d'),                 'compare' => '>=',                 'type' => 'DATE'             ),             array(                 'key' => '_venh_end_date',                 'value' => date('Y-m-d'),                 'compare' => '>=',                 'type' => 'DATE'             ),         )     );     $my_query = new WP_Query( $args ); ?>     <?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>      The query works but the 'orderby' is broken. If I take the second meta_query (end date) out of the equation and remove the 'OR' relation, the sort works perfectly. So the orderby statement is clearly failing when the second meta_query is added. Does anyone have any ideas what I might be doing wrong? Any help is greatly appreciated! @s_ha_dum, the generated SQL is as follows: `string(640) "SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id) INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id) WHERE 1=1 AND wp_posts.post_type = 'event' AND (wp_posts.post_status = 'publish') AND (wp_postmeta.meta_key = 'x_start_date' OR (mt1.meta_key = 'x_start_date' AND CAST(mt1.meta_value AS DATE) >= '2014-02-24') OR (mt2.meta_key = 'x_end_date' AND CAST(mt2.meta_value AS DATE) >= '2014-02-24') ) GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value ASC LIMIT 0, 5"`


custom post type affecting all categories

I have a custom post type (service_provider) that has               'taxonomies'          => array( 'category', 'post_tag' )      The truoble it is affecting all categories. When I look at the categories and hover on a category I get               http://siteurl.com/wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=14&post_type=service_provider      I am having much trouble with the categories on my site and was wondering if this was normal? This is the full code in my functions.php                   function custom_post_type_service__provider() {              $labels = array(             'name'                => _x( 'Service Providers', 'Post Type General Name', 'embc' ),             'singular_name'       => _x( 'Service Provider', 'Post Type Singular Name', 'embc' ),             'menu_name'           => __( 'Service Providers', 'embc' ),             'parent_item_colon'   => __( '', 'embc' ),             'all_items'           => __( 'All Providers', 'embc' ),             'view_item'           => __( 'View Providers', 'embc' ),             'add_new_item'        => __( 'Add New Provider', 'embc' ),             'add_new'             => __( 'Add New', 'embc' ),             'edit_item'           => __( 'Edit Provider', 'embc' ),             'update_item'         => __( 'Update Provider', 'embc' ),             'search_items'        => __( 'Search Providers', 'embc' ),             'not_found'           => __( 'No providers found', 'embc' ),             'not_found_in_trash'  => __( 'No providers found in Trash', 'embc' ),         );         $args = array(             'label'               => __( 'service_provider', 'embc' ),             'description'         => __( 'Post Type Description', 'embc' ),             'labels'              => $labels,             'supports'            => array( 'title', 'editor', 'thumbnail', 'revisions', 'page-attributes', 'post-formats', 'address' ),             'taxonomies'          => array( 'category', 'post_tag' ),             'hierarchical'        => true,             'public'              => true,             'show_ui'             => true,             'show_in_menu'        => true,             'show_in_nav_menus'   => true,             'show_in_admin_bar'   => true,             'menu_position'       => 5,             'menu_icon'           => '',             'can_export'          => true,             'has_archive'         => true,             'exclude_from_search' => false,             'publicly_queryable'  => true,             'capability_type'     => 'page', 'post'         );         register_post_type( 'service_provider', $args );          }          // Hook into the 'init' action     add_action( 'init', 'custom_post_type_service__provider', 0 );      what I would like to have is two categories for the service provider post-type that stays out of the normal category system. I have news and blog as normal categories and would like them to be separate to the custom categories of public-service & educational-service. If possible?.


Show message on wordpress admin dashboard

I have created a form. On success of the form, I am redirecting the user the their dashboard. Now, I want to be able to show a success message/notice on the dashboard. What is the convention to show such messages ?


how do I get the date in a date archive page

In archive.php, if it is a date archive, can I get the date using a function? Consider a url like this: myfirstsite/2013/08 - I want to get the 2013/08


How to create shortcode of this PHP code

I tried a lot but failed to create shortcode of this PHP snippet:
     <?php     $my_query = new WP_Query('post_status=future&order=DESC&showposts=10');     if ($my_query->have_posts()) {         while ($my_query->have_posts()) : $my_query->the_post();                  $do_not_duplicate = $post->ID; ?>
<?php the_title(); ?>
              <?php endwhile;     }     ?>
      Can you tell me how to do that & also explain how to put PHP codes into shortcodes. Don't need to explain the basic as I know how to create a shortcode.


How to create access to a wordpress site via registration/login page?

What I want is, whenever a visitor tries to access my wordpress site, either by putting in the url or by clicking on a link from external source, he/she has to go via the registration/login page (if not already logged in). Which means, the visitor has to be a member of the site to get access to it. Once the registration is complete, the registrant would be redirected to the login page, and once he logs in, he would be redirected to the page he wanted to visit. How do I do it? Please help.


Google map iframe into wordpress theme

I have embedded a Google Map iframe in my theme and I'm trying to center a Google Map location in the middle of the map. All works fine except that my location is always shown to the upper left corner not the center This is my website: http://tommelopp.no/kontakt/ The pop up is made using javascript to center it. Happy for all suggestions, tips or answers :)


Temporary Infinite Redirect Loop

I have written a custom WordPress plugin for a certain site (this is not a public plugin, it is private written for that specific site). The plugin reads RSS entries from other sites, and then for each RSS entry, it goes to the specific url in the RSS entry, and donwloads more information from that page. This process runs on request. Meaning, there is a 'run' button, and when this button is clicked, the process above starts; and it stops when all the RSS entries are read. Everything works just fine. But sometimes during the run of the process described above, I get an infinite redirect loop error. I am not sure what is causing it. The error stays for about half an hour or an hour. What happens is whenever I go to my site site (while the process is running and when the error happened), I get the message: This webpage has a redirect loop. I cannot go to any webpage on the site, nor I can login to the admin area. I noticed one weird thing as well. My WordPress site is setup in a subdirectory. In other words, if my domain was **www.example.com** , my WordPress files are located at **www.example.com/subfolder** as a security measure. But when I try to go to **www.example.com** and when the redirect error happened, the URL changes to **www.example.com/wp-admin/install.php** (it is even bypassing the subfolder setup, it should have been pointing to **www.example.com/subfolder/wp-admin/install.php** instead). This whole thing clears automatically about half an hour or one hour later and the site would work normally! Now, I do not like this. I do not want this to even happen in the first place. Do you have an idea of why is this happeneing? And do you have an idea on how to fix this? Thanks a lot.


Random header image but also specific header for certain pages

I have a question I'm using a theme where the header image changes in different pages of the page because is set like that. But the main header image stays in all the remain pages.. What I want to do is to randomize 2 main header images everytime you refresh the page but leave the other header images to the other pages... I don't know if I explain myself wellb but I'm leaving the code here. It must me something really easy and if you check out the code, you'll understand what I'm talking about.               <?php         //Define Header Logo         $catImage = "img/vallelogo.png";         if (is_page('994')) {             $catImage = "wp-content/uploads/2013/03/logo_lacomercial.png";         }         if (is_page('1013')) {             $catImage = "wp-content/uploads/2013/03/logo_lacomercial.png";         }         if (is_page('998')) {             $catImage = "wp-content/themes/theme1965/images/logo_lafamosa.png";         }     ?>      I want the first image               $catImage = "/img/vallelogo.png";      along with another image I want to add to randomize in the whole website, but leave the other images to show in those specific pages. How do I add the other image and make those 2 main headers to randomize in the whole website?


current_page_item and custom post type?

I have a page on my site that lists all posts for my custom post type 'Literature'. However when I click on one of the posts, the highlighted active menu item changes to 'Blog'. How do I assign these posts to the menu item 'Literature'? Thanks


Collaborative question/answer plugin for WordPress

I am looking for a collaborative question/answer plugin built in the same sort of style as StackOverflow. Features I am looking for:   * Profiles   * Index of questions with search by tag/title/contents   * Vote up/down   * Edit yours and other peoples questions+answers (wiki style)   * Integrated markdown (or similar) Before you ask, yes I have seen Question and Answer Forum Plugin and WP- Answers but neither have support for collaborative editing.


Wordpress: Display posts by custom select query

I need Wp_query with two custom fields, one custom field for orderby and another: (if this key exists in the post so show the post else dont add this post to query.) I tried like this but doesnt work... Any help?               $args = array(     'post_type' => 'post',     'meta_query' => array(         array(             'key' => 'Apple',         ),         array(             'key' => 'Price',             'type' => 'numeric',         )     ),     'orderby' => 'meta_value_num',     'paged' => get_query_var('paged'),     'order'=> 'DESC',         );     $the_query = new WP_Query( $args );      As you can see I want to show posts which has custom field "Apple", and want to order by the custom field "Price", From lowest to highest price.


Add custom fields when specific templates are selected

I'm trying to make change to a site where with the current infrastructure isn't great as due to how it's been built over the previous site rather then fresh. I have a section of the site which needs it's own custom fields. This section doesn't warrant it's own post type, and due to the state of the site it's extremely impractical to do it this way. What I don't want for the sake of the user is to have to make them use the custom fields as it's pretty sloppy. So, how can I add fields (like you would for a custom post type) when a certain template is selected?


how can I get seperate the HTML in the_content(); output?

I want to be able to seperate the first image form the post into a `<div>` tag and link it to the post page and be able to add html around the post text elements seprately. Any help is greatly appreciated This is what I have tried                               query_posts('posts_per_page=1&tag=food');                     while (have_posts()) : the_post();                     echo "
\n";                         echo the_content();                         echo '';                         the_title();                         echo '';                           echo "
\n";                     endwhile;


Best way to initiate a class in a WP plugin?

I've created a plugin, and of course being me, I wanted to go with a nice OO approach. Now what I've been doing is to create this class and then just below create an instance of this class:               class ClassName {              public function __construct(){              }     }          $class_instance = new ClassName();        I'm assuming there is a more WP way to have this class initiated, and then I came across people saying that they prefer to have an `init()` function than a `__construct()` one. And similarly I found the a few people using following hook:               class ClassName {              public function init(){              }     }     add_action( 'load-plugins.php', array( 'ClassName', 'init' ) );      What is generally considered the best way to create a WP class instance on load and have this as a globally accessibly variable? **NOTE:** As an interesting side point, I've noticed that while `register_activation_hook()` can be called from within the `__construct`, it cannot be called from within the `init()` using the second example. Perhaps someone could enlighten me on this point. **Edit:** Thanks for all the answers, there clearly is a fair bit of debate as to how handle the initialization within the class itself, but I think there's generally a pretty good consensus that `add_action( 'plugins_loaded', ...);` is the best way to actually kick it off... **Edit:** Just to confuse matters, I've also seen this used (although I wouldn't use this method myself because turning a nicely OO class into a function seems to defeat the point of it):               // Start up this plugin     add_action( 'init', 'ClassName' );     function ClassName() {         global $class_name;         $class_name = new ClassName();     }


How to stop wp_postmeta from being called on archive and search pages?

Currently, when I load a search or result page, it queries the `wp_postmeta` table which is leading to the page taking ages to load. I realise this is a result of this table being huge (70k rows), and because of how much data is loaded into the cache. Is there a way to stop `update_post_caches` from being called when these pages are loaded, and then send custom (and more efficient) queries to the database once the template has been loaded? ![enter image description here](http://i.stack.imgur.com/1f1oU.png)


Glossary with Custom Post Type

I´d like to make a glossary. It should looks like: Index-Nav   0-9 | A **B** C ... **M** ... X Y Z **B** BMW **M**   Mercedes   ... **ALL** entries from index-nav (A-Z, O-9) should be visible in a `<ul>` and should linked to the content anchor (only if content isn´t empty). Entry without content should get an additional CSS class. My code (thanks to @Mridul Aggarwal) shows just entries in index-nav when there is content, too. Sorry, I´m not an english native speaker. ### page-my-custom-post-type.php               <?php          $index = 0;     $terms = get_terms('marke');     $range = array_merge(range(0, 9), range('A', 'Z'));          echo '
';     foreach ($terms as $term) {              if(ord($range[$index]) <= ord(strtoupper(substr($term->name, 0, 1)))) {             while($range[$index] != strtoupper(substr($term->name, 0, 1))) {                 echo '
'. $range[$index] . '
';                 $index++;             }             $index = strtoupper(substr($term->name, 0, 1));             echo "
$index
";             $index++;         }          }     echo '
';     ?>
<?php echo $term->name; ?>
         <?php $args = array( 'post_type' => 'cpt_auto', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC',              'tax_query' => array(                 array(                     'taxonomy' => 'marke',                     'field' => 'slug',                     'terms' => array($term->slug)                 )             )         );              // ============================= OUTPUT ==============================         $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();             the_title('
', '
');             the_content();              endwhile;           echo "topFooter";     ?>


User submitted content

I have a project that requires users to register, and submit details ( information on a company ). This need to take place on the front end rather than using the WordPress admin.. I have tried Gravity forms but it fails when I need to make edits to these submissions. Is there a decent solution for modifying the users submitted content, or covering all aspects of this process? One of the bigger issues has also been multiple file uploads and the option for premium listings.


WP eCommerce Product Gallery not working

We're not sure when this started but there was recently an update to WP eCommerce and the Product Gallery has stopped working. Wondering if anyone else has experienced this? What we have tried:   * Deactivating all the other plugins   * Tried different images thinking it might be one culprit.   * Reading documentation to see if something has changed - found nothing. ![enter image description here](http://i.stack.imgur.com/g1U71.png) Thanks


How to exclude the particular category from the woocommerce plugin?

add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );          function custom_pre_get_posts_query( $q ) {          if ( ! $q->is_main_query() ) return;     if ( ! $q->is_post_type_archive() ) return;     if ( ! is_admin() ) {          $q->set( 'tax_query', array(array(     'taxonomy' => 'product_cat',     'field' => 'slug',     'terms' => array( 'membership' ), // Don't display products in the membership category on the shop page     'operator' => 'NOT IN'     )));     }          remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' );          }      I used the above code to exclude the membership category in the shop page. Its working on the shoppage but it display in the homepage i need to know how to exclude the particular category in all those page . Basic idea is to be download the products only for the membership. I added the membership as the seperate product category , Also i exclude that category from the shop page but it displaying in the homepage . I don't how to do this in the woocommerce plugin.


What are the benefit in adding hook in the init() hook?

I see a lot of plugins using this approach to add a new hook, e.g.               add_action('init', function() {        add_action('SOME_LATER_HOOK', xxx);        add_filter('SOME_LATER_FILTER', yyy);     });      Why they don't just add the hook directly? I see there are no benefit anyway, e.g. performance Why not just               add_action('SOME_LATER_HOOK', xxx);


Default value for add_settings_field

I'm creating a simple settings page by following these instructions. Since this is a custom plugin, I'd like one of my settings to start with a predefined value (that can later be changed). What is the recommended way to set a default value for a setting added with `add_settings_field`?


How to show static placeholder when less post elements in archive page?

I'm doing an archive page for a theme that will contain only images thumbnails. The maximum amount of thumbnails that the page layout can contains is 12. So as query I would like to been able to get two different results. If there is 12 thumbnails, show them all. If there is less than that maximum, fill the rest with the amount of placeholder that you need to bring the result to 12. Here my first draft:                <?php               $count = 1;         query_posts( 'posts_per_page=12&order=ASC' );              if (have_posts()) : while (have_posts()) : the_post(); ?>
                 <?php if ( has_post_thumbnail() ) {                  ?>                           <a href="<?php echo get_permalink(); ?>"><?php the_post_thumbnail(); ?>                           <?php                      }                      ?>
                       <?php $count++;           endwhile; endif; ?>              <?php if ($count < 12) { ?>
     <img src="<?php bloginfo('template_directory'); ?>/images/thumb.png" alt="" />
     <?php } ?>
                    <?php wp_reset_query(); ?>


Changing functions.php and .htaccess files

Can I mess up my Wordpress site if I change `functions.php` file for my custom theme? One time I added some code to it and it gave me some PHP errors and my site was inaccessible. Luckily it was in the early stage of the website so I just reinstalled Wordpress. So, my actual question is - does `functions.php` file have any influence on any other file or database or any other part of the website? If I have a back up of the `functions.php` file, can I just replace the screwed up file via FTP or do I have to do something else? The same questions goes for `.htaccess` file - if I add this code:               php_flag register_globals off      to it, can I change something irreversibly or do I just upload the back up and all goes back to normal?


WP appending -2 to the end of my slug. Where are the originals stored so I can delete them?

I've been learning about taxonomies, custom posts etc though a lot of trial and error. I finally have it working how I want, however now I am getting some conflict with my desired slugs. I can't name my category "venue" because someplace in the database, that's already taken (I assume) - even though I've deleted the category that used it. Now when I try adding the category that I want to use the "venue" slug, WP automatically makes it "venue-2", which I definitely don't want in my url as the folder. Any suggestions for this?


what is the way to see the currently executing query in wordpress?

I am working on wordpress which is new to me Now I have been provided with site completely designed in wp But the problem is I am unable to search the query for each functionality/page I found               $wpdb->get_results      used for getting result from database also this is not working               $wpdb->queries      Is there any way to print each query currently executing?. Please Help.


API JSON Data in WordPress

On the _Google developer API_ page, it talks briefly on retrieving a dynamic list of fonts using JSON/JavaScript. I was wondering how would I be able to pull the web fonts API into my Wordpress theme so that I'm not creating my own list or have to constantly release an update of fonts. Thank you.


How to auto-approve internal pingbacks?

Whenever I write a post on my blog and link to a previous post, that pingback shows up as a comment needing to be approved. I am running Disqus, but this was happening even pre-use of that plugin. ![comment settings](http://i.stack.imgur.com/x9UdB.png) What is the fix for this behavior?


How to show last comment on hover?

WordPress usually has "Leave a Comment, "1 Comment," or "% Comments" on the blog page, and I want people to be able to hover over that and have jQuery show the latest comment in a rectangular box below it (pushing down all subsequent content). Obviously they'd click through to read more comments or respond, but I can't figure out where to start and go from there. As an example, if you look at the site Destructoid, they show the latest comment after each post. I want to show something similar, but only after the "# comments" is hovered over. Only then would the box with the latest comment show up and push the rest of the content down. It would disappear if the mouse is moved off of the link or box itself. I figure get_comments can be used to call it, but comments_popup_link doesn't take arguments for alt text or jQuery boxes, I don't think. Any suggestions?


Not Found (404) error on admin page, CSS gone on blog

I manually installed wordpress on my server and the wordpress files are located in "www.mydomain.com/wordpress/", however I wanted my "www.mydomain.com" to be the address for my wordpress blog instead of "www.mydomain.com/wordpress/" so I went to the "Settings->General" screen in my dashboard and changed the "Home" url to "www.mydomain.com/wordpress" and the "Site" url to "www.mydomain.com" thinking it would make my home address the blog address. When I went back to the admin page I get a "Not Found (404)" error message and all the CSS formatting is gone from my blog. Is there a way to reset my settings?


Add "Delete" button to my Theme

I'd like to be able to delete my custom theme from within Wordpress. This option is available for the default themes, via the screenshot link below. There is a red "Delete" link in the Theme management area, but it isn't available for my custom theme. How can I enable this for a custom theme? http://screencast.com/t/25h7k08vrE


is_front_page, is_page('slug'), is_page(id) not working

None of the following are working to display conditional format in the sidebar when the current page is the home page:   * is_front_page,   * is_page('home'),    * is_page(id) I added an else clause which is implemented on the home page. In Options > Reading, I have specified a page called Home to be the front page. The slug 'home' and the page id of 13 (obtained from the URL when editing the Home page) all return false. If I place `<?php the_ID(); ?>` in the sidebar, it displays the post ids of blog posts which are also displayed (title only) by home.php (which is the template assigned to the home page). I don't know how else to explicitly display the page id on the front end so I know I'm using the correct id.


How much string content can I store in an option?

I am about to create a new plugin that fetches remote content and stores it locally for use on the WP website. I have a free plugin that does this with twitter and tweets, and I store a JSON file in the plugin directory. Some users complain that the plugin cannot write files to the folder due to permissions. For this reason, I have been thinking about storing the remote content for this new plugin in an option. Is 250kb of HTML too big for an option? Is there another API call that can help me store a large chunk of string data?


How to display the top 5 popular links in the header?

I want to display the top 5 popular links in the header. How will I do this? Also want to display the page hits in the brackets with the links. Any one who can help?


insert data from form to custom table

I have a custom form set up on a custom page template. I need the submitted data to be saved in custom table. What am I missing since this isn't send the data? The code I'm using: (http://pastebin.com/awpZSVe7)


ABSPATH in Windows

I'm having a a pain in the head using the `ABSPATH` constant in Windows.   Addressing files and folders in Windows is usually done using the `\` (forward-slash) character while for Linux the character would be `/` (backslash).   Unfortunately the `ABSPATH` in Wordpress is defined with only Linux in mind (putting a `/` at the end of it).   I wonder if I can over-ride it's definition since in `wp-config.php` it's defined under an `if` clause which indicates it can be defined elsewhere. **Problem detalis:**   1. I'm running on `localhost`   2. The problem is with the `statpress-visitors` internal addressing. This is how it addresses the files:               ABSPATH . 'wp-content/plugins/' . dirname(plugin_basename(__FILE__)) . '/def/os.dat'      And this is what I get as output:               C:\wamp\www\wp/wp-content/plugins/statpress-visitors/def/os.dat


Adding extra authentication field in login page

I am going to enhance my WordPress authentication page. My idea is that simply adding an extra field into the login page. The extra field will require user to enter personal identification code (4 to 8 digit). I have changed the login page layout in "wp-login.php" and added extra column for storing personal identification code in MySQL database. However, I don't know which part of coding is used to verify the password as I want to refer to the existing coding. Could you help me?


What Plugins Demonstrate Great WP Plugin Development?

I'm going to be tackling my first plugin soon and I'm looking for plugins which you feel are of very high quality, under the hood. Stuff I can use as an example while I design the framework for my plugin. Any ideas? Please include what makes it a great plugin.


Plugin Development: WPMU or WP?

I was thinking, what kind of issues might I face if I port a plugin from WPMU to WP or vice versa. Say I developed a plugin from scratch and wanted that plugin to be compatible with both, should I begin with WPMU or WP?


How do I check if a post has a post thumbnail in WP_Query?

I want to grab the 5 most recent posts that have thumbnails.


wordpress is_page() problem

I want to load a .js file only on a specific page in Wordpress 3.1.2 So I use in functions.php               function my_init_method() {     if (is_page('myinfopage')){        echo "yeeessssssss";        //wp_register_script('RGraph',get_stylesheet_directory_uri() . '/js/RGraph/RGraph.common.core.js' );        }     }     add_action('init', 'my_init_method');      The page is 100% 'myinfopage'. I tried it also with the pageID 24 if (is_page(24)){.... But nothing happens. It's not included and noe 'yeeesssss' is displayed. Any idea? Cheers, Joerg


Create own pdf invoice in combo with wpcf7?

I am looking for some examples and best strategies to make a custom pdf invoice with WP plugin contact form 7 data. For this, i am trying out the tcpdf library as i need to create a simple barcode per invoice as well. Any tips or info? regards


How can I autopopulate titles in the media library?

I have hundreds of images in my media library, most have which have no titles. In the media library, the "(no title)" message is displayed along these images. Since I generally have one image per post, I would like to auto-populate the library titles, by grabbing the associated post name. I don't mind if I overwrite some existing titles. Does anyone know of a hack that will do this? I found some plugins, like 'Media Rename' and 'Rename Media' and 'SEO friendly images' but they are usually for renaming the actual image files, or for creating HTML title tags directly in the HTML (on the fly). I want to create titles within the Wordpress media library, so that I don't see the (no title) message. This title data will also help me to search for images in the library -- although, for anyone with the same issue, I did find a plugin called 'Media Search' that enables searching images by associated posts: http://wordpress.org/extend/plugins/media-library-search/


Assign CPT archive page attributes

I have a custom post type `recipes` which uses the `archive-recipes.php` template automatically. I have a Wordpress page called `Top Recipes` which is set to use the `archive- recipes.php` template in the CMS. When browsing to `www.mysite.com/top-recipes/` I get the **Top Recipes** title displayed along with the **Featured Image** I set in the CMS followed by the list of recipes. But the problem occurs when browsing to `www.mysite.com/recipes/` The title and featured image are that of the latest recipe to be entered into the database. How can I assign the `/recipes` custom post type archive to have the same title/ featured image as the `Top Recipes` page?


W3 Total Cache Minify Rewrite Error with Wordpress on nginx

I'm trying to get W3 Total Cache to rewrite URLs to minified files. I've tried every tutorial I could find but I don't seem to be able to get it right. I keep getting a W3 Total Cache error saying this: `It appears Minify URL rewriting is not working. If using apache, verify that the server configuration allows .htaccess. Or if using nginx verify all configuration files are included in the main configuration fail (and that you have reloaded / restarted nginx).` My config files for nginx are as follows: **nginx.conf in /etc/nginx/**               user nginx;     worker_processes 2;          error_log       /var/log/nginx/error.log;     pid             /var/run/nginx.pid;          events {             worker_connections 1024;             multi_accept on;     }          http {             include mime.types;             default_type            application/octet-stream;             access_log              off;             sendfile                on;             keepalive_timeout       20;             client_max_body_size    15m;             upstream php {                     server unix:/dev/shm/php-fpm-www.sock;             }             include /etc/nginx/conf.d/default.conf     }      This file links to **/etc/nginx/conf.d/default.conf** :               server {             server_name mydomain.com www.mydomain.com;             listen 8080;             root /var/www/;             index index.php index.html index.htm;                  include /var/www/nginx.conf;             include /etc/nginx/conf.d/wp.conf;     }      This file itself links to **/etc/nginx/conf.d/wp.conf** which looks as follows:               error_page 404 = @wordpress;     log_not_found off;          location / {             try_files $uri $uri/ /index.php?args;     }          rewrite /wp-admin$ $scheme://$host$uri/ permanent;          location @wordpress {         fastcgi_pass php;         fastcgi_param SCRIPT_FILENAME $document_root/index.php;         include fastcgi_params;         fastcgi_param SCRIPT_NAME /index.php;     }          location ~ \.php$ {         fastcgi_max_temp_file_size 1M;         fastcgi_connect_timeout 60;         fastcgi_send_timeout 180;         fastcgi_read_timeout 180;         fastcgi_buffer_size 128k;         fastcgi_buffers 4 256k;         fastcgi_busy_buffers_size 256k;         fastcgi_temp_file_write_size 256k;         fastcgi_index  index.php;         fastcgi_pass php;         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;         include fastcgi_params;         try_files $uri @wordpress;     }      **/etc/nginx/conf.d/default.conf** also links to the **nginx.conf** file W3 Total Cache created in my Wordpress root folder, which looks as follows:               # BEGIN W3TC Minify cache     location ~ /wp-content/cache/minify.*\.js$ {         types {}         default_type application/x-javascript;         expires modified 604800s;         add_header X-Powered-By "W3 Total Cache/0.9.2.8";         add_header Vary "Accept-Encoding";         add_header Pragma "public";         add_header Cache-Control "max-age=604800, public";     }     location ~ /wp-content/cache/minify.*\.css$ {         types {}         default_type text/css;         expires modified 604800s;         add_header X-Powered-By "W3 Total Cache/0.9.2.8";         add_header Vary "Accept-Encoding";         add_header Pragma "public";         add_header Cache-Control "max-age=604800, public";     }     location ~ /wp-content/cache/minify.*js\.gzip$ {         gzip off;         types {}         default_type application/x-javascript;         expires modified 604800s;         add_header X-Powered-By "W3 Total Cache/0.9.2.8";         add_header Vary "Accept-Encoding";         add_header Pragma "public";         add_header Cache-Control "max-age=604800, public";         add_header Content-Encoding gzip;     }     location ~ /wp-content/cache/minify.*css\.gzip$ {         gzip off;         types {}         default_type text/css;         expires modified 604800s;         add_header X-Powered-By "W3 Total Cache/0.9.2.8";         add_header Vary "Accept-Encoding";         add_header Pragma "public";         add_header Cache-Control "max-age=604800, public";         add_header Content-Encoding gzip;     }     # END W3TC Minify cache     # BEGIN W3TC Page Cache cache     location ~ /wp-content/cache/page_enhanced.*html$ {         expires modified 3600s;         add_header X-Powered-By "W3 Total Cache/0.9.2.8";         add_header Vary "Accept-Encoding, Cookie";         add_header Pragma "public";         add_header Cache-Control "max-age=3600, public";     }     location ~ /wp-content/cache/page_enhanced.*gzip$ {         gzip off;         types {}         default_type text/html;         expires modified 3600s;         add_header X-Powered-By "W3 Total Cache/0.9.2.8";         add_header Vary "Accept-Encoding, Cookie";         add_header Pragma "public";         add_header Cache-Control "max-age=3600, public";         add_header Content-Encoding gzip;     }     # END W3TC Page Cache cache     # BEGIN W3TC Browser Cache     gzip on;     gzip_types text/css text/x-component application/x-javascript application/javascript text/javascri$     location ~ \.(css|htc|js|js2|js3|js4)$ {         expires 604800s;         add_header Pragma "public";         add_header Cache-Control "max-age=604800, public";         add_header X-Powered-By "W3 Total Cache/0.9.2.8";     }     location ~ \.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {         expires 3600s;         add_header Pragma "public";         add_header Cache-Control "max-age=3600, public";         add_header X-Powered-By "W3 Total Cache/0.9.2.8";         try_files $uri $uri/ $uri.html /index.php?$args;     }     location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe$         expires 604800s;         add_header Pragma "public";         add_header Cache-Control "max-age=604800, public";        add_header Link "<$scheme://$host$uri>; rel=\"canonical\"";         add_header X-Powered-By "W3 Total Cache/0.9.2.8";     }     # END W3TC Browser Cache     # BEGIN W3TC Minify core     rewrite ^/wp-content/cache/minify.*/w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/mini$     set $w3tc_enc "";     if ($http_accept_encoding ~ gzip) {         set $w3tc_enc .gzip;     }     if (-f $request_filename$w3tc_enc) {         rewrite (.*) $1$w3tc_enc break;     }     rewrite ^/wp-content/cache/minify/(.+\.(css|js))$ /wp-content/plugins/w3-total-cache/pub/minify.ph$     # END W3TC Minify core     # BEGIN W3TC Page Cache core     set $w3tc_rewrite 1;     if ($request_method = POST) {         set $w3tc_rewrite 0;     }     if ($query_string != "") {         set $w3tc_rewrite 0;     }     if ($http_cookie ~* "(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_swit$         set $w3tc_rewrite 0;     }     set $w3tc_enc "";     if ($http_accept_encoding ~ gzip) {         set $w3tc_enc _gzip;     }     set $w3tc_ext "";     if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index.html$w3tc_enc$         set $w3tc_ext .html;     }     if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index.xml$w3tc_enc"$         set $w3tc_ext .xml;     }     if ($w3tc_ext = "") {       set $w3tc_rewrite 0;     }     if ($w3tc_rewrite = 1) {         rewrite .* "/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ext$w3tc_enc" $     }     # END W3TC Page Cache core     # BEGIN W3TC CDN     location ~ \.(ttf|otf|eot|woff)$ {        add_header Access-Control-Allow-Origin "*";     }     # END W3TC CDN      During copy pasting from nano in my terminal some lines weren't entirely in screen, but these are all standard W3 Total Cache settings, I haven't touched them. They should be ok. I've got my server setup with nginx on port 8080, varnish on port 80, php5-fpm and MySQL. If anyone can help me out on this, that would be amazing. If you need more info, config files, etcetera, please let me know.


Query custom post type in the loop

I have a custom post type running called services:               // Services     function services_cpt() {       $labels = array(         'name'               => _x( 'Services', 'post type general name' ),         'singular_name'      => _x( 'Service', 'post type singular name' ),         'add_new'            => _x( 'Add New', 'production' ),         'add_new_item'       => __( 'Add New Service' ),         'edit_item'          => __( 'Edit Service' ),         'new_item'           => __( 'New Service' ),         'all_items'          => __( 'All Services' ),         'view_item'          => __( 'View Service' ),         'search_items'       => __( 'Search Services' ),         'not_found'          => __( 'No services found' ),         'not_found_in_trash' => __( 'No services found in the Trash' ),          'parent_item_colon'  => '',         'menu_name'          => 'Services'       );       $args = array(         'labels'        => $labels,         'description'   => 'Holds our services and service specific data',         'public'        => true,         'menu_position' => 5,         'supports'      => array( 'title', 'editor', 'thumbnail' ),         'has_archive'   => true,       );       register_post_type( 'services', $args );      }     add_action( 'init', 'services_cpt' );      I would like to use a page template to display the posts instead of archive- services.php. I have built the following page template:               <?php     /*     Template Name: Services     */     // Get header     get_header(); ?>
     <?php $loop = new WP_Query( array( 'post_type' => 'services', 'posts_per_page' => -1 ) ); ?>     <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
     <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('medium'); ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>
     <?php the_content(); ?>
               <?php endwhile; wp_reset_query(); ?>
     <?php get_footer(); ?>      When I go to the page on the front-end, it's displaying the default archive.php. I can't figure out what I'm doing wrong. Any help is much appreciated :)


Multiple options in the options_value field of the wp_options table

I have come across a theme that has a way of having multiple options in the option_value field.For instance,in the theme,one can perform the Create,Read,Uodate and Delete functionalities on such fields as -image url -link url -description The wp_options has the following fields: > option_id / blog_id / option_name / option_value / autoload How is this being done?.


Control load order?

I have a full-width slider on my wp homepage. It's always last to load and everything else gets shoved around when it appears. Any way to hold the whole page from loading until it's ready, or force this element to load first?? Thanks


Convert PHP readfile to WP_Filesystem

In the script below, I need to convert the readfile to the WP_filesytem equivalent. However, I can't find same in Codex. Any help much appreciated. This script saves the settings.ini file to the user's desktop/pc.               WP_Filesystem();     global $wp_filesystem;          $mySettingsFileLocation = WP_PLUGIN_DIR.'/my-settings/settings.ini';          if ( ! $wp_filesystem->put_contents( $mySettingsFileLocation, $mySettings, 0644) ) {         return true;     }               // Define the path to file      $file = WP_PLUGIN_DIR.'/my-settings/settings.ini';           if(!$file)      {              // File doesn't exist, output error              die('file not found');      }      else      {      // Set headers      header("Cache-Control: public");      header("Content-Description: File Transfer");      header("Content-Disposition: attachment; filename=settings.ini");      header("Content-Type: application/ini");      header("Content-Transfer-Encoding: binary");           // Read the file from disk      readfile($file);      }


How does Wordpress redirect to WooCommerce shop page?

I'm creating a plugin for WooCommerce, it needs a parameter in the url of shop page like this `http://domain/wp/shop/?param=value`. It worked fine until I set the shop page as front page, when I access `http://domain/wp`, it is showing the shop page, but when I access it with the parameter (`http://domain/wp/?param=value`), it's showing the blog index page. So, I want to ask where exactly in the Wordpress code that redirects the url to WooCommerce shop page? so I may be able to change the redirection behaviour or something else.


Loop output for custom plugin [solution found]

I am trying to update my plugins to be more user-friendly. One of the things i want to achieve is that i want my plugins output (e.g. for description-fields) to use the full functionality of all normal wordpress posts and pages (use TinyMCE and Loop-Output). I've found a great article on using the tinyMCE right here but what I'm still stuck at is the usage of loop formatting by other plugins. Given Example: I use a download manager plugin. In custom posts and pages i can write `[download id=1]` and it get's nicely formatted by the asociated plugin. I want this functionality in my custom plugins, too. Right now this is the way i do my plugin output:               add_filter('the_content', array(&$myclass, 'myclass_callback'), 7);      and myclass_callback is the following:               public function myclass_callback($sIn)     {       if (isset($_GET['myc_id']) && is_numeric($_GET['myc_id'])) {         $sOut = $this->myclass_detail((int)$_GET['myc_id']);         return str_replace('[[MYCLASS_TAG]]', $sOut, $sIn);       }       $sOut = $this->myclass_index();       return str_replace('[[MYCLASS_TAG]]', $sOut, $sIn);     }      And this approach doesn't bring my wanted result :) So i am trying to figure out how to, but apparently I'm not good enoug of a googler to do so :S Any links or keywords for me to search for will be greatly appreciated. Thanks in advance!


Display trimmed version of the_post()

I am using the following code to display pages on one page and would like to trim the content of each page on this display to 50 words and include images that are attached to the page. How do I go about doing this?                 $args = array(                 'post_type' => 'page',                 'post_parent' => '6',                 'order'=> 'DESC'                      );                 query_posts($args);                 while ( have_posts() ) : the_post();


How to create a simple slideshow out of a post image gallery?

Are there any solutions to transform a default image gallery into a simple slideshow as seen in this theme? Note: click to move to the next picture in the gallery.


Vimeo Feed gived dead link with RSS widget?

I have RSS widget on my home page (footer) pointing to a RSS feed from Vimeo. The videos pull in fine, and the links for these work. The orange RSS icon also takes you to the actual RSS feed. However, the title takes you to a 404. I am not sure if this is a fault of how Vimeo is setup, or the widget. Can anyone think of a workaround to ensure this title is not a dead link? This short screencast explains the situation.


How to insert pictures without hard coded dimensions?

How can I insert pictures into a post without any hard coded dimensions (e.g. `<img src="" alt="" />` instead of `<img src="" alt="" width="" height="" />`)? I don't want my users to switch to the HTML tab and remove the parameters by themselves, so I was wondering if there is any filter I can use to achieve this? Note: I'm already inserting them in "Full size".


Editor cannot access Theme Options

I created a custom theme for Wordpress and customized the backend to have a white label look and feel. I am able to load up the options page and save settings (which push to a CSS file) from the Administrator menu. When I try to access this from the Editor level it attempts to load: http://MYURL.COM/wp-admin/functions.php rather than http://MYURL.COM/wp-admin/admin.php?page=functions.php I was originally able to pull up the options menu with the Editor account. When I would attempt to save it, I would receive the error that I couldn't save. While changing access levels the problem seems to have gotten worse. I read through 3-4 pages of search and couldn't find something that was relavant to my issue, sorry! Below is the code for my functions.php:               <?php     $themename = "Sleek v0.1";     $shortname = "sleek";     $options = array (          /*Declare the variables needed*/          array( "name" => "General Settings",     "type" => "title"),          array( "type" => "open"),          array( "name" => "Call Analytics Number",     "desc" => "This is the call tracking number for the marketing campaign.",     "id" => $shortname."_phone_number",     "type" => "text",     "std" => "(888) 555-5555"),          array( "name" => "MerchEngines Customer ID",     "desc" => "This is the Customer ID in the MerchEngines dashboard",     "id" => $shortname."_cust_id",     "type" => "text",     "std" => "0000"),          array( "name" => "Navigation",     "type" => "title"),          array( "type" => "open"),          array( "name" => "Navigation Bar Background Color",     "desc" => "This is the background color for the top navigation bar and footer. (Default: #000000)",     "id" => $shortname."_navBarColor",     "type" => "text",     "std" => "#000000"),          array( "name" => "Navigation Bar Text Color",     "desc" => "This is the text for the top navigation bar and footer. (Default: #ffffff)",     "id" => $shortname."_navTextColor",     "type" => "text",     "std" => "#ffffff"),          array( "name" => "Current Tab Color",     "desc" => "This is the tab color for the current page (Default: #920000)",     "id" => $shortname."_currentTabColor",     "type" => "text",     "std" => "#920000"),          array( "name" => "Hover Tab Color",     "desc" => "This is the tab color for the current page. (Default: #920000)",     "id" => $shortname."_hoverTabColor",     "type" => "text",     "std" => "#c00000"),          array( "name" => "Call to Action",     "type" => "title"),          array( "type" => "open"),          array( "name" => "Stand Out Font Color",     "desc" => "This is the contrast color used by the CTA phone numbers and the stand out wording within the inForm. (Default: #c00000)",     "id" => $shortname."_CTAstandOutColor",     "type" => "text",     "std" => "#c00000"),          array( "name" => "Base Color",     "desc" => "This is the base color used by the CTA text and the base wording within the inForm. (Default: #000000)",     "id" => $shortname."_CTAbaseColor",     "type" => "text",     "std" => "#000000"),          array( "name" => "Checkmark Color",     "desc" => "This is the color of the 'Feature' checkmarks. Color options are: red, darkred, blue, darkblue, green, darkgreen, purple, and orange (Default: red)",     "id" => $shortname."_checkMarkColor",     "type" => "text",     "std" => "red"),          array( "name" => "Bottom Call to Action Text",     "desc" => "This is the bottom call to action text following the phone number. (Default: for more information!)",     "id" => $shortname."_bottomCTAText",     "type" => "text",     "std" => "for more information!"),          array(  "name" => "Test Drop Down",         "desc" => "Test for a drop down box.",         "id" => $shortname."_test_dropdown",         "type" => "select",         "std" => "red",         "options" => "red, green, blue"),          array( "type" => "close")          );          function mytheme_add_admin() {          global $themename, $shortname, $options;          if ( $_GET['page'] == basename(__FILE__) ) {         if ( 'save' == $_REQUEST['action'] ) {             foreach ($options as $value) {             update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }             foreach ($options as $value) {         if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }          header("Location: themes.php?page=functions.php&saved=true");     die;              } else if( 'reset' == $_REQUEST['action'] ) {             foreach ($options as $value) {             delete_option( $value['id'] ); }          header("Location: themes.php?page=functions.php&reset=true");     die;          }     }          add_menu_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');          }     function mytheme_add_init() {       $file_dir=get_bloginfo('template_directory');       wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");       }           function mytheme_admin() {          global $themename, $shortname, $options;          if ( $_REQUEST['saved'] ) echo '

'.$themename.' settings saved.

';     if ( $_REQUEST['reset'] ) echo '

'.$themename.' settings reset.

';          ?>

<?php echo $themename; ?> Settings
          <form method="post">          <?php foreach ($options as $value) {     switch ( $value['type'] ) {          case "open":     ?>
          <?php break;          case "close":     ?>

          <?php break;          case "title":     ?>

<?php echo $value['name']; ?>

          <?php break;          case 'text':     ?>
     <?php echo $value['name']; ?>	     <input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php     echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings(     $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" />

     <?php echo $value['desc']; ?>

          <?php     break;          case 'textarea':     ?>
     <?php echo $value['name']; ?>	     <textarea name="<?php echo $value['id']; ?>" style="width:400px; height:200px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?></textarea>

     <?php echo $value['desc']; ?>

          <?php     break;          case 'select':     ?>
     <?php echo $value['name']; ?>	     <select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select>

     <?php echo $value['desc']; ?>

          <?php     break;          case "checkbox":     ?>
     <?php echo $value['name']; ?>	     <?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{     $checked = "";} ?>     <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />

     <?php echo $value['desc']; ?>

          <?php break;          }     }     ?>
     <input name="save" type="submit" value="Save changes" />     <input type="hidden" name="action" value="save" />
     </form>     <form method="post">
     <input name="reset" type="submit" value="Reset" />     <input type="hidden" name="action" value="reset" />
     </form>
     <?php     }add_action('admin_menu', 'mytheme_add_admin');     add_action('admin_init', 'mytheme_add_init');     ?>


How to modify Publish metabox?

I'm trying to remove "Pending Review" (Status) and "Password protected" (Visibility) options from Publish metabox. Any ideas how can I do it?


admin search of pages returns custom post types

I was looking for a particular page today and got search results that surprised me. Here's what happened:   * start on Dashboard->Pages->All Pages   * search "standard"      * URL= http://example.com/wp-admin/edit.php?s=standard&post_status=all&post_type=page&action=-1&m=0&paged=1&action2=-1   * get list of some pages, some posts, some custom posts of types ash_dyeing and ash_loomsong   * try searching a different term and receive error message: "Invalid post type" So I wondered if all the admin post searches were wonky. I tried again from   * Dashboard->Posts->All Posts      * http://example.com/wp-admin/edit.php?s=standard&post_status=all&post_type=post&action=-1&m=0&cat=0&paged=1&mode=list&action2=-1     * posts, pages and custom post types returned   * Dashboard->Dyeing Samples->All Dyeing Samples      * http://example.com/wp-admin/edit.php?s=standard&post_status=all&post_type=ash_dyeing&action=-1&m=0&paged=1&mode=list&action2=-1     * posts, pages and custom post types returned As you can see, all the urls are the same except for post_type=X, which appears to be ignored. Why might that happen and how can I fix it? System details: -wp 3.3.1 -theme: Suffusion 3.9.6 with child theme ETA: Turns out this _is_ a plugin problem, specifically Events Manager 5.0.51. It can be resolved by setting the plugin's 'Include in WordPress Searches?' option to 'yes'


Media > Image Sizes aren't being applied to uploads

Under Media Settings I edited the Image Sizes to the following:   * Thumbnail size: 170x80   * Medium size: 550x170   * Large size: 550x320   * ("Crop thumbnails to exact dimensions" is checked)   * Maximum embed size: Width 1000, Height 1000 My problem is when I upload an image it ignores these dimensions. For example, when I upload a 550x320 image, and then try to add it to a post, it has been cropped to the following sizes (uploads folder shows the same):   * Thumbnail size: 137x80   * Medium size: 292x170   * Large size: (unavailable)   * Original size: 550x320 How can I get these image sizes working correctly?


Can I change ownership of my plugin?

By adding a new committer and removing the original committer can I effectively change ownership of plugin? I would like to transfer a plugin to a new wordpress.org profile. I am the author.


Confirmation required on email change

I'm just wondering why wordpress doesn't send confirmation mail every time user change his/her email address. How do we know that email address is not fake or mistyped? So can anyone give me some snippet to implement this function? ## Update: Here is the idea.   1. user changes his/her mail   2. We send confirmation email.   3. If the user confirm that email in X days by clicking confirmation link, then the email should be changed. Else we should use existing email.


Send Notifications to All Admins

I want to, hopefully without a plugin, get and loop through all admin accounts and notify each admin when a comment has been posted or a user has registered, etc. I tried to look into this but all the solutions pointed to plugins and all the plugins are either bulky or outdated which totes sucks. Is there a nice little filter that someone knows about where I can hook into notifications and send the notification to each / every administrator?