custom post types shortode stays on top of other page contents. Is there a bug?

I have created a custom portfolio post type for my wordpress theme, and I have made a shortcode for it too. But when I create a page and use the shortcode to display limited number of my portfolio items, no matter where in the page I insert my shortcode, the portfolio items always stay on top of other contents, I took a look at the source code of the page and for no reason this shortcode is process before any other code is processed on the page. I even tested it on a post, when the post is viewed on the main blog archive page, the shortcode is processed where I want it to be, but when the article is being viewed as a single article again the shortcode is processed and displayed on top of all the contents of that article or page. here is the code I used for the shortcode:                   add_shortcode( 'portfolios', 'ub_portfolios_sc' );         function ub_portfolios_sc ( $atts ) {         global $post;         $default = array(             'type'         => 'post',             'post_type'    => 'portfolios',             'limit'        => 12,             'order'        => 'ASC',             'orderby'      => 'date',             'status'       => 'publish',             'post_columns' => 'three'         );         $r = shortcode_atts( $default, $atts );         extract( $r );              if( empty($post_type) )         $post_type = $type;              $post_type_ob = get_post_type_object( $post_type );         if( !$post_type_ob )         return '

No such post type ' . $post_type . ' found.

';              $args = array(             'post_type'    => $post_type,             'numberposts'  => $limit,             'post_status'  => $status,             'post_columns' => $post_columns,             'order'        => $order,             'orderby'      => $orderby         );         $posts = get_posts( $args );         if( count($posts) ):             echo '
';             foreach( $posts as $post ) : setup_postdata( $post );             ?>
                 <a href="<?php the_permalink(); ?>" data-largesrc="<?php if ( has_post_thumbnail() ) { echo ub_featured_img_url('portfolio-fullsize'); } else { ?>http://placehold.it/600&text=<?php _e('No Thumbnails', 'une_boutique'); } ?>" data-title="<?php the_title() ?>" data-button="<?php _e('View Project', 'une_boutique'); ?>" data-description="<?php the_excerpt() ?>">                     <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } else { ?>                     <img src="http://placehold.it/320&text=<?php _e('No Thumbnails', 'une_boutique'); ?>" alt="no thumbnails">                     <?php } ?>                 <?php the_title() ?>
             <?php             endforeach; wp_reset_postdata();             echo '
';         endif;     }      and here is how I created the custom post type in the first place:               add_action('init', 'portfolio_register', 0);          function portfolio_register() {          $labels = array(         'name' => _x('Portfolios', 'post type general name'),         'singular_name' => _x('Portfolio Item', 'post type singular name'),         'add_new' => _x('Add New', 'portfolio item'),         'add_new_item' => __('Add New Portfolio Item'),         'edit_item' => __('Edit Portfolio Item'),         'new_item' => __('New Portfolio Item'),         'view_item' => __('View Portfolio Item'),         'search_items' => __('Search Portfolio'),         'not_found' =>  __('Nothing found'),         'not_found_in_trash' => __('Nothing found in Trash'),         'parent_item_colon' => ''     );          $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,         'query_var' => true,         'menu_icon' => get_template_directory_uri() . '/images/sofa.png',         'rewrite' => true,         'capability_type' => 'post',         'hierarchical' => false,         'menu_position' => null,         'supports' => array('title','editor','thumbnail','excerpt'),         'taxonomies' => array('post_tag')       );           register_post_type( 'portfolios' , $args );     flush_rewrite_rules();          set_post_thumbnail_size( 600, 600, true );     }          register_taxonomy("Categories",     array("portfolios"),         array(             "hierarchical" => true,             "label" => __('Categories', 'une_boutique'),             "singular_label" => __('Category', 'une_boutique'),             "rewrite" => true         )     );          add_action("admin_init", "admin_init", 10);          function admin_init(){     add_meta_box("project_date-meta", __('Project Date', 'une_boutique'), "project_date", "portfolios", "side", "low");     add_meta_box("project_client-meta", __('Project Client', 'une_boutique'), "project_client", "portfolios", "side", "low");     add_meta_box("project_link-meta", __('Project Link', 'une_boutique'), "project_link", "portfolios", "side", "low");     }          function project_date(){     global $post;     $custom = get_post_custom($post->ID);     $project_date = $custom["project_date"][0];     ?>     <?php __('Year:', 'une_boutique') ?>
     <input id="project-date" name="project_date" value="<?php echo $project_date; ?>" size="42" />     <?php     }          function project_client(){     global $post;     $custom = get_post_custom($post->ID);     $project_client = $custom["project_client"][0];     ?>     <?php __('Project Client:', 'une_boutique') ?>
     <input id="project_client" name="project_client" value="<?php echo $project_client; ?>" size="42" />     <?php      }          function project_link(){     global $post;     $custom = get_post_custom($post->ID);     $project_link = $custom["project_link"][0];     ?>     <?php __('Project Link:', 'une_boutique') ?>
     <input id="project_link" name="project_link" value="<?php echo $project_link; ?>" size="42" />     <?php     }          add_action('save_post', 'save_portfolio_details');     function save_portfolio_details() {     global $post;          update_post_meta($post->ID, "project_date", $_POST["project_date"]);     update_post_meta($post->ID, "project_client", $_POST["project_client"]);     update_post_meta($post->ID, "project_link", $_POST["project_link"]);      }          add_action("manage_posts_custom_column",  "portfolios_custom_columns");     add_filter("manage_edit-portfolios_columns", "portfolios_edit_columns");          function portfolios_edit_columns($columns){     $columns = array(         "cb" => "<input type=\"checkbox\" />",         "title" => __('Item Title', 'une_boutique'),         "year" => __('Project Date', 'une_boutique'),         "Categories" => __('Categories', 'une_boutique'),         "thumbnail" => __('Item Preview', 'une_boutique'),     );          return $columns;      }          // GET FEATURED IMAGE for it's column     function ub_get_featured_image($post_ID) {     $post_thumbnail_id = get_post_thumbnail_id($post_ID);     if ($post_thumbnail_id) {         $post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id, 'thumbnail');         return $post_thumbnail_img[0];     }     }          function portfolios_custom_columns($column){       global $post;            switch ($column) {     case "year":         $custom = get_post_custom();         echo $custom["project_date"][0];     break;     case "Categories":         echo get_the_term_list($post->ID, 'Categories', '', ', ','');     break;     case "thumbnail":         global $post_ID;         $post_featured_image = ub_get_featured_image($post_ID);         if ($post_featured_image) {             echo '';         }     break;       }     }      Can any tell which part I'm doing wrong?


Console shows ReferenceError: jQuery is not defined, no clue why!

I just installed FirePHP to help with debugging in WP, but for some reason all it shows is ReferenceError: jQuery is not defined. I have some jquery stuff on the page that seems to be working just fine. I have no clue how to figure out why this error message is coming up - can anyone help me?? Thanks!


On Category page, How can I get the category ID?

This might be very basic question, but I can't really get the category ID on category page (actually a category page of custom type post). Filename is `taxonomy-item-category.php` & URL is `http://www.abc.com/cat/food/` I have tried some of the following but not working...               $cur_cat_id = get_cat_id( single_cat_title( "food", false ) );     $cur_cat_id = get_cat_id( single_cat_title( "", false ) );          get_the_category( "food" );      How can I get the category ID on category page?


How to show part of the_content?

i wanna show 20 chars of the_content i tried this but doesn't work for me .               <?php $content = '';     $content = the_content();     $count_content = strlen($content);        if($count_content > 20 ) {          $description = substr($content, 0,20,'UTF-8');          echo $description ;        }        else {          echo $content;        }     ?>


How to show Y number of custom posts after every X normal posts?

I have a loop within a loop. I figured out how to show all or X number of custom posts after Y number of normal posts. I also figured out how to show 1 custom post after every Y normal posts. How do I show X custom posts after EVERY Y number of normal posts. In simple terms. How do I show 2 book (custom post type) posts after every 4 blog posts? How does one fetch more than 1 post at a time from the loop? this is the logic of the x custom posts after y normal posts. how do i get x custom posts after EVERY y normal posts?               main query // normal query     $k=0 // setting iterator     while have posts, the post          ---post markup---               if($k == 4 or $k % 4 == 0) { // whether after x number or after every x number     second query // using WP_Query     while second query has posts, the posts          ---custom post type markup // I NEED TO SHOW MORE THAN ONE HERE IF IT IS AFTER EVERY X blogposts          endwhile; //second query ends          }          $k++;     endwhile // main query


Switch between tabs on "Insert Media" dialog

I'm writing a file upload plugin and want to emulate original Wordpress behavior:   1. user uploads file on "Upload Files" tab   2. after upload is complete, "Media Library" tab is activated with just uploaded files selected. Granted I know how to add a third tab, I want after some to switch to "Media Library" tab, if I could select attachments on the tab, that would be awesome too. I have browsed docs and js code but failed to find anything. Snippet would be great, pointing to a proper article will suffice.


WP Query Bug? Cannot find out why posts are not found!

