title: A spam bot loves me, what can I do?

text: I'm receiving many many spam comments using the same username and I guess it is a bot that keeps on submitting comments. In one week I get around 100 such comments (which is quite a lot for my small blog). I want to have a look at all comments that are marked as spam (just in case Akismet is too strict on a certain legit comment), but this is really annoying. Therefore I have two small questions:   * How can I tell WP to trash all comments that come from a certain username?   * What do you generally do in situations like this?


title: Ajax, Permalinks and post_thumbnail

text:
As i'm new to AJAX, i'm still learning a lot and have learned a lot over the past weeks. I do need some more assistance on an AJAX issue though: I'm using the following code to display post_thumbnails in a slider which when clicked go to the specific portfolio piece:
          <?php query_posts('cat=16&post_type=portfolio'); ?>             <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                 <li class="<?php foreach((get_the_category()) as $category ) { echo $category->slug . ' '; } ?>all">                         <?php if ( has_post_thumbnail() ) { ?>                     <a id="caseStudy" href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?>                     <?php } else { ?>                     <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/post-thumb.jpg" width="141" height="73" alt="<?php the_title_attribute(); ?>" />                         <?php } ?>
             <?php endwhile; endif ?>             <?php wp_reset_query(); ?>
      What i'm looking to do is to have the portfolio piece content load on the same page. I'm using this code:               var ajax_load = "<img style='margin-top: 150px;' src='<?php bloginfo("template_url"); ?>/images/loader.gif' alt='Loading...' />";                           var loadUrl = "http://localhost:8888/cnNew/?page_id=4";                          $("#ourTeam").live('click', function(){                             $("#teamLoad")                                 .html(ajax_load)                                 .load(loadUrl + " #innerTeam")                         });      to load other items onto the page but can't seem to get this way of calling it to work with the dynamically listed content. Can someone provide some assistance on the best way to achieve what i'm looking to do or at least a direction? Thanks!


title: Include taxonomy slug in url?

text: I have the following custom post-type and custom taxonomy setup:               add_action( 'init', 'create_post_type' );     function create_post_type() {         register_post_type( 'system',             array(                 'labels' => array(                     'name' => __( 'Systems' ),                     'singular_name' => __( 'System' )                 ),             'capability_type' => 'post',             'supports' => array('title','editor','comments'),                'public' => true,             'has_archive' => true,             'rewrite' => array( 'slug' => 'system' ),             )         );     }          function news_init() {         register_taxonomy(             'system',             'system',             array(                 'label' => __( 'Product Category' ),                 'sort' => true,                 'hierarchical' => true,                 'args' => array( 'orderby' => 'term_order' ),                 'rewrite' => array( 'slug' => 'product-category' )             )         );       }     add_action( 'init', 'news_init' );      Is it possible to include the custom taxonomy name in the URL? At present when I goto a custom post the URL looks like this: > http://www.domain/product-category/(post-name)/ How can I make it look like the following? > http://www.domain/(category-slug)/(post-name)/


title: What is the constant WP_USE_THEMES for?

text: Regarding the `WP_USE_THEMES` constant, the Codex states: > If you are using The Loop inside your own design (and your own design is not > a template), set WP_USE_THEMES to false. But what is the actual effect on WordPress from `WP_USE_THEMES` being set to true or false? I would like to know how it's used by WP.


title: Restrict category choice in dropdown menu?

text:
**Hmmm... maybe trickier than I hoped? If this is simply impossible then please do let me know :-)** Question Refinement:How can I adapt the include section of this code to use category names instead of id's? Thanks               $dropdown = wp_dropdown_categories( array(     'include' => '58, 3',         'name' => 'category_id[]',         'hide_empty' => false,         'echo' => false,     ) );      * * * I recently started using this code to force users of a multisite to select a category from a dropdown menu before creating a new post. Can anyone help me restrict the category options to just a few specific categories eg. news / products? Even just not displaying sub-categories would be helpful. Thanks UPDATE: I found adding this line I was able to restrict the choice to just 2 categories:                'include' => '58, 3',      But how can I make this work with cat names / text instead of id numbers as it's for a multisite & I don't have control over cat id's when new sites are created???? CODE:               add_filter( 'load-post-new.php', 'wpse14403_load_post_new' );     function wpse14403_load_post_new()     {     $post_type = 'post';     if ( isset( $_REQUEST['post_type'] ) ) {         $post_type = $_REQUEST['post_type'];     }          // Only do this for posts     if ( 'post' != $post_type ) {         return;     }          if ( array_key_exists( 'category_id', $_REQUEST ) ) {         add_action( 'wp_insert_post', 'wpse14403_wp_insert_post' );         return;     }          // Show intermediate screen     extract( $GLOBALS );     $post_type_object = get_post_type_object( $post_type );     $title = $post_type_object->labels->add_new_item;          include( ABSPATH . 'wp-admin/admin-header.php' );          $dropdown = wp_dropdown_categories( array(         'name' => 'category_id[]',         'hide_empty' => false,         'echo' => false,     ) );          $category_label = __( 'Category:' );     $continue_label = __( 'Continue' );     echo <<<HTML

{$title}
          <form method="get">

                     {$category_label}	                     {$dropdown}

                     	                     <input name="continue" type="submit" class="button-primary" value="{$continue_label}" />

         <input type="hidden" name="post_type" value="{$post_type}" />     </form>
     HTML;     include( ABSPATH . 'wp-admin/admin-footer.php' );     exit();     }          // This function will only be called when creating an empty post,     // via `get_default_post_to_edit()`, called in post-new.php     function wpse14403_wp_insert_post( $post_id )     {     wp_set_post_categories( $post_id, $_REQUEST['category_id'] );     }


title: Pull posts from another wordpress install on same server

text: I've searched already and couldn't find anything tailored to my specific problem, apologies if it has already been asked though. I have a public Wordpress install and a members only one on a subdomain. The reason for this is that they are both very different sites in terms of functionality so creating members only posts in the main site is not an option. On the subdomain new premium content will be added, but I also need to pull in the posts from the public site. I've looked into feed urls but because I've implemented quite a specific search customisation on the subdomain I need these posts to be searchable. For example I have an additional posts plugin 'post countries' showing a country associated with the post. Is this still something the feed url would be able to handle, or are there any other alternatives? Thanks **EDIT** This is the way my current private search is setup, I've just pasted in the relevant code.               $args = array(     'post_type' => 'post',      'show_posts' => '10',      'paged' => $paged     );          $the_query = new WP_Query($args);           <?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>         // The output      In my own sites private db results are stored in `$the_query` and public site results are stored in `$allsearch`, which would mean I should add the following and make my loop vanilla.               $the_query->posts=array_merge($the_query->posts,$allsearch);     $the_query->post_count=count($the_query->posts);      Does that sound right, it's not pulling in any posts from public site?


title: How do I insert a short tag after 350 words in post_content?

