Verify signup via SMS?

Does anybody know of a plugin available for WordPress that would require a new user to enter their mobile phone number as part of the sign up process? The user would then be sent a verification code via SMS which they would have to enter to complete the sign up process. Any ideas? Thanks


WP-PostRatings - how to make rating show up?

I have Boldy theme on a 3.2.1 instance of Wordpress. I have installed the plugin WP-PostRatings. I want it to show up on my individual posts when posts are viewed individually on a page.   * I installed and activated the plugin.   * I added   `if(function_exists('the_ratings')) { the_ratings(); } ?>`   within my _single.php_ file, as shown in pastebin. However, nothing is happening with my blog posts when viewed as single pages. Have I put the code in the wrong place/file?


A little confused as to what add image size actually does

I have a call to add_image_size like so:               if ( function_exists( 'add_theme_support' ) ) {          add_theme_support( 'post-thumbnails' );      }          if ( function_exists( 'add_image_size' ) ) {          add_image_size( 'sidebar_thumb', 109, 60 );     }      But then when I try to use that image size in my template...               if ( has_post_thumbnail() ) {           the_post_thumbnail( 'sidebar_thumb' );     }      The first image is 80X60, the second is 45 X 60; that's obviously way off. ![images are not the size I wanted](http://i.stack.imgur.com/7BDmv.png) =The height is right on both images. So I guess my question is how do I get an image outputted with an exact size, and if that's not possible by default, then how would I get the URL of a featured image (the image than the user picked as Featured in the admin section) so I can put that URL into a script like timthumb.


How to add meta boxes to Pages

I'm almost complete whit my wp theme an I'm now translating it with the WPML plugin. This is working out great (even all my custom post types and meta boxes :) ), but of course there have to be a problem. I have added meta boxes to one specific page and have target it like this:               add_action('admin_init','my_meta_init');          function my_meta_init()     {         $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;                   // checks for post/page ID         if ($post_id == '17')         {             add_meta_box('meta_webdesign', 'Webdesign', 'my_meta_webdesign', 'page', 'normal', 'high');             add_meta_box('meta_grafisk', 'Grafisk design & Identitets design', 'my_meta_grafisk', 'page', 'normal', 'high');             add_meta_box('meta_illustrasjon', 'Illustrasjon', 'my_meta_illustrasjon', 'page', 'normal', 'high');         }      But now I need to also target the English version of the page (id 348), how do I do that? Ps. I have tried this: **if ($template_file == 'page-tjenester.php')** (the Norwegian and English version both use the same template, but then all the meta boxes disappear. I would be very grateful for help with this :)


Woocommerce - Change Variable Product Add to Cart to behave like external product using Custom Field (link)

I am importing affiliate products via XML into Woocommerce. Due to products having variations if I use the External/Affiliate product type I get repetition of product on my front end (eg. same product with different location/colour). To avoid this I am attempting to import these products as variable products, this solves the problem, except now I need to Change the add to cart to behave like an external product (i.e. a Button that links to another website). I've created a Custom Value associated with each product called "Buy_Link", now what? I have searched and searched, but unable to find a solution for something I thought would be relatively simple for someone with php knowledge. I know that I should be able to retrieve the link doing something like this:               <?php echo get_post_meta($post->ID, 'Buy_Link', true); ?>      (After some help and a bit more searching) I believe I will need to place code: ID, 'Buy_Link', true); ?> into single-product/add-to-cart/variable.php, but I am still unsure where it would go in that template. I would like the link to replace some of the functionality of the original add to cart button. Obviously, I am not too familiar with php code, so please be specific about how and where in the template I can put the code. Much appreciated.


Adding Separator to Breadcrumbs

I have pieced together a breadcrumbs code that displays child pages/posts and is markedup for schema. The only thing this code doesn't have is a separator between each link. How can I add a separator in one instance, rather than adding the separator after each individual generated link?               function crumbs() {      if ((is_page() && ! is_category()) || is_archive() || is_single() || is_single()) {      echo '
';      echo 'Home';      $post_ancestors = get_post_ancestors($post);      if ($post_ancestors) {      $post_ancestors = array_reverse($post_ancestors);      foreach ($post_ancestors as $crumb)      echo ''.get_the_title($crumb).'';      }      if (is_category() || is_single()) {      $category = get_the_category();      echo 'cat_ID).'">'.$category[0]->cat_name.'';      }      if (!is_category())      echo ''.get_the_title().'';      echo '
';      }     }


Is it possible to run plugin code when a multisite blog is deleted?

I have a plugin that creates tables when activated or when a new blog is added to a network. When a blog is deleted I would like to be able to remove those tables for that blog. Is there a hook available to do this? I imagine it would be something similar to wpmu_new_blog, but I can't find an equivalent for deleting.


_n() Single and Plural for search results?

This code produces > Search Results for "hello" - 1 articles "
Search Results for <?php echo'"'?>         <?php /* Search Count */          $allsearch = &new WP_Query("s=$s&showposts=-1");          $key = wp_specialchars($s, 1);          $count = $allsearch->post_count;          _e('');          _e('');          echo $key;          _e('');          echo '"';          _e(' - ');          echo $count . ' ';          _e('articles');          wp_reset_query(); ?>
      How can I make it `$single` and `$plural` for eg. "1 article" or "2 articles"?


Opening a link automatically on page load?

Well I am new and beginner ! I installed auto thickbox plus for wp. Now all I want to do is automatically open a link in specific page. Let's suppose I have a page "about us" on which I have a video. When I click a nice insite popup appears playing the video by thickbox. All I want to do is automatically open that video when someone click on "about us" after the page load of "about us". Kindly help me !


JS error: The "fb-root" div has not been created, auto-creating

There are two errors on my page but i dont know where they are coming from The "fb-root" div has not been created, auto-creating all.js?ver=3.6.1:56 FB.getLoginStatus() called before calling FB.init(). http://bikepologear.eu


How can I find out what an `apply_filter` call is actually doing?

As an example, I'm looking at `class-wp-xmlrpc-server.php` and there's a line (~115) that says:               $this->methods = apply_filters('xmlrpc_methods', $this->methods);      How can I actually find out what transformations are performed on the data by the filter? Obviously, I can compare `$this->methods` before and after the filter is applied to get the bottom line differences but I'd like to know what code is actually being run to make those changes. Any ideas?


What's wrong with my $wpdb query?

I'm just trying to query the first user, but it outputs this error, **WordPress database error** : [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''wp_users' WHERE ID = 1' at line 1] SELECT * FROM 'wp_users' WHERE ID = 1 And my code,               <?php        global $wpdb;          $wpdb->show_errors();          $sql = $wpdb->prepare( "SELECT * FROM %s WHERE ID = %d" , $wpdb->users, 1);     $results = $wpdb->get_results($sql);          echo '<pre>';     print_r($results);     echo '</pre>';         ?>


Add Text Domain To Post Navigation

I'm using `previous_post_link('%link','Previous Post');` and `next_post_link('%link','Next Post');` for post navigation but I want to add text domain to that similar to `_e('Next Post' , 'ft');` How can I do that?


How to combine multiple body classes

My theme already has a specific body class filter for the colorscheme it uses. How can I also add a body class filter for the page name? Basically I want to combine these statements:               <body <?php body_class(); ?>>     <body class="<?php echo get_stencil(); ?>">      I've been trying but I just keep getting error messages with variations like this:                <body class="<?php echo get_stencil(); ?> <?php body_class(); ?>">


Putting a wordpress custom post into a widget

