Proper after_setup_theme and wp_head cleanup

Im trying to clean up code in my theme a little bit, remove some of the code that is not used and basically do things the right way, to decrease load time etc. Currently I have this code:               add_action('after_setup_theme', 'rm_theme_setup');          // start theme setup     function rm_theme_setup() {         add_action('init', 'rm_head_cleanup'); // * 1) calling the function below         add_action('wp_head', 'rm_remove_recent_comments_style', 1);         add_filter('gallery_style', 'rm_remove_gallery_style');              rm_add_theme_support(); // * 2) calling the function to add theme support     }      **1) This is the wp_head cleanup part:** Basically Im calling this function in the theme_setup function above. Is this the correct way to do things?               function rm_head_cleanup() {         remove_action('wp_head', 'feed_links_extra', 3);         remove_action('wp_head', 'feed_links', 2);         remove_action('wp_head', 'rsd_link');         remove_action('wp_head', 'wlwmanifest_link');         remove_action('wp_head', 'index_rel_link');         remove_action('wp_head', 'parent_post_rel_link', 10, 0);         remove_action('wp_head', 'start_post_rel_link', 10, 0);         remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);         remove_action('wp_head', 'wp_generator');         remove_action('wp_head', 'wp_shortlink_wp_head');         add_filter('style_loader_src', 'rm_remove_wp_ver_css_js');         add_filter('style_loader_tag', 'rm_clean_style_tags');         add_filter('script_loader_src', 'rm_remove_wp_ver_css_js');     }      **2)** Then later in the code I have this function, **to add theme support**. When you check the theme setup function, im just doing this: rm_add_theme_support();. Is this the correct way to do it, or should I just copy everything from this fuction and paste it to theme_setup?               function rm_add_theme_support() {     add_theme_support('post-thumbnails');          // remove the default thumbnails     update_option('thumbnail_size_h', 0);     update_option('thumbnail_size_w', 0);     update_option('medium_size_h', 0);     update_option('medium_size_w', 0);     update_option('large_size_h', 0);     update_option('large_size_w', 0);          // set_post_thumbnail_size(200, 200, true);     add_image_size('rm-slide', 960, 500);     add_image_size('rm-service-image', 380, 9999);     add_image_size('rm-service-thumbnail', 80, 60, true);          add_theme_support('menus');          register_nav_menus(         array(             'main-nav' => 'Main menu'         )     );      } Thanks for all the help, hopefully this is not too much code.


Assign SQL 'post_thumbnail' column as featured image

I have added a column called `post_thumbnail` to my wp_posts table. Is there any way I can make `post_thumbnail` to each post's featured image?


How to redirect homepage to actual URL?

