An adiitional function fires on my AJAX submit

I am working on a small community style website for my family to use. Mainly it is a small version of a social network so my nieces and nephews can have fun with each other. I have set up "freinding" functionality and it works fine. But when I respond to a friend request an additional ajax function is fired. My AJAX function works and updates the database, but fails to send an email notification whic I think is due to the additional ajax function being fired. After submitted the response (accept or ignore) FireBug shows my AJAX function has been moved temporarily - I see a 302 Moved Temporarily error. The just underneath it an additional GET request fires for the user I am logged in as. The Headers looks something like this in FireBug:               Cache-Control   no-cache, must-revalidate, max-age=0     Connection  Keep-Alive     Content-Type    text/html; charset=UTF-8     Date    Tue, 27 Nov 2012 20:51:46 GMT     Expires Wed, 11 Jan 1984 05:00:00 GMT     Keep-Alive  timeout=10, max=29     Last-Modified   Tue, 27 Nov 2012 20:51:46 GMT     Pragma  no-cache     Server  Apache     Transfer-Encoding   chunked     Vary    Accept-Encoding     X-Pingback  http://obeliskwebdesign.com/sandbox/family-site/xmlrpc.php      I am not sure what this additional function is or why it fires. I have several other AJAX functions in the site which work fine and have no additional functions firing after them so I am at a bit of a loss here. If anyone can shed some light on what may be the cause of this, or if it could be causing my email notification to not fire please let me know. Thanks! \---- EDIT --------------------------------------------------------- My AJAX function:               //ajax for friend response submission     jQuery('.friend-request-response').click(function(event){         event.preventDefault();         var id = $(this).attr('rel');         var form = jQuery( 'form#friend-response-form-'+id ),             friend_request_response_nonce = form.find( 'input[name="friend_request_response_nonce"]' ).val(),             request_id = form.find( 'input[name="request_id"]' ).val(),             userid = form.find( 'input[name="userid"]' ).val(),             friend_id = form.find( 'input[name="friend_id"]' ).val(),             status = form.find( 'input[name="status"]' ).val();              jQuery('div#request-' + id + 'ul').hide('slow');         jQuery.post(             UiAjax.ajaxurl,             {                 action : 'friend_request_response_action',                 friend_request_response_nonce : friend_request_response_nonce,                 //other parameters                 request_id : request_id,                 userid : userid,                 friend_id : friend_id,                 status : status             },             function( response, data ) {                 var new_status = ucFirst( status );                 jQuery('div#request-' + id).html('<p>' + new_status + '</p>').show('slow');             }         );         return false;            });


How to merge two Wordpress themes?

I have a project in which I want to merge two wp themes, I have two themes in which one has a great interface i want to use this interface and second theme has a good functionality so I want to use that fuctionality with first theme, but I have no idea about this, can it be possible??? if yes how can I achieve this provide some refrence.


WP_Query returns random number of posts

There's a file called `inform.php` included in `index.php`, `single.php` and `single-news.php` with the below query in it:               <?php         $arr = array('cat' => '12837', 'posts_per_page' => '22');         $query1 = new WP_Query($arr);         while($query1->have_posts()) : $query1->the_post();     ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail("icon-40", array('class' => 'right icon-40')); ?><?php /*<?php echo text_excerpt(get_the_title(), 67); ?>*/ ?>
     <?php         endwhile;         wp_reset_postdata();     ?>      It returns exact 22 number of posts in `index.php` and `single.php` but in `single-news.php` it returns only **one** post. There is no difference between `single.php` and `singel-news.php` except styling and displaying some custom fields. Also I checked for `wp_reset_postdata();` to be considered after each custom query I wrote, but yet there is that strange result. Single news template will load by this function:               function custom_cat_single_file($single_template) {       global $post;        if ( in_category( 'news' ) && !in_category('mac-game')) {           $single_template = dirname( __FILE__ ) . '/single-news.php';       }       return $single_template;     }     add_filter( "single_template", "custom_cat_single_file" );      **Update #1** Reformatted `var_dump($query1->request);`               string(476) "SELECT SQL_CALC_FOUND_ROWS wp_posts.id      FROM   wp_posts             INNER JOIN wp_term_relationships                     ON ( wp_posts.id = wp_term_relationships.object_id )      WHERE  1 = 1             AND ( wp_term_relationships.term_taxonomy_id IN (12837) )             AND wp_posts.post_type = 'post'             AND ( wp_posts.post_status = 'publish'                    OR wp_posts.post_status = 'private' )             AND wp_posts.post_date >= '2014:03:21 00:00:00'             AND wp_posts.post_date < '2015:03:21 00:00:00'      GROUP  BY wp_posts.id      ORDER  BY wp_posts.post_date DESC      LIMIT  0, 22"      I've a `pre_get_post` hook but I don't think it affects something.               function post_in_page( $query ) {       // not an admin page and is the main query       if (!is_admin() && $query->is_main_query()){         if(is_category()){           $current = get_query_var('cat');           $cat = get_category ($current);           if($cat->slug != 'news')             $query->set('posts_per_page', 25);         }       }     }     add_action( 'pre_get_posts', 'post_in_page');      **Update #2** As @s_ha_dum noticed about dates, I didn't found any hooked function however I didn't go deep in all plugins files. So I ended up with modifying `WHERE` clause of query:               function so__weird()     {       function filter_where( $where = '' ) {         $where = preg_replace("/ AND\s+wp_posts\.post_date.*?wp_posts\.post_date.+[^'].*?'/s", '', $where);         return $where;       }       add_filter( 'posts_where', 'filter_where' );     }      and calling `so__weird()` at the needed place.


Why is it defaulting to "uncategorized" even after I select a custom taxonomy

I have created a custom taxonomy and configured it to work like a category. The taxonomy shows up fine on the admin, but when I create a post, it is then placed in the default `uncategorized` category. I'm not sure why this is happening. Am I doing something wrong? Any suggestion? My function is:               function register_taxonomy_test() {          $labels = array(          'name' => _x( 'test', 'test' ),         'singular_name' => _x( 'test', 'test' ),         'search_items' => _x( 'Search test', 'test' ),         'popular_items' => _x( 'Popular test', 'test' ),         'all_items' => _x( 'All test', 'test' ),         'parent_item' => _x( 'Parent test', 'test' ),         'parent_item_colon' => _x( 'Parent test:', 'test' ),         'edit_item' => _x( 'Edit test', 'test' ),         'update_item' => _x( 'Update test', 'test' ),         'add_new_item' => _x( 'Add New test', 'test' ),         'new_item_name' => _x( 'New test', 'test' ),         'separate_items_with_commas' => _x( 'Separate test with commas', 'test' ),         'add_or_remove_items' => _x( 'Add or remove test', 'test' ),         'choose_from_most_used' => _x( 'Choose from the most used test', 'test' ),         'menu_name' => _x( 'test', 'test' ),     );          $args = array(          'labels' => $labels,         'public' => true,         'show_in_nav_menus' => true,         'show_ui' => true,         'show_tagcloud' => false,         'show_admin_column' => true,         'hierarchical' => true,              'rewrite' => array(              'slug' => 'little',              'with_front' => true,             'hierarchical' => true         ),         'query_var' => true     );          register_taxonomy( 'test', array('post'), $args );     };      EDIT: @Charles - yes I have added the code below sorry/. forgot to mention it here.               add_action( 'init', 'register_taxonomy_test' );      @OTTO - it shows up in the uncategorized "category" even after I make sure I have checked on a custom taxomony I created EDIT #2 Ok so I decided to go with regular categories and not custom taxonomies. For any one interested why a new post with custom taxomony defaults to un- categorized, is because it is linked to the post type which is "post". So you must also enable a custom post type "register_post_type()" that is linked to your custom taxonomies that will act as categories.


Using post_class to style posts indivdually

I have a homepage on which I want to display the latest post different from the other posts. I haven't used `post_class` and I am not sure how to. Would I be able to achieve what I want using `post_class`?


custom login page redirect to logged in user profile page

If I click on **sign in** then it should go to the login page. The issue is that when I put the link then it goes to `redirect_to` home page, but I want to go on user profile page instead. I don't want to use a plugin to redirect to profile page after login. I have code for user profile - `<a href="<?php echo bp_loggedin_user_domain(); ?>/profile/edit/"><span>My Profile</span></a>` And i want to put this link into `<input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" />` Is this possible? Are there other suggestions?


Why is my custom widget breaking another one?