I have just recently created a widget in my Wordpress theme that inserts a widget into the sidebar. Its based upon the text widget. However the html content is hard coded into the widget and it has its own title, that way if the user ever decided to get rid of the widget out of the sidebar, then the widget would always be available for reuse in the "available widgets" section if they ever changed their mind and wanted it reinstating on that sidebar or another one. Here is the code:               <?php     /* Plugin Name: Basic Text Widget     Plugin URI: www.lancscps.co.uk     Description: Text to put into the sidebar regarding free consultation     Version: 1.0     Author: Jonathan Beech     Author URI: www.lancscps.co.uk     */     class freeconsultation extends WP_Widget {           function freeconsultation() {                     $widget_ops = array(                     'classname' => 'freeconsultation',                     'description' => 'Text to put into the sidebar regarding free     consultation'           );           $this->WP_Widget(                     'freeconsultation',                     'Free Consultation',                     $widget_ops           );     }           function widget($args, $instance) { // widget sidebar output                     extract($args, EXTR_SKIP);                     echo $before_widget; // pre-widget code from theme     print <<<EOM

In order to establish how we can proceed together with your needs, our first meeting is free of charge.

     EOM;                     echo $after_widget; // post-widget code from theme           }     }     add_action(           'widgets_init',           create_function('','return register_widget("freeconsultation");')     );      I was hoping there would be a method of inserting a custom post into the widget replacing the HTML that is already there. Perhaps this could be done by id so that the user could adjust the content of the post and therefore the widget as they see fit. Changing the code file wouldn't be feasible for the end user.


admin.php taking 14 seconds

This is a clean install but it has a (relatively) huge database of dummy posts/comments/etc. But even on single-post loads it still takes just as much. ![scr](http://i.stack.imgur.com/qP7Kk.png) Narrowing further down `menu.php` takes 8 seconds but I'm lost at where exactly... ![scr](http://i.stack.imgur.com/GLMrX.png) All its sub values are small... * * * **Edit**   Question: Any pointers on where to look for the bottleneck? (that call stack is HUGE, and apparently child-`callable`'s `Time` doesn't add to parent - as seen in `menu.php`)


How can I change the look of a post as is displayed

When an article is posted it comes out like this:   Where the title is on top, then the picture, then the image. ![enter image description here](http://i.stack.imgur.com/Xiyf5.png) But what I would like to do is how technobuffalo.com has it: ![enter image description here](http://i.stack.imgur.com/Zx36k.png) How is this done? is a template html copied and pasted for each new article and displays in that format or does WordPress render it for each posting? Thanks


How to get the id or url of the image in an image post?

I have a bunch of image posts and I'd like to get the ID of those images I didn't set a featured image so I can use `wp_get_attachment_image_src()` to get the urls of various sizes of those images. This is what I created:               $img_posts = get_posts( array(         'tax_query' => array(             array(               'taxonomy' => 'post_format',               'field'    => 'slug',               'terms'    => 'post-format-image',               'operator' => 'IN'             )         )     ) );          foreach( (array) $img_posts as $post ) {         setup_postdata( $post );        $imgID = get_img_id();         //img sources         $thumb = wp_get_attachment_image_src($imgID, 'thumb');         $reg = wp_get_attachment_image_src($imgID, 'large');         $big = wp_get_attachment_image_src($imgID);     }      The `get_img_id` function on the 6th to lastline, which is probably the source of all of my problems, looks like this:               function get_img_id() {             global $post;             $id = intval( $post->ID );             $imgID = get_children( array(                     'post_parent' => $id,                     'post_status' => 'inherit',                     'post_type' => 'attachment',                     'post_mime_type' => 'image',                     'order' => 'ASC',                     'numberposts' => 1                 ) );              return $imgID;     }      When I do this I get no errors or output. If I add something like `the_content` to the array instead it functions properly. UPDATE: Per @TheDeadMedic's suggestion I tried this:               $img_posts = get_posts( array(         'cat' => '2',         'tax_query' => array(             array(               'taxonomy' => 'post_format',               'field'    => 'slug',               'terms'    => 'post-format-image',               'operator' => 'IN'             )         )     ) );     foreach( (array) $img_posts as $post ) {         setup_postdata( $post );         $img_id = get_img_id();         var_dump ($img_id);     }      This returned               array         empty      Once per post queried.


Enqueue a stylesheet for login page and make it appear in head element

I try to style the login page in my theme. Very simple:               add_action( 'login_enqueue_scripts', function()     {         wp_enqueue_style( 'TEST', get_template_directory_uri() . '/css/login.css' );     });      Unfortunately, it doesn’t work as expected. The `link` element appears in the `body` of the login page, very late. Rendered output:               <link rel='stylesheet' id='TEST-css'  href='http://themes.wp/t5-theme-base/css/login.css?ver=3.9-alpha' type='text/css' media='all' />

                This is wrong, how can I print the link element in the `head`?


Show author name not the author ID

I have added the code to get the author, but it displays the author's ID number. How can I get the author's name to show and their gravatar. **CODE**               <?php     $product_pages_args = array(         'meta_key' => '_wp_page_template',         'meta_value' => 'page_library_html_content.php',         'hierarchical' => '0'     );     $product_pages = get_pages( $product_pages_args );     ?>          <?php     foreach ( $product_pages as $product_page ) {         echo '
';         echo '
ID ) . '">' . $product_page->post_title  . '
';         echo '
' . get_post_field('post_content', $product_page->ID ) . '
';         echo '
' . get_post_field('post_author', $product_page->ID ) . '

';     }     ?>


How to echo Widget Title in Custom Frontend-Template Box

I've created a custom Widget with the help of following code:                   // Creating the widget      class wpb_widget extends WP_Widget {          function __construct() {         parent::__construct(         // Base ID of your widget         'wpb_widget',               // Widget name will appear in UI         __('WPBeginner Widget', 'wpb_widget_domain'),               // Widget description         array( 'description' => __( 'Sample widget based on WPBeginner Tutorial', 'wpb_widget_domain' ), )          );     }          // Creating widget front-end     // This is where the action happens     public function widget( $args, $instance ) {         $title = apply_filters( 'widget_title', $instance['title'] );         // before and after widget arguments are defined by themes         echo $args['before_widget'];         if ( ! empty( $title ) )         echo $args['before_title'] . $title . $args['after_title'];              // This is where you run the code and display the output         echo get_template_part( 'partials/widgets/test-w' );         echo $args['after_widget'];     }          // Widget Backend      public function form( $instance ) {         if ( isset( $instance[ 'title' ] ) ) {             $title = $instance[ 'title' ];         }         else {             $title = __( 'New title', 'wpb_widget_domain' );         }         // Widget admin form         ?>
         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?>          <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
         <?php      }          // Updating widget replacing old instances with new     public function update( $new_instance, $old_instance ) {         $instance = array();         $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';         return $instance;     }     } // Class wpb_widget ends here          // Register and load the widget     function wpb_load_widget() {         register_widget( 'wpb_widget' );     }     add_action( 'widgets_init', 'wpb_load_widget' );      **As you can see, i echo a html template with**               echo get_template_part( 'partials/widgets/test-w' );      in the main code. I've register the sidebar in my functions.php with following code                   register_sidebar(         array(             'name'              => 'Index Right',             'before_widget' => '
',             'after_widget'  => '
',             'before_title'  => '
',             'after_title'   => '
',         )     );      The widget output in my frontend looks like: ![enter image description here](http://i.stack.imgur.com/ihXw5.png) **THE PROBLEM** The title is outside the widget box. I tried a lot of things to get the title to the top of the box like following image - but no luck :( ![enter image description here](http://i.stack.imgur.com/BBGIe.png) My php/html code ( `echo get_template_part...` ) for the widget looks like                   <?php        $default_thumbnail = 'http://vvvvvvvv.com/vvvvvvvvv.png';        $the_query = new WP_Query('showposts=12&orderby=desc&category_name=featured');       while ($the_query->have_posts()) : $the_query->the_post();     ?>
                       <a target="_blank" href="<?php the_permalink()?>">

                             <?php                             if (has_post_thumbnail()):                             the_post_thumbnail('thumbnail-test');                             else:                             ?>                             <img src="<?php echo $thumbnail; ?>"/>                             <?php endif; ?>

                                <?php the_title(); ?>

           <?php endwhile; ?>     <?php wp_reset_query(); ?>      Any suggestions on how to solve my problem?


Force changing the Site Title and add link

I have the function below, but it's not actually changing the site title where it is called in my theme.               function blog_filter($string, $show) {         if ( $show == "name" ) {             $string = str_replace('Blog', 'blog.com', $string);         }     return $string;     }     add_filter('bloginfo', 'blog_filter', 10, 2 );      anyone knows why? thank you


Limit categories visible

How could you limit the categories displayed for a certain role when adding a new post? I would like to only list a few categories, but would rather not prevent them from seeing these categories elsewhere. I already have something for the conditional user role portion:               function dashboard_limited_options() {         if(current_user_can('add_users'))             {                 // donlt do anything             }             else             {             remove_menu_page('options-general.php'); // Settings             remove_menu_page('tools.php'); // Tools             remove_menu_page('upload.php'); // Media                     }         }


How to change order of custom post types. I want Featured post to come first

Used this but not working:               $my_query = new WP_Query( array(              'post_type' => 'businesslistings',             'post_status' => 'publish',             'orderby' => get_query_var('orderby'), // will return orderby query string variable             'order' => '$var',              'paged' => get_query_var('paged'),         ));


WordPress admin webfonts (dashicons) go to blank squares after inactivity (random)

I'm using the new WordPress 3.8 and I've noticed that when I leave the admin page open in a tab, and return later, I'm getting a random thing happening with the dashicon fonts used for the menu icons. They all turn to squares, rather than the appropriate dashicon. Its as if the connection to the server that hosts the webfonts has been temporarily lost. Interestingly, just moving my mouse over the sidebar area makes the squares transform into their appropriate dashicon font symbol. Has anyone else experienced this?


next_posts_link does not work when querying a specific category

What I am trying to do is display every post from the "News" category (in my case the "news" category's ID is 13), with 5 posts per page. The pagination links display on the page, but when I click on the 'previous' link, it will only show me the first 5 posts in the category. The contents of page-news.php:               <?php get_header(); ?>
Latest News
     <?php         /*$args = array('cat' => 13);         $posts = new WP_Query($args);*/         global $paged;         global $wp_query;              $temp = $wp_query;         $wp_query = null;         $wp_query = new WP_Query();         $wp_query->query(array('cat=13', 'paged='.$paged));              if ($wp_query->have_posts()) :     ?>
     <?php             while ($wp_query->have_posts()) : $wp_query->the_post();     ?>

<a href="<?php esc_url( the_permalink() ); ?>" title="Permalink to <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?>
                     <time datetime="<?php the_time( 'Y-m-d' ); ?>" pubdate><?php the_date(); ?> <?php the_time(); ?></time>                     <?php the_content(); ?>

     <?php         endwhile;     ?>

             <?php next_posts_link( __( '← Older posts')); ?>             <?php previous_posts_link( __( 'Newer posts →')); ?>
     <?php         $wp_query = null;         $wp_query = $temp;         else :     ?>
It looks like there's nothing happening at the moment.
     <?php endif; ?>          <?php get_footer(); ?>


Woocommerce override mini-cart.php not working

I am trying to override `mini-cart.php` which is template file located at `woocommerce/cart/mini-cart.php`. It should override behaviour of woocommerce widget cart but it isnt working. I can make any changes to the file but it looks like it is still loading from some other place and it is not overriden. I have also tried modifying core template files of woocommerce and deleting mini-cart.php from it but widget is still working. However `mini-cart.php` structure looks exactly the same as html structure generated in final. But it looks like woocommerce isnt using this file so it has probably changed by some update and mini-cart.php is just remain from later versions. Any ideas what file should I override to change look of widget cart? I dont want to completely override whole core widget cart class because I just want to change one `<span>` to `<p>`. Thanks in forward


Shortcode or placeholder for theme options page?

I'm writing a theme options page that provides a space for the user to enter code for social buttons e.g.               <a href="https://twitter.com/share" class="twitter-share-button"          data-url="<?php echo get_permalink(); ?>">Tweet      Obviously, having `<?php echo get_permalink(); ?>` for the data-url attribute is not going to work in a theme options textarea. What are my options here? I've seen others user   1. shortcodes e.g. [permalink] - but how can I process the shortcode?   2. placeholders e.g. {{url}} - again, how do I replace these placeholders? Appreciate any pointers in the right direction. Thanks!


wp_nav_menu with WP as pure CMS

I'm trying to use WP as a pure backend CMS for my site. I've got a few pages setup in WP e.g. About, Main Page, Sample Page and I can display the content on my own php pages by using `get_page_by_title`. However when I try to use `wp_nav_menu` to generate the navigation elements, the links generated are in the form of `www.example.com/wordpress/?page=2`. I know I can change WP to use nice permalinks to get `www.example.com/wordpress/about` but I'd like to customise it further so that the link would read `www.example.com/about` e.g. skip the wordpress install location. Is this possible and how can I do it?


When I change slug, will WordPress create redirect from the old URL?

When I change a slug from `post-a` to `post-b`, will WordPress create a redirect from `/post-a` to `/post-b`, like HTTP 301 or something similar? If not, is there a plugin for that?


Use WordPress file upload in my plugin - on frontend and on backend?

Is there a way to use wp multifile upload system in my plugin?


Related Tags not in category

I'm using this piece of code to show related posts based on the tag of the post you are viewing. I'd like to modify is a little to exclude the related posts from the loop if they are in the same category of the post you are viewing Reason for this is i already have a loop to show related posts in the same category, so trying to cut out the duplicates.               <?php     $tags = wp_get_post_tags($post->ID);     if ($tags) {       $first_tag = $tags[0]->term_id;       $args=array(         'tag__in' => array($first_tag),         'post__not_in' => array($post->ID),         'showposts'=>5,         'caller_get_posts'=>1        );       $my_query = new WP_Query($args);       if( $my_query->have_posts() ) {         while ($my_query->have_posts()) : $my_query->the_post(); ?>                  <!-- loop here -->                <?php         endwhile;       }wp_reset_query();     }     ?>      Thanks


Display ONLY Latest Post From Several Categories

I have searched for this solution on here and was not able to find one that worked for me so I apologize if this seems like a redundant question. I have several categories that I want to display ONLY the latest post from in order of date/time (regardless of category) on my index.php page. Please let me know if I can be more specific to help with this answer!


Set default featured image for terms of a custom taxonomy

I want to set a default featured image for terms of a custom taxonomy. I found this code but it is only good for categories and not for other terms:               <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())) : ?>          <?php the_post_thumbnail('thumbnail'); ?>          <?php else :?>          <img src="whatever/directory/<?php $category = get_the_category(); echo $category[0]->cat_name; ?>.jpg" />           <?php endif;?>      How can I make this code also work for a custom taxonomy?


Post array not printing after post is published?

I'm using this function which displays the post array when I click Add new post. After the post has been published I do not see the array of the published post. What's wrong with the code? I've also tried using `save_post` in place of `wp_insert_post`               function print_test( $post_id ) {     $post = get_post($post_id, ARRAY_A);              echo 'this is from the print_test function';         print_r($post);          }     add_action( 'wp_insert_post', 'print_test',99999,1 );


Check if variable is set in filter

Thanks to your suggestions, I enabled wp_debug and discovered flaws with my plugin. I have a filter for sorting posts by votes. I use it when the `sort` URL parameter is on. `add_filter( 'posts_where', 'votes', 10, 2 );` I used to get `Undefined index: sort` so I modified my function to first check if the variable is set.               function votes( $where, $query )     {       $sort = array_key_exists('sort', $query->query_vars) ? $_GET['sort'] : null;       if ( isset($sort) ) {                     $where .= " AND $sort >= votes";                      }       return $where;     }      This works fine but I'm not confident if it's correct. I'm wondering if there's a better method to do this.


Almost Done... Post Format Code

I would REALLY appreciate some help with this, I have been working on it for a while and am so close to done I can taste it. I need each post format excerpt to have the same excerpt code as the default excerpt (used without post formats) which is provided as "Code 1". This MUST contain the excerpt_wrap and exerpt_inside along with the conditional div class. Basically, everything in this code... simply figure out how to integrate it into the second code everywhere it says "CODE GOES HERE"... Code 1:

                                <?php if ( has_post_thumbnail() ) { ?>                      <a href="<?php the_permalink() ?>">                 <?php the_post_thumbnail( 'thmb-index' ); ?>                                       <?php } ?>                      <div class="excerpt_content<?php if ( has_post_thumbnail() ) echo ' with-thumbnail'; ?>">               <a href="<?php the_permalink(); ?>">                        <?php the_title(); ?>                                   By                        <?php the_author_posts_link( ); ?>                        |                        <?php the_time('F j, Y'); ?>                        | <a href="<?php the_permalink(); ?>/#commentlist">                        <?php comments_number( 'No comments', 'One comment', '% comments' ); ?>                                                <?php the_excerpt(); ?>

      Code 2:               <?php get_header(); ?>

                               <?php while (have_posts()) : the_post(); ?>                                                              <?php          if ( has_post_format( 'aside' )) {          CODE GOES HERE          }          elseif ( has_post_format( 'chat' )) {          CODE GOES HERE          }          elseif ( has_post_format( 'gallery' )) {          CODE GOES HERE          }          elseif ( has_post_format( 'image' )) {          CODE GOES HERE          }          elseif ( has_post_format( 'link' )) {          CODE GOES HERE          }          elseif ( has_post_format( 'quote' )) {          CODE GOES HERE          }          elseif ( has_post_format( 'status' )) {          CODE GOES HERE          }          elseif ( has_post_format( 'video' )) {          CODE GOES HERE          }          elseif ( has_post_format( 'audio' )) {          CODE GOES HERE          }          else {          $format = get_post_format();          if ( false === $format ) {           ?>

                                                    <?php if ( has_post_thumbnail() ) { ?>                      <a href="<?php the_permalink() ?>">                      <?php the_post_thumbnail( 'thmb-index' ); ?>                                            <?php } ?>                      <div class="excerpt_content<?php if ( has_post_thumbnail() ) echo ' with-thumbnail'; ?>">               <a href="<?php the_permalink(); ?>">                        <?php the_title(); ?>                                   By                        <?php the_author_posts_link( ); ?>                        |                        <?php the_time('F j, Y'); ?>                        | <a href="<?php the_permalink(); ?>/#commentlist">                        <?php comments_number( 'No comments', 'One comment', '% comments' ); ?>                                                <?php the_excerpt(); ?>

                    <?php } // ending the if ( false === $format ) ...                         } // end else                            ?>          <?php endwhile; ?>

                        <?php next_posts_link('« Older') ?>

                        <?php previous_posts_link ('Newer »') ?>

                      <?php get_sidebar(); ?>

                    <?php get_footer(); ?>


Tagit with json and autocomplete

I am using tagit Tagit for my wordpress site for adding tags through front- end. So far the taglist is displaying fine through json (for json I use the json api However, I can not get the autocomplete to work. If a user starts typing on the input field it displays all the tags. But I want to filter the taglist as soon as the user starts typing (if a user types 'mijn' the results should be 'termijn' but also 'mijnserver'.) This far I have to following in my function:                   $value = '';          if ( $post_id ) {         $post_tags = wp_get_post_terms( $post_id, 'post_tag' );         $tagsarray = array();         foreach ($post_tags as $tag) {             $tagsarray[] = $tag->name;         }              $value = implode( ', ', $tagsarray );     }          ?>
Business Tags

         <input type="text" id="test" name="tags" value="<?php echo esc_attr( $value ); ?>" size="40">      The javascript:               jQuery(function($)     {         $("#test").tagit({         fieldName: "tags[]",        singleField: true,         allowSpaces: true,         minLength: 2,         matchContains:true,         removeConfirmation: true,         placeholderText: 'Kernwoord',              tagSource: function( request, response ) {             console.log("1");             $.ajax({                 url: "http://localhost/sbnl/api/get_tag_index/?dev=1",                 data: {term:request.term},                 dataType: "json",                 success: function(data) {                          response($.map(data.tags, function(item) {                         return {                             label: item.title,                             id: item.id                         }                     }));                 }                  });         },              });     });      last bit of the code:
     <?php      If someone could please help me out


Unable to sort wp_query by date/time with multiple meta_key s

**4th EDIT 11/17/2011** I spoke too soon. Now I have all the posts showing up but the total events does not seperate the events by day after I moved the endif; and endwhile; I posted the modified code below and below this is the previously modified code. Before the count was correct for each day. If I had two events from different posts on Friday then it would say "2 Events on Friday" but it would only display the content of the most recent post. Now it displays the content of all the posts but if I have two events from different posts on Friday then it say "1 Event Friday" before each post. Here is the code and Thank you.               <?php           $today = date("Y-m-d 00:00");  //set today's date            $todaytext = date("l"); // define $todaytext with written out days            for ($i=0; $i<7; $i++){           $thedate = strtotime ( '+'.$i.' day' , strtotime ( $today ) ) ;           $thedate = date ( 'Y-m-d H:i' , $thedate );           $thedatetext = strtotime ( '+'.$i.' day' , strtotime ( $todaytext ) ) ;           $thedatetext = date ( 'l' , $thedatetext );           $future = strtotime ( '+24 hours' , strtotime ( $thedate ) ) ;           $future = date ( 'Y-m-d H:i' , $future );            $args = array(      'post_type' => 'event',      'orderby'     => 'meta_value',      'order'       => 'asc',      'meta_query' => array(      'relation' => 'OR',         array(             'key' => 'opening_time',             'value' => array($today,$future),             'compare' => 'BETWEEN',             'type' => 'DATE'         ),         array(             'key' => 'artist_talk_time',             'value' => array($today,$future),             'compare' => 'BETWEEN',             'type' => 'DATE'             )     )     );          $event_query = new WP_Query( $args );           if ($event_query->have_posts()) : while ($event_query->have_posts()) :  $event_query->the_post();              $keys = array('opening_time', 'film_time', 'artist_talk_time');     $times = array();  // I tried putting the new array line here but then I got a repeat of the post for everyday     $custom_field_keys = get_post_custom_keys();     foreach ($custom_field_keys as $custom_field_key) {          if (in_array($custom_field_key, $keys))      {         $custom_field_value = get_post_meta($post->ID, $custom_field_key, true);              if ($custom_field_value >= $thedate && $custom_field_value <= $future) {                  $counttest++;             $times[] = array($custom_field_value, $post->ID, $custom_field_key); // I changed the array here              }         }         }                     if ($counttest >0) {       echo $counttest;            if ($counttest>=2){       echo ' Events ';       } // end if ($totalevents>=2) function            if ($counttest<2){        echo ' Event ';       }       echo $count;       if ($thedate==$today){echo 'Today';}       if ($thedate>$today){       echo $thedatetext;}       echo  '
';            }            $counttest=0;                 asort($times); // I changed the asort to sort here       foreach ($times as $event) { $time_value = $event[0]; $post_id = $event[1]; $time_key = $event[2];  // changed the foreach here          if ($time_key == 'opening_time') { ?>
     <a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_post_thumbnail($post_id, 'upcoming_event_sidebar'); ?>
<a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_title($post_id); ?>

Opening

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

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

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

Artist Talk

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

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

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

Film
       <?php       echo get_post_meta($post_id,'film_time', true); echo get_the_content($post_id);       }           }          endwhile;       endif;            rewind_posts();            }       ?>      **End 4th EDIT** **3rd EDIT 11/17/2011** I made the changes that you suggested Marcochiesi but the behavior stays the same. I tried making any other changes that I could wrap my heard around but know luck. What would you try next? Thank you so much for your help. **revised code**                 <?php           $today = date("Y-m-d 00:00");  //set today's date            $todaytext = date("l"); // define $todaytext with written out days            for ($i=0; $i<7; $i++){           $thedate = strtotime ( '+'.$i.' day' , strtotime ( $today ) ) ;           $thedate = date ( 'Y-m-d H:i' , $thedate );           $thedatetext = strtotime ( '+'.$i.' day' , strtotime ( $todaytext ) ) ;           $thedatetext = date ( 'l' , $thedatetext );           $future = strtotime ( '+24 hours' , strtotime ( $thedate ) ) ;           $future = date ( 'Y-m-d H:i' , $future );            $args = array(      'post_type' => 'event',      'orderby'     => 'meta_value',      'order'       => 'asc',      'meta_query' => array(      'relation' => 'OR',         array(             'key' => 'opening_time',             'value' => array($today,$future),             'compare' => 'BETWEEN',             'type' => 'DATE'         ),         array(             'key' => 'artist_talk_time',             'value' => array($today,$future),             'compare' => 'BETWEEN',             'type' => 'DATE'             )     )     );          $event_query = new WP_Query( $args );           if ($event_query->have_posts()) : while ($event_query->have_posts()) :  $event_query->the_post();              $keys = array('opening_time', 'film_time', 'artist_talk_time');     $times = array();  // I tried putting the new array line here but then I got a repeat of the post for everyday     $custom_field_keys = get_post_custom_keys();     foreach ($custom_field_keys as $custom_field_key) {          if (in_array($custom_field_key, $keys))      {         $custom_field_value = get_post_meta($post->ID, $custom_field_key, true);              if ($custom_field_value >= $thedate && $custom_field_value <= $future) {                  $counttest++;             $times[] = array($custom_field_value, $post->ID, $custom_field_key); // I changed the array here              }         }         }           endwhile;           if ($counttest >0) {       echo $counttest;            if ($counttest>=2){       echo ' Events ';       } // end if ($totalevents>=2) function            if ($counttest<2){        echo ' Event ';       }       echo $count;       if ($thedate==$today){echo 'Today';}       if ($thedate>$today){       echo $thedatetext;}       echo  '
';       }            endif;       $counttest=0;                sort($times); // I changed the asort to sort here      foreach ($times as $event) { $time_value = $event[0]; $post_id = $event[1]; $time_key = $event[2];  // changed the foreach here           if ($time_key == 'opening_time') {         ?>
<a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>">       <?php echo get_the_title($post_id); ?>

Opening
       <?php       echo get_post_meta($post_id,'opening_time', true); echo get_the_content($post_id);             }       else if ($time_key == 'artist_talk_time') {             ?>
<a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>">       <?php echo get_the_title($post_id); ?>

Artist Talk
       <?php       echo get_post_meta($post_id,'artist_talk_time', true); echo get_the_content($post_id);            }       else if ($time_key == 'film_time') {             ?>
<a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>">       <?php echo get_the_title($post_id); ?>

Film
       <?php       echo get_post_meta($post_id,'film_time', true); echo get_the_content($post_id);       }           }            rewind_posts();            }       ?>      **end 3rd EDIT** **2nd EDIT 11/16/2011** Marcochiesi, thanky for the additional help. Now I get the right count of events and they are sorted properly. The problem is that only the most recent post shows any content. If I add a new CPT event then it will show the its title and permalink but if I delete it it goes back to the next most recent post. Do you know what the problem is? Thank you again. It is impossible without your help. **2nd revised code**                 <?php           $today = date("Y-m-d 00:00");  //set today's date            $todaytext = date("l"); // define $todaytext with written out days            for ($i=0; $i<7; $i++){           $thedate = strtotime ( '+'.$i.' day' , strtotime ( $today ) ) ;           $thedate = date ( 'Y-m-d H:i' , $thedate );           $thedatetext = strtotime ( '+'.$i.' day' , strtotime ( $todaytext ) ) ;           $thedatetext = date ( 'l' , $thedatetext );           $future = strtotime ( '+24 hours' , strtotime ( $thedate ) ) ;           $future = date ( 'Y-m-d H:i' , $future );            $args = array(      'post_type' => 'event',      'orderby'     => 'meta_value',      'order'       => 'asc',      'meta_query' => array(      'relation' => 'OR',         array(             'key' => 'opening_time',             'value' => array($today,$future),             'compare' => 'BETWEEN',             'type' => 'DATE'         ),         array(             'key' => 'artist_talk_time',             'value' => array($today,$future),             'compare' => 'BETWEEN',             'type' => 'DATE'             )     )     );          $event_query = new WP_Query( $args );           if ($event_query->have_posts()) : while ($event_query->have_posts()) :  $event_query->the_post();              $keys = array('opening_time', 'film_time', 'artist_talk_time');     $times = array();     $custom_field_keys = get_post_custom_keys();     foreach ($custom_field_keys as $custom_field_key) {          if (in_array($custom_field_key, $keys))      {         $custom_field_value = get_post_meta($post->ID, $custom_field_key, true);              if ($custom_field_value >= $thedate && $custom_field_value <= $future) {                  $counttest++;                  $times[$custom_field_key] = array($custom_field_value, $post->ID);         }         }         }           endwhile;      if ($counttest >0) {       echo $counttest;            if ($counttest>=2){       echo ' Events ';       } // end if ($totalevents>=2) function            if ($counttest<2){        echo ' Event ';       }       echo $count;       if ($thedate==$today){echo 'Today';}       if ($thedate>$today){       echo $thedatetext;}       echo  '
';       }            endif;        $counttest=0;                asort($times);      foreach ($times as $time_key => $event) {      $time_value = $event[0]; $post_id = $event[1];            if ($time_key == 'opening_time') {         ?>
<a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>">       <?php echo get_the_title($post_id); ?>

Opening
       <?php       echo get_post_meta($post_id,'opening_time', true); echo get_the_content($post_id);            }      else if ($time_key == 'artist_talk_time') {             ?>
<a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>">       <?php echo get_the_title($post_id); ?>

Artist Talk
       <?php       echo get_post_meta($post_id,'artist_talk_time', true); echo get_the_content($post_id);            }       else if ($time_key == 'film_time') {             ?>
<a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>">       <?php echo get_the_title($post_id); ?>

Film
       <?php       echo get_post_meta($post_id,'film_time', true); echo get_the_content($post_id);       }           }            rewind_posts();            }       ?>      **END 2nd EDIT** **EDIT 11/15/2011** After changing the code from marcochiesi (thank you) I was able to stream line my if statements and gain the ability to sort artist_talk_time in front of opening_time if that is what the meta_key said. But now I have duplicate posts coming from multiple days in the sorting. Each CPT can have 3 meta_keys that have a date & time value. Currently I have 3 test CPTs. 1 has an opening_time at 2:00 today (it shows up first) It also has an artist talk time on the next day at 2:00. This also shows up but in both today and tomorrow. This behavior happens with all the posts. What am I doing wrong? **revised code**                <?php           $today = date("Y-m-d 00:00");  //set today's date            $todaytext = date("l");  // define $todaytext with written out days           for ($i=0; $i<7; $i++){           $thedate = strtotime ( '+'.$i.' day' , strtotime ( $today ) ) ;           $thedate = date ( 'Y-m-d H:i' , $thedate );           $thedatetext = strtotime ( '+'.$i.' day' , strtotime ( $todaytext ) ) ;           $thedatetext = date ( 'l' , $thedatetext );           $future = strtotime ( '+23 hours' , strtotime ( $thedate ) ) ;           $future = date ( 'Y-m-d H:i' , $future );       $args = array(      'post_type' => 'event',      'orderby'     => 'meta_value',      'order'       => 'asc',      'meta_query' => array(      'relation' => 'OR',         array(             'key' => 'opening_time',             'value' => array($today,$future),             'compare' => 'BETWEEN',             'type' => 'DATE'         ),         array(             'key' => 'artist_talk_time',             'value' => array($today,$future),             'compare' => 'BETWEEN',             'type' => 'DATE'             )     )     );          $event_query = new WP_Query( $args );           if ($event_query->have_posts()) : while ($event_query->have_posts()) :  $event_query->the_post();              $keys = array('opening_time', 'film_time', 'artist_talk_time');     $times = array();     $custom_field_keys = get_post_custom_keys();          foreach ($custom_field_keys as $custom_field_key) {          if (in_array($custom_field_key, $keys))      {         $custom_field_value = get_post_meta($post->ID, $custom_field_key, true);              if ($custom_field_value >= $thedate && $custom_field_value <= $future) {                  $counttest++;                  $times[$custom_field_key] = $custom_field_value;         }      }      }           endwhile;      if ($counttest >0) {       echo $counttest;            if ($counttest>=2){       echo ' Events ';       } // end if ($totalevents>=2) function            if ($counttest<2){        echo ' Event ';       }       echo $count;       if ($thedate==$today){echo 'Today';}       if ($thedate>$today){       echo $thedatetext;}       echo  '