I have a stupid problem. In the custom header template I include on all pages are some images. When I set the links to the images as images/image.png it works on the homepage but not on other pages. When I set the links to these images as **../** images/image.png it works on all other pages but not on the homepage.. This is because the homepage url is given as 'mysite.com' instead of 'mysite.com/home/'. Is there any easy solution to this problem? My guess was to redirect any visit to the homepage to 'mysite.com/home/'. But it looks like Wordpress itself prevents this. If I type 'mysite.com/home/' in an adress bar it redirects immediately to 'mysite.com'. I had no idea that changing these image links would give me such a weird problem :) I hope anyone here has a solution for it. Thx in advance!


Wordpress Multi-site Automated migaration script

Bit of a long shot but can anyone recommend a script to automate moving a Wordpress multisite from local to live server.


Getting URL of Resized Image

I have a Wooframework specified question. I'm using Bueno theme with WooFramework 4.5.4 . I'm trying to get url of image which resized with **Dynamic Image resizer** of WooFramework on single.php. I'm using woo_get_image('image', 490, 200); for this but this isn't returning url of image, it's displaying image on page, directly. I need to get url. So i can use it like this : `<img src="<?php get_img_url(); ?>">` . Which function should i use?


Pass var into wp function instead of direct string text

Looking to replace static string text in this function with dynamic text from a var. Current model:                 comments_number( 'no responses', '1 response', '% responses' );      Ideal Outcome (code guess):                 comments_number( '$no_responce_text', '1'.$responce_text, '%'.$responce_text );      I am sure this is an easy php question but stumped here. Any help would be nice. Thanks


Get post title with link

I am using this code to send an email from my wordpress site. It send permalinks of the posts. How can i edit this to have linked titles instead of just permalinks;               if(count($ids) > 0){                     $user_id = $usermeta['user_id'];                     $userdata = get_userdata($user_id);                     $email = $userdata->data->user_email;                     //echo $email;                     $links = '';                     foreach($ids as $id){                         $link = get_permalink($id);                         $links .= $link . ' <br>';                     }                     //echo $links;                          if (have_posts()) :                          while (have_posts()) :                              the_post();                             $emailTpl = get_the_content();                         endwhile;                     endif;                          $message = preg_replace('/\[\%urls\%\]/', $links, $emailTpl);                     $headers = "MIME-Version: 1.0\n" . "Content-Type: text/html;";                      //wp_mail('ehmudroy@gmail.com', 'New project notification', $link);                     //wp_mail('lijb@stunningtech.com', 'New project notification', $message, $headers);                     wp_mail($email, 'New project notification', $message, $headers);                 }


How can I offer different RSS-Feeds by category?

I want to write a WordPress-Blog about some quite different topics. I will write most of it in English, but some topics are only interesting for Germans. The posts in the German-category will be in german. I guess it's not interesting for most readers who read the English categories whats in the German category. So I would like to have one RSS-Feed for all posts in the German-Category and one RSS-Feed for all other posts. How can I realise this? Per default are two Feeds available:               <link rel="alternate" type="application/rss+xml" title="MyBlog RSS Feed" href="http://localhost/wordpress/feed/" />      <link rel="alternate" type="application/atom+xml" title="MyBlog Atom Feed" href="http://localhost/wordpress/feed/atom/" />


WordPress Admin Bar Moving Links

Is there a way to move the links such as Add New Appearance Comments into one menu


Use of apply_filter in plugin/widget class

I'm having difficulties to find out what I'm doing wrong in my use of `apply_filter()` in a widget class. Here's some samples of my code:               class Byad_CountDown_Widget extends WP_Widget {       function __construct() {         parent::__construct(           'byadcd_widget',  // Base ID of widget           __('BYAD Countdown Widget', 'byad-countdown'), // Widget name will appear in UI           // Widget description & class           array(              'description' => __( 'Widget for displaying a countdown (Years (opt.), Days, Hours, Minutes, Seconds)', 'byad-countdown' ),              'classname' => 'byad-countdown',           )          );            }            public function widget( $args, $instance ) {              $title = '' . $instance['title'] . '

';         $title = apply_filters( 'byad_title', $title );//Try to add the possibility of changing the widget title via add_filter()              // before and after widget arguments are defined by themes         echo $args['before_widget'];              // some code to implement some vars              if ( is_active_widget( false, false, $this->id_base, true ) ) {           wp_enqueue_script( 'byad-countdown', plugins_url( 'js/byad-countdown.js' , __FILE__ ), array('jquery'), '1.0', true );                $params = apply_filters('byad_jsdata', array(             'byadClass' => 'countdown-display',             'byadImg' => '/byad-countdown/images/skull.png',             'byadAlt' => '.',             'year' => __('Years', 'byad-countdown'),             'month' => __('Months', 'byad-countdown'),             'day' => __('Days', 'byad-countdown'),             'hour' => __('Hours', 'byad-countdown'),             'min' => __('Minutes', 'byad-countdown'),             'sec' => __('Seconds', 'byad-countdown'),           ) ); //Try to modify the array passed to the JS file                wp_localize_script( 'byad-countdown', 'jbydCD_Data', $params );         }              echo '

';              if ( ! empty( $title ) ) {           echo $args['before_title'] . $title . $args['after_title'];         }              echo $args['after_widget'];       }            // Widget Backend        public function form( $instance ) {         if ( isset( $instance[ 'title' ] ) ) {           $title = $instance[ 'title' ];         }         else {           $title = __( 'My Default title', 'byad-countdown' );         }         //here goes Widget admin form       }            // Updating widget replacing old instances with new       public function update( $new_instance, $old_instance ) {         $instance = array();         $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';         return $instance;       }     } // Class Byad_Countdown_Widget ends here               // Register and load the widget     function byad_load_widget() {         register_widget( 'Byad_Countdown_Widget' );     }     add_action( 'widgets_init', 'byad_load_widget' );      As you can see I've made twice the use of apply_filter to be able to hook into the variable passed to my widget: `byad_title` and `byad_jsdata`. But when in my theme `function.php` file I do the following:               function my_title($title){       $title = 'you know what?';       return $title;     }     add_filter('byad_title','my_title');      Nothing happen, even if I change the priority of the `add_filter` function I'm looking for any advice, because after running the net and different answers and possibilities, I haven't had any success to make it work.


How do I only load a plugin js on it's settings pages?

I have a plugin that is conflicting with some default wordpress functions. In the post and page creating/edit areas. I only need my functions on my settings pages. I have the js file loading in admin, no problem. Can I tell the script not to load unless I'm viewing the settings pages for my plug?


update_post_meta only updating on last loop of foreach

I'm building a way to upload multiple files for an announcement custom post type on the front end. My function here uploads any number of files succesfully so I can see them under "Media" in WordPress... attached to the post. I need to be able to store the url of the file in a custom field. When I use `update_post_meta` ... it only updates the values for the last loop/file in my foreach loop below. I can't figure out why? `update_post_meta()` says it "Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. It also returns false if the value submitted is the same as the value that is already in the database." http://codex.wordpress.org/Function_Reference/update_post_meta See my comments in the code for where things are happening. Any ideas? Thanks!               akpsi_insert_attachment( $announcement_id, 'wpcf-announcement_attached_file' );          function akpsi_insert_attachment( $post_id, $post_meta  ) {                  if ( $_FILES['announcement_upload'] ) {                 $files = $_FILES['announcement_upload'];                 foreach ( $files['name'] as $key => $value ) {                     if ( $files['name'][$key] ) {                         $file = array(                             'name'          => $files['name'][$key],                             'type'          => $files['type'][$key],                             'tmp_name'  => $files['tmp_name'][$key],                             'error'         => $files['error'][$key],                             'size'          => $files['size'][$key]                         );                              $_FILES = array( "announcement_upload" => $file );                              foreach ( $_FILES as $file_key => $array ) {                                      // check to make sure its a successful upload                                 if ($_FILES[$file_key] !== UPLOAD_ERR_OK) __return_false();                                      require_once( ABSPATH . "wp-admin" . '/includes/image.php' );                                 require_once( ABSPATH . "wp-admin" . '/includes/file.php' );                                 require_once( ABSPATH . "wp-admin" . '/includes/media.php' );                                      // successfully uploads any file on each loop                                 $attach_id = media_handle_upload( $file_key, $post_id );                                           // this is only updating post meta once, and only the last loop/file.                                        $attach_url = wp_get_attachment_url( $attach_id );                                                           $postmeta_updated = update_post_meta( $post_id, $post_meta, $attach_url );                                       // test to see what it gives me on each loop...                                  // ex: gives me 'int(777)' for first loop/file, 'bool(true)' for second loop/file, 'bool(true)' for third loop/file                                 var_dump( $postmeta_updated );                              }                     }                 }             }          }


Custom Post Type loops and Disqus

I've created a CPT for a site I'm working on at the moment called "campaigns". I've created a page which displays some content as well a custom loop which displays the most recent Campaign. Everywhere else on the site I've used Disqus for commenting and I'd like to use Disqus here - but it doesn't seem to display. I've tried modifying the comments code to:               <?php $withcomments = "1"; comments_template(); ?>      but I get the regular comments form, rather than Disqus. Anyone any ideas how to work around that? Thanks in advance! 8-2-11 - I've found a temporary workaround - which is to overwrite the comments.php file in the theme with the comments file from the plugin - but that means keeping the two in sync, so it would be great if I could find a better solution.


Exclude from the query posts with meta_key and meta_value

I use this function to exclude from the query posts that are 30 days old,               function filter_where($where = '') {       //posts in the last 30 days       $where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";       return $where;     }     // Register the filtering function     add_filter('posts_where', 'filter_where');     // Perform the query, the filter will be applied automatically     query_posts($query_string);      is it possible to do something like this to exclude posts that have a meta_key=votes and meta_value=0 ?


Rewriting the WP Sub Posts plugin to allow one custom post type to be a child of another custom post type

I'll preface this by saying that I'm ok with CSS and Wordpress, but very new to PHP. You all seem to be an enormously smart bunch, and I was wondering if someone could help me out? I am building a Wordpress site for a friend, and they are wanting to be able to post mixtapes. I have created two custom post types: 'mixtape' and 'track', and my friend wants to be able to post a 'mixtape' and then attach several child 'track' posts that will remain in the correct order and will only display on the parent post page. I've been messing around with the WP Sub Page plugin ( http://takien.com/550/wordpress-plugin-wp-sub-post.php ) and trying to make it work with post types other than the default post type. Basically, it has the exact function that I'm looking for, but I need to be able to use it to link one post of the type 'track' to a parent post of the type 'mixtape'. Is this possible? I've included the plugin code below in case that helps. I know this is a big ask, but I've been toiling away at this for three days now, to no avail. If anyone out there has the time to help me with this, I'd be so enormously appreciative! Just trying to learn how this all works! Thanks. Code:               <?php
     /*     Plugin Name: WP Sub Post     Description: You can make a post is a child of another post.     Author: Takien     Version: 0.1 Alpha     */          ////////////////////////////          class Walker_PostDropdown extends Walker {              var $tree_type = 'post';              var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');              function start_el(&$output, $page, $depth, $args) {             $pad = str_repeat(' ', $depth * 3);                  $output .= "\tID\"";             if ( $page->ID == $args['selected'] )                 $output .= ' selected="selected"';             $output .= '>';             $title = esc_html($page->post_title);             $output .= "$pad$title";             $output .= "\n";         }     }     /////////////     function &wp_get_posts($args = '') {          global $wpdb;          $defaults = array(         'child_of' => 0, 'sort_order' => 'ASC',         'sort_column' => 'post_title', 'hierarchical' => 1,         'exclude' => '', 'include' => '',         'meta_key' => '', 'meta_value' => '',         'authors' => '', 'parent' => -1, 'exclude_tree' => '',         'number' => '', 'offset' => 0     );          $r = wp_parse_args( $args, $defaults );     extract( $r, EXTR_SKIP );     $number = (int) $number;     $offset = (int) $offset;          $cache = array();     $key = md5( serialize( compact(array_keys($defaults)) ) );     if ( $cache = wp_cache_get( 'wp_get_posts', 'posts' ) ) {         if ( is_array($cache) && isset( $cache[ $key ] ) ) {             $pages = apply_filters('wp_get_posts', $cache[ $key ], $r );             return $pages;         }     }          if ( !is_array($cache) )         $cache = array();          $inclusions = '';     if ( !empty($include) ) {         $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include         $parent = -1;         $exclude = '';         $meta_key = '';         $meta_value = '';         $hierarchical = false;         $incpages = preg_split('/[\s,]+/',$include);         if ( count($incpages) ) {             foreach ( $incpages as $incpage ) {                 if (empty($inclusions))                     $inclusions = $wpdb->prepare(' AND ( ID = %d ', $incpage);                 else                     $inclusions .= $wpdb->prepare(' OR ID = %d ', $incpage);             }         }     }     if (!empty($inclusions))         $inclusions .= ')';          $exclusions = '';     if ( !empty($exclude) ) {         $expages = preg_split('/[\s,]+/',$exclude);         if ( count($expages) ) {             foreach ( $expages as $expage ) {                 if (empty($exclusions))                     $exclusions = $wpdb->prepare(' AND ( ID <> %d ', $expage);                 else                     $exclusions .= $wpdb->prepare(' AND ID <> %d ', $expage);             }         }     }     if (!empty($exclusions))         $exclusions .= ')';          $author_query = '';     if (!empty($authors)) {         $post_authors = preg_split('/[\s,]+/',$authors);              if ( count($post_authors) ) {             foreach ( $post_authors as $post_author ) {                 //Do we have an author id or an author login?                 if ( 0 == intval($post_author) ) {                     $post_author = get_userdatabylogin($post_author);                     if ( empty($post_author) )                         continue;                     if ( empty($post_author->ID) )                         continue;                     $post_author = $post_author->ID;                 }                      if ( '' == $author_query )                     $author_query = $wpdb->prepare(' post_author = %d ', $post_author);                 else                     $author_query .= $wpdb->prepare(' OR post_author = %d ', $post_author);             }             if ( '' != $author_query )                 $author_query = " AND ($author_query)";         }     }          $join = '';     $where = "$exclusions $inclusions ";     if ( ! empty( $meta_key ) || ! empty( $meta_value ) ) {         $join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";              // meta_key and meta_value might be slashed         $meta_key = stripslashes($meta_key);         $meta_value = stripslashes($meta_value);         if ( ! empty( $meta_key ) )             $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key);         if ( ! empty( $meta_value ) )             $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_value = %s", $meta_value);          }          if ( $parent >= 0 )         $where .= $wpdb->prepare(' AND post_parent = %d ', $parent);          $query = "SELECT * FROM $wpdb->posts $join WHERE (post_type = 'post' AND post_status = 'publish') $where ";     $query .= $author_query;     $query .= " ORDER BY " . $sort_column . " " . $sort_order ;          if ( !empty($number) )         $query .= ' LIMIT ' . $offset . ',' . $number;          $pages = $wpdb->get_results($query);          if ( empty($pages) ) {         $pages = apply_filters('wp_get_posts', array(), $r);         return $pages;     }          // Sanitize before caching so it'll only get done once     $num_pages = count($pages);     for ($i = 0; $i < $num_pages; $i++) {         $pages[$i] = sanitize_post($pages[$i], 'raw');     }          // Update cache.     update_page_cache($pages);          if ( $child_of || $hierarchical )         $pages = & get_page_children($child_of, $pages);          if ( !empty($exclude_tree) ) {         $exclude = (int) $exclude_tree;         $children = get_page_children($exclude, $pages);         $excludes = array();         foreach ( $children as $child )             $excludes[] = $child->ID;         $excludes[] = $exclude;         $num_pages = count($pages);         for ( $i = 0; $i < $num_pages; $i++ ) {             if ( in_array($pages[$i]->ID, $excludes) )                 unset($pages[$i]);         }     }          $cache[ $key ] = $pages;     wp_cache_set( 'wp_get_posts', $cache, 'posts' );          $pages = apply_filters('wp_get_posts', $pages, $r);          return $pages;     }     //////////////          function walk_post_dropdown_tree() {         $args = func_get_args();         if ( empty($args[2]['walker']) ) // the user's options are the third parameter             $walker = new Walker_PostDropdown;         else             $walker = $args[2]['walker'];              return call_user_func_array(array(&$walker, 'walk'), $args);     }          function wp_dropdown_posts($args = '') {     $defaults = array(         'depth' => 0, 'child_of' => 0,         'selected' => 0, 'echo' => 1,         'name' => 'page_id', 'show_option_none' => '', 'show_option_no_change' => '',         'option_none_value' => ''     );          $r = wp_parse_args( $args, $defaults );     extract( $r, EXTR_SKIP );          $pages = wp_get_posts($r);     $output = '';     $name = esc_attr($name);          if ( ! empty($pages) ) {         $output = "     <select id=""$name\"" name="\"$name\"">     <option value="\"-1\"">$show_option_no_change</option>     <option value="\""">$show_option_none</option>          \n";     }          $output = apply_filters('wp_dropdown_pages', $output);          if ( $echo )         echo $output;          return $output;     }     /////////////////////////////          /* Use the admin_menu action to define the custom boxes */     add_action('admin_menu', 'myplugin_add_custom_box');          /* Use the save_post action to do something with the data entered */     add_action('save_post', 'myplugin_save_postdata');          /* Adds a custom section to the "advanced" Post and Page edit screens */     function myplugin_add_custom_box() {            if( function_exists( 'add_meta_box' )) {         add_meta_box( 'myplugin_sectionid', __( 'WP Sub Posts', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'post', 'side','high' );         //add_meta_box( $id,                  $title,                                      $callback,                  $page, $context, $priority );         add_meta_box( 'myplugin_sectionid', __( 'WP Sub Posts', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'page', 'advanced' );        } else {         add_action('dbx_post_advanced', 'myplugin_old_custom_box' );         add_action('dbx_page_advanced', 'myplugin_old_custom_box' );       }     }          function myplugin_inner_custom_box() {     echo '               ';          echo '     <input id="myplugin_noncename" name="myplugin_noncename" type="hidden" value="' .         wp_create_nonce( plugin_basename(__FILE__) ) . '" />';  ?>