The first plugin is somehow breaking the second one (the content of the second one doesn't show up at all): **plugins/featured-images.php:**               <?php     /* Plugin Name: Featured Jobs     Plugin URI: [Enter your website URL]     Description: [Enter brief description of plugin]     Version: [Enter version number of plugin (probably 1.0)]     Author: [Enter your name]     Author URI: [Enter your website URL]     */     class Featured_Jobs extends WP_Widget {              /**          * Register widget with WordPress.          */         public function __construct() {             parent::__construct(                 'featured_jobs', // Base ID                 'Featured Jobs', // Name                 array( 'description' => __( 'A Foo Widget', 'text_domain' ), ) // Args             );         }              /**          * Front-end display of widget.          *          * @see WP_Widget::widget()          *          * @param array $args     Widget arguments.          * @param array $instance Saved values from database.          */         public function widget( $args, $instance ) {             extract( $args );             $title = apply_filters( 'widget_title', $instance['title'] );                  echo $before_widget;             if ( ! empty( $title ) )                 echo $before_title . $title . $after_title;         ?>
           <?php // Create and run custom loop             $custom_posts = new WP_Query();             $custom_posts->query('post_type=jobs&posts_per_page=8');             while ($custom_posts->have_posts()) : $custom_posts->the_post();           ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
           <?php endwhile; ?>
See All Positions >>

              <?php                  echo $after_widget;         }              /**          * Sanitize widget form values as they are saved.          *          * @see WP_Widget::update()          *          * @param array $new_instance Values just sent to be saved.          * @param array $old_instance Previously saved values from database.          *          * @return array Updated safe values to be saved.          */         public function update( $new_instance, $old_instance ) {             $instance = array();             $instance['title'] = strip_tags( $new_instance['title'] );                  return $instance;         }              /**          * Back-end widget form.          *          * @see WP_Widget::form()          *          * @param array $instance Previously saved values from database.          */         public function form( $instance ) {             if ( isset( $instance[ 'title' ] ) ) {                 $title = $instance[ 'title' ];             }             else {                 $title = __( 'New title', 'text_domain' );             }             ?>
             <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?>              <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
             <?php          }          } // class Foo_Widget          // register Foo_Widget widget     add_action( 'widgets_init', create_function( '', 'register_widget( "featured_jobs" );' ) );      **plugins/theme/theme.php:**               add_action( 'widgets_init', create_function( '', 'register_widget(   "px_reviews_widget" );' ) );               class Px_Reviews_Widget extends WP_Widget {              /**          * Register widget with WordPress.          */         public function __construct() {             parent::__construct(                 'px_reviews_widget', // Base ID                 'Game - Reviews', // Name                 array( 'description' => __( 'Game - Reviews', 'text_domain' ), ) // Args             );         }              /**          * Front-end display of widget.          *          * @see WP_Widget::widget()          *          * @param array $args     Widget arguments.          * @param array $instance Saved values from database.          */         public function widget( $args, $instance ) {                  if ( !is_singular('games')) {                  return;             }                  extract( $args );             $title = 'Reviews';//apply_filters( 'widget_title', $instance['title'] );                  echo $before_widget;             if ( ! empty( $title ) )                 echo $before_title . $title . $after_title;             //echo __( 'Hello, World!', 'text_domain' );                   $templates = array();                  $templates[] = "game-reviews.php";                   // Backward compat code will be removed in a future release         locate_template($templates, true);                        echo $after_widget;         }              /**          * Sanitize widget form values as they are saved.          *          * @see WP_Widget::update()          *          * @param array $new_instance Values just sent to be saved.          * @param array $old_instance Previously saved values from database.          *          * @return array Updated safe values to be saved.          */         public function update( $new_instance, $old_instance ) {             $instance = array();             $instance['title'] = strip_tags( $new_instance['title'] );                  return $instance;         }              /**          * Back-end widget form.          *          * @see WP_Widget::form()          *          * @param array $instance Previously saved values from database.          */         public function form( $instance ) {             /*             if ( isset( $instance[ 'title' ] ) ) {                 $title = $instance[ 'title' ];             }             else {                 $title = __( 'New title', 'text_domain' );             }             */             ?>             This widget only show on Game single page             <?php              /*             ?>
             <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?>              <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
             <?php              */         }          }      What could be the cause?


get_the_post_thumbnail wordpress 3.5

For some reason the following isn't loaded anymore in wordpress 3.5. Does anyone know how to fix the `get_the_post_thumbnail()` ? I'm using the follow code:               echo "
";     echo "";     echo "
".get_the_post_thumbnail($post->post_id, 'thumbnail', $attr)."
";     echo "
".$post->post_title."
";     echo "";     echo "
";


Post Bulk Update

Is there any way to update all the posts at a time through query or through admin panel. For an example i am having an 1000 posts, how to update all the posts at a time. Thanks.


Removing translation textdomain

I am working on a plugin for myself, so, it's totally useless to load textdomain. But most of codes I copied from others are using the `__(' ','')` I copied the codes from several plugins. So, even if I load textdomain, it's going to be useless as well,posibly slow down the performence. My question is-- What's going to happen when WP read those `__(' ','')` without a textdomain loaded ? Will it become a problem?


Woocommerce "out of stock" message

By default the "out of stock" message is being output as a `<p>` tag after the product description. How can I change the location where this message is being rendered?


Cafe Food Menu upload

A funky cafe changes their menu every month, and they're not comfortable with using the default Wordpress editor to make a Wordpress page look the same as their Word doc. Example word doc here. Can you think of a way to get this menu to display nicely as HTML inside their website?


Filter Hook Returning Blank When Used Twice

This is a pretty lengthy question, so bare with me. In a plugin I've written that allows users to easily create new meta boxes, I have a function that uses a switch() to return the appropriate HTML for the kind of meta field being added. The function looks like this:               // displays the requested field type     function ecpt_render_field($field, $meta) {              global $wp_version, $post, $ecpt_options;              switch($field['type']) :                  case 'text' :                 $field_html = '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . stripslashes($meta) . '" size="30" style="width:97%" />
' . __(stripslashes($field['desc']));                 break;                      /*****************************************************************                 * lots of case statements here have been removed for this example                 ******************************************************************/              case 'checkbox' :             $field_html = '<input type="checkbox" name="' . $field['id'] . '" id="' . $field['id'] . '" ' . checked(!empty($meta), true, false) .'/>
' . __(stripslashes($field['desc'])) . '
';             break;                    endswitch;                if(has_filter('ecpt_fields_html')) {             // this adds any addon fields (from plugins) to the array             $field_html = apply_filters('ecpt_fields_html', $field, $field_html, $meta);         }                 // return the final field         return $field_html;     }      $field is an array that contains all of the information for the field (id, type, class, etc). $meta is the value stored in the post meta. At the end of the function there is a check for the existence of the "ecpt_fields_html" filter. This is a filter I've setup to allow additional meta field types to be registered via other plugins. An example function that registers additional field types (successfully), looks like this:               // generates the HTML for the additional fields     function ecpt_bonus_fields_html($field, $field_html, $meta) {              switch($field['type']) :                  case 'taxonomy' :                 // returns the options html for select fields                 $field_options = ecpt_get_field_options($field, $meta);                 $field_html =  '<select name="' . $field['id'] . '" id="' . $field['id'] . '">' . $field_options . '</select>
' . $field['desc'];                 break;                  case 'separator' :                 $field_html = '
';                 break;                            case 'colorpicker' :                 if (empty($meta)) $meta = '#';                 $field_html = "<input class='ecpt-color' type='text' name='" . $field['id'] . "' id='" . $field['id'] . "' value='" . $meta . "' size='8' />                         " . __('Select a color') . "                         " . __('Hide Picker') . "

";                 break;                  default :                 $field_html = $field_html;              endswitch;              return $field_html;     }     add_filter('ecpt_fields_html', 'ecpt_bonus_fields_html', 10, 3);      This function to register extra field types works exactly like the first one. Now, let's say that I have the the function above activated in an add-on plugin (everything works fine), and then I setup a second plugin that has a second function that registers more field types (this new second function is structured exactly like the filter function above). If I do this, both of the filter functions that register new field types fail completely. They don't throw any errors, but the "return $field_html;" statement simply returns nothing at all. The second filter function looks like this:               // generates the HTML for the additional fields     function ecpt_sample_fields_html($field, $field_html, $meta) {              switch($field['type']) :                  case 'textblock' :                 $field_html = 'this should be shown in the metabox, but is not';             break;                        endswitch;              return $field_html;     }     add_filter('ecpt_fields_html', 'ecpt_sample_fields_html', 10, 3);      Both filter functions work perfectly when the other is not active, but if both are active, then the *$field_html = apply_filters('ecpt_fields_html', $field, $field_html, $meta);* in the very first function results in nothing, just blank. Alright, now is where it gets a little stranger. I have an almost identical set of functions / filters setup that display the labels for the field types in the meta box. They work perfectly fine. In the core plugin, the function that setups the label for each field looks like this:               // run the label through a filter. This allows us to modify/remove the label for any field type     function ecpt_field_label($field) {         $label = '' . __(stripslashes($field['name'])) . '';         // the ecpt_field_label_filter allows the field label output to be altered for any field type         if(has_filter('ecpt_field_label_filter')) {             $label = apply_filters('ecpt_field_label_filter', $label, $field);         }         return $label;     }      And the filter function that allows the label HTML to be changed for fields registered with other plugins looks like this:               // modify the labels for the bonus fields (if needed)     function ecpt_bonus_fields_labels($label, $field) {              if($field['type'] == 'separator') {             // removes the label for the separator field             return;         }         if($field['type'] == 'header') {             return '
' . $label . '
';         }         return $label;     }     add_filter('ecpt_field_label_filter', 'ecpt_bonus_fields_labels', 10, 2);      This works perfectly fine, even when I setup a _second_ label filter function (remember, setting up the second function for the field types is what caused it to break). So my second filter function for the labels looks like this:               // modify the labels for the bonus fields (if needed)     function ecpt_sample_field_labels($label, $field) {              if($field['type'] == 'textblock') {             return '' . $label . '';         }         return $label;     }     add_filter('ecpt_field_label_filter', 'ecpt_sample_field_labels', 10, 2);      The _only_ difference (aside from using switch() and i() statements) is that the filter types filter has 3 parameters and the field labels filter has 2. At least that is the only difference I can find. Below are screenshots that illustrates the issue. ![Only the first filter function is active, used to register the Color field](http://i.stack.imgur.com/VJvri.jpg) ![Both filter functions are active. The field labels work, but not the input fields](http://i.stack.imgur.com/VYZlW.jpg)


querying on custom meta fields and sorting them by custom meta

