title: How to make image proportional bigger?

text:
I'm trying to make my slider images bigger but it doesn't work. I want them to be proportionally bigger and with `width:100%` they look funny. It's fine if the image get cut and doesn't show the whole image. Any suggestions to make it work? I found this in my function.php dont really know witch line so change?               // This theme uses a custom image size for featured images         add_theme_support('post-thumbnails');         add_image_size('img68', 68, 68, true);         add_image_size('img100', 100, 90, true);         add_image_size('img235', 235, 134, true);         add_image_size('img297', 297, 170, true);         add_image_size('img515', 515, 300, true);         add_image_size('img737', 737, 300, true);      And this is the only code I have for the slider :               <?php     /*     Plugin Name: TM Slider Widget (Center)     Plugin URI:     Description: This widget for display Slider in center (middle) area.     Author: Template.my.id     Version: 1.0     Author URI: Template.my.id     License: GPL2      */          // Start class name widget //          class TM_Slider_Widget extends WP_Widget {          // Constructor //              function TM_Slider_Widget() {             $widget_ops = array('classname' => 'widget_tm_slider', 'description' => __('This widget for display Slider in center (middle) area'));             $control_ops = array('width' => 410, 'height' => 360);             $this->WP_Widget('tmmyid_slider_box', __('TM Slider Widget (Center)'), $widget_ops, $control_ops);         }          // Extract Args //              function widget( $args, $instance ) {             extract($args);                  $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance );             $tmcategory = $instance['tmcategory'];             $tm_totalpost = $instance['tm_totalpost'];             $text = apply_filters( 'widget_tm_slider_home', $instance['text'], $instance );                  echo $before_widget;             if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }                  ob_start();                 eval('?>'.$text);                 $text = ob_get_contents();                 ob_end_clean();                 ?>
<?php echo $instance['filter'] ? wpautop($text) : $text; ?>
             <?php             echo $after_widget;         }              function update( $new_instance, $old_instance ) {             $instance = $old_instance;             $instance['title'] = strip_tags($new_instance['title']);             $instance['tmcategory'] = strip_tags($new_instance['tmcategory']);             $instance['tm_totalpost'] = strip_tags($new_instance['tm_totalpost']);             if ( current_user_can('unfiltered_html') )                 $instance['text'] =  $new_instance['text'];             else                 $instance['text'] = stripslashes( wp_filter_post_kses( $new_instance['text'] ) );             $instance['filter'] = isset($new_instance['filter']);             return $instance;         }              function form( $instance ) {             $defaults = array(                           'tmcategory' => __(''),                         'tm_totalpost' => __('5'),                         'text' => __('
         <?php          $recent = new WP_Query( array(  "cat" => $tmcategory,                                          "posts_per_page" => $tm_totalpost,                                          "post_type" => "post",                                       )                                );          while($recent->have_posts()) : $recent->the_post();          ?>                  <?php if (has_post_thumbnail()) { ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">             <img src="<?php $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id,"img737", true); echo $image_url[0]; ?>" alt="<?php echo get_the_title(); ?>" title="<?php echo get_the_title(); ?>">
                    <?php } else { ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">             <img src="<?php echo get_template_directory_uri(); ?>/images/nophoto515.png" alt="<?php echo get_the_title(); ?>" title="<?php echo get_the_title(); ?>">
             <?php } ?>              <?php endwhile; ?>
                                      ', 'tm_category_text'),                             );                  $instance = wp_parse_args( (array) $instance, $defaults, array( 'title' => '', 'tmcategory' => '', 'tm_totalpost' => '', 'text' => '' ) );                  $tmcategory = strip_tags($instance['tmcategory']);             $tm_totalpost = strip_tags($instance['tm_totalpost']);             $text = format_to_edit($instance['text']);     ?>
<label for="<?php echo $this->get_field_id('tmcategory'); ?>"><?php _e('Recent Slider By Category (Separated Category ID by comma):'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('tmcategory'); ?>" name="<?php echo $this->get_field_name('tmcategory'); ?>" type="text" value="<?php echo esc_attr($tmcategory); ?>" />

<label for="<?php echo $this->get_field_id('tm_totalpost'); ?>"><?php _e('Total Posts:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('tm_totalpost'); ?>" name="<?php echo $this->get_field_name('tm_totalpost'); ?>" type="text" value="<?php echo esc_attr($tm_totalpost); ?>" />

<label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('PHP Code (If you not sure, please do not edit the below code) :'); ?>             <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>          <?php         }     }          add_action('widgets_init', create_function('', 'return register_widget("TM_Slider_Widget");'));          // Portfolio link //     add_filter('plugin_row_meta', 'tmmyid_sliderbox_link', 10, 2);     function tmmyid_sliderbox_link($links, $file) {         if ($file == plugin_basename(__FILE__)) {             $portfolio_link = 'View Portfolio';             $links[] = $portfolio_link;         }         return $links;     }


title: Date archive shooting 404 when months and days are quarried

text:
I know you guys have seen hundreds if not thousands of 404 questions. I assure you I have done everything in my power. 1. updates permalinks 2. using /%post_id%/%postname%/ for structure 3. have been working on a clean 3.2 install 4. no plugins or extra functions now not all archives are broken for example this               php wp_get_archives( array( 'type' => 'monthly' ) );      works fine, the resulting url structure is for example, site.com/blog/date/2011/06/ however this is not what i am trying to get to work what does not work is this
     <?php     $months = $wpdb->get_results("SELECT DISTINCT MONTH( post_date ) AS month , YEAR( post_date ) AS year, COUNT( id ) as post_count FROM $wpdb->posts WHERE post_status = 'publish' and post_date <= now( ) GROUP BY month , year ORDER BY post_date DESC");     foreach($months as $month) : ?>
<a href="<?php bloginfo('url') ?>/<?php echo $month->year; ?>/<?php echo date("m", mktime(0, 0, 0, $month->month, 1, $month->year)) ?>"><?php echo date("F", mktime(0, 0, 0, $month->month, 1, $month->year)) ?> <?php echo $month->year ?> - <?php echo $month->post_count; if ($month->post_count> 1 ) { echo " posts"; } else { echo " post"; }?>
     <?php endforeach; ?>
      the resulting url structure is site.com/blog/2011/06/ , no _date_ , even if i add date that does not change anything, i still get 404, yes i have updated my permalinks and put it to default if that makes a difference and back and back to default and over the menu to mars as well to make things worse i get 404 on the second page of the regular               wp_get_archives( array( 'type' => 'monthly' ) );      can someone please test this out, one more thing the quarried items are custom posts types


title: How do I sort posts with multiple pages

text: I am using a drop-down to sort posts by title, meta_value, etc. However, the sorting feature only works on the first page. The second page displays the default order rather than continuing the order from page 1. I am using wp- pagenavi for pagination. Any ideas what would be causing this error? Here's a link to the code: http://pastebin.com/AwSmMPtM Thanks so much.


title: Why this code causes infinite loop?

text:
Hi all I have this template page which get the page's post and then a list of posts from the category news.               <?php     /*      * Template Name: News & Info      */          get_header();     ?>
         <?php         if (function_exists('yoast_breadcrumb')) {             yoast_breadcrumb('
', '
');         }         ?>              <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php the_title(); ?>

                     <?php the_content(); ?>
                  <?php endwhile;         endif; ?>              <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                  <?php query_posts('cat=32'); ?>

             <?php endwhile;         endif; ?>

News & Info:

             <?php wp_list_pages('hide_empty=0&child_of=26&title_li=&sort_column=menu_order'); ?>

          <?php get_footer(); ?>      The second loop gets in infinite loop and I don't know what am I doing wrong. Thanks in advance


title: When I split a large post with <!--nextpage-->, how can a search locate users to the correct page?

text: I have a large post split with `<!-- nextpage -->`. A term resides on page 50. When I search for the term, I land on page#1. **Q:** How can the system auto-forward me to page#50? Thanks


title: Unusual Custom Post 404 problem (NOT a permalink issue)

text: I seem to have exhausted all the references on this subject, but if this is a duplicate post my apologies. I am having a problem where ANY custom post page displays the 404.php file's error content, regardless of method of getting there. This includes simply going to something as rudimentary as http://domain.com/?p=123. I have done the following:   * Flushed permalink settings (though I don't think it's a permalink problem)   * Deleted .htaccess and recreated it by going to settings -> permalinks   * Specifically created a single-[name].php file for any given type   * Disabled all plugins   * Checked for any page/taxonomy name conflicts (still fails even w/ random name)   * Checked server logs for errors (none since troubleshooting began)   * Uploaded entire theme to different WP install All to no avail. I have reduced the custom post registration to as simple a function as I can conjure:               add_action('init', 'init_sample');     function init_sample() {         $args = array(             'public' => true,         );         register_post_type( 'sample' , $args );     }      But neither this nor any other combinations of arguments seem to help. Even clicking the "View Post" link in admin takes one to a 404 page. I can, however, retrieve custom posts via query with no problem. I'm running WP v3.2.1. If I had to guess, I'd say there's something elsewhere in the theme fouling things up, but I have no idea where to go to find that out - could anyone provide some suggestions on where to even look to troubleshoot this issue?


title: Using the Rewrite API to Construct a RESTful URL

text: I'm trying to generate rewrite rules for a RESTful API. I just want to see if there is a better way to make this work than having to write out every possible rewrite combination. Ok so I have 4 query variables to account for in the URL   * Indicator   * Country   * Response   * Survey The base url will be www.example.com/some-page/ The order of the 4 variables will be consistent but some query variables are optional. So I could have...               /indicator/{indicator value}/country/{country value}/response/{response value}/survey/{survey value}/      or...(no /response/)               /indicator/{indicator value}/country/{country value}/survey/{survey value}/      or...               /indicator/{indicator value}/country/{country value}/      Is there a better way to accomplish this than filtering the `rewrite_rules_array` and adding an array of my rewrite rules manually created? Would `add_rewrite_endpoint()` rewrite_endpoint or `add_rewrite_tag()` be any use to me?


title: Can you ungroup Custom Fields?

text: I have been using a lot of Custom Fields to use Wordpress like a CMS, beyond simple posts and post meta. The admin area for adding new posts has little "widgetized" movable areas like the "categories", "publish," and "tags" boxes for instance. With Custom Fields, all are grouped under one "widget" with the same name. Is there a way to break out the Custom Fields into their own "widget" boxes to rearrange the placement of the admin area?


title: Add some fileds to the wp_posts table

text: I need to extend some wp tables (wp_posts, wp_comments, wp_users) to store some additional fields. I can't use metadata because I need to query those values directly via MySQL. I need an help to choose if it's better to extend the original table or to define an additional one with those fields, with a 1-1 relationship to the original one. This second case will require an additional JOIN. Thanks. eV


title: Keep sticky posts out of query unless they have featured image

text: I have a query running which prevents posts without various criteria from appearing, one of these is the necessity to have a featured image. Sticky posts however seem to end up in the query regardless. How can I achieve this?                   $args = array(                 'posts_per_page' => $articles_no,                 'meta_key' => '_thumbnail_id',                 'post__not_in' => $a_empty_titles,                 // remove post formats as per theme options ( using $hide from above )                 'tax_query' => array(                         array(                             'taxonomy' => 'post_format',                             'field' => 'slug',                             'operator' => 'NOT IN',                             'terms' => $hide                         )                     )                 );             $fp_query = new WP_Query( $args ); ?>                 <ul class="thumbnails">                     <?php                      $thumbnail_span = "span4";                     if( $fp_query->have_posts() ) : while( $fp_query->have_posts() ) : $fp_query->the_post(); ?>                          ... Typical Formatting Follows ...                     ... Posts without featured images should have been excluded but "sticky" posts seem to persist


title: Woocommerce Add Variation Product to Cart from custom link

text: I am trying to add a variation product to my cart directly through a link. I am setting the variation_id with the query string. As far as I can tell I am sending the data the exact same way as the default variation product form does. Here's the code inside of my single-product page:               <a href="<?php echo esc_url( $product->add_to_cart_url() ); ?>&variation_id=262" class="rounded-rect-button add-to-cart">Add to Cart      Conversely, the simple product works fine. I have set prices to my product variations in the admin. Not sure why it's not as simple as sending the data through. Any help would greatly appreciated.


title: Using Offset in Custom Post Type Query

text:
I'm using the following query for a custom post type:               <?php                  $posts = get_posts(array(                     'numberposts' => -1,                     'offset' => 20,                     'post_type' => 'faqs'                       ));                           if($posts)                 {                          foreach($posts as $post)                     {                         echo '

ID) . '">' . get_the_title($post->ID) . '

';                             /*
ID) . '">' . get_the_title($post->ID) . '

' . get_the_excerpt($post->ID) . '

'; */                     }                      }                  wp_reset_query();                 ?>      Is there a reason as to why the offset parameter doesn't work? Perhaps I need to write an entirely different query altogether?


title: Numbering Image List in Gallery

text: While adding images in a post with the gallery shortcode, I want to display an image number as title of the image e.g if there are 3 images in a gallery and displayed as a list, above each image there should be a serial number. Shown as ![enter image description here](http://i.stack.imgur.com/T11Dg.jpg) I can set it afterwards with inline css. I tried alot in `media.php`, but without success.


title: Where in WP can I check history or log of updates of plugins etc?

text: I need to find out what happend at certaint time when some of my admins make some plugin updates etc. So i need to check in admin the log of changes, updates etc. Where can I find that in WP admin?


title: How to downgrade plugin?

text: I have installed a plugin, but it causes problem with get_the_excerpt() function in my theme. So, I need to downgrade that plugin. How to do that?


title: Getting term_id for newly created or edited term

text: I'm taking my first foray into plugin development and have got confused pretty quickly. I'm attempting to make a simple plugin that stores hex colours against terms, so you can assign a colour to a tag or category and then use that in a theme. What I cant figure out is how to get the term_id of a newly created or edited term. I've bolted on a form to 'edit_tag_form' with a colour picker and can access these values through $_POST, but if it's a newly created tag I don't see how my code can know the ID of the newly created one. I need to know the term_id to be able to link it with the hex colour and save it to wp_options. I'm using the action hook 'edited_term'. I guess for edited existing terms I could get the tag_ID from the query string, but I want to be able to assign colours immediately to newly created tags/categories.


title: Upload image to wordpress

text:
I'm a beginner writing website and use WordPress and I'm writing plugin that involves profile page (not avatar because this field that I implemented, user can upload image, anything, i.e. Picture of my friends) and I added field upload that browse file from directory and save them to database using WordPress' `wp_handle_upload`. I ran my code then the picture doesn't show I don't know which part of my code (below) is wrong. What should I do to solve this problem! Here is my code that I modified from this discussion               <?php     add_action( 'user_edit_form_tag','make_uploadable_form');     function make_uploadable_form() {     echo ' enctype="multipart/form-data"';     }     ?>      =============Edited==============   Here is the HTML code               <?php     add_action( 'show_user_profile', 'UploadField' );     add_action( 'edit_user_profile', 'UploadField' );          function UploadField( $user ) {      if ( !current_user_can( 'edit_user') )         return false;     $prfile_image_id = get_user_meta($user->ID,'profile_photo',true);     $profile_image = wp_get_attachment_image($profile_image_id,"full");          if(!empty($profile_image)){         echo $profile_image;     }     else{     ?>
Extra profile information

             Upload	                                      <input name="profile_photo" type="file" id="profile_photo" value="" />
          <?php     }      HERE IS THE HANDLE FILE UPLOAD:               add_action( 'personal_options_update', 'save_user_custom' );     add_action( 'edit_user_profile_update', 'save_user_custom' );          function save_user_custom($user_id){          if($user_id == false)         return false;          // If the upload field has a file in it     if(isset($_FILES['profile_photo'])){         if(!function_exists('wp_handle_upload'))             require_once(ABSPATH.'wp-admin/includes/file.php');              // Get the type of the uploaded file. This is returned as "type/extension"         $arr_file_type = wp_check_filetype(basename($_FILES['profile_photo']['name']));         $uploaded_file_type = $arr_file_type['type'];         // Set an array containing a list of acceptable formats         $allowed_file_types = array('image/jpg','image/jpeg','image/gif','image/png');         // If the uploaded file is the right format         if(in_array($uploaded_file_type, $allowed_file_types)) {             // Options array for the wp_handle_upload function. 'test_upload' => false             $upload_overrides = array( 'test_form' => false );                   // Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array             $uploaded_file = wp_handle_upload($_FILES['profile_photo'], $upload_overrides);                  // If the wp_handle_upload call returned a local path for the image             if(isset($uploaded_file['file'])) {                      // The wp_insert_attachment function needs the literal system path, which was passed back from wp_handle_upload                 $file_name_and_location = $uploaded_file['file'];                      // Generate a title for the image that'll be used in the media library                 $file_title_for_media_library = 'your title here';                      // Set up options array to add this file as an attachment                 $attachment = array(                     'post_mime_type' => $uploaded_file_type,                     'post_title' => 'Uploaded image ' . addslashes($file_title_for_media_library),                     'post_content' => '',                     'post_status' => 'inherit'                 );                      // Run the wp_insert_attachment function. This adds the file to the media library and generates the thumbnails. If you wanted to attch this image to a post, you could pass the post id as a third param and it'd magically happen.                 $attach_id = wp_insert_attachment( $attachment, $file_name_and_location );                 require_once(ABSPATH . "wp-admin" . '/includes/image.php');                 $attach_data = wp_generate_attachment_metadata( $attach_id, $file_name_and_location );                 wp_update_attachment_metadata($attach_id,  $attach_data);                      update_user_meta( $user_id, 'profile_photo', $attach_id );             }               }          }     }     ?>


title: SImple Example To Update User Info From Front End

text:
I want to give user ability to update their nickname from front end using `wp_update_user` and shortcode. The code below is working.                     add_shortcode('user-profile', 'get_current_user_prof');                function get_current_user_prof() {           global $current_user;           get_currentuserinfo();                 if(is_user_logged_in()) {     $tableuserinf = "<form method='post' action='#'>

";     $tableuserinf .= "
Nickname:	<input type='text' name='fepusernick' value='". $current_user->nickname ."'/>
";     $tableuserinf .= "

<button>Submit</button></form>";                    $user_id = 1;         $nicksname = $_POST['fepusernick'];         wp_update_user( array ( 'ID' => $user_id, 'nickname' => $nicksname ) ) ;                     return $tableuserinf;     }               }      The only problem with the code above is its field showing the previous value of the database after update success. And will only retrieve the database data after the page is refreshed. This will confuse user. How to solve that problem?


title: fatal error get_page_permastruct()

text: I'm getting the following error `Fatal error: Call to a member function get_page_permastruct() /link-template.php on line 276` when I invoke the in class constructor the `wp_insert_post($new_post);`.               add_action( 'plugins_loaded', array ( 'test', 'init' ) );     class test{              public static function init()         {             new self;         }              //the consructor for parser admin         function __construct(){                  global $wpdb;             $this->db = $wpdb;                        if ($_POST['action'] == 'add-page'){                 add_action( 'plugins_loaded', array ( $this, 'add_newpage' ) );                 $this->add_newpage();             }         public function add_newpage(){             $new_post = array(                     'post_title' => $_POST['page-name'],                     'post_content' => '',                     'post_status' => 'publish',                     'post_type' => 'page'             );                  $post_id = wp_insert_post($new_post);                $newtarget = $this->db->insert(                          'wp_test_table',                          array(                              'post_id' => $post_id,                              'slug' => 'test'                         ),                          array(                              '%d',                              '%s'                              )                          );              }          }


title: How to minimize WP dashboard menu programmatically?

text: I'd like to programmatically (either with js or php, but I imagine it'd simpler with js) hide the dashboard admin menu using the same functionality that is already built in. All I want is, when the user click on a custom link in the dashboard the admin menu will collapse so I can more screen space. Does anyone knows how to do this? I've been search for a couple days and can only find how to remove the menu completely which is not what I want. I could do that with a custom js script, however I'd rather just add an additional event handler to the current js function that hides the menu. Thanks for the help.


title: Adding new parent item to admin bar

text: I see many questions have been asked about adding something to the admin bar, but still I can't get a new 'parent' admin-bar item for Advanced Custom Fields to work. The admin bar doesn't show up if I add this to my functions.php:               function my_theme_admin_bar_render() {     $wp_admin_bar->add_menu( array(         'parent' => 'Advanced Custom Fields',         'id' => 'acf',         'title' => __('Advanced Custom Fields'),         'href' => admin_url( 'edit.php?post_type=acf')     ) );     }        add_action( 'wp_before_admin_bar_render', 'my_theme_admin_bar_render' );      How can I get this new admin bar item to work?


title: Can I use wordpress themes without wordpress?

text: I didn't find answer for my question so I'm decided to ask here, so: Can I use wordpress themes (for example: Twenty Twelve) without using wordpress? I really like this theme but I don't want to use wordpress. **UPDATE** I don't need a theme functionality, but only a layout, colors (everyghink what is visible, (html/css)) and I want to use this theme (of course with modified code) in my own application.


title: Different database query in function.php using mysqli

text: I am trying to connect to a database in the function.php using mysqli. The code seems to run fine when it is not on a separate php file not on wordpress. But when I run it on wordpress I get "Connect failed: No connection could be made because the target machine actively refused it." I am not sure if wordpress is preventing this. So can someone enlighten me on this problem? Code is provided below if needed.               require_once($_SERVER['DOCUMENT_ROOT'] . '/forum/config.php');     $mysqli = new mysqli($dbhost,$dbuser,$dbpasswd,$dbname);          if ($mysqli->connect_errno)     {         printf("Connect failed: %s\n", $mysqli->connect_error);         exit();     }          $data = '<?xml version="1.0"?>     <!-- squad info -->     <squad nick="DC">     <name>Dog Company</name>     <email>n/a@gmail.com</email>     <web> http://www.dog-company.com</web>     <picture>sqd_logo.paa</picture>     <title>Dog Company</title>     <!-- start of member list/info -->     <!-- Updated users and updated to xml on server-->';          $query = 'SELECT *             FROM '.$table_prefix.'users u              LEFT JOIN '.$table_prefix.'profile_fields_data f             ON (u.user_id = f.user_id)             LEFT JOIN '.$table_prefix.'user_group g             ON (u.user_id = g.user_id)             WHERE g.group_id = 9';          if ($result = $mysqli->query($query)) {              /* fetch associative array */         while ($row = $result->fetch_assoc()) {             if($row['pf_xml_arma_id'] != ""){                 $data .= '<member id="'.$row['pf_xml_arma_id'].'" nick="'.$row['pf_xml_player_name'].'">';                      $name = ($row['pf_xml_name'] == '' ? "N/A" : $row['pf_xml_name']);                 $email = ($row['pf_xml_email'] == '' ? "N/A" : $row['pf_xml_email']);                 $steam = ($row['pf_xml_steam_user'] == '' ? "N/A" : "Steam: ".$row['pf_xml_steam_user']);                 $quote = ($row['pf_xml_remark'] == '' ? "N/A" : $row['pf_xml_remark']);                      $data .= '<name>'.$name.'</name>                 <email>'.$email.'</email>                 <icq>'.$steam.'</icq>                 <remark>'.$quote.'</remark>';                 $data .= '</member>';             }         }              /* free result set */         $result->free();     }          /* close connection */     $mysqli->close();          $data .= '</squad>';           return $data;      Thank you for your time, UPDATE Seems like my $query wasn't getting the $table_prefix from my config file. I am not sure why it cannot access it though. Anyone?


title: Combine Query and Select Database to create directory loop

text: I have a query loop on my page that I am using which displays all users on the page with certain custom fields filled out. It's working fine however, I need to also query these users for their level of membership (created by Paid Membership Pro plugin) and only list those with a certain membership. The code snippet I have to select the database is as followed --               $member_ids = $wpdb->get_col("SELECT user_id FROM $wpdb->memberships_users WHERE membership_id = '1'");     $level1users = get_users(array("include"=>$member_ids));      And the code Im using to create the author directory is --                <?php          $blogusers = get_users (array(             'meta_query'   =>              array(                     'relation' => 'AND',                      array(                     'key' => 'custom_field_24'                 ),     array(                     'key' => 'custom_field_39',     'value' => 'yes'                 ),                 array(                     'key' => 'first_name'                 )              )        ));                          foreach ($blogusers as $user) :         ?>     //my divs     <?php endforeach; ?>      How can I combine these 2 codes?


title: Video post format, extra content breaks video embed

text:
I am using the **content-video.php** include to show the latest video post on my homepage. The include only shows the video from the post and not the rest of the content, which works well. My problem is, if I add any content (eg - text, another link, etc) after the link to the video in the post, it breaks my video embed on the homepage. The video and text before and after display fine in the actual post. Here is the code I have for **content-video.php**               <?php if(strlen( get_the_title() ) >0 ): ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
     <?php endif; ?>                            <?php         $parsedUrl  = parse_url(get_the_content());         $embed      = $parsedUrl['query'];         parse_str($embed, $out);         $embedUrl   = $out['v'];     ?>                        <iframe width="385" height="217" src="http://www.youtube.com/embed/<?php echo $embedUrl; ?>" frameborder="0" allowfullscreen>      And, here is the loop code where I'm including it on the homepage:                                 <?php             $args = array(                 'post_type' => 'post', // if the post type is post                  'posts_per_page' => 1,                 'tax_query' => array(                 array(                     'taxonomy' => 'post_format',                     'field' => 'slug',                     'terms' => 'post-format-video'                 ))             );             $my_query = new WP_Query( $args );             ?>             <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
                 <?php get_template_part( 'content', 'video' ); ?>                 more videos
         <?php endwhile; ?>      Can anyone spot what I'm doing wrong, or do I need to embed the video in a different way?! Thanks for any help.


title: Username from e-mail

text: Which files do I have to edit to get a grip on $_POST data sent by the registration form? I want to explode $_POST['email'] and build an username from that. I simply want to allow people to register only with their e-mail and password. Could you please help me with it?


title: Using Multiple Submit buttons to trigger customised php functions

text: I may be going about this completely the wrong way but bear with me... I have a long guestlist that is automatically populated using a `foreach` table. I would like to put a 'No Show' button on this guestlist so that without being admin the host of the event can click (client side) "No Show" and update the ticket (custom post) meta to State: 'noshow' A lot of the examples I have found mean making a new .php page for the submit button to link to and run the code [obviously because it is server side language] - the first problem is then, once they have clicked the submit button, it goes to a blank page (having no real HTML output) rather than returning to their event... This isn't such a big problem - I can put a redirect in I suppose but seems a bit clunky. The second problem is also that many of these examples don't take into account A) Multiple Submit Buttons that have to be automatically produced B) Different PHP code to be triggered for each one... Here is the jist of what I need doing below:                       <form onsubmit="return confirm('Do you want to mark <?php echo $FullName ?> as a 'No Show' - this cannot be undone unless you are an admin');" method="post" action="<?php HELP ?>">             <input name="NoShow<?php echo $IDuser?>" type="submit" value="No Show" class="button" /> //$IDuser is their user ID to give the values something different on the page. Could also be ticket [post] numbers?             </form>      Now on the server side I need something like this to run:                   $tixID = $ticket['id']; //This gets the ticket [custom post] ID number                 $StateKey = state; //This is the meta_key that needs changing                 $NoShowing = noshow; //This is what it needs to change to.                       update_post_meta($tixID , $StateKey , $NoShowing ); #This is the code to change the State: to No Show                 ?>      So I gather I need to use something along the lines of               if(isset($_POST['SUBMIT-BUTTON'])) {      some_function_called_here();      }       But this is fixed and is looking out for a certain name - It would be physically impossible for me to type out the different submit button names as it would be changing individual tickets - of which about 6,000 have already been sold on the site... Also the function called would have to be unique to the button that called it. Any shining light would be great as I feel like I'm going round in circles with some of these blog posts. EDIT: Sorry - for clarification. What I need to happen is...   1. Trigger - User presses one button in a list of buttons client side. It is generated in a table using php and a foreach that lists tickets bought for that event. `<input name="noshow<?php echo $ticketID ?>" type="submit" value="No Show" class="button" />`   2. Action - Each particular button corresponds to a particular ticket, once the button is clicked for that ticket it runs the code to edit that ticket post meta data, server side. `update_post_meta($ticketID , 'state' , 'noshow' );` This updates the key `State:` to `noshow`   3. Result - Page is reloaded and you remain on the same event page Here's a visual example of the screenshot ![Screenshot Example of scenario](http://i.stack.imgur.com/GqTus.png)


title: Removing all my hardcoded URLs with get_site_url()

text: In my php files, I would like to remove all my hardcoded URLs (ex: http://mysite.com/) and replace them with the `get_site_url()` function. My problem is with the php code of one of my functions (in functions.php) that adds a `_blank` attribute to all the links of my website except for the internal URLs.               function autoblank($text) {         $return = str_replace('href=', 'target="_blank" href=', $text);         $return = str_replace(             'target="_blank" href="http://localhost.com/test/',              'href="http://localhost.com/test/',              $return         );         $return = str_replace('target="_blank" href="#', 'href="#', $return);         return $return;     }     add_filter('the_content', 'autoblank');     add_filter('comment_text', 'autoblank');      How can I replace `http://localhost.com/test/` using `get_site_url()` so this code would work for any website? (not just `http://localhost.com/test/` )


title: WP database error for comments_popup_link()

text:
I'm using the `comments_popup_link()` function to show the number of comments for each post in a loop.               <?php if (have_posts()) : while (have_posts()) : the_post();  ?>          <?php if ( get_post_meta($post->ID, 'thumb_value', true) ) : ?>             //something     <?php else: ?>            //something else     <?php endif; ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?>
                   <?php the_content(__('Read more'));?>
            <?php the_time('F j, Y'); ?>
Category: <?php the_category(', '); ?>

<?php the_tags(); ?>

<?php comments_popup_link('Post Comment', '1 Comment', '% Comments'); ?>

               <?php endwhile; ?>      <?php $wpdb->show_errors();      $wpdb->print_error(); ?>          <?php else: ?>
There has been an error.
     <?php $wpdb->show_errors(); ?>      <?php $wpdb->print_error(); ?>
          <?php endif; ?>      Everything displays fine but I get > WordPress database error: [] SELECT * FROM wp_comments WHERE comment_post_ID > = 216 AND comment_approved = '1' ORDER BY comment_date_gmt DESC I'm just curios why I get that..


title: Wp_deregister_script() doesn't work

text: Somewhere in the parent theme for which I'm creating a child theme, the following line is executed:               wp_enqueue_script('quovolver', get_template_directory_uri() . '/js/jquery.quovolver.js','','',true);      I want to remove this script, so I added in the end of "footer.php":               wp_deregister_script('quovolver');      However it doesn't work as the script is still called. Why is that?


title: .htaccess in wp-admin produces a redirect loop

text: I've decided to take the advice of protecting the `/wp-admin` directory using .htaccess on a website which keeps getting hacked. Whenever I upload .htaccess to `/wp-admin`, my browser says `/wp-admin` has a redirect loop. This is `/wp-admin/.htaccess`: > >     AuthUserFile /.../.htpasswd >     AuthType Basic >     AuthName “restricted” >     Order Deny,Allow >     Deny from all >     Require valid-user >     Satisfy any >   A server redirection checker says there is a **302 (Moved Temporarily)** redirect from `/wp-admin` to `/wp-admin` If I delete `/wp-admin/.htaccess`, the redirect checker says there is still a 302 redirect from /wp-admin, but now it is to `/wp- login.php?redirect_to=http%3A%2F%2Fwww.example.com%2Fwp-admin%2F&reauth=1` Bare in mind the server redirect checker is not logged into Wordpress. Why does the presence of `/wp-admin/.htaccess` make `/wp-admin` redirect to itself? Thanks. PS - I am also using `Better WP Security`, but this made no changes to the site's `/.htaccess` in terms of `/wp-admin`. i.e. I didn't cloak `/wp-admin`


title: change the_content images for different sizes (Desktop, tablet, mobile)?

text: This may be a complicated question so I'll try to explain it as easy as possible. I have three sizes for images in my post (thumbnail, medium, large, 640px, small) and I would like to change the size based on browser size. I was thinking of having a way to load three images (small, medium, 640px) and use css to hide and show images based on the screen size. Is there a way to do this? I'm open to other suggestions as well. Thanks, Gregory S.


title: How can I change the tooltip in the_category?

text: My use of the_category works fine, but I want to change the tooltip, which says "View all posts in (category name)". How can I change this tooltip? I guess this might be something similar to this. Thank you


title: How do I "get the next 10 posts after post_id == x"?

text: I am building a mobile application that is pulling the json feed from a blog. I can easily query to get the latest 10 posts for example. But next, I want to be able to query the next 10. This presents me with a problem, because while pulling the first 10, another 2 posts may be added, so if I try to pull the next ten posts, I would get duplicates and get 8 unique posts instead of 10. I am trying to think of a way that I can simply get my last post id retireved, and request for the next ten posts after post id = x. I guess technically I would be getting the next 10 posts "before" that id, but I hope I explained my question. Update: I download recent posts               30 29 28 27 26 25 24 23 22 21      now I want to download next 10               20 19 18 17 16 15 14 13 12 11      Works perfect. But what happens if I want to download the next ten while x new posts were added. In this case we'll use 3 as x Download first 10               30 29 28 27 26 25 24 23 22 21      now the next 10 Whoops. Someone added 3 new posts still try to get next 10               23 22 21 20 19 18 17 16 15 14      Got duplicates of 23 22 21. I want to say `get last post download aka(21) and take next ten after that` How would I make the api in the address bar to handle this?


title: Where is definied the theme location for the main menu in a WordPress template?

text:
I am pretty new in WordPress (I came from Joomla) and I have the following doubt related the **Theme Location** of the main menu. For example, using the preinstalled **Twenty Twelve** theme, if in the backend I go into: **Appearance ---> Menus ---> Manage Location** I can assign my **main-menu** only to a specific **theme location** named **Primary Menu**. I think that this area is into the **header.php** file of the **Twenty Twelve** theme (because my main menu is shown in the page header) but I can't find it, this is the **header.php** content:               <?php     /**      * The Header template for our theme      *      * Displays all of the  section and everything up till
      *      * @package WordPress      * @subpackage Twenty_Twelve      * @since Twenty Twelve 1.0      */     ?><!DOCTYPE html>                    <html <?php language_attributes(); ?>>               <meta charset="<?php bloginfo( 'charset' ); ?>" />     <meta name="viewport" content="width=device-width" />     <title><?php wp_title( '|', true, 'right' ); ?></title>     <link rel="profile" href="http://gmpg.org/xfn/11" />     <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />     <?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>          <?php wp_head(); ?>               <body <?php body_class(); ?>>
                      <hgroup>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?>

<?php bloginfo( 'description' ); ?>
             </hgroup>
<?php _e( 'Menu', 'twentytwelve' ); ?>
                 <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?>                 <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>                               <?php if ( get_header_image() ) : ?>             <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php header_image(); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />             <?php endif; ?>
      Where is this **Primary Menu** or how is it definied in the theme? Tnx Andrea


title: Problem with the loop?

text:
I'm customizing my Twenty Twelve theme to show a single posts from two separate categories on my home page using a custom template. Here's my code :
     <?php         $catquery = new WP_Query( 'cat=26&posts_per_page=1' );         while($catquery->have_posts()) : $catquery->the_post();         the_post_thumbnail(array(250,300));     ?>     <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?>     <?php the_excerpt(); ?>     <?php endwhile; ?>

     <?php         $catquery = new WP_Query( 'cat=2&posts_per_page=1' );         while($catquery->have_posts()) : $catquery->the_post();         the_post_thumbnail(array(250,300));     ?>     <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?>     <?php the_excerpt(); ?>     <?php endwhile; ?>
      The problem what I face is the first loop runs fine and outputs post from cat 26. But the second loop with cat 2 don't display anything at all. Help would be much appreciated. Any thoughts? Update : added entire code for the two loops. Also I have another custom loop furthur down the page to display just thumbnails of latest posts from a specific category and that works fine. So as of now it stands like, out of three loops on the page first and last is executed perfectly but the second one isn't.


title: Diagnosing plugin conflicts

text: I'm having problems with what I think are conflicting plugins. I've done my research and I'm a bit stuck. This conflict only seems to happen _a little while_ after a core or a plugin update. Not immediately, but often around 12 hours later. What happens is the backend stops responding, whilst the front end appears to work, thanks to the cache. If I disable and then re-enable the plugins (via the db) the site responds again and remains stable until the next update. So, do you have any ideas how I can diagnose what's causing this? Or are there any known conflicts in this list? The site has these plugins and uses a modified Thematic theme   * Akismet   * BackWPup   * Custom Post Widget   * Display widgets   * Google Analytics Dashboard   * Google Analytics graph integration.   * Gravity Forms   * Maintenance Mode   * NextGEN Gallery   * PHP Snippets   * qTranslate   * TinyMCE Advanced   * WordPress Ken Burns Slideshow   * WP Remote   * WP Super Cache Thanks in advance Pete


title: Sort posts by meta key that is serialised with other meta keys

text: I need price sorting, where price is a metakey that is serialisez with other metakeys and stored in wp_postmeta ## I need something like this: When user click on **free** (Anchor tag) it should show posts with price '0' When they click on **paid** (Anchor tag) it should show posts with price excluding '0' Serialised Meta value a:7:{s:19:"et_is_editor_choice";s:1:"0";s:15:"et_fs_variation";s:1:"0";s:12:"et_fs_button";s:0:"";s:10:"et_fs_link";s:0:"";s:11:"et_fs_price";s:0:"";s:17:"et_affiliate_link";s:0:"";s:17:"et_affiliate_text";s:0:"";}


title: Excluding posts by meta, and also keeping posts without the meta

text: **edit:** Think I managed to figure it out, check the answer right under here, or click the following link: http://wordpress.stackexchange.com/a/51175/15809 * * * I've been trying to find a way to exclude posts with 2 meta keys + values, but also keep the posts without the metas at all. I looked into parse query request and have this in my `functions.php`:               function filter_out_efter15_posts( $request ) {         $dummy_query = new WP_Query();         $dummy_query->parse_query( $request );              if ( $dummy_query->is_home() || $dummy_query->is_category('notiser') ) {             $request['meta_query'][0]['key'] = 'efter15';             $request['meta_query'][0]['value'] = 'Nej';             $request['meta_query'][0]['compare'] = '=';             $request['meta_query'][0]['type'] = 'CHAR';                  $request['meta_query'][1]['key'] = 'show_on_front_page';             $request['meta_query'][1]['value'] = 'Ja';             $request['meta_query'][1]['compare'] = '=';             $request['meta_query'][1]['type'] = 'CHAR';                  return $request;         }         else {             return $request;         }      As you can see above, queries on the front page/home and on the category **notiser** (only category with posts that have these metas) filters out any posts with the meta key `efter15` with the value `Nej`, and meta key `show_on_front_page` with the value `Ja`. However, when I go to a tag page, the above function will not alter anything, and thus _all_ posts with that tag will show up. I still want the posts with the metas filtered out. I could add `$dummy_query->is_tag()`, but then it would filter out all the other posts that does not have the metas. Obviously I cannot set specific tags, like with the category. Hopefully you'll understand what I'm trying to do. Is there a clean and good way to deal with this? I'd like to keep the number of queries to a minimum, and there are 20k+ posts in the database so I don't know about running all of them into `post__not_in`, read it might slow things down a bit. Do I have to use a custom select query? Thanks


title: Assigning tags to a post from front end using tag-it jquery UI plugin

text:
Tag-it is a jquery UI plugin that allows assigning tags, exactly like tags system in stackoverflow. https://github.com/aehlke/tag- it/blob/master/README.markdown My goal is to allow members of my wordpress site to post from front end. To do so, I have created a form with input fields. I get the input content using `$_POST['something']`.To insert the post data (title, content, custom fields values), I use `wp_insert_post` function, and it is working well. And to insert tags for the specific post I use `wp_set_object_terms` function (since I am using custom post type and a taxonomy for tags). This last function is working well if I assign some sample values to it but I cant get the input values of the tags input created by `tag-it`. I tried my best to link between the plugin and the PHP code responsible of assigning tags to my post in WP DB. In fact, in my code source I put:

      And this code is transformed by the plugin (after execution) to :

     <input type="text" class="ui-widget-content ui-autocomplete-input" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">

      How can I retrieve the POST variable from this input field as an array, so that I can put it in the parameters of `wp_set_object_terms` ? Your usual help is always appreciated.\


title: Query not sorting DESC

text: I am using the following query:               <?php $postslist = new WP_Query('meta_key=Ordermetakey&orderby=meta_value_num&order=ASC&posts_per_page=5');      To sort a small post list on the frontpage to show latest new. It needs to order them by a meta key and do this DESC. The strange thing is it shows the posts ASC even though i have put ASC in this query. The value of the meta key is a date - time stamp: Example: 120403 = 03-04-2012 How can i make it work?


title: Custom button and html with [settings api plugin]

text: We are trying to improve the backend of a small plugin of ours via the settings api and we are using Tareqs http://tareq.wedevs.com/2012/06/wordpress-settings-api-php-class/ Settings API for it. We don't seem to figure out how to implement a custom button that after saving the settings it executes the plugin. This is one "Save" and one "Save & Execute" button. Also, there are no HTML or plain text types in the array, so we are not sure how to implement a kind of documentation tab with plain HTML info.


title: Getting recent posts corresponding to category items in custom menu

text: I'm trying to create a tabbed navigation, each tab containing 5 recent post excerpts of category items that are listed in a custom menu. I'm planning to load all these posts at once and put each category in its own tab. I know how to get posts and navigation links separately but not how to make them work together.. Thanks for your help!


title: Why does deactivating a plugin cause error: "You do not have sufficient permissions to access this page"?

text: We recently deactivated the bbPress plugin because we don't use it anymore. Immediately following that, no admin users can get into the dashboard without hitting the infamous: `"You do not have sufficient permissions to access this page?"` We tried removing ALL plugins to rule out a dependance from one of those, but it didn't work.


title: Remove rewrite rules generated by plugin during deactivation

text: I have a simple plugin like the following               add_action('generate_rewrite_rules', function ($wp_rewrite)     {         $wp_rewrite->rules = xxx + $wp_rewrite->rules;     });          if (is_admin())     {         register_activation_hook( __FILE__, function() {             flush_rewrite_rules(FALSE);         });              register_deactivation_hook(__FILE__, function() {             flush_rewrite_rules(FALSE);         });     }      When I activate this plugin, the rewrite rule is being updated and in effect, cool! However, when I deactivate the plugin, the rewrite rule cannot be flushed automatically. I need to manually flush by at the permalinks settings page. So how to modify my plugin code so no manually flushing is needed during plugin deactivation?


title: How to fetch posts that are stored in the different table than (default) wp_posts?

text: What I need is altering default Wordpress posts-pooling mechanism so I can get posts from other tables in database, not just default wp_posts and wp_postmeta. How is that possible? I'm ready to proudly die dealing with consequences of altering Wordpress core.


title: Is each issue of a magazine site a static page

text: I want to create a monthly magazine style website. I can see the url for a month is something like this: www.magazine.com/mywebpage/2013/08 Suppose I want to create a custom page for each month, do I create static pages for each month? If I do that, how do I display the static page when the user clicks on the date archive?


title: How to bulk update META Data in posts

text: I have almost 50,000 posts in my wordpress website. I have never written the META Title, META Description and META Keywords. Now I need to write them for SEO purpose. How can I do it easily in the shortest possible time? I am using All in one SEO plugin.


title: Using OR conditions in meta_query for query_posts argument

text: I have searched high and low for this but I cant seem to locate anything. I am trying to filter some results and when I make an args array like this and pass it to query_posts I noticed that the generated SQL uses AND instead of OR for the 'class_1_days' value. I would like to make than an OR. How would I go about doing this? (I am using LIKE there as the data is serialized, otherwise I would have tried an "IN" and pass an array. What is the proper way to go about this?               $args = array(                 'taxonomy' => 'courses',                  'term' => 'drawing',                  'post_type' => 'school',                  'paged' => $paged,                 'meta_query' =>                     #$checkbox_array,                     array(                         array(                             'key' => 'instructor',                             'value' => '1128',                             'compare' => 'LIKE',                         ),                         array(                             'key' => 'class_1_days',                             'value' => 'Friday',                             'compare' => 'LIKE',                         ),                         array(                             'key' => 'class_1_days',                             'value' => 'Saturday',                             'compare' => 'LIKE',                         ),                     )                  );      This is the relevant SQL that is being generated where I noticed the AND               [138] => Array         (             [0] => SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  INNER JOIN     wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN     wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)     INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)     INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id) WHERE 1=1  AND (     wp_term_relationships.term_taxonomy_id IN (18) ) AND wp_posts.post_type = 'school' AND     (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND (     (wp_postmeta.meta_key = 'instructor' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%1128%')     AND  (mt1.meta_key = 'class_1_days' AND CAST(mt1.meta_value AS CHAR) LIKE '%Friday%')     AND  (mt2.meta_key = 'class_1_days' AND CAST(mt2.meta_value AS CHAR) LIKE '%Saturday%') ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 5


title: Woocommerce - Hide “add to cart” on free products

text: im using Woocommerce and searching for a way to hide the "Add to cart"-Button on   a single-Product page **IF** the product is for free - I'm making a big CSV- Import and some product-prices are set to zero - i just want to hide the "add to cart" button on these products, so these are not buyable. already asked this on the support page, but no success Greets


title: SQL query for converting post meta image url to featured image

text: WordPress guru, we have a question: We work on a website, which was not updated a while. Most of time it have wordpress 3.2 installed. We've updated it to the latest wordpress version, but encountered a problem with featured image. Before this website store a link to a featured image on custom post meta field named 'image'. On this field we have full path to image, like http://example.com/wp- content/uploads/year/month/picture.jpg We need an example of how query the custom field to get the url of image and add it to a featured image section. Another problem - we have 30000 of posts, that we need to convert. Big thanks. **UPDATE**   Here what we find(old support answers and stackoverflow answers): http://wordpress.org/support/topic/convert-custom-field-image-to-be-the- featured-image http://stackoverflow.com/questions/15585063/how-to-set- wordpress-featured-images-via-sql Thanks! **UPDATE** This is what we`ve tried:               while($posts->have_posts()):           $posts->the_post();      $args = array(         'post_mime_type' => 'image/jpeg',         'post_title'     => esc_attr( get_the_ID() ), // you may want something different here         'post_content'   => '',         'post_status'    => 'inherit'     );      $image_url = get_post_meta(get_the_ID(),'image',true);      $filename = strpos($image_url,'uploads/');      $filename = substr($image_url,$filename+strlen('uploads'));           $thumb_id = wp_insert_attachment( $args, $basedir.$filename,  get_the_ID());           $metadata = wp_generate_attachment_metadata( $thumb_id, $basedir.$filename);      $good = wp_update_attachment_metadata( $thumb_id, $metadata );      update_post_meta( get_the_ID(), '_thumbnail_id', $thumb_id );          endwhile;      But at this moment we have a error : "not enough memory".


title: How and where can we request new WordPress hooks to be added?

text: I use the great Changelogger plugin, which adds plugin version history to the plugins page when there is an update. Although I would like it to, it doesn't work from the updates page where you can update WordPress core, plugins, and themes. How and where can a new hook for that page be requested so that the changelogs can be added to that page too?


title: How do I rename the wp-admin folder with the admin_url filter?

text: > **Possible Duplicate:**   >  Can I rename the wp-admin folder? I have applied some mod_rewrite rules to redirect `/wp-admin` to `/my-admin` - based on this tutorial. I also changed the admin url internally by hooking into `admin_url` and replacing the `/wp-admin` string:               add_filter('admin_url', 'my_admin_url');     function my_admin_url($path)     {        return str_replace('wp-admin', 'my-admin', $path);     }      **Update #1**   In order to not break those (about 200) code parts with hardcoded `/wp-admin`, I search&replace all relevant `$_SERVER` attributes with `/wp-admin` early in my `functions.php`. This works so far. **Update #2**   Rewriting the `$_SERVER` attributes in `functions.php` is too late for a correct setup of `$current_screen`, which might break code parts depending on it. The setup eventually happens in `wp-includes/vars.php` (by setting the global variable `$pagenow`), which is too early to hook into by plugins. I fixed this issue by moving `$_SERVER` rewrites to `wp-config.php` - which is early enough. :) * * * ### Problems with approach described above ↑ The approach above might not work for conditions which compare `admin_url()` to one of the `$_SERVER` attributes (first one points to `/my-admin`, second one to `/wp-admin`). However, first tests indicate that none of such conditions are present in the WP core code. Does anybody see other problems with this approach?


title: Rename wp-admin

text: I want to rename the admin URL 'wp-admin' to e.g. 'admin'. I set a rewrite rule in the .htaccess to acces the admin login: RewriteRule ^admin wp-admin [NC,L] That works but I can still use /wp-admin. So I have to tell Wordpress that 'admin' is the new URL. Can anyone help?


title: Show content after the first and second paragraph

text:
The function below is used to show certain content after the first paragraph. I would like to show 'content X' after the 1st paragraph and 'content Y' after 2nd paragraph.               <?php     $paragraphAfter= 1; //display after the first paragraph     $content = apply_filters('the_content', get_the_content());     $content = explode("
", $content);     for ($i = 0; $i <count($content); $i++ ) {     if ($i == $paragraphAfter) { ?>
Insert content here
          <?php }     echo $content[$i] . "
";     } ?>      I appreciate any help.


title: How to wrap "Read More" link in a DIV tag?

text: Can someone tell me how to wrap the Read More anchor (that displays after an excerpt) with DIV tags using `get_the_content('Read More')`?


title: Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php

text: I have a custom post type **events** and am displaying these events using archive-events.php and single-events.php from the template hierarchy. I have a custom query in archive-events.php               $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;     $events_query = new WP_Query( array (       'post_type' => 'events',       'orderby' => 'meta_value',       'meta_key' => '_fulldate',       'order' => 'ASC',       'paged' => $paged,       'meta_query' => array ( array(           'key' => '_fulldate',           'value' => $cutoff_date,           'type' => 'numeric',           'compare' => '>' ) ) )     );      This displays the events in order of event date ( as opposed to published date ). All works fine until I put `previous_post_link()` and `next_post_link()` into single-events.php. What happens then is that the next and previous links take me to the next and previous event by published date as opposed to by event date. I am a bit confused about how events-single.php is meant to know which is the next event. Should I be doing some kind of query on there as well, because I'm not at the moment? It's just a standard 'single' file. Could anybody help me out I have been up and down this and cant find out how to do it.


title: Echo custom field value in shortcode function

text:
I must be doing something wrong here. I want to display the custom fields **"pw_featured_note"** & **"pw_featured_price"** Here is my code so far               function featured() {          query_posts('post_type=property&posts_per_page=2');         if (have_posts()) :         while (have_posts()) : the_post();         echo "
";         if ( get_post_meta($post->ID, 'pw_featured_property', true) ) ;         echo "";         the_post_thumbnail('home-thumb');         echo "";         echo "
".get_the_title()."
";         echo "
".get_post_meta($post->ID, 'pw_featured_property', true)."
";         echo "
 goodbye
";         echo "
";         endwhile;         endif;          wp_reset_query();          }          add_shortcode('featuredproperty', 'featured');      Any help would be greatly appreciated.


title: Hide menu items for visitors and filter based on role

text: In my menu i've got some menu items that i don't want to show to people who aren't logged in. One of these i only want to show to logged in users of a certain roles the other to everyone logged in. So one of them is called 'My Printer'. This should be visible to everyone that is logged in. The other is called 'Partners'. This should only be visible to users with the partner role. I've tried using Role Scoper but i find it very difficult to use and it doesn't make a lot of sense. It also interferes with a lot of other things as well which i don't need. Is there anyway i can hide menu items based on their role? Thanks **EDIT** I've created the menu using the admin and placed that menu in a theme location. The menu items i want to hide are in this menu. Thanks for the 2 answers below, but neither achieve what i'm after.


title: Code in theme functions.php faster than with a plugin?

text: I've read many articles that says that we should not keep plugins that we don't use. Even if they are disabled, they use memory. **functions.php instead of 10 plugins?** What if i have 10 small plugins that each of them have a little function. Could I gain speed if moving the functions to the themes functions.php? If yes / no, why?


title: Is there a way to add a link directly into this media query?

text: I am running this query which pulls all of the images attached to a particular post and outputs them into a slideshow (See example here - http://powers.deanelliott.me/property/1428-elm-street/) Is there a way that I can directly output a link (So that the larger image gets displayed in a lightbox) into this query as adding link tags doesn't seem to work               <?php $args = array('numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $post->ID); ?>         <?php if ( $photos = get_posts($args) ) : ?>             <?php foreach ( $photos as $photo ) : ?>                 <?php echo wp_get_attachment_image($photo->ID,'thumbnail'); ?>             <?php endforeach; ?>         <?php endif; ?>


title: Very Slow Page - How to Optimize # of Queries?

text:
**EDIT 12/19/2011** Thank you again Ijaas. Everything is working except for the order of the days. It is ordering the groups of days by the publish order. If an older post has a newer date in its meta_key then it is before a newer published post with an older meta_key. It sorts the events on one day properly but it does not sort the days. Do you have any idea why? Here is the current code that I am using.
Upcoming
     <?php          $convertedtime = "Y-m-d H:i"; // Time format You can remove this if it is defined before     $convertedtime = "g:i"; // convert to 12 hour clock and minutes for upcomming events sidebar     $convertedendtime = "g:i a"; // convert to 12 hour clock and minutes for upcomming events sidebar     $today  = date ( 'Y-m-d H:i' );      $thedate = time(); // IF you want to start from a future date use strtotime( FutureDateHere );     $thedate = date ( 'Y-m-d H:i' , $thedate );     $future = strtotime ( '+10 Days' ); // IF you want to start from a future date use strtotime( '+10 Days', strtotime( FutureDateHere ) );     $future = date ( 'Y-m-d H:i' , $future );          $times  = array();     $events = array();          $keys = array('opening_time', 'closing_time', 'artist_talk_time', 'special_event_time', 'lecture_time', 'panel_time', 'workshop_time');          $args = array(      'post_type' => 'event',      'orderby'     => 'meta_value',      'order'       => 'asc',      'meta_query' => array(     /* 'relation' => 'NONE',*/         array(             'key' => $keys,             'value' => array($today,$future),             'compare' => 'BETWEEN',             'type' => 'DATE'         ),          )     );          $event_query = new WP_Query( $args );      if ($event_query->have_posts()) : while ($event_query->have_posts()) :  $event_query->the_post();               // Storing events in array is more efficent than using get_the_title, ect... later on         $events[$post->ID] = array(             'title'     => apply_filters('the_title', $post->post_title),             'link'      => get_permalink($post->ID),             'thumbnail' => get_the_post_thumbnail($post->ID, 'upcoming_event_sidebar'),             'venue'     => get_post_meta($post->ID,'event_venue', true),             'custom_venue' => get_post_meta($post->ID,'custom_event_venue', true),             'opening_time_end' => get_post_meta($post->ID,'opening_time_end', true),             'closing_time_end' => get_post_meta($post->ID,'closing_time_end', true),             'artist_talk_time_end' => get_post_meta($post->ID,'artist_talk_time_end', true),             'special_event_time_end' => get_post_meta($post->ID,'special_event_time_end', true),             'lecture_time_end' => get_post_meta($post->ID,'lecture_time_end', true),             'panel_time_end' => get_post_meta($post->ID,'panel_time_end', true),             'workshop_time_end' => get_post_meta($post->ID,'workshop_time_end', true)         );                   $custom_field_keys = get_post_custom_keys();              foreach ($custom_field_keys as $custom_field_key) {                  if (in_array($custom_field_key, $keys)) {                 $custom_field_value = get_post_meta($post->ID, $custom_field_key, true);                 if ($custom_field_value >= $thedate && $custom_field_value <= $future) {                     $times[date('Y-m-d', strtotime($custom_field_value))][] = array($custom_field_value, $post->ID, $custom_field_key);                       $events[$post->ID][$custom_field_key] = $custom_field_value; //opening_time, closing_time.......                      }             }         }          endwhile;              foreach($times as $day => $list): if($num = count($list)):                  sort($list);                  echo "
"; // Start a day             ?>

                                                      <?php echo $num.(($num >= 2)? " Events " : " Event "); ?>                                                                                <?php echo ($day == $today)? "Today" : date( 'l', strtotime($day) ); ?>                                                                                <?php echo date( 'F j', strtotime($day) ); ?>

                  <?php                  foreach($list as $ev){                      $time_value = $ev[0]; $post_id = $ev[1]; $time_key = $ev[2];                 $e = (object) $events[$post_id];                      if ($time_key == 'opening_time') { ?>
                         <a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->thumbnail ?>
<a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->title ?>

Opening

<?php echo ($e->venue != 'other')? $e->venue : $e->custom_venue; ?>

<?php echo date( $convertedtime, strtotime( $e->opening_time ) ); echo " - "; echo date( $convertedendtime, strtotime( $e->opening_time_end ) ) ;?>

                      <?php } else if ($time_key == 'closing_time') { ?>
                         <a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->thumbnail ?>
<a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->title ?>

Closing

<?php echo ($e->venue != 'other')? $e->venue : $e->custom_venue; ?>

<?php echo date( $convertedtime, strtotime( $e->closing_time ) ); echo " - "; echo date( $convertedendtime, strtotime( $e->closing_time_end ) ) ;?>

                      <?php } else if ($time_key == 'artist_talk_time') { ?>
                         <a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->thumbnail ?>
<a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->title ?>

Artist Talk

<?php echo ($e->venue != 'other')? $e->venue : $e->custom_venue; ?>

<?php echo date( $convertedtime, strtotime( $e->artist_talk_time ) ); echo " - "; echo date( $convertedendtime, strtotime( $e->artist_talk_time_end ) ) ;?>

                      <?php } else if ($time_key == 'special_event_time') { ?>
                         <a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->thumbnail ?>
<a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->title ?>

Special Event

<?php echo ($e->venue != 'other')? $e->venue : $e->custom_venue; ?>

<?php echo date( $convertedtime, strtotime( $e->special_event_time ) ); echo " - "; echo date( $convertedendtime, strtotime( $e->special_event_time_end ) ) ;?>

                       <?php } else if ($time_key == 'lecture_time') { ?>
                         <a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->thumbnail ?>
<a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->title ?>

Lecture

<?php echo ($e->venue != 'other')? $e->venue : $e->custom_venue; ?>

<?php echo date( $convertedtime, strtotime( $e->lecture_time ) ); echo " - "; echo date( $convertedendtime, strtotime( $e->lecture_time_end ) ) ;?>

                       <?php } else if ($time_key == 'panel_time') { ?>
                         <a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->thumbnail ?>
<a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->title ?>

Panel

<?php echo ($e->venue != 'other')? $e->venue : $e->custom_venue; ?>

<?php echo date( $convertedtime, strtotime( $e->panel_time ) ); echo " - "; echo date( $convertedendtime, strtotime( $e->panel_time_end ) ) ;?>

                       <?php } else if ($time_key == 'workshop_time') { ?>
                         <a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->thumbnail ?>
<a href="<?php echo $e->link ?>" title="<?php echo $e->title ?>"> <?php echo $e->title ?>

Workshop

<?php echo ($e->venue != 'other')? $e->venue : $e->custom_venue; ?>

<?php echo date( $convertedtime, strtotime( $e->workshop_time ) ); echo " - "; echo date( $convertedendtime, strtotime( $e->workshop_time_end ) ) ;?>

                 <?php }             }                  echo "
"; // End a day              endif; endforeach;                    endif; // END $event_query->have_posts();          ?>      I have a page that loops through a custom post type and sorts by dates entered in `meta_boxes`. It seemed to work at a reasonable speed before but now it is extremely slow. There is probably some logical mistake I am making in the order of my querys and php requests but I do not know how to optimize it. Here is the code that is loaded on the page. Link to * _original_ *code on Pastebin for easier viewing: Pastebin Code Here is the code from the functions.php that makes the meta data for the posts. Link to Pastebin of this code section: Meta Box Code Thank you in advance. **EDIT 12/14/2011 - Replaced original code with example below. Am I on the right track?** Original code still available at Pastebin Link.                       <?php         /* Let's get all the meta date in one call rather then so many queries */              $event_custom_meta=get_post_custom($post->ID); // Get all the data               $event_start_date = $event_custom_meta['start_date'][0];  /* Not sure why I need [0] here but it returns Array if I don't have it */         $event_end_date = $event_custom_meta['end_date'][0];         $event_opening_time = $event_custom_meta['opening_time'][0];         $event_closing_time = $event_custom_meta['artist_closing_time'][0];         $event_lecture_time = $event_custom_meta['lecture_time'][0];         $event_panel_time = $event_custom_meta['panel_time'][0];         $event_special_event_time = $event_custom_meta['special_event_time'][0];         $event_workshop_time = $event_custom_meta['workshop_time'][0];         $event_event_venue = $event_custom_meta['event_venue'][0];         $event_custom_event_venue = $event_custom_meta['custom_event_venue'][0];              echo $event_start_date;         echo $event_end_date;         echo $event_opening_time;         echo $event_closing_time;         echo $event_artist_talk_time;         echo $event_lecture_time;         echo $event_panel_time;         echo $event_special_event_time;         echo $event_workshop_time;         echo $event_event_venue;              /* The test works. Alright, now I can echo these variables anyplace that I want */              /* Replace the previous code below with the cleaner code after*/         ?>                  <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('
', '
'); ?>
<?php                    if (get_post_meta(get_the_ID(),'event_venue', true) != 'other') {                  echo get_post_meta(get_the_ID(),'event_venue', true);                 }             if (get_post_meta(get_the_ID(),'event_venue', true) == 'other') {                 echo get_post_meta(get_the_ID(),'custom_event_venue', true);                 }         ?>
                             <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('
', '
'); ?>
<?php                    if ($event_event_venue != 'other') {                  echo $event_event_venue;                 }             if ($event_event_venue == 'other') {                 echo $event_custom_event_venue;                 }         ?>
                       <?php         /* is calling the function get_related_event data another query?          *Is there away to add this infor to the orignial meta_box setup?        */        echo get_related_event_data( $event_event_venue, 'address' );         echo get_related_event_data( $event_event_venue, 'phone_no' );         echo get_related_event_data( $event_event_venue, 'url' );         /* end question */        ?>      **END EDIT on 12/14/2011 - added revised code example above** I am pretty sure that it is in this section below, because the page speeds up when I take out the "Upcoming" loop. What am I doing wrong? Link to Suspicious section on Pastebin:Suspicious Code
Upcoming
            <?php       for ($i=0; $i<10; $i++) {       $thedate = strtotime ( '+'.$i.' day' , strtotime ( $today ) ) ;       $thedate = date ( 'Y-m-d H:i' , $thedate );            $thedaytext = strtotime ( '+'.$i.' day' , strtotime ( $todaytext ) ) ;       $thedaytext = date ( 'l' , $thedaytext );            $thedatetext = strtotime ( '+'.$i.' day' , strtotime ( $todaydatetext ) ) ;       $thedatetext = date ( 'F j' , $thedatetext );            $future = strtotime ( '+24 hours' , strtotime ( $thedate ) ) ;       $future = date ( 'Y-m-d H:i' , $future );        $times = array();  // put before the $event_query and seems to work            $args = array(            'post_type' => 'event',            'orderby'     => 'meta_value',            'order'       => 'asc',            'meta_query' => array(            'relation' => 'OR',               array(                   'key' => 'opening_time',                   'value' => array($today,$future),                   'compare' => 'BETWEEN',                   'type' => 'DATE'               ),               array(                   'key' => 'artist_talk_time',                   'value' => array($today,$future),                   'compare' => 'BETWEEN',                   'type' => 'DATE'               ),               array(                   'key' => 'closing_time',                   'value' => array($today,$future),                   'compare' => 'BETWEEN',                   'type' => 'DATE'               ),               array(                   'key' => 'special_event_time',                   'value' => array($today,$future),                   'compare' => 'BETWEEN',                   'type' => 'DATE'                 )           )       );            $event_query = new WP_Query( $args );        if ($event_query->have_posts()) : while ($event_query->have_posts()) :  $event_query->the_post();              $keys = array('opening_time', 'closing_time', 'artist_talk_time', 'special_event_time');       $custom_field_keys = get_post_custom_keys();            foreach ($custom_field_keys as $custom_field_key) {          if (in_array($custom_field_key, $keys)) {                   $custom_field_value = get_post_meta($post->ID, $custom_field_key, true);               if ($custom_field_value >= $thedate && $custom_field_value <= $future) {                  $counttest++;                  $times[] = array($custom_field_value, $post->ID, $custom_field_key);               }           }       }                 endwhile;       ?>
            <?php       if ($counttest >0) {       ?>

              <?php            echo $counttest;           if ($counttest>=2) {               echo ' Events ';           } // end if ($totalevents>=2) function           if ($counttest<2) {                echo ' Event ';           }       ?>                                <?php           if ($thedate==$today) {               echo 'Today';           }           if ($thedate>$today) {               echo $thedaytext;           }       ?>                                <?php           echo $thedatetext;       ?>

            <?php       }       endif;       $counttest=0;            sort($times); // I changed the asort to sort here                 foreach ($times as $event) { $time_value = $event[0]; $post_id = $event[1]; $time_key = $event[2];  // changed the foreach here                if ($time_key == 'opening_time') { ?>
           <a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_post_thumbnail($post_id, 'upcoming_event_sidebar'); ?>
<a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_title($post_id); ?>

Opening

             <?php           if (get_post_meta($post_id,'event_venue', true) != 'other') {                echo get_post_meta($post_id,'event_venue', true);               }           if (get_post_meta($post_id,'event_venue', true) == 'other') {               echo get_post_meta($post_id,'custom_event_venue', true);               }             ?>

<?php $opening_time_formated = date($convertedtime, strtotime( get_post_meta($post_id,'opening_time', true)));             echo $opening_time_formated;?>

           <?php }                else if ($time_key == 'artist_talk_time') { ?>
           <a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_post_thumbnail($post_id, 'upcoming_event_sidebar'); ?>
<a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_title($post_id); ?>

Artist Talk

<?php echo get_post_meta($post_id,'event_venue', true);?>

<?php $artist_talk_time_formated = date($convertedtime, strtotime( get_post_meta($post_id,'artist_talk_time', true)));             echo $artist_talk_time_formated;?>

           <?php }                 else if ($time_key == 'closing_time') { ?>
            <a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_post_thumbnail($post_id, 'upcoming_event_sidebar'); ?>
<a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_title($post_id); ?>

Closing

<?php echo get_post_meta($post_id,'event_venue', true);?>

<?php echo get_post_meta($post_id,'closing_time', true);?>

           <?php }                 else if ($time_key == 'special_event_time') { ?>
            <a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_post_thumbnail($post_id, 'upcoming_event_sidebar'); ?>
<a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_title($post_id); ?>

Special Event

<?php echo get_post_meta($post_id,'event_venue', true);?>

<?php $special_event_time_formated = date($convertedtime, strtotime( get_post_meta($post_id,'special_event_time', true)));             echo $special_event_time_formated;?>

           <?php }                 }                  rewind_posts();       ?>
            <?php        }        ?>


title: Disable formatting on textarea

text: I'm using the following code in my plugin to display a `<textarea>` field on a page:               echo '<textarea required="required" name="Message" class="textarea" cols="70" rows="10">'.esc_textarea($message).'</textarea>';      However, WordPress seems to be inserting `<p>` and `<br />` tags into the textarea contents if the message contains newline characters. I'm assuming this is being caused by the default wpautop() filter. Is there a way to disable filtering of `<textarea>` contents on a page? **Edit** Some more information about how my plugin works. It creates a hook for `the_content`, which will append data to the contents of certain pages. I still want `wpautop` formatting to be applied to the appended content, just not for the `<textarea>` field. Here is a rough outline of how my plugin is setup:               function get_special_content()     {         $text = '';              // Customized content is appended to text here         // including the textarea field              return $text;     }          function my_plugin_content_hook($content)     {         if(is_some_special_page()) {             return $content.get_special_content();         }              return $content;     }          add_action('the_content', 'my_plugin_content_hook');


title: Assigning a list of ZIP codes to specific WordPress Pages?

text: Background: We live in a small state and have 10 "stores" located throughout it. Each of these stores has their own WordPress Page. We have a master list of ZIP codes for our state (roughly 400 ZIP codes) and would like to assign these ZIP codes to one of the 10 WordPress Pages. If a user enters their ZIP code in a search field, we'd like to take them directly to the assigned "store" WordPress Page. What's the best way to go about building this while keeping WordPress' best practices in mind? It's a pretty simple one-to-many relationship (Page -> ZIP codes) and I don't think any geocoding is needed, but I'm not an expert on building WordPress plugins and want to do things correctly. I'm thinking a simple database table of the 400 ZIP codes with a "post_id" field corresponding to the correct WordPress page, but it would be nice to have some sort of interface on the backend that allows us to bulk-assign ZIP codes (via a multi-select box?) to a WordPress Page without having to edit each database row manually - are there any tools to help build these interfaces or is this something I'll have to create manually?


title: Migrate bbpress content to posts

text: I'm looking for a way to migratie a bbPress forum to post & replies. Why you ask? Well... the use of a forum in this case is an overkill. And I want to get rid of it. It's a bad apple from the past.               bbPress   migrate to   Wordpress     forums       >         category     topics       >         post     replies      >         comments      Is this possible without SQL queries and such? If not... is this straight forward when I give a programmer the task to migrate? I'm just trying to find my bearings here. Maybe there is some crazy tool out there that I don't know about. Cheers, Paul


title: Best pratice to make taxonomy terms translatable without changing slugs?

text: I have one custom taxonomy with countries and states. I'd like to make these terms translatable but I'm not sure what would be the best way to achieve this. First of all, I don't want the slugs to change, only the label, and maybe the description strings. I thought of two ways. One could be using WPML. But WPML seems to force you change the slug for each language as well which is what I don't want. Another could be `wp_insert_term()` but I'm not sure if that is efficient or the correct way of doing it. I'd find more practical to let admins/editors to add their own terms, hard coding all the terms wouldn't allow me to do that and furthermore I have a feeling it's not very efficient (there could be a few hundred locations in my taxonomy)... Any clues? **UPDATE 1 : WPML** I contacted WPML support, they explained WPML creates new taxonomy terms for each language and as such each term must have an unique slug... however I'm wondering if there's any other option to achieve this, eg. with term aliases for instance **UPDATE 2 : wp_insert_term()** I found this: http://tommcfarlin.com/programmatically-create-categories/ and it suggests to run `wp_insert_term()` within a hook of `'after_theme_setup'` or `after_switch_theme` action. However that won't solve the translation problem. Since the hook action fires only after theme setup, even if I gettext all the terms labels strings, it will only consider the language at the moment of theme setup.


title: WordPress Multisite on nginx

text: We have two versions of our site test.example.com running on nginx and our core site example.com running on Apache. The site is running for few year and has a lot of content and traffic. We want to now to add multisite feature to our site, but to keep our core site running in the root domain. We enabled multisite, wildcard subdomains, etc. on test.example.com   site1.test.example.com shows, 'Welcome to nginx! If you see this page, the nginx web server is successfully installed and working. Further configuration is required. For online documentation and support please refer to nginx.org. Commercial support is available at nginx.com. Thank you for using nginx.' Our questions are:   1. What is the best practice to configure nginx and solve this common problem since there are so many different answers on this question.   2. When we will be applying it on our core site example.com (on Appache), what will be different what we need to care of and what to do/not to do in that case.    3. On the test.example.com the posts are giving error 404 after enabling multisite although they are normally showing up in the loop on main page. I hope it is related to nginx problem and will be solved with same fix, if not please, give me some lead to debug it.


title: Insert taxonomy term to different table

text: I have different table in the database called "wp_taxterms". How do I insert to that table every time a news taxonomy term under "Clients" is created or if an existing one has been updated/deleted? EDIT:                   if( isset($_GET['page']) && ($_GET['page']=="export-clients") ) {             global $wpdb;             $result = $wpdb->get_results("SELECT * FROM wp_special");                $categories = get_terms( 'clients' );                  header("Pragma: public");             header("Expires: 0");             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");             header("Cache-Control: private", false);             header("Content-Type: application/octet-stream");             header("Content-Disposition: attachment; filename=\"Clients.csv\";" );             header("Content-Transfer-Encoding: binary");                  //create a file pointer connected to the output stream             $output = fopen('php://output', 'w');                  //output the column headings             fputcsv($output, array('Name', 'Address', 'Email', 'Contact'));                  foreach($categories as $cat) {                 fputcsv($output, array($cat->name, $cat->description, $cat->email, $cat->contact) );                         }                     fclose($output);             exit;         }//endif


title: Using functions concatenated with strings inside a variable

text: Trying to do some dynamic image sourcing but I'm stuck. Probably pretty basic stuff, but I'm new to this. This works:               <img src="<?php  bloginfo('template_url');?>/images/LakeArnaulMap-<?php the_ID();?>.png"/>      Why doesnt this:               <?php      $my_img = '';     echo $my_img;     ?>


title: Cropping thumbnails to specific dimensions on front end post

text: Probably not the best title description but here we go. One of my custom post types is for youtube videos which I take the thumb from youtube and upload it as a thumbnail for the post. Now it's easy enough to download the image from youtube and use `media_handle_sideload()` to upload it as an attachment for the post and set thumbnail sizes for it be cropped to but youtube video images come with excess black bars at the top and bottom. So I need a way to crop them out. So I have a custom thumbnail size that crops all thumbs to a width of 224px called 'post-thumbnail'. I get and process the thumb like so from a front end post.               $vid_url = $_POST['video_url'];     $video_id = getVideoId($vid_url);     if ($video_id) {        $video_response = wp_remote_retrieve_response_code(wp_remote_request($vid_url));        if ($video_response == 200) {           $video_url = $vid_url;           $video_image_url = 'http://img.youtube.com/vi/'.$video_id.'/hqdefault.jpg';           $tmp = download_url($video_image_url);           $file_array = array(                         'name' => basename( $video_image_url ),                         'tmp_name' => $tmp                       );        }     }     $pid = wp_insert_post($new_post);     $vid_thumb = media_handle_sideload( $file_array, $pid );     update_post_meta($pid,'video_thumb',$vid_thumb);      Now this gives me a thumb of 224px/168px so now what I need to do is crop the thumb to 224px/120px knocking off 24px from the top and bottom. Any ideas?


title: add_action on inherit post status

text: I'm trying to use the add_action() hook to run a custom function, but am struggling with the post status. I originally tried using:               add_action('pending_to_publish_portfolio', 'my_function');      (portfolio being my custom post type). This didn't work, so i posted in the official Wordpress Support forum for some help. I was given the following code to get the right transition status'               function bj_test($new, $old) {     print_r($old . '_to_' . $new);     echo '<br>';     print_r($old . '_' . $new);     die();     }     add_action('transition_post_status', 'bj_test', 10, 2);      This gives me 2x status': new_to_inherit new_inherit I've looked at the inherit status and the codex simply states it's used for post revisions. Which makes sense as i'm changing from a pending post to a published post. My problem is, i just don't know how to use this information now. All i'm trying to do is trigger an event when i changed a post from pending to published. According to all the online tutorials i can find it should be as easy as my very first attempt (posted above), but that just doesn't work. Has something changed recently in the way post transitions are handled so all these tutorials are out of date? It's probably really simple for somebody who knows what they're doing, but i'm very new to WP and am running out of options :( any help appreciated.


title: Remove "Edit Link" next to "Publish immediatley" when adding a new post

text: I need to remove the **Edit link** next to **Publish immediately** as I don't want my user to schedule the post. How can I achieve this? Thanks!


title: Wordpress creates unused (unregistered) image sizes

text: I have a news blog created on WordPress. I've set up WordPress to create 3 resized versions of images when uploading them.   * 315x215(featured image with cropping option enabled)   * 620x (to create images by width and set up height automatically depending on image)   * 900x (the same, but larger for gallery)   * original image(it is being saved automatically) When I uploaded some images Ive noticed that WordPress creates   * **300x250 or 216...** ,   * 315x215   * 620x   * 900x images (and of course original) WHY does WordPress create 300x size image??? Recently I removed 900x image option because I don't use it anymore, and after that WordPress does the same but instead of making unused 315x image now it creates additional image of 620 width which is being cropped by height (for example, normal 620x396 and cropped 620x350). Now the 315x images are generated without unused 300x, but the same problem is with 620x. Using WordPress 3.5.1 (but the problem was from the start- 3.4). **Update:** I am using this code in functions.php               add_theme_support('post-thumbnails');        set_post_thumbnail_size(315, 215, true);             add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10, 3 );          function remove_thumbnail_dimensions( $html, $post_id, $post_image_id ) {         $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );         return $html;     }      I've set up WordPress to create 3 resized versions of images by going to Media Options and pointing 315x215 in featured image options and checked Crop featured image option, 620x0 for medium size and 900x0 for large size(the last one 0x0 now, I just dont need it anymore) **Update 2:** Sorry Michael, but You didn't understand. I **WANT** WordPress to automatically generate different sizes of images(315x215 for thumbnails 620x for medium size images). I have adjusted the sizes in Dashboard -> Settings -> Media -> Image Sizes like that. What I **DONT** want WordPress to do is to generate two images with width 620px and different heights (often or always it is 620x350 and 620x348). It's some kind of bug or something I think, an intermediate image left by wordpress after generating sizes. Will really appreciate if someone helps.