custom post type metaboxes not saving

I have the following code. I am trying to enter data into the custom metabox and then save it. When I go to view it has entered a post, however the name column has nothing in it. Also when I hit save I get a post.php page with a blank page, is this a page I need to create in my theme and have it go back to the current page or something.               <?     /**     *   Custom post-type booktime     **/          add_action('init', 'booktime_register');          function booktime_register() {              $labels = array(             'name' => _x('booktime', 'post type general name'),             'singular_name' => _x('booktime', 'post type singular name'),             'add_new' => _x('add new', 'add new'),             'add_new_item' => __('add new item'),             'edit_item' => __('edit item'),             'new_item' => __('new item'),             'view_item' => __('view item'),             'search_items' => __('search items'),             'not_found' =>  __('nothing here'),             'not_found_in_trash' => __('not found in trash'),             'parent_item_colon' => ''         );              $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             'rewrite' => true,             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => null,             'supports' => array('title','editor','thumbnail','comments','custom-fields','revisions')           );              register_post_type( 'booktime' , $args );     }          ?>          <?php          add_action("manage_posts_custom_column",  "booktime_custom_columns");     add_filter("manage_edit-booktime_columns", "booktime_edit_columns");          function booktime_custom_columns($column){         global $post;              switch ($column) {             case "name":                 the_excerpt();             break;             case "address":                 $custom = get_post_custom();                 echo $custom["address"][0];             break;             case "phone":                 $custom = get_post_custom();                 echo $custom["phone"][0];             break;             case "date":                 $custom = get_post_custom();                 echo $custom["date"][0];             break;             case "bottles":                 $custom = get_post_custom();                 echo $custom["bottles"][0];             break;              }     }          function booktime_edit_columns($columns){         $columns = array(             "cb" => "<input type=\"checkbox\" />",             "title" => "Post should show",             "description" => "name",             "address" => "address",             "phone" => "phone",             "date" => "date",             "bottles" => "bottles"         );              return $columns;     }          ?>          <?php     add_action("admin_init", "admin_init_booktime");          function admin_init_booktime(){              add_meta_box("name", "name", "name", "booktime", "normal", "low");          }     ?>          <?php     function name() {         global $post;         $custom = get_post_custom($post->ID);         $name = ( !empty($custom["name"][0]) ) ? $custom["name"][0]: "";         ?>
Name:
             <input type="text" name="name" value="<?php echo $name; ?>"/>
         <?php     }     ?>          <?php     add_action('save_post', 'save_details_booktime');          function save_details_booktime(){         global $post;         $custom_meta_fields = array( 'name' );              foreach( $custom_meta_fields as $custom_meta_field ):             if(isset($_POST[$custom_meta_field]) && $_POST[$custom_meta_field] != ""):                 update_post_meta($post->ID, $custom_meta_field, $_POST[$custom_meta_field]);             endif;         endforeach;          }     ?>


How to get post ID in post_updated action hook?

I want to execute a function, myfunction() [hypothetically named], whenever a page is updated in the admin. The function doesn't do anything to the content that is saved—it just runs an unrelated task elsewhere. I read that the `post_updated` hook is good to use for this, but I cannot seem to get this code to run:               add_action('post_updated', 'myfunction');          function myfunction() {         // check if this is a page         $id = get_the_id();         if ( is_page($id) ) {             // do stuff here         }     }      I'm sure I'm missing something obvious; do I have to pass in/return parameters ($post_ID, $post_after, $post_before, from what I gather in the Wordpress Hooks Database) for it to work? If I just want the ID, do I still have to pass in/return the other two?


Wordpress.com Stats stats_get_csv with custom field?

I am trying to figure out how to add a custom field to display an image instead of a title on the stats_get_csv from Wordpress stats.                 <?php if ( function_exists('stats_get_csv') && $top_posts = stats_get_csv('postviews', 'days=2&limit=6') ) : ?>
     <?php foreach ( $top_posts as $p ) : ?>
<a href="<?php echo $p['post_permalink']; ?>"><?php echo $p['post_title']; ?>
     <?php endforeach; ?>
     <?php endif; ?>      **Update**               <?php if ( function_exists('stats_get_csv') && $top_posts = stats_get_csv('postviews', 'days=2&limit=6') ) : ?>         <?php if ( get_post_meta($post->ID, 'Image', true) ) : ?>
                 <?php foreach ( $top_posts as $p ) : ?>
                         <img class="thumb" src="<?php echo get_post_meta($post->ID, 'Image', true) ?>" alt="<?php the_title(); ?>" height='100' width='100' />
                 <?php endforeach; ?>
         <?php endif; ?>     <?php endif; ?>


Return ID of authors who have at least one post

I found a great piece of code here that returns the ID's of users by role. What I would like to do is modify it so it only returns the ID's of the users who have at least one post. I have tried to `INNER JOIN` the `$wpdb->posts` table and feel that I did that correctly but not sure. Here is what I have so far:               function getUsersByRole( $roles ) {         global $wpdb;         if ( ! is_array( $roles ) ) {             $roles = explode( ",", $roles );             array_walk( $roles, 'trim' );         }         $sql = '             SELECT  ID, display_name             FROM ' . $wpdb->users . ' INNER JOIN ' . $wpdb->usermeta . ' ON ' . $wpdb->users . '.ID=' . $wpdb->usermeta . '.user_id             AND INNER JOIN '. $wpdb->posts .'  ON ' .$wpdb->users . '.ID=' . $wpdb->posts . '.post_author             WHERE   ' . $wpdb->usermeta . '.meta_key        =       \'' . $wpdb->prefix . 'capabilities\'              AND     (         ';         $i = 1;         foreach ( $roles as $role ) {             $sql .= ' ' . $wpdb->usermeta . '.meta_value    LIKE    \'%"' . $role . '"%\' ';             if ( $i < count( $roles ) ) $sql .= ' OR ';             $i++;         }         $sql .= ' ) ';         $sql .= ' ORDER BY display_name ';         $userIDs = $wpdb->get_col( $sql );         return $userIDs;     }      Which the SQL query outputs > SELECT ID, display_name FROM wp_users INNER JOIN wp_usermeta ON > wp_users.ID=ba_usermeta.user_id AND INNER JOIN wp_posts ON > wp_users.ID=ba_posts.post_author WHERE wp_usermeta.meta_key = > 'wp_capabilities' AND ( wp_usermeta.meta_value LIKE '%"author"%' OR > wp_usermeta.meta_value LIKE '%"editor"%' ) ORDER BY display_name I've never used `INNER JOIN` (or `JOIN`) so I could doing it wrong. I also think I need to do a count or something to make sure I get a result. Any help would be awesome **EDIT:** Here is the full working function as PHP for anyone who finds this later                   function getUsersByRole( $roles ) {         global $wpdb;         if ( ! is_array( $roles ) ) {             $roles = explode( ",", $roles );             array_walk( $roles, 'trim' );         }         $sql = 'SELECT ID, display_name             FROM '. $wpdb->users .'             JOIN '. $wpdb->usermeta.' ON ('.$wpdb->users.'.ID = '.$wpdb->usermeta.'.user_id AND '.$wpdb->usermeta.'.meta_key = \''.$wpdb->prefix.'capabilities\')             WHERE ID IN (SELECT post_author FROM ' .$wpdb->posts.')             AND(';         $i = 1;         foreach ( $roles as $role ) {             $sql .= ' ' . $wpdb->usermeta . '.meta_value    LIKE    \'%"' . $role . '"%\' ';             if ( $i < count( $roles ) ) $sql .= ' OR ';             $i++;         }         $sql .= ' ) ';         $sql .= ' ORDER BY display_name ';         $userIDs = $wpdb->get_col( $sql );              return $userIDs;     }


Problems with the sidebar args and wp_list_bookmarks

I have run into an issue trying to use the sidebar args (before_widget,after widget,after_widget,before_widget) as theme style friendly parameters for the function wp_list_bookmarks, that is that the wp_list_bookmarks output will look just as the one inside WP_Widget_Links. I almost copied verbatim the code of the links widget but when trying to reuse the only one sidebar args (via the global $wp_registered_sidebars) I get some css classes for the widget container that dont show up using the WP_Widget_Links. For example the following dump of a sidebar args:               'name' => 'Sidebar 1'     'id' => 'sidebar-1'     'before_widget' => '
'     'after_widget' => '
'       'before_title' => '
'     'after_title' => '
'      By reading the wp code I assumed that is safe to change %1$s, %2$s for %id, %class resp, and then once the wp_list_bookmarks gets executed I should end with before_widget looking like `<li id="linkcat-" class="widget linkcat">`. But after comparing to the output of the links widget the widget css classname is missing, and the output of my code looks a bit odd in the page. This is the code where I use the function, which gets called as a filter to sidebars_widgets:               function my_sidebars_widgets($sidebar_widgets) {         global $wpdb, $wp_registered_sidebars;         static $hits;         if(++$hits == 2) {                  $sidebar = array_values($wp_registered_sidebars);                  $before_title = $sidebar[0]['before_title'];             $after_title = $sidebar[0]['after_title'];             $before_widget = $sidebar[0]['before_widget'];             $after_widget = $sidebar[0]['after_widget'];                  $before_widget = str_replace('%2$s','%class',$before_widget);             $before_widget = str_replace('%1$s','%id',$before_widget);                  wp_list_bookmarks(apply_filters('widget_links_args',array(                 'title_before' => $before_title, 'title_after' => $after_title,                 'category_before' => $before_widget, 'category_after' => $after_widget,                 'hide_invisible' => true,'title_li' => 'Links',                 'categorize' => 0,'inquiry' => true             )));         }         return $sidebar_widgets;     }      Did you have any clue of what Im missing here? I keep trying to get clear how WP feed widgets args but no explanation so far while reading the code. thanks in advance for any on your considerations.


Get all terms, including unchecked, or get the terms outside loop