I have event posts with multiple custom date and time fields. To pull all the events happening this week, I am querying on the different date fields. Here is my code:               $today=date("Y-m-d");     $nextweek= date("Y-m-d", strtotime("+7 days"));          $args2 = array(          'post_type' => 'post',     'meta_query' => array(     'relation' => 'OR',          array(     'key' => 'date2',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN'     ),     array(     'key' => 'date3',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN'     ),     array(     'key' => 'date1',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN'          )     )     );     $query2 = new WP_Query( $args2 ); ?>      When I put var_dump($query2->request) after this, I get the following string:               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID      FROM wp_posts      INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)      INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)      INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id)      WHERE 1=1 AND wp_posts.post_type = 'post'      AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')      AND (        (wp_postmeta.meta_key = 'date2' AND CAST(wp_postmeta.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')        OR (mt1.meta_key = 'date3' AND CAST(mt1.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')        OR (mt2.meta_key = 'date1' AND CAST(mt2.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')      )      GROUP BY wp_posts.ID      ORDER BY wp_posts.post_date DESC LIMIT 0, 10      This is pulling the correct posts, but now I want to sort the results on the date1 field. I tried this and it isn't working. I end up with all of the events posted, and not sorted either. I've also tried the 'meta_value' for orderby without luck. The values in the date1 field are in date format YYYY- MM-DD Any help would be appreciated.               $args2 = array(     'order' => 'ASC',     'meta_key' => 'date1',     'orderby' => 'meta_value_num',     'post_type' => 'post',     'meta_query' => array(     'relation' => 'OR',          array(     'key' => 'date2',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN'     ),     array(     'key' => 'date3',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN'     ),     array(     'key' => 'date1',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN',          )     )          );          $query2 = new WP_Query( $args2 ); ?>      When I put var_dump($query2->request) after this I get:               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID      FROM wp_posts      INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id      INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)      INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id)      INNER JOIN wp_postmeta AS mt3 ON (wp_posts.ID = mt3.post_id)      WHERE 1=1      AND wp_posts.post_type = 'post'      AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')      AND (wp_postmeta.meta_key = 'date1'        OR (mt1.meta_key = 'date2' AND CAST(mt1.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')        OR (mt2.meta_key = 'date3' AND CAST(mt2.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')        OR (mt3.meta_key = 'date1' AND CAST(mt3.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')      )      GROUP BY wp_posts.ID      ORDER BY wp_postmeta.meta_value+0 ASC LIMIT 0, 10


Wordpress won't let me use a page slug of 'feed'

I want to make a custom feed page* with the slug of 'feed', but when I try to save, Wordpress changes it to 'feed-2'. Is there a way I can force Wordpress to let me use a slug of feed—or, if it's better practice, to hook my custom feed template* into the default Wordpress RSS feed generator? If the latter, what code do I need to substitute my own feed template for the default? * The custom feed template I'm using is based on the useful code here: http://digwp.com/2011/08/custom-feeds/


Best way to categorize/populate a magazine style layout

I'm taking the reigns of an existing Wordpress site that has a magazine-style home page with sections for featured articles, upcoming events, different categories of articles, etc. Currently, these fields are populated with a hodgepodge of different taxonomy - the page uses categories, tags, **and** sticky posts to correctly populate the content. Using all three seems a big excessive. What's the best method of categorizing and populating a magazine style layout. Just being driven by the category of the article, etc? Or are their plugins/methods for the editors to directly choose specifically which article appears where.


How to load previous or next attachment with jquery ?

When i am on the single.php page, i show the first image attachment. then i would like to load the next (and previous) image attachments without reloading the page. so in single.php i started with this to retrieve an array with the images html:               <?php $args = array('post_type' => 'attachment', 'post_mime_type' => 'image', 'order'=> 'ASC', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );            $attachments = get_posts($args);       if ($attachments) {                 foreach ( $attachments as $attachment ) {                      $my_image = wp_get_attachment_image($attachment->ID, large) );              $attachments_list[] = $my_image;         }       }       reset($attachments_list);       $first_image = current($attachments_list);       echo $first_image;      ?>      and then in the script.js file i would like to get the value of my php array $attachments_list to do something like this :               $(document).ready(function(){         var count = attachments_list.lenght();         var init = 0;         var current = init;              if (count > 1) {             $('#next-img').click(function() {                 if (current+1 < count) {                     current++                 } else if (current+1 === count) {                     current = init;                 }                 $('#image-container').html(attachments_list[current]);             });             $('#previous-img').click(function() {                 if (current > init) {                     current--                 } else if (current === init) {                     current = count-1;                 }                 $('#image-container').html(attachments_list[current]);             });         }     });      how can i retrieve the value of the php $attachments_list array to attachments_list inside the script.js file ? Json maybe ? thanks for your attention


Ajax form filter post by custom fields

I'm currently working on a site where users can search for apartments. I have a custom post type for the apartment posts, which contain several custom fields. I have a page where i list all of the apartments. What i want to do is have a form, containing check boxes, drop-downs and radio button, where the user can filter apartment posts by custom fields. For example by price or size. So when the users clicks on an check-box for example i want the result field to be refreshed. Much like this one product-sort. I know this can be done via the query, but i would like an AJAX function to filter the post without reloading the entire page. I have tried Ultimate WP Query Search Filter plugin but it didn't work that well. I have done a lot of searching to find a solution, but i'm not a ajax/javascript master. So can you point in some direction, maybe with some code to help me out?


Single Page View for Paginated Posts

Okay, so you know how you can break up a wordpress post by inserting the next- page/page break quicktag. Then, using the wp link pages function in your template, wordpress will generate page 1, 2, 3, etc. links for your now paginated post. Great. But is there any way to put the post back together again? Think about all the online magazines and newspapers that break their articles into pages and then offer some variation on a "single page view." Can you do that with Wordpress? I spent the whole weekend trying to google a solution and came up with exactly nothing.


Is there a way to prevent a function/method from being called outside a specific hook?

I would like to make function only callable by a specific action, in this case the `register_activation_hook()` function. How can I do this?


Is there a Image Gallery which will load all my posted Images like twitter's image grid?

Many of my wordpress posts have images in them for my personal blog. I have been searching for a good way to display all of the images from all of the posts in a grid layout on a page. Similar to the twitter grid layout seen here. I have seen Next Gen Gallery, and was wondering if there is a way not just images from the current post, but ALL of the images from all posts into a collecting on one page. Thanks


split searchresults into different topics?

How could I split the searchresults into topics. I have e.g. three Topics - cars | computers | culture all are "custom post types" . Now a user searches for term "speed" in the searchbox and the resultpage would be something like this:               cars ---           2 Posts with "speed" in Cars.     searchresults          computers ---          10 posts with "speed" in Computers     searchresults          culture ---          0 nothing found for "speed" in Cutlure.     searchresults      any way to make this work? Need different loops I guess? thank yoU! AD


How to get cropped thumbnail source for custom post type

I need thumbnail image url with size 148*148px. I using custom post type for testimonials. I need just the image source like http://example.com/demoimage.jpg. It is possible to get cropped image source. 'add_image_size' doesn't solve my problem. I have some classes and some data attribute in my <img> tag. Please help Thank You


Replacing global wp_query