text:
I have 700 posts mostly in excess of 1000 words each. I'm setting this up as a membership site. I'm using wishlist member and would like to protect all the content after the first 350 words. This requires placing a short tag after the 350th word and another short tag at the very end of the post. Adding the shortcode at the end seems pretty straightforward. However, I can’t figure out how to get the short code into the middle of post_content.. I’ve considered a couple different approaches including: a. Trying to figure out a regular expression find and replace in dreamweaver working with the xml flat files b. Trying to work with a query in mysql to query the post content field, count the words in that field, and then insert the shortcode tag there c. Running some php script to achieve the result (something similar here, but not quite the same http://bacsoftwareconsulting.com/blog/index.php/wordpress-cat/how-to-create-a- variable-length-excerpt-in-wordpress-without-a-plugin/ ) d. Or some combination of the above or some more incisive simpler answer As I am looking to make a permanent change to the data (and not do something on the fly with the theme each time an article loads up) the mysql option seems like the most appropriate way to do this. This is not a find and replace in the simple context of looking for a specific string and replacing it, but instead counting to a certain position in post_content and then either   1. adding a shortcode [example_shortcode] or   2. copying the first portion of post_content up to the and including the 350th word, concatenating that with [example_shortcode], plus all remaining text after the 350th word, plus the closing [/example_shortcode] **Some of my research leads so far:** ergo a little more involved than example of search and replace query I suspect it may require the substring function more on substrings in mysql as in this example where substrings were used for pagination pagination link               SELECT SUBSTRING(post_content,1000,1000) FROM posts WHERE id=x      **Visual example of my goal** > How can I insert the first tag after say the first 350 words of a post and > the last tag at the end of a post and repeat across all of our posts 700+ > posts? ergo > > Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. > Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at > nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec > tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget > nulla. Class aptent taciti sociosqu ad litora torquent per > > skip to -> ** word 350 ->Vestibulum [example_shortcode]**ante ipsum primis > in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia > molestie dui. Praesent blandit > > skip to end of post Morbi lacinia molestie dui. Praesent blandit dolor. Sed > non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum si. > [/example_shortcode] * * * For a variety of reasons, the path of simply writing a function to dynamically add the tags as opposed to updating the db has **proven unworkable**. The main reason is due to a deficiency (lack of options) in the Wishlist member api. **bottom line** it doesn't support using the php version of short tags. (note if I had it to do over again I probably would have gone with a different member plugin solution and not something so closed down as wishlist). That said, the only viable option at this point is to simply update the db by inserting the shortags into the posts with the appropriate category. (This is what I asked here in the original question and thus far no solutions have been suggested, although the alternatives were plausible they were not workable in this situation). So now, I'm half way back to the first step. How to do a mass update of almost all wordpress posts. Specifically all posts that are not in two categories. There are 3 related suggestions that I have found to do mass updates in wordpress although they mostly perform updates on fields in wp_posts and not an update within the string of post_content.   1. See http://stackoverflow.com/questions/7917725/update-all-wordpress-posts /* Plugin Name: Example Description: This is not just a plugin, it's _CODE_.. Author: */ add_action('init','example_hide'); function example_hide(){ $my_posts = get_posts( array('post_type' => 'post', 'numberposts' => 10 ) ); foreach ( $my_posts as $my_post ): $my_post['post_content'] = 'This is the updated content.'; wp_update_post( $my_post );              endforeach;      }   2. Then see this example that only updates slugs (something far easier to do in mysql btw http://stackoverflow.com/questions/12707469/update-all-the-posts-at-once-nothing-want-to-add-or-delete-only-update-so-that-p // get all posts $posts = get_posts( array ( 'numberposts' => -1 ) ); foreach ( $posts as $post ) { // check the slug and run an update if necessary $new_slug = sanitize_title( $post->post_title ); wp_update_post( array ( 'ID' => $post->ID, 'post_name' => $new_slug ) ); } Then 3 and I think this has the most promise http://www.michaelbrentecklund.com/wordpress-mass-update-posts-mass-update- pages-custom-post-types/07-18-2012/               /**       * Mass Update Posts      *      * Mass update portions of posts, pages or custom post types.      * Get all posts from a specified post type, determine the      * status of the post, choose a portion of the post structure,      * search for a string value associated with the specified key,      * specify a replacement string, and choose whether you want to       * search for a partial or exact match.      *      * @param string $post_type Post type to fetch posts from.      * @param string $post_status Status of the post (eg. publish, private).      * @param string $key Portion of the post (eg. post_status, post_type).      * @param string $find Value of the portion of post (eg. publish, page).      * @param string $replace String to replace value with. (eg. private, post).      * @param string $match_type Accepts 'partial' or 'exact' match.      **/     function mass_update_posts($post_type, $post_status, $key, $find, $replace, $match_type){         $args = array(             'numberposts'   => -1,             'post_type' => $post_type,             'post_status'   => $post_status         );         $posts = get_posts($args);         $return = '';         for($i = 0; $i < count($posts); $i++){             // Check if the portion of the post exists.             if(array_key_exists($key, $posts[$i])){                 if($match_type == 'exact'){                     // Check if the portion of the post matches exact search.                     if($posts[$i]->$key == $find){                         $action = 'update';                     } else{                         $action = 'return';                     }                 } elseif($match_type == 'partial'){                     // Check if the portion of the post matches partial search.                     $search = strpos($posts[$i]->$key, $find);                     if($search !== false){                         $action = 'update';                     } else{                         $action = 'return';                     }                 } else{                     $return .= '
Error! Specify either "partial" or "exact" match.
';                 }                 // Found the search query. Carry on.                 if($action == 'update'){                     // Set the portion of the post to be updated.                     $update['ID'] = $posts[$i]->ID;                     $update[$key] = $replace;                     // Update the portion of the post.                     $updated = wp_update_post($update);                     // Check if update passes/fails.                     if($updated){                         //array_push($replaced, array($posts[$i]->$key => str_replace($find, $replace, $posts[$i]->$key)));                         $replaced[][$posts[$i]->$key] = str_replace($find, $replace, $posts[$i]->$key);                     } else{                         $return .= '
Error! Key: '.$key.' was found, however, failed to update the post: #'.$posts[$i]->ID.' '.$posts[$i]->post_title.'.
';                      }                    } elseif($action == 'return'){                     $return .= '
Error! Could not find "'.$find.'" in key: '.$key.'.
';                 }             } else{                 $return .= '
Error! Invalid key specified.
';             }         }         // Posts were updated. Output the result.         if(!empty($replaced)){             $return .= '
Success! Updated '.count($replaced).' posts.
';             foreach($replaced as $key => $value){                 foreach($value as $old => $new){                     $return .= '
Old: '.$old.' =>
 New: '.$new.'
';                 }             }         }         echo $return;     }      I think that a combination of that last function combined with the evolving content limit function as initially conceived below by @userabuser and modestly amended by myself, might ultimately prove to be the solution...               //* Limited Content     add_filter('the_content', 'limited_content', 11);               function post_is_in_descendant_category( $cats, $_post = null ) {         foreach ( (array) $cats as $cat ) {             // get_term_children() accepts integer ID only             $descendants = get_term_children( (int) $cat, 'category' );             if ( $descendants && in_category( $descendants, $_post ) )                 return true;         }         return false;     }          add_filter('the_content', 'do_shortcode', 11); // From shortcodes.php               function limited_content($content) {              $limit   = 350; //word limit for non-member/non-subscriber         $words   = str_word_count($content);         $user_id = get_current_user_id();          //if it is not in either category we have to test membership     if ( in_category( array('2497','2811')) /*|| post_is_in_descendant_category(array('2497','2811')) */ ) {         return $content;              //check if the user is part of the "member" role if so, return the full content         } elseif ( user_can($user_id, 'member') ) {                     return $content;                      //otherwise for non members return 350 of the content                 } elseif ( $words >= $limit) {                          $contentteaser = explode(' ', $content, $limit);                     array_pop($contentteaser);                     $contentremainder = explode(' ', $content);                     $contentremainder = array_slice($contentremainder, 349);                     $contentremainder = implode(" ", $contentremainder);                     $contentteaser = implode(" ", $contentteaser);                     echo do_shortcode($contentteaser.' '.'[private_Silver level]'.$contentremainder.'[/private_Silver level]'. '... sign up to read more');                                 //if there's less than 350 words, just return whatever exists                 } else {                     return $content;                 }          }  // end function Limited Content


title: List all categories in options

text: I used to use the following code to make the list of all categories:               foreach($categories as $cat) {         print '<label>'.$cat->name.'</label>';         print '<input type="text" title="Add value" name="'.$themename.'_value_'.$cat->slug.'" id="'.$themename.'_color_'.$cat->slug.'" value="'.get_option($themename.'_value_'.$cat->slug).'" />';     }      It generates the list and unique input box for each category. But I have rewritten the structure using arrays: i.e.               $categories = get_categories('hide_empty=0&orderby=name');       $tz_wp_cats = array();       foreach ($categories as $category_list ) {           $tz_wp_cats[$category_list->cat_ID] = $category_list->cat_name;           }       array_unshift($tz_wp_cats, "Choose a category");          // ==========================//     //             Start the theme options!                  //     // ==========================//              $themename = "Name";         $shortname = "tz";              $options = array (              array(  "name" => __("selected", 'framework'),         "id" => $shortname."_selectedtab",         "std" => "",         "type" => "hidden"),              array(  "type" => "opentab"),              array(  "type" => "open"),              array(  "name" => __("Banner Settings", 'framework'),         "id" => $shortname."_banner_settings",         "type" => "title"),              array(  "name" => __("Show Header Advert", 'framework'),         "desc" => __("Check this to show a banner in the header of your site (468px x 60px)", 'framework'),         "id" => $shortname."_banner_header",         "std" => "false",         "type" => "checkbox"),              array(  "name" => __("Banner Image URL", 'framework'),         "desc" => __("Enter the full image URL of your banner (468px x 60px) e.g. http://www.example.com/banner.gif", 'framework'),         "id" => $shortname."_banner_img_url",         "std" => get_bloginfo('template_directory')."/images/header_advert.jpg",         "type" => "text"),      It is the same structure as suggested on http://blog.themeforest.net/wordpress/create-an-options-page-for-your- wordpress-theme/ What would be the solution to rewrite the original way? Any suggestions? (I have just a checkbox, text, textarea and file types)


title: Trying to uninstall a theme, but it's hijacking my home page

text: I'm trying to install Thesis on my blog, and I'm having an issue that's caused by the theme that's currently active, which is Structure by Okay Themes. This theme created a static home page when I installed it, but not in the way recommended by the WordPress docs. When I activate Thesis, the home page returns an empty HTML doc. I'm a developer, so I'm comfortable monkeying around behind the scenes, but I'm not sure where to start. Did the theme install a custom PHP file and set it as the home page? Any suggestions would be much appreciated. ## Update The `options` table has a `current_theme` value that names Structure:               +-----------+---------------+--------------+----------+     | option_id | option_name   | option_value | autoload |     +-----------+---------------+--------------+----------+     |       158 | current_theme | Structure    | yes      |     +-----------+---------------+--------------+----------+


title: Custom field outside the loop and inside an array