Hello I have tried a lot now and I did not find a solution yet: When a page is loaded and I do a custom Query in the PHP code like this, it works and has a lot of results:               $q = new WP_Query(array('post_type'=>'video'));      When I am on a "custom taxonomy archive page" and have exactly the same code, the posts inside of the WP_Query object are always empty:               $q = new WP_Query(array('post_type'=>'video'));      I have compared the request strings: On page (this is how it should be!):               string(243) "SELECT SQL_CALC_FOUND_ROWS  wp_ngn_posts.ID FROM wp_ngn_posts  WHERE 1=1  AND wp_ngn_posts.post_type = 'video' AND (wp_ngn_posts.post_status = 'publish' OR wp_ngn_posts.post_status = 'private')  ORDER BY wp_ngn_posts.post_date DESC LIMIT 0, 10"      On taxonomy archive page:               string(293) "SELECT SQL_CALC_FOUND_ROWS  wp_ngn_posts.ID FROM wp_ngn_posts  WHERE 1=1  AND wp_ngn_posts.post_type = 'video' AND (wp_ngn_posts.post_status = 'publish' OR wp_ngn_posts.post_status = 'private') AND wp_ngn_posts.post_content LIKE '%%'  ORDER BY wp_ngn_posts.post_date DESC LIMIT 0, 10"      Why are new WP_Query objects built differntly on the different pages [where does this "LIKE '%%' come from"? Does anybody know why this happens and what I can do to fix this? @Edit: The post type only supports title/custom field and yes - it has query_var set to true. @Edit 2: May this problem be caused by the qTranslate Plugin? @Edit 3: ... LIKE '%%' should not make a difference anyway although post content for this posts is always empty?


Automatic -1 suffix being added to the permalinks of a page when the page does not exist

I have a really strange problem with a -1 suffix being added to a permalink on a page im trying to create which is getting very frustrating. Its specifically a page titled event, each time i try to add the new page titled event the suffix -1 gets added. I have checked every single possible post, page, category, tag in every single post type and page too. I have gone to the URL and im getting a 404 page not found error. I have tried to rewrite the links numerous times in settings. I have checked the trash and drafts for any pages and posts too. I have even downloaded a plugin named "Remove Old Slugs" which did not find the 'event'. Has anyone else come aross this problem before? The usual rewrite permalinks usually works, but this time it really has not. Any help rearding this would be great. Thank you


Post view increments twice

I am having a small issue to display most views post in my blog where it is incrementing twice for each visit of post. I am not sure why this is happening because i didn't put any code to `single.php` file. Just follow the below rules & code where passing a tracker function to wp_head:               function cosonix_set_post_views($postID) {       $count_key = 'count_post_views';       $count = get_post_meta($postID, $count_key, true);       if($count=='') {          $count = 0;          delete_post_meta($postID, $count_key);          add_post_meta($postID, $count_key, '0');       } else {          $count= $count+1;          update_post_meta($postID, $count_key, $count);       }     }          //To keep the count accurate, lets get rid of prefetching     remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);          //adding tracker function for wp_head      function track_post_views () {         if ( is_single() && !is_page() ) {             global $post;             cosonix_set_post_views($post->ID);         } else {              return ;         }     }          add_action( 'wp_head', 'track_post_views');          function cosonix_get_post_views($postID){          $count_key = 'count_post_views';                        $count = get_post_meta($postID, $count_key, true);          if($count==''){              delete_post_meta($postID, $count_key);              add_post_meta($postID, $count_key, '0');              return "0";          }          return $count;     }      Anybody please help me to solve where I am getting wrong?


Is it possible to display my theme sidebar in wordpress admin?

I'm trying to create sidebar in my wordpress admin. This is because I'm trying to make my wordpress admin look like my front end. My front end theme has sidebar in the right side. So i would like to display the same sidebar in my admin area. I know its possible by editing wordpress core files. But if i update my wordpress core in the future then all my works will be wasted. So i'm trying to find some alternate ways. Is there any wordpress admin hook available out there to edit admin body, like editing admin header(admin_head) ? I respect and appreciate everyone's comments/answers. So please help me. Thanks to all


How to update post's featured image in front-end

I created a new template page with code to allow front-end posting. Everything works great, with tags, post meta and image uploading (as featured image). I have seen many codes about front-end post editing, but even though I tried to figure it out I can not successfully make it to work. I took as example this How can I edit a post from the frontend? and placed it in single.php with no luck. I guess the right way to have it, is to have an EDIT link below the post and there will be appear a new php template that contains the edit form when it is clicked. Is this correct? Secondly, how can I update the featured image I added from the front-end ? Thank you for your help.


Force Publish Future (Scheduled) Posts Immediately

I am trying to force publish 'future' or 'scheduled' posts, and I am having trouble The reason I am asking is because I am creating a site that allows users to do the editing on the front of the site, so I need a button that will allow users to force publish scheduled posts. Right now I am just trying to find a process or idea that works consistently, and all I have come up with is this: 1) Adjust the scheduled time to the past 2) Changing post status from future to draft 3) Change draft back to scheduled 4) Server realizes the scheduled post time has past and marks it published Needless to say this isn't ideal. For other status changes I was able to use the status button seen here: Publish pending article from front end with a button? . I am at a loss on this one because I can't even get the process working on the backend I have looked around a great deal and see that others have had similar problems (e.g. http://core.trac.wordpress.org/ticket/8368) but cannot find a solution. Asking the community for any ideas?


Alternate post_class on each post

I need to have an alternating (even, odd...) class on posts to provide alternate highlights on a column. The best thing would be to attach this to the post_class() so that it's on every instance of post_class(). Below is the code I have at this point to achieve this effect.               <?php           // setting other variables for alternating categories     $style_classes = array('even', 'odd');     $style_counter = 0;     ?>          <?php if (have_posts()) : ?>          <?php while (have_posts()) : the_post(); ?>          <div class="<?php $k = $style_counter%2; echo $style_classes[$k]; $style_counter++; ?>">          <?php the_cotent(); ?>          </div>          <?php endwhile; ?>          <?php endif; ?>


Plugin access and Roles

I'm new to Wordpress and am a little confused with which Wordpress user types can access plugin functionality? As administator I know I can activate (and deactivate) plugins. I can access their settings through the dashboard. However, this doesn't seem to be the case for the editor user. Which plugins settings (if any) are editable for an editor? The reason for me asking is because I want to manage my clients sites, but there may be some plugin settings that I will want my clients to use. I am assuming that the best way of working will be me as administrator and my clients as editors.


WordPress stats API key

Everytime WordPress stats updates, I need to provide the API key. Is there some way to automate this?


Pass data back to TinyMCE from Thickbox

I've added a shortcode button in the TinyMCE editor in the page/post pages that opens up a Thickbox form. The button is working; it opens up the thickbox form like it should. However my stumbling point is getting the value BACK to the TinyMCE editor and closing the thickbox. This is the code I'm using to display the button and opening Thickbox               ed.addButton('aesloop', {                 title: 'Adds a loop of recent posts with specific parameters to the page.',                 image: url+'/../img/shortcodeloop.png',                 onclick: function(){                     tb_show('Test', 'admin-ajax.php?action=aes_ajax_test');                 }             });      which calls this function               add_action('wp_ajax_aes_ajax_test', 'aes_ajax_test');     function aes_ajax_test(){         // echo the form     }      At the end of the form there will be a button that is supposed to take all the data and turn it into a shortcode. My question is: **How do I get data from this thickbox upon a button press BACK to the TinyMCE editor and then close the thickbox?** I've done a lot of searching but I can't find proper documentation on Thickbox and can't find any on shortcodes and thickbox forms as well. EDIT: I have tried using window.send_to_editor and tb_remove but I might have used these wrongly


Wordpress cookies

I am trying to set a cookie on click via                setcookie('mycookie', 1, time()+60*60*24;      but I can not seem to get it working . If i click the button - when I check my cookies, it is not there .


WP 3.3 my rich text category editor toolbar is gone!

Up until today's update, the code below has worked flawlessly to add a rich text editor control to the category description editor. Today it stopped working after updating to 3.3 Any clues what to tweak here?               <?php      function my_editor_init()     {         if ( is_admin() || defined('DOING_AJAX') )              {             if ( current_user_can('manage_categories') )remove_filter('pre_term_description', 'wp_filter_kses');             }     }          add_action('load-categories.php', 'my_admin_init');          add_action('load-edit-tags.php', 'my_admin_init');          function my_admin_init()      {         if ( user_can_richedit() && isset($_GET['action']) && 'edit' === $_GET['action'] && ( !empty($_GET['cat_ID']) || ( !empty($_GET['taxonomy']) && !empty($_GET['tag_ID']) ) ) )          {             add_filter( 'tiny_mce_before_init', 'my_mceinit');             add_action('admin_footer', 'wp_tiny_mce');             add_action('admin_head', 'my_head');         }     }          function my_mceinit($init)      {         $init['mode'] = 'exact';         $init['editor_selector'] = 'description';         $init['elements'] = 'category_description,description';         $init['plugins'] = 'safari,inlinepopups,spellchecker,paste,fullscreen';         $init['theme_advanced_buttons1'] .= ',image';         $init['theme_advanced_buttons2'] .= ',code';         $init['onpageload'] = '';         $init['save_callback'] = '';         return $init;     }          function my_head()      { ?>     <style type="text/css">#category_description_tbl,#description_tbl{border:1px solid #dfdfdf;}.wp_themeSkin .mceStatusbar{border-color:#dddddd;}</style><?php      }           add_action('init', 'my_editor_init');          ?>


What is the proper way to get logged in user id in a plugin?

I need to get logged in user id inside my plugin. Is this the proper way?               $root = dirname(dirname(dirname(dirname(__FILE__))));     if (file_exists($root.'/wp-load.php')) {     require_once($root.'/wp-load.php');     }      $user_id = get_current_user_id();      Otto saying that we shouldn't load wp-load.php file since we have no idea where wp-load.php file located and it doubles the server load. So I'm really confused. And one more question.. Check this Rarst's Image According to that image wp-load.php loaded before all the plugins. So why all plugin authors include that file again?


Can posts have parents?

Are posts supposed to have parents? If so, what would that mean for a post to have a parent? Also, if there are some constraints to posts having parents, then where is that enforced? Not in the DB as I see it.


Wordpress CSS head info - contents, expansions?

AFAIK a `style.css` for Wordpress needs some comments at the top to be properly recognized, like:               /* Theme Name: Cool Theme      Theme URI:     http://www.example.com      Description:   Super cool theme */      Are there any restrictions regarding content? I've also seen people writing stuff in there like               @author Michael Jordan     @copyright 1990 by me      What's up with that?


How Do I Programmatically Force Custom Permalinks with My Theme?

I'm making a custom theme. It's a highly specialized theme to make WordPress into like an application rather than a CMS system or blog. For instance, a Dental Office Scheduling System (with CMS and widget capabilities), as an example. Because my theme needs pretty URLs to work properly, something I really need is for the .htaccess file to be that default that gets created only when someone sets Permalinks to Custom (and then types in something like %postname%). How do I trigger that in WordPress, programmatically, so that it creates this? I mean, I could probably overwrite the file myself during theme activation, but the better thing would be to use the WordPress API for it.


Retrieving an alt tag from a custom field

I have a theme that uses TimThumb to generate thumbnail images on a gallery page. The problem is that image alt tags are not showing for each image on the main gallery pages, see here: http://christinecraven.com/gallery/press I've tried to generate the alt tag by adding a custom field in each post/ portfolio item, called "alt_tag" and then calling it in the category.php file in my theme: `$alttag = get_post_meta($post->ID, 'alt_tag', true);`
         <?php the_post_thumbnail( 'thumbnail' ); ?> alt="<?php echo get_post_meta($att, 'alt_tag', true); ?>"
             <a href="<?php the_permalink(); ?>" class="goto-icon" style="width:150px; height:150px;">

      I found on this forum a similar question: alt attributes not showing on pages But unfortunately can't seem to cobble together a solution that works!


Auto resize images after adding a new size

I have added a new (small) image size to the theme we develop: `add_image_size('small', 160, 91, TRUE);` How to automatically generate these small images (exactly of the specified size) for every image uploaded in the past?


How to add custom status to quick edit

I have added some custom post status to WordPress, I can able display in New and Edit interfaces of POST. I would like to display those to quick edit too. Also I need to apply some condition to display custom status, I will explain with example. Example : I have created status below 1)status-1 2)status-2 "status-1" appear in the drop-down box only if current post status is 'pending'. "status-2" appear in the drop-down box only if current post status is 'status-1'. Thanks in advance.


Allow tags and attributes in post and pages content

I am trying to allow the "onclick" attribute on links as well as some html tags such as iframe to the content displayed in posts and pages. In my theme's functions.php file, I tried   * removing filters such as wpautop               function rm_wpautop($content) {       global $post;       // Get the keys and values of the custom fields:       $rmwpautop = get_post_meta($post->ID, 'wpautop', true);       // Remove the filter       remove_filter('the_content', 'wpautop');       if ('false' === $rmwpautop) {       } else {         add_filter('the_content', 'wpautop');       }       return $content;     }     // Hook into the Plugin API          add_filter('the_content', 'rm_wpautop', 9);        * adding tags              add_action( 'init', 'allow_contenteditable' );     function allow_contenteditable() {       global $allowedposttags;            $tags = array( 'iframe' );       $new_attributes = array( 'contenteditable' => array() );            foreach ( $tags as $tag ) {         if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) )             $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );       }     }      without any success.


Pages and posts on ElegantTheme featured slider

I use an ElegantTheme on a wordpress site. These themes have a "featured" slider on the home page. In the administration panel of the theme, you can choose wether you want to show featured articles (blog posts) or pages. You can select which posts or pages you want on the slider. But, there is no option to mix both pages and articles. I believe one may achieve this by editing the `featured.php` file from the theme :               <?php              $responsive = 'on' != get_option('aggregate_responsive_layout') ? false : true;         $featured_auto_class = '';         if ( 'on' == get_option('aggregate_slider_auto') ) $featured_auto_class .= ' et_slider_auto et_slider_speed_' . get_option('aggregate_slider_autospeed');     ?>          <div id="featured" class="<?php if ( $responsive ) echo esc_attr( 'flexslider' . $featured_auto_class ); else echo 'et_cycle'; ?>">         <?php esc_html_e('Previous','Aggregate'); ?>         <?php esc_html_e('Next','Aggregate'); ?>          <?php if ( $responsive ) { ?>
     <?php } else { ?>
     <?php } ?>          <?php         $arr = array();         $i=0;              $featured_cat = get_option('aggregate_feat_cat');         $featured_num = (int) get_option('aggregate_featured_num');              if (get_option('aggregate_use_pages') == 'false') query_posts("posts_per_page=$featured_num&cat=".get_catId($featured_cat));              else {             global $pages_number;             if (get_option('aggregate_feat_pages') <> '') $featured_num = count(get_option('aggregate_feat_pages'));                  else $featured_num = $pages_number;             $featured_page_args = array(                     'post_type' => 'page',                     'orderby' => 'menu_order',                     'order' => 'ASC',                     'posts_per_page' => (int) $featured_num,                 );                  if ( is_array( et_get_option( 'aggregate_feat_pages', '', 'page' ) ) )                     $featured_page_args['post__in'] = (array) array_map( 'intval', et_get_option( 'aggregate_feat_pages', '', 'page' ) );                     query_posts( $featured_page_args );     } ?>          <?php if (have_posts()) : while (have_posts()) : the_post();     global $post; ?>          <?php if ( $responsive ) { ?>
     <?php } else { ?>
     <?php } ?>          <?php                          $width = $responsive ? 960 : 958;                     $height = 340;                     $small_width = 95;                     $small_height = 54;                     $titletext = get_the_title();                          $thumbnail = get_thumbnail($width,$height,'',$titletext,$titletext,false,'Featured');                     $arr[$i]['thumbnail'] = get_thumbnail($small_width,$small_height,'',$titletext,$titletext,false,'Small');                                 $arr[$i]['titletext'] = $titletext;                     $arr[$i]['post_id'] = get_the_ID();                     $thumb = $thumbnail["thumb"];                          print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, ''); ?>