<?php _e('Parent') ?>
          Please select the parent of this post          <?php           $currentid = $_GET['post'];     wp_dropdown_posts(array('exclude_tree'             => $currentid,                                 'selected'             => $post->post_parent,                                 'name'                 => 'parent_id',                                 'show_option_none'     => __('Main Post (no parent)'),                                 'sort_column'        => 'menu_order, post_title'));      }          /* Prints the edit form for pre-WordPress 2.5 post/page */     function myplugin_old_custom_box() {            echo '
' . "\n";       echo '     <fieldset id="myplugin_fieldsetid" class="dbx-box">' . "\n";       echo '

' .             __( 'WP Sub Posts', 'myplugin_textdomain' ) . "

          ";               echo '

';            // output editing form            myplugin_inner_custom_box();            // end wrapper            echo "

     </fieldset>
          \n";     }          /* When the post is saved, saves our custom data */     function myplugin_save_postdata( $post_id ) {            // verify this came from the our screen and with proper authorization,       // because save_post can be triggered at other times            if ( !wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__) )) {         return $post_id;       }            // verify if this is an auto save routine. If it is our form has not been submitted, so we dont want       // to do anything       if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )         return $post_id;            // Check permissions       if ( 'page' == $_POST['post_type'] ) {         if ( !current_user_can( 'edit_page', $post_id ) )           return $post_id;       } else {         if ( !current_user_can( 'edit_post', $post_id ) )           return $post_id;       }            // OK, we're authenticated: we need to find and save the data            $mydata = $_POST['parent_id'];             return $mydata;     }          add_filter('posts_where','where_no_parent');     add_filter ('the_content','subpost_template', 1, 2 );          function subpost_template($content) {              if(is_singular) {         remove_filter('posts_where','where_no_parent');         }         echo $content;              $idnya = get_the_ID();         $child = new WP_Query("post_type=post&post_parent=".$idnya."");              while($child->have_posts()) : $child->the_post();         echo '
          ';         echo '
';         the_title();              echo '
          ';         $childid =  get_the_ID();         the_content();              edit_post_link('Edit','','',$childid);         echo '
          ';              endwhile;         wp_reset_query();     }          function where_no_parent($where) {         global $wpdb;          $where .= " AND post_parent  = 0";          return $where;     }     ?>          ?>


Adding header function to theme

I changed the theme of my website this weekend but did not see that it wasn't supporting headers... I am now trying to create the get header image function manually, I managed to do someting in the functions.php section but I do not really know what I should do in the header.php section. When I try to put some code in the header.php my header appears on the top of the website container, above the logo. What I would like is having a full width header that replaces all the white background above the menu, and with the logo and the news ticker visible on it. Could anyone help me? Thank you in advance :)


Performance tips for a large user base

I’m preparing a site with many users (100.000+). Since the output depends on the current user’s relation to some custom post types and taxonomies a static cache won’t help much. Besides using a separate table for the users and serving static files from a cookieless domain – what else can I do for performance? For example: Should I use InnoDB or MyISAM? Hints on indexes? ## Update Obviously, I wasn’t clear enough. Sorry. All users are logged in. Always. No one else can see more than the start page. The site offers paid material for online courses. I’m looking for tips related to to a large user base only. Basic general performance optimizations like compression, lazy loading of scripts, sprites etc. are useful, but that’s not what I'm out for.


Can Anyone provide an example of RAW SQL for SELECTING posts by 2 or more tags

I need a RAW SQL, as I am working from different platform with WordPress Database. When I run `example.com/tag/first+second`, WordPress runs a query `SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (10649,7783,6336,4556,3938)` Where did this get the post IDs? I am only guessing. I do have certain thoughts about it, but first want to see if someone knows. Here is the query I have built when getting posts by SINGLE tag:               SELECT `wp_posts`.`ID`, `wp_posts`.`post_name`, `wp_posts`.`post_title`, `wp_posts`.`post_date`, `wp_posts`.`post_content` , DATEDIFF(CURDATE(),post_date) as days_ago      FROM `wp_posts`          INNER JOIN wp_term_relationships             ON (wp_posts.ID = wp_term_relationships.object_id)          INNER JOIN wp_term_taxonomy              ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)         INNER JOIN wp_terms              ON (wp_term_taxonomy.term_id = wp_terms.term_id)     WHERE 1=1         AND wp_term_taxonomy.taxonomy = 'post_tag'         AND wp_terms.slug SOUNDS LIKE 'Hennessy'         AND wp_terms.slug SOUNDS LIKE 'VS'          AND wp_posts.post_type = 'post'         AND (wp_posts.post_status = 'publish')     GROUP BY wp_posts.ID     ORDER BY wp_posts.post_date DESC      thanks.


Paypal API and Wordpress

Hi does anybody know where i can find a PayPal API tutorial that can help to point me in the right direction, What im needing is something that when payment is verified by paypal it bounces through some code to update_user_meta and also a few fields in a custom table in wp database. Information that i can find via google is pretty vague in what im requiring. regards Martin


Show Nav Link To Users Signed In

Wordpress let's users apply CSS classes to links under Appearances-->Menus. Well based off of this, I would like to know if there is a way to hide links that have a certain CSS class. So say I apply the CSS class > .members to one of my navigation links. The catch is, I would like this link to only show to users that are logged in. I am a little stuck though as I don't know how to exactly go about doing this. Could something like:               if(is_user_logged_in()) {          }      I just don't know how I could target a CSS class.


Widgets dissapearing in adminpanel

I have 2 sidebars registered. They appear as they should in the Widget are and i can drop widgets into them. When i save the widgets the widgets content appears on the website where the sidebars are registered. But when i return to the widget admin page the sidebar panels are empty, so i cant edit the content of the widgets. The content is still showing on the website though even when i reload.


disqus: comments that've been liked the most rise to the top...like youtube?

With Disqus, can I allow the most 'liked' or 'favorited' comments to rise to the top, sort of like YouTube? If not, are there any other commenting systems that have this functionality built in?


How to activate "custom fields" section in WP3

This is probably a stupid question, but I am setting up a finnish Wordpress installation. The "custom fields" section in the "write post" section is gone; I gather it is hidden by default. That is a great step, but my finnish is a bit rusty, it's my first WP install, and I can't for the life of me find the switch to turn it on. Where do I do this? > **Edit:** Martin shows a way to do this on a per-post basis, thanks for > that. In my case, it would be useful to _always_ show custom fields, so > extra brownie points for anybody who can give me a hint on how to do that. I > can't find any documentation on this.


Duplicated Template Does Not Load the Same as the Original Template File?