';       }            endif;            $counttest=0;            if ($event_query->have_posts()) : while ($event_query->have_posts()) :  $event_query->the_post();            asort($times);       foreach ($times as $time_key => $time_value) {            if ($time_key == 'opening_time') {         ?>       <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('
', '
'); ?>
Opening
            <?php       echo get_post_meta($post->ID,'opening_time', true);       the_content();       }       else if ($time_key == 'artist_talk_time') {             ?>       <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('
', '
'); ?>
Artist Talk
            <?php       echo get_post_meta($post->ID,'artist_talk_time', true);       the_content();       }       else if ($time_key == 'film_time') {             ?>       <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('
', '
'); ?>
Artist Talk
            <?php       echo get_post_meta($post->ID,'film_time', true);       the_content();       }            }            endwhile;            endif;       rewind_posts();            }       ?>      **END EDIT 11/15/2011 - Original Question Below** Through help on this answers collection I have the code working below that sorts events by date and then lists them and counts them. It does not filter by time. For example, a single CPT 'event' has multiple meta_keys with a yyyy-mm-dd 00:00 entry. Each main event or art opening runs for about a month, but there is also the opening reception and artist talks that have their own meta_keys opening_time and artist_talk_time. I have another page that lists the month long portion of the events. Now I am trying to list the upcoming events in order. The problem is in an individual CPT "event" if the artist_talk_time is 16:00 and the opening_time is after 16:00, the opening_time shows first since it is called first in the loop where I display the_content(). This is not the behavior that I want. All events on a single day, even if in the same CPT should be listed in order by time. I am sure that I am doing this the wrong way and any help is greatly appreciated. Thank you.               <?php           $today = date("Y-m-d 00:00");           $todaytext = date("l");            for ($i=0; $i<7; $i++){           $thedate = strtotime ( '+'.$i.' day' , strtotime ( $today ) ) ;           $thedate = date ( 'Y-m-d H:i' , $thedate );           $thedatetext = strtotime ( '+'.$i.' day' , strtotime ( $todaytext ) ) ;           $thedatetext = date ( 'l' , $thedatetext );           $future = strtotime ( '+23 hours' , strtotime ( $thedate ) ) ;           $future = date ( 'Y-m-d H:i' , $future );       $args = array(      'post_type' => 'event',      'orderby'     => 'meta_value',      'order'       => 'asc',      'meta_query' => array(      'relation' => 'OR',         array(             'key' => 'opening_time',             'value' => array($today,$future),             'compare' => 'BETWEEN',             'type' => 'DATE'         ),         array(             'key' => 'artist_talk_time',             'value' => array($today,$future),             'compare' => 'BETWEEN',             'type' => 'DATE'             )     )     );           $event_query = new WP_Query( $args );                if ($event_query->have_posts()) : while ($event_query->have_posts()) :  $event_query->the_post();           if ((get_post_meta($post->ID,'opening_time', true)>=$thedate) && (get_post_meta($post->ID,'opening_time', true)<=$future))       { $counttest++;}          if ((get_post_meta($post->ID,'film_time', true)>=$thedate) && (get_post_meta($post->ID,'_time', true)<=$future))       { $counttest++;}          if ((get_post_meta($post->ID,'artist_talk_time', true)>=$thedate) && (get_post_meta($post->ID,'artist_talk_time', true)<=$future))       { $counttest++;}          endwhile;       if ($counttest >0) {       echo $counttest;            if ($counttest>=2){       echo ' Events ';       } // end if ($totalevents>=2) function            if ($counttest<2){        echo ' Event ';       }       echo $count;       if ($thedate==$today){echo 'Today';}       if ($thedate>$today){       echo $thedatetext;}       echo  '
';       }            endif;            $counttest=0;            if ($event_query->have_posts()) : while ($event_query->have_posts()) :  $event_query->the_post();            if ((get_post_meta($post->ID,'opening_time', true)>=$thedate) && (get_post_meta($post->ID,'opening_time', true)<=$future))       {       ?>       <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('
', '
'); ?>
Opening Reception
       <?php       echo get_post_meta($post->ID,'opening_time', true);       the_content();            }            if ((get_post_meta($post->ID,'artist_talk_time', true)>=$thedate) && (get_post_meta($post->ID,'artist_talk_time', true)<=$future))       { ?>       <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('
', '
'); ?>
 Artist Talk
       <?php        echo get_post_meta($post->ID,'artist_talk_time', true);       the_content();            }             endwhile;            endif;       rewind_posts();            }       ?>


How to execute code only on posts older than 2 weeks

I am trying to modify a plugin to only execute on posts that are older than two weeks. I added the isOldEnough function below to try and do that. What am I missing, here?               function remove_metadata()          {     $isOldEnough = function ()         {             $postDate = strtotime( $post->post_date );             $todaysDate = time();             if($postDate - $todaysDate > 129600) {                 return true;             } else {                 return false;             }         };      if ($isOldEnough)       {             /* Register style css. */             wp_enqueue_style( 'remove-style-meta', plugins_url( 'css/entrymetastyle.css', __FILE__ ), false, '1.0', 'all' );          }     }     add_action('wp_head', 'remove_metadata');      The plugin simply removes the metadata using a couple lines of CSS. Right now it executes the code on all posts, regardless of post_date.


How to have two column on my index page?

I want two full columns after the header and main menu bar on my index page. Seems simple, but googling and prowling the wordpress.org site hasn't gotten me anywhere. Short explanation + a link to relevant section of TFM to R would be much appreciated.


I can't access the pages for my custom taxonomy

I'm working on a recipe site that has a custom post type, recipes, with two custom taxonomies for handling recipe categories and tags. The custom post type works and so does the custom taxonomy for the categories, i.e. i can access individual posts and category pages. However, when I try to access a custom taxonomy tag page, I get the wordpress 404 page. I don't really know how to troubleshoot this since wordpress isn't giving me any useful error codes. Any suggestions?


How do I use two different images, one as a thumbnail and one as a linked image?

I wanted to do an image gallery in a post, where the linked image (a href) was different from the thumbnail's src. Unfortunately, WP seems completely incapable of doing this. If I put the large image in the gallery, I can't specify a custom thumbnail. If I put the thumbnail in the gallery, I can't link the large image since "Link URL" appears to be broken. If I change the "Link URL" and then click "Save All Changes," it ignores whatever changes I make in the "Link URL" text box. Since there appears that there is no way to do this from the front end (which seems ridiculous?), I went looking through my web site's directories in an attempt to find where the blog posts are stored, but they're not on "/wp/" nor "/wp/wp-content", so I'm sort of stumped here!


Redirect category to first available child post

Is possible to redirect category to first available child post please? Thanks!


Replacement for gallery_shortcode function not taking all attributes

I have the following custom function to replace the `gallery_shortcode` function from core. It hooks in at the beginning and works. **The problem** is that I can't get my custom key/values from the gallery shortcode in there. I receive them in the core function, but they don't get passed into my custom function. I can't really investigate what's going wrong or where they get missing, because i don't get any `print_r` output for `$attr` inside my custom function. Any ideas? _Note: I added comments for everything I changed from the core to my custom function._               function modified_post_gallery( $attr )      {         // I can't get any output from the following         echo '
';                  print_r( $attr );          echo '
';         // But: i get the expected output if i place the same line inside the core function:          /root/wp-include/media.php line 759 and get the actual output including all custom key/values.              global $post, $wp_locale;              static $instance = 0;         $instance++;              $output = '';              // We're trusting author input, so let's at least make sure it looks like a valid orderby statement         if ( isset( $attr['orderby'] ) )          {             $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );             if ( ! $attr['orderby'] )                 unset( $attr['orderby'] );         }              // extract result from user input & defaults         extract( shortcode_atts( array(              'order'        => 'ASC'             ,'orderby'      => 'menu_order ID'             ,'id'           => $post->ID             ,'itemtag'      => 'span' // CHANGED             ,'icontag'      => 'span' // CHANGED             ,'captiontag'   => 'span' // CHANGED             ,'columns'      => 3             ,'size'         => 'thumbnail'             ,'include'      => ''             ,'exclude'      => ''             ,'class'        => '' // ADDED             ,'test'         ), $attr ) );              $id = intval( $id );         if ( 'RAND' == $order )             $orderby = 'none';              if ( !empty( $include ) )          {             $include = preg_replace( '/[^0-9,]+/', '', $include );             $_attachments = get_posts( array(                   'include'          => $include                 ,'post_status'      => 'inherit'                 ,'post_type'        => 'attachment'                 ,'post_mime_type'   => 'image'                 ,'order'            => $order                 ,'orderby'          => $orderby              ) );                  $attachments = array();             foreach ( $_attachments as $key => $val )              {                 $attachments[$val->ID] = $_attachments[$key];             }         }          elseif ( !empty( $exclude ) )          {             $exclude = preg_replace( '/[^0-9,]+/', '', $exclude );             $attachments = get_children( array(                   'post_parent'      => $id                 ,'exclude'          => $exclude                 ,'post_status'      => 'inherit'                 ,'post_type'        => 'attachment'                 ,'post_mime_type'   => 'image'                 ,'order'            => $order                 ,'orderby'          => $orderby              ) );         }          else          {             $attachments = get_children( array(                   'post_parent'      => $id                 ,'post_status'      => 'inherit'                 ,'post_type'        => 'attachment'                 ,'post_mime_type'   => 'image'                 ,'order'            => $order                 ,'orderby'          => $orderby              ) );         }              // No attachments, so abort         if ( empty( $attachments ) )             return '';              // RSS/Atom         if ( is_feed() )          {             $output = "\n";             foreach ( $attachments as $att_id => $attachment )                 $output .= wp_get_attachment_link( $att_id, $size, true )."\n";                  return $output;         }              $itemtag = tag_escape( $itemtag );         $captiontag = tag_escape( $captiontag );         $columns = intval( $columns );         $itemwidth = $columns > 0 ? floor( 100/$columns ) : 100;         $float = is_rtl() ? 'right' : 'left';              $selector = 'gallery-'.$instance;              $gallery_div = '';              $size_class = sanitize_html_class( $size );              $gallery_div = '
';              $i = 0;         foreach ( $attachments as $id => $attachment )          {             $class = $columns > 0 && ++$i % $columns == 0 ? ' last' : ''; // ADDED for the single item/image                  $link = isset( $attr['link'] ) && 'file' == $attr['link'] ? wp_get_attachment_link( $id, $size, false, false ) : wp_get_attachment_link( $id, $size, true, false );                  $output .= '<'.$itemtag.' class="gallery-item '.$class.'">'; // ADDED class             $output .= '<'.$icontag.' class="gallery-icon">'.$link.'</'.$icontag.'>';             if ( $captiontag && trim($attachment->post_excerpt) )             {                 $output .= '<'.$captiontag.' class="wp-caption-text gallery-caption">';                 $output .= wptexturize( $attachment->post_excerpt );                 $output .= '</'.$captiontag.'>';             }             $output .= '</'.$itemtag.'>';         }         $output .= ''."\n";              return $output;     }     add_filter( 'post_gallery', 'modified_post_gallery', 10, 2 );


How to run this SQL query of wp_terms database

I have the following tables (only pertinent info included for brevity and clarity) Table Name: wp_term_relationships               object_id    term_taxonomy_id     1266         1341     1266         452     1266         449      Tabloe Name: wp_term_taxonomy               term_taxonomy_id    term_id     1341                1342     452                 453     449                 450      Table Name: wp_terms               term_id      name      slug     1342         792       792     453          396       396     450          394       394      I have a list of the wp_term "names" and I want to get a list of the object_ids (only unique ones) from wp_term_relationships So, my list will be something like: 394, 396, 988, 666 And I would like it to return (based on the above data): 1266 (i.e. Using term_id from wp_terms to get term_taxonomy_id from wp_term_taxonomy and then finally using that value in wp_term_relationships to get the object_id) I am quite new to mySQL and have been reading/experimenting with it all day and can't seem to get it quite right.               SELECT $wpdb->term_relationships.object_id     FROM $wpdb->term_relationships         LEFT JOIN $wpdb->term_taxonomy ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id         LEFT JOIN $wpdb->terms ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id        WHERE name IN (394, 396, 988, 666)       GROUP BY $wpdb->term_relationships.term_taxonomy_id     ORDER BY $wpdb->term_relationships.term_taxonomy_id DESC      I wondered if someone could maybe cast an experienced eye over it and help me see where I'm going wrong? Thank you :-) This is my query so far:


Can I bulk register contributors for a new blog

I just designed a blog to go with our small classic car club website here in the south of Spain. Before I make it available to club members I need to do something about registration. I have read up on as much as I can find but couldn't find an answer to this: Ideally I would like to be able to pre-register the 60 or so members so that they can post and comment from the outset (some are not very computer literate and registering first might throw them for a loop). I have looked at the user creation part of Dashboard and it would be very laborious to have to do this for every member. Is there a simple way to create, say, contributor rights for all the members? I have their names and email addresses - e.g. in an excel file. Is there any way to cut and paste from, or import a pre-defined list? Thanks for any help...


Plugin similar to Taxonomy Drill-Down for custom fields?

Is there a plugin available that does for custom fields what Scribu's excellent Taxonomy Drill-Down (formerly called Query Multiple Taxonomies) does for taxonomies?


Problem Building a Simple Google Maps Plugin

I'm learning how to build a google maps plugin. (I know that there are plugins that add Google Maps, but I'd like to be able to adapt the code to my needs. And it's fun to learn). Unfortunately, I'm not getting a map after inserting my short code. This is the main php file of the plugin:               <?php     /*     Plugin Name: Lax Google Map Plugin     Plugin URI: http://www.mysite.com     Description: Make Map     Version: 1.0     Author URI: http://www.mysite.com     */               function lax_google_map_init() {         wp_enqueue_script('google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=false');     }     add_action('init', 'lax_google_map_init');               function lax_google_map_init_js() {       wp_enqueue_script('lax_google_map_script', plugins_url('js/lax_google_map_script.js', __FILE__), array('google-maps'));         }           add_action('init', 'lax_google_map_init_js');               function lax_google_map_maker($atts,$content=null) {                  $output = '

';          return $output;          }                    add_shortcode('lax-google-map', 'lax_google_map_maker');     ?>      In the javascript file, I've got:               jQuery.noConflict();          jQuery(document).ready(function($) {            var latlng = new google.maps.LatLng(-34.397, 150.644);       var myOptions = {           zoom: 8,           center: latlng,           mapTypeId: google.maps.MapTypeId.ROADMAP         };         var map = new google.maps.Map(document.getElementById("map_canvas"),             myOptions);          });      I'm not getting an error. It doesn't do anything. Any suggestion as to what I'm doing wrong? I want to get a basic map working and then I should be able to add more functionality later. Thank you. -Laxmidi


How do I properly format the user_role array?

I used a role editor recently and needed to delete a role. After deleting it I noticed that it began to appear as blank in the edit user role drop-down. After a bit of investigating and deleting entries from the database. I renabled more_fields and the blank boxes reappeared. I then did a db search and found multiple entries in wp_options more_fields as `a:12:{i:0;s:13:"administrator";i:1;s:6:"editor";i:2;s:6:"author";i:3;s:11:"contributor";i:4;s:10:"subscriber";i:5;s:11:"distributor";i:6;s:10:"integrator";i:7;s:5:"sales";i:8;s:7:"support";i:9;s:7:"revisor";i:10;s:7:"premier";i:11;s:9:"marketing";}` I've tried adjusting it back to wps default roles like the example below but it causes a 404. `a:5:{i:0;s:13:"administrator";i:1;s:6:"editor";i:2;s:6:"author";i:3;s:11:"contributor";i:4;s:10:"subscriber";}` Do I have my syntax correct or am I missing something else? I've added the database entry to pastebin, you'll notice that the user role array is listed five times. Thanks for the help. http://pastebin.com/RpsFytgc ![enter image description here](http://i.stack.imgur.com/Dkvy0.png)


How do I redirect a post url to a custom url?

I've created a page that loops posts. Each post acts as a category link so that when you click it brings you to a category archive. My issue is that wordpress somehow overrides my htaccess and redirects me to the single.php post. So ill have a category page called 'Neighborhoods'. Within 'Neighborhoods' I have a post called 'Highland Park'. When I click 'Highland Park' it brings you to the the single.php not the archive.php of 'Highland Park.' Note: I uploaded my wordpress files into a folder called 'pages'. In my htaccess file I have a rewrite where 'neighborhoods/' is 'pages/category/neighborhoods/' Is there a solution? Am I overlooking something? Thanks in advance!


How to override WP_DEBUG for Ajax responses?

It is highly recommended practice (that I completely agree with) to develop with `WP_DEBUG` enabled. However it is merely inconvenient to see not yet fixed warnings in pages, but in Ajax responses they ruin response completely. I am just starting with Ajax in WP, is there some appropriate hook to suppress errors for Ajax responses only? PS fix everything is not viable option at moment, because it is extremely extensive and complex environment :)