<?php esc_html_e('Posted','Aggregate'); ?> <?php esc_html_e('by','Aggregate'); ?> <?php the_author_posts_link(); ?> <?php esc_html_e('on','Aggregate'); ?> <?php the_time(esc_attr(get_option('aggregate_date_format'))) ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

<?php truncate_post(410); ?>

                         <a href="<?php the_permalink(); ?>" class="readmore"><?php esc_html_e('Read More', 'Aggregate'); ?>
              <?php if ( $responsive ) { ?>
              <?php } else { ?>
              <?php } ?>             <?php $i++; endwhile; endif; wp_reset_query(); ?>     <?php if ( $responsive ) { ?>
      <?php } else { ?>
      <?php } ?>

             <?php for ($i = 0; $i < $featured_num; $i++) { ?>

                         <a href="#"<?php if ( $i == 0 ) echo ' class="active"'; ?>>                             <?php print_thumbnail( array(                             'thumbnail'     => $arr[$i]["thumbnail"]["thumb"],                             'use_timthumb'  => $arr[$i]["thumbnail"]["use_timthumb"],                             'alttext'       => $arr[$i]["titletext"],                             'width'         => (int) $small_width,                             'height'        => (int) $small_height,                             'et_post_id'    => $arr[$i]['post_id'],                             ) ); ?>

             <?php } ?>

       Sorry for such a big piece of code, but I'd rather provide the whole file just in case. I tried to remove the `if (get_option('aggregate_use_pages') == 'false')` test and always do both the `query_posts` and what's in the `else`, but all this does is always show the featured pages, even if you choose to show the articles in the admin panel. Is there any way to ignore the choice you make in the admin panel and show both featured articles and pages ? Thanks.


Folder installation to be in ROOT

What I want to achieve is just a simple removal of the `/folder` name after my `website.com` URL and have all my links and WordPress login just under `website.com/wp-login.php`. 1.) I did a restore function of a test site on my main site (website.com) which is in folder `/site`. 2.) After the successful restore using a plugin (WP Clone), My site at website.com works. But once I click on other links and pages , they go to `website.com/site`. 3.) I have tried: `http://codex.wordpress.org/Moving_WordPress` and `http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory` to no avail. They either end up screwing my themes up, screw my `HTTPS` up, or screw up my `wp-login` and keep redirecting to unknown places and keep me from logging in to the WordPress Dashboard. If there is anyone who understands what I am doing wrong, or missed something out, please do help me.


Count comments + last pub date for subcategories

How do I get the comment count for a subcategory in this loop? So every child category of 225 had comments. That amount I want to list per child. Tried some stuff with get_comments, but unsuccessful due lack of php skill.
     <?php         $args = array(             'child_of' =>225,             'orderby' => 'name',             'order' => 'ASC'         );              $categories = get_categories($args);             foreach($categories as $category) {      ?>
         <a href="<?php get_category_link( $category->term_id ); ?>">             <?php echo $category->name ?>
<?php echo $category->description ?>

         <?php echo $category->count ?>

          <?php } ?>
      And than the last column gives me troubles as wel... There I want the post date from the last entry in that child category. Cheers, Paul


Variable undefined but it is defined

I have an author list that I include on every page template. This author list shows the authors details and photo. I also show the author images on many different place on the different page templates. This use to work well until I changed the way I get the author details. I reverted back to the old method I used that worked but my author images just doesn't show up. It's still works in the author list but the image on the template pages gives me the error variable currentauth doesn't exist. What am I missing? Debug Info: > NOTICE: wp-content/themes/ewarch/single-project_post.php:81 - Undefined > variable: curauth > > NOTICE: wp-content/themes/ewarch/single-project_post.php:81 - Trying to get > property of non-object > > NOTICE: wp-content/themes/ewarch/single-project_post.php:82 - Undefined > variable: curauth > > NOTICE: wp-content/themes/ewarch/single-project_post.php:82 - Trying to get > property of non-object – AUTHOR_LIST:

              <?php                  // Get the authors from the database ordered randomly             global $wpdb;             $auth_query = "SELECT ID, user_nicename from $wpdb->users WHERE ID != '1' ORDER BY 'ASC' LIMIT 20";             $author_ids = $wpdb->get_results($auth_query);                  // Loop through each author             foreach($author_ids as $author) :                      // Get user data                 $curauth = get_userdata($author->ID);                      // Get link to author page                 $user_link = get_author_posts_url($curauth->ID);                 $post_link = get_permalink($curauth->ID);                           // Set default avatar (values = default, wavatar, identicon, monsterid)                 $main_profile = get_the_author_meta('mainProfile', $curauth->ID);                 $hover_profile = get_the_author_meta('hoverProfile', $curauth->ID);                 $award_profile = get_the_author_meta('awardProfile', $curauth->ID);              ?>

                         <img src="<?php echo $main_profile; ?>" alt="<?php echo $curauth->display_name; ?>">

                         <a href="<?php echo $user_link; ?>">                             <img src="<?php echo $hover_profile; ?>">

              <?php endforeach; ?>         <?php wp_reset_postdata(); ?>
      PAGE_TEMPLATE:               <div id="projects-single" class="<?php if (get_field('awards')): ?> award-winner <?php endif; ?> js-height">
             <?php get_template_part( 'author_list' ); ?>

                       <?php while(have_posts()): the_post(); ?>