text:
I am trying to use a **custom field** inside a **widget** so it's therefore outside the loop. Taking it a step further, the theme I have is using an array to generate listings which makes it hard for me to understand. Basically, the theme uses a **feature image** to display thumbnails of each post and I want to use a **custom field**. Here is the piece of coding I need to change:                       <?php if($images && has_post_thumbnail()): ?>             <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image'); ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" width='290' height='160' /><?php echo $icon; ?>
             <?php else: ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php bloginfo('template_directory'); ?>/images/thumbnail.png&w=290&h=160" alt="<?php the_title(); ?>" width='290' height='160' /><?php echo $icon; ?>
             <?php endif; ?>      This is inside a counter with an array. This seems easy enough to do but my programming skills are very limited. I don't know PHP or WordPress very well especially when it comes to outside the loop and using arrays. I believe I just need to change this line:               <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image'); ?>      To something like this (but it doesn't work, I think it's because it's outside the loop):               <?php $image = get_post_meta($postid, 'Thumbnail', true); ?>      **In case you need to see more, here is the entire code on the widget page:**               function pyre_homepage_1col_load_widgets()     {         register_widget('Pyre_Homepage_1col_Widget');     }          class Pyre_Homepage_1col_Widget extends WP_Widget {              function Pyre_Homepage_1col_Widget()         {             $widget_ops = array('classname' => 'pyre_homepage_1col', 'description' => 'Homepage 1-column recent posts widget.');                  $control_ops = array('id_base' => 'pyre_homepage_1col-widget');                  $this->WP_Widget('pyre_homepage_1col-widget', 'Avenue Theme: Home 1-column', $widget_ops, $control_ops);         }              function widget($args, $instance)         {             extract($args);                  $title = $instance['title'];             $post_type = 'all';             $categories = $instance['categories'];             $posts = $instance['posts'];             $images = true;             $rating = true;             $show_excerpt = isset($instance['show_excerpt']) ? 'true' : 'false';                  echo $before_widget;             ?>                  <?php             $post_types = get_post_types();             unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item']);                  if($post_type == 'all') {                 $post_type_array = $post_types;             } else {                 $post_type_array = $post_type;             }             ?>

<a href="<?php echo get_category_link($categories); ?>"><?php echo $title; ?> »
                      <?php                 $recent_posts = new WP_Query(array(                     'showposts' => $posts,                     'cat' => $categories,                 ));                 ?>                 <?php                 $big_count = round($posts / 4);                 if(!$big_count) { $big_count = 1; }                 ?>                 <?php $counter = 1; while($recent_posts->have_posts()): $recent_posts->the_post(); ?>                 <?php                 if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {                     $icon = 'ID) . '-icon">';                 } else {                     $icon = '';                 }                 ?>                 <?php if($counter <= $big_count): ?>                 <?php if($counter == $big_count) { $last = 'block-item-big-last'; } else { $last = ''; }?>                 <div class="block-item-big <?php echo $last; ?>">                     <?php if($images && has_post_thumbnail()): ?>                     <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image'); ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" width='290' height='160' /><?php echo $icon; ?>
                     <?php else: ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php bloginfo('template_directory'); ?>/images/thumbnail.png&w=290&h=160" alt="<?php the_title(); ?>" width='290' height='160' /><?php echo $icon; ?>
                     <?php endif; ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?>
                     <?php the_time('F j, Y'); ?>, <?php comments_popup_link(); ?>                     <?php if($show_excerpt == 'true'): ?>
<?php echo string_limit_words(get_the_excerpt(), 15); ?> ...
<?php endif; ?>
                 <?php else: ?>
                     <?php if($images && has_post_thumbnail()): ?>                     <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image-thumb'); ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" width='50' height='50' /><?php echo $icon; ?>
                     <?php else: ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php bloginfo('template_directory'); ?>/images/thumbnail.png&w=50&h=50" alt="<?php the_title(); ?>"  width='50' height='50' /><?php echo $icon; ?>
                     <?php endif; ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?>
                     <?php the_time('F j, Y'); ?>, <?php comments_popup_link(); ?>
                 <?php endif; ?>                 <?php $counter++; endwhile; ?>
                  <?php             echo $after_widget;         }              function update($new_instance, $old_instance)         {             $instance = $old_instance;                  $instance['title'] = $new_instance['title'];             $instance['post_type'] = 'all';             $instance['categories'] = $new_instance['categories'];             $instance['posts'] = $new_instance['posts'];             $instance['show_images'] = true;             $instance['show_rating'] = true;             $instance['show_excerpt'] = $new_instance['show_excerpt'];                  return $instance;         }              function form($instance)         {             $defaults = array('title' => 'Recent Posts', 'post_type' => 'all', 'categories' => 'all', 'posts' => 4, 'show_excerpt' => null);             $instance = wp_parse_args((array) $instance, $defaults); ?>
                 <label for="<?php echo $this->get_field_id('title'); ?>">Title:                 <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" />

                 <label for="<?php echo $this->get_field_id('categories'); ?>">Filter by Category:                  <select id="<?php echo $this->get_field_id('categories'); ?>" name="<?php echo $this->get_field_name('categories'); ?>" class="widefat categories" style="width:100%;">                     <option value='all' <?php if ('all' == $instance['categories']) echo 'selected="selected"'; ?>>all categories</option>                     <?php $categories = get_categories('hide_empty=0&depth=1&type=post'); ?>                     <?php foreach($categories as $category) { ?>                     <option value='<?php echo $category->term_id; ?>' <?php if ($category->term_id == $instance['categories']) echo 'selected="selected"'; ?>><?php echo $category->cat_name; ?></option>                     <?php } ?>                 </select>

                 <label for="<?php echo $this->get_field_id('posts'); ?>">Number of posts:                 <input class="widefat" style="width: 30px;" id="<?php echo $this->get_field_id('posts'); ?>" name="<?php echo $this->get_field_name('posts'); ?>" value="<?php echo $instance['posts']; ?>" />

                 <input class="checkbox" type="checkbox" <?php checked($instance['show_excerpt'], 'on'); ?> id="<?php echo $this->get_field_id('show_excerpt'); ?>" name="<?php echo $this->get_field_name('show_excerpt'); ?>" />                  <label for="<?php echo $this->get_field_id('show_excerpt'); ?>">Show excerpt
         <?php }     }     ?>      Thanks so much!


title: Display metabox with date

text:
I'm trying to add metabox with date in WordPress. I used code from this page It works well, but I have a problem displaying the metabox values on page. My loop:               <?php query_posts(array('post_type' => 'event' , 'posts_per_page' => 9999, 'orderby' => 'menu_order', 'order' => 'ASC' ));     if (have_posts()) : while (have_posts()) : the_post();     $custom = get_post_custom($post->ID); ?>

<?php the_title(); ?>

Date: <?php echo get_post_meta($post->ID, '_day', true);?>.<?php echo get_post_meta($post->ID, '_month', true);?>.<?php echo get_post_meta($post->ID, '_year', true);?>

Hour: <?php echo get_post_meta($post->ID, '_hour', true);?>:<?php echo get_post_meta($post->ID, '_minute', true);?>
         <?php the_content(''); ?>
     <?php endwhile; endif; ?>      I added custom post type 'event'. Values in metabox(date/location) have been saved, but it haven't displayed on page. Why it doesn't work? Thanks for reply.


title: how to change # of tag posts on /tag page?

text: I have my blog page limited to 5 posts on the main page, which I'm happy with. However, I want my tag pages to list much more, maybe 15 or so. How do I most easily make this change? There's no option on the reading page. thx!


title: How to only show the first X words (from each post) on the home page?

text: How can you have it so that the site's home page will only show the first X (let's say 300) words of the post? But without using "more" tag, or hand filled excerpts? I am looking for a plugin/hack for WP 2.9 and onward. I came across several solutions so far, but am hoping for a recommended solution. Challenges I came a cross so far:   * What happens in case a tag (for example ) starts on word 295, and ends after word 301 ?   * Can it be possible to have a different X for the home page , tags page, category page - and so on?   * Can the format of the text be preserved? (all the images and text formating)?   * Having the plugin take the least amount of recourses from the server.


title: Options for CDN with WordPress Including Supporting Plugins?

text: What are the **options for Content Distribution Networks for use with WordPress**? I'd like to their objective pros and cons, their associated plugins or other ways to utilize them, their relative pricing, their appropriate customer profiles/scenarios/use-cases, projects they've been used on if you know of any, and any other relevant information. **This is a community wiki** and so please provide only one CDN option per answer and please don't duplicate answers. If you have something to include regarding a CDN already listed please either edit the answer or add comments. And **please vote up the solutions you recommend** and/or think are most viable. **UPDATE** : I found few resources on the web for WordPress+CDN so decided to list them here too:   * HowTo: Configure Wordpress To Use A Content Delivery Network (CDN)   * rewriting URLs for using a CDN for your Wordpress blog   * how to copy your Wordpress files to CloudFront efficiently   * Using a CDN for your WordPress blog   * Using a CDN with WordPress   * Plugin: WordPress Caching with CDN Integration   * Free CDN Plugin   * CDN Tools Plugin   * My CDN Plugin


title: How to call a funcion via a dropdown or a input? (Woocommerce funcion)

text: This is the function I want to call               function test() {     echo "test";     add_filter('loop_shop_per_page', create_function('$cols', 'return 24;'));     }      And I call it like this               <?php test() ?>       So it shows me the "test" text but not make the "filter" To be more specific, I want to show a dropdown with this options :10, 20, 30 so I can sort the list of products on a woocommerce site.


title: spaces inside parenthesis

text: The Wordpress coding standards states to put parenthesis both inside and outside opening and closing parenthesis. What is the rationale behind spaces on the inside of parenthesis? I've hardly ever seen that in any other code except PHP.


title: How to make permalink structure %category%/%postname%/ work for custom post type?