Images Being Incorrect Generated Outside Of Wrapper in Wordpress Nivoslider

I have the following code generating the images and thumbnails from the featured image of a post in the category Showcase.               <?php         $featured_image = get_the_post_thumbnail( get_the_ID() );         $dom = new DOMDocument();         $dom->loadHTML($featured_image);              $fi_src = $dom->getElementsByTagName('img')->item(0)->getAttribute('src');              $slider = get_the_post_thumbnail( get_the_ID(), 'thumbnail' );         $dom = new DOMDocument();         $dom->loadHTML($slider);          $s_src = $dom->getElementsByTagName('img')->item(0)->getAttribute('src'); ?>          <img src="<?php echo $fi_src; ?>" data-thumb="<?php echo $s_src; ?>" title="" />      However on implementation, and multiple posts. Its throwing the images outside the wrapper http://www.milknhny.co.uk/ Can anyone advise how this can happen?


How to share WordPress session and cookies between domain and subdomain?

I have missed a lot of time by searching answer to my question. For today I have two WP installations on the one server and one DB but with different prefix. I already shared users data and meta between two blogs and it working fine! But I still can’t setup autologin or single sign on under two blogs. The code below does not work in WP3.8.               define('COOKIE_DOMAIN', '.domain.com'); //replace with the 1st website URL     define('COOKIEPATH', '/');


