title: Distinction on meta value on pre_get_posts

text: I've got a special "position" meta field for posts which can be between 0 and 37. 0 Is ignored, and everything else can have obviously any number between and including 1 and 37. But this of course means that multiple posts can have the same number. Now I'm trying to select only the latest entry from these duplicates, however, I'm not having any luck. These are the hooks I've applied to achieve what I get at the moment:               add_action( 'pre_get_posts', 'foo_pre_get_posts' );     function foo_pre_get_posts( $query ) {         if (!is_admin() && is_home() && is_a( $query, 'WP_Query' ) && $query->is_main_query() ) {             $query->set( 'meta_key', '_position' );             $query->set( 'posts_per_page', 37 );             $query->set( 'meta_value', '0' );             $query->set( 'meta_compare', '>' );             $query->set( 'paged', 1 );         }     }          // order the stuff on meta value and then post date since pre_get_posts can't do it.     add_filter("posts_orderby", "foo_posts_orderby");     function foo_posts_orderby( $orderby) {         if (!is_admin() && is_home()) {             return "wp_postmeta.meta_value+0 ASC, wp_posts.post_date DESC";         }         return $orderby;     }          add_filter("posts_groupby", "foo_posts_groupby");     function foo_posts_groupby( $orderby) {         if (!is_admin() && is_home()) {             return "wp_posts.ID, wp_postmeta.meta_value";         }         return $orderby;     }      The SQL generated:               SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID     FROM wp_posts         INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)     WHERE 1=1  AND         wp_posts.post_type = 'post' AND         (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND         ( (             wp_postmeta.meta_key = '_position' AND             CAST(wp_postmeta.meta_value AS CHAR) > '0'         ) )     GROUP BY wp_posts.ID, wp_postmeta.meta_value     ORDER BY wp_postmeta.meta_value+0 ASC, wp_posts.post_date DESC LIMIT 0, 31      I tried a groupby, to no avail, tried playing around with `DISTINCT` directly in phpMyAdmin (copying the generated SQL of course), again, to no avail. The results I get:               [ ID ] [ position ] [ date ]       1         1         12/08/2012       4         1         07/08/2012       5         1         06/08/2012       6         2         08/08/2012       9         2         07/08/2012       8         5         09/08/2012      Note: this is just test data How can I make it select only the first option based on position so something like this:               [ ID ] [ position ] [ date ]       1         1         12/08/2012       6         2         08/08/2012       8         5         09/08/2012      Thanks!


title: What approach should I take for this URL structure?

text: For a website I am developing I have to create two pages with listings of courses. The first page is a "Trainings" page while the other page is "Coaching". I would like to use a single custom post type for the content of the courses, because this will be the same for the all the courses on the Trainings and Coaching listings. I also need to assign each courese to a sub category. These sub categories will only be used to display the courses in separate columns on the Trainings and Coaching pages, but the user should be able to specificy the sub category for each course, however, a course should only be allowed to have a single sub category. The URL structure I would like to have is the following: `Trainings > Training category 1 > Training one ==> /trainings/training-one` `Trainings > Training category 2 > Training two ==> /trainings/training-two` `Coaching > Coaching category 1 > Coaching one ==> /coaching/coaching-one` `Coaching > Coaching category 2 > Coaching two ==> /coaching/coaching-two` I am new to Wordpress so I would like to know what would be the correct Wordpress way to go about this.


title: How to point "add_menu_page" to HTML file rather than PHP function