<?php the_title(); ?>
                                  <?php if (get_field('awards')): ?>
<?php the_field('award_title'); ?>
                             <?php endif; ?>

<?php the_author_posts_link(); ?> was involved with <?php the_title(); ?>

                             <?php the_content(); ?>

                                 <img src="<?php echo get_the_author_meta('mainProfile', $curauth->ID); ?>" class="no-award">                                 <img src="<?php echo get_the_author_meta('awardProfile', $curauth->ID); ?>" class="award">

<?php the_author_posts_link(); ?>

I was part of the design team on the <?php the_title(); ?> project.

                       <?php endwhile; ?>

      THIS IS THE PART WHERE I SHOW THE IMAGES:               <img src="<?php echo get_the_author_meta('mainProfile', $curauth->ID); ?>" class="no-award">                                 <img src="<?php echo get_the_author_meta('awardProfile', $curauth->ID); ?>" class="award">


How to display data from custom fields in my custom shortcode?

This is the shortcode I have come up with, according to a tutorial on Dig WP (http://digwp.com/2010/01/custom-query-shortcode/) in order to display list of songs on specific albums.               [loop the_query="post_type=song&albumtype=enc&order=ASC&showposts=-1"]      Above is an example, using a custom taxonomy in order to achieve what I want. This returns a list item with the title and permalink of/to the song post type item. However, I would also like to return data from a couple of custom fields associated to the song post type, such as "Duration". I tried to insert this the way I would in a template, but it did not return anything. Where should I add what to the below code in order to display the value of the custom field next to the link?               function custom_query_shortcode($atts) {          // EXAMPLE USAGE:     // [loop the_query="showposts=100&post_type=page&post_parent=453"]          // Defaults     extract(shortcode_atts(array(       "the_query" => ''     ), $atts));          // de-funkify query     $the_query = preg_replace('~&#x0*([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $the_query);     $the_query = preg_replace('~&#0*([0-9]+);~e', 'chr(\\1)', $the_query);          // query is made                    query_posts($the_query);          // Reset and setup variables     $output = '';     $temp_title = '';     $temp_link = '';          // the loop     if (have_posts()) : while (have_posts()) : the_post();            $temp_title = get_the_title($post->ID);       $temp_link = get_permalink($post->ID);            // output all findings - CUSTOMIZE TO YOUR LIKING       $output .= "
$temp_title I WANT MY CUSTOM FIELD VALUE HERE
";          endwhile; else:            $output .= "nothing found.";          endif;          wp_reset_query();     return $output;          }     add_shortcode("loop", "custom_query_shortcode");      The above code is from my functions.php file, which is obvious.


Order post by date with ACF

I implemented a custom post type for a class post. Now every post has a additional date picker called "date_event", my question is: Any have ideas how can i order the post for the last date of the label date_event? Thank you for your help.


custom post type default permalink

Is it possible to use the permalink structure defined in the Wordpress settings panel for custom post types? And if so, how do I do that? I currently have:               function add_posts_two() {         $labels = array(             'name' => 'Poststwo',             'singular_name' => 'posttwo',             'add_new' => __('New Posttwo'),             'add_new_item' => __('New Posttwo'),             'edit_item' => __('Edit Posttwo'),             'new_item' => __('New Posttwo'),             'all_items' => __('All Poststwo'),             'view_item' => __('View Posttwo'),             'search_items' => __('Search Poststwo'),             'not_found' =>  __('No poststwo found'),             'not_found_in_trash' => __('No poststwo found in Trash'),             'parent_item_colon' => '',             'menu_name' => 'Posttwo'         );              $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'show_in_menu' => true,             'query_var' => true,             'rewrite' => false,             'capability_type' => 'post',             'has_archive' => true,             'hierarchical' => false,             'taxonomies' => array("post_tag", "category"),             'menu_position' => 5,             'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )         );              register_post_type( 'posttwo', $args );     }     add_action( 'init', 'add_posts_two' );


Adding width and height to wp_get_attachment_image_src

I'm trying to add the width and height attributes to the wp_get_attachment_image_src. Why is this returning width and height:0?               <?php      $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'two' );          if ($image) : ?>         <img class="attachment-two" src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" />     <?php endif; ?>       Thank you!


WP_Query: Fetch posts that are in (category1 and not in category2), OR posts that are not in cagegory1

I have two categories that will always stay the same. They are called "Events" and "Show on frontpage". The latter is a child category to Events. What i want to do is, when fetching posts (using WP_Query), check if the post is in the Events category. If it is, and it is NOT in the "Show on frontpage" category, don't fetch the post at all. Scenarios:               - post is in Events but NOT in Show on frontpage:     Don't fetch post     - post is in Events AND in Show on frontpage:         Fetch post     - post is NOT in Events:                              Fetch post      The goal is to achieve the functionality only using WP_Query. Maybe it's possible using some special `category__in` or `category__not_in` queries or something. The trick is to kind of have an `if` statement inside the query, because there are three possible scenarios. Ideas?


404 not Found (But recommendations like changing port did not work)

I have issues with Wamp and Wordpress Combo.   (Please let me know if this is not the right place to ask) Reason i ask here is because it started with this: (Beginner) Need help installing Wordpress on my VPS (Virtual Private Server) I tried changing the port like said on other posts here.   But when i do that i get complete no connection page. not even 404.   I do have another php installed which is being used on a website. Could this be it?   Would really appreciate any help. i google'd lots and posted on the wamp forum aswell.   My Results from netstat port 80 > C:\Users\Administrator>netstat -aon |find /i "listening" |find "80"   >  TCP---0.0.0.0:80------------------------0.0.0.0:0---LISTENING---4 > TCP---[::]:80----------------------------[::]:0-------LISTENING---4 > TCP---[ab29::4da:bzrr:re75:50dx@40]:42---[::]:0-------LISTENING---3172   >  TCP---[fe80::21a:4aff:fe82:8d50%41]:42----[::]:0-------LISTENING---3172 Those last two are IP6 addresses i assume? so i changed the lettering a bit.


500 error after update

I had a working (test) blog, and during an update from 3.2.1 to 3.3.1 - something went wrong , I think the update did not finished.. Just before the Update, I have enabled a new theme (all functions and files made by me ) Since the update went wrong - I can not access my admin area (500 error) but the front end works just fine ... The same blog and theme works without a problem on local machine . I had deleted ALL files on server (except uploads) and updated with a new version - but to no avail. any solutions to such a problem =??


Trying to use WP_Query to return post with and without meta values

I am trying to return posts that contain meta value and ones that don't in one query. Is this possible? So in plain English, I am trying to get posts that have a meta key of date and value of date and posts that don't have date set as well. This is what I have so far and it isn't working. UPDATED - i have now added another meta to the post to make it easier...I added no-date meta so instead of checking for it being empty, I am checking if no-date is set. So my revised code now looks like this but I can't seem to order it now.                $args = array(                 'cat' => $type,                 'post_status' => 'publish',                 'post_type' => 'post',                 'paged' => get_query_var('paged'),                 'posts_per_page' => 10,                         'orderby' => 'meta_value',                 'meta_query' => array(                         'relation' => 'OR',                         array('key' => 'date', 'value' => date('m-d-Y'), 'compare' => '>=', 'type' => 'char'),                         array('key' => 'no-date', 'value' => '1', 'compare' => '=')                         )                  );      So now this "seems" to return what i want...however I can't seem to sort it using orderby...I want the date to be closet first and future date last and for the no-dates ones to come after the ones with date via the post date. Thanks...


Modify the structure of data returned by $wpdb

Modify the structure of multidimensional array outputed by SQL via $wpdb The output that I need from `$wpdb` is easily achievable by running multiple queries within `foreach`. However, I am trying to avoid the same for performance issues. I have two custom tables:               items     - item_id     - item_name          sub_items     - sub_item_id     - item_id     - sub_item_name      The query I am running:               $items_tbl = $wpdb->prefix . 'items';     $sub_items_tbl = $wpdb->prefix . 'sub_items';     $results = $wpdb->get_results($wpdb->prepare("SELECT * from $sub_items_tbl LEFT JOIN $items_tbl ON $items_tbl.item_id = $sub_items_tbl.item_id"), ARRAY_A);      This is the resultant output of the above query:               array(         [0] => array(             ['sub_item_id'] => 1             ['item_id'] => 1             ['sub_item_name'] => 'Lorem Ipsum'             ['item_name'] => Some Item Name         )         [1] => array(             ['sub_item_id'] => 2             ['item_id'] => 1             ['sub_item_name'] => 'Lorem Ipsum Ornare Parturient'             ['item_name'] => Some Item Name         )         [2] => array(             ['sub_item_id'] => 3             ['item_id'] => 2             ['sub_item_name'] => 'Lorem Ipsum Adipiscing Malesuada'             ['item_name'] => Some Item Name         )         [3] => array(             ['sub_item_id'] => 4             ['item_id'] => 2             ['sub_item_name'] => 'Lorem Ipsum Ligula'             ['item_name'] => Some Item Name         )         [4] => array(             ['sub_item_id'] => 5             ['item_id'] => 2             ['sub_item_name'] => 'Lorem Ipsum Sit Adipiscing'             ['item_name'] => Some Item Name         )     )      And this is the output I need:               array(         [0] => array(             ['item_id'] => 1             ['item_name'] => Some Item Name             ['sub_items'] =>[0] => array(                                 ['sub_item_id'] => 1                                 ['sub_item_name'] => 'Lorem Ipsum'                             )                             [1] => array(                                 ['sub_item_id'] => 2                                 ['sub_item_name'] => 'Lorem Ipsum Ornare Parturient'                             )         )         [1] => array(             ['item_id'] => 2             ['item_name'] => Some Item Name             ['sub_items'] =>[0] => array(                                 ['sub_item_id'] => 3                                 ['sub_item_name'] => 'Lorem Ipsum Adipiscing Malesuada'                             )                             [1] => array(                                 ['sub_item_id'] => 4                                 ['sub_item_name'] => 'Lorem Ipsum Ligula'                             )                             [2] => array(                                 ['sub_item_id'] => 5                                 ['sub_item_name'] => 'Lorem Ipsum Sit Adipiscing'                             )         )     )      I'd preferably want to modify the sql to give me the resultant output. However, if that cannot be achieved then how can the output be altered in PHP?


Dequeue scripts in IE7 only using functions.php

Is it possible to dequeue scripts in IE7 only using functions.php? I have my scripts configured in the following way:               // JS     function scripts() {       // Register scripts & styles       wp_register_script( 'responsive_nav', get_template_directory_uri() . '/js/responsive-nav.js', '', '', false );       wp_register_script( 'initialize_lightbox', get_template_directory_uri() . '/js/initialize_lightbox.js', 'jquery', '', true );       wp_register_script( 'lightbox', get_template_directory_uri() . '/js/lightbox.js', 'jquery', '', true );       wp_register_style( 'lightbox_styles', get_template_directory_uri() . '/css/lightbox.css', array(), '', 'all' );            // Enqueue       wp_enqueue_script( 'responsive_nav' );       wp_enqueue_script( 'initialize_lightbox' );       wp_enqueue_script( 'lightbox' );       wp_enqueue_style( 'lightbox_styles' );          }     add_action( 'wp_enqueue_scripts', 'scripts' );      Thanks! Squid


Programatticaly Import Pages while Maintaining Hierarchy

I am working on a rather complex import project right now. I'm trying to import 2k pages into Wordpress. I am able to import them just fine using a tool caleld TurboCSV. The issue is that I also need to maintain hierachy for the pages. So for example, /about/board-of-directors/page1 and /about/members/all-members where page1 and all-members are pages, that have parents of "board of directors" and "members" (which in tern have parent pages of "about". Parent pages are set by page ID in the database, so i'm not sure how programatically importing these would be possible because it would require first creating the page before assigning the parent ID, but I wanted to see if anyone has any thoughts on this.


Question about "wp_deregister_script()"

Should I always deregister script or not? Right now I am using this:               add_action('wp_enqueue_scripts', 'js_jqTransform', 20);     function js_jqTransform() {         wp_register_script('jqTransform', get_template_directory_uri() . '/js/jqtransform/jqtransformplugin/jquery.jqtransform.js', false, null);         wp_enqueue_script('jqTransform');     }      And my concern is if I should use it like this:               add_action('wp_enqueue_scripts', 'js_jqTransform', 20);     function js_jqTransform() {         wp_deregister_script('jqTransform');         wp_register_script('jqTransform', get_template_directory_uri() . '/js/jqtransform/jqtransformplugin/jquery.jqtransform.js', false, null);         wp_enqueue_script('jqTransform');     }      And if I should use always deregister then why? Because I have noticed that some developers use for frontend something like this:               if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);     function my_jquery_enqueue() {              // JQuery         wp_deregister_script('jquery');         wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js", false, null);         wp_enqueue_script('jquery');          }      What is the reason behind that?


Create pages automatically if they don't exist

I have a WPMU instance that works less like a network of blogs and more like a holistic application. I'm needing to do a check and see if 3 pages with the slugs 'home', 'login', and 'password' exist. If not, I need the system to generate them automatically. If it does, I need the system to ignore. Right now I have the following code, and for some reason it is generating 5 posts each time a page is loaded. Anyone have advice on how I could better accomplish this?               function check_pages_live(){             if(get_page_by_title( 'home', page ) != NULL) {                 create_pages_fly('home');             }             if(get_page_by_title( 'login', page ) != NULL) {                 create_pages_fly('login');             }             if(get_page_by_title( 'password', page ) != NULL) {                 create_pages_fly('password');             }         }         add_action('init','check_pages_live');         function create_pages_fly($pageName) {             $createPage = array(               'post_title'    => $pageName,               'post_content'  => 'Starter content',               'post_status'   => 'publish',               'post_author'   => 1,               'post_type'     => 'page',               'post_name'     => $pageName             );                  // Insert the post into the database             wp_insert_post( $createPage );         }


Can I hook into user registration *before* a user is created?

I want to limit registration based on the domain associated with their email address. I was looking at the `user_register` action hook, but it fires _after_ the user is already inserted, which, although it could be hacked into working, is less than ideal. I want to preempt rather than retroactively remove invalid users. I've looked through the source in `wp-includes/user.php`, but nothing in there looks to be helpful. I did notice the `pre_user_email` filter, but that doesn't seem to offer any options for doing anything useful since I can't see a way to do anything with that.


Custom Nav Walker to show siblings and children of current branch?

I have seen very similar (if not exact) queries to this all over Google, but always seem to find something short of what I need. I am trying to create my full vertical menu using wp_nav_menu in my template. Only I would like to only show the current branch, siblings, and their children. Kind of an accordion- style menu. I prefer to do this in PHP, not using CSS or JQuery. Example full menu:               - Home     - Products        - Cool Item 1           - Item 1 Details           - Item 1 Gallery        - Cool Item 2           - Item 2 Details           - Item 2 Gallery     - Services        - Svc 1        - Svc 2      If, for example, I am on current item "Cool Item 1", I want to see all Root menu items, all Products, but only children of "Cool Item 1", no children of "Cool Item 2" or any Services. Like below:               - Home     - Products        - Cool Item 1 (-current page-)           - Item 1 Details           - Item 1 Gallery        - Cool Item 2     - Services      If I click on Services, I want to see:               - Home     - Products     - Services (-current page-)        - Svc 1        - Svc 2      Currently in my custom walker I have the star_el method like so: (make_menu_item is typical menu display you'd see searching walkers)               function start_el(&$output, $item, $depth, $args) {              // am I on the current Item?         if($item->current_item_ancestor or $item->current_item_parent or $item->current){             $cur_branch = true;         }         // this works for all current branch items, but not siblings or children         if( $cur_branch || $depth == 0 ) {             $output .= $this->make_menu_item($item, $depth, $args);         } else  {             // need to know if my parents are in current branch, then OK to show children             // not sure how to do that from this point?             if($item->menu_item_parent && $depth > 0) {                 // this currently shows everything, not what I want                 // if this is removed, no children objects show, even under cur_branch                 $output .= $this->make_menu_item($item, $depth, $args);             }         }          }      I know this logic probably isn't the best, but its a start. I can easily tell if I am in the "current branch" of the menu, and I have setup $item->hasChildren in the display_elements method, but hasChildren doesn't do me any good for children of current. It would be most helpful I just knew at this point whether or not my parent object is in the current branch, because I could either show the menu item or not then, which is what I want. I could do an SQL query, but I sure rather not do that. Is there a way to get parent info in the walker array's and objects available ($item or $elements?) ? Maybe I am going about this all wrong? Seems like it should be easy to get parent info, but calling get_ancestors() here is giving me an empty array. Thank you for any help! Greg


Require authorization for access to RSS feeds, but leave posts public

Is there a way to protect all RSS feeds from my WPMU install without blocking access to the individual posts or pages? Essentially I want anyone to have access to individual pages, but the aggregate list should require an auth code. Anyone have advice or a direction to point me in?


What is the best practice for customizing a plugin's JavaScript/jQuery?

Most well written plugins support a safe means for a developer to customize/theme the plugin by copying PHP files to the theme directory and modifying the copies rather than the original plugin file. But, unless I'm overlooking something, I'm not aware of any that support this with JavaScript/jQuery files. What is the best practice or approach for customizing the plugin's JavaScrpt/jQuery files in an `upgrade safe` manner?


Folder structue same as WordPress categories URLs?

Is it possible to have folders on disk same as categories URLs? For example I have folder on disk "images" and subfolders images/subfolder-one/subfolder-two images/some-folder/ I use "images" as category base and make categories with same URL slug as folders on disk. Than I have this: www.my-site.com/images/subfolder-one/subfolder-two and www.my-site.com/images/some-folder/ Problem is when I try to open: www.my-site.com/images/subfolder-one/subfolder-two I get blank page with directory listing instead of WordPress category page. Is it possible to make WordPress to open category page(s) even if same folder structure is on disk as WordPress category structure? Any ideas and advice?


Wordpress tax query use operator LIKE

I have taxonomy color which is associated with a custom post type. I am listing all the post meta and the taxonomy in a table. I have a option in the table to search the posts matching the search value. when search key is entered it will do a ajax call to get the the posts. this is the query to get all the posts matching the search string.               function get_query_posts_custom($post_id,$start,$length)  {         //get_posts arguments         $args =  array(             'post_type'     => 'custom_post',             'post_status'   => array('publish'),             'numberposts'   => $length,             'offset'        => $start,             'orderby'       => 'menu_order',             'order'         => 'asc',             'post_parent'   => $_product->id         );                   //get custom post taxonomy         $taxonomies = (array) maybe_unserialize(get_post_meta( $post_id, 'post_taxonomy', true));         if(empty($attributes)) {             $taxonomies = array();         }              $meta_keys  = array('type','code','key');                if(!empty($search)) {             foreach($meta_keys as $meta_key) {                 $meta_query[] = array(                             'key'   => $meta_key,                             'value' => $search,                             'compare'   => 'LIKE';                         );                  }                  $args['meta_query'] = $meta_query;             $tax_query = array();                  foreach($taxonomies as $taxonomy) {                 $tax_query  = array(                     'taxonomy'  =>  $taxonomy;                     'field' =>  'slug';                     'terms' =>  $search;                     'operator'  => 'LIKE';                 );             }             if(count($tax_query)) {                 $args['tax_query'] = $tax_query;             }         }         $results    = get_posts($args);                 return $results;     }      How to get the posts that matches the search string of a taxonomy? I searched the wordpress function reference it says only operator allowed to tax_query are 'IN,NOT IN, OR and AND') can I use the LIKE operator?


Rewrite rules for changing a custom page permalink with author details

I have the following page with permalink:               http://mysite.com/custom_page/custom_var/author_name      and I want it like this:               http://mysite.com/author_name/custom_page      The custom page conatins some details about the author. So I need to get the author id from the url. So far I had this:               http://mysite.com/custom_page?custom_var=author_name


Only single mail function is working from double mail functions one after another on wordpress

I am having a html form in my wordpress page and i have call action on my form. The file which is calling an action is saved in the root of wordpress directory. sending-mail.php I have two mail function on the sending-mail.php file one after another and only first function is successfully working not second one.I have tried the wp_mail() function also but same thing is happening with that also. Following is the code of my php file.               <?php     ob_start();     include("wp-config.php");     $connhandle=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD)or die('can\'t establish connection with mysql');     $dbSelect=mysql_select_db(DB_NAME,$connhandle) or die('could not connect to the database');          $name = $_POST['f_name'];     $email = $_POST['u_email'];     $contact = $_POST['contact'];     $product = $_POST['product'];     $segment = $_POST['segment'];     $how_did = $_POST['how_did'];          $ip = $_SERVER['REMOTE_ADDR'];     $date=date('d M Y h:i A');          $to = "download@somesite.com";     $subject = $email." has downloading a trial version of ".$product;     $headers2 = 'MIME-Version: 1.0' . "\r\n" .     'From: download@somesite.com' . "\r\n" .     'Reply-To:  download@some.com' . "\r\n" .     'Content-type: text/html; charset=iso-8859-1' . "\r\n" .     'X-Mailer: PHP/' . phpversion();     $headers = 'MIME-Version: 1.0' . "\r\n" .     'From: '.$email . "\r\n" .     'Reply-To:  '.$email . "\r\n" .     'Content-type: text/html; charset=iso-8859-1' . "\r\n" .     'X-Mailer: PHP/' . phpversion();      $body = "Name:". $name . "
 Email ". $email . "
 Phone ". $contact ."
 Product ". $product . "
 Segment ". $segment . "
 How did you hear ". $how_did;      $sql = "INSERT INTO `downloader_list` VALUES('','$name','$email','$contact','$product','$segment','$how_did','$ip','$date')";           $msg_body_mailpigeon = "Dear ". $name .",
Kindly download from
 http://somesite.com/file.iso
";      $msg_body_vpnbee = "Dear ". $name .",
Kindly download from
 somesite.com/file.iso
 ";      $msg_body_spamcheetah = "Dear ". $name .",
Kindly download from
 http://somesite.com/file.iso
";                    mysql_query($sql);          if($product=="mailpigeon"){     mail($email,'trial download',$msg_body_mailpigeon,$headers);     mail($to,$subject,$body,$headers2);     echo "";     } else if($product=="vpnbee"){     mail($email,'trial download',$msg_body_vpnbee,$headers);     mail($to,$subject,$body,$headers2);     echo "";     } else if($product=="spamcheetah"){     mail($email,'trial download',$msg_body_spamcheetah,$headers);     mail($to,$subject,$body,$headers2);     echo "";     }          ?>


Advanced Custom Fields - Disable Users to Edit Custom Fields

I don't really know how to explain this, so this will most probably not make much sense. Basically, I made a custom field (drop-down selection) for the Add/Edit User page, and I want to be the only one who can edit this. Like... when users go to the Edit User page, they can change the value of this field, which I don't want them to be able to do. I would at least like this field to be invisible to them, but not completely disappear, as I still do need this field.


Restrict certain posts from being sent to the feed subscribers

Is there any way to restrict certain category’s posts or certain posts from being displayed into site default feed after published? I’m asking this because I don’t want few specific categorie’s posts to be sent to my feedburner subscribers. I think preventing them from displaying into site feed will also prevent them to be sent to the the feed subscribers! What do you think? Or is there any way to do so..


remove user_meta data from database for all users

I'd like to create a button for admins to be able to delete from table wp_usermeta -> key: 'ref_credit' for all users. Is there simple resource friendly way to do this? does wp have built in function for this? I found this: http://codex.wordpress.org/Function_Reference/delete_user_meta But this is only for single user.


Get terms that contain posts that in turn belong to other terms?

So I have custom taxonomy called "shape" and another one called "color". If I want to get the list terms under **shape** that contain posts that are also present in terms under **color** , how do I do that? Example, I have a post under custom post type **toy** called Ball which is present in both shape Circle and color Red. I want to retrieve the term name Circle via `$wpdb` query. I'd like to emphasize that I want to retrieve the list of terms and not the posts.


Add a Submenu from Another Submenu in a Custom Theme

Good day everyone! I would like some help from you since I'm just a beginner in WordPress. I would like to add a submenu under another submenu like this:   * International      * China Independent        * Group Tours       * DPRK Add-ons       * Classic Chin       * YPT Exclusive       * Ticket Services' I don't have a problem adding them under 'China Independent' when I go to 'Appearance>Menu', however, they don't show up[maybe because it is indeed a custom theme] and I want them to be seen as drop down list on hover since China Independent is another different page. How can I achieve this? You can see this image: ![enter image description here](http://i.stack.imgur.com/C4DvL.png) Or the link: http://www.developerspace.co.vu/ All your help will be greatly appreciated!


How to Delete Old Comments by Date?

I run a contest/giveaway blog at www.mommylivingthelifeofriley.com and currently have over 160,000 comments on 1100 posts. I would like to find a way to delete all comments from my site which are older than 6 months, so as to improve my site's overall performance. Does anyone have any ideas on how to accomplish this? Thanks for your help!


What is the correct way to check if WP_Filesystem can write to a directory without aking for username / password?

I'm trying to implement caching using the filesystem so i need to check if i can write in a directory. I've read Otto's article, but i've failed to understand how should i implement a check where the user doesn't input any kind of password. So basically i need to use the direct method, what's the correct way to do it?


Wordpress Duplicator causes redirect error

I'm attempting to copy the contents of an internal Wordpress server for my company to an external client-facing Wordpress server.   The standard Wordpress import/export tool fails at receiving image content because the internal server is not accessible from outside of the domain.   Now I'm trying to use the Wordpress Duplicator plugin to do so, and the process works fine, but after importing the data into the external facing site, accessing the site gives a redirect loop, and the url redirects to website_name/wp-signup.php?new=website_name. It is not occurring in the .htaccess file, and would like to know if anyone has seen the same issue or would know how to resolve it or further troubleshoot?


*Add* items in a certain taxonomy to existing posts with pre_get_posts()

I've seen _somewhat_ similar questions on here, but not exactly what I'm trying to do. Assuming I have this:               function eg_homepage_pre_get_posts( $query ) {         if ( ! is_admin() && is_front_page() && $query->is_main_query() ) {             $query->set( 'posts_per_page', 25 );         }     }     add_action( 'pre_get_posts', 'eg_homepage_pre_get_posts' );      This will get 25 of the most recent posts on the blog, regardless of category/taxonomy, as desired. Now, if want to _add_ , say, 10 items that are in a custom taxonomy to this query, **in addition to the 25 that are queried (regardless of what taxonomies these original 25 most-recently-published posts)** , can that be done? I know how to query for items that are in a custom taxonomy, and use tax_query to be very specific with this – but anything I try, and any answer I've found on here so far, applies this taxonomy-based filtering to those 25 posts retrieved. Any help or insight would be extremely appreciated!


Wordpress - How to make cloning: description and picture

I use the plugin Meta Box Please, help me. I can not make cloning text with a picture when pressing the plus. Here is my code, only the text is cloned:               $prefix = 'stepping_';     global $meta_boxes;     $meta_boxes = array();          $meta_boxes[] = array(     'id' => 'recipe-step-box',     'title' => 'Title',     'pages' => array('post'),     'context' => 'normal',     'priority' => 'high',     'type'  => 'group',     'fields' => array(         array(             'name'      => 'Step',             'id'        => $prefix . 'step',             'desc'      => 'Desc',             'clone'     => true,             'type'      => 'textarea',             'std'       => ''         ),         array(             'name'      => 'Add image',             'id'        => $prefix . 'photo',             'desc'      => 'Desc',             'type'      => 'plupload_image',             'max_file_uploads' => 20,         ),     )      ); How to do well? ![enter image description here](http://i.stack.imgur.com/R4tQF.jpg) Please help me = (


TinyMCE 4.0: specifying buttons to display

Maybe I'm just clueless, but in looking through the documentation for TinyMCE 4.0 I can't seem to find information how how to specify which editor buttons to display. The `theme_advanced_buttons[n]` argument that works fine in TinyMCE 3 doesn't appear to be supported in version 4, and I can't find information on the replacement argument. Can anyone point me in the right direction?


Save button in theme customization page stays disabled

Ok here's the scenario: I have added a custom section to an existing theme so that it shows up in the theme customization page (customize.php). The problem I am having is that I don't know how to notify wordpress when changes are made in my custom control. I guess I am missing something in my code because it should do it in automatic? Here is some sample code:               $wp_customize->add_section('my_section',          array(             'title' => 'My title',             'description' => 'My description',             'priority' => 201         )     );          $wp_customize->add_setting(         'my_setting',         array(             'default' => '',             'type' => 'option',             'transport' => 'postMessage'         )     );          $wp_customize->add_control(         new My_Control(             $wp_customize,             'my_control',             array(                 'label'    => 'My label',                 'settings' => 'my_setting',                 'section'  => 'my_section'             )         )     );      Note that `My_Control` is a class which enqueues additional js/css files and renders my sortable list. I am storing my model in **an array** rather than using multiple settings; I add my model to the page using the `wp_localize_script` function.


How to have the thumbnail cropping tool working

I've been using wordpress (and developing on it) for years now, but never be really able to use the drop tool. So I try to ask here... If I crop a thumb, ![enter image description here](http://i.stack.imgur.com/4lpjt.png) I see the right cropping in the media editing window, ![enter image description here](http://i.stack.imgur.com/viyyM.png) but then I don't get that cropped image if I ask for the thumb (even in frontend). ![enter image description here](http://i.stack.imgur.com/lcjba.png) Why?


How can I target WordPress 3.8 new interface MP6 with CSS?

When MP6 was a plugin in WordPress 3.6+ it changes the body class of the admin and added an "admin-mp6" class which helps me to style my plugin accordingly. Now with the latest Alpha of WordPress 3.8 the class was removed. I know since it's an alpha version the class may come back but I wonder if there are any official "best practices"


selectively disable akismet

I need to disable Akismet for comments written by one of my registered users, since there is a problem that when such plugin is enabled they do not appear. I have some familiarity with php but I am unable to understand the right place to insert my if condition. Where can I add my little piece of code to prevent Akismet recalling?


WP Options Query "Rewrite Rules" Taking 10 Seconds After Testing wp_insert_post( )

Suddenly one of my test sites became absolutely unresponsive after testing with wp_insert_post( $my_post ) I Installed the black box plugin and checked what queries are slowing it down I found one that takes 10 seconds to load. I deactivated all plugins that were activated recently but it's still slowing everything down. Also noticed that PHP crashed a couple times due to this. Any ideas what could be causing such a slowdown? I REMOVED PARTS due to the length (end: WHERE `option_name` = 'rewrite_rules';)               UPDATE `wp_options` SET `option_value` =     'a:77:{s:47:\"category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$\";s:52:\"index.php?category_name=$matches[1]&feed=$matches[2]\";s:42:\"category/(.+?)/(feed|rdf|rss|rss2|atom)/?$\";s:52:\"index.php?category_name=$matches[1]&feed=$matches[2]\";s:35:\"category/(.+?)/page/?([0-9]{1,})/?$\";s:53:\"index.php?category_name=$matches[1]&paged=$matches[2]\";s:17:\"category/(.+?)/?$\";s:35:\"index.php?category_name=$matches[1]\";s:44:\"tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$\";s:42:\"index.php?name=$matches[1]&feed=$matches[2]\";s:35:\"([^/]+)/(feed|rdf|rss|rss2|atom)/?$\";s:43:\"index.php?name=$matches[1]&feed=$matches[2]\";s:28:\"([^/]+)/page/?([0-9]{1,})/?$\";s:44:\"index.php?name=$matches[1]&paged=$matches[2]\";s:35:\"([^/]+)/comment-page-([0-9]{1,})/?$\";s:44:\"index.php?name=$matches[1]&cpage=$matches[2]\";s:20:\"([^/]+)(/[0-9]+)?/?$\";s:43:\"index.php?name=$matches[1]&page=$matches[2]\";}'     WHERE `option_name` = 'rewrite_rules';


Change Woocommerce Variations price at .post() level

I am trying to build a product with infinite variations in woocommerce. Therefore the product price is defined in js on the client webpage. Then, I send a .post() to woocommerce frontend to define the attributes value for the variations. It is working fine with a post request like: $.post( "/site/cart/?add-to- cart=xx&variation_id=yy&attribute_pa_un=zz&attribute_pa_deux=yes&...&quantity=abc" ); But I can not find a way to define and send a custom price so that it appears in the cart. Is there a way, parameter to do that in the POST request?


How can I format email notification after registration?

I saw already this answer. And it helped me to make unique mail. It's great. But how to format some text using HTML? For example to work with tags                         I wrote               spintf("Text");      And on my mail I got letter with `<a href="http://site.com/some- page">Text</a>` instead of this Text. It seems that WordPress mailer cut HTML, cause I tried printf and echo. Or may be I just do something wrong?


Programatically switch page template?

I want to build a very simple toggle for taking my site down into a maintenance mode. To do that, I want to add a admin area to define a template that is the maintenance page, and allow that page to override the database defined template when maintenance mode is switched on. How can I change the theme template called for each page, WITHOUT affecting the database?


How to override Category rendering mechanism

Currently for every category there is a separate template ( _category-1.php, category-2.php_ , etc..), in my case there is over a hundred of them. I want refactor it to 4, so for instance if $cat is in range 1..20, render "first_category.php", if in range 21..50, render "second_category.php" and so on. Thanks!


Syntax highligting for custom fields

Does anyone know how to allow syntax highlighting for custom fields. None of the solutions out there seems to have support for custom fields. Thanks!


uneven behaviour create a post in using json api with white spaces

$url = "http://192.168.201.214/wordpress/?json=posts/create_post&dev=1&nonce=".$_POST["nonace"].             "&title=".$_POST["title"]."&content=".$_POST["content"]."&slug=".$_POST["title"]."&status=draft";     //echo $url; exit;     $ch=curl_init($url);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);     curl_setopt($ch, CURLOPT_COOKIESESSION, false);     $r=curl_exec($ch);     curl_close($ch);     echo "
";     $ar=json_decode($r);     //print_r($ar);         echo "status ------------------------------ ".$ar->status."
";         echo "Link ------------------------------ ".$ar->post->url."
";      this my code to create a post everthing is fine but when i create a post with spaces in my title or content it only considering first word and leaving reamining Examples:content without spaces in my return json object iam getting it like               "status": "draft",         "title": "sivaji",         "title_plain": "sivaji",         "content": "
ThisIsVeryGood<\/p>\n",      Examples:content with spaces in my return json object iam getting it like               "status": "draft",         "title": "sivaji",         "title_plain": "sivaji",         "content": "
This<\/p>\n"      Iam usig ajax call and text boxes to post the content


Custom Post Type archive

Hey all first off im a WP newbie so go easy! Ive been searching for a couple of days now to see if I can find the answer to this but cant get anything definitive. I have a custom post type called 'documents' and a corresponding archive called `archive-documents.php`. When I click on a custom taxonomy it displays my custom posts in the default `archive.php` template. Rather than trying to explain more here is the code in `functions.php`               add_action('init', 'documents_register');          function documents_register() {          $labels = array(         'name' => _x('Documents', 'post type general name'),         'singular_name' => _x('Document', 'post type singular name'),         'add_new' => _x('Add New', 'Document Entry'),         'add_new_item' => __('Add New Document Entry'),         'edit_item' => __('Edit Document Entry'),         'new_item' => __('New Document Entry'),         'view_item' => __('View Document Entry'),         'search_items' => __('Search Documents'),         'not_found' =>  __('Nothing found'),         'not_found_in_trash' => __('Nothing found in Trash'),         'parent_item_colon' => ''     );          $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,         'query_var' => true,         'menu_icon' => get_stylesheet_directory_uri() . '/images/documents-icon.png',         'rewrite' => true,         'capability_type' => 'post',         'hierarchical' => false,         'menu_position' => null,         'rewrite' => array( 'slug' => 'documents' ),         'has_archive' => true,         'supports' => array('title','editor','thumbnail'),            );           register_post_type( 'documents' , $args );          register_taxonomy("types", array("documents"), array("hierarchical" => true, "label" => "Types", "singular_label" => "Type", "rewrite" => true));      }


Is any gallery plugin available to generate galleries from existing uploaded images?

I have tried NextGEN Gallery and Lazyest Gallery, but both seem to require to upload it with their form. PhotoSmash is not supported any longer. Could you please tell me which plugin (that is supported and works with the latest WordPress) can generate galleries with already uploaded photos?


Get full content from feeds and save a duplicate copy in my site

Okay Now I'm editing old problem because its done but now i've new problem I've knowledge of mysql queries but not wordpress queries I'm doing this with mysql queries and its working well but server is going damn slow i know i'm running about 30 query per page load so is there any way to do it easily with help of wordpress queries or something else ???                <?php $rss = fetch_feed('http://example.com/feed');         if (!is_wp_error( $rss ) ) :             $maxitems = $rss->get_item_quantity(10);              $rss_items = $rss->get_items(0, $maxitems);          endif;          if ($maxitems == 0) ;             else             foreach ( $rss_items as $item ) :             $posttitle=$item->get_title();             $postcontent=$item->get_description();             $pt=mysql_real_escape_string($posttitle);             $pc=mysql_real_escape_string($postcontent);             $result=mysql_query("SELECT post_title FROM wp_posts WHERE post_title='".$pt."'");             if(mysql_num_rows>0)             {             echo "hello";             mysql_query("UPDATE wp_posts SET post_title='".$pt."',post_content='".$pc."' WHERE post_title='".$pt."'");             }             else             {             echo "hi";             mysql_query("INSERT INTO wp_posts (post_title,post_content) VALUES ('".$pt."','".$pc."')");             }             endforeach; ?>


How to link categories to custom taxonomy terms?

In a site I have registered some custom taxonomies.   I want to have sort of a linkage between one of the custom taxonomies and the categories (which is, also, a taxonomy by itself), in such a way:   If the admin assigns a post to category A - so he will be able to choose to associate with that post only specific terms of the custom taxonomy.   If the user assigns a post to category B - then he will be able to choose only other terms set from that custom taxonomy, and so on.. Each custom taxonomy term would be 'associated' with only one category. Two ways in which I do not want to implement it - I don't want to use sub- categories for this, but to use a different taxonomy.   Also, I don't want to register some different taxonomies and each them to put the terms that fit each category. The only way I could think of now, is to add a custom field to each term of the custom taxonomy. This field will be selected in the admin, for example, through a select box to avoid mistakes.   Then in the post editing screen, instead of showing the regular default metabox of adding terms of a taxonomy (which is like adding tags) - so to remove it and add a custom metabox, where relevant terms are selectable by the selected category. Of course, in that case the editor would have to first save a draft after choosing a category, to let the system know what terms to pull of the custom taxonomy (or, make ann Ajax call after each checkbox check, to reload the list of possible terms to choose according to the category selected). I'm not sure this is the best way, but it's only now I think ... I would love to brainstorm ideas of this issue. Thanks a lot, Maor


Using links (link_rss field) as the source for fetch_feed

I am trying to display feeds from a couple of my blogs using the build in function fetch_feed() however I stumbled across a few problems. I am storing the rss urls in the links section and will be calling the link_rss as the input for fetch_feed(). I know that I would have to deal with an array, perhaps nested arrays?? Can someone be kind enough to give me a way of pulling all the link_rss fields into one single variable which can be use for fetch_feed()?? Having the variable in the form of an array would be great so I can just plug it in to the function like so fetch_feed($variable). Any help would be greatly appreciated. Thanks!!


Any problem in using native jquery ajax style instead of using admin-ajax.php?

I had problem using admin-ajax.php while creating one plugin. I had problem using "add_action( 'wp_ajax_ajax_action', 'ajax_action_stuff' )" in my plugin where i have used oop module. So I want to go with jquery native way like below :               $.ajax({       url: "test.html",       context: document.body,       success: function(){         $(this).addClass("done");       }     });      Wordpress recommend to use admin-ajax.php for handeling ajax request. Is there any specific reason. Will i encounter any problem if go with native jquery ajax way.


How can this crude function be improved?

In the first function below, inside the foreach, I'm calling out to the 2nd function in order to test for the occurence of matching category ids that I want to remove from the category listing. However, the way I'm doing it in the 2nd function seems to me to be pretty crude, for lack of a better term. How could I improve this lookup?               function admin_trim_category_description( $terms, $taxonomies )     {         if( 'category' != $taxonomies[0] )return $terms;              foreach( $terms as $key=>$term )              {              $terms[$key]->description = strip_tags(substr( $term->description, 0, 75 ))."...";              if(ce4_get_utility_cats($terms[$key]->term_id))                 {                 unset($terms[$key]);                 }             }              return $terms;     }          function  ce4_get_utility_cats($cat_id)     {         if($cat_id == get_cat_ID('category1') OR $cat_id == get_cat_ID('hidden') OR $cat_id == get_cat_ID('category2') OR $cat_id == get_cat_ID('category3'))             {             return true;             }             else             {             return false;             }     }      EDIT: The above functions are called in the following manner...               add_action( 'admin_head-edit-tags.php', 'admin_edit_tags' );     function admin_edit_tags(){         add_filter( 'get_terms', 'admin_trim_category_description', 10, 2 );         }


I'm using add_meta_box() but want to include TinyMCE editor *and* Media Uploads for each box

I'm using a very lightweight plugin called WPAlchemy that lets me rapidly create meta-boxes for posts and pages. I've ben able to convert `<textarea>`'s into rich, TinyMCE's editors just fine. The problem is, I'd like to include the Media Upload buttons for those metaboxes / editors. I've been able to add the buttons above each TinyMCE editor but when I click "Insert into Post" it isn't (has no idea) which `<textarea>` to insert the requested picture/media. For reference, I'm adding the following line above my `<textarea>`: `<div id="media-buttons" class="hide-if-no-js"><?php do_action( 'media_buttons' ); ?></div>` I'm aware this isn't valid since I'm using the same id, (`#media-buttons`) as what the default content editor uses at the top. Someone suggested the following JS code to kinda hook and grab the `src` but I can't get this working for my scenario. (Suggestions came from here http:(slash)(slash)farinspace.com/multiple-wordpress-wysiwyg-visual- editors/comment-page-1/#comment-3552) Finally, I'm attaching an image of what it currently looks like, but it just doesn't link the "Insert Into Post" button with the currently focused metabox. Image: http:(slash)(slash)cl.ly/4BMf **Any help, please?**


How to send home page of wordpress website as a newsletter to subscribers? Is it possible? I want to send some part of home page as a newsletter on weekly basis


Proper formatting of post_date for wp_insert_post?

What is the proper way to define the post date when submitting a post from the front end using wp_insert_post (Trac)? My snippet now is publishing with the mysql time...               if (isset ($_POST['date'])) {         $postdate = $_POST['Y-m-d'];     }     else {         $postdate = $_POST['2011-12-21'];     }          // ADD THE FORM INPUT TO $new_post ARRAY     $new_post = array(     'post_title'    =>   $title,     'post_content'  =>   $description,     'post_date'     =>   $postdate,     'post_status'   =>   'publish',     'post_parent' => $parent_id,     'post_author' => get_current_user_id(),     );          //SAVE THE POST     $pid = wp_insert_post($new_post);


limiting characters shown in taxonomy descriptions

Right now I'm using the following code in my sidebar, which grabs the first term connected to a post from a taxonomy called "peoples" and displays it along with a link and description.               <?php $taxonomy = 'peoples';$terms = get_the_terms( $post->ID , 'peoples' );  if ( !empty( $terms ) ) : foreach ( $terms as $term ) {if($counter++ >= 1) break; $link = get_term_link( $term, $taxonomy ); if ( !is_wp_error( $link ) ) echo '
Profile: ' . $term->name . '

slug. '">
' .$term->description.'

';} endif;?>      The problem is, my descriptions are ususally more than 400 words long, so I need to figure out how I can limit their length to, say, 40 words. I've been searching for answer for a good three months now, lol; but I'm not having any luck. Does anyone have a function that can handle this? Thanks


Sidebar Stuck To First Post, Not Top Of Page

I am having an odd issue where my sidebar is stuck aligned with the first post on my page chronologically instead of appearing at the top of my page ie. I have two posts and the second post(being the most recent) appears at the top yet the sidebar aligns with the first post which is located further down the page. When I have had this issue previously it has meant the sidebar has appeared down the bottom due to invalid markup however I have not come across this issue before. Any help or suggestions would be greatly appreciated. You can see this issue here On My Site It's still in it's infancy. Thanks


The plugin generated x characters of unexpected output, $wpdb not defined

I've written a simple Wordpress plugin to create a new database table. The new table ought to be created when the plugin is activated. When I try to activate the plugin, I get the following error:               The plugin generated 3989 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.      _emphasized text_ This is obviously a result of the fact the $wbdb is not defined. xDebug outputs the following:               [Mon Feb 04 ] [error] PHP Notice:  Undefined variable: wpdb in test.php on line 13      The entire plugin consists of the following:               <?php          /**      * Plugin Name: Test Plugin      * Plugin URI: http://everybytcaptive.com      * Description: A test plugin.      * Version: 1.0      * Author: Christopher Green      * Author URI: http://everybytecaptive.com      */          $test_db_name = $wpdb->prefix . 'test_db_name';          function test_install_plugin() {         global $wpdb;         global $test_db_name;              $sql = "CREATE TABLE " . $test_db_name . " (             `id` int(9) NOT NULL AUTO_INCREMENT,             UNIQUE KEY id (id)         );";              require_once(ABSPATH . 'wp-admin/includes/upgrade.php');         dbDelta($sql);     }          register_activation_hook(__FILE__,'test_install_plugin');          ?>      I have no other plugins installed. Why isn't $wpdb defined? Is there a standard way to create a new database table when activating a plugin?


How to save Wordpress Options as an array?

How do I save options as an array using forms? I don't want to use Settings API. Here's working form that saves 3 options separately:               <form method="post" enctype="multipart/form-data" action="options.php">        <?php wp_nonce_field('update-options'); ?>             <input type="text" name="option1" value="<?php echo get_option('option1');  ?>" />        <input type="text" name="option2" value="<?php echo get_option('option2'); ?>" />        <input type="text" name="option3" value="<?php echo get_option('option3'); ?>" />          <input type="hidden" name="action" value="update" />     <input type="hidden" name="page_options" value="option1,option2,option3" />
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
     </form>      And here's how it should look for an array, but this method doesn't work (I guess the problem lies in input called page_options:               <form method="post" enctype="multipart/form-data" action="options.php">        <?php wp_nonce_field('update-options'); ?>        <?php $options = get_option('my_options'); ?>             <input type="text" name="option1" value="<?php echo $options['option1']; ?>" />        <input type="text" name="option2" value="<?php echo $options['option2']; ?>" />        <input type="text" name="option3" value="<?php echo $options['option3']; ?>" />          <input type="hidden" name="action" value="update" />     <input type="hidden" name="page_options" value="my_options" />
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
     </form>      Any ideas?


How to display a term of taxonomy

My doubt is how can I show a "term” of an specific taxonomy, the problem is that I have not found an applying example, just short code lines that don’t show me nothing at all. I want please the entire code to show the post. My post type names: “sección_deportes"   My taxonomy names: “tipo_deporte”   and the term I want to show: “futbol” I just found this: http://stackoverflow.com/questions/13512137/how-to-sort- post-by-custom-taxonomy-in-wordpress?s=f36f5472-cf86-4e93-8ee2-5856d4ef06bf but the loop shows me the same posts repeatedly.


Possible to add "Template" selector to posts?

I would like to apply layout templates to my posts, just like I can do with pages. For example, I have a template-wide.php that does not include sidebars and adds a special "wide" class to the content div. At present, I can only use this template for pages. Is it possible to make it available to posts as well?


Table for plugin-list-category-post?

I'm using the list-category-post plugin - is it possible to display the list of posts in a table? I want to have a dynamic table showing all the posts in a category, so a user can search the table and select a column to sort by. Is this possible? Thanks,


Display Post Titles on top of the_post_thumbnail()

I'm working on an issue that's just about solved, but I'm currently stuck. I've changed content php to change the way posts are displayed. I've ran $wp_query->current_post to determine what the post count is, and styled each one individually. The first post (post count 0) has a bigger featured image and headline. The 2nd, 3rd, 4th and 5th posts have no excerpt – only a featured image, 250x250, in a group of four (like the boxes on this site: http://roispark.com) I have this all working, however, I need to be able to put the post titles on top of these images. Since content.php generates each image by itself, 4 times, I can't use relative/absolute positioning, or all the titles are stacked on top of each other. Here's my code:                    <?php if ( $wp_query->current_post == 0 && !is_paged() ) { ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
       <?php get_template_part('templates/entry-meta'); ?>       <?php if ( has_post_thumbnail() ) {             the_post_thumbnail('homepage-first-thumb');         } ?>          <?php } elseif ( $wp_query->current_post == 1      || $wp_query->current_post == 2      || $wp_query->current_post == 3      || $wp_query->current_post == 4      && !is_paged() ) { ?>
       <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('homepage-thumb'); ?>
          <?php } else { ?>       <?php if ( has_post_thumbnail() ) {         the_post_thumbnail('homepage-child');       } ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
       <?php get_template_part('templates/entry-meta'); ?>     <?php } ?>      Any ideas on how I can get the_title to show up on the images? **EDIT:** Here's the LESS I have associated with the post-box:               .post-boxes {         position: relative;         img {             margin-right: 35px;             margin-bottom: 25px;         }         p {             position: absolute;             top: 50px;         }     }      It seems like it should be displaying correctly. However, here's an image of what it's doing on my site: http://imgur.com/6ig3GDn


html blog template to wordpress template

i bought a new template from themeforest and it has a blog template named as blog (the main blog template), blog2 (alternative main blog template) and post which shows the inside of a post. i just checked some online tutorials but it says how to convert a simple html site to wordpress. but i want to change the the layout, widgets and posts as in my html blog template. can some one explain me how can i convert this html blog to a wordpress template?