Conditional statement for if archive page has posts which contain certain taxonomies/categories/tags, show those terms

I am using Isotope to filter posts on the fly from my archive pages. I have a Custom Post Type called "art". On the sidebar, I've created links to yearly archives on my sidebar, i.e. 2014, 2013, 2012... etc. When I am on a yearly archive page, i.e. /art/2012, I want _only the terms which exist_ for _this custom-post-type_ on _this year's archive page_ to appear. For example, if I am on the date archive of 2009, I only have drawings, not paintings, so I only want the category "Drawings" to show, as clicking "Paintings" will yield zero results (hence the redundancy). The code I have currently on my sidebar.php (outside the loop) is a modified version that I found here which simply makes wordpress regurgitate all categories across all post types, which is not what I want:

All
              <?php // Verify if tag/cat is used in archive: http://wordpress.stackexchange.com/a/31981/32287         $categorys = get_categories(                         array(                         'type' => 'art',                         'exclude' => '1,5',                         'hide_empty' => false                         )          );         if ($categorys) {             foreach ($categorys as $category) {                 echo '
';                 if($category->count > 0){ // check cat count                         echo 'slug . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name . '
';                 } else { // if no posts                 }             } // end foreach         } // end if         ?>
      Can anyone help me write a function which will output the terms that only exist for the yearly date archive page of custom post type "Art"? Been googling for days without avail. :(


Create a Page via plugin

My problem is to show a list of products read from db tables. I know how to read them and I am able to produce the table, but only using a shortcode embedded in a page that I've created via WP. I want the plugin itself create a page with my table inside, and that this page is made available to the WP users via a menu item (not the admin menu). What is the right way?


What are the common security flaws I need to look for?

As a wannabe WP plugin developper, what are the main security flaws/holes I should look for? I'm about to create a new plugin with a configuration panel (ie input fields and stuff). What should I be concerned about? For example, is data sanitization such a big deal since it's in the /wp-admin/ area? Could someone malicious directly hit my plugin page and send POST requests or something like that? Thank you!


Paypal Framework

I'm trying to set up a paypal-subscription-based website, where people can sign up if they pay a subscription fee trough Paypal. I'm pretty new to this Paypal IPN system, but I found this plugin which seems to do what I want: http://wordpress.org/extend/plugins/paypal-framework/ Does anyone know what command do I need to send trough the hashCall() function to set up a paypal subscription for the user that's attempting to register? I assume it's something else than `doDirectPayment` and doesn't require all those CC parameters, right?


Review site using Wordpress

I have my domian viewport.mobi, I want to create mobile review site like http://www.mobileawesomeness.com/ , I think its created in wordpress. Can anyone suggest a free or paid theme available for wordpress. so I can post screenshot of the mobile site and the review, also Open for Comments. Thanks,


How to store the value of a custom field dropdown select for post referencing?

I'm trying to reference posts to each other. Editors should have a custom field select list of certain post's titles to link the current post with other posts. I got quite far, I think. The select list appears correctly. All titles are there. Now, I'm stuck at the point, where the referred post's ID has to be saved. How do I grab the selected option's value, save it and make it default value? Do I have to wrap everything inside a form function? This is what I have so far:               add_action("admin_init", "admin_init");     add_action('save_post', 'save_reference_id');       /*** add_meta_box ***/     function admin_init(){         // adding a custom field to post type 'case'         add_meta_box("refInfo-meta", "Reference", "meta_options", "case", "side", "high");     }       /*** callback ***/     function meta_options(){       ?>         <form action="<?php bloginfo('url'); ?>" method="get">           <select name="page_id" id="page_id">                <?php           global $post;           // getting all child pages of ID 21           $args = array( 'numberposts' => -1, 'post_type' => 'page', 'post_parent' => 21);           $posts = get_posts($args);                foreach( $posts as $post ) : setup_postdata($post); ?>             <option value="<?php echo $post->ID; ?>"><?php the_title(); ?></option>           <?php endforeach; ?>                </select>         </form>            <?php     }       /*** save_post ***/     function save_reference_id(){       // big question mark     }


Custom WP_List_Table: How to create an unapproved row?

In this Example, let's assume every item had the attribute `$item['approved']` with values Zero unapproved and One for approved. How can I get the rows of the "unapproved books" to be yellow? (well, it's not about the yellow, but about the WP standard compliant procedure of marking rows as unapproved)