text: I'm trying to achieve the following permalink structure for a custom post type called "`concept`" with taxonomy "`category`"               http://domain/categoryname/conceptname      Note: The main problem here is I don't want the custompost type slug /concept to appear, and now it seems to be conficting with existing rewrite rules I did               global $wp_rewrite;     $concept_permalink_structure = '/%category%/%concept%/';     $wp_rewrite->add_rewrite_tag('%concept%/','([^/]+)', 'concept=');     $wp_rewrite->add_permastruct('concept/',$concept_permalink_structure,false );      and               add_filter('post_type_link', 'tt_concept_permalink2', 10,3);             function tt_concept_permalink2($permalink, $post, $leavename ) {              if($post->post_type != 'concept')                 return $permalink;              if( !isset($post->ID) ){             global $post;         }                   $categories = get_the_terms( $post->ID, 'category');              if( is_array($categories) && count( $categories ) > 0 ) {             $cat = $categories[key($categories)]->slug;             $permalink = str_replace('concept/', $cat .'/', $permalink );         }              return $permalink;          }      and it is working! # But! all other permalink( page, other custom post types ) are giving 404 error! How can I make them work?


title: Translating dynamic strings

text: In my form I have a dropdown. I'm getting the values and labels of the dropdown dynamically from SugarCRM via it's rest API. I would need to translate these strings. I tried to pass the dynamic string into the I18n localizaton function and translating the "Married" string using CodestylingLocalization plugin:               <?php __('Married','ja')?>     <option label="<?php echo esc_html(__($field['value'],'ja')); ?>"                                     value="<?php echo esc_attr(__($field['name'],'ja')); ?>"><?php echo esc_html(__($field['value']),'ja'); ?></option>      But that didn't work. Is there a way to translate the dynamic strings using I18n?


title: Editing a Wordpress plugin to add my own functionality

text:
I'm trying to add more fields to this php script. By default what it does is allow visitors to your site to input their name and email address to register it into a list on the back end, which I can then export as a .csv file. At the moment I'm attempting to add fields for phone number, city, state, ect. I've been able to add the fields, but they don't register on the back end. Actually when I finish adding a field, it breaks every other field. Here is my php code. Anything referencing number, or sml_number is what I'm trying to add. Edit: I wasn't being clear enough. I _think_ the problem is in the end of sml.php. Below are what I think the problems might be.                           // Handle form Post                 if ($_POST['sml_subscribe']) {                     $name = $_POST['sml_name'];                     $email = $_POST['sml_email'];                     $number = $_POST['sml_number'];                     if (is_email($email)) {                              $exists = mysql_query("SELECT * FROM ".$wpdb->prefix."sml where sml_email like '".$wpdb->escape($email)."' limit 1");                         if (mysql_num_rows($exists) <1) {                             $wpdb->query("insert into ".$wpdb->prefix."sml (sml_name, sml_email, sml_number) values ('".$wpdb->escape($name)."', '".$wpdb->escape($email)."', '".$wpdb->escape($number)."')");                         }                     }                 }      and                                       if ($_SERVER['REQUEST_METHOD']=="POST" and $_POST['sml_import']) {                                 $correct = 0;                                 if($_FILES['file']['tmp_name']) {                                     if(!$_FILES['file']['error'])  {                                         $file = file_get_contents ($_FILES['file']['tmp_name']);                                         $lines = preg_split('/\r\n|\r|\n/', $file);                                         if (count($lines)) {                                             $sql = array();                                             foreach ($lines as $data) {                                                 $data = explode(',', $data);                                                 $num = count($data);                                                 $row++;                                                      if (is_email(trim($data[0]))) {                                                     $c = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."sml where sml_email LIKE '".$wpdb->escape(trim($data[0]))."' limit 1", ARRAY_A);                                                     if (!is_array($c)) {                                                                                $wpdb->query("INSERT INTO ".$wpdb->prefix."sml (sml_email, sml_name, sml_number) VALUES ('".$wpdb->escape(trim($data[0]))."', '".$wpdb->escape(trim($data[1]))."', '".$wpdb->escape(trim($data[0]))."')");                                                         $correct++;                                                     } else { $exists++; }                                                 } else { $invalid++; }                                             }                                              } else { $message = 'Oh no! Your CSV file does not apear to be valid, please check the format and upload again.'; }                                              if (!$message) {                                             $message = $correct.' records have been imported. '.($invalid?$invalid.' could not be imported due to invalid email addresses. ':'').($exists?$exists.' already exists. ':'');                                         }                                          } else {                                         $message = 'Ooops! There seems to of been a problem uploading your csv';                                     }                                 }                                                            }      And below is the entire contents of the plugin for reference. sml.php:                           // Plugin Activation                 function sml_install() {                     global $wpdb;                     $table = $wpdb->prefix."sml";                     $structure = "CREATE TABLE $table (                         id INT(9) NOT NULL AUTO_INCREMENT,                         sml_name VARCHAR(200) NOT NULL,                         sml_email VARCHAR(200) NOT NULL,                         sml_number VARCHAR(200) NOT NULL,                     UNIQUE KEY id (id)                     );";                     $wpdb->query($structure);                      }                 register_activation_hook( __FILE__, 'sml_install' );                      // Plugin Deactivation                 function sml_uninstall() {                     global $wpdb;                      }                 register_deactivation_hook( __FILE__, 'sml_uninstall' );                      // Left Menu Button                 function register_sml_menu() {                     add_menu_page('Subscribers', 'Subscribers', 'add_users', dirname(__FILE__).'/index.php', '',   plugins_url('sml-admin-icon.png', __FILE__), 58.122);                 }                 add_action('admin_menu', 'register_sml_menu');                      // Generate Subscribe Form                       function smlsubform($atts=array()){                     extract(shortcode_atts(array(                         "prepend" => '',                           "showname" => true,                         "nametxt" => 'Name:',                         "nameholder" => 'Enter your name.',                         "emailtxt" => 'Email:',                         "emailholder" => 'Enter your email address.',                         "numbertxt" => 'Phone Number:',                         "numberholder" => 'Enter your Phone Number.',                         "showsubmit" => true,                         "submittxt" => 'Subscribe',                         "jsthanks" => false,                         "thankyou" => 'Thank you for subscribing to our mailing list!'                     ), $atts));                          $return = '<form class="sml_subscribe" method="post"><input class="sml_hiddenfield" name="sml_subscribe" type="hidden" value="1">';                          if ($prepend) $return .= '
'.$prepend.'
';                          if ($_POST['sml_subscribe'] && $thankyou) {                          if ($jsthanks) {                             $return .= "";                         } else {                             $return .= '
'.$thankyou.'
';                          }                     }                               if ($showname) $return .= '
'.$nametxt.'<input class="sml_nameinput" placeholder="'.$nameholder.'" name="sml_name" type="text" value="">
';                     $return .= '
'.$emailtxt.'<input class="sml_emailinput" name="sml_email" placeholder="'.$emailholder.'" type="text" value="">
';                     $return .= '
'.$numbertxt.'<input class="sml_numberinput" name="sml_number" placeholder="'.$numberholder.'" type="text" value="">
';                     if ($showsubmit) $return .= '
<input name="submit" class="btn sml_submitbtn" type="submit" value="'.($submittxt?$submittxt:'Submit').'">
';                     $return .= '</form>';                          return $return;                 }                 add_shortcode( 'smlsubform', 'smlsubform' );                      // Handle form Post                 if ($_POST['sml_subscribe']) {                     $name = $_POST['sml_name'];                     $email = $_POST['sml_email'];                     $number = $_POST['sml_number'];                     if (is_email($email)) {                              $exists = mysql_query("SELECT * FROM ".$wpdb->prefix."sml where sml_email like '".$wpdb->escape($email)."' limit 1");                         if (mysql_num_rows($exists) <1) {                             $wpdb->query("insert into ".$wpdb->prefix."sml (sml_name, sml_email, sml_number) values ('".$wpdb->escape($name)."', '".$wpdb->escape($email)."', '".$wpdb->escape($number)."')");                         }                     }                 }                      function plugin_get_version() {                     $plugin_data = get_plugin_data( __FILE__ );                     $plugin_version = $plugin_data['Version'];                     return $plugin_version;                 }                      ?>      index.php
              <?php screen_icon( 'themes' ); ?>
Mail list subscribers

                      <form method="post" action="?page=<?php echo esc_js(esc_html($_GET['page'])); ?>">                 <input name="sml_remove" value="1" type="hidden" />                             <?php                              if ($_SERVER['REQUEST_METHOD']=="POST" and $_POST['sml_remove']) {                                 if ($_GET['rem']) $_POST['rem'][] = $_GET['rem'];                                 $count = 0;                                 if (is_array($_POST['rem'])) {                                     foreach ($_POST['rem'] as $id) {                                          $wpdb->query("delete from ".$wpdb->prefix."sml where id = '".$wpdb->escape($id)."' limit 1");                                          $count++;                                      }                                     $message = $count." subscribers have been removed successfully.";                                 }                             }                                  if ($_SERVER['REQUEST_METHOD']=="POST" and $_POST['sml_import']) {                                 $correct = 0;                                 if($_FILES['file']['tmp_name']) {                                     if(!$_FILES['file']['error'])  {                                         $file = file_get_contents ($_FILES['file']['tmp_name']);                                         $lines = preg_split('/\r\n|\r|\n/', $file);                                         if (count($lines)) {                                             $sql = array();                                             foreach ($lines as $data) {                                                 $data = explode(',', $data);                                                 $num = count($data);                                                 $row++;                                                      if (is_email(trim($data[0]))) {                                                     $c = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."sml where sml_email LIKE '".$wpdb->escape(trim($data[0]))."' limit 1", ARRAY_A);                                                     if (!is_array($c)) {                                                                                $wpdb->query("INSERT INTO ".$wpdb->prefix."sml (sml_email, sml_name, sml_number) VALUES ('".$wpdb->escape(trim($data[0]))."', '".$wpdb->escape(trim($data[1]))."', '".$wpdb->escape(trim($data[0]))."')");                                                         $correct++;                                                     } else { $exists++; }                                                 } else { $invalid++; }                                             }                                              } else { $message = 'Oh no! Your CSV file does not apear to be valid, please check the format and upload again.'; }                                              if (!$message) {                                             $message = $correct.' records have been imported. '.($invalid?$invalid.' could not be imported due to invalid email addresses. ':'').($exists?$exists.' already exists. ':'');                                         }                                          } else {                                         $message = 'Ooops! There seems to of been a problem uploading your csv';                                     }                                 }                                                            }                             //echo $sql;                             if ($message) { echo '