I have a site that uses a custom query to search for posts by country. The search results come back fine, but the pagination at the bottom reflects the total number of posts in the site, instead of the total number of posts in the search results. The plug in that manages this uses global $wp_query to determine the number of posts, instead of the custom query. By default, it works like this:               function wp_page_numbers($start = "", $end = "")     {         global $wp_query;         global $max_page;         global $paged;         if ( !$max_page ) { $max_page = $wp_query->max_num_pages; }         if ( !$paged ) { $paged = 1; }              $settings = get_option('wp_page_numbers_array');         $page_of_page = $settings["page_of_page"];         $page_of_page_text = $settings["page_of_page_text"];         $page_of_of = $settings["page_of_of"];              $next_prev_text = $settings["next_prev_text"];         $show_start_end_numbers = $settings["show_start_end_numbers"];         $show_page_numbers = $settings["show_page_numbers"];              $limit_pages = $settings["limit_pages"];         $nextpage = $settings["nextpage"];         $prevpage = $settings["prevpage"];         $startspace = $settings["startspace"];         $endspace = $settings["endspace"];              if( $nextpage == "" ) { $nextpage = ">"; }         if( $prevpage == "" ) { $prevpage = "<"; }         if( $startspace == "" ) { $startspace = "..."; }         if( $endspace == "" ) { $endspace = "..."; }              if($limit_pages == "") { $limit_pages = "10"; }         elseif ( $limit_pages == "0" ) { $limit_pages = $max_page; }      I tried modifying it to this:               if ($gallery_query){ $page_query=$gallery_query; }else {$page_query=$wp_query;}         global $max_page;         global $paged;         if ( !$max_page ) { $max_page = $page_query->max_num_pages; }         if ( !$paged ) { $paged = 1; }      But that returns no pages. Ideally, I should replace the $wp_query value with the $gallery_query value, but I don't know how. The obvious `$wp_query = $gallery_query` doesn't work. Any suggestions? Thanks! ty


Page title in post query

How do i add the current post/page title in a post query? I've tried this, doesn't work:               query_posts( 'posts_per_page=10category_name=&' . $post->post_title); if (have_posts()) : while (have_posts()) : the_post();


wp_rewrite not working on third level url

I have the following code :               global $wp;             $wp->add_query_var('akey');             $wp->add_query_var('sort');             $wp->add_query_var('paged');             add_rewrite_rule('^activate/([^/]*)/?','index.php?pagename=activate&akey=$matches[1]','top');             add_rewrite_rule('^users/$','index.php?pagename=users','top');             add_rewrite_rule('^users/most-active/?','index.php?pagename=users&sort=mostactive','top');             add_rewrite_rule('^users/most-active/paged/([^/]*)/$','index.php?pagename=users&sort=mostactive&paged=$matches[1]','top');             add_rewrite_rule('^users/recent/?','index.php?pagename=users&sort=recent','top');             add_rewrite_rule('^users/recent/paged/([^/]*)/$','index.php?pagename=users&sort=recent&paged=$matches[1]','top');             add_rewrite_rule('^users/oldest/?','index.php?pagename=users&sort=oldest','top');             add_rewrite_rule('^users/oldest/paged/([^/]*)/$','index.php?pagename=users&sort=oldest&paged=$matches[1]','top');             add_rewrite_rule('^users/by-username/?','index.php?pagename=users&sort=byusername','top');             add_rewrite_rule('^users/by-username/paged/([^/]*)/$','index.php?pagename=users&sort=byusername&paged=$matches[1]','top');      the problem is the following users/recent/ works while users/recent/paged/number/ does not work Any ideas ? Thanks


Theme my Login plugin, how to update fields

I'm using the Theme my Login plugin for a client project and I'm having trouble updating profile fields once a user has been registered; I followed the instructions here but they didn't seem to have any effect. If anyone could shed some light on it that would be great. This is my current code; `register-form.php`               <p>         <input           type="text"           name="phone_number"            id="phone_number<?php $template->the_instance(); ?>"            class="input"            value="<?php $template->the_posted_value( 'phone_number' ); ?>"            size="20"            tabindex="20"            placeholder="Phone Number"         />     </p>      `profile-form.php`               <p>         <input            type="text"            name="phone_number"            id="phone_number"            value="<?php echo esc_attr( $profileuser->phone_number ); ?>"            class="regular-text"            placeholder="Phone Number"         />     </p>      `theme-my-login-custom.php`               function tml_user_register( $user_id ) {             // Phone Number             if ( !empty( $_POST['phone_number'] ) )                 update_user_meta( $user_id, 'phone_number', $_POST['phone_number'] );     }     add_action( 'user_register', 'tml_user_register' );


Advanced Custom Fields: how do I check to see if a value is set in an field?

How do I check and see if a value is set in an Advanced Custom Field?


WooCommerce plugin appearance and look

Is it possible to customize WooCommerce plugin the same as my own theme? Im about to finish the theme development, and I was wondering if it's possible to style the WooCommerce Checkout system that it looks the same as the theme Im creating? Thanks


What the mean about 'child theme'?

I have read on codewordpress about this issue. In the article "A WordPress child theme is a theme that inherits the functionality of another theme". And then on stylesheet use import style from parent style `@import url("../twentythirteen/style.css");` Lets take example with twenty thirteen. So I have current conclusion that is good system for fast & simple development. We no need build from scratch and no need update in future because parent update->child also updated. But yesterday, I found that this theme claim is child from twenty thirteen. I check it, but I don't see any import style to twenty thirteen and all php file is all there (I create child theme and just php file from twenty thirteen that have in my theme as example function.php, header, footer, and content-_*). Any wrong with my conclusion about child theme? One other part of my question and for help me for mistake in future. If we use child theme and override some function and style on twenty thirteen. Does in future (when parent theme updated) the function and style still used?? For example: `#article {code override}` Is this id/class will be still used? `function foo(){all code}` Is this function (example) in functions.php will be still used? I hope anyone can explained more to me so It confused will be done. Thanks


calling an additional css and js links for a custom page template

I am building a custom page for portfolio. It will require additional css and jss file for the navigation slider... Since that part is contained in the header.php I decided to take the part I need and hoped it would accept my tags for the external files. Though the link can be seen in the page's head tag, they are not being called. I have looked extensively and all the suggestions points to using wp_enqueue_script() and wp_enqueue_style() which is an overkill. Even trying them does not help and I would like to call the external links only if someone visits the portfolio page and not burden the rest of the site. I will appreciate some insight. www.gransar.net/portfolio


Get cat parameter from admin-ajax

I have a plugin that restricts the categories users can view/edit in the admin. All works fine in WordPress 3.0.1, but as I started testing 3.1 I noticed that the category filter, which is AJAX, allows you to bypass the restrictions. I'm able to filter this out in 3.0.1 because it's submitted via URL parameters. My trouble is being able to $_GET the 'cat' parameter from the new AJAX request. I have tried testing for $_SERVER['HTTP_X_REQUESTED_WITH'], but it doesn't register. I've asked this question on the wp-hackers mailing list, but no one can give me actual code that helps with my predicament.


Basic gallery plugin suggestion

I'm developing a custom wp theme which needs a gallery function. I looked over a few popular gallery plugins, but all of them seem "bloated" with a lot of unnecessary stuff. Do you have any recommendations of a light gallery plugin that allows the admin to upload photos and group them into galleries?


Links from the_tag not working

I am using Wordpress to output different content types here: http://www.africanhealthleadership.org/resources/articles/ Each type of content is tagged accordingly. Users should be able to click on these tags & see all items marked with that tag e.g. clicking the word "Article" above the article name would take someone to a full list of articles. However, the tag links are not working: clicking does nothing. This is the code I used to output the tag and article name. ` ## ### ` When I check the page with Firebug, I see a link such as Is the rel preventing the links from working? Or is it my goofy little brain? Thanks for any ideas, Jeff


Display WordPress commenter nice name

I'm working on a custom plugin that needs to display specifically the commenter's nice name. The codex shows how to do this for the logged in user but not someone else. Can this easily be done?


How to determine, from plugin script, if active theme has
The Post Title

My plugin needs to know if the currently active theme places the post title in H1 heading tags? I'm looking for suggestions on approaches to create script that could discern this. UPDATE: The plugin evaluates the SEO profile of the post content to help the user make improvements for search rankings. Second only to the post title, the h1 tag is one of the most important tags for SEO. However, I don't want to ask the user to include their primary keyword in an h1 heading tag in the post content if the theme already does that (as many do).


Prevent user from editing others posts

I have declared a new post type and it is visible on the admin menu: function create_post_type() {                   register_post_type( 'employer_fm',           array(             'labels' => array(           'name' => _x('Employer', 'Employers'),           'singular_name' => _x('Employer ', 'domain'),         ),             'public' => true,              'capability_type'    => array('employer','employers','adminstrator'),                  'supports' => array('title','author','thumbnail','page-attributes'),             'capabilities' => array(                   'read_post' => 'read_employer',                   'publish_posts' => 'publish_employer',                   'edit_posts' => 'edit_employers',                   'edit_others_posts' => 'edit_others_employer',                   'delete_posts' => 'delete_employer',                   'delete_others_posts' => 'delete_others_employer',                   'edit_others_pages' => 'edit_others_employer_page',                   'read_private_posts' => 'read_private_employer',                   'edit_post' => 'edit_employer',                   'delete_post' => 'delete_employer',                  ),           )         );       }      I have also declared roles:               $result = add_role(             'employer',             __( 'Employer' ),             array(                  'edit_employer'   => true,                 'edit_employers' => true,                 'publish_employer' => true,                 'read_employer' => true,                 'delete_employer'=> true,                 'edit_others_employer' => false,                 'delete_others_employer' => false,                 'edit_others_employer_page' => false             )         );           $role = get_role( 'administrator' );          $role->add_cap( 'edit_employer' );           $role->add_cap( 'read_employer' );           $role->add_cap( 'delete_employer' );           $role->add_cap( 'edit_employers' );           $role->add_cap( 'publish_employer' );       if `'map_meta_cap' => true,` Users can only view and publish posts (including admin) and if it it not set all users can edit all employer type posts. How can I prevent `employer` user types from editing others posts?


Frontend posting - everything saves other than checkboxes?

I have a form on the frontend of Wordpress which is saving all fields except a checkbox array. It displays and saves the correct values if I tick the boxes in the backend post editor, and the ticks show correctly on the front. However ticking a box on the frontend doesnt save! All other fields save correctly from font and back.I have spent a long time trying to figure it out however it doesn't seem to work, any help would be **greatly** appreciated. Here's the code:               $query = new WP_Query( array( 'post_type' => 'property', 'posts_per_page' => '-1' ) );           if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();           if(isset( $_GET['post'] ) ) {         if ( $_GET['post'] == $post->ID ) {             $current_post = $post->ID;             $options = $custom_meta_fields[7]['options'];             $checkboxes = get_post_meta($current_post, 'custom_cgtest', true);     }     }     endwhile; endif;      wp_reset_query();     global $current_post;          if(isset($_POST['submitted']) && isset($_POST['post_nonce_field']) && wp_verify_nonce($_POST['post_nonce_field'], 'post_nonce')) {     $post_information = array(     'ID' => $current_post,     'post_title' => ($_POST['post_title']),     'post_content' => esc_attr(strip_tags($_POST['postContent'])),     'post-type' => 'property',     'post_status' => 'publish',     );              $post_id = wp_update_post($post_information);     if($post_id) {      update_post_meta($post_id, 'custom_cgtest', ($_POST['cbn']));     }     }      In the page:               foreach ($options as $option) {           echo '<input type="checkbox" name="cbn[]" id="'.$option['value'].'"',$checkboxes && in_array($option['value'], $checkboxes) ? ' checked="checked"' : '',' /> ';         echo $option['value'];         }      In functions.php:               array (       'label' => 'Checkbox Group',       'desc'  => 'A description for the field.',       'id'    => $prefix.'cgtest',       'type'  => 'cgtest',       'options' => array (           'one' => array (               'label' => 'Option One',               'value' => 'one'           ),           'two' => array (               'label' => 'Option Two',               'value' => 'two'           ),           'three' => array (               'label' => 'Option Three',               'value' => 'three'           )       )       )      If you require any more code please let me know.


Server-side sorting of posts

I have seen on some websites that you can sort posts server-side by passing in some queries like so: `domain.com/?sort=date` or `domain.com/?sort=name` How would I do this with WordPress posts on a page?


Redirect homepage ( www.sitename.com ) to the latest post

I'm just wondering how I would go about redirecting to the latest post when you go to the web site? Similar to http://gregorywood.co.uk/ Many thanks :) Suleiman


Give a unique ID while saving

I have in my theme custom post types (products) with some meta-boxes. My client asked me, to automaticly give a unique SKU (meta-box) while saving that product. My thought: > Give a random ID => have to check if that ID somewhere else exists OR > > Give the Post-ID => that is just possible after saving once, cuz WP assign > that ID while saving. **@Milo** "additionally, a new post already has an ID before the user saves the post" How can I get the ID before I save the post and put it into that meta box and save it with a new post at once? Thanks


How to use checkbox and radio button in options page?

Call me stupid but I coudn't figure out how to do it. For text input I would just:               <input type="text" name="option_name"  value="<?php echo get_option( 'option_name' ); ?>" />      and then hook it into workdpress using `register_setting()`. I could then get its value thru `get_option('option_name')`. How should I do that with checkboxes and radio buttons?


How do I migrate custom post type data to a new format?

I am renovating an old site that has a messy custom post type. Over the years, it has accumulated redundant fields and taxonomies. I have replaced it with a new CPT that reflects the client's current business logic, and now I need to migrate the old data to the new format. This is the process I have in mind for migrating the post metadata:   1. Add both old and new CPT and related taxonomy definitions to a blank theme.   2. Output meta data and taxonomy terms for a sample of the old posts, and for an example of a new post. Look for patterns, and build up a `$migrationMap` array, where each element is `Relation` object: ### Relation     * `$oldKey`     * `$newKey`     * `function translate( $oldVal ) -> $newVal`     * (optional) `function verify( $oldVal, $newVal ) -> $ok`   3. Dry run: Loop over the old CPT and make sure that all `verify` funtions pass. `var_dump` the output, a translated version, of each post, and make sure it looks good.   4. Do it again, but this time run the outputs through `wp_insert_post` to complete the migration of the CPT data. And then, repeat the process for taxonomies. Has anyones else done this? Does anyone know if there is a simpler / easier way?


unable to access network admin of a blog

I am unable to see it network admin link in a multisite blog. Can anyone tell me how to activate it again? I am logged in as super user. For the main blog I could see, I used to see the network admin link previously for any other blogs too if am logged in as super user but now I am unable to see. check the below images, Before, I can see network for all sites if am logged in as super user ![enter image description here](http://i.stack.imgur.com/IxwEm.png) Now, I cannot see network admin link for any blogs ![enter image description here](http://i.stack.imgur.com/bUGVZ.png)


Where to place landing pages or files inside wordpress?

We have some content that it's outside the wordpress instalation like landing pages, or forms which sometimes must be embedded. I'm wondering where to place them so I don't loose it if I update the wordpress installation or change the theme. I thought about placing it on the wp-content folder, is it a good idea? If not where should I place them?


enqueue and localize script in footer

I have a script which must run in my footer, after some variables are declared. It works if I just put the code directly in my footer file, but I think best practices dictate I should do this via functions.php and wp_localize_script. Unfortunately that doesn't work; the script is always output in the header. Any ideas on where I'm going wrong? Thanks in advance for your help!               add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_front_page_scripts' );          function mytheme_enqueue_front_page_scripts() {          wp_register_script('flowplayer_object',                                 get_bloginfo('stylesheet_directory') . '/_/js/flowplayer/flowplayer-object-creator.js' );               // last 'true' in wp_enqueue_script should force this into footer, right?          wp_enqueue_script( 'flowplayer_object','','',true, true );               $data = array( 'my_stylesheet_path' => __( get_bloginfo('stylesheet_directory') ) );          wp_localize_script( 'flowplayer_object', 'my_data', $data );     }


Show different category galleries without page refresh using Galleriffic and Wordpress

I'm using Galleriffic in a WordPress site to display a gallery of images. The images belong in several different categories, and I want users to be able to filter by category via a submenu without the page refreshing. My basic idea is to use a conditional statement within the wp_query call for each category and link each condition to a different button/link in the category menu. It would default to showing all of the images, but if one of the category buttons was selected, only images of that category would show in the gallery. My Javascript/JQuery/Ajax skills are a bit sub-par, however, and I haven't been able to figure out a good way to implement the menu. I imagine this technique has been used for things other than galleries. Has anyone done something similar?


Is the new WordPress 3.1 admin bar pluggable and how can I extend it?

## How can I extend the functions of the WordPress 3.1 admin bar in my plugins? I am looking for specific hooks and filters to use in adding links or other features to the admin bar. A good example of what has already been done is the Yoast WordPress SEO (Wordpress Plugin). ![alt text](http://i.stack.imgur.com/ZapRm.png) Currently there is no documentation available on extending the admin bar. According to The Codex there are two filters to turn it off or not show it: `no_admin_bar()` & `show_admin_bar()`


Get page link from slug?

Is is possible to get a page's permalink from the slug alone? I'm aware that you can get the page's permalink from the ID using `get_page_link()`:               <a href="<?php echo get_page_link(40); ?>">Map      I'm curious if there is any way to do the same with the slug of a page:               <a href="<?php echo get_page_link('map'); ?>">Map


What is the use case for the "Class" parameter in register_sidebar?

I registered a new sidebar and filled in the `class` parameter (see code), I then dropped in an Archive widget and went hunting for my "testing" class. **Not there**. So what is the class parameter used for. Can I see an example?               register_sidebar(         array(             'name'  => __('Footer Widget One', 'wpbs-framework'),             'id'    => 'footer-01',             'class' => 'testing',             'description'   => __('The first footer area', 'wpbs-framework'),             'before_widget' => '
',             'after_widget'  => '
 ',             'before_title'  => '
',             'after_title'  => '
'         )     );


Making extra parameters optional

I've setup a very specific function and it works well but I'd like to make the parameters optional but I can't get a handle on the regex bit:               add_rewrite_rule('whats-on/([^/]+)/([^/]+)/([^/]+)/?$', 'index.php?page_id=71&event_year=$matches[1]&event_month=$matches[2]&event_day=$matches[3]','top');      `/whats-on/2012/01/25` I'll show all events on this date. `/whats-on/2012/01` goes to 404 but I'd like the parameter to be optional so I can show all January dates and the same for `/whats-on/2012` all dates in year 2012 Any help will gratefully received - thanks


running queries of multiple post types

I am trying to figure out the query I need to build for my project. I've got a little idea but i am getting confused by all the different query methods and I'm not sure which one to use. I have two post types that I need to pull meta data from. First post type is pods_product_grps (PG). This is the post type that will display information for both this post type and the second post type which is product_variants I need to create a sub loop that pulls all the meta data from the product_variants (PV) based on its relationship to the PG. The way the two connect is through a common variable PG:group_id => PV:grp_id So at first I was going to get the current group_id with:               $group_id= get_post_meta(get_the_ID(),'group_id','single');      If the data was in its own table I would run a select * from Pv where grp_id = $group_id but its not. The data is in the meta table with different meta values on each line. So, I am guessing I need to first figure out the post_id associated with the result, then use that in the get_post_meta functions? I'm thinking there is a more direct method of doing this, but I'm not sure what it is. I will need to pull data from 4 meta fields in the PG and 5 from the PV. Each product group has multiple variations, so a Foreach loop will be established, so I need to set this up to make as few database request as possible. If anyone can assist me, I would appreciate it. Thanks I also found this code that I thought could be useful, but I'm not sure what to do with it. I can use this to get the post_id or other data for the subsequent queries maybe?               $meta_query_args = array('key' => 'grp_id',     'value' =>$group_id,     'compate' => 'LIKE')


Ascending order of yearly archives

### Hey there, I stumbled upon this question but I can't seem to contact the author, because I'm still too new here. I'm using this snippet on my `archives.php` page to display my posts sorted by years. It works great, now I want to know how to sort the posts in **descending** order, so that the newest posts are displayed on top.               // get years that have posts     $years = $wpdb->get_results( "SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year DESC" );          foreach ( $years as $year ) {     // get posts for each year         $posts_this_year = $wpdb->get_results( "SELECT post_title FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' AND YEAR(post_date) = '" . $year->year . "'" );              echo '
' . $year->year . '

';         foreach ( $posts_this_year as $post ) {             echo '
' . $post->post_title . '
';         }         echo '
';     }      This is what it looks like at the moment: ![image](http://abload.de/img/bildschirmfoto2014-096aoop.png) Every help is very much appreciated. Thank you from Berlin.


Filter Posts By Tag

I'm trying to filter my posts by category, then further by city. The only way I can think of filter by city is if the admin adds the city to the listed tags and then filtering from there via switch statement. How can I filter posts by a certain tag? Is there a better way to do what I'm doing? My PHP knowledge is intermediate and my Wordpress knowledge is pretty basic. Thanks in advance!


using $wpdb to insert a form into a post

I am wanting to take the following form, and use $wpdb to insert it into a post. I have tried reading the class reference page INSERT rows, but I don't really know what should be referenced. I am not sure how to tell the form to insert the data into a post using $wpdb?               <?php     if (isset($_POST['pickup-form']))     {         // Clean POST data         $demo_input = (isset($_POST['demo-input'])) ? trim((string) $_POST['demo-input']) : '';              // Validate POST data         if ('' === $demo_input)         {             $errors['demo_input'] = __('Demo field is required');         }              // No errors         if (empty($errors))         {             // Save POST data to database, send some e-mails, etc.             $success = TRUE;         }     }     ?>          <?php if ( ! empty($success)) { ?>
Thank you!
          <?php } else { ?>              <?php if ( ! empty($errors)) { ?>             <?php print_r($errors) ?>         <?php } ?>              <form method="post" action="">             <input type="hidden" name="pickup-form">             <input type="text" name="demo-input" value="<?php if (isset($demo_input)) { echo esc_attr($demo_input); } ?>">             <input type="submit">         </form>          <?php } ?>


Load more button

I am trying to make a button that loads more posts with AJAX each time you click it. When I click the button the first time, it'll load 3 new posts, but if I click on it a 2nd or 3rd time it will show the same 3 posts. What am I doing wrong?               //js file          $(document).ready(function() {     $('#load-more').on('click', function() {         var $this = $(this);              $.ajax({             url: '?page_id=90',             type: 'POST',             data: {                 posts_per_page: 3             },             beforeSend: function() {                 $this.text('Loading...');             },             success: function(data) {                 if (data) {                     $('#post-container').append(data);                     $this.text('Load more');                 } else {                     $this.text('No more');                 }             },             fail: function() {                 console.log('error');             }         })       });     });          //php file     <?php     /*     Template Name: AJAX     */     ?>          <?php     $not_in = array();          $pages = get_posts(array(         'post_status' => 'publish'     ));          foreach($pages as $p){         array_push($not_in, $p->ID);         //echo $p->ID.' ';     }          query_posts(array(         'post_type' => 'post',         'posts_per_page' => $_POST['posts_per_page'],         'post__not_in' =>  $not_in     ));          if (have_posts()) {       while (have_posts()) {         the_post();     ?>

             <?=the_post_thumbnail()?>

 <?=the_title()?>

                     <?=the_content()?>

     <?php         }     }      wp_reset_query();     ?>


display menu with out list tags

Is there a way I can display a menu in my theme that isn't formatted in a list? i just want to display the `<a>` tags without the `<li>` tags. is this possible? theme file:               <?php wp_nav_menu( array( 'theme_location' => 'navigation' ) ); ?>      functions.php:               function register_my_menus() {         register_nav_menus(array('navigation' => __( 'Main Nav' )));     }          add_action( 'init', 'register_my_menus' );      **Edit:** see my answer below, found on Stack Overflow


Inserting data into MagicFields using mysql queries

PART 01: INTRO Hey Stackexchange Greetings from the Snowy alps of Norway I have now tried for two full consecutive days to reverse engineer Magic Fields. Why? Because I am a simple man, and want to import data to my wordpress from an exotic database using CSV (and not programming a php routine, which I don't know nor understand). This has worked for all vanilla Wordpress fields, i.e. post-data, categories and so on. (I used LibreOffice Calc to fine-tune the CSV data, Quest Toad for MySQL import and to create MySQL queries). My designer has designed this entire thing extensively using the Magic Fields plugin. Therefore I have to deal with Magic Fields for the rest of the data that I need to have imported. It's a movie database, so it's the typical meta- data for movies like "productionyear" "producer" "imdblink" "youtubetrailerlink" and so on. My question is that I am hoping to get some insights/ideas/support on how to import these data into the magic fields. I have tried and given up the "magic fields importer", it is not documented and does not give any error messages when I try to import various csv formats. PART 02: Understanding Magic Fields My question is how can I populate(insert) a magic field with data using a mysql query? I have tried to understand what it is Magic Fields is doing when I put some data into a magic field and press save, in the admin-edit-post- frontend. It does a lot of things that I can't seem to re-create. For one it is not enough to insert data into the two places where the data is referenced. wp_postmeta and wp_mf_post_meta. This example post is not sufficient to get the data to "work" i.e. display themselves in wordpress neither in the admin-post-editor nor the front-end for the user:               INSERT INTO `wp_postmeta` (`post_id`,`meta_key`,`meta_value`) VALUES ('474','originaltitle','Die Hard 3');          INSERT INTO wp_mf_post_meta ( meta_id, field_name, field_count, group_count, post_id )  VALUES ( 1100083, 'originaltitle' , 1,1 ,474 );      Also with that meta_id number, Magic Fields creates a number series of 10 for each post, like 7000-7010 and then 8000-8010. I don't understand where it takes those numbers from, and whether they have to be sequential/consecutive. I have found that once entered by the admin-post-editor frontend, I can change the meta-id's in wp_postmeta and wp_mf_post_meta and it still works. But again when I try to create them myself with a SQL query, "it just doesn't work (TM)". After enabling MySQL querylogging and examining the logfile from the MySQL db engine gives and then trying to insert the queries manually (that I can make out from the logs), I still can't make Wordpress "find" the data and display them properly on the page. I can modify the data with mysql queries after I have populated them using the frontend with no problems. Also using the query logs, I found that after I push "SAVE" in the Wordpress frontend-post-editor it does no less than ~780 mysql query lines (regardless if I populate 1 or 10 of my magic fields)! The other thing I have tried is to take a snapshot of the database before and after I have done the post of the magic fields, and then used a diff-tool (various, WinMerge and Notepad++ mainly). I can't understand what it's doing but I THINK it is doing some hidden trickery in wp_term_taxonomy. This is just speculation. Part 03: Conclusion I don't know programming so any practical solution, would be deeply apprechiated. the full query I want to do per post (I have about 800 of these) is here: http://pastebin.com/5cZT3AjA The FULL list of queries that Magic Fields is doing after I push save in the admin-front-end is listed here (which I call the 'robot-at-work'). http://pastebin.com/c2c6qUQt To be sure I have checked three times that it wasn't something extraordinary that it is doing ~780 lines after I push save. I guess if I could find a way to bulk-edit all of my posts, and then have the "robot" i.e. admin-post-edit frontend do the work to create all these lines in the database. I could then change the fields afterwards... But the bulk-editor doesn't show the magic-field editor either. I have twisted my head around this problem 10 times now, and can't twist anymore!


Custom taxonomy permalinks and custom post types

I have set up a custom post type called "Portfolio". I have asigned this custom post type 2 taxonomies, "Clients" & "Service". The portfolio homepage URL is as follows: **www.domain.co.uk/portfolio/** The portfolio single page is as follows: **www.domain.co.uk/portfolio/project-name/** The clients and services though are as follows (client eg): **www.domain.co.uk/client/client-name/** I would like this URL to be as this if possible: **www.domain.co.uk/portfolio/client-name/** When I change the slug for this it completely ruins all my other links. Has anyone any ideas on how to make my custom taxonomy permalinks look like this?


more than one upload directory?

Is it possible to have 2 separate upload directories? One in which the resized images are created/stored and another to where full size original images are uploaded. This would let you use the path to the resized images in your templates thus keeping the path to original full size images hidden from public view (but in a location such that they could still be used to regenerate thumbnails/new image sizes etc).


Redirect non-members to about/intro page

I´m making a small wordpress/buddypress community site where I want all content except an about page to be for members only. I need to do a redirect to the about-page for all non-logged in users. When users log in (from the sidebar) they should end up on the blog/frontpage. How can I achive this? I tried some different members-plugins for buddypress and wordpress but none of them did exactly what I wanted, or didn´t work with other important plugins (like WP-FB-autoconnect). I´m guessing this is pretty easy to do with custom code in the header or functions file. But I´m not really a coder so I would like som help!


Archive Widget - Show selected Category Post title. Sorted by Year

I need to add a widget to the sidebar that shows post titles sorted by year ie: 2011 POST TITLE 1 POST TITLE 2 POST TITLE 3 2010 POST TITLE 1 POST TITLE 2 POST TITLE 3 I was thinking of using the Archive widget to do this, but I dont know how to add the display post title bit and then have the YEAR display as a type of heading for all the posts under that year. This might not be the best way to go... Any thoughts or feedback would be greatly appreciated


Custom role conflict with NextGen-Gallery

* * * EDIT: I've discovered that on a clean install of Wordpress and a reset database, the NextGen plugin appears to return this error with any standard Wordpress role except Administrator. Perhaps I shouldn't have assumed that their code was less likely to have errors than mine. Have contacted their customer support to notify them. If it is confirmed that the error is on their part, I will close/remove this question. * * * I am adding a custom post type to an existing theme where certain users will be able to log in and draft (but not publish) posts to only the custom post type and not interact with anything else on the admin side of the site. I created a custom post type and custom role to go with it. Tested it with both admin and custom role users - so far so good. However, I am having a consistent problem with logging in to the custom role user if NextGen-Gallery is activated.               PHP Notice: Undefined index: nextgen-gallery in [directory_path]\wp-content\plugins\nextgen-gallery\products\photocrati_nextgen\modules\nextgen_admin\class.page_manager.php on line 110      I did the custom role in functions.php like so:               add_role( 'guest_author', 'Guest Author', array( 'post_blog' ) );     function add_theme_caps() {         $role = get_role( 'guest_author');         $role->add_cap('delete_blogs');         $role->add_cap('edit_blogs');         $role->add_cap('delete_blog');         $role->add_cap('edit_blog');         $role->add_cap('upload_files');         $role->remove_cap('publish_blogs');         $role->add_cap('read');         $role->add_cap( 'read_blog' );           }     add_action( 'admin_init', 'add_theme_caps');               /*access for administrator*/          function add_caps_to_roles() {         $role = get_role('administrator');         $role->add_cap('publish_blogs');         $role->add_cap('manage_blogs');          $role->add_cap('publish_private_blogs');         $role->add_cap('publish_blog');         $role->add_cap('upload_files');         $role->add_cap('delete_blogs');         $role->add_cap('delete_published_blogs');         $role->add_cap('delete_blog');         $role->add_cap('delete_published_blog');         $role->add_cap('delete_others_blogs');         $role->add_cap( 'edit_blog' );         $role->add_cap('edit_blogs');         $role->add_cap('edit_private_blogs');         $role->add_cap('edit_published_blogs');         $role->add_cap('edit_others_blogs');         $role->add_cap('read');         $role->add_cap( 'read_blog' );          $role->add_cap( 'read_private_blogs' );          }         add_action( 'admin_init', 'add_caps_to_roles');      The code referred to in the php error (and surrounding lines) are:               107  if ($properties['before']) {     108 global $submenu;     109                      110 $parent = $submenu[$properties['parent']];     111 $item_index = -1;     112 $before_index = -1;      It seems unlikely that such a popular plugin can't work with custom roles, so I assume I am doing something incorrectly. I would be deeply grateful to anyone who can shed light in this issue or maybe point me in a helpful direction. I've driven myself to distraction with it.


Custom Database Table and foreach

I have just created a custom database table and would now like to output every inserted row from it into a predefined format using a foreach statement. Some guidance in this matter would be great. Thanks, Ashley


Checking if a Page has an Associated Term?

I am looking for a way to do some conditional logic on terms associated with a post. Essentially I created my own custom taxonomy for "age groups" and have created three terms for them. Kids, Teens, Adults... In the admin area I want to check the terms which apply to a specific post and on the frontend of the site within my page template I want to show a specific image if the term was associated with the post or a different one if the term was not associated. Does anyone have a solution for this... I thought the following code example would work but it does not. (BTW - what I am doing here is changing the image based off css).               <li id="kids-<?php if ( is_term( 'Kids' , 'age_groups' ) ) {        echo 'on';     } else {echo 'off';} ?>">Kids Programs


What is the http://go2.wordpress.com/ redirect?

Hi I see a wordpress.com blog and on the latest post there is a redirect for the external links via "http://go2.wordpress.com/" redirect. This redirect is obfuscated - on hovering the link it displays a "http://google.com/url?..." redirect instead. What is this and why is it suddenly on this post and not others? Also, I see the redirect type is a 302 - surely this is harmful in terms of SEO for the destination links?


Coding Challenge - JavaScript Easter Egg

As some of you know, there's an Easter Egg hidden in the WordPress post revision system that will display a message from the movie _The Matrix_ if you perform a specific action (if you don't know, I won't spoil the surprise ... poke around with post revisions and see if you can find it). I love Easter Eggs, and this one was a thrilling find when I stumbled upon it. Some people, it seems, aren't really fans, though. I had a client recently discover this Easter Egg go into a panic attack because they thought someone had hacked their blog. They freaked out, flooded my inbox with panicked messages, and maxed out my voice mail quota with "please help!" messages. This leads me to believe that some Easter Eggs should be turned off when WordPress is deployed in certain situations - i.e. for high-maintenance clients. Enter my idea for the first ever WordPress Answers code challenge. ### The winner of this challenge will be awarded an extra 150 reputation points!!! Let's see how skilled you all are at coding ... what would you recommend as the simplest way to remove this Easter Egg from WordPress without hacking core? In other words, using only action hooks, filters, and custom enqueued JavaScript, how would _you_ remove the Matrix Easter Egg? I'll select the "best" answer on October 31st based on:   * The completeness of the answer (a description of the code + example code + screenshots if applicable)   * The simplicity of the code (but remember, shorter isn't always better)   * Full descriptions of how you would install the code on a client site BTW, anyone who merely copy-pastes the solution I already posted on the WP- Hackers mailing list will be automatically disqualified. Let the games begin!


Adding Properties to User Profile and Displaying in List

I have a site that I am migrating to WordPress, and I have a need to add properties that each of the users can edit (e.g., Address, City, State, Business Name, etc), along with some properties that Administrators can edit (IsActive, CanEmail) that wouldn't be displayed to the user. In addition, I need to be able to display the properties in a table (similar to how the plugin, "Members List", displays, but with the custom fields displaying as well. Given these requirements, I had attempted to use a combination of "Cimy User Extra Fields" and "Members List", but the members list grid did not have an option to display the extra fields created by the other plugin. How would you recommend I approach this? EDIT: So I guess the crux of my question is, what is the preferred method to add properties to the User?


Serialize data for wp options

I am creating my first ever plugin, its purpose is to show a notice when some conditions are met, I created the function in jQuery and initially I had to manually edit the file everytime I wanted to change the notice message, so I decided to create a settings page so that the user could edit the message from the front end. Thanks to another member on stackxchange I was able to use wp localize to show the custom message saved in the wp options instead. however, I now find my self having to structure the message being shown such as;               Title          Message          Image      I don't want to create many options so I thought I could try and serialize the data but I dont know how to. In the settings page I have a single textbox for the user to enter the message.               <textarea name="msg_data" id="msg_data" cols="40" rows="10" />     <?php echo get_option('notice_data'); ?>     </textarea>      Here is the localize               $custom_notice = get_option('notice_data', 'default_value');       wp_localize_script( 'lu_ban', 'custom_notice', $custom_notice);      My goal is to create three different inputs, one for title, one for body message and one for image path, can anyone help me out please. THanks


Rename upload images during upload

I want to insert newpost on Front-end of wordpress.   And i want to rename images name during upload **for my code below**   Result like: "MemberUpload_ _dd/mm/yy_ _random_number_[width]x[height].jpg"   (For all size: thumbnail, medium, large, full and custom size) My code upload i'm using for my theme..   Thanks friends verymuch! ;)               // Upload      if (!function_exists('wp_generate_attachment_metadata')){                         require_once(ABSPATH . "wp-admin" . '/includes/image.php');                         require_once(ABSPATH . "wp-admin" . '/includes/file.php');                         require_once(ABSPATH . "wp-admin" . '/includes/media.php');                     }                      if ($_FILES) {                         foreach ($_FILES as $file => $array) {                             if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {                                 return "Upload Err: " . $_FILES[$file]['error'];                             }                             $attach_id = media_handle_upload( $file, $newPost );                         }                        }                     if ($attach_id > 0){                         //and if you want to set that image as Post  then use:                         update_post_meta($newPost,'Uploaded_img_id',$attach_id);                     }     // END upload


Search url wp-rewrite after redirect?

I started using this functions for my "search results"-page.               #SearchRewrite     add_action('generate_rewrite_rules', 'my_rewrite_rules');     function my_rewrite_rules( $wp_rewrite )     {         //RewriteRule ^icerik/(.+)?$ /index.php?s=$1 [QSA,L]         $new_rules = array(         'icerik/(.+).html' => 'index.php?s=' .         $wp_rewrite->preg_index(1) );         $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;     }      Also I added this line to my `.htaccess`-file               RewriteRule ^icerik/(.+)?$ /index.php?s=$1 [QSA,L]      But, whenever I search for something in my search-field the URL doesnt redirect to new URL—even though the new links actually works, I now have two links. Example: This is the rewritten URL: http://www.fatihtoprak.com/icerik/linux.html This is the regular URL: http://www.fatihtoprak.com/?s=linux My question is then: how do I make the rewritten URL display, when a user uses the search-field on my website? **\---UPDATED---** It solved with this Plugin & Class here.. Also i have another question about this. Its like ; when i type a word with Turkish character (İ,Ü,ü,Ö,ö,ğ,Ğ,ş,Ş) it gost 404 Error page :( Do you _have any idea for this ?_ Please type and search **Atatürk ve Cumhuriyet**. Also the query results hook doesn't care with spaces too (:


Wordpress show posts from children terms of a taxonomy term

I was a little hard for me to explain what I'm trying to achieve in the title so I will explain my setup much more detailed here. I tried to find an answer searching here and other sites but couldn't find anything that fits what I'm trying to do. I have a a custom taxonomy called "products_cat" this custom taxonomy has different terms as parent categories: "Electronics", "Computer", "Home Appliances", etc. And then under each of those terms I have more subcategories like under Electronics for example I have "TV", "Audio", "Home Theaters", "MP3",etc. So the thing I'm trying to do is to have within the taxonomy-product_cat.php a code that display the current chosen Taxonomy (suppose Electronics) and then have the titles of all children and the products under each one of those. Thanks.


Declaring an instance of class included in parent theme from child theme functions.php

**Please note this is all "working" - the question is about the best practice and to try and work out why I need to include the PHP file which contains the class in two places for it to work correctly.** I'm working on a simple parent theme to speed up my own development cycle - and have got to the point of testing a simple child theme. I understand that the `functions.php` file for the child is called up before the parent `functions.php` \- which includes all the PHP functions and a class for adding CPT's. I would like to build the CPT from the child theme - I want the parent to contain all the reusable and update-able functionality - but not to pre-build added features into each WP install it's used on. To the code question: I tried to include the class (which is in a separate PHP file) in the child `functions.php` and then instantiate an instance - for example:               require_once TEMPLATEPATH."/library/cpt/cpt.php"; // CPT class ##     $cpt_tree = new Custom_Post_Type( "tree" ); // New CPT - "tree" ##      Reloading the page gives an error:               Fatal error: Class 'Custom_Post_Type' not found in C:\xampp\htdocs\site\wordpress\wp-content\themes\child\functions.php on line 14      So, then I included the same PHP file in the parent `functions.php` file - and it all works - as an experiment I removed the class from the child theme - and it gives the same error. I know this question is lacking lots of code examples - I'm hoping it will ring a bell with someone - or someone who understands more about using Classes will be able to give me some pointers - seems silly to require this file in two places and I'll like to keep the `functions.php` file as clean as possible.


Set up dataTables row delete rather than php and page refresh

I am using the dataTables jQuery plugin to display a table in a wordpress site with data from a custom table and it works well. I have added select check boxes and once a row or rows have been selected and the Delete button is clicked the form calls an external non-wordpress file to delete the rows corresponding to the IDs in the GET (for me to see the data being passed). I know dataTables can do this for me instead but I am not good enough at JS to implement it can anyone help? Also I know I should be using the correct Wordpress $wpdb delete but just found this easier as I am used to doing things outside of wordpress. Here are the pertinent parts of the files I am using.               <form action="<?php echo plugins_url('process/process-form-delete.php',__FILE__) ; ?>" method="get">

                         Select	                         Part Image	                         Part Name	                         Vehicle	                         Seller Type	                         Location	                         Price	                         Date	                         View

                    <?php                         foreach ($rows as $row) {                                 $part_details = pl_get_part_details($row->pl_part_ID);                             ?>                             <tr id="<?php echo $row->my_part_ID; ?>">                             <input name="selector[]" type="checkbox"  value="<?php echo $row->my_part_ID; ?>"  />	                              Stuff Here 	                              Stuff Here 	                              Stuff Here 	                              Stuff Here 	                              Stuff Here 	                              Stuff Here 	                              Stuff Here 	                              Stuff Here
                               <?php                         } ?>

                       <button class="btn btn-primary"  name="submit_mult" type="submit">Delete</button>                       </form>      Process-form-delete.php               <?php     require_once ('../config/dbwpconfig.php');     $number = $_GET['my-parts_length'];     $i=0;     while ($i < $number) {      $data = $_GET['selector'];     if (isset($data[$i])) {         $sql = "DELETE FROM wp_pl_my_parts WHERE my_part_ID =  :partID";         $stmt = $dbh->prepare($sql);         $stmt->bindParam(':partID', $data[$i], PDO::PARAM_INT);           $stmt->execute();               }     $i++;     }     header('Location: ' . $_SERVER['HTTP_REFERER']);     ?>      jQuery to get table to become a datatables table               jQuery(document).ready( function() {       jQuery('#my-parts').dataTable( {         "aaSorting": [[2,'asc']],         "aoColumnDefs": [           { "bSortable": false, "aTargets": [ 0,8 ] }         ]              } );          } );


Remove 'More..' link from RSS feed

I believe this can probably be done with a filter, but haven't been able to find any info so far about it. We are pulling the description node from our RSS feed into some external properties. The problem is that wordpress is adding a Read More link to the feed. We need it to disappear. Here is what a description node currently looks like:               <description>     <![CDATA[     This is the article text......[.....]           Read More …     ]]>     </description>      And what we want it to look like               <description>     <![CDATA[     This is the article text............]     ]]>     </description>      Is this possible to achieve?


How to exclude specific category from the get_the_category(); array

In my loop I've added:               <?php     $categories = get_the_category();     $separator = ' ';     $output = '';     if($categories){         foreach($categories as $category) {             $output .= 'term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.''.$separator;         }     echo trim($output, $separator);     }     ?>      to display all the categories attached to the post here. There is a specific category "Featured" that I want to prevent from displaying. I've tried :               <?php     $categories = get_the_category();     $separator = ' ';     $output = '';     if($categories){         foreach($categories as $category) {     if($category !== 'Featured'){             $output .= 'term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.''.$separator;}         }     echo trim($output, $separator);     }     ?>      But I guess it's a wrong approach since it's not working :) Can anyone please help to achieve my task or at least point me in the right direction? :)