How to get rid of error message of custom metabox in dashboard when moving out of edit page?

in plugins folder i'have `custom-post-metabox folder`, inside it `custom-post- metabox.php`, `admin.js` and `admin.css`. //code of `custom-post-metabox.php`               <?php          /**      * Plugin Name: Custom Post Meta Box      * Plugin URI: http://localhost/wpuploadtest      * Description: Demonstration of custom post meta box      * Version:1.0.0      * Author: me      * Author URI: http://google.co.in      * License:GPL2      */               function cpmb_css(){              wp_enqueue_style('cpmb-admin', plugins_url('custom-post-metabox/admin.css'));     }          add_action('admin_enqueue_scripts', 'cpmb_css');               function cpmb_js(){            $screen = get_current_screen();                 if ('post' == $screen->id) {         wp_enqueue_script('cpmb-admin', plugins_url('custom-post-metabox/admin.js'));       }          }          add_action('admin_enqueue_scripts', 'cpmb_js');                         function cpmb_add_meta_box(){              add_meta_box(            'cpmb_audio',            //The ID for the meta box            'Add_mp3',               //The title for the meta box            'cpmb_display_meta_box', //the callback function for the meta box            'post',                  //we'll be only displaying this on posts            'side',                  //where the meta box should appear            'core'                   //the priority of where the meta box should be displayed             );     }          add_action('add_meta_boxes', 'cpmb_add_meta_box');          function cpmb_display_meta_box($post){            wp_nonce_field(plugin_basename(__FILE__), 'cpmb-nonce-field');            if ('invalid-file-type' == get_post_meta($post->ID, 'mp3', true)) {         ?>
Invalid File Type
       <?php         }              ?>               MP3 Title              <input type="text" id="mp3_title" name="mp3_title" value="<?php echo get_post_meta($post->ID, 'mp3_title', true); ?>" placeholder="Give me some sunshine">               MP3 File              <input type="file" id="mp3_file" name="mp3_file">         <?php     }                         function cpmb_save_metabox_data($post_id){              if(cpmb_user_can_save($post_id, 'cpmb-nonce-field')){                         if (isset($_POST['mp3_title']) && !empty($_POST['mp3_title']) ) {                      $mp3_title = stripslashes(strip_tags($_POST['mp3_title']));                      update_post_meta($post_id, 'mp3_title', $mp3_title);                    }                             if (isset($_FILES['mp3_file']) && !empty($_FILES['mp3_file']) ) {                                 if (cpmb_valid_mp3($_FILES['mp3_file']['name'])) {                                   $response = wp_upload_bits($_FILES['mp3_file']['name'], null, file_get_contents($_FILES['tmp_name']));                                   if (0 ==strlen(trim($response['error']))) {                                     update_post_meta($post_id, 'mp3', $response['url']);                                   }                            }else{                                     update_post_meta($post_id, 'mp3', 'invalid-file-type');                            }                       }         }          }          add_action('save_post', 'cpmb_save_metabox_data');                    function cpmb_valid_mp3($filename){      $path_parts = pathinfo($filename);           return 'mp3' == strtolower($path_parts['extension']);          }          function cpmb_user_can_save($post_id, $nonce){            $is_autosave = wp_is_post_autosave($post_id) ;       $is_revision = wp_is_post_revision($post_id);       $is_valid_nonce = (isset($_POST[$nonce]) && wp_verify_nonce($_POST[$nonce], plugin_basename(__FILE__) )  );            return !($is_autosave || $is_revision) && $is_valid_nonce;     }               function cpmb_display_mp3($content){                if(is_single()){                if('invalid-file-type' != get_post_meta(get_the_ID(), 'mp3', true)){                      $title = get_post_meta(get_the_ID(), 'mp3_title', true);                 $link  = get_post_meta(get_the_ID(), 'mp3', true);                 $content .= ''.$title.'';                          }                     }              return $content;     }          add_action('the_content', 'cpmb_display_mp3');      //code of `admin.js`               (function($){       "use strict";            $(function(){              $('form').attr('enctype', 'multipart/form-data');       });          })(jQuery);      The problem is if i just click on the update button without uploading anything the error message of invalid file type is still there , even if i leave the page and comeback to the edit page the error message is still there. How to fix it?


WordPress Twenty Twelve Child Theme. Removing default widgetized areas

I'm trying to remove Main Sidebar, First and Second Front Page Widget areas in my child theme. Basically I don't want them to be shown up in Admin Panel. I've placed that code into my function.php file. It's seems to not work:               function remove_some_widgets(){              unregister_sidebar( 'Main Sidebar' );         unregister_sidebar( 'First Front Page Widget Area' );         unregister_sidebar( 'Secon Front Page Widget Area' );     }     add_action( 'widgets_init', 'remove_some_widgets', 11 );      I've got it from WordPress Codex but I think that was developed for Twenty Ten theme. Anyone knows the right code for Twenty Twelve parent theme. ? Thanks for answers.


How to hook in and modify the new revisions UI (3.6+)?