'.$message.'

'; }                                  ?>

                                     <input type="checkbox">	                                     Name	                                     Email Address	                                     Number

                                     <input type="checkbox">	                                     Name	                                     Email Address	                                     Number

                                      <?php                                           $results = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."sml");                                     if (count($results)<1) echo '
No mailing list subscribers have been added.
';                                     else {                                         foreach($results as $row) {                                                  echo '
                                                         <input type="checkbox" name="rem[]" value="'.esc_js(esc_html($row->id)).'">	                                                         '.esc_js(esc_html($row->sml_name)).'	                                                         '.esc_js(esc_html($row->sml_email)).'	                                                         '.esc_js(esc_html($row->sml_number)).'
';                                                             }                                     }                                      ?>

                             <input class="button" name="submit" type="submit" value="Remove Subscribers" /> <a class="button" href="<?php echo plugins_url( 'export-csv.php', __FILE__ ); ?>">Export List                     </form>

       export-csv.php               <?php      require_once '../../../wp-load.php';     if (current_user_can('manage_options')) {         header("Content-type: application/force-download");          header('Content-Disposition: inline; filename="subscribers'.date('YmdHis').'.csv"');           $results = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."sml");         echo "First Name,Last Name,Email Address\r\n";         if (count($results))  {             foreach($results as $row) {                 $n = doSplitName($row->sml_name);                 echo $n['first'].','.$n['last'].','.$row->sml_email."\r\n";             }         }     }          function doSplitName($name) {         $results = array();              $r = explode(' ', $name);         $size = count($r);              if (mb_strpos($r[0], '.') === false) {             $results['salutation'] = '';             $results['first'] = $r[0];         } else {             $results['salutation'] = $r[0];             $results['first'] = $r[1];         }              if (mb_strpos($r[$size - 1], '.') === false) {             $results['suffix'] = '';         } else {             $results['suffix'] = $r[$size - 1];         }              $start = ($results['salutation']) ? 2 : 1;         $end = ($results['suffix']) ? $size - 2 : $size - 1;              $last = '';         for ($i = $start; $i <= $end; $i++) {             $last .= ' '.$r[$i];         }         $results['last'] = trim($last);              return $results;     }     ?>      Any and all help is much appreciated. Or even just a push in the right direction. I've been working on this for weeks, and I'm not terrific at php. Thank you very much.


title: Remove site root trailing slash

text: I am using Wordpress for a "news" section on a e-commerce site. So the root of the wordpress install is in a sub-folder. www.mysite.com/news I have setup the home & site URL to reflect this in the admin. I also make sure there are no trailing slashes in the permalinks. However, it keeps doing a 301 redirect and forcing a trailing slash so it looks like: www.mysite.com/news/ I even tried to force it in the wp-config.php file, defining the WP_HOME and WP_SITEURL parameters. I cannot for the life of me figure out where this is happening. I don't mind creating a small PHP function to rewrite this url (without any kind of redirect). Ideas?


title: Filtering results for post_type tells me I don't have permission

text: I have a post type that for some reason I am unable to access. Here is the message I get when I try to access it:               You do not have sufficient permissions to access this page.      edit.php?post_type=alt How can I change the permission? How can I find why it is blocking a certain user? **UPDATE** I use `register_post_type()` and in it I added `'assign_terms' => "edit_alt"`. But when I `var_dump( "$tax->cap->assign_terms" );` the `'assign_terms'` is back to `'edit_posts'`. I think this is the source of the problem. But how do I correct this?


title: Using Post ID and Page ID in same function

text: I've written a function to display a custom sidebar, which is outputted as a sidebar. On some pages, I have a Custom Field called 'show_sidebar', which I can assign as 'false' on pages which I do not want to display the Sidebar. On the pages, I have some more shortcodes set up to initiate a loop for specific post categories. I need to show the sidebar on each page (through page.php in theme files), with 4 posts printed, each of the same category of the main posts (they are all the same category). Problem is, to get the Custom Field, I need to use the `global $post;` method to get the Page ID and not the Post ID (none of the posts will have the Custom Field set as there is no point). This all works fine and I can get the value of Custom Field just fine. However, when I echo the shortcode, I need the ID of the posts on the page (generated through the loop shortcode I wrote). Here is my code:               function showSidebar() {         global $post; // so I get the Page ID, not the Post IDs         $customField = get_post_meta($post->ID, 'show_sidebar', true);         if ($customField == 'true' || empty($customField)) {             $showSidebar = true;         } elseif ($customField = 'false') {             $showSidebar = false;         } // get value of Custom Field 'show_sidebar' and check if it was true or false         $postCat = get_the_category($post->ID); // here is where I need to use the Post ID, not the Page ID         if ($showSidebar) {             echo do_shortcode('[sidebar category="'. $postCat[0]->name .'" no_of_posts="4" title="Latest '. $postCat[0]->name .'"]');         } // shortcode is initiated     }      So my question is, how can I use the Page ID in one part of the function, and Post ID in another part?


title: Display current category title on category page

text:
Using the following code in a category template, but instead of showing the current category page that I am on, it displays the first category of the first post. For example on Food category page it should say Food, but instead it says Desserts because the first post's category is desserts. Here is the site http://theveganproject.ca/wp/category/food/               add_action ( 'genesis_before_content', 'sk_show_category_name' );     function sk_show_category_name() {     $category = get_the_category();     if (is_category()) {         echo '
' . $category[0]->cat_name . '
';     }     }


title: Allowing HTML in Menu Descriptions

text: This has been answered elsewhere, but I am having a problem with the code. I'm using this:               remove_filter( 'nav_menu_description', 'strip_tags' );     add_filter( 'wp_setup_nav_menu_item', 'cus_wp_setup_nav_menu_item' );     function cus_wp_setup_nav_menu_item( $menu_item ) {     $menu_item->description = apply_filters( 'nav_menu_description', $menu_item->post_content );     return $menu_item;     }      This works fine except for when I first add the item to the menu. It then adds all the content from the post in the menu description area. Is there someway to avoid that? I can just delete the content after adding it the menu (and it works fine after that), but that is not very user friendly for my clients.


title: Twenty Ten theme - how to put a different header banner on every page

text: 1. In the Appearance Menu, submenu ‘Themes’ I prepared several custom banners which remain as menu choices if I do not want them any more. How can I erase them?   2. After searching for answers I found a site http://yoast.com/wordpress-theme-anatomy/ that explained the inner content of a wordpress page. In what they call the ‘cheat-sheet’ for ‘my’ blog’ the header section is referred to as the header-php.   3. In the FTP directory found on the godaddy server I found a listing showing among others file wp-blog-header.php. However, when I click on it the only thing that happens is for the square to the left to be marked. I assume it is within this file that I have to modify the HTML code so as to make the headers on each page independent (?) Anybody could direct me as to what to do next? Thank you


title: Custom Post Type vs. User Page

text: I'm creating a multisite network for authors and readers and I want each blog author to create a user profile. Ideally I would do this through a customized user admin area with a bunch of added custom fields, but it seems a bit clumsy and not sure how hard it would be to pull this info into the main site (I was thinking switching to that site, pulling the info, then back). The other way involved creating a Custom Post Type in the main site and manually creating the content myself and linking to the author's sites (sub sites). I know this is a general question without specific code, but I think it's an important question. One implication: I want to assign custom taxonomies to the users and run custom loops usign them (on the main site). I'm not interested in using BuddyPress because I only really need about ten custom fields and I want the sub blog authors to be able to use any theme they want. Thanks.


title: Use custom clean URLs for a plug in

text: I've created a plug in that displays a list of items from the database. I need to link from an item to the item description page, however instead of the link looking like:               item_description.php?item_id=2      I'd like it to look like:               products/this-is-the-product-name      How do I create the page I'm linking to and set it to be directed there? How can I read the slug? Thank you for any ideas!


title: Custom header content within a customer page template

text: I built a custom page template and everything is working swimmingly. I have a problem however making it so each custom page using the template can insert custom code into the header area. If you click this link here you can see the custom page template in action: http://www.gigyastaging.com/single-sign-on/ Notice the large background image with a lot of white space. I need to be able to insert on a per page basis custom code into that white space area. Is there an easy way to do this that I have overlooked? I can't create custom template files for each unique header, that is unrealistic. Ideally I could have some type of plugin or additional fields on the page editor that allows me to insert code into this space. Any ideas?


title: Woocommerce product info in a sidebar?

text: I'm having a terrible time trying to figure this out. On the single product page in woocommerce, I need to add a sidebar and move the product "summary entry-summary" into that sidebar. Leaving just the product image, and tabs in the main content area. Has anyone done this before or could help me out? Thanks in advance


title: Multiple WordPress on Virtual Host