I'm trying to return all the terms for a particular taxonomy (so eventually I can create a link for it). At the moment, this function I've written only returns terms for the current post. How can I just return a list of all of them?
Get terms
     <?php         $taxonomies=get_taxonomies('','object');          foreach($taxonomies as $tax){             echo "
$tax->name
";             $terms = get_terms($tax->name);             foreach($terms as $term){                 print_a($term->name);             }         }     ?>       Just for a bit more detail, the site is about wine, and one taxonomy is grape type. If the current wine is a Chardonnay, it returns "Chardonnay", but I'd like it to return "Chardonnay, Merlot, Pinot Grigio" etc. The `print_a` function is just a `print_r` wrapped in pre tags. Thanks


Wordpress VPS out of Memory Problem

I would want to put forward my case in detail. My website www.thehardtackle.com receives around 5000-10000 pageviews every day since 4th August. The server was a VPS with 1 GB memory, 800 GB Bandwidth. I have not installed any cache plugins and that is why used to get DB error at times when the website experienced spikes. 25th August onwards, the rate of DB errors increased and my host told me that the memory is very low and Ishould upgrade and optimise. So I upgraded to 1.5 Gb Memory, 1 TB Bandwidth. I optimised my database tables and removed one particluar post that was too heavy. Removed the revioion history as well. After this the website did get up, but went down any time (even with low traffic conditions) I upgraded to latest WP version, deactivated any plugin that I installed around 25th or even before. The problem still persisted. I had installed phpwiki for testing purpose near 25th, so I thought that could be a problem and removed the whole phpwiki installation from the server. In the mean time (2 days back) my host informed me that someone is using my server to send spam emails. My email's I previously shifted to Google APPs and none of the WP users had the email id the host provided me. I am still facing the breakdowns due to out of memory! And I donot even know whether the spamming is the reason or something is wrong with wordpress. I have increased the memory limit in php.ini to 256(writing this after changing the limit), it was 128 previously. I have facebook Iframes on Sidebars as well as homepage, I dont know what to do. Installing cache is an option but that would not correct the root cause of the problem. **UPDATE** : The host says that the spamming is not a problem, either that got solved due to phpwiki deletion or it was never really there. Anyways, I still get out of memory errors 2-4 times a day. With 6000 page views. While researching on the internet, I found this issue, which looks like close to my problem. It basically says that large databases face problems in WP; slow queries etc. I have a relatively small database, but I am facing DB errors after upgrading to 3.1 (right now I am on 3.2.1) I have disabled almost all the plugins that are not compatible with WP 3.2.1, and installed WP Super Cache (I still got one out of memory error and had to restart). The current memory usage is                        'total       used       free     shared    buffers     cached `                   ` 1536        954        581          0         24        208`      TOP processes with memory utilization - `3276 mysql 15 0 590m 78m 3024 S 0.0 **5.1** 0:30.31 mysqld` `1496 root 15 0 112m 33m 2120 S 0.0 **2.2** 0:04.38 spamd`


Get current page term title to use in WP_Query

I am trying to format a template page for a custom taxonomy and I'm having a hard time getting the term of the current page to use in the query. This is what I've tried so far:               <?php                    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;             $report = single_term_title();             $report_type = strtolower($report);             $temp = $wp_query;              $wp_query = null;              $args = array(               'showposts'=> 5,               'orderby'  => 'meta_value',               'meta_key' => 'report_date',               'order' => 'DESC',                       'post_type'=> 'match_report',               'report_type' => $report_type,               'paged'    => $paged             );             $wp_query = new WP_Query();                   $wp_query->query($args);                         if ( $wp_query->have_posts() ) :             ?>       when I `echo $report_type` I still get an uppercase value. Is there another function that I should be using rather than `single_term_title()`?


Redirect user on first visit based on geographical location

My project has two versions of the website - American and International. This is not localization, language is same, only content changes. I have created subdomain for the US version and kept international version on main domain. Now, I googled for solutions to redirect US users to US website by default and used Geo redirect plugin (http://wordpress.org/extend/plugins/geographical- redirect/). Now the problem, this plugin redirects visitors from US everytime they attempt to open the international version. What I need to do is, user should be redirected to the US version on first visit, then through a referrer link I put on US website, visitor should be allowed to visit the international version and surf the website. But again, if user tries to open website directly, he should be redirected to the US version. How do I do that?


Sorting custom post types by category?

I'm working on an exchange site of sorts where people will be able to list or request surplus items inside of our organization. Listings will just be submitted as 'posts' but I've created a custom post type 'request' for requests and it seemed to be working fine; I'm displaying the requests on a page with my own little loop that shows the post title, excerpt, thumb and category (Both 'posts' and 'requests' share the same category taxon.) The problem is, I can't seem to view the 'requests' by category in the same blog style format that I can with posts. If I click on the category next to a request, It takes me to the 'posts' with that category. This seems like it would be pretty basic so I'm not sure what I'm missing. I can go to `mysite.com/category/mycategory` to see all of my listings ('posts') by category and I can go to `mysite.edu/request` to see all the requests but I can't just sort requests by category. Just in case, here's my custom post type code. Also, I have not selected a blog page in settings, I just left it blank - I don't think that really makes a difference, I just thought I would mention. One more thing, If I include a category widget in the sidebar, it includes both 'posts' and 'requests' in the post count but if I click the link, obviously, it just goes to the 'posts' in that cat.               <?php         /*         Plugin Name: U Custom Post Types         Plugin URI: http://mysite.edu         Description: Creates custom post types         Version: 0.1         Author: Me         Author URI: http://mysite.edu         */          function my_custom_post_request() {         $labels = array(             'name'               => _x( 'Requests', 'post type general name' ),             'singular_name'      => _x( 'Request', 'post type singular name' ),             'add_new'            => _x( 'Add Request', 'request' ),             'add_new_item'       => __( 'Add New Request' ),             'edit_item'          => __( 'Edit Request' ),             'new_item'           => __( 'New Request' ),             'all_items'          => __( 'All Requests' ),             'view_item'          => __( 'View Request' ),             'search_items'       => __( 'Search Requests' ),             'not_found'          => __( 'No requests found' ),             'not_found_in_trash' => __( 'No requests found in the Trash' ),              'parent_item_colon'  => '',             'menu_name'          => 'Requests'         );         $args = array(             'labels'        => $labels,             'description'   => 'Holds our requests and request specific data',             'public'        => true,             'menu_position' => 5,             'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),             'has_archive'   => true,             'taxonomies'        => array('category'),             'capabilities'  => array(                                                     'publish_posts' => 'publish_requests',                                                     'edit_posts' => 'edit_requests',                                                     'edit_others_posts' => 'edit_others_requests',                                                     'delete_posts' => 'delete_requests',                                                     'delete_others_posts' => 'delete_others_requests',                                                     'read_private_posts' => 'read_private_requests',                                                     'edit_post' => 'edit_request',                                                     'delete_post' => 'delete_request',                                                     'read_post' => 'read_request',                                                 ),         );         register_post_type( 'request', $args );      }     add_action( 'init', 'my_custom_post_request' );          ?>


Child themes: disabling the parent

I'm creating a parent theme and several child themes. But how can I prevent the parent theme from ever being used?


How to display posts by author in a separate page, other than author.php?

I have an author.php page that displays two kind of posts:   1. first section displays latest 10 posts(games) from all categories, except one.   2. second section displays latest 10 posts only from that category that are excepted at the first section. With two kinds of posts, I put one red button link under each section, to see all posts by the same author. Each button link should link to the right page: the first button link that should link to a page with the posts belonging to the first section, and the last button link that should link to a another page with the posts belonging to the second section. On that pages I think it's easy to display post by categories, my problem is that I really don't know how to create these pages and how to link to them. Any help or suggestions will be greatly appreciated.


restore_current_blog() vs switch_to_blog()

After every instance of `switch_to_blog()` you should call `restore_current_blog()` to restore the current (actually, previous) blog. But if you're looping through two or more blogs and calling `switch_to_blog()` on each, is there any reason _not_ to use an additional `switch_to_blog()` at the end of the loop to switch to the original blog rather than calling `restore_current_blog()` at each pass. E.g. Why not:                $original_blog_id = get_current_blog_id();      foreach( $blog_ids as $blog_id ){         switch_to_blog( $blog_id );         //Do stuff      }      switch_to_blog( $original_blog_id );      instead of:                foreach( $blog_ids as $blog_id ){         switch_to_blog( $blog_id );         //Do stuff         restore_current_blog_id();      }


How to integrate Yelp API

I'm trying to figure out how to add data from an external site to a basic wordpress site I've created. I'm generally comfortable with basic wordpress setup and features, but now I'm trying to understand how to use API's and I'm not sure where to start. I've created an account with Yelp and have an API key, but I'm stuck on what to do next. Any guidance for an "API beginner" would be much appreciated.


How can I fix a Virtual Multiblog install that has no errors, but won't show all my sites?

I've been using Stephen Rider's Virtual Multiblog system for WordPress for a while now, and recently, I decided to add one more blog to my existing batch of three. The difference was, while all my other blogs existed as subdomains, this time I wanted WordPress for my main domain. Somehow, this broke all my other (non-WP) sites, because they started to look in my WordPress directory for the folders containing the other sites. At present, I have one site that's a virtual user/symlink site that is working. The other two sites, including the one for the subdomain in which WordPress is actually installed with the Virtual Multiblog system, aren't loading at all. They try and take me to the install script (which I've removed access to until I can resolve this issue). I've made sure that the mb-config-VUSER.php files are set up properly, and compared the working site's config files to the non-working ones, but I can't think of anything. I'm guessing this is something on my host's end, but they're insisting the symlinks are set up correctly, and there's some redirect somewhere that's breaking everything. Anyone have any ideas, or any suggestions for possibly switching my existing sites/database tables from VMB to WP's own Multisite feature if I can't get this figured out?


Category Slugs = 404s?

With the help of the internet and you lot, I have been stumbling about to create a worpress site here. So at this stage, its not exactly a default install. - Im running the boldy theme from Site5. - Have made some tweaks to the underlying PHP, but nothing that I can think that would cause this issue. **Issue** :   Slugs setup normally for categories: ![enter image description here](http://i.stack.imgur.com/jN7CL.png) But the URL it takes me too is a 404. > http://www.dekho.com.au/category/screencasts/ All my categories are broken, except my case studies category.   - This uses a Portfolio template to display posts in that category (part of Boldy theme) Im sure I had both the 'portfolio' and the other category links working at the same time. **What have I missed?**


Notification when certain posts are published

I normally work ahead of schedule and sometimes need to contact people when a certain post reaches publication. Is there any plugin that will do this? It would need to be customisable for each post as most posts I don't need this reminder, and for the ones where I do need it I would need to write something different each time.


Community and User Generated Content Website: Have been thinking about Drupal but leaning on Wordpress heavily

I'm a non-programmer and run a food website (plain - jane Dreamweaver) along with a simple Wordpress powered blog. I envisioned **creating a food website that is both user powered (one can submit recipes, tips articles, photos etc) and also act as a mini social network (people can blog) - create profiles, make friends etc.** I stumbled on Drupal nearly 2 years ago and was impressed by its flexibility in creating content - through modules such as CCK (custom content types), Views - to display content from various queries and Panels (displaying content without manual theming). It also offered a host of modules that could do things like - classifieds, greetings, newsletters, events etc. However I got so mired by what Drupal could do, I ignored site development and it's been sitting in the backburner all this while. Recently I met a designer / developer (More Wordpress & Less Drupal) who agreed to customize a theme that I finally chose for the website. I'm scared that despite Drupal's scaling abilities as a business owner I will be left with fire-fighting stuff if anything goes wrong with if i get the site developed on Drupal. I have explored and searched previously whether Wordpress can be used more as a CMS platform but came away disappointed. With Wordpress 3.1, Multisite and BuddyPress, I'm excited whether I can ditch Drupal and choose Wordpress instead. Plus I'm more inclined to use Wordpress after I read this post about Why Drupal isn't a good choice for a CMS - http://mikeschinkel.com/blog/17-reasons-wordpress-is-a-better-cms-than-drupal/ **Here's what I'm looking for:** 1.Food / Recipes Websites that will have 4-6 types of content - recipes, food guides, photos, menus, videos etc 2.The site should be high on usability - tech 'unsavvy' should be able to submit content recipes, photos, videos etc) to the site - this is an important need. Can I make this really simple?   1. Social networking capabilities - profiles, adding friends, member search, rewarding members. I want to build a strong community that goes beyond just creating profiles. I want them to be able to contribute to the site's growth.   2. A decent / elegant theme (Wordpress had zillions of themes, I know)   3. Displaying content - Can I display say, in a page, a thumbnail and excerpt, of content that is being posted to the site? and perhaps in another page - only a set of links of content that is being posted. - Do plugins exist for these? Drupal hs Views, CCK and Panels that achieve these quite easily.    4. Like I mentioned before, as a non-tech business owner, can I scale the website without worrying too much into maintaining the technical aspects of the site? * * * Please help me.


can I chage url for register_post_type

I registered custom post type by `register_post_type('new_post',$args);` So new post url looks like `http://myweb.com/new_post/post_name Can I change **_ _later_ _** the part of url from `new_post` to something else?


In adding CMS functionality to static website, is complete conversion the only way?

I have a static website that is built in ASP.NET and PHP, and I want to add the functionality of a CMS to it. I know the most complete way would be to convert the whole site over to WP - mimic the design, theme and navigation of the existing site in WP and go from there. I wanted to know if it is possible to add bits of WP functionality to existing pages. Or is the only way to add WP functionality to an existing site to add whole new WP pages. I think this is an odd question but I would appreciate any and all help.


How can I let my audience tag my posts?

I have over 400 interviews on my site and my audience keeps asking me for a way to sort through them. I don't have time to tag all 400 interviews. Do you think there's a way for my audience to tag interviews themselves?


How do I create a dynamically-updated copyright statement?

I'd like to find an optimized, WP_Query-safe method for generating a dynamically-populated copyright statement for the bottom of my themes. That is to say, I'd like to check the date (by year) of my oldest and newest posts and then output something along the lines of               [blog name] © [oldest post year]-[newest post year] [primary blog author]      What's the easiest/safest way to do so?


Top Commenters: exclude admin

I'm using the following code in my function.php to display the top commenters in my theme: function top_comment_authors($amount = 5){               global $wpdb;          $results = $wpdb->get_results('         SELECT             COUNT(comment_author_email) AS comments_count, comment_author_email, comment_author, comment_author_url         FROM             '.$wpdb->comments.'         WHERE             comment_author_email != "" AND comment_type = "" AND comment_approved = 1         GROUP BY             comment_author_email         ORDER BY             comments_count DESC, comment_author ASC         LIMIT '.$amount          );          $output = "
";     foreach($results as $result){     $output .= "
".get_avatar($result->comment_author_email, 30).'
'.(($result->comment_author_url) ? "comment_author_url."'>" : "").$result->comment_author.(($result->comment_author_url) ? "" : "")." (".$result->comments_count.")

";     }     $output .= "
";          echo $output;      } It works fine, but I'd like to **exclude** myself, aka the **admin** /author. Is this possible at all? If so, how would I do that? In what way would I have to modify the code above? Thanks a lot in advance! :)


How to effectively reset the post object after calling get_posts()

The function below is called from my index.php just below the main content block. Its purpose is to write out a link list of the latest posts. However, I need to reset the post object once this function has completed (or the sidebar query that follows thinks that the current post is the last post that gets executed by this function.) How should I reset the post back to the current post of the page? I've tried adding wp_reset_query() at the end of the function, but its not producing the results I want (produces multiple posts in the content area). Any help much appreciated.               function myFunction(){         $catHidden=get_cat_ID('hidden');         $myquery = new WP_Query();         $myquery->query(array('cat' => "-$catHidden",'post__not_in' => get_option('sticky_posts')));         $myrecentpostscount = $myquery->found_posts;         if ($myrecentpostscount > 0){ ?>

Menu Title

                 <?php                  global $post;                 $myrecentposts = get_posts(array('post__not_in' => get_option('sticky_posts'), 'cat' => "-$catHidden",'numberposts' => get_option('latest_count')));                 foreach($myrecentposts as  $idxrecent=>$post) { ?>
                         <a href="<?php the_permalink(); ?>"><?php if(has_post_thumbnail() && get_option('show_thumbs')) the_post_thumbnail('thumbnail', array('class' => 'alignleft', 'style' => 'margin:0 10px 0 0;')); ?><?php the_title(); ?>                         <?php                               if(has_post_thumbnail() && get_option('show_thumbs')) echo '

';?>
                 <?php }          echo "

";}}


Manage Private Posts

I have a public blog but would like to have a section just for my own private notes? What is the easiest way to do this? Is there a way to make an entire category of post private?


How to get featured image's width and use elsewhere in template?

I'm wondering if it's possible in the single.php template to use the width of the post's featured image elsewhere in the page. What I'm trying to do is add a div element on the page with the same width as the post's featured image (which will always be a different width). If anyone has any ideas, let me know. Thanks


Thickbox no longer working on front end, did code change in WP3.3 beta 3?

Prior to the 3.3 beta 3 I used thickbox on the front end with the below script. Since beta 3 the lightbox has stopped working. Is there an error in my code or did the function change?               function add_themescript(){         if(!is_admin()){         wp_enqueue_script('thickbox',null,array('jquery'));         wp_enqueue_style('thickbox.css', '/'.WPINC.'/js/thickbox/thickbox.css', null, '1.0');         }          }     add_action('init','add_themescript');


Featured image with link to post shortcode, image displaying above the post

I have created a shortcode to display the featured image linking to the post:               function ck13_post_image($atts){        extract(shortcode_atts(array(           'ck_img_size'      => 'full'        ), $atts));              $show_the_image .= '' . the_post_thumbnail("$ck_img_size") . '';          return $show_the_image;     }          //---------------------------------------------          function register_shortcodes(){        add_shortcode('show-post-img', 'ck13_post_image');     }     add_action( 'init', 'register_shortcodes');      But instead of displaying the image inside the post, the image is displayed above it. The weird thing is that the link to the post is displayed correctly inside the post, just the image is above.   Did i make some mistake? How can i make this work?


How to show SWF, where Flash is available, and gracefully fallback to MP4 video for iOS devices?

I have a SWF, which uses a MP4 file for the video part (the SWF also has a Table of Contents, which is important for me to have). But when viewing the website on iOS devices, (or where there is no flash), I would like the MP4 file to be played (using jwplayer, etc) How can I implement this? Is there a Wordpress plugin which handles SWF as well as MP4?


post meta - problem : copy the same meta for all the articles

i created a post meta, to add the name of a specific "author" to my articles. But if i enter the meta of the first article, all the other articles copy the same meta. If i enter then a second name in the meta of the second article, all the other articles copy this second "meta", as if i entered this second name for each article. How can i specify the meta for only one article? in the admin panel : if i did not specify the author, i still have "empty meta", which is the text i specify in this case in functions.php . BUT, in the page on internet, it shows the name of the last "meta" name written in any of the article. I hope my description is clear enough, please tell me for more informations. Here's the main lines of the code :               $met = get_post_meta($post->ID, 'champ', true)? get_post_meta($post->ID, 'champ', true) : 'empty meta';          echo '<input type="text" id="champ" name="champ" value="'.$met.'" />';     …     add_post_meta($post_id, "champ", $_POST['champ'], true);     update_post_meta($post_id, "champ", $_POST['champ']);


Adding custom url to readmore link using get_permalink()

I am having issues with a custom url. I have a page with a gallery type plugin/shortcode. Now each gallery item displayed on the page, has a readmore link, linking to that gallery item post. Now I created my own custom url variable that can be set on the gallery item post: ![enter image description here](http://i.stack.imgur.com/WdZdf.png) This was added like this on the **recipe_options.php** page, where you can set the various options on each gallery item post.               $recipe_url = '';      This was added like this to the recipe_options.php page:               function add_recipe_option_element(){             $recipe_price = '';             $recipe_social = '';             $sidebars = '';             $right_sidebar_recipe = '';             $left_sidebar_recipe = '';             $recipe_detail_xml = '';             $select_chef = '';             $recipe_url = '';                   foreach($_REQUEST as $keys=>$values){             $$keys = $values;         }         global $post;              $recipe_detail_xml = get_post_meta($post->ID, 'recipe_detail_xml', true);         $ingredients_settings = get_post_meta($post->ID, 'ingredients_settings', true);         $nutrition_settings = get_post_meta($post->ID, 'nutrition_settings', true);              if($recipe_detail_xml <> ''){                  $cp_recipe_xml = new DOMDocument ();             $cp_recipe_xml->loadXML ( $recipe_detail_xml );             $recipe_price = find_xml_value($cp_recipe_xml->documentElement,'recipe_price');             $recipe_url = find_xml_value($cp_recipe_xml->documentElement,'recipe_url');             $recipe_social = find_xml_value($cp_recipe_xml->documentElement,'recipe_social');             $sidebars = find_xml_value($cp_recipe_xml->documentElement,'sidebars');             $left_sidebar_recipe = find_xml_value($cp_recipe_xml->documentElement,'left_sidebar_recipe');             $right_sidebar_recipe = find_xml_value($cp_recipe_xml->documentElement,'right_sidebar_recipe');         }      //AND further down on the recipe_options.php page

              <?php _e('RECIPE URL', 'crunchpress'); ?>

             <input type="text" name="recipe_url" id="recipe_url" value="<?php if($recipe_url <> ''){echo $recipe_url;};?>" />

Please enter your url

      **The LINK** This is the part, on the same **recipe_options.php** page, where you set the **href** property for the 'read more' link:

<?php echo strip_tags(mb_substr(get_the_content(),0,$num_excerpt));?> <a class="c-link" href="<?php echo $recipe_url ;?>"><?php _e('Read M...', 'crunchpress'); ?>

      You need to look at this part:               href="<?php echo $recipe_url ;?>"        The original code was:               href="<?php echo get_permalink() ?>"         Now, I cannot get this url to appear on the link on the page...I even tried using some of the existing variables like **$recipe_price** , but nothing works Any ideas what I might be doing wrong? Thanks


links to Media Library content in sidebar per page

I have a bunch of PDF files in my Media Library and I want to show the relevant ones on a per-page basis in the sidebar. So on the 'About Cats' page, I want ILoveCats.pdf and cat-food.pdf from the Media Library to show up in the sidebar, but not dogsAreGreat.pdf. What would be the best way to do this? I'm using the Genesis framework if that helps. I would like for there to be an explicit connection between a file in the Media Library and the page(s) on which it shows up, so I'd prefer not to have just some hard-coded links in a template file with PHP testing `is_page('blah')`.


why esc_url not working in smartmetabox

Have you ever tried http://www.wproots.com/ultimate-guide-to-meta-boxes-in- wordpress/ ? It's good classes to create metabox. But I'm having problem with the validation. I tried the `sanitize_callback` parameter to sanitize URL, so I used `esc_url` but the field still accepted all values. What is the problem here? Here's my code               add_smart_meta_box( 'themename_slides_url', array(              'title'     => __( 'Slides Options', 'themename' ),         'pages'     => array( 'slides' ),         'context'   => 'normal',         'priority'  => 'high',         'fields'    => array(                 array(                 'name' => __( 'Slides URL', 'themename' ),                 'id' => 'slide_url',                 'default' => '',                 'desc' => __( 'Type the URL of the slide', 'themename' ),                 'type' => 'text',                 'sanitize_callback' => 'themename_sanitize_url'                 ),             )         )          )               function themename_sanitize_url( $new, $meta_key, $id ) {              if( esc_url( $new ) )             return $new;          }      Any idea ?


Is there a has_more_tag() method or equivalent?

I need to determine if the current post has a "more" tag. I'm currently using               $pos=strpos($post->post_content, '<!--more-->');      Am I missing a built in method similar to has_excerpt()?


Only Admin can Edit, Delete or Update

I want to know if there is any way in WordPress that only Admin can update/edit or delete published posts/listings. User who have submitted the post/listing can't even edit/update or delete it. Theme: DirectoryPress


How to Remove All Admin Bar Menu Items?

I've seen techniques on how to remove specific Admin Bar items, but how do we do with those extra menus added by plugins/themes? How to remove **all** Admin Bar items? ![admin bar full of items](http://i.stack.imgur.com/ryQ93.png) * * * _**Related Q &A's_**   * Is the new WordPress 3.1 admin bar pluggable and how can I extend it?   * remove "edit your profile" from admin menu bar   * WordPress Admin Bar Moving Links   * Make 'Howdy, [name]' function as log out button


remove or update add_image_size

I'm working on a theme that has a number of image sizes defined correctly using:               add_image_size( 'name', 500, 200, true );      I would like to override these defined sizes from the child theme:               add_image_size( 'new-name', 400, 300, true );      I know I can add new sizes, but if I add the same name i.e:               add_image_size( 'name', 400, 300, true );      Then the parent function call is used - the child one is ignored - adding extra rules adds extra images which will never be used - it's not so bad, but it's not efficient. Is there a function to de-register an added image size? Cheers! Ray


More Fields & Media Upload

I'm using the more types, more fields and more taxonomies plugins and they're beyond excellent. However, I've found that once I remove the main wysiwyg block I no longer have access to the media upload buttons. ![enter image description here](http://i.stack.imgur.com/OQJ5A.jpg) I've searched extensively for an option that would give me a new upload field or different buttons but have been unsuccessful. I read this brilliant answer by MathSmath But I'm unsure how I would implement it with more-fields. I also found an article indicating that the developer wouldn't provide this option so I'm stuck figuring it out myself. I've gone so deep down the rabbit hole with these plugins that there's no turning back. Any help would be immensely appreciated.


Remove some tags from shortcodes output? Trying to fix autop

remove_filter( 'the_content', 'wpautop' );     add_filter( 'the_content', 'wpautop' , 99 );     add_filter( 'the_content', 'shortcode_unautop', 100 );      Work for almost all my shortcodes excluding one that returns a list of custom post type thumbnails like this:

      No matter what I do it always adds this `<p>` before `</a>` despite returning them inline (I don't even have single space between them in my shortcode source, eg.               <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

          <?php endwhile; ?>      Is there any way of removing this empty P from my shortcodes output?


Writing a plugin that notify my friends of new post that mentions(@) them

For example, I write a new post with content "Today I'm happy, because I finally met the girl that @David told me about bla blah..." Once the post is published, there should be an email notification sent to David about this post that mentions him. Is there already such plugin? If not please help me with my implementation. Thanks a million time! :) The script needs to first parse the content of this new post. Find names after '@', then go to database to match commenter's name in order to get his/her email address (Assuming the person that I @ must have comment on my blog before) The basic send email part is below.               function email_friend()  {              $postTitle = get_the_title($id);         $post_permalink = get_permalink( $id );         $to = 'David@email.com';         $subject = 'Arch!tect mentioned you in his new post《'.$postTitle .'》';         $from = "noreplay@myWebsite.com";         $headers = "From:" . $from;              $message = "Arch!tect mentioned you in his new post《".$postTitle .          "》 check it out？\n\n"  ."Post link：".$post_permalink         ."\n\n\nPlease don't reply this email.\r\n";              mail($to, $subject, $message, $headers);     }          add_action ( 'publish post', 'email_friend' );      Done with simple part! Now please help me with the hard part...parsing name in post and fetching email address in database. * * * P.S. Thank you all for helping! I managed to finish the code and it's working fine now (tested). To mention people with name that has space in it, I'm using underscore first then change it back to space. It now send email to all people that I mention in my post and after doing that it will send a summary to myself with the result. I'll paste the complete code below please have a look and tell me what I need to improve.               function email_friend()  {              // get post object         $post = get_post($id);         // get post content         $content = $post->post_content;         // get how many people is mentioned in this post         //$mentionCount = preg_match_all('/(@(\w)+)/', $content, $matches);         $mentionCount = preg_match_all('/(@[^\s]+)/', $content, $matches);//support other lang                   // if there is at least one @ with a name after it         if (0 !== $mentionCount) {                  $friendList = array();//for storing correct names                  for ($mentionIndex=0; $mentionIndex < $mentionCount; $mentionIndex++) {                      $mentionName = $matches[0][$mentionIndex];                        $mentionName = str_replace('_',' ',$mentionName); //change _ back to space                      $mentionName = substr($mentionName, 1); //get rid of @                 //for security and add wildcard                 $friend_display_name_like = '%' . like_escape($mentionName) . '%';                       global $wpdb;                      // get correct name first                 $friendCorrectName = $wpdb->get_var( $wpdb->prepare( "                                                                     SELECT comment_author                                                                FROM $wpdb->comments                                                                WHERE comment_author                                                                LIKE %s ",                                                                $friend_display_name_like                                                                )) ;                      // get friend email by comment author name                 $friend_email = $wpdb->get_var( $wpdb->prepare( "                                                                     SELECT comment_author_email                                                                FROM $wpdb->comments                                                                WHERE comment_author                                                                LIKE %s ",                                                                $friendCorrectName                                                                )) ;                           if($friend_email) {// if found email address then email                          $postTitle = get_the_title($id);                     $post_permalink = get_permalink( $id );                     $to =   $friend_email;                     $subject =   'Arch!tect mentioned you in his new post 《'.$postTitle .                           '》';                          $from = "noreplay@swotong.com";                          $headers = "From:" . $from;                          $message = "Arch!tect mentioned you in his new post《".$postTitle .                      "》 check it out？\n\n"  ."Post link：".$post_permalink                     ."\n\n\nPlease don't reply this email.\r\n";                          if(mail($to, $subject, $message, $headers)) {                         //if send successfully put his/her name in my list                         array_push($friendList, $friendCorrectName);                        //array_push($friendList, $friend_email);                     }                           }                             }       $comma_separated = implode(",", $friendList); //friend list array to string                   // now send an email to myself about the result             $postTitle = get_the_title($id);             $post_permalink = get_permalink( $id );             $to =    'myOwn@email.com';             $subject =   "Your new post《".$postTitle .              "》has notified ".count($friendList)."friends successfully";             $from = "noreplay@email.com";             $headers = "From:" . $from;             //list all friends that received my email             $message = "Your new post《".$postTitle .              "》has notified ".count($friendList)."friends successfully:\n\n".$comma_separated ;                  mail($to, $subject, $message, $headers);                   }                              }//end of email_friend function               add_action ( 'publish_post', 'email_friend' );      Edit: changed (\w)+ to [^\s]+ so it supports more languages. (Chinese tested)


How to simultaneously access the same MySQL database in the main column and sidebar of Wordpress?

I've wrote some basic custom PHP code for my Wordpress site. The code basically access a MySQL database (a different database from the wordpress database) and displays the information. In addition to running it on the main page, I also need it to run on the sidebar. The code functions perfectly in the main page _or_ it functions perfectly in the sidebar, but when I put the code in both, I get the following error in the sidebar: **Fatal error: Call to a member function prepare() on a non-object in /home/kimusubi/public_html/wp-content/plugins/php-code-widget/execphp.php(44) : eval()'d code on line 5** I thought it was an issue of accessing the same table and database at the same time, but I'm using include_once and closing my connection as soon as I'm done with it, so I'm not sure what the problem is. This is the code that I'm using for the sidebar and the main column page:               <?php     include_once 'db_config.php'; //Include database configuration file     $current_user = wp_get_current_user()->user_login; //Get current WP logged in user     try { //Access accounts table and pull user info into associative array         $STH = $DBH->prepare("SELECT * FROM accounts WHERE accnt = :accnt");         $STH->bindParam(':accnt', $current_user);         $STH->execute();         $Result = $STH->fetch(PDO::FETCH_ASSOC);         $DBH = null;         }     catch(PDOException $e) {           echo "Select Accounts Table Error: " .$e->getMessage(). "
"; //Display Error (if any)     }          $available = min($Result['week_two'],$Result['week_one'],$Result['current']);          echo "Account: " .$Result['accnt']. "
";     echo "Name: " .$Result['first']. " " .$Result['last']. "
";     echo "Address: " .$Result['address']. ", " .$Result['city']. ", " .$Result['state']. ", " .$Result['zip']. "
";     echo "Phone: " .$Result['phone']. "
";     echo "Current Balance: $" .$Result['current']. "
";     echo "Available Balance: $" .$available. "
";     ?>      And this is what's in my db_config.php file:               <?php     try {     $DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);     $DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );          }     catch(PDOException $e) {           echo "Select DB Error: " .$e->getMessage(). "
";     }          ?>      Exec-PHP is the only plugin I'm using in order to execute PHP directly from Wordpress. I'd appreciate any guidance.


Get current user array with post string

I need to get 10 current user fields and pass the field values to a post string. The post string is expecting certain label names for each value. Example - post string expects `'firstname' => 'value'`, not `'user_firstname' => 'value'`. After days of fatal parse errors for syntax, now I just get a fail status. Either my array code or post code, (or both), is somehow flawed. I read a post today from 2011 that says since WordPress 3.3 (current version now is 3.9), that the way custom user fields are called is different. The post > http://goo.gl/x5deHi says the way to call custom WP fields like 5 of mine are, is like this:                   if ( $current_user->has_prop( 'my-field' ) ) )     echo '<p>         ' . $current_user->get( 'my-field' ) . '         </p>';`      So this is the code I have right now:                   //Get values for these 10 user fields          function wp_get_current_user() {         $current_user = wp_get_current_user();              $current_user_info = array(         'firstname' . $current_user->user_firstname =>' ',         'lastname' .  $current_user->user_lastname =>' ',         if ( $current_user->has_prop( 'mepr-address-one' ) ) )         ' . $current_user->get( 'mepr-address-one' ) .  => ' ',         if ( $current_user->has_prop( 'mepr-address-city' ) ) )         ' . $current_user->get( 'mepr-address-city' ) .  => ' ',         if ( $current_user->has_prop( 'mepr-address-state' ) ) )         ' . $current_user->get( 'mepr-address-state' ) .  => ' ',         if ( $current_user->has_prop( 'mepr-address-zip' ) ) )         ' . $current_user->get( 'mepr-address-zip' ) .  => ' ',         if ( $current_user->has_prop( 'mepr-address-country' ) ) )         ' . $current_user->get( 'mepr-address-country' ) .  => ' ',            'email' . $current_user->user_email =>' ',         'username' . $current_user->user_login =>' ',         'password' . $current_user->user_pass =>' '              );         }         // Generate the POST string         // These last three lines aren't posting my get user values         $postdata = '';         foreach($query_vals as $key => $value){      $postdata .= $key.'='.urlencode($n=$value).'&';         }      And the post string needs to meet the parameters described in the post that is this:                   foreach ( get_user_meta( $user->ID ) as $key => $values ) {     var_dump( $key, $values );         }      But being a php newb, I'm not sure of the coding syntax. Don't I have to define has_prop before I can use it?


How to install Facebook, Google+, & Twitter LIKE buttons for each individual post at frontpage?

I wanna install the Facebook, Google+ & Twitter buttons at the frontpage for each (at the preview of the) posts, so that the user to need to click into the post to like it. Just the like the buttons there at the frontpage: http://www.webdesignerdepot.com/ Any plugin or quick codes can do it? THANKS a lot!


Google Apps SMTP for WP MultiSite?

How can you force WordPress MultiSite to send all emails via a Google Apps SMTP server? I have attempted to use Easy WP SMPTP, however that does not work exactly as I'd hoped, not to mention it fails to even send emails at all in tests through the Google Apps SMTP server. It seems as though there should be a way to cleanly define to WordPress that all mail sent throughout network should go through a singular SMTP gateway (such as by Google Apps Gmail) vs having to jump through hoops.


Modifying the permalink href for posts with jquery

I Was wondering if there is any way to modify a link to add for example a category that I could use with $_GET. For instance, www.example.com/this-is-the-post/category (or ?cat=category) I've tried to make a function in jquery to modify the link but it wont work. My best guess is that it has to do with the mod rewrite that wordpress uses.                           $('.post-style li a').each(function() {                     var oldHref = $(this).attr('href');                     $(this).attr('href', oldHref + '?cat=' + <?php echo $currentCat; ?>);                 });      $currentCat gets the page current category. So I was hoping that someone could point me in the right direction! If anything is unclear, or needs to be added please comment and ill get on it asap! Thanks


Get category slug and display it on a query_post

I just read "How to create option page for wordpress theme" in wp.tutsplus.com - I have a problem with getting categories . there is two parts to my question **- Part A - Get category slug and display it** In this tutorial there is a select option as follow :               $options[] = array(         "section" => "select_section",         "id"      => WPTUTS_SHORTNAME . "_select_input",         "title"   => __( 'Select (type one)', 'wptuts_textdomain' ),         "desc"    => __( 'A regular select form field', 'wptuts_textdomain' ),         "type"    => "select",         "std"    => "3",         "choices" => array( "1", "2", "3")      Now, instead of the 1-2-3 choices , I want to return category slugs to display it to user - can someone please modify this code so it return the slugs for categories created on the site? **- Part B - Display category slug in query_posts format** The typical returning value for above code is this :               <?php echo $wptuts_option['wptuts_select_input']; ?>      I use this code for my query post :               <?php query_posts('showposts=1&category_name=news'); ?>      where the "news" is the category "slug" - not name of the category now , can someone please modify the code so it gets the category slug based on the option chose in the theme option page ? I am stuck in fixing this problem and I looked every where, but cant find a solution thanks


Can a page_id and a post_id be same?

Wordpress generates ID's for each page/post. Do pages in wordpress share the same ID column in the database as the posts? I mean, if a site has both posts and pages, can one or more page_ID's be same as some Post_ID's?


Removing unneccessary p-tags (Not every p)

I removed `wpautop` from my theme:               function disable_linebreaks($content) {            remove_filter ('the_content','wpautop');            return $content;     }     add_filter('the_content','disable_linebreaks',1);      But now, when switching between HTML and Editor ALL p-tags disappear, even the ones I coded myself. What I want is just to prevent Wordpress from adding empty `<p></p>` - Code. Basically I'm happy with `wpautop`, it's just that sometimes it's too much (For example around images. There's always an empty p before every image).


Requested URL changes when using custom rewrite rule

I'm having basically the same problem as question #44117. I have a custom rewrite rule set using add_rewrite_rule, but when the user goes to the page, the entered url changes and the value is lost. User enters: membership/member-profile/profile-name/ And is forwarded to: membership/member-profile/ Here's my rewrite code:               function profile_rewrite() {         add_rewrite_rule('membership/member-profile/([^/]+)/?', 'index.php?pagename=member-profile&profile=$matches[1]', 'top');     }     add_action('init', 'profile_rewrite');      I've been researching for hours, and while I've found others with a similar problem, there has never been a definite solution. Maybe it's a problem with my Wordpress settings? If I enter the URL: index.php?pagename=member-profile&profile=test I'm forwarded to: membership/member-profile/?pagename=member-profile&profile=test Which returns a 404 error. Thanks in advance for any help. I'm pretty new to this Wordpress stuff and maybe I'm jumping in a bit too quickly.


How to implement jquery-ui autocomplete into custom fields?

I currently have a custom fields for enter State name. I want to use the autocomplete from jquery-ui in this fields. However, I failed. This is the first time I using jquery-ui, and I am not so familiar with php and jquery. I hope that you guys can give me some advises. This was the code that I use:               (function ($){         $(document).ready(function() {             var availableTags = [                 "ActionScript",                 "AppleScript",                 "Asp",                 "BASIC",                 "C",                 "C++",                 "Clojure",                 "COBOL",                 "ColdFusion",                 "Erlang",                 "Fortran",                 "Groovy",                 "Haskell",                 "Java",                 "JavaScript",                 "Lisp",                 "Perl",                 "PHP",                 "Python",                 "Ruby",                 "Scala",                 "Scheme"             ];             (jqeury)( "#custom_field_city" ).autocomplete({                 source: availableTags             });           })(jQuery);      Above is the example code that I use to call the autocomplete feature. But nothing happened in my custom field. No list populated. Since the above code cannot work, so I try to find another way to implement the jquery-ui and I found this article enter link description here However, I stuck at this code:                  $(document).ready(function() {         //attach autocomplete               (jqeury)("#cctmcity").autocomplete({                        //define callback to format results                   source: function(req, add){                            //pass request to server                       $.getJSON("friends.php?callback=?", req, function(data) {                                //create array for response objects                           var suggestions = [];                                //process response                           $.each(data, function(i, val){                           suggestions.push(val.name);                       });                            //pass array to callback                       add(suggestions);                   });               },                    //define select handler               select: function(e, ui) {                        //create formatted friend                   var friend = ui.item.value,                       span = $("<span>").text(friend),                       a = $("<a>").addClass("remove").attr({                           href: "javascript:",                           title: "Remove " + friend                       }).text("x").appendTo(span);                            //add friend to friend div                       span.insertBefore("#to");                   },                        //define select handler                   change: function() {                            //prevent 'to' field being updated and correct position                       $("#to").val("").css("top", 2);                   }               });      })(jQuery);      I don't want the source file retrieved from the database like this one:               $.getJSON("friends.php?callback=?", req, function(data)       I want it retrieved from the simple place, like the 1st example. How can I do that? Thanks


Drag posts and pages so you can sort them in order

So has anyone done this? can be done? On wordpress admin, when you click List Pages, or List posts, I want to make a drag&drop in order to sort the pages/posts, but before I start I want to know if someone has done it already, or if there is a plugin for this.


Why Can't PHPUnit UnitTest My Wordpress Website

I have been researching this issue for days and although many people ask this question I never found a clear and concise answer. I am running:   * PHP Unit: Version 3.7.21   * WordPress: Version 3.5.1   * OS: Ubuntu 11.10   * MySQL: Version 5.1.69-0ubuntu0.11.10.1   * PHP: Version 5.3.6-13ubuntu3.10 Long story short, I have the basic wordPress core downloaded into a directory on my computer. I have successfully downloaded and installed pear and phpunit. I tested phpunit by writing basic tests on simple php files which worked fine. My issue is when I run phpunit on a wordpress site (which I have not changed the core WP files of). I get the error: > "PHP Fatal error: Call to a member function main() on a non-member object in > /< root_directory>/functions.php on line 779". This error corresponds to this code-segment:               function wp( $query_vars = '' ) {         global $wp, $wp_query, $wp_the_query;         $wp->main( $query_vars ); // Line 779              if ( !isset($wp_the_query) )             $wp_the_query = $wp_query;     }      After some intense internet crawling I found many people had errors on this exact line so I know there is some general thing like an environment setting or our setup process that gave us all this error. Some solutions I have **read and tried** that did not work for me:   * Change the required file in your "index.php" file.   * Place a require of "load.php" above the head in your "index.php" file.   * Re-install WordPress   * Change boot-strap and phpunit environments. I have been a web-developer for 5 years but I have never used WordPress for one of my clients before. Once I can get this set up writing the unit tests will be easy; but I have no idea what is causing this issue. Any links to guides/tutorials or clear explanations would be greatly appreciated. Thank you for your time. --EDIT-- The test file I am running is:               <?php        //include PHPUnit     require_once('PHPUnit/Autoload.php');     //include the code to be tested     require_once('../index.php');          // extend the PHPUnit class     class StackTest extends PHPUnit_Framework_TestCase {              public function testOne(){             $this->assertTrue(TRUE);             $this->assertEquals(2,2);             $this->assertTrue(1<3);         }     }     ?>      I didn't use any WordPress specific function tests; I just ran basic tests that work when I don't access the homepage of my WordPress site and fail when I do. Also another note; I properly set up my config file and my database. The site works perfectly fine, it is just the PHPUnit tests are unable to successfully run the websites files.


Unable to Upload image via WordPress Media Manager

I have a WordPress 3.5.1 driven website. When trying to upload images via WordPress Media Manager, the below error is displayed: " _xxx.jpg has failed to upload due to an error. The uploaded file could not be moved to /xx/xxx/dddd/wp-content/uploads/2013/08._ " I know the above Error is related to folders and files permission issue on the server. The website is running on the **Amazon EC2 server which is running on a Amazon Version of Linux "AMI"**. When trying to upload image(s) via FTP, WordPress Media-Manager fails to recognize the uploaded image(s). I did a search on the net and found that when using WordPress Media Manager, _WordPress makes an entry in the database_. **My Question is:** If I upload the image(s) using FTP then which table do I need to update if I want the image(s) to appear in the Media Manager?


Registering custom post type menu editor problem

I'm trying to register custom post type this way:               add_action( 'init', 'vocabulary_register_post_type' );     function vocabulary_register_post_type() {         $labels = array(                 'name'               => 'Słowniczek',                 'singular_name'      => 'Pojęcie',                 'menu_name'          => 'Pojęcia',                 'name_admin_bar'     => 'Pojęcie',                 'add_new'            => 'Dodaj nowe pojęcie',                 'add_new_item'       => 'Dodaj nowe pojęcie',                 'edit_item'          => 'Edytuj pojęcie',                 'new_item'           => 'Nowe pojęcie',                 'view_item'          => 'Wyswietl pojęcie',                 'all_items'          => 'Wszystkie pojęcia',                 'search_items'       => 'Wyszukaj pojęcia',                 'parent_item_colon'  => 'Nadrzędne książki',                 'not_found'          => 'Pojęć nie znaleziono',                 'not_found_in_trash' => 'Brak usuniętych pojęć'         );         $product_args = array(             'public'             => true,             'publicly_queryable' => true,             'show_ui'            => true,             'show_in_menu'       => true,             'query_var'          => true,             'rewrite'            => array( 'slug' => 'vocabulary' ),             'capability_type'    => 'post',             'has_archive'        => true,             'hierarchical'       => false,             'menu_position'      => null,             'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),             'labels'             => $labels         );         register_post_type( 'vocabulary', $product_args );     }      All works fine except I cant select any of those custom post types element to insert them into a menu (custom post type section doesn't show in menu editor). But... when I change last line               register_post_type( 'vocabularys', $product_args );      suddenly everything works as it should. The problem is, that I have already few custom post type items, and don't want to mess with database to change guids and post_type entires for them. So the final question is - why first one doesn't work, and the second one does? After digging more - it seems it has something to do with the order when you add this code. Did clean wp318 installation and putted above code into default 2014 theme. After setting up the database and logging into backend there was no option in custom menu (after creating one). Now did another install, this time didn't change anything in the template, logged in, created menu. After that I have added code into functions.php - all did well, with exact same names. So it looks like there is something blocked in database when custom post type is added in wrong time.


how do config PHPCHART Script For wordpress theme

i have a wordpress theme that i want use PHPChart in some page ... first step of using PHPChart is confige file 'conf.php' , i tried very much , but i cant do it Imagine that you have the correct folder structure and files Track of files and folders is as follows. i want === require_once("../conf.php"); === in file === currency_header_chart.php === that is exsits in root of wordpress theme And == conf.php == Located in Currency/Currency-inc/php/phpchart/conf.php i include conf.php in currency_header_chart.php without error , But Master problem is on line 1 of conf.php that should determine PHPChart script path ... Note : if conf.php move to other place the script do not work please tell me how do change conf.php thanks a lot


how to connect the author profile with google webmaster tools in multiuser blog?

in this page google help us to enable our profile image on google search list when some one search get results from our blog post. my question not about how to do that ... like this link that closed ... but about the blog that has many authors that in the Google article i cant find anything about multi user authors and separation.(seperate them and linked their own posts to google result?) how we can do that , with second solution ?


Making breadcrumb with wp_nav_menu

I was looking for a quick and dirty method to output a breadcrumb navigation on a WP site, without requiring the installation of a plugin and also leveraging the built-in WP menu. Here's what I came up with. I'm curious to know if there is a better solution I am missing, and/or if there is anything obviously wrong with doing it this way. So far in my testing it works quite well.               class BreadcrumbWalker extends Walker_Nav_Menu {         private $i_current_page_id;         private $i_depth;         private $a_output;              function __construct() {             // sets our current page so we know when to exit             $this->i_current_page_id = get_queried_object()->ID;         }              function start_lvl(&$output, $depth=0, $args=array()) {             // increment the depth every time a new ul is entered             $this->i_depth++;         }              function end_lvl(&$output, $depth=0, $args=array()) {             // decrement the depth when we exit a ul             $this->i_depth--;         }              function start_el(&$output, $item, $depth=0, $args=array()) {             // if this value is zero, we're starting a new branch             if($item->menu_item_parent == 0) {                 // reset the output array and depth counters                 $this->a_output = array();                 $this->i_depth = 0;             }             // if we haven't set the representative menu item for this depth, do so             if(!isset($this->a_output[$this->i_depth])) {                 $this->a_output[$this->i_depth] = 'object_id) . '">' . $item->title . '';             }         }              function end_el(&$output, $item, $depth=0, $args=array()) {             if($this->i_current_page_id == $item->object_id) {                 // check to see if this is our last item, if so display the breadcrumb                 if($this->i_depth > 0) {                     // but only show it if we actually have a breadcrumb trail                     $this->display_breadcrumb();                 }             } else {                 // if not, unset the item for this depth since this isn't what we're going to display                 unset($this->a_output[$this->i_depth]);             }         }              function display_breadcrumb() {             // implode our array into a string             echo implode(' » ', $this->a_output);         }     }      Basically what I'm doing is using the Walker_Nav_Menu methods to set an output array that uses the depth as its key, and once the end_el method is called, if it's not the ID of the page that's the end of the breadcrumb, it unsets the item at that depth and keeps iterating over the array. If it _is_ the correct ID, it calls the display_breadcrumb method to output the menu. Thanks in advance for any input. I feel like there's probably a better way to do this, but at the moment am stumped as to what that might be. Cheers.


need some assistance with the checkboxes (selecting/deselecting featured posts)

I am working on a project which has a functionality of "featured_posts" based on this discussion. I have created a table which lists all the posts. I have a checkbox in each row which upon click submits the for through javascript. when the box is checked, it updates everything and marks the post as featured. As a test, i disabled all the featured posts. Upon unchecking the last checkbox, i got > Warning: Invalid argument supplied warning. My code is               foreach( $_POST['list_id'] as $listID ) {         if( update_post_meta( $listID, '_property_featured', 'true' ) ) {             $featureMessage = "Selected listings have been marked as featured successfully.";         }         else $featureError = "An error occurred. Please try again.";     }      list_id refers to the post_id and was in the value attribute of checkbox. I know when the last checkbox was unchecked, i had to face this warning. Question is how can I track unchecking of checkbox as it is not included in the POST data of the form.


WPMU Domain not pinging

I have set up a WPMU setup and used my primary domain as the www. version of topmmorpg100.com This has however caused me a few issues, as a simple command to ping topmmorpg100.com without the www. seems to fail. This is causing some problems when signing up for services of which the domain is pinged and checked for status. I would assume the ping is not working because it is not following the redirect, how would someone suggest that I can fix this?


Fatal errors when Safe Mode is off

I have a site that throws fatal errors when Safe Mode is turned off. For example: > Fatal error: Allowed memory size of 262144 bytes exhausted (tried to > allocate 30720 bytes) in /home/user/public_html/mydomain.com/wp- > includes/compat.php on line 57 or > Fatal error: Allowed memory size of 262144 bytes exhausted (tried to > allocate 30720 bytes) in /home/user/public_html/mydomain.com/wp- > includes/functions.php on line 609 Memory really shouldn't be a problem because Wordpress is allocated 256MB and php is allocated 128MB on my server. Can anyone point to a way to troubleshoot this?


Use Auto Embed with get_post()

I have PHP script outside the WordPress directory where I'm getting the content of a specific post and now trying to apply the `oembed` filter on it:               include('../wp-load.php');     $thePost = get_post(42, ARRAY_A);     $theContent = $thePost['post_content'];      The post's content contains text and one or more URLs to YouTube (or similar pages). Obviously WordPress is able to discover those URLs and rewrite them to embeds, but I have no idea how to apply this behavior on my code snippet. I know there's `wp_oembed_get`, but that function doesn't do the auto- discovery. Any idea how to achieve this?


Bare minimum to include in PHP file to use WP functions?

I'm finding the documentation on coding WP stuff to be very lacking and can't figure out which files I need to include in my PHP script to get a bare minimum working code environment? Example: I want to call `wp_insert_user()` to add a user to my site. How do I know which files in `wp-includes/` I need to include in my PHP script?


Load minimum WordPress environment

I made my own upload service for my website that is separate from WP, but uses WP to provide low level db functions and user verification. To do that, I include wp-load.php in my main script (Uploadify) but doing that seems to fill the server's memory with unnecessary components. Thanks to that, I'm seeing an error in my script that seems to point to a installed WP plugin. How can I load only the core WP components and ignore plugins? Is this even possible?


What happened to the media manger?

Since WP 3.5 (right?), the media manager has been "streamlined" and images are no longer, as I can see it, ordered by year / month in the media manager, although they are still saved as before. Is there any way I can use a hook (or something) to display folders in media manager?


Ensuring sticky posts are retrieved first (without using two queries)?

I need to maintain pagination for use with infinite scroll. Is there no way to tell query_posts to retrieve sticky posts first? It seems to be default behaviour on a standard wordpress blog on the home page, but becomes a bit awkward on a custom template for a page from what I can tell. Thank you. _**Edited to show current query:_**               query_posts( array(          'post_type' => array('post', 'careers-post'),         'paged' => $paged,         'posts_per_page' => 6,         'category__in' => $page_categories,         'ignore_sticky_posts' => 0     ) );      _**Edit 2:_** Seems like "category__in" has a conflict with sticky posts dating back a long time: http://wordpress.org/support/topic/category_in- ampamp-sticky Just to confirm, removing "category__in" does indeed let sticky posts bubble to the top as expected, but obviously doesn't solve the problem.


Can I simulate a user being logged in from a WP_UnitTestCase?

I have some logic in my code that's based on whether or not the user is logged in. How do I test it from my WP_UnitTestCase?


Good tutorial to get started with advanced wordpress plugin development?

Ok I saw many of the tutorials that allow you to introduce a shortcode. Well that is not what I am looking for. I actually want to extend the backend with a way to allow a second title. At the moment we have this: ![enter image description here](http://i.stack.imgur.com/nz3YZ.png) Now I want the possibility to add a "short" title for elements that specifically request, say, a title not longer than 15 characters. So what I want to have is a second input box that allows me to enter this short title. Is there a proven good tutorial for this out there? thanks


How can i initialize a widgetized sidebar (with widgets)

I have a WordPress multisite installation. The client wants an email update form on the sidebar of every blog. I want to use a widget there so I need to assign it to the sidebar. Is there any way to do that on the theme install ?


Create custom permissions for user type

I'm currently wanting to have it so that writers on my site have to have an admin approve their content before it's published, but still be allowed to do other tasks such as uploading images, adding tags, etc, and the wordpress static permission levels are either too restrictive, or let writers publish themselves. I know on drupal there is an easy way to edit permissions for account types, but I was wondering if there is a way to do the same level of functionality with wordpress at all.


Can Rich Text features be configured per user?

There are obviously different types of users (from power-users to casual authors). WordPress's Rich Text editor is based on TinyMCE - which has a lot of features. Most of these features are disabled, by default, inside WordPress to create a friendlier (and safer) editing experience. However, some power-users would prefer to use these extra TinyMCE features. Is it possible to enable or disable various Rich Text features (tables, layers, styles, etc) per user? How is this done? Thanks.


Gantry Framework: new page loads homepage content instead of page content

# Revised Question: I have a WordPress based website with the Crystalline theme installed (made by RocketTheme, uses the Gantry framework). When I create new pages, they do not show the intended content and instead display the home page content. # Original: ### The Issue Permalinks for Pages created since migrating from a LAMP server to a Windows/IIS server incorrectly load the home page content, regardless of whether I use the default Permalink structure or a custom Permalink structure. So, if I attempt to visit www.domain.com/wordpress/new_page/, it loads the content from www.domain.com/wordpress/, but the URL does not change; it remains www.domain.com/newsite/new_page/. However, loading a page created before the transition works fine, so if I attempt to visit www.domain.com/wordpress/old_page, it loads the intended content. As far as I can tell, there is some problem with the internal rewriting that Wordpress does, since a problem with my .htaccess rules would affect all pages. I do not know how to start debugging this though. ### Additional Info   * Permalinks work for all pages that existed when I migrated, even if I change the permalink structure in Settings->Permalinks   * If I make a newly created Page into a child of a pre-existing Page, visiting the newly created page's Permalink now loads the correct content. So, www.domain.com/wordpress/old_page/new_page/ will load the intended content.   * If I make a pre-existing Page into a child of a newly created page, these are the results: www.domain.com/wordpress/new_page/old_page/ loads the intended content www.domain.com/wordpress/new_page/ does not load the intended content   * I am using ISAPI_Rewrite 3. The following is my global configuration file (I am not doing per directory .htaccess files): `               RewriteEngine On       RewriteBase /            #New wordpress site       RewriteCond %{REQUEST_FILENAME} !-f       RewriteCond %{REQUEST_FILENAME} !-d       RewriteRule .*wordpress/.* /wordpress/index.php [L]            #Whole site       RewriteCond %{REQUEST_FILENAME} !-f       RewriteCond %{REQUEST_FILENAME} !-d       RewriteRule .* /index.php [L]`        `


WordPress Ajax Data Security

I am aware of nonces to check for intentions but can't make any sense if I can use them to restrict for database reads somehow? I mean, I am fetching records from the database using AJAX but I don't want anyone to have that data by some other means (POST requests to that `admin-ajax.php` page). For example, in my AJAX handler I have this much of work (I am sending `$myid` along with the action in the AJAX call):               $myid = 5575;     $query = "SELECT `id` FROM table WHERE `user_id` = $myid;";     $data = $wpdb->get_col( $query );     echo json_encode($data);     die();      I am calling this much of data through AJAX, how can I protect it from evil users who can try to make direct POST calls to that page? **Edit:** @Bainternet Thanks for the detailed explanation, appreciate that but my question is really about what @Milo said and I can see that unless I can create a unique nonce for that request, I can't do anything as per @goldenapples. Right? I am handling all this stuff with Facebook JS SDK, so everything that has to be done is with AJAX only (without page load), and whatever I can think of making the user sign in `wp_signon()` or anything, anyone else can do that too without authority. So, I don't have any uniqueness in a user who is actually using the site and the one who is trying to get read some data out other than the site makes the call to fetch the data. And whatever I can do to make it login or anything, that can be replicated by someone else too. Can anyone think of something? **Update:** I think I have found a workaround by just calling it with `action` and get other parameters from Facebook using PHP SDK. But I am still open for suggestions or anything else for that matter.


Nested Gallery Shortcode INTERMITTENTLY working

I have an Expand/ Collapse plugin which, via a shortcode, can expand/ collapse content. My expandable content is a shortcode of a gallery. See here: http://shop.dearearth.net/collections INTERMITTENTLY, the gallery shows up in at least the first to be expanded section, but never in the second... * _these are the plugins:_ *dagondesign.com/articles/expanding-text-plugin-for-wordpress and wordpress.org/extend/plugins/galleria-galleria Any help on this would really be appreciated, of course! :)


Reducing spammy user sign-ups

After following the advice in a previous question (here) I've managed to nuke my spam comments. I now, however, find that every day I have a few new members sign up to the site with rubbish e-mail addresses like 7428174812@aweseome- jewlery.co.uk. I could close sign-ups but I'd rather not as I'm hoping the site will beceome a bit more popular and would like to encourage comments.


Allow html tags in WordPress Custom Menus Description Field

I added descriptions to my menus using this post, Menu items description?. However I need to be able to use html tags and WordPress is stripping them out. Can anyone help?


Display content from "About Us" page on the Home Page

I have a page called "About Us" with some static content. I want to display that static content on the home page. Would I need to do a custom query that returns the about page, or is there a better way?               $about_page = new WP_Query('p=7'); // is this basically it?       Is there a better way to do this? A more dynamic way that would allow me to distribute this theme to others who don't have a specific ID for an About page. EDIT: Found this page on the Codex. It recommends using the get_page function.


Hide / rewrite download link

I want to hide the actual path of my downloads that look like this > http://my.wordpresssite.com/wp-content/uploads/2012/12/example.pdf and instead get something like this: > http://my.wordpresssite.com/downloads/example.pdf I guess I have to do this by rewriting, but I am really not comfortable with that. Could somebody suggest a solution to my problem?


Preventing collisions between permalinks and subdirectories

I've deployed a WordPress installation on the root of my site. This site also has a few subdirectories that should remain accessible, such as `/somefolder/`. I've configured WordPress to use `/%postname%/` as its permalink structure. While importing existing blog posts from another WordPress install, I noticed that a certain post used `somefolder` as its slug, which creates a collision. I know that I can just change the slug, but I was wondering if WordPress offers a mechanism to check for permalink/subdirectory collisions.


How WordPress attaches its Featured Images with posts?

I'm working on a `WP_Query()`, where I'm trying to fetch all the images using `'post_type' => attachment` and `'post_parent_in' => array( 1688 )`(I want to pass some more post_ids) along with other parameters. With these I can fetch all the attachments, but the featured image. I attached two different images into a post to check the thing. Then I sneaked into the WordPress database, and in '`posts`' table, I found the two images are there as `'post_type' => 'attachment'`, and `'post_mime_type' => 'image/jpeg'`.   But...   in '`post_parent`' one image is attached with the post with the post id (1688), but the other is showing Zero (0). I found that, only the images, those are inserted into a post are getting `post_parent`, but the featured image. ![database posts table post_type attachment with no post_parent](http://i.stack.imgur.com/4hwM3.png) And the same attachment is in `postmeta` table: ![featured image in postmeta table](http://i.stack.imgur.com/YJbG6.png) So, currently I'm unable to get all the attachment that are attached to some posts. And, I wonder, HOW THE FEATURED IMAGES ARE ATTACHED WITH THE POSTS?


I made a custom plugin for my wordpress admin for view user detail. This plugin is working fine after showing this error but the main issue is by this plugin , when i try to open some link the page went blank. I dont know why and what is this error..Searched on internet but unable to resolve this issue. Your help would be appreciated...here is the fulll error comes when i activate this plugin...I **The plugin generated 751 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin**


one term two taxonomy's?

Anybody got any solutions for this... I'm building an app where I have two heirchical custom taxnomies acting as custom categories. So i've got cat1 and cat2 taxonomy. What I want to do is copy a term, along with its children from cat1 to cat2. Maybe something like:               set_term_taxonomy($term_id, array("cat1, "cat2"));      where the same term, along with its children, could be in more than one taxonomy. The reason for 2 taxonomies is that they are 2 different shop inventories.


Change a Page's Header Image

I am using Sunrise Theme from s5themes.com , and I was wondering if in the individual pages I can have a different Header Image, because from what I can tell they use the same CSS code in displaying the header image on the Home Page. Here is the screenshot of the Home page showing the Image as header ![enter image description here](http://i.stack.imgur.com/26WS2.jpg) And here is the screenshot of the a Page (About Us) which uses the same Image (the brown texture with green part) as header only seemed zoomed-in. ![enter image description here](http://i.stack.imgur.com/Ov13L.png) I tried digging into the code and I believe this is the part in the Styles.css that deals with it. **CSS**               .header-wrapper {     background: #333;     background-image: url(img/wood-only.png);     background-attachment: fixed;     background-size: cover;     min-height: 200px;      So I edited the code above, unfortunately it also affects the Image in the Home page I tried setting the background-size into               background-size: auto;      Ideally I can work with editing the template files but I am not familiar with WordPress' structure, and now I am not sure how to procede.


How we retrieve the 'tags' and 'attachment' of the custom post which is created by wp_insert_post();

I am not able to get the data of post which i inserted by               wp_insert_post();      now i want to get the tags which i stored by               'tags_input' => array('thread_tag' => $tags)      and i also upload an image of this post as attachment, so could you please tell me how to retrieve the attachment?


How to fix a theme with page.php Default Template that accidentally deleted?

I am having a quite odd case with WP today, and after spending about an hour searching on google and forums, can't find any answers. I hope posting here might allow me some chance to get help from WordPress Wizards that lurks somewhere on this support forum :) Anyway, my problem here is that I accidentally deleted page.php on my template (I am trying to remove all default template and make WordPress more personalized and customizing backend). I wanted to remove the template called 'Default Template' and make the template dropdown on pages shows like: One Page Template (or just a random name) Grid 2 sidebar Template (or just a random name) Store contents (or just a random name) After I deleted page.php -- the Default Template didn't removed at all, I still got it, and I got no way to style or remove it. Adding to the problem is when I recopied page.php from my repository, **I got DOUBLE template called 'Default Template' now!** I tried to replicate the problem by installing a fresh copy of WP 3.1.2 and duplicate 2010, and then I activate that duplicate. Here's my steps:   1. Delete page.php and page-with-sidebar.php   2. Check pages, now I got 'Default Template', but no page.php   3. Recopied page.php   4. Check pages, now I got TWO 'Default Template'   5. Switched to the original 2010 -- check pages -- works OK, with one 'Default Template' and one 'Default Template with Sidebar'   6. Switched back to the modified 2010 -- check pages -- still got double 'Default Template' Now, what I see here is that this problem definitely happens because I deleted page.php -- and it's stuck on the Theme, not on the wordpress installation itself. To make the matter worse, I can't find any file that is updated because of it -- really amusing. This is what looks close to what I have, but not really:   * http://wordpress.org/support/topic/page-templates-gone-wp-271   * http://wordpress.org/support/topic/missing-template-files-makes-wp-fall-back-on-default My questions:   1. What should I do to fix the problem? I wanted to know if there is anyway to return the theme to recognize that we already got the page.php back.   2. How to remove the 'Default Template' from the dropdown lists of page template? Maybe through unset   call on functions.php ? Many thanks in advance. Andre


WooCommerce wp_mail attachment not working dynamically

I have edited function send() to attach the file in woo commerce plugin when, I am use the attachment file path statically it work's but when, I put it on dynamically attachment source not able send the attachment but, I am getting mail.I am using select query for getting image from database to attach in mail.               function send( $to, $subject, $message, $headers, $attachments ) {      global $wpdb;                       $current_post1=$post->ID;          $result1=$wpdb->get_results("SELECT BgImageName FROM ca_woocommerce_order_items where order_id = $current_post1 ");               foreach ( $result1 as $print1 )            echo $imgemail=$print1->BgImageName;                     //static path it's work        //$attachments = array(  '/home2/rahulr/public_html/cutting-edge/wordpress_theme/user_templates/1384010402.png' );                 //dynamic path it's not working        $attachments = array('/home2/rahulr/public_html/cutting-edge/wordpress_theme/user_templates/'.$imgemail);                       add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );             add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );             add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );                  wp_mail( $to, $subject, $message, $headers, $attachments );                  remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );             remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );             remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );         }


I want Page titles and excerpts to show up on home.php in certain order

In the functions.php, I have the following code added:               add_post_type_support( 'page', 'excerpt' );      This allows pages to have excerpts. The reason I want an excerpt is because I want to call only pages with excerpts to be one of 3 modules on the home page. On the front page, in my home.php file, these 3 modules will show the titles and excerpts of the pages in which I have added an excerpt. At anytime, the editor should be allowed to change the placement or page so that any existing page could theoretically become a module on the home page. For example, I have an About, New Patients and Services page, all three of which I have added text to the excerpt field (I will leave all other excerpt fields blank on pages which don't need to appear on the front page). On home.php, in the order I just listed, I want the title and excerpt of each page to show up as three columns. Here's how I intend to style it: http://i.stack.imgur.com/jOPb0.png It's possible these 3 modules will either need an order change or replaced by another page, which is why I'm looking for dynamic modules. I have created two custom fields, called `home_widget` and `order`. `home_widget` is equal to either `true`, whereas `order` is equal to the order they should appear on the page. This code is wrong, but I'm looking for similar logic:               <?php       $pageExcerpt = get_the_excerpt();        if (is_page() && $pageExcerpt !== '') {         the_excerpt();       }     ?>      In other words, if a page exists AND it has an excerpt, then call the_excerpt() but do it in the order I define by custom field entry. This allows for dynamic insertion as needed. How do I write this code to work as I stated?