Let's say I want to add some post_meta into the "new" revisions UI. I'm saving some meta on revisions only, and want to display it on this screen. ![enter image description here](http://i.stack.imgur.com/nmfgQ.png) Normally, I'd open up `wp-admin/revisions.php` look for some hooks and code away. But the revisions page is all done with Backbone. I don't know Backbone (totally willing to learn). However, I can't find anything about how to modify existing admin Backbone views in WordPress. Has anyone successfully modified this interface and can provide an example of how it can be done?


Edit / Change Jetpack Mobile Theme

I really like the idea to switch themes for mobile devices and am using jetpack for several feature on my website, So I thought, why not use it for mobile devices as well. Jetpack comes packed with a feature that switches themes for mobile devices, but it is only possible to use their theme and adjust some things like bg colour etc.. I was wondering is it possible to completely change this theme? So use jetpack to detect device, yet use your own mobile theme? That would stay like that after any updates.


Share plugins, themes, and multi post in a multidomain network

I have created a network consisting of 3 sites (site1.com, site2.com, site3.com). Everything works fine, and I can access all three sites fine. What I need is to be able to share themes, plugins and post to all sites. I have tried multipost-mu, and ThreeWP Broadcast. When I create a post I can now choose the other two sites, but the post doesn't show up there. The way I set up my network is:   1. My host Setup the dns with a wildcard A record, and setup apache by adding ServerAlias *.|DOMAIN| to my httpd.conf   2. I then added the subdomain   3. I Edit the new subdomain: Changeg the value of Domain, Siteurl, Home, and Fileupload Url to suit to my new domain (http://www.site1.com)   4. I Edit my wp-config.php: define( 'DOMAIN_CURRENT_SITE', 'domain.com' ); changed it to define( 'DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST'] ); What am I doing wrong?


Copy and delete a directory with WordPress functions

I have successfully used `copy_dir()` to copy a directory to a new location. How can I delete a directory using WordPress functions?


Different Category Headers using in_category and elseif

At the moment I'm trying to figure out why this snippet is not working basically I want to display a div id for different categories. I'm using the following.                <?php if (in_category( array('6,14,15,13') )) { ?>
           <?php } elseif (in_category( array('7,11,12,10,9') )) { ?>
           <?php } elseif (in_category( array('4,16,17,18,19') )) { ?>
           <?php } elseif (in_category( array('3,22,21,26') )) { ?>
           <?php } elseif (in_category( array('5') )) { ?>
           <?php } else { ;?>
           <?php } ?>      But this is not working I'm getting the following error message: Parse error: syntax error, unexpected $end in /home/test/public_html/project/wp-content/themes/project/category.php on line 75 Line 75 is the               <?php get_footer(); ?>      Any help would be awesome, thanks!


Custom field query without duplicates results

I have categories as cities like london or new york I also have a custom field called Location where I usually put the name of a restaurant. I am trying to show on a separate post/page all the restaurants in a certain town. Each post I make is basically a review of a restaurant but sometimes there is a review for the food or another one for their bar. I can t seem to figure out how to list all the restaurants in one city without getting duplicates. I have this for example:               <?php query_posts('posts_per_page=20&category_name=New York&meta_key=Location&order=DES'); ?>     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>     <a href="<?php the_permalink(); ?>"><?php the_title(); ?>     <?php $links = get_post_custom_values("Location");     if ($links[0]!="") {     $mykey_values = get_post_custom_values('Location');     foreach ( $mykey_values as $key => $value )     {     echo $value;     echo "

";     }     }     ?>      So this lists all the posts from New York and the content of the custom field called Locations. But I am getting duplicates. I would like that if there is a location on a post called Trump Tower that it will show listed only once? Any help is appreciated


Force logged in users to provide more data when commenting

I have added more data to my comment using hooks. I added a group of radio buttons so users can select and choose one of radio buttons. Everything works perfectly fine but the newly added radio buttons do not show up when you're already logged in.. they only show up and work when you are not logged in. Logged in users only see the comment box. How to show the newly added field alongside with the comment box to logged in user? this is what I added to my functions.php               function add_comment_fields($fields) {              if(is_user_logged_in()) {                  $fields['age'] = '
' . __( 'Age' ) . '' .             '<input id="age" name="age" type="text" size="30"' . $aria_req . ' />
';             return $fields;         }     }     add_filter('comment_form_default_fields','add_comment_fields');               function add_comment_meta_values($comment_id) {              if(isset($_POST['age'])) {             $age = wp_filter_nohtml_kses($_POST['age']);             add_comment_meta($comment_id, 'age', $age, false);         }          }     add_action ('comment_post', 'add_comment_meta_values', 1);


How to show custom field and parent post id in wordpress attachment page (image.php)

I'm trying to use code to show custom field outside the loop in wordpress attachment page (image.php) it's returns nothing. this is the code i'm used to show the custom field:               <?php     global $wp_query;     $postid = $wp_query->post->ID;     echo get_post_meta($postid, 'my-custom-field', true);     ?>      and i'm trying to show parent post id in attachment page too with `get_the_id` and use this code               <?php global $wp_query;     $this_page_id = $wp_query->post_parent;     $post_id = get_the_id($post->ID);     echo $post_id ;?>      but the code above just shown the attachment ID not the parent post ID. anyone can help, please ?


Delete original image - keep thumbnail?

I'm using a lot of thumbnails but never the original file. To save space, I'd like to prevent the original from being saved on disk but only keep a thumbnail of 100px. How can I do this? Thanks, Dennis


Set (featured) thumbnail for post?

I'm using wp_insert_post and media_sideload_image to create a post and attach a single image to the post. However, how can I mark this attached image as featured thumbnail? It would make listing the thumbnails significantly faster by using the_post_thumbnail instead of looping through each post manually showing the first image. How can I mark the attached image as featured thumbnail? Thanks, Dennis


If have posts a week old, display, else display a different loop

This is what I have.               <?php     $week = date('W');     $year = date('Y');     $projects_in_news = new WP_Query(                     array(                     'post_type' =>'news',                     'posts_per_page' => 5,                     'orderby' =>'ID',                     'order' =>'ASC',                     'w' => $week,                     'y' => $year,                     'tax_query' => array(                             array(                                  'taxonomy' => 'project_taxo',                                  'terms' => $post->post_name,                                  'field' => 'slug'                                  )                            )                     )     );          // The Loop     <?php if($projects_in_news->have_posts()) : ?>                  <?php while($projects_in_news->have_posts()) : $projects_in_news->the_post(); ?>

                              <a href="<?php the_permalink(); ?>">                                 <?php the_title(); ?>                                 <?php the_author(); ?>, <?php the_time('d F Y'); ?>

             <?php endwhile; ?>                  <?php else: ?>
There is no news related to this theme
                  <?php endif; ?>                 <?php wp_reset_postdata(); ?>      What I have here displays posts from the last week that match the query. Is there a way of determining if this loops query has posts and if not use a different query and loop? I tried adding the following code in place of `<p>There is no news related to this theme</p>`                                                 <?php                                                  $theme_in_news = new WP_Query(                                                         array(                                                             'post_type' =>'theme',                                                             'posts_per_page' => 5,                                                             'orderby' =>'ID',                                                             'order' =>'ASC',                                                         )                                                 );                                         ?>                                              <?php if($theme_in_news->have_posts()) : ?>                                              <?php while($theme_in_news->have_posts()) : $theme_in_news->the_post(); ?>

                                                 <a href="<?php the_permalink(); ?>">                                                 <?php the_title(); ?>                                                 <?php the_author(); ?>, <?php the_time('d F Y'); ?>

                                         <?php endwhile; ?>      But it returns an Internal Server Error. Thanks


References to other site everywhere in Wordpress site

I am relatively new to Wordpress, have been handed a site developed by someone else on one server, and have to deploy it to another. This site has bbpress installed, plus a load of other stuff. However it also seems to contain (somewhere) references to the other developers server, so even though I have copied the site onto my server all the links still point to his. I'm assuming that somewhere in the template files or database there is a reference to his site but I don't know where. I've done a search / replace and replaced what I can find, but still the same thing happens. I'm just wondering if there is any really obvious place I need to look for things like that. It seems to me he has just done something pretty stupid by hard coding references to his site; but maybe it's for a good reason, I don't know.


Remove the whole menu in the admin

How can i remove the whole menu in the admin? I have this code:               function remove_menu_items() {         global $menu;              end( $menu );              while ( prev($menu) ) {             $value = explode( ' ', $menu[ key($menu) ][0] );             if ( $value[0] != NULL ? $value[0] : "" ) {                 unset( $menu[ key($menu) ] );             }         }     }     add_action( 'admin_menu', 'remove_menu_items' );      This only removes the default menu items, any pages added to the menu by a plugin are still there. How can i remove the whole menu?


How to display a listing template of a certain taxonomy?

I'm trying to figure out how to display a list of specific taxonomy (`categorycourses`). In `functions.php` for the theme I have:               //Register custom taxonomy for courses-categories     $course_cat_args = array(       'hierarchical' => true,       'labels' => $course_cat_labels, //Other labels set before       'show_ui' => true,       'show_admin_column' => true,       'query_var' => true,       'rewrite' => array( 'hierarchical' => true )     );          register_taxonomy( 'categorycourses', array('course'), $course_cat_args );      The actual taxonomy is working fine in admin. Now I'm trying to create a template for `categorycourses` at frontend that lists all coursecategories. I've looked at the template hierarchy and I thought I should create a file with the taxonomy name `categorycourses.php` So I created a file called `categorycourses.php` in the themes folder. I also tried creating `categorycourses-categorycourse.php`, `archive- categorycourses.php` but I just keep getting a 404 error. Please bare with me. I understand lot of backend-stuff in WP, but I'm just learning how to create templates at frontend. I'm able to create archive-pages for certain post typs, so rewrites rules and so on are working on my local server. What am I doing wrong? **UPDATE** 1\. I've tried to create a file name `taxonomy-categorycourses.php` and with same result (404 error) I've flushed permalink-settings in admin by resaving them I've also tried:               $course_cat_args = array(       'hierarchical' => true,       'labels' => $course_cat_labels,       'show_ui' => true,       'show_admin_column' => true,       'query_var' => true,       'rewrite' => array('slug' => 'soup')     );          register_taxonomy( 'categorycourses', array('course'), $course_cat_args );      I try to access the template with `http://server/soup` but still get the error. (after resaving permalink-settings in admin) **UPDATE2:** * _I think I've figured it out:_ * There don't seem to be any template for "root-taxonomy". You have to choose a specific coursecategory to act as a root. In my case I've created this file:               taxonomy-categorycourses-semester2014.php      When I then access `http://server/soup/semester2014` the expected template (t`axonomy-categorycourses-semester2014.php`) is shown. But there seems no way to actually create a "root template for a taxonomy" like `http://server/soup/` . Even if I create a template called `taxonomy- categorycourses.php` it does not work. **Is this correct?**


Moved server, and WP now uses original images for all thumb sizes?

I just moved servers. When calling `wp_get_attachment_image()` or any of its sister functions the image returned is always the full-size image, scaled down, instead of the requested thumbnail size. This has a pretty nasty impact on load times. Both AJAX thumbnail rebuild and Regenerate Thumbnails those have happily created plenty of thumbnails. WordPress just chooses to ignore them. Thanks for any help. This _might_ be a dupe of Major issue with image sizes being lost, only full size images being shown but I'm not sure. **Update** After some research, it appears that the attachment_meta => sizes array on each image has all the correct keys for sizes, but none of the values:               (     [width] => 677     [height] => 472     [hwstring_small] => height='89' width='128'     [file] => my_original_image.jpg     [sizes] => Array         (             [thumbnail] =>              [medium] =>              [large] =>              [admin-list-thumb] =>              [select-a-post] =>              [detail] =>          )      Why might this be happening?


how to assign an ID to a wordpress menu

The following code does not produce a UL with ID of "nav". It just produces

      This is the code:               wp_nav_menu( array( 'theme_location' => 'menu-1', 'container_id'    => 'nav';       According the WP Codex this should work. Why isn't it working? WP version = 3.5 **Update** I now have:               wp_nav_menu( array( 'theme_location' => 'menu-1', 'items_wrap' => '
%3$s
', 'menu_id' => 'nav'));      but this doesn't work either.


Only show posts with image and the correct ammount of posts in loop

This script makes a loop showing only posts with images, but I have a problem. It doesnt show the right ammount of posts pr page. Probably because it counts the total nr of posts, including the ones without pictures. Does anyone know how to fix this?               <?php      while ( have_posts() ) : the_post();         $content = $post->post_content;         $searchimages = '~<img [^>]* />~';         preg_match_all( $searchimages, $content, $pics );         $iNumberOfPics = count($pics[0]);         if ( $iNumberOfPics > 0 ) {             //your loop content goes here         }      endwhile;      ?>      Second problem: It also shows broken-image if the image in the post is external.