text: I have AWS EC2 Linux server. Currently only one wordpress multisite mode is hosted in root folder (/var/www/html). Now I would like to host another wordpress site. So that I have enable apache virtual host. Here is my vhost.conf               NameVirtualHost *     <VirtualHost *>     ServerName firstdomain.com     ServerAlias www.firstdomain.com     DocumentRoot /var/www/html     </VirtualHost>     <VirtualHost *>     ServerName seconddomain.com     ServerAlias www.seconddomain.com     DocumentRoot /var/www/html/seconddomain.com     </VirtualHost>      I have one php test file inside seconddomain.com folder and I can browse by www.seconddomain.com After that I download wordpress and copy into seconddomain.com folder and change the wp-config.php. But I got the error "This webpage has a redirect loop". Is it because I have one wordpress in root folder or other security reason? Regards, Alex


title: wp_update_nav_menu_item() to insert categories

text: In the script below, I'm attempting to dynamically add categories to a custom menu. Everything works great, except for the fact that the categories do not have hyperlinks. What am I missing in wp_update_nav_menu_item() below?                       $cat_args=array(             'hierarchical' => 0,             'exclude' => '1',             'exclude_tree' => '1',             'hide_empty' => 1,             );                  $theCats = get_categories($cat_args);                  $name = 'Site Menu';             $menu_id = wp_create_nav_menu($name);             $menu = get_term_by( 'name', $name, 'nav_menu' );                  /* insert the a link to home */             wp_update_nav_menu_item($menu->term_id, 0, array(                 'menu-item-title' => 'Home',                 'menu-item-url' => get_bloginfo('url'),                 'menu-item-status' => 'publish')             );                  /* insert each category except uncategorized */             if (count($theCats) > 0){                 foreach($theCats as $category){                     wp_update_nav_menu_item($menu->term_id, 0, array(                         'menu-item-title' => $category->name,                         'menu-item-type' => 'taxonomy',                         'menu-item-status' => 'publish',                         'menu-item-object' => 'category',                         'menu-item-parent-id' => 0)                     );                 }             }                  theme_set_nav_menu($menu->term_id,'header-menu');


title: Collect Data from AIO SEO pack plugins

text: I have AiO SEO pack plugins installed on my WP. This plugins allow us to write custom "meta title" or "meta description" and we can make a "meta title" different from the "WP title" itself. My question is how to collect "Meta Title" from AiO SEO pack plugins and then embed the "meta title" to single post: `<h1>"meta title from Aio SEO Pack"</h1>` I want this because I post: "my title as a title posting" > and this is AIO meta title "my title seo pack as a title posting". I want to show: "my title seo pack as a title posting" in `single.php` rather than using the "wp title".


title: plugin backend help

text:
this code is working perfect for me, but just want to know, how can i bring this after my post, currently all my tweets are coming before the post, how can i make it before the post??                   function parse_twitter_feed($feed, $prefix, $tweetprefix, $tweetsuffix, $suffix) {       $feed = str_replace("<", "<", $feed);       $feed = str_replace(">", ">", $feed);       $clean = explode("<content type=\"html\">", $feed);            $amount = count($clean) - 1;            echo $prefix;            for ($i = 1; $i <= $amount; $i++) {         $cleaner = explode("</content>", $clean[$i]);         echo $tweetprefix;         echo $cleaner[0];         echo $tweetsuffix;       }            echo $suffix;     }          function the_twitter_feed($username) {       // $username = "Mba_"; // Your twitter username.       $limit = "5"; // Number of tweets to pull in.            /* These prefixes and suffixes will display before and after the entire block of tweets. */       $prefix = ""; // Prefix - some text you want displayed before all your tweets.       $suffix = ""; // Suffix - some text you want displayed after all your tweets.       $tweetprefix = ""; // Tweet Prefix - some text you want displayed before each tweet.       $tweetsuffix = "
"; // Tweet Suffix - some text you want displayed after each tweet.            $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $limit;            $twitterFeed = get_transient($feed);       if (!$twitterFeed) {         $twitterFeed = wp_remote_fopen($feed);         set_transient($feed, $twitterFeed, 3600); // cache for an hour       }       if ($twitterFeed)         parse_twitter_feed($twitterFeed, $prefix, $tweetprefix, $tweetsuffix, $suffix);     }     function append_the_content($content) {         $content .= the_twitter_feed(get_option('tweetID'));            return $content;     }     add_filter('the_content', 'append_the_content');          add_action('admin_menu','tweet_fetch');          function tweet_fetch(){     add_options_page('Tweet','Tweet', 8, 'tweet', 'tweet_fetcher');     }     function tweet_fetcher(){     ?>
Tweet Fetcher options
     <form method='post' action='options.php' style='margin:0 20px;'>     <?php wp_nonce_field('update-options'); ?>
Twitter UserID:<input type="text" name="tweetID"  value="<?php echo get_option('tweetID'); ?>" <?php echo get_option('tweetID'); ?> />
     <input type='hidden' name='action' value='update'/>     <input type='hidden' name='page_options' value='tweetID'/>
     <input type='submit' name='Submit' value='Update Options »'/>
     </form>     <?php     }


title: How do you remove Link backs on Theme settings page?

text: How do we edit and remove link backs to theme Developers from theme settings page ? Some themes which we install on site has link backs .How do you edit them from multisites? Does any body have Idea on removing these links? I want to edit the Links Like "Mystique 2.4.2 by digitalnature" .


title: Form that creates posts

text: How can I create a form that allows people to submit questions / ideas that once submitted creates a post in wordpress?


title: How to limit image size for the entire website ? But without editing the post (css/plugin?!)

text: I have a post here: http://www.food101.co.il/?p=5993 Where the image is overlapping the sidebar. I wish to shrink the image, but I want something that will do this without me editing the post (why? because the author is not me - and I want an automated system) Is there a plugin or a CSS solution that can do this? (as cross browser as possible?)


title: Add content in between of foreach

text: I have the following foreach witch gets all the content in several groups. I am using Magic Fields.                <?php $omtaleseksjoner = get_group('Seksjoner');     foreach($omtaleseksjoner as $seksjoner){          echo "<h3>" . $seksjoner['sectiontitle'][1] . "</h3>";         echo $seksjoner['sectioncontent'][1];     }      ?>      I have usually 5 groups in this foreach, and I want to break it off in two places. Is it possible to insert other content e.g. after group 2 and 4 ? Thanks


title: What Plugin Do You Use to Turn WordPress based site to A Blog Aggregator

text: I mean that if I want to publish news feeds ,blog updates like bloglines and techmeme . I and my users should have possibility to add RSS entries and the feeds should be published . For now I am using feedwordpress .But here it is grabbing the blog authors emails and creating the accounts on my site for them .For example If I add readandwriteweb's feed .Every time when the authors puclish a post on that site . That plugin is creating accounts for them.And this plugin allows only blog admin to add RSS entries .I wanted to allow the registered users to add RSS entries . Does anybody implemented such aggregation functionality or created such aggregator using wordpress ? Could any one help me Thanks !


title: Receiving error with Custom Tables plugin

text: How to resolve this warning which is shown when I use the Custom Tables plugin? Can anybody help me please > Warning: Invalid argument supplied for foreach() in ..\wp- > content\plugins\custom-tables\pages\show_table.php on line 378


title: tag search using WP_Query

text: I need to find only posts with a tag `forest gump`. I've tried: `new WP_Query('tag=forest+gump');`, `new WP_Query('tag=forest gump');`. However they both return ALL the posts and not only the posts with `forest gump` tag. Single tags (without spaces) work fine, though. Alternatives (like plain SQL) will work as well. The entry tag line is `forest gump, forrest gump, questend`.


title: Cant create table if including the file in main script

text: I want to create a table by including the script that creates it in the main plugin file. I have this:               register_activation_hook( __FILE__, 'vkrwps_agt' );     function vkrwps_agt() {        global $wpdb;        global $jal_db_version;             $table_name = $wpdb->prefix . "attribute_groups";             $sql = "CREATE TABLE $table_name (       id int(11) NOT NULL AUTO_INCREMENT,       attribute_name VARCHAR NOT NULL,       attribute_group VARCHAR NOT NULL,       PRIMARY KEY id (id)         );";             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );        dbDelta( $sql );          } // end vkrwps_agt()      If I have that in my main plugin file, it works (it creates the table), but I put that code in another script called `tables.php` inside `inc` folder in my plugin root directory, because I want to include it within the main plugin file. I tried the following but it does not work:               require 'inc/tables.php';      I get no error (e.g. file not found) but the table does not get created.


title: Getting custom size image URL

text: I added custom image size like below.               add_image_size( 'team-member', 220, 220, true );      I can get this image like below in the post.               the_post_thumbnail( 'team-member' );      But how can I get image URL if it's outside of loop. For example, is there any way to get image URL like this and use it inside shortcode?               <img src="http://URL.../member1-220x220.jpg">      UPDATE: For now, I'm getting it like below. Is there any better solution?               $image_extension = substr( $image, -4 );     $image = str_replace( $image_extension, '-220x220' . $image_extension, $image);


title: Custom walker pulldown display current page