text: I added a new menu item for my plugin like this:               add_menu_page(       'Control Panel',       'My Plugin',       'manage_options',       'control-panel',       array($this, 'control_panel_page'),       plugins_url('/images/menu_icon.png', __FILE__)     );          public function control_panel_page() {       // My HTML goes here     }      However, I feel uncomfortable with the fact that all my HTML resides in PHP function (`control_panel_page`). Is there an option/hack to point to HTML file rather than PHP function?


title: Assign single template to multiple custom post types?

text: I have a number of custom post types that I would like to display with the same template which I have created initially as `single-photography.php` in my theme. Is there any way to assign this template to multiple custom post types? I understand I can probably do this within the `single.php` file with a conditional include based on `get_post_type()`, but I'm wondering if there is a better way?


title: How can I modify the media upload form fields?

text: I would like to add a line of text under the description field in the media edit form to give users more direction as to how to fill out this field. What is the best way to do this? I know how to add form fields, but can't seem to figure out how to modify existing ones. I added               unset($form_fields['post_content']);       but for some reason this doesn't seem to remove the default description field. Thanks!


title: About pro paypal express

text: For our WP website http://www.interlinguals.com we want to use Paypal Express as part of our Ready Ecommerce plugin. We added the API and all credentials in the Paypal plugin part, but we cannot seem to connect the Paypal Express with the Ready Ecommerce plugin. Following instructions on http://docs.readyshoppingcart.com/paypal-express-plugin-configuration/ we followed the steps within the section Setup Paypal Express. In the WP Dashboard > Ready Ecommerce > Options > Payments it mentioned the Paypal Express PRO, so on the right side it said 'get it!'. We bought it, unzipped the file and tried to see if we could follow the next steps on the instructions. Now having arrived at the section Configure Gateway we still cannot find the 'Lable' option for this gateway neither the next steps. We tried adding the unzipped files through the ready ecommerce plugin folder using the FTP client. Still no result on the WP Dashboard Ready ecommerce Options > Payments screen. Also, the WP Paypal section doesnt give an option to connect PayPal with Ready Ecommerce. How can we make the Paypal Express to work? Thanks for your help!


title: allow BOTH post slug and meta key value in permalink for custom post type

text: I want to pull up a custom post type called `Schedule` whether the permalink uses the post slug OR a value stored in the post's meta values. E.g. `/schedule/jims-schedule/` and `/schedule/67sGHGj54hjs/` need to pull up the same post. A little more info so you understand why I'm doing this:   * The reason for the funky meta value "id" and corresponding permalink is that it's the link you can use to share with whoever you want so they can pull up your schedule, so I don't want to just use slugs because they could be easy to guess.   * using the default permalink with post slug needs to be something that only the signed-in post author can use to view the Schedule. They'll have options to modify and manage the schedule on the front-end.


title: Shortcode inserts paragraphs before and after executing shortcode

text:
When my shortcode is executed, it inserts a `<p></p>` before and after the shortcode. My shortcode is the only thing in the text editor of the page. There is not a newline before or after my shortcode. Here's my shortcode functions:               //* Shortcode for child pages     function list_sub_pages( $atts ) {              extract( shortcode_atts(array('page' => 'home', 'display' => 'excerpt', 'show' => '3', 'speed' => '10'),$atts));                  $page_id = get_page_by_path($page);              switch ( $display ) {             case 'excerpt':                 $content = display_page_excerpt($page_id, (int) $speed);                 break;             case 'kids':                 $content = display_child_pages($page_id, (int) $show, (int) $speed);                 break;             case 'blog':                 $content = display_blog_posts((int) $show, (int) $speed);                 break;             default:             break;         }                   return $content;     }     add_shortcode('group', 'list_sub_pages');          function display_page_excerpt( $page_id = 1, $speed = 10 ){         $page_data = get_page($page_id->ID);              $output = '
post_name.'">';         $output .= '
post_name.'-bkgd" data-type="background" data-speed="'.$speed.'">

';         $output .= '
post_name.'">'.$page_data->post_excerpt.'
';         $output .= '

';                  return $output;     }          function display_child_pages( $page_id = 1, $show = 3, $speed = 10 ){         global $post;              //query subpages         $args = array(             'post_parent' => $page_id->ID,             'showposts' => $show,             'post_type' => 'page',             'orderby' => 'menu_order',             'order' => 'ASC'         );         $subpages = new WP_query($args);              // create output         if ($subpages->have_posts()) :             $output = '
post_name.'">';             $output .= '
post_name.'-bkgd" data-type="background" data-speed="'.$speed.'">

';             $output .= '
post_name.'-title home-titles">post_name.'">';             $output .= get_the_title($page_id->ID);             $output .= '

post_name.'">';             while ($subpages->have_posts()) : $subpages->the_post();                 $output .= '
post_name.'-link">
post_name.'-info">
post_name.'-img">'.get_the_post_thumbnail($page->ID,'icons').'

'.get_the_title().'

post_name.'-excerpt">'.get_the_excerpt().'

';             endwhile;             $output .= '
';             $output .= '

';         endif;              // reset the query         wp_reset_postdata();              // return something         return $output;     }          function display_blog_posts( $show = 3, $speed = 10 ){              $output = '
';         $output .= '

';         $output .= '
Recent News

';              $args = array(             'numberposts' => $show,             'order' => 'post_date',             'order' => 'DESC',             'post_status' => 'publish'         );           $posts = wp_get_recent_posts($args);         foreach( $posts as $post ){             $post_id = $post["ID"];                  $output .= '

'.$post["post_title"].'

'.$post["post_excerpt"].'

 ';         }              $output .= '
';         $output .= '

';              // reset the query         wp_reset_postdata();              return $output;     }      Here's what the HTML mark up looks like from my browser. ![enter image description here](http://i.stack.imgur.com/OWV3y.png) So, I'm in need of figuring out where these rogue paragraphs are coming from. Any insight would be greatly appreciated. Thanks!


title: Common page width?

text: I just made a new wordpress theme for a code type site, I am currently at 920px wide, I am curious what most people are using for a width now days, I would like to go wider but I just want to know if there is any kind of standard or common width that most people use?


title: How to list first (etc. 5) posts as new?

text: I am looking for a plugin or a way to list first five posts as new. It should be just a small picture added in the index.php. Any ideas of how I could achieve this? Thanks!


title: What filter should I use to insert a button inside on Media>Add New

text: I am adding a new way to upload a media file to WordPress. So I am looking for a way to add a link or a button to the Upload New Media page. What is the recommended filter? Or is there another better solution to add a button? Here is a screenshot of what I am trying to accomplish: ![enter image description here](http://i.stack.imgur.com/SZ359.png) I added a button named: "Other Option". I also added: "Another option: Other Option". On top of Maximum upload file size...


title: Difference between an archive and a page listing posts

text: I am wondering what is the difference between a wordpress archive page, and just a page template listing out posts? Right now I have a custom archive page, listing all entries of a custom post type. This could very well have been handled by just a normal page. Right now I am going to list out all blog posts (not on the front page, but as a `news` option in the menu), and I am wondering if I should use an archive page or create a page template that lists out posts. What is the different in intent for these pages?


title: Cannot install plugins on Centos VPS

text: I am unable to install plugins on my Centos 6 VPS. When I attempt the install I get this: > Installing Plugin: BotDetect WordPress CAPTCHA 3.0.Beta1.7 > > Downloading install package from   >  [web path to:]botdetect-wp-captcha.zip…   >  Unpacking the package…   >  Could not create directory.   >  Return to Plugin Installer UPDATE: This seems to have something to do with permissions -- I'm guessing there's some group that wordpress needs to be part of in order to change folders, create files, etc., but I can't figure out what that group should be. I have no www-data group -- I read something somewhere about this being a requirement. Can somebody tell me what groups and permissions need to exist for WP to operate? UPDATE: I have chmodded the permissions to my plugin and uploads folders to 777. I also have created an FTP user specifically for Wordpress and made the home directory for that user the same as my Wordpress root folder as recommended HERE. I then changed these lines in the wp-config.php file from:               /** Absolute path to the WordPress directory. */     if ( !defined('ABSPATH') )         define('ABSPATH', dirname(__FILE__ . "/"));          /** Sets up WordPress vars and included files. */     require_once(ABSPATH . 'wp-settings.php');      to:               /** Absolute path to the WordPress directory. */     if ( !defined('ABSPATH') )         define('ABSPATH', dirname(__FILE__));          /** Sets up WordPress vars and included files. */     require_once(ABSPATH . '/wp-settings.php');      This should eliminate the double slash conflict mentioned HERE. Note -- I was also having a problem uploading media but that issues was resolved with the chmod to 777. Now when I try to install a plugin I get this:               Unable to locate WordPress Plugin directory.          Return to Plugin Installer


title: orderby in WP_query doesn't works

text: I thought that this already works but now I tested it and it seems that it no longer works.   I have this code:               wp_reset_query();     $args=array(         'posts_per_page' => 3,         'meta_key' => 'info_tab_1',         'orderby' => 'meta_value_num',         'order' => 'DESC'                );     $info_tab = null;     $info_tab=new WP_Query( $args );      `print_r($args);` prints:               Array (        [posts_per_page] => 3        [meta_key] => info_tab_1        [orderby] => meta_value_num        [order] => DESC      )      `print_r($info_tab);` prints:               WP_Query Object (        [query_vars] => Array (          [posts_per_page] => 3          [meta_key] => info_tab_1          [orderby] => title          [order] => ASC          [error] =>          [m] =>          [p] => 0 ...


title: Understanding WordPress Search

text: I am trying to create a custom search similar to the one on totaljobs.com but through a WordPress site. Essentially I would be able to search for both search terms and location simultaneously. The way it's working now is that there is a search term field and then there is also a location search. They are two separate fields. For the search term field, I'm using the standard WordPress search and for the location search I am taking the jobs latitude and longitude and a radius setting and running them through the Google Maps API. As you can see, the search process is quite different on both searches. I've added custom fields to the posts for latitude and longitude and am querying them in the database for my search. What I don't know is how the standard WordPress search works. Is it looking in the post_content and post_title field, etc.? I can't seem to find the server side code to investigate it because the search.php is more of a generic loop code. I've found that $s is the global variable for search term but I can't find where that variable is being processed and am interested in how the database uses that variable because I think I'll need to build around the current WordPress search info. I appreciate the help. Thanks!


title: Don't load the theme for a page FROM a plugin EDITED

text: I'm developing a pseudo admin area for my client and they don't want the theme overlaid on it, rather have their admin area take up 100% of the page. Normally I would add `if (!is_page($id))` and be done with it however this admin area is part of a plugin that will be used on multiple sites and I would rather not be adding that line of code to every site that is created with this plugin. Essentially, is there a function akin to `use_theme(false)` that I can use as part of my plugins shortcode? **EDIT** Is it possible to call `define('WP_USE_THEMES', false);` from a plugin file? I have tried adding it to the top of my short codes function but to no avail. This is leading me to believe that the template is called before the plugins meaning by the time you get to calling plugins it's too late? **EDIT 2** I have had luck creating a page template using this plugin however it is still loading the page css. My template file is listed here on pastebin. The page still shows as if the theme is being called in it's entirety. I am fairly certain it's been called because the plugin is no longer outputting an incorrect `plugin_dir_path` which it was doing due to hierarchy fun.


title: Can Categories be used to hack a Multisite-like setup w/ a single MySql db?

text: I have a project which will effectively create multiple blogs that will be fed existing content (don't worry, this isn't copyrighted content from other blogs or anything like that). From a DB management and moderator point of view, and to limit hosting costs, I would like to avoid the built in multisite functionality which requires a separate DB for each blog. I am wondering whether, with some intelligent duct-tape hacking, it is feasible to run multiple blogs in one WordPress blog that appears as many separate blogs. I think that Categories might be hijacked to make this work. Basically each separate "blog" is a separate category. Is there anyone who has done this or has another, single DB multi blog approach (using WordPress)? Words of wisdom or caution about the kind of tweak I am suggesting?


title: Child theme within a child theme?

text: I'm developing a child theme, but also want to make it possible for that child theme to have a custom functions.php file that won't be overwritten during theme updates .. is this possible in any manner?


title: How does WP media uploader create the 3 different sized images, and how can I duplicate it

text: I have finally!! got this thing I've tried about 12 times to make and 12 different ways, but finally got it to work,... sort of. I made a custom metabox for uploading and attaching images to posts, and it doesn't require you to use the horrible thickbox media uploader built into WP. I hate that thing. No, what I've done is just a group of inputs (title, description, file), which you can also duplicate, to add additional attachments if you want. So you fill in the fields, select an image to upload, and save draft or publish the post. Once there are attachments added to a post, the metabox will display the input fields, along with a preview image of the attached image for each attachment you added. The title and description fields are used to generate the file meta data, nothing is saved as the post_meta, that I know of. That's currently all that I have gotten working so far. I need to make it so that when you save/publish a post, inturn upload/create the attachment files, it will create the three image sizes as the default wp uploader would, thumbnail, medium, large, and keeping the full size image too. If that's possible somehow. If not, I would like to otherwise use add_image_size() to create/define new custom sizes, and generate them that way instead, upon uploading. I'm not sure which function is the most ideal to use in this case, maybe the image_make_intermediate_size() function would be better, or wp_create_thumbnail() or wp_crop_image()... who knows!! I cannot figure out how to go about doing that, if I need to run the wp_handle_upload() function for each one, or maybe something involving the wp_generate_attachment_metadata() function. It's confusing to me since the 3 image sizes are to be associated as variants of the same attachment, and how to go about doing that. I have scoured the web, read the source of every wp media/upload/image related file, and played with just about every function there is for the media upload stuff and cannot find how WP creates the 3 image sizes anywhere, or how to do it myself. In wp-includes/media.php the image_resize() function looks like it would be best since it's exactly what it should be. I just can't figure out for the life of me what the hell I'm missing or have tried doing but did wrong to make the image thumbnails. Here's my working function that does the wp_handle_upload() stuff and things, but it also needs to create the 100px thumb, and make a resize version of the image that is max-width like 500px, and saved as new files of the uploaded one.               function update_attachment(){       global $post;            wp_update_attachment_metadata( $post->ID, $_POST['a_image'] );            if( !empty( $_FILES['a_image']['name'] )) { //New upload         require_once( ABSPATH . 'wp-admin/includes/file.php' );              $override['action'] = 'editpost';         $url = wp_handle_upload( $_FILES['a_image'], $override );              // $medium = image_make_intermediate_size( $uploaded_file['url'], 500, 400, true );         // $thumb = = image_make_intermediate_size( $uploaded_file['url'], 100, 100, true );              if ( isset( $file['error'] )) {           return new WP_Error( 'upload_error', $file['error'] );         }              $array_type = wp_check_filetype         $allowed_file_types = array('image/jpg','image/jpeg','image/gif','image/png');              $name_parts = pathinfo( $name );         $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] )) ));              $type = $file['type'];         $file = $file['file'];         $title = $_POST['a_title'] ? $_POST['a_title'] : $name;         $content = $_POST['a_desc']              $post_id = $post->ID;         $attachment = array(           'post_title' => $title,           'post_type' => 'attachment',           'post_content' => $content,           'post_parent' => $post_id,           'post_mime_type' => $type,           'guid' => $url['url']         );                   // Save the data         $id = wp_insert_attachment( $attachment, $_FILES['a_image'][ 'file' ]/*, $post_id - for post_thumbnails*/);              if ( !is_wp_error( $id )) {           $attach_meta = wp_generate_attachment_metadata( $id, $uploaded_file['url'] );           wp_update_attachment_metadata( $attach_id, $attach_meta );         }         update_post_meta( $post->ID, 'a_image', $uploaded_file['url'] );       }     }      Anyone able to help me finally fix this so it works proper would be loved. I've spent so many ridiculous countless hours numerous different times trying to develop this thing and the documentation sucks, and there's not really any good posts anywhere on how to do it. Thanks


title: Plugin to remove Admin menu items based on user role?

text: I searched high and low for a plugin that can remove/hide Admin menu items , including custom post types and taxonomies, based on user role. Every one I have tried only does a global hide, not based on user role. Other more complex ones like adminize do not display custom post types or taxonomies. Do I have to write my own function or is there a simple plugin I am overlooking?


title: Plugin Upgrade Strategy

text: Reading register_activation_hook() told me that in wordpress 3.1, this will only work for every plugin activation, not plugin upgrade. What I want to know is, what's the best plugin upgrade strategy? My though is:   1. on action 'admin_init' check for '{plugin_name}_version' option      1. if '{plugin_name}_version' doesn't exist, let's assume it's from previous version (because at that version, we don't have '{plugin_name}_version' option, yet. Go to process 2.     2. if '{plugin_name}_version' option exists and doesn't match with '{plugin_name}_version' set in script, go to process 2.     3. if '{plugin_name}_version' option match with '{plugin_name}_version' set in script, exit process.   2. launch our plugin upgrade function with '{plugin_name}_version' value as parameter   3. do whatever needed for this upgrade process   4. after upgrade process finished, set '{plugin_name}_version' option to '{plugin_name}_version' from script. Any comment for this process?


title: Filter Categories widget to allow custom sorting?

text: Man, I can't seem to ever get done with enhancements to WordPress categories. I hope there's more work done on core category options in the future. Especially with the emergence of site theming and siloing of late. I know WP is ahead of most publishing systems in terms of its early support for categories, but it seems they've left lots on the table after that. Does a hook exist that would allow one to enhance the widget options for the category widget in order to allow setting the default sort order? Also, I notice in the codex the options for sort appear to be one of any of these (id, name, slug, count, group) and either ascending or descending. So, Ideally a drop down menu on widget options panel to allow one to set those two parameters (order and orderby) is what I'm looking to do. Otherwise, I'll just filter wp_list_categories and add the order option to my theme options, but it seems more logical to put it on the widget control itself.


title: How to Make Multiple Pages Display Previous 2 out of 10 Next

text:
I'm using wp_link_pages to split my post into multiple pages. I want to achieve something like this. Please help me with the exact codes. Thank you so much in advance. ![Display Previous count and Next Page](http://i.stack.imgur.com/fQMKx.png) Here's my code so far **Functions.php**               add_filter('wp_link_pages_args','add_next_and_number');     function add_next_and_number($args){         if($args['next_or_number'] == 'next_and_number'){             global $page, $pages, $numpages, $multipage, $more, $pagenow;             $args['next_or_number'] = 'number';             $prev = '';             $next = '';             if ( $multipage ) {                 if ( $more ) {                 $i = $page - 1;                 if ( $i && $more ) {                     $prev .= _wp_link_page($i);                     $prev .= $args['link_before']. $args['previouspagelink'] . '';                 }                 $i = $page + 1;                 if ( $i <= $numpages && $more ) {                     $next .= _wp_link_page($i);                     $next .= $args['link_before']. $args['nextpagelink'] . '';                 }             }         }         $args['before'] = $args['before'].$prev;         $args['after'] = $next.$args['after'];         }     return $args;     }      **single.php**               wp_link_pages(array('before' => '
', 'after' => '
', 'next_or_number' => 'next_and_number'));        That code displays page links as numbers like this: 1, 2, 3, 4 I want it to look like this: 2 of 4


title: Can't get rewrite rules working

text: Basically I want to rewrite: /edit/test-post to an existing page with a parameter: /edit?e=test-post From the examples in the Codex I created:               add_filter( 'rewrite_rules_array','my_insert_rewrite_rules' );     add_filter( 'query_vars','my_insert_query_vars' );     add_action( 'wp_loaded','my_flush_rules' );          // flush_rules() if our rules are not yet included     function my_flush_rules(){         $rules = get_option( 'rewrite_rules' );              if ( ! isset( $rules['(edit)/(\d*)$'] ) ) {             global $wp_rewrite;             $wp_rewrite->flush_rules();         }     }          // Adding a new rule     function my_insert_rewrite_rules( $rules )     {         $newrules = array();         $newrules['(edit)/(\d*)$'] = 'edit?&e=$matches[2]';         return $newrules + $rules;     }          // Adding the id var so that WP recognizes it     function my_insert_query_vars( $vars )     {         array_push($vars, 'e');         return $vars;     }      However, I simply cannot get it working, what am I doing wrong? Thanks!


title: Basic installation questions

text: I've downloaded WordPress and I want to ensure I'm uploading it to my server correctly:   1. I see there's a .zip file and a .tar.gz file -- which should I use? It's an Apache server. This is the place my site will be: http://plowtoplate.com/   2. I want the site to be at http not at www., but I do want either the site to also be visible at www. or for the www. to redirect to http -- where should I upload the WordPress files? Into public_html? or just into the place I get to when I login with ftp? (the 'root' I think that's called...?)   3. Do I unzip wordpress-3.2.1.zip and upload those files, or do I upload the .zip to the server?   4. Once the files are uploaded, is there anything else to do before it's ready to go?   5. How do I get the username and password to login to the admin panel so I can build the site? And what url do I go to to login? Beginner questions, I know. I appreciate help. Thanks, Richard


title: Specify what to do for a specific image number of the post

text:
I want to specify for the images of my post - if is number x, output this, else if is number y output this instead, etc. I'm trying make specific treatments to my 1st, 4th, 9th images for that post. This code below is the code i'm using to just simply output all of my images for the post. Any ideas?               <?php $images = get_post_meta($post->ID, 'rw_postpage_images');  ?>     <?php foreach ($images as $att) {     $src = wp_get_attachment_image_src($att, 'full');     $src = $src[0];      $image_path =  thumbGen($src,80,80,"crop=1&halign=center&valign=center&return=1");     ?>

     <img src="<?php echo $image_path; ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" width="80"  height="80"/>

     <?php } ?>


title: Problems with loop

text:
I have this loop in my index.php:                     <?php if (have_posts()) :               while (have_posts()) :                 get_template_part( 'post' );               endwhile;             endif; ?>      which calls this template               <?php         ?>      <h2 id="post-<?php the_ID(); ?>">      <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">      <?php the_title(); ?>
      <?php the_post();      the_content(); ?>
<?php the_time('l, j F Y'); ?>
      <?php trackback_rdf();     ?>      The loop behaves strangely printing out titles and posts in this order:   * Title post #1   * Content post #1 (and this is ok, but then...)   * Title post #1   * Content post #2   * Title post #2   * Title post #3 (and so on...) What am I doing wrong?


title: Catch 404 errors in nested installations

text: I have a site at the root of my `/http/` folder (I'm using Apache). In a subfolder, I have another WP site. When a 404 is encountered within the subsite, like this:               www.mysite.com/subsite/thisDoesntExist/      the 404 page for `www.mysite.com` comes up - instead of the 404 for `www.mysite.com/subsite/` Can I make the subsite catch these 404 errors?


title: How to set a static html front page

text: I'm trying to set a wordpress static HTML front page, which doesn't seem trivial. I tried three approaches: 1) add a index.html, and rename index.php to blog.php. Change the permalink into custom: `/blog.php?p=%postid%`. However for handling categories, the generated link is `/blog.php?p=cat=3`. 2) add a index.html, and rename index.php to blog.php. Change the installation position into `www.mydomain.com/blog.php` in my dashboard. This time it direct to `www.mydomain.com/blog.php/?p=123`. 3) add a page and set it to be displayed as frontpage in my dashboard/settings/reading. However for this solution, I don't know how to change the overall html of a page edited in wordpress. I can only modify the html for the body but I need to change it whole. Any suggestions?


title: problem using ajax url

text: I've got a `js` file like this:               var category = [];     var genre = [];     var type = [];     var mainContent = jQuery('#content');     var siteURL ="http://" + top.location.host.toString();         var URL = siteURL + "/?category="+ category +"&genre=" + genre +"&type="+ type +" #content";          jQuery('.ajax-cb').each(function() {         jQuery(this).click(function() {                      mainContent.load(URL,function(){                                     mainContent.animate({opacity: '1'});             });                            });          });       It does load `GET[]` parameters to change the loop, in the theme's `function.php` I've got:               function pre_selected_results() {       $taxquery = array(           'relation' => 'OR',           array(             'taxonomy' => 'category',             'field' => 'slug',             'terms' => $_GET['category'],             'operator'=>'IN'           ),           array(             'taxonomy' => 'genres',             'field' => 'slug',             'terms' => $_GET['genre'],             'operator'=>'IN'           ),           array(             'taxonomy' => 'types',             'field' => 'slug',             'terms' => $_GET['type'],             'operator'=>'IN'           )                                                );       $stack[] = "dog";       $the_query = new WP_Query($myquery);       while ($the_query->have_posts()) :        //the loop            //I then collect info from the loop displayed                 $args = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'slugs');       $results = wp_get_post_terms(get_the_ID(),'category',$args);             foreach ($results as $result){               array_push($stack, $result);           }       endwhile;     /*And I use wp_localize_script(); to send $stack back to js*/       wp_enqueue_script( 'feedback' );       wp_localize_script( 'feedback', 'jsdata', $stack);     }; //end of pre_selected_results      On my home page I call `pre_selected_results();` the loop display fine and refresh, but `$stack` only refresh if I edit the URL with `GET[]` manually in the browser, otherwise it just return 'dog', anything obvious to you that I'm missing?


title: Image upload and path to custom field

text:
I build a script, to post from frontend. There are many custom-fields. Most works fine, but with one thing i have problems. First a description, then the script. It seems like, that images won't upload, cause i can't find them in the upload-directory or anywhere else. The cutom-field will be generated, that's no problem. I say that, cause the field appears at the backend - but empty. I think it's empty, cause it doesn't upload. Yes, for testing i have put 777 to my serversettings for the upload-directory, so i think the server is not disabling the upload. P.S.: I shortened the code to make it clear. If you want the hole code, just say a word. Thank you for helping!               if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {         // Funktion zum Image-Upload, falls sie noch nicht existiert         if ( ! function_exists( 'wp_handle_upload' )) {              require_once(ABSPATH . "wp-admin" . '/includes/image.php');             require_once(ABSPATH . "wp-admin" . '/includes/file.php');             require_once(ABSPATH . "wp-admin" . '/includes/media.php');         }              // Variablen für die Bilder         $image_1_gesucht = wp_handle_upload( $file['image_1_gesucht'] );         $image_2_gesucht = wp_handle_upload( $file['image_2_gesucht'] );              // Benutzerdefinierfte Felder für die Bilder         add_post_meta($pid,'image_1_gesucht',$image_1_gesucht['url']);         add_post_meta($pid,'image_2_gesucht',$image_2_gesucht['url']);     }          <form id="new_post" name="new_post" method="post" action="" enctype="multipart/form-data">
             <fieldset class="images">                 Bild 1:                 <input type="file" name="image_1_gesucht" id="image_1_gesucht">             </fieldset>

             <fieldset class="images">                 Bild 2:                 <input type="file" name="image_2_gesucht" id="image_2_gesucht">             </fieldset>
     </form>


title: Custom counter when link is clicked in Wordpress

text: I would like to monitor the number of times a user clicks the hyperlink assigned with a class name link_counter. I'm using jQuery and PHP to do this, for example:                   $('.link_counter').click(function() {            <?php           //Retrieve the current count from dB              @countdata = $wpdb->get_var($wpdb->prepare( "SELECT counter FROM $mycustomtable WHERE my_user_id=%d",$user_id));              //increment counter              $updated_count=$countdata+1;              //update back the dB table              $wpdb->query($wpdb->prepare("UPDATE $mycustomtable SET counter=%d WHERE my_user_id=%d",$updated_count,$user_id));         ?>              });      It works well. However the only issue is when there are more than one link page having the same class. If I click on the another link on that the same page, the count would not be updated. How do I modify my code and my query to update this count without using AJAX and not reloading the page? Thanks.


title: WP_Query arguments: Loop through custom post type - get all entries except excluded meta_key?

text: Can't seem to find out what I'm doing wrong.               $args = array(          'post_type' => 'wr_event', // my custom post type         'posts_per_page' => -1, // show all posts          'meta_query' => array(               array(                  'key' => 'event_announced', // a custom field either "on" or "off"                  'value' => 'on',                  'compare'  => 'NOT IN'                  )         )     );     $loop = new WP_Query( $args );      So all I want to do is loop through all `wr_events` but if an event has the custom field `event_announced` (a checkbox) checked I'd like to exclude it. Ideas? I tried setting "on" or "off" for the `value` and tried different solutions for `compare`


title: Can't change theme name

text: I am developing a theme and it currently has no theme information. Right now it is pulling it's name from the theme folders name and the "Author"is anonymous. I tried changing it by adding code into the style.css as such:               /*     Theme Name: Twenty Twelve     Theme URI: http://wordpress.org/extend/themes/twentytwelve     Author: the WordPress team     Author URI: http://wordpress.org/     Description: The 2012 theme for WordPress is a fully responsive theme that looks great on any device. Features include a front page template with its own widgets, an optional display font, styling for post formats on both index and single views, and an optional no-sidebar page template. Make it yours with a custom menu, header image, and background.     Version: 1.1     License: GNU General Public License v2 or later     License URI: http://www.gnu.org/licenses/gpl-2.0.html     Tags: light, gray, white, one-column, two-columns, right-sidebar, flexible-width, custom-background, custom-header, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready     Text Domain: twentytwelve          This theme, like WordPress, is licensed under the GPL.     Use it to make something cool, have fun, and share what you've learned with others.     */      It succeeds at adding text into the author name, except it adds it all with the formatting messed up. It looks like this on my theme page:               Current Theme     Twenty TwelveTheme URI: http://wordpress.org/extend/themes/twentytwelveAuthor: the WordPress teamAuthor URI: http://wordpress.org/Description: The 2012 theme for WordPress is a fully responsive theme that looks great on any device. Features include a front page template with its own widgets, an optional display font, styling for post formats on both index and single views, and an optional no-sidebar page template. Make it yours with a custom menu, header image, and background.Version: 1.1License: GNU General Public License v2 or laterLicense URI: http://www.gnu.org/licenses/gpl-2.0.htmlTags: light, gray, white, one-column, two-columns, right-sidebar, flexible-width, custom-background, custom-header, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-readyText Domain: twentytwelveThis theme, like WordPress, is licensed under the GPL.Use it to make something cool, have fun, and share what you've learned with others.          By Anonymous Version     Customize OPTIONS: Widgets Menus Customize      So basically what it is doing is adding all of the theme information into the Author description/heading, instead of adding the info into it's own correct description/heading. Can anyone tell me why this could possibly be happening? I haven't found anything at all about this issue, and I am baffled as to why it would even happen.


title: How to take the help button and link off the dashboard

text: I want to take the help button/link off fron the top right of the dashboard. I dont want to do it with a plug in so if you could tell me where the code is located and what to take off that would be great thanks.


title: Need to redirect a non-primary Multisite URL

text: I have two sites on a Multisite installation. During development they were at the addresses new.site1.com and new.site2.com. Site1 was the primary. I had a subdomain install as indicated in wp-config. I have succeeded in launching the primary site, whose URL is now www.site1.com. The second one I have changed all references in the Database and the Network Mapping area to www.site2.com, but I can't reach the site at that address now. There are now no references to the old URL in the database or anywhere in the admin. Is there anything else I should do?


title: How to control contextual help section by code?

text: I had added some content to contextual help section for plugin options page. Now I'd like that page defaulted/toggled to contextual help section open on specific condition in my PHP code. My only issue is that I am not strong with JS and don't see clear approach to coding that (I know how to pass variable to JS through localize, but not what code will actually get it done). I had found relevant JS functions in source, but not sure how to properly reuse them for my task.


title: Formatting error with source code on WordPress.com?

text: I've been trying to post some Java code to my blog, but it seems like it has some problems with the formatting. First, whenever I copy/paste code into the editor, it's pasted as pre- formatted, which means that it converts the indents to spaces, all on a single line. And when I try to separate the lines by making each line of code on a single physical line, it doesn't indent them automatically. I'm using the visual editor, and I've checked the HTML code, and nothing seems to be wrong with it. What am I doing wrong? Or is this a bug I should report to WordPress?


title: Custom functions for string data calculations

text: Just a quick question. I have a form that calculates values based on user entry. The information is then passed via ajax to a php file for calculation returning the results. The problem is that that PHP file needs to reference the header as it needs to use the get_posts function to receive the string and collapse it into an array. Problem is that that bulks up the file massively and courses functions to execute in the header that we do not want as then the whole damn header arses up the ajax load and we get a blank screen. So is there a way or a place to put this file whereby it can get_posts without having the bulky header load as well. Bit of code here if you are interested.                  <?php     if (is_page('main-functions')) {          $str = dataSting;     (explode(",",$str));          $totalprice_posts = get_posts('post_type=services&numberposts=-1');     $totalprice_array = array();     foreach ($totalprice_posts as $post) {         $productprice = $_POST['price'.$post->ID];         $productprice = $_POST['quant'.$post->ID];         $totalproductprice = ($productprice * $productquantity);         array_push($totalprice_array, $totalproductprice);     }     implode(',', $totalprice_array);     $totalprice = array_sum($totalprice_array);      echo $totalprice;               ;}           ?>      Any ideas, Marvellous.


title: Image still attached to post even after removing it as featured image

text: I'm sorry if this is too noob of a question, but when I upload an image and set it as the featured image then later remove it (as featured image), the media list still shows it's "Attached to" the post I removed it as featured image from. Any clue? More importantly, how do I then make it so that when I remove the featured image, it will be "Unattached"? Any hook I can attach to or the like? Thanks so much.


title: Pagination broke after updateto Wordpress 3.4

text: > **Possible Duplicate:**   >  Custom Post Type Pagination Doesn't Work in Wordpress 3.4 I updated to wordpress 3.4 and after so my pagination broke showing not found on page/2 etc. I am using custom post types and custom query such as:               <?php       $type = 'products';       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $args=array(         'post_type' => $type,         'post_status' => 'publish',         'paged' => $paged,             'caller_get_posts'=> 1       );       $temp = $wp_query;       $wp_query = null;       $wp_query = new WP_Query();       $wp_query->query($args);     ?>      is there any possible fix for that? thank you.


title: wp-signup.php redirected to register.php

text: I have worpdress 3.4 multisite subdirectory set-up. (eg: example.com\username) I also have a buddypress installation installed as a secondary blog.(eg: example.com/community) http://codex.buddypress.org/getting-started/install- buddypress-on-a-secondary-blog/ All settings found in the above apply to my installaiton of Buddypress. Now, I would like users to register to example.com using example.com/wp-signup.php page so that they can create a new site and a new account. Unfortunately this is not possible as users are re-directed to example.com/community/register If I disbale buddypress though then users can create a site + account using example.com/wp-signup.php page. (eg: example.com/username) What setting should I apply for the above to be true considering that buddypress is intalled as a second blog?


title: Too many actions/filters!

text: New to wordpress here. The concept of actions/filters in and of itself is not too difficult to grasp. What I am overwhelmed by is the HUGE amount of actions and filters available. When I am looking at tutorials/guides, they say "simply add this function to the wp_head action or after_setup_theme". Without these tutorials, how on earth would i know to hook that function to that action? As a beginner, how the heck would i know what is the appropriate action to hook on to? Any advice on how to navigate this? Thanks


title: Category menu item and its last 10 posts as sub-menu

text: i have some posts categories as element of a main navigation menu, and i'd like to display the ten lasts posts of this category as sub menu. ex: Category1 Lastpost1 Lastpost2 The main menu is build in the admin panel, and i'm wondering if there is a hook or something to achieve that automatically. I know how to hardcode that, but i'd like to keep using the cool menu edition from admin panel. any ideas?


title: WordPress dashboard, viewing CPT results in 504

text: I created a custom post type with a custom taxonomy. I have about 1500 posts all of which are assigned to some sort of taxonomy term...some being assigned to 200+ terms. I noticed that from the dashboard, it takes an extremely long amount of time to view the custom post types, most of the time resulting in a 504 Gateway Time-Out. Querying these post from the front-end is just fine and I have no issues with that. It's my understanding that when the dashboard is trying to view these custom post types, it's trying to pull all the information assigned to each post, before it shows everything. I do have this WP install set to be able to use as much memory as needed (memory_limit = -1), as I was researching, some said it may be memory related. Is there something i can do to increase the performance of this query ...maybe not load all the taxonomy term relationships of a post until you're editing the post? **Errors after increasing`WP_MEMORY_LIMIT` from 1Gb to 2Gb:**               WordPress database error: [MySQL client ran out of memory]     SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('locations') AND tr.object_id IN          WordPress database error: [Lost connection to MySQL server during query]     SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN          WordPress database error: [MySQL server has gone away]     SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month FROM wp_posts WHERE post_type = 'services' ORDER BY post_date DESC


title: How to skip woocommerce PayPal redirection?

text: I use WooCommerce plugin for my shop. I want to skip the PayPal redirection on the "Thank You" page, where users are redirect to PayPal site. I'd like to add to every order also the shipping prices which are different for every product due to product weight and courier distance. I can invoice the customer later with the updated price so they can proceed with payment via PayPal after that. Thank you.


title: Load external javascript files

text: I have some trouble with loading external javascript files inside my WordPress theme. Use the following markup:               <script src="<?php bloginfo('template_directory'); ?>/js/jquery-1.8.1.min.js" type="text/javascript"></script>     <script src="<?php bloginfo('template_directory'); ?>/js/custom.js" type="text/javascript"></script>      The above code is set inside the `<head>` of my `header.php` file of my WordPress theme. Why is this not working? Or should I also use the following for link external scripts?               function my_scripts() {         wp_enqueue_script( 'my-sweet-script', get_bloginfo('template_directory') . '/script.js', array('jquery') );     }      Thank you. Casper


title: Custom /page/2/ template (different from index.php)

text: I'm trying to create a custom page 2 template that's different from the main index.php. For example, the main index page would display the latest news + a lot of features like a magazine. When readers click to read on to page 2, 3, 4 etc of the news posts, they are taken to a more regular news page. Kinda like something on theverge.com (at the bottom, click "next page" and see what I mean). Anyone have any ideas on how to do this? I know it's possible to create archive pages for categories and tags, but I'm not sure how to do it for the index.php. Thanks!


title: add img class to native wordpress galleries

text: Trying to add an img class = "the image alt field" to the images in a native wordpress gallery so i can use jquery isotope to filter the gallery. I could use the image alt field or the description field to give the image a simple class of "apple" or "orange" or "apple tasty". This should probably be done using tags somehow but surprising that is not a feature of wordpress.               add_filter('wp_get_attachment_link', 'galleryWIthClass');          function galleryWithClass($src) {          global $post;     $alt= get_post_meta($id, '_wp_attachment_image_alt', true);          echo str_replace('<img', '<img class="'. $alt.'" ', $src);          }             This code results in : img class = "". I need to set $id = "something" in order to return some sort of value. I feel im approaching this wrong. Any advice?


title: Can I use core's "or Link to Existing Content" feature in my plugin?

text: When adding a link in the TinyMCE editor, you get a nice search with ajax function that searches your existing content and lets you select from it. Is it possible/reasonable to re-use this in a plugin? If so, how would I go about doing it? (I'm working on a Related Posts functionality, and while I can easily list ALL posts in the list, it seems it would get out of hand quickly without the ability to search/filter.)


title: Implementing "Random" to custom-background

text: I have a client site that requires a random background image. I figured that `custom-background` would have something similar to `custom-header` for randomizing which image is selected, but alas it does not seem to be the case. Does anyone have experience doing this, or know what direction would be best to extend `custom-background`? Or would the better approach be to ignore `custom-background` and create my own background theme support (I severely frown upon this method, but 'the easy route' is always there).


title: Custom password reset using AJAX

text: I used this (great) tuturial 'WordPress AJAX Login Without a Plugin – The Right Way' to make a custom login form and everything works fine. But I could need some help building the same functionality for the lost password form. The (perfectly working) login code uses these lines:                   $user_signon = wp_signon( $info, false );     if ( is_wp_error($user_signon) ){         echo json_encode(array('loggedin'=>false, 'message'=>__('Wrong username...')));     } else {         echo json_encode(array('loggedin'=>true, 'message'=>__('Login successful')));     }      For my password page I need to replace this with a WP function that checks the user input (email or username) and sends an e-mail. The function I need is retrieve_password, but I don't know how to call that function and how to pass the user input.


title: Wordpress 3.1.2 Bug: add_theme_support() and video post format registering twice

text: Ive been experiencing a problem with the new WordPress 3.1.2 update. When i use `add_theme_support();` and register an array of post formats, it registers all of them fine, but when it comes to the video post format, it registers it twice, and gets called **post-format-video-2**. This is the way im writing out the code:               add_theme_support( 'post-formats', array( 'aside', 'gallery', 'image', 'link', 'video' ));      Ive tested this out both on my theme, and the twentyten theme. The problem is exclusive to the video post-format. Its really strange. Additionally when you declare a "posts" format as "video" upon publishing or updating, the post- format meta box adds a new radio button with a new post format without a slug/name. Illustration (where numbers are the radio buttons):   1. Aside   2. Gallery   3. Image   4. Link   5. Video   6.  Despite only showing 5 radio buttons, upon updating/publishing, a new radio button appears, and it gets selected (radio button 6) rather than the one I chose (radio button 5). Ive used the `add_action( 'after_setup_theme', 'foobar' );` on my theme with no luck. Of-course this comes standard with twentyten. Any ideas?


title: Static home page with "Blog" inside?

text: I'd like to have a static home page and also have a link called "Blog" that lists posts in the "blog" category in chronological order. Would the best way to do this just be to place code in archive.php and do a "switch case" on the category and do a loop on the posts? Just looking for some options before I decide on a strategy and code the solution.


title: WP_Query by date not working?

text: I'm using a function that returns posts using shortcode. My 'featured posts' are to be any category with the highest comments and only for the week. I have looked over the documents and even did a vardump and the variables are passing through, not sure why its getting old posts anyway. Please look at the var_dump() of the query here: http://pastebin.com/i51RRgTp The function I made is here: http://pastebin.com/821UDrsf I apologize that the tabbing did not paste properly into pastebin. The page that uses shortcode output is here:               [preview_posts title="Featured" weekly="true" orderby="comment_count"]     [inline-post id="5603" class="alert col-md-8 col-md-offset-2" anchor="contest-spotlight"]     [preview_posts title="New" orderby="date"]     [inline-ad]     [preview_posts title="Latest Questions" cat="104"]     [preview_posts title="Blast from the Past!" cat="84"]     [inline-ad]     [preview_posts title="New Installs" cat="87"]     [preview_posts title="Helpful Guides & Diagrams" cat="82"]     [inline-ad]     [preview_posts title="Memes"  cat="81"]     [preview_posts title="Videos" cat="99"]      The result of the page is here: www.hvac-hacks.com


title: Multiple orderby values in WP_Query

text: I'm trying to come up with a query to sort by multiple orderby values. Here's what I have so far:                   $dept_id=2;         $query=new WP_Query(array(                 'post_type'=>'wpcontactus',                 'nopaging'=>true,                 'post_status'=>array('publish', 'pending', 'future'),                 'meta_key'=>'wcu_dept',                 'meta_value'=>$dept_id,                 'orderby'=>'title',                 'order'=>'ASC'         ));      I'm trying to query a custom post type, and within that post type, query a meta value. Then, I'd like to first sort by `menu_order` ascending, then by a custom meta value `wcu_lastname` ascending. However, the orderby value didn't seem to be able to take an array. How can I order the query using multiple orderby values?


title: How to insert custom code into wp_nav_menu structure?

text:
I was able to use `<?php wp_nav_menu( array( 'theme_location' => 'primary- menu', 'container' => false ) ); ?>` to create the menu within my theme. Messed around with 'items_wrap' but couldn't get it to display correctly. I need to add an image and container div into the sub menu ul before the li's. This is the structure I want:

Page
                 <img src="<?php bloginfo('template_directory'); ?>/images/nav_ul_tab.png" class="nav_ul_tab" />

Sub Page

Sub Page

Sub Page


title: How do I get WooCommerce to recreate the home page?

text: I was hoping the answer to the question (How do I get WooCommerce to automatically recreate pages?) would help but i could not recreate the home page. Im using mystile theme and when i go to customize i cant find the home page to set it as the front page.How can i recover the built in home page ?


title: Get active term on single (CPT) page

text: I know similar questions have been asked here but I feel my case is slightly different. I need to get the _active_ _current_ term (object) on a CPT single page. However, the single post can have multiple categories. This means _I can't just get all the post terms_ and array pop the first index (because this is not always the currently active term). Say for example I have an url like: mysite.com/my-cpt/my-custom-term/my-cpt- post Now on the my-cpt-post template I need to get the "my-custom-term" object. Thanx for the help.


title: How to display term description in empty terms archive?

text: I list all terms from a taxonomy, even the empty ones, but I found out that at least in 2010/2011 themes I got a 404-like message, the default seems to only display the term description when at least one post is using it # Filters seems the best thing but I can't find the right one. Thanks for any idea.


title: JQuery undefined and Stylesheet loads in bottom along with js files

text: I'm developing a theme for wordpress and I'm using this function to enqueue scripts and styles               function Joy_scripts() {          wp_enqueue_style( 'Joy-style');          wp_enqueue_script( 'Joy-scripts', get_template_directory_uri() . '/js/scripts.js', array( 'jquery' ), '1.0', true );          if ( is_singular() && wp_attachment_is_image() ) {     wp_enqueue_script( 'Joy-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );     }          if ( in_category('12') ) {     wp_enqueue_script( 'Joy-jquizzy-engine', get_template_directory_uri(). '/js/jquery.jquizzy.js', array( 'jquery'), '1.7' );     wp_enqueue_script( 'Joy-jquizzy-init', get_template_directory_uri(). '/js/init.js', array( 'jquery'), '1.7' );     wp_enqueue_script( 'Joy-jquizzy-script', get_template_directory_uri(). '/js/jquizzy-script.js', array( 'jquery'), '1.7' );      }     }     add_action( 'wp_enqueue_scripts', 'Joy_scripts');      This is the html output:               </footer>     </div><!-- #page -->          <script type='text/javascript' src='http://localhost:8888/theme/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>     <script type='text/javascript' src='http://localhost:8888/theme/wp-content/plugins/mailchimp-widget/js/mailchimp-widget-min.js?ver=3.5.2'></script>     <script type='text/javascript' src='http://localhost:8888/theme/wp-content/plugins/media-element-html5-video-and-audio-player/mediaelement/mediaelement-and-player.min.js?ver=2.1.3'>    </script>          <!-- some other scripts loaded here they're not important for this question purposes-->          <link rel='stylesheet' id='Joy-style-css'  href='http://localhost:8888/theme/wp-content/themes/Joy/style.css?ver=1.0' type='text/css' media='all' />      As you can see the theme stylesheet is loaded AFTER the scripts, and at the BOTTOM of the document. This is causing FOUC (I have added the stylesheet at the top using `<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="all" />` and the FOUC dissappeared) Also in the Chrome console I'm getting: `Uncaught ReferenceError: jQuery is not defined localhost/:111 Uncaught TypeError: Property '$' of object [object Object] is not a function` jQuery is loading properly and before the other scripts, so, I really did not understand what is happening here, am I doing something wrong? My theme is based in on Underscores Thanks for your help.


title: How do I get is_single() to return true when called internally from the_content()?

text:
I have a custom page, _e.g._ `blog.php?post=42` that shows a GET-specified post like so:               <?php require('wordpress/wp-blog-header.php'); ?>                    <?php         global $post;         $post = get_post($_GET['post']);         setup_postdata( $post );     ?>

<?php the_title(); ?>

<?php the_content(); ?>
         <?php             global $withcomments;             $withcomments = 1;             comments_template();         ?>
                I have Jetpack sharing buttons enabled, however the buttons don't appear in `the_content()` as they should. I'm new to WordPress development, so my guess is that I'm doing something fundamentally or obviously wrong above. ## Details From my own debugging, it appears that `the_content()` leads to some Jetpack code in `sharing-service.php` where `is_singular()` is called to decide whether the sharing buttons should show, _i.e._               $sharer = new Sharing_Service();     $global = $sharer->get_global_options();          $show = false;     if ( !is_feed() ) {         if ( is_singular() && in_array( get_post_type(), $global['show'] ) ) {             $show = true;         } elseif ( in_array( 'index', $global['show'] ) && ( is_home() || is_archive() || is_search() || in_array( get_post_type(), $global['show'] ) ) ) {             $show = true;         }     }          // Pass through a filter for final say so     $show = apply_filters( 'sharing_show', $show, $post );      I'd like my post to be "detected" as `is_single()` and therefore `is_singular()` and route execution to the first branch, reprinted from above:                   if ( is_singular() && in_array( get_post_type(), $global['show'] ) ) {             $show = true;         } ...      I don't know what the second condition means, but I verified that it returns `true`. I also verified by hardcoding `$show` to `true` in the last line as such,               $show = apply_filters( 'sharing_show', true, $post );      that indeed this causes the sharing buttons to appear. How can I get a `get_post()`'ed object to be set up such that `is_single()` returns true? Or, am I simply doing things a way they should not be done?


title: Wordpress Wp_nav_menu How to create Columns in submenu

text:
i have been trying to develop custom navigation in wordpress. i want to add columns in sub menu item. i want to add images in navigation as well as create Multi column Navigation. Please check this attached screenshot. i tried to develop using custom walker method. Need Help to create multi column menu here is my code: **Navigation code:**                     <?php wp_nav_menu( array( 'theme_location' => 'primary','container_class' => 'navbar-collapse collapse in','container_id' => 'defaultmenu', 'menu_class' => 'nav navbar-nav','depth' => 10,'walker' => new themeslug_walker_nav_menu ) ); ?>      **custom walker function in Function.php file:**                class themeslug_walker_nav_menu extends Walker_Nav_Menu {           // add classes to ul sub-menus       function start_lvl( &$output, $depth = 0, $args = array() ) {        // depth dependent classes         $indent = ( $depth > 0  ? str_repeat( "\t", $depth ) : '' ); // code indent        $display_depth = ( $depth + 1); // because it counts the first submenu as 0             $classes = array(         'sub-menu',         ( $display_depth % 2  ? 'menu-odd' : 'menu-even' ),         ( $display_depth >=2 ? 'sub-sub-menu' : '' ),         'menu-depth-' . $display_depth         );       $class_names = implode( ' ', $classes );             // build html        $output .= "\n" . $indent . '
' . "\n";       }               // add main/sub classes to li's and links         function start_el(  &$output, $item, $depth = 0, $args = array(), $id = 0 ) {        global $wp_query;       $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent             // depth dependent classes         $depth_classes = array(         ( $depth == 0 ? 'main-menu-item' : 'sub-menu-item' ),         ( $depth >=2 ? 'sub-sub-menu-item' : '' ),         ( $depth % 2 ? 'menu-item-odd' : 'menu-item-even' ),         'menu-item-depth-' . $depth         );         $depth_class_names = esc_attr( implode( ' ', $depth_classes ) );              // passed classes         $classes = empty( $item->classes ) ? array() : (array) $item->classes;        $class_names = esc_attr( implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ) );           // build html       //print_r( $depth_class_names);                 $output .= $indent . '
ID . '" class="' . $depth_class_names . ' ' . $class_names . '">';                  // link attributes        $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';              $attributes .= ' class="menu-link ' . ( $depth > 0 ? 'sub-menu-link' : 'main-menu-link' ) . '"';               $item_output = sprintf( '%1$s%3$s%4$s%5$s%6$s',         $args->before,         $attributes,         $args->link_before,         apply_filters( 'the_title', $item->title, $item->ID ),         $args->link_after,         $args->after        );            // build html           $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );          }         }      ![enter image description here](http://i.stack.imgur.com/5qCTP.png)


title: How much resources are good enough for 3.9.2

text: I have the following specification:   * memory_limit(maximal 128 MB),   * max_execution_time(max 60 sec)    * same PHP-Prozesse(max 10) Is this good enough for wordpress? I am having a small site with around 100 visits a day, so nothing really large. Do you think I could host 2 other wordpress installations on the server? I appreciate your answer!


title: Align text left of image in this php script?

text:
Ok so i am using this code, which allows me to upload photo's to a post and instead of inserting them myself, it calls all the photos attached to the post. Thus for placing all the photos in the post by itself. But what i did was made this page int a gallery where i use a jquery jcarousel where they can click the arrows to go to the next photo. here is the code                <?php          if ( 'photos' == get_post_type() ) { //condition to show gallery on post type - photos          if ( $attachments = get_children( array(         'post_type' => 'attachment',         'post_mime_type'=>'image',   //return all image attachment only         'numberposts' => -1,   //get all the attachments         'post_parent' => $post->ID     )));          foreach ($attachments as $attachment) {         // you can customize the oputput         echo '
';         echo wp_get_attachment_link( $attachment->ID, 'full' , false, false, '' );         echo ''.$attachment->post_excerpt.'';         echo '
';     }     }          ?>      But how do i get the post_excert part of the code which is the caption, to align left of the image, what do i add to the code and where, or is this something i do in css.


title: Stale $GLOBALS['post'] after custom WP_Query empty result set bothers my template, whose fault is this?

text: Story below looks to me like it's about a commercial Event Management plugin whose authors to me just don't seem very good at WordPress. But bear with me and let's see if there's also an issue in WP. This is on 3.5.2. Chain of events I'm looking into:   * custom taxonomy query is made in browser   * `$wp_the_query` gets all results (1 post total), WordPress sets `$GLOBALS['post']` to this post   * in "wp" action, commercial plugin builds new WP_Query (meta query, resulting in a correct EMPTY RESULT SET), then replaces global `$wp_query` with this empty result by bluntly doing `$wp_query = $this->_wp_query;`   * but nobody touches `$GLOBALS['post']`, so all subsequent `get_post()` calls see `$wp_query->post` not being there, fall back on `$GLOBALS['post']` and cause incorrect results (`post_class()` and friends, who think they have an `<article>` element to work with) If I manually hook into "wp" action after commercial plugin has finished its' query and do `$GLOBALS['post'] = null`, template will correctly reflect reality.   * we have even more fun when for example Yoast's SEO plugin does `wp_reset_query()` for its own magic in "wp_head" action, which will resurrect global `$post` variable from `$wp_the_query` after I've nulled it earlier in "wp" So this is some sort of an issue with empty result set custom queries. I have not see any guidelines so far to care for resetting global `$post` variable like this. While the plugin is just badly built, should there be something for this addressed in core?


title: Custom frontend post not working?

text:
Hi I am creating a custom post front end submission. This is my code to submit the custom post details. Here the validation is not working as well as it will not submit the post. When i submit the post it will display the **no post found** page. Can any one suggest me what is wrong.               <?php function as_front_end() { ?>         <form id="custom-post-type" name="custom-post-type" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">              Post Title
              <input type="text" id="title" value="" tabindex="1" size="20" name="title" />         Post Description
         <?php  wp_editor( $value_to_return, 'textareaname', array( 'textareaname' => 'textareaname', 'teeny' => true ) ); ?>                       <?php echo wp_dropdown_categories('show_option_none=Select Category&show_count=0&orderby=name&echo=0&selected=6&hierarchical=1/True&show_option_all='); ?>
         <input type="submit" value="Publish" tabindex="6" id="submit" name="submit" />
         <input type="hidden" name="post-type" id="post-type" value="custom_posts" />         <input type="hidden" name="action" value="custom_posts" />         <?php wp_nonce_field( 'as_front_end','custom-post-type' ); ?>              </form>         <?php              if($_POST){             ty_save_post_data();         }         }          function ty_save_post_data() {              if ( empty($_POST) || !wp_verify_nonce($_POST['as_front_end'],'custom-post-type') ){             print 'Sorry, your nonce did not verify.';             exit;              }else{                  if (isset ($_POST['title'])) {                 $title =  $_POST['title'];             } else {                 echo 'Please enter a title';                 exit;             }             if (isset ($_POST['description'])) {                 $description = $_POST['description'];             } else {                 echo 'Please enter the content';                 exit;             }                  if(isset($_POST['post_tags'])){                 $tags = $_POST['post_tags'];             }else{                 $tags = "";             }                  $post = array(                 'post_title' => wp_strip_all_tags( $title ),                 'post_content' => $description,                 'post_category' => $_POST['cat'],                    'tags_input' => $tags,                 'post_status' => 'pending',                              'post_type' => $_POST['post-type']                );             wp_insert_post($post);                    $location = home_url();                    echo "<meta http-equiv='refresh' content='0;url=$location' />";              exit;         }            }            add_shortcode('custom-post','as_front_end');


title: Auto approve all comments (editor)

text: I **unchecked** both options in the `discussion` area _(so the one where they need a post to comment and administrator has to approve)_ , but still, my users can't put their comments without me approving it. Has someone a solution for this glitch? Why on earth can't they post a comment? And if they post one, the second one needs to be approved?


title: Similar to wp_editor but for the post title input field

text: What is the function that I can use to render the post title input field? I know wp_editor does that for the editor. I need to move the custom post title field (the default title that comes with the default post) inside a meta box I created. I can unset the default title and then re add it inside the custom meta box. Something similar to http://wordpress.org/support/topic/move-custom-meta-box- above-editor In the link above they did it for the editor. Thanks.


title: URLs getting appended with strange number string, resulting into 404s

text: > **Possible Duplicate:**   >  Massive 404 issue reported by Google Webmaster Tools on a WordPress Site I've been dealing with large number of 404 errors reported in the Google Webmaster Tools. I found that out of the 1000 "404" URLs reported in GWT majority of the reported 404s are regular URLs with a strange number string attached. Here are few sample URLs - http://www.domain.com/correct-url-ends-here **/1345601488000/1345993967000** http://www.domain.com/another-correct-url-ends-here **/1346198904000/1346893566000** The bolded number string is appended and GWT even reports several versions of each URL (each with its own number string). My doubts: 1. Is it because of the 'disqus' comments system? Or something else? I've switched over to the LiveFyre system for the time being. I can disable it totally, if required. 2\. What's the proper way to fix this?


title: Merge / Combine two php functions for Previous and Next Link with Thumbnail

text:
I will wrap two merged php funtions in one div container - so i have only one php function and one link to the next post, regardless if someone clicks on the thumb or the text part. These are the two functions i use:               <?php previous_post_link( '%link', 'Previous Post
%title' ); ?>      and:               <?php $prevPost = get_previous_post(true); $prevThumbnail = get_the_post_thumbnail($prevPost->ID, 'thumbnail' ); echo $nextthumbnail; ?><?php previous_post_link( '%link', $prevThumbnail ); ?>      How can i merge the above two codes to one?


title: Add simple Nivo Slider to wordpress site

text: I have a wordpress website, on the front page i have an area below the main menu which takes a post and displays it along with an image, what i would like to do is swap this box for the nivo slider.               http://79.170.40.241/shaddersafrica.com/      The problem is, this area of the website isn't controlled through the admin area and although i have the simple-nivo-slider plugin installed, i don't know if it is possible to place it in place of the current post area and if so how i would do that. Thanks Lee


title: Combining two meta_values within one row with query

text: I've added two new meta_keys to the `wp_usermeta` table: `bid_user_lat` and `bid_user_lng` And I need to be able to get both of these values within a single row, along with the `user_id`. `ROW - (user_id) 220 | (bid_user_lat) 45.099080 | (bid_user_lng) -140.09099` Now comes the tricky part ... I then need to use these values within a calculated radius statement: `( 3959 * acos( cos( radians( @lat ) ) * cos( radians( **bid_user_lat.meta_value** ) ) * cos( radians( **bid_user_lng.meta_value** ) - radians( @lng ) ) + sin( radians( @lat ) ) * sin( radians( **bid_user_lat.meta_value** ) ) ) ) AS distance` In the end, I'm making sure that the user is within a certain radius, and if so, I will return it within the query. **But the most important part is being able to query the`wp_usermeta` the way I need to!**


title: Generate Wordpress salt

text: I am in need of a function that automatically generates and returns salts for Wordpress wp-config.php (Don't link me to their API, I'm looking for offline solution). Does Wordpress core has this function defined somewhere? If it doesn't, can these salts be generated randomly or are there any specific rules for creating them? Edit: **This is what I ended up with:**                   $keys = array('AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY',                   'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT');         $salts = '';         foreach ($keys as $key) {             $salt = wp_generate_password(64, true, true);             $spaces = str_repeat(' ',16 - strlen($key));             $salts .= "define('{$key}',{$spaces}'{$salt}');\n";         }      And the output is string:               define('AUTH_KEY',        'f@5^8(OyZLS%+~LNQ6,w(Zpn`3X#A}o4t2LQuqc=x4vn+ b}xYM>TlSwB`|E;}PA');     define('SECURE_AUTH_KEY', 'vEEF@-c_`VO!d{s)_Nv^uS,)eg9{;60.$nU370/9E1z}O#iu)wkPrw8sh[TqGdC;');     define('LOGGED_IN_KEY',   '9:z95.y<_LhUnGlH>6%)/-szx8Dwj{z`#mz-C%taXoD:KK86k(?K-f{w]U5w(41v');     define('NONCE_KEY',       '?YP2djRHOn7[4n[p(KwmX#u.#^s3Fel%AKu@Ac,(L$1DM^@6NNk@x&B/w2/<an:@');     define('AUTH_SALT',       '$r>m{8@l?xDv<^uNz^.|<Am2}J3q(OMAS<dLB({66M)zy2ufOP8$x*{:US|7PL4x');     define('SECURE_AUTH_SALT','Nn4uU#rIe}7CaXw=Z?pk82Cqo8{ALC6McPHYq_G{><]_YWhHlEuk?`tJ6G[)D$)A');     define('LOGGED_IN_SALT',  'YLiGuP$DPKP-F3UGw(0#E0L1w;HO0L_Hkt6.(*92t*B6Mclq*`{OO[xM$3)]^9yi');     define('NONCE_SALT',      '{hh3bpLu$b:e8-uXiCx(3FaK3Q4[`/Mji}~<.cz8W#_a0[O!{h;Fm{^c]p>./RF{');


title: How can I alter the [gallery] markup?

text:
I would like to change the markup created by [gallery] from what is it as standard (dl) to a unordered-list with a difference. Below is the desired markup:

       I want the main image source for the link & img, as I want to run the img src through a php cropper script. Is this possible? I'm sure we can crack it!


title: What does wp-list.js do?

text: Pretty straightforward question! What does wp-list.js do? It's listed in the wp_enqueue_script codex page as one of the WP included javascript libraries. Thanks!


title: MultiPostThumbnails for Custom Post Type

text: I have spent time and figured out how to add Multiple Thumbnails to a custom post type in the wordpress admin for the custom post type, code and question below:                   if (class_exists('MultiPostThumbnails')) { // imports to post_type pages                 new MultiPostThumbnails(array('label' => '2nd Feature Image', 'id' => 'feature-image-2', 'post_type' => 'page', 'post_type' => 'landing_pages')); /* 'post_type' => 'landing_pages' adds support for landing pages CPT */                 new MultiPostThumbnails(array('label' => '3rd Feature Image', 'id' => 'feature-image-3', 'post_type' => 'page', 'post_type' => 'landing_pages'));                 new MultiPostThumbnails(array('label' => '4th Feature Image', 'id' => 'feature-image-4', 'post_type' => 'page', 'post_type' => 'landing_pages'));                 new MultiPostThumbnails(array('label' => '5th Feature Image', 'id' => 'feature-image-5', 'post_type' => 'page', 'post_type' => 'landing_pages'));         };      _*_ Does anyone know if there is a way to write an array or condense the code below so you dont have to list the post type twice:                   new MultiPostThumbnails(array('label' => '2nd Feature Image', 'id' => 'feature-image-2', 'post_type' => 'page', 'post_type' => 'landing_pages'));      Thanks.


title: Retina for Wordpress Posts

text: I was checking one of the answers here, and it says: > Just create the copies of images with double size using wordpress native > media settings. And then add the following code in your templates.               <?php $normal = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail');     $retina = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' ); ?>          <img src="<?php echo $normal[0]; ?>" data-at2x="<?php echo $retina[0]; ?> alt="<?php the_title(); ?>" width="xxx" height="xxx"/>      > Here my thumbnail (normal) size is 300x300px and medium thumbnail (retina) > has 600x600px size. And also don't forget to load retina.js otherwise data- > at2x= will not work. Good luck!" \-- I'm using the Genesis Framework, and I'm wondering where you'd suggest adding the above code


title: Dynamic Sidebars On Multiple Subpages

text: I am building a site in WordPress. It has multiple subpages, many of which require different sidebars. So, I have a widgetized theme and I have also created a few sidebar widgets. I have written a conditional statement to show different sidebars on different pages. However, one widgetized sidebar displays on almost all pages despite the conditional statement. The sidebar that is appearing on the desired page can be seen here: http://www.africanhealthleadership.org/about/approach/ The subpage that should have a different sidebar is under Knowledge Resources>Research The code is as follows. I am a total PHP spazz, so I likely did something silly. I have tried single quotes around dynamic_sidebar(2) but that did not work. Thank you for any help.               <?php           if ( is_subpage('approach') ) {          if (!function_exists ( dynamic_sidebar(1) ) ) ;      }         elseif ( is_subpage('research')) {         if (!function_exists( dynamic_sidebar(2)) || !dynamic_sidebar( "Sidebar2") );         }     ?>


title: What are these variables and where are they documented?

text: This is in the twentyeleven theme. Can somebody tell me what this is?               Posted in %2$s', 'twentyeleven' )                  ^^^^                   ^^^^      My best googling tells me it's something to do with i18n, but I don't think that's the full story because some of them spit out things like author names and post titles, like this example:               %7$s                               ^^^^         ^^^^               ^^^^      At any rate, is this something I can/should be using? What's it actually called, and where is it documented? Sorry if this is a dumb question, but it's a hard thing to google! Thanks!


title: How to add filter in "Comments" at the admin panel?

text: I found so many information and most of the tutorials only talk about adding filter in post/custom post only. I want to do something similar to this tutorial in 'Comments' area in admin panel. Add filter menu to admin list of posts (of custom type) to filter posts by custom field values However, I'm not sure if the parse_query handle also handle the query in this area? Anyone might have suggestion on tutorial, plugin that might help?


title: How do I override the default number of items to be listed on an archive.php page?

text: > **Possible Duplicate:**   >  How To Modify The Loop in archives.php To Have 11 Posts Per Page and CSS > Styling I am using the following code on my archive.php template to list a few fields from a custom post type. It's an album review post type and this code pulls in the artist name, the album name and the album cover. Is there any way to alter this code to tell wordpress to display a certain number of results? The issue I have is that for all other archive pages the default (set to 10) is fine, but because I am only displaying a thumbnail and a name on the archive for reviews there's a lot of room to add more in.


title: Activate / Deactivate plugin

text: I'm working on my first plugin and am trying to use `register_activation_hook()` and `register_deactivation_hook()` ... I know I'm not doing this right:               /*====================================================*/     //  1.0 Actions to perform upon plugin activation     /*====================================================*/     register_activation_hook( __FILE__, 'construct_uploader_page' );     register_activation_hook( __FILE__, 'construct_terms_page' );     register_activation_hook( __FILE__, 'create_custom_user_role' );          // Construct Event Photo Uploader template page     function construct_uploader_page() {              $post_id = -1;              // Setup custom vars         $author_id = 1;         $slug = 'event-photo-uploader';         $title = 'Event Photo Uploader';              // Check if page exists... if not, create it             if ( null == get_page_by_title( $title )) {                  $uploader_page = array(                 'comment_status'    => 'closed',                 'ping_status'       => 'closed',                 'post_author'       => $author_id,                 'post_name'         => $slug,                 'post_title'        => $title,                 'post_status'       => 'publish',                 'post_type'         => 'page'             );                  $post_id = wp_insert_post( $uploader_page );                  if ( !$post_id ) {                 wp_die( 'Error creating template page' );                  } else {                 update_post_meta( $post_id, '_wp_page_template', 'custom-uploadr.php' );             }         }     } // end construct uploader page          // Add Event Photo Uploader page     add_action( 'template_include', 'uploadr_redirect' );          // Callback to add menu items     function uploadr_redirect( $template ) {         $plugindir = dirname( __FILE__ );              // A Specific Custom Post Type         if ( is_page_template( 'custom-uploadr.php' )) {             $template = $plugindir . '/templates/custom-uploadr.php';         }              return $template;        }          // Construct Terms and Usage template page     function construct_terms_page() {              $post_id = -1;              // Setup variables         $author_id = 1;         $slug = 'terms-and-usage';         $title = 'Terms and Usage';              // Check if page exists... if not, create it         if ( null == get_page_by_title( $title )) {             $uploader_page = array(                 'comment_status'    => 'closed',                 'ping_status'       => 'closed',                 'post_author'       => $author_id,                 'post_name'         => $slug,                 'post_title'        => $title,                 'post_status'       => 'publish',                 'post_type'         => 'page'             );                  $post_id = wp_insert_post( $uploader_page );                  if ( !$post_id ) {                 wp_die( 'Error creating template page' );             } else {                 update_post_meta( $post_id, '_wp_page_template', 'terms-and-use.php' );             }         }     } // end construct terms page          // Add Terms and Usage page     add_action( 'template_include', 'terms_redirect' );          // Callback to add menu items     function terms_redirect( $template ) {         $plugindir = dirname( __FILE__ );              // A Specific Custom Post Type         if ( is_page( 'Terms and Usage' )) {                  $template = $plugindir . '/templates/terms-and-use.php';         }              return $template;     }          // Create custom user-role for registration     function create_custom_user_role() {              $custom_role = get_role('subscriber');         $standard_user = add_role( 'register', 'Register User', $custom_role->capabilities  );     }     // End Activation function      I need to add these three things when the plugin is activated ( two pages and a custom role ) and then deactivate them when the plugin is, well, deactivated ... I need help; from everything I've seen there is only supposed to be one `activation_hook()` and one `deactivation_hook()`, but I have more than one function I need activated/deactivated. Thanks for any help!


title: The best way to collision check in WP

text: E.g. I have a random number generated by a PHP code `$random` And I need to make a check if this number doesn't exist in any of my posts in DB in my meta field called `unique_code` What is the preffered way in WP to check if this value(random number) exist or not?


title: Loading different stylesheet on Wordpress pages?

text: I have one stylesheet linked to my Wordpress page in header section:               <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/style.css" />      Now, I want to load different stylesheets on a few pages or sub-pages. What's the best/correct way of achieving this? I'm thinking about writing my own shortcode calling "wp_enqueue_style", is that a good idea?


title: Use an array of page template slugs and $hook

text: I'm using the function below to load some javascript that removes the checkbox in the User Profile that is used to toggle the Visual Editor:               //Remove Visual Editor option in User Profile     function remove_visual_editor_admin_script( $hook ){      if ('user-edit.php' != $hook) {             return;         }         wp_enqueue_script( 'remove_visual_script', get_stylesheet_directory_uri().'/js/remove-visual-editor.js', array('jquery') );     }     add_action('admin_enqueue_scripts','remove_visual_editor_admin_script');      It loads a simple jQuery function in `remove-visual-editor.js` that removes the HTML and CSS and hides the checkbox. Problem is, the Visual Editor checkbox appears on two admin pages: one is `user-edit.php` and the other is `profile.php`; I'm calling the jQuery script on `user-edit.php` above. So I tried an array of page templates, like this               if (array('user-edit.php', 'profile.php') != $hook) {      with no luck. _How to I add the`remove-visual-editor.js` to both 'user- edit.php`and`profile.php` pages?_ Is there another way to add an array or multiple pages to the `if` line?


title: Find page IDs with specific meta tag key value pairs

text: Is there a way to find the ids of the pages who contain meta tags/custom fields with a certain key-value pair? Say, for instance, that I wanted to find all of the pages who had a meta- tag/custom-field key of "weather" with a value of "raining", is there a way to do that?


title: What is the significance of _e("Some String", 'String')?

text: I have seen this in lots of wordpress themes and using it for a while but don't know what is the significance of it. It seems it does the same work as echo something out. Look for it in codex but failed to find anything about it. May be i have looked in wrong place. So, my question is what does `_e("Some String", 'String');` means? And is it different from `echo "Some String";` ?


title: wordpress widget textbox in the sidebar

text:
I have a normal textbox widget that I am using in certain sidebars. The text widget generates a div within a ul. Is there anyway to make the widget generate another ul li instead?

Heading


title: How can I process all requests for a given directory in a URL with my plugin?

text: I'd like to pass all requests for a given directory using a plugin or template file. For instance, all of the following requests would be sent to the plugin:               mysite.com/directory/blah     mysite.com/directory/foo/bar     mysite.com/directory/another/one/here      I would then like to do some custom processing on the "blah", "foo bar", and "another one here" data, outputting resulting content. I've looked into rewrite rules, but I can't figure out if this is just used for "prettifying" URLs or if it can be used for more complex processing. **Edit:** I do not believe I need an endpoint. I don't want to add an action to some other post types. For instance, let's say /directory/ is retrieving content from another server.


I've created a custom meta box to handle certain custom post meta fields and I don't want the clutter of having these custom fields duplicated down in the "Custom Fields" area. How can I remove specific custom post meta from the "Custom Fields" fieldset?


title: Is there a way to upgrade a theme without losing custom templates?

text: I recently updated the main theme of a production site. Unfortunately, the upgrade process deleted all our custom templates. Is there any way I can prevent this happening again?


title: Automatically sorting custom post type admin area by a custom field

text: I have created a custom post type to display future events, with the event's date stored in a custom field (YYYY/MM/DD format). I'd like the admin screen for this custom post type to be automatically sorted by the event date custom field. Having tried out MikeSchnickel's excellent tutorial on creating a 'sort by' column, I think I've worked out that I need to use something similar to the parse_query filter he uses. But I can't seem to adapt it to my needs, I'm pretty new to customizing wordpress like this, so some simple guidance would be much appreciated! Here's my code to register the custom type post (gs_events), add meta box for the custom field (event_date), and set up custom columns for the admin screen....               add_action('init', 'my_custom_init');          function my_custom_init() {       $labels = array(         'name' => _x('Events', 'post type general name'),         'singular_name' => _x('Event', 'post type singular name'),         'add_new' => _x('Add New', 'event'),         'add_new_item' => __('Add New Event'),         'edit_item' => __('Edit Event'),         'new_item' => __('New Event'),         'view_item' => __('View Event'),         'search_items' => __('Search Events'),         'not_found' =>  __('No events found'),         'not_found_in_trash' => __('No events found in Trash'),          'parent_item_colon' => ''       );       $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,          'query_var' => true,         'rewrite' => array('slug' => 'events'),         'capability_type' => 'post',         'hierarchical' => false,         'menu_position' => 5,         'supports' => array('title','editor','thumbnail','comments')       );        register_post_type('gs_events',$args);     }          register_taxonomy("Location", array("gs_events"), array("hierarchical" => true, "label" => "Cities", "singular_label" => "City", "rewrite" => true));          add_action("admin_init", "admin_init");          function admin_init(){       add_meta_box("event_date-meta", "Event Date", "event_date", "gs_events", "side", "high");     }          function event_date(){       global $post;       $custom = get_post_custom($post->ID);       $event_date = $custom["event_date"][0];       ?>       <label>Date:</label>       <input name="event_date" value="<?php echo $event_date; ?>" />       <?php     }          add_action('save_post', 'save_details');          function save_details(){       global $post;       update_post_meta($post->ID, "event_date", $_POST["event_date"]);     }          add_action("manage_posts_custom_column",  "events_custom_columns");     add_filter("manage_edit-gs_events_columns", "events_edit_columns");          function events_edit_columns($columns){       $columns = array(         "cb" => "<input type=\"checkbox\" />",         "title" => "Venue",         "location" => "Location",         "event_date" => "Date",       );            return $columns;     }     function events_custom_columns($column){       global $post;            switch ($column) {         case "event_date":           $custom = get_post_custom();           echo $custom["event_date"][0];           break;         case "location":           echo get_the_term_list($post->ID, 'Location', '', ', ','');           break;       }     }      And I reckon I need to add some modification of this code from Mike Schnickels's aforementioned tutorial, but I'm not sure how to implement it in this case...               add_filter( 'parse_query', 'sort_movie_by_meta_value' );     function sort_movie_by_meta_value($query) {         global $pagenow;         if (is_admin() && $pagenow=='edit.php' &&                 isset($_GET['post_type']) && isset($_GET['post_type'])=='movie' &&                  isset($_GET['sortby'])  && $_GET['sortby'] !='None')  {             $query->query_vars['orderby'] = 'meta_value';             $query->query_vars['meta_key'] = $_GET['sortby'];         }     }