Exporting Custom Taxonomy in plugin

I am writing a plugin which requires exporting custom taxonomies in csv on submit button click. I am using get_terms() to export taxonomies terms. I have written a class file which handle this operation and this file is included on the top of plugin main file. I have searched about it and found out that get_terms() doesn't work until theme function.php is not loaded. So I want to know where should I include the class file. I have checked various hooks also but problem is that if I include it on admin_menu or admin_init hooks then it also outputs some other text of wordpress in exported csv file. So please let me know how should I include the class file.


How do add_action and WP_Query

I am new to WP, semi-new to PHP and new to OOP. 1) How can the WP function `add_action` receive another function as its argument? I know this by itself is not possible. I deliberately broke some code and found that there is actually a native php function `call_user_fun_array`, but how did they make it so that their own function can have a function as its argument? 2) I am doing some plugin tutorial and working with WP_Query, and I just passed an argument directly to WP_Query, as if it was a method and not a class.               I did the following:           $loop = new WP_Query(             array(                 'posts_per_page' => 3             )     );      I would understand if I first instantiated the class and THEN used its method, something like:               $loop = new WP_Query();         $loop->someMethod(                 array(                 'posts_per_page' => 3,                 'category__in' => $cats,                 'orderby' => 'rand',                 'post__not_in' => array($id)             )     );      but how is this possible, that instantiating a class can act as a method as well? (this is more of a general OOP question I guess).