text: I have this pulldown menu and when I go to a page with this pulldown menu, I want that the current page is showed in the pulldown menu. I've searched in the documentation but can't find any.               class Walker_Nav_Menu_Dropdown extends Walker_Nav_Menu {              function start_lvl($output, $depth) {    }              function end_lvl($output, $depth) {    }              function start_el($output, $item, $depth, $args) {             // Here is where we create each option.             $item_output = '';                  // add spacing to the title based on the depth             $item->title = str_repeat("&nbsp;", $depth * 4) . $item->title;                  // Get the attributes.. Though we likely don't need them for this...             $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';             $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';             $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';             $attributes .= ! empty( $item->url )        ? ' value="'   . esc_attr( $item->url        ) .'"' : '';                  // Add the html             $item_output .= '<option'. $attributes .'>';             $item_output .= apply_filters( 'the_title_attribute', $item->title );                  // Add this new item to the output string.             $output .= $item_output;              }              function end_el($output, $item, $depth) {             // Close the item.             $output .= "</option>\n";         }


title: How to override the Jigoshop plugin Shipping Class method in Theme directory

text: I need to Modify the **jigoshop_shipping Class method calculate_shipping** I have Copied the Class in my Theme Folder and want to use this Class rather than the one in the Plugin. Please Guide me how can i do this without editing the Plugin Code So that when ever any updates are made for plugin there is no issue. Thanks in advance Nikhil Joshi


title: A blank page is shown after I add a Function

text: I am redesigning a template. So I am trying to show a holding page till the redesign process is done. I ever used following function for the purpose on many other projects and it's redirected to the `holding.php` if the user is not an **Admin** `add_action( 'template_redirect', function() { if( !current_user_can( 'manage_options' ) ) { include( get_template_directory() . '/holding.php' ); exit; } });` But when I try to put this code on my current redesigning project it's shows a blank page if I go to the home page or any other page. if I remove the above code from `function.php` the site works fine. And I've noted that this current projects' all php file has `/** * @package WordPress * @subpackage Starkers */` my **theme** folder contains `WordPress, Starkers` too I thought it's commented out. so it does nothing. Those lines are included every files such as `index.php, function.php, etc` Why it's showing a blank page if I add the redirection function as I mentioned below.?? Any help will be appreciated. **[UPDATE]** when I enable the debug i got the following lines. Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in /home/supgower/public_html/wp-includes/functions.php on line 3008 Notice: date_default_timezone_set() [function.date-default-timezone-set]: Timezone ID 'UTC-1' is invalid in /home/supgower/public_html/wp- content/plugins/event-calendar/tz.php on line 27 Notice: date_default_timezone_set() [function.date-default-timezone-set]: Timezone ID 'UTC-1' is invalid in /home/supgower/public_html/wp- content/plugins/event-calendar/tz.php on line 27 Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /home/supgower/public_html/wp-includes/functions.php on line 3049 Notice: wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /home/supgower/public_html/wp-includes/functions.php on line 3049


title: Facebook like button not showing up in iframe

text: I have tried what seems like every plugin to add the facebook like button to my site, but none of them are displaying on the page. I am trying to use the iframe method to avoid having to create an app id to use the XFBML method. The iframe gets created in the right spot, but nothing is showing on the page. Can anyone recommend a plugin that is currently working? I'm only interested in adding a Like button, I don't need other social sharing, but at this point, I'm willing to use whatever works!


title: wp_list_categories() Exclude All Categories Except One

text: Is there a way to exclude all categories except one? I want to show a category and it's sub-categories as a dropdown menu, but the admin might add more subcategories to it so I don't want to limit what they can put in there by just including unique ID's. So I want to exclude all categories except 1 and it's subcategories. Is this possible with wp_list_categories()?


title: Leverage WP_Rewrite to pre-validate links / detect invalid links

text: I'm automatically generating links to (supposed) pages/posts. These links are generated by get_permalink( $post->ID ), so in_theory, should be valid links. Unfortunately, in some situations, where the $post is actually a nav menu item, there is a "theoretical" permalink that actually doesn't correspond to an actual page. So, sometimes, the page the link points to doesn't actually exist. I would like to be able to detect this condition (ie: broken link) prior to outputting the HTML for that link, perhaps substituting it for something else. I don't want to open a separate HTTP request or socket to do this because that would slow down page load times while waiting for the response. I'd like to leverage WordPress' built-in rewrite logic to determine what the link would be and whether that corresponds to any page/post record in the DB. WordPress does this automatically already when it pulls up the correct page, so in theory this should be possible. My question really is: are there any functions or methods of WP_Rewrite that already facilitate this, or do I need to roll my own code?


title: Redirecting simple big problem

text: i'm a little worried here. I'm trying to redirect EVERYONE that access my site to a specific webpage, and nothing is working! Currently i'm trying this code:               function redirect_this() {         wp_redirect( 'http://www.myawesomesite.com/here.html', 301 );         exit;     }     add_action('template_redirect', 'redirect_this');      And the page always show               Warning: Cannot modify header information - headers already sent by ...      This is driving me crazy. By the way, i've created a plugin to hold this code. So this code is in a single plugin file.


title: Importing Direct to DB - GUID Question

text: I've got a CSV file of new posts which I'll be importing straight into the database. Is it safe to give a GUID of `http://domain/?p=[n]` where `[n]` is any number, as long as it's not a duplicate of an existing post?


title: Sort Posts Alphabetically by Multiple Categories

text: Basically I have an array of posts which I want to sort by title.               $categories = get_categories('child_of=4');      $arr_records = array();     $post_data = array();          foreach($categories as $category)      {         $sub_catname = $category->cat_name;         foreach(get_posts('cat='.$category->term_id) as $post)          {             $arr_records[] = $post_id;             $post_data[] = $post;         }     }          foreach($post_data as $show_post)     {          echo $show_post;     }      How do I sort the `$post_data` array?


title: How to order posts by taxonomy in WP_Query

text: > **Possible Duplicate:**   >  Using wp_query is it possible to orderby taxonomy? I have a page template that should show CPTs grouped by taxonomy. I'd like to get all the CPTs in a single query and not query by taxonomy (i.e. create a different query for each term) Is there a proper way to do that ?


title: How to rename index.php to home.php

text: I rename `index.php` to `home.php` and put a flash in `index.php`. In the flash I make an effect and after it played 5 minutes it redirects to `home.php`. I put this code:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /home.php [L]     </IfModule>      in my `.htaccess` file. I turned on the permalinks to `example.com/sample-post` and all the posts links are ok. But `example.com/home.php` is not ok. If I set permalinks to `example.com/?p=123` all the links are not ok. The `example.com/home.php` is ok. The home page content is from `themes/mytheme/index.php`. How to correct `example.com/home.php`? what i want: i want to add a flash to my site,namely,when access my site, first shows the flash, after some minutes,then redirect to the home page. on the flash, there is a link "enter to the website". the way i am able to think is the following, in the flash i add code stop();getURL('example.com/index.php','_self'). then create a file named index.php. put the invoke flash code in it. then rename the default index.php name to "fhp.php". but it's not work. how to correct it?


title: How to remove the statusbar from the default wordpress editor?

text: How to remove the letter P from the default wordpress editor? Previously i have removed that P but now the entire code changed from the `class-wp- editor.php` file. > ![WordPress 3.9.1 WP_Editor](http://i.stack.imgur.com/HXh4s.png)


title: Update a users role based on number of posts published

text: I am trying to update a users role based on number of posts published when the user publishes a new post. I have tried this code but it does not work.                   add_action('publish_post', 'update_roles');              function update_roles()         {                 global $wpdb;                 // Get the author            $author = wp_get_current_user();                  $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_author = " . $author->ID );                  $numPost = count($posts);                  // Do the checks to see if they have the roles and if not update them.             if($numPost > 0 && $numPosts <= 2 && current_user_can('subscriber'))             {                      $user_id_role = new WP_User($user_id);                 $user_id_role->set_role('contributor');                   } elseif ($numPost > 3 && $numPosts <= 5 && current_user_can('contributor'))             {                 $user_id_role = new WP_User($user_id);                 $user_id_role->set_role('author');                   } elseif ($numPost > 6 && $numPosts <= 9 && current_user_can('author'))             {                      $user_id_role = new WP_User($user_id);                 $user_id_role->set_role('author');                   }                   }          ?>      I have also tried this and it is not working either.               <?php              add_action('publish_post', 'update_roles');              function update_roles()         {                 global $wpdb;                 // Get the author            $author = wp_get_current_user();                      // Get post by author            $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_author = " . $author->ID );                 $numPost = count($posts);                 // Do the checks to see if they have the roles and if not update them.            if($numPost > 0 && $numPosts <= 2 && current_user_can('subscriber'))            {                // Remove role                $author->remove_role( 'subscriber' );                     // Add role                $author->add_role( 'contributor' );                 } elseif ($numPost > 3 && $numPosts <= 5 && current_user_can('contributor'))            {                // Remove role                $author->remove_role( 'contributor' );                     // Add role                $author->add_role( 'author' );                 } elseif ($numPost > 6 && $numPosts <= 9 && current_user_can('author'))            {                // Remove role                $author->remove_role( 'author' );                     // Add role                $author->add_role( 'editor' );                 }                   }          ?>      **EDIT NEW:** Can you please tell me either I have done correctly or not?               <?php              add_action('publish_post', 'update_roles');              function update_roles()         {                 global $wpdb;                 // Get the author            $author = wp_get_current_user();                 // Get post by author            $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_author = " . $author->ID );                 $numPost = count($posts);                 // Do the checks to see if they have the roles and if not update them.            if ($numPost > 3 && $numPosts <= 5 && array_key_exists( 'contributor', $old_role ) )             {                 $user_id_role = new WP_User($user_id);                 $user_id_role->set_role('author');                   } elseif ($numPost > 6 && $numPosts <= 9 && array_key_exists( 'author', $old_role ) )             {                      $user_id_role = new WP_User($user_id);                 $user_id_role->set_role('editor');                   }                   }          ?>


title: Multiple Custom Field Query

text: I have a unique situation where I need to filter on 2 custom fields where 1st field is expiry and values of "" and greater than todays date are valid and 2 field is a number which should be greater than some value. So Ideally I need to put a OR relation for 2 possibilities of 1st field with and between 1st field and second field. Any help in this regard will be highly appreciated.


title: Setting image upload absolute path?

text: In anticipation of a major upgrade, I moved the webroot from `site_v1` to `site_v2`. The public url for the WP 3.3.1 install is still example.com/ (no change). I did a tar copy from the /site_v1 dir to the new /site_v2 dir. The WP installation is working well from its new Linux path of /site_v2 instead of site_v1. All pre-existing images continue to work fine etc. **The Problem** is that when new image files are uploaded using either the flash or classic uploader, the files themselves are put into /site_v1/wp- content/uploads/2012/03 instead of the correct /site_v2/wp- content/uploads/2012/03 location. How do I change the upload file location?


title: Should I use set_transient or update_option?

text: I want to store some Twitter API data in WordPress. After every hour, I want to fetch new data from Twitter, and update only if the data is successfully retrieved from API (sometimes the API gives error, so in that case I want to keep using the old data). So in that case should I use `set_transient` or `update_option`? If I used `update_option` then at least I can check if new data is available before updating the option. What happens if I `set_transient` for an hour and after one hour the new data is not available, will I lose the stored data?


title: New posts label category with "new"

text: I have 3 different custom post types, with each type forming my main navigation. When I post something new under one of them, I want that category in the nav to be marked with a "new" label for a limited time (7 days for example). I've found a few decent posts on how to apply it to single posts, but I can't figure out how to apply it to multiple categories in the top navigation. The code for single posts is below should that be of any use:               function newly_posted() {     global $post;     $now = date('U'); $published = get_the_time('U');     $new = false;     if( $now-$published  <= 3*24*60*60 ) $new = true;     return $new;     }      Any help would be appreciated! **EDIT:** As mentioned in the comments, I'm I'm basically looking for something that will do: `If post type X has new post within 7 days, add class "new"`


title: Page 2 of Search Results shows homepage

text: Search bar is just under the header and menu at the top of the page. Example search: http://www.animefushigi.com/?s=bleach Scroll down and try going to page 2, see it shows homepage instead. Similar problem here, but the answer in that question did not work for me I believe the issue is with my searchform.php. I have pasted my searchform and search.php here: http://pastebin.com/raw.php?i=rSedK6AC Any ideas on how to fix this ?


title: Disable front end to use as CMS only?

text: I'm using the WordPress database and back end to administer the news for my band's website and everything is working great however I'd like to disable the front end of WordPress itself. I have the WordPress installation installed in `/wordpress/` and obviously the admin section is under `/wordpress/wp-admin/`. What would be the best way to restrict someone from accessing the rather *un*setup WordPress site itself without affecting the admin section? If anything, I could simply redirect to the website's proper home page (`domain.com/`).


title: Header links also appearing in the footer

text: In my menu area of the word press admin I have access to place links in both the h "main menu" and the "footer links"               register_nav_menus(array(         'main_nav' => 'The Main Nav',         'footer_links' => 'The Footer Links'     ));      In the Header:               wp_nav_menu(array('menu' => 'The Main Nav'));      In the Footer:               wp_nav_menu(array('menu' => 'The Footer Links'));      In the header Nav, I have a link to the default sample page, in the footer I have a link to google. I save the menus and look at the front end, I get the sample page link in both the header and the footer. for further proof that I have two menus: ![enter image description here](http://i.stack.imgur.com/h17Za.png) What's going on?


title: How to get only text from wordpress post content?

text: I have been using wordpress for my projects. For my homepage of the site I need to display limited text from the post content and the content contains images as well. To display the 100 text i have used substr function of php. What happens here is that the text as well as image is dispalayed. I want to display only the text. Is there any way or plugin to do so? Any help is appreciated. Thanks in advance


title: Image gallery plugin

text: Can you recommend a tutorial or a plugin in wordpress that lets you achieve a similar gallery, like this http://www.whitehouse.gov/photos-and- video/photogallery/may-2011-photo-day Large Preview then at the bottom a thumbnails then an album. I also like cooliris because it supports fetching images from facebook and flikr. Another feature I like about it is its sharing options, you can easily share those images in facebook. The only thing I don't like is its interface, its not fully customizable, the arrows left and right are hardly to be seen, the animation is too techno for my project. I need a gallery where thumbnails where thumbnails can easily be browse, and it also has an album so its organize. It would be a plus if you have an option to pull images from flikr or facebook and you can share them via facebook or twitter. Let me know if you know a software that is close to my description. Thanks so much!


title: How to sync tags between posts that are linked through Posts 2 Posts?

text: I am faced with a thorny problem and can't seem to find the solution in the wealth of community knowledge on the web. I have two custom posts types "Person" and "Activities". I use posts 2 posts (plugin) to link Persons with their various Activities and vice-versa. I have Taxonomies which apply to Activities. They describe areas of practice and interest. Using them, I'd like to be able to get a list of Persons who partake in Activities tagged with "Cranes", for example. Where "Cranes" is part of an Area of interest in my tag-like custom taxonomy. I suspect the most practical way to go about it would be to apply the taxonomy to both post-types and keep them in sync from the linked Activities to the Persons automatically. Is there a way to do that? Kind regards,   Evren EDIT: My p2p_register_connection_type is as follows               function ghunige_connection_types() {         p2p_register_connection_type( array(             'name' => 'profile_to_activity',             'from' => 'ghunige_profile',             'to' => 'ghunige_activity',             'reciprocal' => true,             'title' => array( 'from' => __('Participates in', 'ghunige_dir_domain'), 'to' => __('Participants', 'ghunige_dir_domain') )              ) );     }


title: Customizing the gallery of the post correctly

text:
I've found a way to insert a customized gallery inside my wordpress template but I'm not sure this is the better way. I've uploaded my images with the default image uploader of wordpress to manage the photos, than I've removed it from the post article and managed the media from the `loop-single.php` page template I've created like this:               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>                              <?php      $args = array(         'order'          => 'ASC',         'post_type'      => 'attachment',         'post_parent'    => $post->ID,         'post_mime_type' => 'image',         'post_status'    => null,         'numberposts'    => -1,     );     $attachments = get_posts($args);     if ($attachments) {         $html = '

';                   foreach ($attachments as $attachment) {             //echo apply_filters('the_title', $attachment->post_title);             $html .= ''. wp_get_attachment_link($attachment->ID, 'full', false, false).'	';             if (empty($list_imgs)) {                 $list_imgs = '

';             } else {                 $list_imgs .= '

';             }         }              $html .= '

'.$list_imgs.'
';              echo $html;     }     ?>
<?php the_title(); ?>

         <?php the_content(); ?>

         <?php the_tags(); ?>
          <?php endwhile; // end of the loop. ?>      I can't believe this is the best way to manage photos but I don't know wordpress and I've did the first thing I thought. Should I use a better way to custom the image gallery of a post or is this the best way? Is it possible to customize the `[gallery]` in the `loop-single.php` page without remove it and create it manually? I've read here how to customize the gallery, but if I do it I'll print the customized gallery, and than with `<?php the_content(); ?>` I'll print it again with the default wordpress style. Does exists some way to customize `[gallery]` directly?


title: How to display user role

text: How to display user role on author page. I have created my own role (group) so I want to display the user role on below the post and on author list. I have tried this code but not working as its calling current_user and its showing current user role in all authors profile               <?php          $user_roles = $current_user->roles;         $user_role = array_shift($user_roles);              if ($user_role == 'administrator') {             echo 'Administrator';         } elseif ($user_role == 'editor') {             echo 'Editor';         } elseif ($user_role == 'author') {             echo 'Author';         } elseif ($user_role == 'contributor') {             echo 'Contributor';         } elseif ($user_role == 'subscriber') {             echo 'Subscriber';         } else {             echo '<strong>' . $user_role . '</strong>';         }     ?>      How can I alter this code to display user actual role and not the current user role.


title: Broken Media Library

text: I'm trying to upload media using the media library. I uploaded a couple of images several months back, and the library worked fine, these images are still available as normal through the WP backend. However, any new documents of any kind cannot be viewed due to a "failed to load" error. They're not accessable via embedded links (http://www.leghumped.com/wp- content/uploads/2013/08/lockscreen_shortcut-150x150.png) or attachment pages but I can see them when I click 'Edit->Edit Image' for a media item (the image source is '/wp-admin/admin-ajax.php?action=imgedit- preview&_ajax_nonce=46c2917e48&postid=650&rand=98186'). The permissions on my wp-uploads directory are 777 and I'm totally at a loss as to why this isn't working.


title: Page not loading content - Body archive - page

text: I'm working on this page The problem Is that is not loading any content, altought it's english version does: link I'm not getting any console errors so can't find where the problem is. ![enter image description here](http://i.stack.imgur.com/s6KlK.png) The only difference I see is that the spanish page has :               <body class="page page-id-584 page-template page-template-tienda-page-php logged-in admin-bar woocommerce woocommerce-page customize-support">      and the english version has :               <body class="archive post-type-archive post-type-archive-product logged-in admin-bar woocommerce woocommerce-page customize-support">      It is exactly the same page, just translated to english, any ideas what could be the problem?