I had someone code a custom theme that I had designed. I need to duplicate one of the templates this person made, give unique class names for the CSS, adjust the CSS as needed, and finally save it as an entirely new template. **What I have done so far:**   * Opened the template that I want to duplicate in Dreamweaver.   * Changed the template name at the top of the page to the name of the new template.   * Saved the template under a different name since it will become a new template.   * Saved the template on the server via FTP to the location where the rest of the templates are. **Here's the problem:** If I create a new page, and select my new template, the custom meta boxes (cmb) doesn't show up like when I select the template I copied my new template from. It only shows the default metabox. Have a look at these screenshots ![storage template](http://i.stack.imgur.com/GVK04.jpg) ![testimonial template](http://i.stack.imgur.com/nLMQR.jpg) Here is the code to the original template (template.storage.php) and my new template. Bare in mind, these templates are exactly the same, I just change the template name. I will later change some classes to add custom styling, but that is not relevant now.                 <?php     /**     Template Name: Storage     **/     ?>     <?php get_header(); ?>     <?php $container_background = get_post_meta($post->ID, '_cmb_background-container', true); ?>     <?php          $box_one_heading = get_post_meta($post->ID, '_cmb_storage-box-one-heading', true);     $box_one_content = wpautop(get_post_meta($post->ID, '_cmb_storage-box-one-content', true));          $box_two_heading = get_post_meta($post->ID, '_cmb_storage-box-two-heading', true);     $box_two_content = wpautop(get_post_meta($post->ID, '_cmb_storage-box-two-content', true));     ?>              <div id="container" class="innerpage" style="background: #fff3cb url('<?php echo ($container_background ? $container_background : "".get_stylesheet_directory_uri()."/images/corks.png"); ?>') center bottom no-repeat;">         <?php fourosix_breadcrumbs(); ?>
                 <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>                     <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                              <?php if($box_one_heading && $box_one_content) { ?>

<?php echo $box_one_heading; ?>
                             <?php echo $box_one_content; ?>
                         <?php } ?>                              <?php if($box_two_heading && $box_two_content) { ?>

<?php echo $box_two_heading; ?>
                             <?php echo $box_two_content; ?>
                         <?php } ?>

                             <?php the_post_thumbnail(485,320,true); ?>

                             <?php $beerimage = get_post_meta($post->ID, 'BeerImage', true); ?>

                         <?php if ( is_user_logged_in() ) : ?>                                                      <?php edit_post_link( __( 'edit' ), '', '' ); ?>                                                  <?php endif; ?>
                 <?php endwhile; ?>                 <?php else : ?>

page not found

                 <?php endif; ?>

               <?php get_footer(); ?>                     Here is the head for the duplicated template:               <?php     /**     Template Name: Testimonials     **/     ?>      I also include these 2 pieces of code as this might be of help Code from my "enable.php"                 <?php     /**      * Include and setup custom metaboxes and fields.      *      * @category YourThemeOrPlugin      * @package  Metaboxes      * @license  http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)      * @link     https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress      */          add_filter( 'cmb_meta_boxes', 'wsod_metaboxes' );     /**      * Define the metabox and field configurations.      *      * @param  array $meta_boxes      * @return array      */     function wsod_metaboxes( array $meta_boxes ) {              // Start with an underscore to hide fields from custom fields list         $prefix = '_cmb_';              $meta_boxes[] = array(             'id' => 'general-settings',             'title' => 'General Settings',             'pages' => array('page'),             'context' => 'normal',             'priority' => 'high',             'show_names' => 'true',             'fields' => array(                 array(                     'name' => 'Background Container',                     'desc' => 'Please upload the image you would like to use as background for the container of this page',                     'id' => $prefix . 'background-container',                     'type' => 'file'                     )             )            );              $meta_boxes[] = array(             'id' => 'page-storage',             'title' => 'Storage Content',             'pages' => array('page'),             'context' => 'normal',             'priority' => 'high',             'show_names' => 'true',             'fields' => array(                 array(                     'name' => 'Box #1 Heading',                     'desc' => 'Please input the heading of Box#1 here',                     'id' => $prefix . 'storage-box-one-heading',                     'type' => 'text_medium'                 ),                 array(                     'name' => 'Box #1 Content',                     'desc' => 'Please input the content of Box#1 here',                     'id' => $prefix . 'storage-box-one-content',                     'type' => 'wysiwyg',                     'options' => array( 'textarea_rows' => 6, )                 ),                 array(                     'name' => 'Box #2 Heading',                     'desc' => 'Please input the heading of Box#2 here',                     'id' => $prefix . 'storage-box-two-heading',                     'type' => 'text_medium'                 ),                 array(                     'name' => 'Box #2 Content',                     'desc' => 'Please input the content of Box#2 here',                     'id' => $prefix . 'storage-box-two-content',                     'type' => 'wysiwyg',                     'options' => array( 'textarea_rows' => 6, )                 )             )         );                   $meta_boxes[] = array(             'id' => 'page-services',             'title' => 'Services Content',             'pages' => array('page'),             'context' => 'normal',             'priority' => 'high',             'show_names' => 'true',             'fields' => array(                 array(                     'name' => 'Box #1 Heading',                     'desc' => 'Please input the heading of Box#1 here',                     'id' => $prefix . 'services-box-one-heading',                     'type' => 'text_medium'                 ),                 array(                     'name' => 'Box #1 Content',                     'desc' => 'Please input the text content of Box#1 here',                     'id' => $prefix . 'services-box-one-content',                     'type' => 'wysiwyg',                     'options' => array( 'textarea_rows' => 6, ),                 ),                 array(                     'name' => 'Box #2 Heading',                     'desc' => 'Please input the heading of Box#2 here',                     'id' => $prefix . 'services-box-two-heading',                     'type' => 'text_medium'                 ),                 array(                     'name' => 'Box#2 Content',                     'desc' => 'Please input the text content of Box#2 here',                     'id' => $prefix . 'services-box-two-content',                     'type' => 'wysiwyg',                     'options' => array( 'textarea_rows' => 6, ),                 ),                 array(                     'name' => 'Box #3 Heading',                     'desc' => 'Please input the heading of Box#3 here',                     'id' => $prefix . 'services-box-three-heading',                     'type' => 'text_medium'                 ),                 array(                     'name' => 'Box#3 Content',                     'desc' => 'Please input the text content of Box#3 here',                     'id' => $prefix . 'services-box-three-content',                     'type' => 'wysiwyg',                     'options' => array( 'textarea_rows' => 6, ),                 ),                 array(                     'name' => 'Box #4 Heading',                     'desc' => 'Please input the heading of Box#4 here',                     'id' => $prefix . 'services-box-four-heading',                     'type' => 'text_medium'                 ),                 array(                     'name' => 'Box#4 Content',                     'desc' => 'Please input the text content of Box#4 here',                     'id' => $prefix . 'services-box-four-content',                     'type' => 'wysiwyg',                     'options' => array( 'textarea_rows' => 6, ),                 ),                  )              );           // Rest of code          return $meta_boxes;     }          add_action( 'init', 'cmb_initialize_cmb_meta_boxes', 9999 );     /**      * Initialize the metabox class.      */     function cmb_initialize_cmb_meta_boxes() {              if ( ! class_exists( 'cmb_Meta_Box' ) )             require_once 'init.php';          }      Code from my "script-metabox-template-toggle.js"               jQuery(document).ready(function() {         // in this functions hide all the custom metaboxes that are used         function hide_all_custom_metaboxes() {             jQuery('#page-facilities').hide();             jQuery('#page-services').hide();             jQuery('#page-storage').hide();         }              function show_custom_metabox(meta_id) {             var selector = "#" + meta_id;             if(jQuery(selector).length)                 jQuery(selector).show();         }              function toggle_wp_editor(current_metabox) {             jQuery('#postdivrich').show();             switch(current_metabox) {                 case 'facility':                     //jQuery('#postdivrich').css("display","none");                     show_custom_metabox("page-facilities");                 break;                 case 'services':                     jQuery('#postdivrich').css("display","none");                     show_custom_metabox("page-services");                 break;                 case 'storage':                     jQuery('#postdivrich').css("display","none");                     show_custom_metabox("page-storage");                 break;                  }         }              function get_template_html_id() {             current_metabox = jQuery('#page_template option:selected').val();             current_metabox = current_metabox.replace('template.','');             current_metabox = current_metabox.replace('.php','');             /*if(current_metabox == "default") {                 current_metabox = "content-default";             }*/             return current_metabox;         }              hide_all_custom_metaboxes();              var current_metabox = get_template_html_id();              show_custom_metabox(current_metabox);         toggle_wp_editor(current_metabox);              jQuery('#page_template').bind("change", function() {             hide_all_custom_metaboxes();             show_custom_metabox(get_template_html_id());             toggle_wp_editor(get_template_html_id());         });          });      Any suggestions on how to make my custom template work?


How to modify the comments list in WP & BuddyPress?

I'd like to modify the **comments list** (comments left by users) on WP site using BuddyPress. In **comments.php** I narrowed it down to the following code:               <?php wp_list_comments( array( 'callback' => 'bp_dtheme_blog_comments' ) ); ?>      Any clue where I can find **bd_dtheme_blog_comments** , and the best way to modify it? Thank you.


When adding buttons to the tinyMCE editor, how do I make them wrap to the next line and/or display in the "Kitchen Sink" area?

I'm successfully adding buttons to the TinyMCE editor in Wordpress, but the problem is they all show up to the right of the Kitchen Sink button and I have so many that I need them to display on a new line. How do I make the buttons wrap to the next line and/or create a new row for my custom buttons? Here is my code:               tinymce.create('tinymce.plugins.boxlight', {         init : function(ed, url) {             ed.addButton('boxlight', {                 title : 'Add a light content box',                 image : url+'/images/box-light.png',                 theme_advanced_buttons3_add : 'boxlight',                 onclick : function() {                      ed.selection.setContent('[box_light]' + ed.selection.getContent() + '[/box_light]');                      }             });         },         createControl : function(n, cm) {             return null;         },     });          tinymce.PluginManager.add('boxlight', tinymce.plugins.boxlight);      That code just adds the buttons to the main TinyMCE toolbar and I can't figure out how to add the buttons to a new toolbar.


Custom Content Type with No Page View

I am trying to define a custom content type, more exactly I want to create some controls in a content type for a slider that I will show on the home page custom template. What I would like to know if it's possible to make the content type to don't have a view (a actual page where it would show up).


WordPress Plugin: Global Update

Hi I want to be able to make a plugin that will check for updates of other plugins that i have made from a single place. In my main plugin file i have               include_once( 'class-login-slider-updater.php' );          $login_slider_updater = new Login_Slider_Updater( 'http://wp-creation.com/api/plugins/login-slider/',plugins_url('login-slider', 'login-slider').'login-slider.php');      In my class-login-slider-updater.php file i have this below. This file calls the API which specifies all the information it needs just like what WordPress.org uses.               class Login_Slider_Updater     {         private $api_url = 'http://wp-creation.com/api/plugins/login-slider/';         private $api_data = array();         private $name = 'login-slider';         private $slug = 'login-slider.php';                        /**          * Class constructor.          *          * @uses plugin_basename()          * @uses hook()          *           * @param string $_api_url The URL pointing to the custom API endpoint.          * @param string $_plugin_file Path to the plugin file.          * @param array $_api_data Optional data to send with API calls.          * @return void          */         function __construct( $_api_url, $_plugin_file, $_api_data = null )         {             $this->api_url = $_api_url;             $this->api_data = $_api_data;             $this->name = plugin_basename( $_plugin_file );             $this->slug = basename( $_plugin_file, '.php');                  // Set up hooks.             $this->hook();         }              /**          * Set up Wordpress filters to hook into WP's update process.          *           * @uses add_filter()          *           * @return void          */         private function hook()         {             add_filter( 'pre_set_site_transient_update_plugins', array( &$this, 'pre_set_site_transient_update_plugins_filter' ) );             add_filter( 'plugins_api', array( &$this, 'plugins_api_filter' ), 10, 3);         }              /**          * Check for Updates at the defined API endpoint and modify the update array.          *          * This function dives into the update api just when Wordpress creates its update array,          * then adds a custom API call and injects the custom plugin data retrieved from the API.          * It is reassembled from parts of the native Wordpress plugin update code.          * See wp-includes/update.php line 121 for the original wp_update_plugins() function.          *          * @uses api_request()          *          * @param array $_transient_data Update array build by Wordpress.          * @return array Modified update array with custom plugin data.          */         function pre_set_site_transient_update_plugins_filter( $_transient_data )         {             if( empty( $_transient_data ) ) return $_transient_data;                  $to_send = array( 'slug' => $this->slug );                  $api_response = $this->api_request( 'plugin_latest_version', $to_send );             if( false !== $api_response && version_compare( $_transient_data->checked[$this->name], $api_response->new_version, '<' ) ) $_transient_data->response[$this->name] = $api_response;                  return $_transient_data;         }              /**          * Updates information on the "View version x.x details" page with custom data.          *           * @uses api_request()          *           * @param mixed $_data          * @param string $_action          * @param object $_args          * @return object $_data          */         function plugins_api_filter( $_data, $_action = '', $_args = null )         {             if ( ( $_action != 'plugin_information' ) || !isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) return $_data;                  $to_send = array( 'slug' => $this->slug );                  $api_response = $this->api_request( 'plugin_information', $to_send );             if ( false !== $api_response ) $_data = $api_response;                  return $_data;         }              /**          * Calls the API and, if successfull, returns the object delivered by the API.          *           * @uses get_bloginfo()          * @uses wp_remote_post()          * @uses is_wp_error()          *           * @param string $_action The requested action.          * @param array $_data Parameters for the API action.          * @return false||object          */         private function api_request( $_action, $_data )         {             global $wp_version;                  $data = array_merge( $this->api_data, $_data );                  $options = array(                 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),                 'body' => array( 'action' => $_action, 'data' => serialize( $data ) ),                 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) // Do not change this line.             );                  // Call the custom API.             $raw_response = wp_remote_post( $this->api_url, $options );                  if ( !is_wp_error( $raw_response ) && ( 200 == $raw_response['response']['code'] ) ):                 return unserialize( $raw_response['body'] );             else:                 return false;             endif;         }}      So what i want to do is to be able to make this plugin check for updates for other plugins i have developed by calling the API. Or could you point me to a good tutorial for this as i can't seem to find any that explain how to do this.


Import of 200+ sermons

While this not a Development-specific question for WordPress, I am looking for a way to import 200+ sermons for our church website.. I have updated the mp3 files wtih mp3tag and all look good. I am trying to bring these over from a Concrete5 to a WordPress instance. I don't want to have to code/update all of these in WordPress. I have looked at a number of Sermon Managers for WordPress including - https://wordpress.org/plugins/sermon-manager-for-wordpress/ which has a mass- import module, but does not do a very good job. Thanks.


Multisite Tables the same as Single Install?

Are the tables created for each individual site/blog on Multisite the same as single? Can I do an SQL dump for each MS table and import it to a single install?


wp_kses_post only removes <script> tags, but not their content

Is there any way to remove the `<script>` tags including their contents? wp_kses_post seems to only remove the tags, while their content remains visible on the page. Thank you


Why does my URL keep returning 404 error code?

I have a custom type on my wordpress site called 'movie'. If the user type this URL : `http://mysite.com/1994`,   I would like to display all movies published in 1994. Unfortunately, I get a consistent 404 error. When I call `get_post_type` in index.php(that is the template page called since I didn't defined 404.php), it displays 'movie' but I have no movie called 1994... at least not yet. I have pretty permalinks ON. If I ask the rewrite rule inspector to check the URL, here is the result for `http://mysite.com/1994`:               ([0-9]{4})/?$   index.php?year=$matches[1]  date     (.?.+?)(/[0-9]+)?/?$    index.php?pagename=$matches[1]&page=$matches[2] page     ([^/]+)(/[0-9]+)?/?$    index.php?name=$matches[1]&page=$matches[2] post      What am I missing?


When will be the next major update for wordpress?

My client isn't a great fan of updates so I want to assure him that the next major upgrade will be at least 3-4 months down the line. I just upgraded his blog to 3.1 - (YAY!) Would anyone concur with this or is this just wishful thinking on my part?


Updating wordpress user meta data array (unexpected multiple arrays)

So I am trying to update a user meta data array that I have previously stored with this function:               function oe_charge_customer( $customer ) {               // load the stripe libraries         require_once(STRIPE_BASE_DIR . '/lib/Stripe.php');              // check if in test mode or not         check_stripe_api();              // counter         $i = $customer['i'];              // get user meta, if any         $payment_args = get_user_meta( $customer['user_id'], 'oe_customer_details' );              // update paid value to true         $payment_args[0]['payments'][$i]['paid'] = 1;              // attempt to charge the customer's card         try {                  $charge = Stripe_Charge::create(array(                     'amount'    => $customer['amount'] * 100,                     'currency'  => 'usd',                     'customer'  => $customer['cust_id']                 )             );                  // update user profile to show paid             update_user_meta( $customer['user_id'], 'oe_customer_details', $payment_args );              } catch (Exception $e) {                  wp_die($e);              }          }      I am getting somewhat expected results, except it keeps throwing it in a new array every time it gets updated. Any idea why this is happening? I can't seem to wrap my head around it . I get the following after it gets updated:               Array     (         [0] => Array             (                 [0] => Array                     (                         [0] => Array                             (                                 [0] => Array                                     (                                         [0] => Array                                             (                                                 [customer] => Array                                                     (                                                         [name] =>                                                          [id] => cus_2Oo1hyvYyZsaj0                                                         [user_id] => 18                                                     )                                                      [payments] => Array                                                     (                                                         [0] => Array                                                             (                                                                 [amount] => 16                                                                 [date] => 1376710188                                                                 [paid] => 0                                                             )                                                              [1] => Array                                                             (                                                                 [amount] => 4                                                                 [date] => 1376710238                                                                 [paid] => 0                                                             )                                                          )                                                  )                                              [payments] => Array                                             (                                                 [0] => Array                                                     (                                                         [paid] => 0                                                     )                                                  )                                          )                                  )                              [payments] => Array                             (                                 [1] => Array                                     (                                         [paid] => 1                                     )                                  )                          )                  )          )


Image Editor does not affect custom sizes!

Recently working with wordpress 3.5, I came across this patch :http://core.trac.wordpress.org/ticket/19889 ...which solved the problem of custom image sizes defined by my theme not resizing or rotating properly. The issue was image-edit.php did not account for sizes added by the function add_image_size (i think this is the name of the function but not 100% sure) in functions.php. this patch worked perfectly but unfortunately it does not work on 3.6. image- edit.php seems to have been replaced completely by different files and functions. I could backup to 3.5 but the best thing to do is fix it under 3.6! I am not an experienced coder so I wanted to ask someone to have a look at the patch and help me go about fixing the .php file now responsible for editing images.


View photo album without having to scroll down for each picture

I need a way to see my photo albums without having to scroll down for each picture. So, is there a way to lose the Header when I open the photo album ? Or, can the photo album open in a new window ? Thanks, Mike


WordPress documentation - WP_Query arguments

I've been looking for a list all WP_Query arguments. This looks obvious, but http://codex.wordpress.org/Function_Reference/WP_Query isn't helpful at all, "post_type" is mentioned only in an example, and arguments like "posts_per_page" aren't even there.


Dynamically creating custom post type items and updating them

I am creating a plugin which uses a custom post type. My question is two folds: (1) upon activation of my plugin how do I create the items of my custom post types. For example: if my post type was say... "Best Restaurants". I want to create 10 custom post types items since my plugin will need this information. How would I do that? Is there a function I can use which adds a post item along with its custom data? and (2) When my plugin is updated, say I released a new version, what is the best way to modify this list? I was thinking of deleting all items with a certain post type and then inserting the new ones, but that might be overkill. Thanks in advance.


Get a term each custom post type

I have a problem to get the term of custom posts list. I have 2 taxonomies on my custom post type. one of them is "visa_processing". and I am trying to create a list (table, tr, td) "Name1, Name2, passport num, processing." "processing" is a term and each different. I need to get "processing" term on list for each posts. ex) John, Smith, K009923, waiting Price, Mark, K009923, failed Jordan, MC, K009923, issued "applied, waiting, failed, issued" <\--- these are terms of the taxonomy "visa_processing". But terms are not showing or printed "Array". how can I fix it?                $args = array(     'post_type'   => $post_type,     'numberposts' => $limit,     'post_status' => $status,     );     $posts = get_posts( $args );     if( count($posts) ):     $return .= '
';     foreach( $posts as $post ): setup_postdata( $post );          /** get meta values and replace **/     $getPassport = get_post_meta( get_the_ID(), '_Passport', true );     $getPassport_replaced = substr_replace($getPassport, "*", 3).'*****';          $getName1 = get_post_meta( get_the_ID(), '_Name1', true );     $getName2 = get_post_meta( get_the_ID(), '_Name2', true );     $getName2_replaced = substr_replace($getName2, "*", 3).'***';     //$getNames = get_the_title();  // 전체 이름 : 사용안함          //$processing = get_the_terms( get_the_ID(), 'visa_processing', array("orderby"=>"term_order"));     //$processing = wp_get_post_terms( get_the_ID(), 'visa_processing');     //$processing = wp_get_object_terms( get_the_ID(), 'visa_processing' );     //echo get_the_ID();          //$terms = get_the_terms();   print_r($terms);                 $return .= '
' . $getName1 .' '. $getName2_replaced .'	  '.$getPassport_replaced.'	'.$processing.'
';           endforeach; wp_reset_postdata();        $return .= '

'; //#recent_visas      else :        $return .= '
No posts found.
';      endif;      return $return;


simple expandable vertical menu, java script problem

I am trying to create a simple expandable menu in wordpress. Bellow you can see the javascript I am using (copy and mix from internet).               <script type="text/javascript">         $(document).ready(function($) {             $('#access li').has('ul').addClass('has_submenu');             $('#access ul li.has_submenu a').click(function() {                 $("#access ul ul").toggleClass("showHide");             });          });     </script>      The **first part is ok** , script adds has_submenu class to my menu. **Second part** should toggle showHide class. My problem is that when I click the showHide class appears but dissapears right after(page reloads). Thanx for help :)


display 20 lines only with the_content

I like to display only 20 lines of post with the read more link using               the_content( __( 'Continue reading →' ) );       But it shows full content . How can i strip it .please help me !


How to Add a Custom Script to Customize.php

I am having a rather difficult time adding a script to the 3.4 Theme Customizer (i.e., customize.php). If I want, I can deregister jquery and add it from googleapi as follows:               wp_deregister_script( 'jquery' );     wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js');     wp_enqueue_script( 'jquery' );      That works just fine. However, if I want to add jquery-color or some other script I just can't get it to work. For instance, this doesn't work:               wp_enqueue_script( 'jquery-color' );      This also does not work:               wp_register_script( 'bpjquerycolor', 'http://localhost/bp2/wp-content/themes/buildpress/admin/scripts/bpjquerycolor.js');          wp_enqueue_script( 'bpjquerycolor' );      In terms of add_action, none of the following work:               add_action( 'admin_print_scripts', 'add_admin_scripts' );     add_action( 'wp_enqueue_scripts', 'add_admin_scripts' );     add_action( 'init', 'add_admin_scripts' );     add_action( 'admin_init', 'add_admin_scripts' );      I have also tried the following with no success:               global $wp_customize;     if ( isset( $wp_customize ) ) {     wp_enqueue_script( 'jquery-color' );     }      In short, I've tried every combination that I can think of with no success. What am I doing wrong? How can I add this to the theme customizer? Thanks in advance for any help you can offer.


How do I use Ajax to show the new posts realtime, on the frontpage

Does anyone know how to make new posts automatically show up in the frontpage, with out having to refresh the page. I have a wordpress site with multiple authors and want their new posts to show up automatically. Thanks.


Memberpress isn't cooperating with WooCommerce

I'm working on a site for a client that has a member subscriptions as well as a small store. We're using memberpress to handle subscriptions, and restricting content to certain membership types. For the store we're using woocommerce. The two plugins seem to be conflicting on the checkout page though. Everything works fine if you are logged in. However if you try to checkout as a guest things get wonky. In woocommerce's checkout.min.js, there is a function for update_checkout() that has little ajax call. Normally this seems to load the order summary and payment gateway form, however, if you are logged out it ends up loading Memberpress's "URL to direct member to after login:" page in it's entirety within the checkout form page. So it looks like Memberpress is getting in the way of woocommerce from refreshing data within the checkout form. My question is then, has anyone had experience with disabling Memberpress completely for certain pages of your site? Or coming at it from another angle is there a way to turn off ajax in the checkout form? * * *


wp_remote_get vs. file_get_contents vs. cURL?

I need to fetch the contents of a remote file. Which is better for performance - wp_remote_get, file_get_contents, or cURL? How exactly does wp_remote_get work? Can you suppress errors, ex. @wp_remote_get ? Thanks


Capability to read user's own draft post of CPT

I've got a custom role called 'Gym' and custom post type (CPT) called 'Story'. Every Gym user can create a draft of a story and view their own story drafts. My 'Story' CPT have got the following capabilities:               [cap] => stdClass Object(                 [edit_post] => edit_post                 [read_post] => read_post                 [delete_post] => delete_post                 [edit_posts] => edit_posts                 [edit_others_posts] => edit_others_posts                 [publish_posts] => publish_posts                 [read_private_posts] => read_private_stories                 [read] => read                 [delete_posts] => delete_posts                 [delete_private_posts] => delete_private_posts                 [delete_published_posts] => delete_published_posts                 [delete_others_posts] => delete_others_posts                 [edit_private_posts] => edit_private_posts                 [edit_published_posts] => edit_published_posts                 [create_posts] => edit_gymtopia_story             )      A Gym user have the following capabilities:               [read] => 1     [upload_files] => 1     [edit_gymtopia_story] => 1     [read_private_stories] => 1      A Gym user can create a Story draft ok. However, the Gym user is unable to view his own story draft posts. I'd thought that `[read_private_posts] => read_private_stories` capability would work.. Instead I'm getting 404 page not found. I would really appreciate any tips and help, I don't know what I'm missing. Many thanks, Dasha


Rewriting single post url; add_rewrite_rule problem?

I have to customize single post permalink (the structure of the permalink) if posts have a certain value in a certain custom fields. I use the filter `post_link` to change permalink when needed, and this works greatly (I mean, in front-end permalink are different when they should). First question: in your opinion I have to use other filters to cover all cases of single post permalink customization? Then I have added specific rule using `add_rewrite_rule` to interpret this new kind of structure, and here I face the problem. As this permalink structure has the ID (with 0 at the beginning in order to reach 6 digit, ex. 008467) at the end, I notice that Wordpress redirects to a new url with this number - cast to an integer - repeated, for example: from               /CATEGORYNAME/2013/04/22/POSTSLUG/008467/      to               /CATEGORYNAME/2013/04/22/POSTSLUG/008467/8467/      Do not worry about the structure before POSTSLUG, in fact the important thing is that if I remove the POSTID from the structure (008647) all works fine! For example, the following works:               /CATEGORYNAME/2013/04/22/POSTSLUG/      How is it possible?! It seems that Wordpress thinks that number is something different, like pagination or something similar. This is the rule I have added (the regexp is correct, I have tried it with an online tester):               add_rewrite_rule(           '(.+?)/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(.?.+?)/([0-9]{6})(/[0-9]+)?/?$',         'index.php?pagename=$matches[5]&page=$matches[7]',         'top');


Rename attachments during upload

Here's the function I use for WP to rename images during upload on the fly and set the image's filename to match the post slug.               function wpsx_5505_modify_uploaded_file_names($arr) {          // Get the parent post ID, if there is one     if( isset($_REQUEST['post_id']) ) {         $post_id = $_REQUEST['post_id'];     } else {         $post_id = false;     }          // Only do this if we got the post ID--otherwise they're probably in     //  the media section rather than uploading an image from a post.     if($post_id && is_numeric($post_id)) {              // Get the post slug         $post_obj = get_post($post_id);          $post_slug = $post_obj->post_name;              // If we found a slug         if($post_slug) {                  $random_number = rand(10000,99999);             $arr['name'] = $post_slug . '-' . $random_number . '.jpg';              }          }          return $arr;          }     add_filter('wp_handle_upload_prefilter', 'wpsx_5505_modify_uploaded_file_names', 1, 1);      I want to keep the original filename adding $ post_slug [thread_title]-[original_filename].ext


After import, oEmbeds non-functional until manual republish

I've just finished cleaning up the data from an application I was using previously and have got everything into a few WXR files. As a final test, I just imported them back into a local test installation, and all Vimeo and YouTube oEmbeds are failing. (This presumably applies to any other oEmbed media; it just so happens those are the majority in this case) All that gets displayed is the video URLs as plain text. The only way I've found to force the embeds to become functional is to manually republish the various posts, and it must be done via the full post edit screen. Quick Edit'ing and bulk editing on the listing screen has no effect. There are ~2000 of these posts, so this process is completely out of the question. Is this a known problem? And, obviously, is there a way around it?   I can't find anything that matches this situation so far. Most support threads that seem close have to do with the import process stripping iframe/object embeds, not disabling oEmbeds. Others involve the oEmbed URLs not being recognized at all(read: the feature failing altogether), not in this specific context. Alternately, what is the difference between publishing a post via quick/bulk editing and doing it on the full edit screen? ( _Why_ is there a difference?) And can that be hacked into the other process so I could at least do it that way? [edit]   Just confirmed the behavior on the live installation.   I don't expect there'll be anything interesting, but for reference a snippet of a couple of posts from one of the WXR files.


Force a specific template based on the URL

When a user browses to a URI beginning with "/forums", WordPress should call a specified template. For example, all of these URLs:   * mysite.com/forums   * mysite.com/forums/questions   * mysite.com/forums/questions/1/my-question   * mysite.com/forums/questions/ask   * mysite.com/forums/users ... should call the following template: **mytheme/page-forums.php** I believe this involves **WP_Rewrite** , but I have no clue what to do from here. Any ideas?


How can I temporarily remove content from all pages, but leave up URL?

How can I temporarily remove content from all pages, but leave up the URL? I need to turn off all site content, but leave the URL's up so google can still find them. ...at least I think I want to do this. Basically, I am in negotiation with another site about who "owns" the content, but both of us have agreed to remove the content for 10 days during this discussion. However, I was thinking that I'd leave the URL's up so I don't get totally slammed by Google for have the entire site down. Or does it matter if there's no content. I'd hate to lose my position in Google for being down 10 days. so anyways, is there a way to show a maintenance message for each URL until this is resolved?


.htaccess RewriteRule to include post type and taxonomy

I'm trying to rewrite this url www.domain.com/gallery/?university=birmingham to an seo friendly one like this www.domain.com/uni/birmingham/gallery the (?university=birmingham) represent the taxonomy and gallery is the post type. At the moment this url (www.domain.com/gallery/?university=birmingham) works fine, it displays the right posts, just haven't had any success in rewriting it to the one above I have tried doing this (which should work):               RewriteEngine On     RewriteRule ^uni/([0-9A-Za-z_-]+)/(.+)$ /$2?university=$1 [QSA,NC,L,R=302]               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /students/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /students/index.php [L]               </IfModule>      can anyone please point me in the right direction or show me what am doing wrong?


How to roll back a wordpress plugin update?

Yesterday I updated my wordpress seo by yoast plugin to version 1.2.8.4 from version 1.2.7 and my admin panel is messed up. I searched through the support forum but the plugin author hasn't replied to the existing threads related to same update issues. So I think roll back to previous version of plugin would be the best option until a fix to the above issue is not released by the plugin option. I have database backup files and my home directory backup files available with me. I searched in wordpress forums but couldn't find exact details on how do I roll back my plugin update. Can someone here guide me with the procedure or refer me to a solution?


Network Admin URL is shown to anyone before accessing a blog

I have a multisite setup and I noticed today that my security was not working properly. Each of my blogs has its own url :   * `http://www.example1.com`   * `http://www.example2.com`   * … My "main blog" is not in use, its URL exists in order to access the Network admin   * `https://wordpress.example.com`   * `https://wordpress.example.com/wp-admin/network/` Each time someone visits one of my websites (www1, www2 …) there is an access to `https://wordpress.example.com/?dm=dcf8262sdfsdff0d8ebcc8608e55e9bf9a&action=load&blogid=9&siteid=1&t=239523830&back=http%3A%2F%2Fwww.example2.com%2F` Now, since my SSL certificate is self-signed and mostly because `https://wordpress.example.com/` is limited to my IP addresses I'm facing an embarrassing issue. Would anyone know what is happening with this redirection? Is it really necessary?


How to 'remember' a site member's last visited page?

I've seen this on a couple of sites - they offer a multipage tutorials to site members. When you return to the site, they have a link that takes to the last page of the tutorial you were on. How is this accomplished? Guessing it has something to do with the PHP session?


Wrapping a function in html tag and return?

I am creating a shortcode. The shortcode will output a list of pages with the wp_list_pages() function. I am using the ('title_li') parameter and the list headline will be removed, because it is left empty and the "ul tag" will be removed as well, which is not desired. http://codex.wordpress.org/Function_Reference/wp_list_pages#Hiding_or_Changing_the_List_Heading Now I am trying to wrap it in ul tag again. This is what I am trying but it will return list of pages in "li" with out the "ul tag".               function sitemap_function() {       $return_string .= "<ul>";       $return_string .= wp_list_pages('sort_column=menu_order&title_li=');       $return_string .= "</ul>";            return $return_string;     }          function register_shortcodes() {       add_shortcode('sitemap', 'sitemap_function');     }          add_action('init', 'register_shortcodes');      Hope someone can help me out here. Thanks in Advance.


Bulk edit wordpress images alt and title attributes

I uploaded around 600 pictures in different galleries in wordpress without setting the titles and alt attributes. I need to edit them, I was wondering a way to edit them by album, let's say the title of the pictures in the album soccer would be soccer1, soccer2 etc.. but without doing it manually?


wpdb->update error

I am trying to update the value of an entry in the gravity forms detail table. I am simply trying to update the 'date' field inside of an entry. Here is my query:                       $update_date = $wpdb->update(                  'wp_rg_lead_detail',                  array(                      'value' => the_date('Y-m-d')                 ),                  array(                      'lead_id' => 170,                      'field_number' => 16                 )             );      It seems to be returning an error. This is the first time I am using $wpdb at all, so I may be doing something wrong here. Thanks!


Search & Replace trailing strings

I need to filter the_content/the_excerpt and search & replace the following prepared array:               $searchArray = array("foo", "bar", "foo bar", ...);      My problem is the fact, that using php's **str_replace()** function it doesn't replace trailing strings like "foo bar". Instead it replaces only the "foo" without checking for the "foo bar" to be replaced. I understand why but I'm not sure how to solve this?               $content = str_replace(array_keys($searchArray), $replaceArray, $content);          add_filter('the_content', 'my_search_and_replace_function');


Is There a Difference Between Taxonomies and Categories?

I've been reading the codex for WordPress closely and am confused about the vague definitions between what a Taxonomy is and what a Category is. For that matter, term is also a word that is used in the description of Taxonomies, but seems used in a manner that hints that it isn't solely limited to a Taxonomy. Both are described as a way to classify and group together posts. I do understand that Taxonomies are a more general form of categories, but how exactly do they relate to each other? Is there a subtle difference I'm just not picking up on?


Disable only the main feed?

It's possible to make a site totally inaccessible via feeds (RSS, Atom, RDF) with a function like this:               function itsme_disable_feed() {         wp_die( __( 'No feed available, please visit the homepage!' ) );     }     add_action('do_feed', 'itsme_disable_feed', 1);     add_action('do_feed_rdf', 'itsme_disable_feed', 1);     add_action('do_feed_rss', 'itsme_disable_feed', 1);     add_action('do_feed_rss2', 'itsme_disable_feed', 1);     add_action('do_feed_atom', 'itsme_disable_feed', 1);     add_action('do_feed_rss2_comments', 'itsme_disable_feed', 1);     add_action('do_feed_atom_comments', 'itsme_disable_feed', 1);      But that disables feeds for the entire site i.e. the main feed, feeds for categories, tags, comments, posts, pages, custom post types, etc. How do I disable just the **main feed** and the **main comments feed** of the site? i.e. only make `site.com/feed/` and `site.com/comments/feed/` inaccessible. Simply hiding feed using something like this (below) isn't an option:               remove_action( 'wp_head', 'feed_links_extra', 3 );     remove_action( 'wp_head', 'feed_links', 2 );


wp_enqueue_script() doesn't work with AJAX

My problem is: I made an AJAX call using this code               wp_enqueue_script( 'prefix-myscript-name', plugins_url( 'js/ajaxcall.js', __FILE__ ) );      I made the call and the AJAX just going fine. I used this code:               add_action( 'wp_ajax_ajax_action', 'ajax_response' );     add_action( 'wp_ajax_nopriv_ajax_action', 'ajax_response' );          function ajax_response(){         wp_enqueue_script( 'prefix-myscript-call', plugins_url( 'js/myscript.js', __FILE__ ) );     }      I used an `alert('Test')` in `ajaxcall.js` but it's not showing up! I'm disappointed. Any Solution?


Custom permalink structure only saves with index.php inserted

So I'm having this weird issue on the dashboard where custom permalinks only (default, day and name, month and name etc. those all work fine) doesn't save. I can choose the radio button and click "Save Changes" and the radio button will revert to one of the previous choices that works fine. And so I found this online which suggests to add index.php preceding the link, and it works now - but I feel this fix is a "bandaid" of sorts and doesn't actually resolve the issue. Are there any repercussions of using index.php in the custom permalink structure? Also, if it helps, the site was updated from 3.4.1 to 3.9.1, no PHP errors, all plugins are disabled, and there was an htaccess file missing, but I put one in using this. I am also seeing the htaccess actively update whenever I choose one of the options that work so it's writable. Any idea why only the custom permalink structure is an issue and can I safely insert index.php into it as a fix?


WP-ecommerce : Change the price before inserting it into the cart

The question is: How can I change/set the product price to `0` for every product whenever a product added to the cart. There is a `hook` in the plugin as `wpsc_set_cart_item` so I can call it but can't figure out how to change the price on the fly and return the new parameters. Hope someone can help me. Please ask anything you need to know. Thanks.


event organiser not loading in main content area

there is possibly a very simple answer for this, but im afraid im a novice at this stuff :( on my wordpress site Im using the event list shortcode in the main content area and the calendar in the sidebar. however whenver I click on an event to view it in full, either from the list or from the actual calendar...it loads it up in the sidebar and not the main content area. I hope you can help :) thank you very much! I really like the plugin, I just cant seem to get it the work as i would like. thanks ross


Logged in user ID as post ID

Is there a way to automatically insert the current user ID as the post category name or maybe have WordPress display only the post with a category name that matches the current logged user ID?               <?php              $query = new WP_Query('category_name=current-user-id');              if($query->have_posts()) : while($query->have_posts()) : $query->the_post();              ?>                <?php                 the_content( __('Read the rest of this page »', 'template'));                endwhile; endif;               wp_reset_postdata();          ?>


Trying to edit archive.php to only show post extract, with featured image

I am using two themes (full and desktop), so I am trying to get them to behave in the similarly. The archive.php for the mobile theme is doing what I want, which is to just show the title and post excerpt. I think this is the bit of code that does that:               <?php while ( have_posts() ) : the_post(); ?>         <?php get_template_part( 'content', get_post_format() ); ?>     <?php endwhile; ?>      The archive.php for the desktop site is showing whole posts, where I want it to only show the excerpt, as well as featured images.               <div <?php post_class() ?>>        <?php the_category(' / '); ?> — <?php edit_post_link( __( 'Edit', 'mythemename' ), '', ' — '); ?>  <?php comments_popup_link( __( 'No Comments', 'mythemename' ), '1 Comment', '% Comments' ); ?>
           <?php the_time('d'); ?>
<?php the_time('M \'y'); ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e( 'Permanent link to ', 'mythemename' ); ?><?php  the_title_attribute(); ?>"><?php the_title(); ?>

           <?php the_content( 'Continue reading →' ); ?>

      I don't know it does not use a php function to do all that. How could I replace that with something that will show all the same stuff, but only the post excerpt, with featured image?


Avoiding Duplicate function names in Post Loop (WP_Footer script)

Say I created a plugin that injects content (used as a shortcode) into a post. I'm trying to push that code for each post to the bottom of the page. This works fine, however when you are on an archive page with multiple posts using the same shortcode, there is an obvious conflict because the function names become duplicate and it will only output the footer code (activate_flex_slider) once.               <?php     function your_function() {         echo '
This is inserted at the bottom
';     }     add_action('wp_footer', 'your_function');     ?>      What i'm trying to do is output footer script so that there are multiple jQuery instances pointing to their respective ID's...               <?php         function flex_slider() {             $output ='

Slide Content

';             return $output;         }                   function activate_flex_slider(){             ?>              <?php         }              // Hook into footer so slider becomes active after page loads         add_action('wp_footer','activate_flex_slider');              // Create the Shortcode         add_shortcode('flex_slider', 'flex_slider');         ?>


Plugin Expires Headers - W3 Total Cache

Using the Google PageSpeed Online, it looks like the CSS/Images/JS files of most of my plugins (including wp-nivo-slider) do not get their expires-headers set. Is there a solution for this so that W3 Total Cache will set the expires headers on all the media on my page?


Is Wordpress fast enough for a heavy traffic project?

I was always a WP guy, built many small sites with it. I will create a new community with a big fanbase and I was wondering if 3.1.3 is fast enough? I didnt have the opportunity to work with it since 3.0. How does it react with heavy traffic web sites? Is it something that will make me worry enough to search for a lighter CMS or should I rely on it even with hundreds of visitors per day? I know about the tricks/tips to make it feels faster but is it by default ? Thank you for your answers.


Plugin (or Theme) containing its own Plugins?

My Theme defines its own **actions** and **filters** so that it can be _extended_ by third-parties without having to fork or modify the Theme's core code. I already have a few plugins specific to my Theme, that I'm installing in the usual way in `wp-content/plugins` and activating through the Admin panel. However, for ease of use, I would like to **bundle a few plugins directly into my Theme itself** , for example in `my_theme/plugins`, without having to require the user to move the plugins he wants to install to the WordPress plugin directory (thus breaking the Theme's update capabilities, etc.). **Have you seen any Theme or Plugin that does that in an elegant way? What are best practices to doing that?** In particular, a few questions come to mind if I were to implement such a system:   * Is there a way to easily configure a custom plugin directory into WordPress, in addition to `wp-content/plugins`?   * If I were to simply implement my own naive plugin activation system, what steps should I take? Do I just need to set up a basic admin panel listing, store a list of activated "custom plugins" and just include the corresponding PHP files on Theme init? Thanks for your help! _EDIT: Related to, but different from,Are drop-in plugins a product of design and Add Plugins to Wordpress Theme: in the present case, plugins don't make sense without the Theme (they extend it) and they're written by the same person/company._


Displaying a list of categories ordered by popularity?

I would like to add a list of categories to my template showing only the 5 most popular categories(by number of post views within each category). Is this something easy or would it take heavy customization? This is the code I am currently using:               <?php wp_list_categories('number=5&show_count=1&orderby=count&order=DESC&title_li=') ?>      This code displays the top 5 categories based on number of posts within the category, I'm hoping that I can make it a bit more specific and list them in order of which categories have the most post views. Thanks in advance!


Get $image_id after uploading with media_sideload_image()

I want to upload a image and set it as a featured image in a post. What i tried was this:               $image_id = media_sideload_image($image_url, $post_id, $post_id);     update_post_meta($post_id, '_thumbnail_id', $image_id);      But media_sideload_image() is not returning the image_id, but the render html image. How can I get the image_id??


can't see custom post content filtered under "mine" filter in admin panel

after creating a custom post type with custom post type UI plugin, and after creating the capabilities for a new role to edit, delete and publish it's own custom posts with User Role Editor plugin, i've encountered this issue. if two or more of the users published content in the custom post type, the system will show a new filter link called "Mine" for each of the users, and it will be the default filter for this page: http://www.mysite.com/wp- admin/edit.php?post_type=custom the problem is that it echo's "no item found.", although the user clearly have published content in this custom post type. when i switch to the "all" filter it will show also the user's content, but not in the "mine" filter. it's very frustrating! can figure it out after several hours. can somebody help with that? * * * I don't have code actually, it is more of a Plugin / core capabilities misusing, that I don't really understand. the flow was like this (and i'm sorry but the images will be in Hebrew. i tried to translate all of the important stuff that are problem related): I have created a custom post type with "custom post type UI". Up until now I have never had any problems with this plugin (it's my first multi users / different roles kind of site). I have created a new role with "User Role Editor" Plugin or with "Members" plugin. the problem below is accruing on both, and that's way i think it's not a plugin bug. I added to the Subscriber Role this list of capabilities and (message is the name of the custom type), without the capability "edit_others_messages as in ![without edit_others_messages](http://i.stack.imgur.com/1jtGK.png) and when i'm using as subscriber, the default url of the "all messages" menu button is the "mine" link, and it's empty! - no messages found! ![mine tab - no messages found](http://i.stack.imgur.com/RPpuY.png) but when i'm clicking the "all" tab, it does show me the list of all messages and knows what post is of that subscriber user, and which of them isn't. ![enter image description here](http://i.stack.imgur.com/C12WW.png) so what i want is to understand how to give the user role the permission only to manage it's own custom post types, but to aliminate the "not found" query at the "mine" link (that is - the primary query of the "all messages" page "wp-admin/edit.php?post_type=messages" please help.


If taxonomy exists then to show some code

I want to insert following custom code in single.php can I set condition that if specific taxonomy exist then show and work this code otherwise not;
 All courses in<?php echo get_the_term_list($post->ID,'country', ' ', ' ', '' ) ; ?>
All courses in<?php echo get_the_term_list($post->ID,'institute', ' ', ' ', '' ) ; ?>
All <?php echo get_the_term_list($post->ID,'subject', ' ', ' ', '', '' ) ; ?> courses worldwide
All<?php echo get_the_term_list($post->ID,'qualification', ' ', ' ', '' ) ; ?> courses worldwide
Alphabetical List: <?php echo get_the_term_list($post->ID,'alphabetical', ' ', ' ', '' ) ; ?> worldwide


Add Google Analytics manually, or use a plug-in?

Our situation is that we only dabble with Wordpress, however one of our Wordpress customers wishes to add Google Analytics to his site. I'm assuming we can do this manually, relatively easily. And our instincts would be to go down that route. The customer is only small scale and won't need to do anything especially sophisticated, at least at this stage. We want to keep this simple. Is it best to avoid a plugin? ## Update Thanks for all the great answers- in the end we did use a plug-in. As promised by the experts who answered below it was super straightforward.


iframe works on a page, but not a single, why?

I am trying to load a vimeo video into a single page, but it is telling me:               Given URL is not allowed by the Application configuration.      but on other pages the same iframe, copied and pasted into a page template, works fine.               <iframe src="http://player.vimeo.com/video/4426465" width="400" height="230" frameborder="0"></iframe>


Creating multiple blogs

I'm trying to bulk-create a certain number of blogs:                 $blog_count = 5;       $site = get_current_site();            while($blog_count > 0){         shuffle($words);              $blog_title = implode(' ', array_slice($words, 0, mt_rand(1, 3)));         $blog_domain = $blog_path = sanitize_key($blog_title);              if(domain_exists($site->domain, $site->path.$blog_path, $site->id)) continue;              $blog_id = wpmu_create_blog($site->domain, $site->path.$blog_path, $blog_title, 0, '', $site->id);              echo "Created - {$blog_id}";         $blog_count--;            }      And I cannot get the paths set up correctly on all blogs. In this case only 2 out of 5 blogs work correctly.   * `$site-domain` is "localhost"   * `$site->path.$blog_path` is "/wpmutest/thenameoftheblog/" (this is not a sub-domain install) When I go and edit them, the "Update siteurl and home as well." option is unchecked on the problematic blogs, and I cannot update it (it doesn't change after I press save). It seems that the database tables are not getting created. Am I doing something wrong here, or is this a bug?


background/font size change and remember

I want to create font size and background change buttons, which i know how to do it. The problem is with remember it, so if user will go to a different page, background and font will stay the same. How can i do it? I was thinking about saving this in cookies. What do you think about that? Is anyone can write an example of saving valible in cookies in wordpress.


If paginated comments don't span to a second page, how do I hide the div wrapper?

I have a div wrapper around my comments pagination. I have the comments set to paginate in the Wordpress admin at 10 comments per page. I want to hide the div wrapper if there are less than 10 comments (i.e. the pagination links aren't shown). I can't figure out how to do this. I know how to hide the div wrapper if pagination is turned off altogether, but I don't know how to check to see if the comments don't span to a second page when pagination is turned on. Here is my code:

                                <?php paginate_comments_links($args); ?>

      I would like to hide the comment-nav-wrapper altogether if the comments don't span to a second page. Is there some sort of Wordpress function for this, or do I need to come up with a bit of custom code?


Geo Mashup Maps show only specified categories

I'm using the geo Mashup plugin to display maps on my site. I've changed a pages template so it now only lists pages from certain categories instead of listing them all which has now effected my global map to only show maps from the first categories I specify should be listed. I'm using: to show the map is there a way to give the map a list of categories it should be displaying? I can't find anything to suggest how you would do this.


Check if on Custom Post Type for TinyMCE buttons

I'm adding TinyMCE buttons to my plugin and they're working, but I only want these buttons to show up for a certain custom post type. I followed this tutorial if it helps: http://www.tutorialchip.com/wordpress/wordpress-shortcode-tinymce-button- tutorial-part-2/ How can I have that check if they are editing/posting a post in a custom post type of lets say, `newpages`?


How to choose which template to be used for multiple taxonomy query?

Since 3.1 WordPress support multiple taxonomy query. The question is : If I have a two taxonomy query, e.g:               http://localhost:8888/site/?lot-term=australia&story-type=note      how can I determine which template to be used for the query? On the first try, it loads taxonomy-lot-term.php, but after I re install the theme, it loads taxonomy-story-type.php instead. After some experiment, I found a way to make it use my preferred template file by using a single taxonomy query first (the preferred taxonomy template file) and altering it using query_posts. But I believe there is a better way to do it since it add another SQL query. Thank you in advance.


Get author's first name

I am probably being a little dumb here, but can anyone point me in the right direction. I am trying simply display the authors first name as a link in my loop. But the doesnt seem to be any options with the `get_author` tag. This is what I got so far.               Posted by <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author"><?php printf( __( '%s' ), get_the_author() ); ?>      Thanks Josh