is_singular just won't work

I'm working with wp 3.9.1 and plugin Custom Content Type Manager. I'm creating my own theme. I created a custom type called "aggregato". I also use custom taxonomies. I then created a WP_query for my front-page:               $query = new WP_Query( array(        'post_type' => array ('post', 'aggregato'),        'cat' => '-1',        'posts_per_page' => 12,     ));      The query works, it returns 12 items of both the "post" and "aggregato" post types. Problem is that I want to format them differently. So when I use:               if ( is_singular('aggregato') ) {         //my code     }      Nothing happens. It never enters, that condition is never return true. I don't know what to do anymore. I used `is_singular()`, `is_single()`, `$query->post- type`, `$post->post-type`. Nothing. It just does not work. Anybody has any idea? Any pointers? Please, help! EDIT: the point is that using the codex and looking for answetrs on the web I was always sent to that particular function. It got some time to understand that it was not my case. I think that the question I posted was very clear. I was just, very simply, wrong.


How to get alphabetic listing x other posts, based on first letter post?

Let's say I have a `post` called "Hello World" and I am on that page... Let's say I have different posts like "Haaaa" and "Hoooo".... What I want to do is showing Haaa and Hooo in a different place (let us say the `sidebar`) if this "Hello World" post is being watched... So in the sidebar we get this:               Heeee     Haaaaa     <div class="highlighted active"> Hello World </div>     Hoooooo     Hxxxxx     Hzzzzzz      Where do I start? I guess `<?php wp_get_archives('type=alpha'); ?>`, but how do I get what I want?


How to Create a Directory in a Plugin Folder?

I am creating a plugin in WordPress Version 3.4.2. When the administrator submits a form, a new folder is created inside my plugin directory and a file saved in this new folder. But it gives me the following error:               error : The file has not been created           $dir = plugins_url()."/folder-name/;       The above code returns the following path:               http://localhost/website/wp-content/plugins/abc/folder-name          mkdir($dir, 0777, true);


Possible to add a language file to a plugin without adding .po/.mo files to plugin directory?

I need to add a language file to an existing plugin. Not for translation reasons, but because I'd like to change all occurrences of a certain word to something else. While I could just drop another .po/.mo file set into the plugin's languages directory, I don't want to lose the language file when the plugin is updated. It appears if the plugin used `load_textdomain` to pull files from the `WP_LANG_DIR` in addition to `load_plugin_textdomain` then I could just drop in some .po files into `/wp-content/languages/` and it would work. BuddyPress does it this way, and has instructions for doing the exact sort of thing I'm trying to do: http://codex.buddypress.org/getting- started/customizing/customizing-labels-messages-and-urls/. I've changed every reference to "Group" to "Community". All I have to do is drop the correctly-named files into the `/wp- content/languages/` directory and the files are loaded. The plugin I'm trying to modify is: BuddyPress Group Email Subscription. It loads the languages using this function:               function activitysub_textdomain() {         load_plugin_textdomain( 'bp-ass', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );     }     add_action( 'init', 'activitysub_textdomain' );


Change Twentyeleven Search Form Text

Anyone know how to change the text inside the Twentyeleven search field from "Search" to another choice?


How to determine if it is legal to remove credit link from theme?

I have downloaded a theme and modified few things and customised it according to my needs. Now I want to remove the credits i.e. the back link to the designers site. I want to know if its legal for me to remove that. What are the terms and conditions? Theme is http://diovo.com/links/voidy/ Credits is a backlink: Theme by Niyaz Diovo (with link)


Trailing slash results in an error:

On my website, any trailing slash is resulting in an error. How do I fix this? Example:   * http://example.com/content \- no error   * http://example.com/content/ \- error


Previous & Next on Index Page broken

So the Next/Previuos on my index page is broken. It goes to page 2 but doesn't refresh the posts. It will work on my categories and it will work on my posts but it just won't work on the from page. Here's my code:               <?php get_header();?>     <?php include('from.php'); ?>

             <?php if ($posts) {                     if (get_settings('mistylook_asideid') != "")                         $AsideId = get_settings('mistylook_asideid');                     function ml_hack($str)                     {                         return preg_replace('|
\s*
|', '', $str);                     }                     ob_start('ml_hack');                     foreach($posts as $post)                     {                         the_post();                     ?>                     <?php if ( in_category($AsideId) && !is_single() ) : ?>
                             <li id="p<?php the_ID(); ?>">                                 <?php echo wptexturize($post->post_content); ?>

<?php comments_popup_link('(0)', '(1)','(%)')?>  | <a href="<?php the_permalink(); ?>" title="<?php _e('Permalink:','ml');?> <?php echo wptexturize(strip_tags(stripslashes($post->post_title), '')); ?>" rel="bookmark"># <?php edit_post_link(__('(edit)','ml')); ?>

                     <?php else: // If it's a regular post or a permalink page ?>                     <div id="post-<?php the_ID(); ?>" <?php if (function_exists('post_class')){ post_class(); } else { echo 'class="post"' ;} ?>>

<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e('Permanent Link to','ml');?> <?php the_title(); ?>"><?php the_title(); ?>

                             <?php the_time(__('M jS, Y','ml')) ?> <?php _e('by','ml');?> <?php the_author_posts_link() ?> <?php edit_post_link(__('Edit','ml'), '', ' | '); ?>

                         <?php the_content(__('Continue Reading »','ml')); ?>                         <?php wp_link_pages(); ?>
<?php if (function_exists('the_tags')) the_tags(__('Tags: ','ml'), ', ', '
'); ?>

<?php _e('Posted in','ml');?> <?php the_category(', ') ?> | <?php comments_popup_link(__('No Comments »','ml'), __('1 Comment »','ml'), __('% Comments »','ml'),'',__('Comments Off','ml')); ?>
                     <?php comments_template(); ?>
                 <?php endif; // end if in category ?>                 <?php                     }                      ob_end_flush();                 }                 else include_once(TEMPLATEPATH.'/notfound.php');             ?>
<?php posts_nav_link(' · ', 'previous page', 'next page'); ?>

     <?php get_sidebar();?>     <?php get_footer();?>      I'm using a random theme called MistyLook. I've tried working with it but if I have to go to the core files then im stumped... Any suggestions?