Hide Default Video Shortcode Controls on PageLoad

In wordpress 3.6+ when we use default video shortcode `[video]`, controls of video are always visible on pageload. How can we hide these controls on page load and show only when we hover over the video element. Using the CSS code below, does the trick ...               .wp-video .mejs-container .mejs-controls {         visibility: hidden;     }      But, controls wont show on hovering then. How to solve the issue?


How to completely save my wordpress data?

I am changing domain and I was wondering if using the export tool on my wordpress admin panel was enough to save all of my wordpress data? What I want to do is intall a new version of wordpress on my new domain and import the file I have exported using the tools. Does that file contain everything? Members, posts, images, preferences, etc? What does it save exactly. I want my other site to be exactly the same (I know I will have to add the theme again)


How come this loop is not working?

I've wrapped the contents of the loop within two `divs`. However, only the **first** post appears to be wrapped within the `divs`, leaving the latter unstyled. Here is the code:

                     <?php                     while ( have_posts() ) : the_post(); ?>
                         <?php the_title(); ?>                         <?php the_content(); //this is not in inner_box ?>

              <?php endwhile; ?>       Would anyone know why this is?


Display random page

I'd like to display a random page that:   * has a parent page of X _or_ Y _or_ Z, etc.   * excludes pages with the title "Contributors" The following code works (though without the specific conditions above), but **the_content** isn't displaying anything. I'm not sure what's going wrong there. fwiw, this is a template page for a child theme of Twenty Thirteen.               <?php     /*     Template Name: Random Page     */          get_header(); ?>

          <?php     $args = array( 'post_type' => 'page', 'numberposts' => 1, 'orderby' => 'rand' );     $rand_posts = get_posts( $args );     foreach( $rand_posts as $post ) : ?>                          <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_title(); ?>

                             <?php if($post->post_parent) {         $parent_link = get_permalink($post->post_parent); ?>     <a href="<?php echo $parent_link; ?>" class="parent-link parent-header"><?php     $parent_title = get_the_title($post->post_parent);     echo $parent_title;     ?>     <?php } ?>                               <?php the_content(); ?>                                       <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'twentythirteen' ) . '', 'after' => '
', 'link_before' => '', 'link_after' => '' ) ); ?>
                                                           <?php edit_post_link( __( 'Edit', 'twentythirteen' ), '', '' ); ?>
                          <?php twentythirteen_post_nav(); ?>          <?php endforeach; ?>     <?php wp_reset_query(); ?>

          <?php get_sidebar(); ?>     <?php get_footer(); ?>


How to change a specific page to custom page?

I want to change specific page so that non-member users will be faced with a form that they can register with, and also this page wouldn't look like the others, I mean this page must be totally different to other pages because of my HTML code. But I don't have any idea how to implement it. For example in my plugin I wrote this code:               function ok() {     if (is_page('get-messages')){         $user = wp_get_current_user();         foreach ($user->roles as $role) {             echo "$role<br>";         }         echo get_settings('siteurl') . '/get-messages';         if ( !is_user_logged_in() ) {             ?>             <form method="get" action="">             <input type="submit" value="ok">             </form>             <?php         }        }          }      add_action('template_redirect', 'ok');      what i must write in `if(!is_user_logged_in())` so that my plugin don't let to page loads its template and only show my html code. I appreciate your help


Getting a "Cannot modify header information - headers already sent by..." after duplicating widget

This probably isn't the smartest way to go about it, but I'm very close to launch and the client wanted a news widget displayed two ways. Our theme's news widget displays a settable number of news entry titles. So, I created another widget that would display the news entries, with the only difference being that it prints their excerpts. When I duplicated the widget, I changed its registry name, loaded it through functions, and changed the widget output slightly. So I have two widget files called `widget-news.php`   `widget-news-excerpts.php` Their respective code begins like this: From widget-news:               function gg_News_Widget() {              /* Widget name and description */         $widget_opts = array (             'classname' => 'gg_news_widget',              'description' => __('Display your latest News Entries.', 'gxg_textdomain')         );                $this->WP_Widget('gg-news-widget', __('SOUNDBOARD - News', 'gxg_textdomain'), $widget_opts);          }      From widget-news-excerpts:               function gg_News_Excerpt_Widget() {              /* Widget name and description */         $widget_opts = array (         'classname' => 'gg_News_Excerpt_Widget',          'description' => __('Display EXCERPTS (and not titles) of your latest News Entries.', 'gxg_textdomain')         );                $this->WP_Widget('gg_News_Excerpt_Widget', __('SOUNDBOARD - News Excerpts', 'gxg_textdomain'), $widget_opts);          }      I think I've been diligent about changing the name of the function throughout the new widget, except that when I update or add any sort of entry in the Dashboard, I now get: > Warning: Cannot modify header information - headers already sent by (output > started at /home/safespac/public_html/kim.safespac.es/wp- > content/themes/kimberley/includes/widgets/widget-news-excerpts.php:148) in > /home/safespac/public_html/kim.safespac.es/wp-includes/pluggable.php on line > 876 Any ideas about where to begin? I'm thinking of just figuring out how to add an checkbox option in the original widget that changes the display. Thanks for any and all assistance or even pointing in the direction of a solution. I'm using WP 3.5.1.


This code won't find authors page?

I am using this code to display current users author page. However if the user has a space in their username it won't find the URL. How can I get the code to place a '-' if there is a space in the author's username. Thanks `<?php if ( is_user_logged_in() ) { echo 'ID ) . '"> My personal page'; } else { echo 'Login'; } ?>`


get_theme_mod return a blank value instead of saved value

when i try this and in colors section , get_theme_mod works well               function tcx_register_theme_customizer( $wp_customize ) {         $wp_customize->add_setting(             'tcx_link_color',             array(                 'default'     => '#000000',                 'transport'   => 'postMessage'             )         );     $wp_customize->add_control(         new WP_Customize_Color_Control(             $wp_customize,             'link_color',             array(                 'label'      => 'Link Color',                 'section'    => 'colors',                 'settings'   => 'tcx_link_color'             )         )     );      but when i create a section and want to use it , get_theme_mod return a blank value               $wp_customize->add_section( 'page_styling', array(             'title'          => __( 'Background Colors', 'swift-framework-admin' ),             'priority'       => 210,         ) );              $wp_customize->add_setting(             'tcx_fontss_color',             array(                 'default'     => '#000000',                 'transport'   => 'postMessage'             )         );              $wp_customize->add_control(             new WP_Customize_Color_Control(                 $wp_customize,                 'fonts_color',                 array(                     'label'      => 'Test',                     'section'    => 'page_styling',                     'settings'   => 'tcx_fontss_color'                 )             )         );     }     add_action( 'customize_register', 'tcx_register_theme_customizer' );      what should i do ? my wordpress version is 3.9.1 and using php 5.3 if you need more detail let me know thanks


All URLs Redirect to Main Page

Whenever I try to access pages within my site, such as mysite.com/wp- login.php, it redirects to mysite.com. It doesn't redirect if I put www.mysite.com, however. Is this a domain configuration issue, or a WordPress issue?


Want to turn Wordpress into a paid subscription directory

I need to create a paid subscription directory where people can register their business and enter its details. Subscriptions should be paid on a monthly or yearly basis. Business details include typical fields such as: description, address, phone number, zip code, etc. The idea is that people can create their user as usual, but all the data about their business should be entered in a custom post type. The reason I want this is because I can easily add new fields to a custom post type and also can assign different custom taxonomies, such as neighborhood, business type, etc **Question #1: how do I restrict each user to a single post? When a user signs up, a post should be created and assigned to his username automatically.** **Question #2: I also need to offer paid membership per month or per year. How can integrate such a feature with a payment gateway, such as Paypal for example?** I don't expect an exact response for these questions, but it would be great if I could get some guideance on where to get started. Thanks!


Wordpress: How to get the current logged in author page URL?

Is there a way to display, via a PHP function, the author posts link (myblog.com/author/jason) of the current logged in user ? In fact, I would like to display, for every logged in user, a "My personnal page" link which links toward his author page. Thanks !


How to add extra field in admin comment section

I wish to add extra field in post comment section while admin is logged in. Screenshot I just add subject field in template comment form.But i couldn't store in db and retrieve it. How can i do this ? Help me !


Chat window hiding behind Twenty Eleven header

I use the Chat plugin, but I found a bug when using it with the Twenty Eleven theme in WordPress 3.2. If you scroll, the chat window goes behind the header image. ![Screenshot with chat window behind header image](http://i.stack.imgur.com/f43Vc.jpg) I used this plugin with no problems up to WordPress 3.1.4, and it works find in 3.2 - except for this problem. I guess the `z-index` is the reason, but I am not sure about that.


Multisite favicon.ico

I know it's pretty easy to add a unique favicon.ico to each site in a multisite install. But any ideas for making each sites favicon.ico appear to be in the root directory of the site? The end result would be http://example.com/favicon.ico and http://anotherexample.com/favicon.ico


How to Render Post Types in RSS Feed?

I'm using a recent theme which uses custom post formats for video, gallery, audio and more. In my RSS feed, these do not render properly. I mean the content is there but the video, gallery or audio attached to the post is not included in the RSS feed. So you have a post that talks about this great new video, but no video or link is included in the RSS feed post content. I would like to add a custom function to my theme custom-functions.php that will hook on the RSS feed generation and for these types of post formats add custom HTML so that they are included at the top of the post. I'm pretty sure we can do something with the_content_rss hook and I'm guessing that for each post I can get the post format associated, but I can't find good examples. Thanks for your help!


WPeC - Adding conditional logic to purchases

I need to add conditional logic to purchases. ie – **_item a** included for free with the purchase of **item b** or **item a** can be purchased individually for x amount_. Does anyone know if this functionality can be achieved through settings on the backend of WPeC. Thanks Cam


Highlighting current item of custom post types' sub pages, listed by wp_list_pages

The below code is for listing the custom post types itself and its children in the sidebar. The code works great but does not highlight the sub pages. In `functions.php`:               if(!function_exists('get_post_top_ancestor_id')){     /**     * Gets the id of the topmost ancestor of the current page. Returns the current     * page's id if there is no parent.     *      * @uses object $post     * @return int      */     function get_post_top_ancestor_id(){     global $post;          if($post->post_parent){         $ancestors = array_reverse(get_post_ancestors($post->ID));         return $ancestors[0];     }          return $post->ID;     }}      and adding this code to the sidebar:
     <?php     $getid=get_post_top_ancestor_id();      #echo $getid;     global $post;     $post=get_post($getid);     setup_postdata($post);     ?>     <?php     if (is_single($post->ID)) {$pg_li .="current_page_item";}     else {     $pg_li .="page_item";}     ?>
<?php the_title();?>

     <li class="<?php echo $pg_li; ?>">     <a href="<?php the_permalink(); ?>">BIOGRAPHY
     <li class="<?php echo $pg_li; ?>">     <?php     $args=array(     'post_type'=>'artists',     'child_of'=>$getid ,     'sort_column'=>'menu_order',     'hierarchical' => 1,     'title_li'=>__('')     );     wp_list_pages( $args );     wp_reset_query();     ?>

      I am not familiar with PHP, and a friend helped me to write this code. So what am I missing to highlight the current sub menu of that custom post type?


Custom Post Types Archives and Single Pages not showing custom taxonomy data

I have a custom post type called "Newsitems" that I have registered two custom taxonomies for: "newsitem types" and "news item tags" I want these two taxonomies' terms to appear almost like the typical post meta info would for categories and tags, but at the client's request they need to function separately than the default post meta. Despite almost 15 hours of working on this, I still can't get them to render. Notes:   * On the single post page, I do get the "newsitem type" ID number, but have been unable to output the actual tax term name.    * I realize you'll see some Genesis related code, as I'm working with Genesis and used the Genesis Custom Meta Box template to build this. However, my problem (I hope) has a lot less to do with Genesis functionality and moreso regular WordPress behavior. I don't feel this is a case for the Genesis support forums.   * I'm not a noob, but clearly I don't understand the WordPress loop as well as I should. My code for the archive page:               function custom_do_loop() {          // Intro Text (from page content)     echo '
';     echo '
'. get_the_title() .'
';     echo '
' . get_the_content() ;          $args = array(         'post_type' => 'newsitem', // enter your custom post type         'orderby' => 'date',         'order' => 'DESC',         'posts_per_page'=> '12',  // overrides posts per page in theme settings         'paged' => get_query_var( 'paged' ),     );          $terms = get_the_terms( $post->ID , 'newsitem-type' );          $loop = new WP_Query( $args );     if( $loop->have_posts() ):              while( $loop->have_posts() ): $loop->the_post(); global $post;              echo '
';             echo '
' . get_the_title() . '
';             echo '
' . genesis_get_custom_field( '_cmb_newsitem_subtitle' ) . '
'; //retrieve custom field             echo '
' . genesis_get_custom_field( '_cmb_newsitem_source' ) . '
'; //retrieve custom field             echo '
' . $terms->name . '
'; //retrieve custom field             echo '
' . genesis_get_custom_field( '_cmb_newsitem_author' ) . '
'; //retrieve custom field             echo '
' . genesis_get_custom_field( '_cmb_newsitem_pub_date' ) . '
'; //retrieve custom field             echo '
' . get_the_content() . '
';            echo '
';              endwhile;               genesis_posts_nav();              endif;          wp_reset_query();          // Outro Text (hard coded)     echo '
';     echo '
';      } My code for the single posts:               add_action('genesis_before_post_content', 'envision_newsitem_meta');      function envision_newsitem_meta() {      global $wp_query;           $postid = $wp_query->post->ID;      $subtitle = get_post_meta($postid, '_cmb_newsitem_subtitle' , true);      $source = get_post_meta($postid, '_cmb_newsitem_source' , true);      $cattypes = get_post_meta($postid, '_cmb_newsitem_cat_type' , true);      $author = get_post_meta($postid, '_cmb_newsitem_author' , true);      $date = get_post_meta($postid, '_cmb_newsitem_pub_date' , true);      $url = get_post_meta($postid, '_cmb_newsitem_url' , true);      $tag = get_post_meta($posid, 'post_tag' , true);           $cattypeString = implode (',' , $cattypes);           echo '
Subtitle: ' . $subtitle . '
' .       '
Source: ' . $source . '
' . '
Author: ' . $author . '
' . '
Article Type: ' . $cattypeString . '
' . '
Date Published: ' . $date . '
' . '
URL: ' . $url . '
';           wp_reset_query();      }


How to remove the images from "Uploaded to this post"?

I was wondering if there's a simple way to deselect images from uploaded to this post, but still have the images in the image library? I uploaded some images while i was editing a post and this isn't the same as uploading images with _Media > Upload_. For example, I make a post with 4 images, but overtime I don't like to use the 4 images as this particular theme auto creates a gallery from the images. When selecting insert media these images are "Uploaded to this post". How to deselect some of these images from _Uploaded to this post_?


Naming script handles right way

I was wondering is there any convention or what is the right way for naming handles in `wp_register_script()` and `wp_register_style()` functions? For example if I am developing a plugin that uses modernizer, is it better simply naming it 'modernizer' or something unique like 'my-script-modernizer'? If it is better to have unique handles and I am developing multiple plugins and I'm sure all uses same script. Should I use same handle in all plugins?


Test if page is child and has children, if so echo child pages also on grandchild pages

I am trying to show a sub-menu of child-pages only on level 2 pages (who have a parent) and if they have children. I am using the code below (made from several snippets I found), it works fine on level 1 (not showing anything as meant to be), works fine on level 2: if there are child pages they are shown in the sub-menu. My question: When i go to level 3 pages I would like the sub-menu to stay but it disappears. How can I change the code below to make it work?                   <?php              if (is_page() && $post->post_parent ) { // test to see if the page has a parent                    $page = $post->ID;                    if (is_page() ) {                 $page = $post->post_parent;               }                    $children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );                         if ($children) {                 $output = wp_list_pages( array(                     'child_of' => $post->ID, // Only pages that are children of the current page                     'depth' => 1, // Only show one level of hierarchy                     'title_li' => ''                 ) );               }                       }           echo $output;           ?>


Widget Option is Missing

My Widget Option is missing in the Dashboard area. How can i make that appear? I have downloaded this Blank Theme from Chris Coyiers site. sidebar.php               <?php     /**      * @package WordPress      * @subpackage HTML5-Reset-WordPress-Theme      * @since HTML5 Reset 2.0      */     ?>
       <?php if (!function_exists('dynamic_sidebar') && !dynamic_sidebar('Sidebar Widgets')) : else : ?>                        <?php get_search_form(); ?>
         <?php _e('Archives','html5reset'); ?>

         <?php wp_get_archives('type=monthly'); ?>

         <?php _e('Meta','html5reset'); ?>

         <?php wp_register(); ?>
           <?php wp_loginout(); ?>

<a href="http://wordpress.org/" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.','html5reset'); ?>">           <?php _e('WordPress','html5reset'); ?>
         <?php wp_meta(); ?>

         <?php _e('Subscribe','html5reset'); ?>

<a href="<?php bloginfo('rss2_url'); ?>">           <?php _e('Entries (RSS)','html5reset'); ?>

<a href="<?php bloginfo('comments_rss2_url'); ?>">           <?php _e('Comments (RSS)','html5reset'); ?>

       <?php endif; ?>
      the widget code in my functions.php               // Widgets     if ( !function_exists('register_sidebar' )) {         function html5reset_widgets_init() {             register_sidebar( array(                 'name'          => __( 'Sidebar Widgets', 'html5reset' ),                 'id'            => 'sidebar-primary',                 'before_widget' => '',                 'after_widget'  => '',                 'before_title'  => '
',                 'after_title'   => '
',             ) );         }         add_action( 'widgets_init', 'html5reset_widgets_init' );     }


wp_enqueue_script order - external vs inline js

I have a few scripts loading with my theme:                   // loading script.js         <script type="text/javascript" src="script.js"></script>               // doing something using script.js         <script type="text/javascript">             script-var: <?php echo get_option('script1-var');?>         </script>      They work well, but when I do `wp_enqueue_script` instead of `<script src="">` the script is loading AFTER in-line js content, so:                    // enqueuing script.js          wp_enqueue_script('script-js', get_template_directory_uri() ."/scripts/script.js");                      // doing something using script.js          <script type="text/javascript">              script-var: <?php echo get_option('script1-var');?>          </script>      Gives:                 <script type="text/javascript">             script-var: <?php echo get_option('script1-var');?>       </script>             <!-- EVERYTHING ABOVE THIS LINE IS USELESS SINCE THE SCRIPT LOADS AFTER, NOT BEFORE, IT -->       <script type='text/javascript' src='http://address/scripts/script.js?ver=3.2.1'></script>      How to avoid that? I know I could put my inline scripts into different files and enqueue them as well, but this is absolutely pointless since there is a lot of PHP functions in them.


Fix My Custom Function: Remove Automatic <p>

I want to remove the automatic paragraph tag that goes around my excerpts, which are being outputted by a custom function. I'd really appreciate if you could tell me what to add to my code. I'm using this custom function for excerpts:                 // Default length (by WordPress)       public static $length = 25;            // So you can call: my_excerpt('short');       public static $types = array(           'short' => 5,           'regular' => 25,           'long' => 100         );            public static function length($new_length = 55) {         Excerpt::$length = $new_length;         add_filter('excerpt_length', 'Excerpt::new_length');         Excerpt::output();       }       public static function new_length() {         if( isset(Excerpt::$types[Excerpt::$length]) )           return Excerpt::$types[Excerpt::$length];         else           return Excerpt::$length;       }       public static function output() {         the_excerpt();       }     }          // An alias to the class     function my_excerpt($length = 25) {       Excerpt::length($length);     }      and calling it using               <?php my_excerpt('short'); ?>


Replacing raw database query to WP_Query

I have a plugin which displayed the top most voted posts in a list with the vote count. **The code is placed here:** https://gist.github.com/hchouhan/6727356                       function dot_most_recommended_posts($numberOf, $before, $after, $show_count, $post_type="showcase" ) {                 global $wpdb;                      $request = "SELECT * FROM $wpdb->posts, $wpdb->postmeta";                 $request .= " WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id";                 $request .= " AND post_status='publish' AND post_type='$post_type' AND meta_key='_recommended'";                 $request .= " ORDER BY $wpdb->postmeta.meta_value+0 DESC LIMIT $numberOf";                 $posts = $wpdb->get_results($request);                               foreach ($posts as $item) {                         $post_title = stripslashes($item->post_title);                         $permalink = get_permalink($item->ID);                         $post_count = $item->meta_value;                         echo $before.'' . $post_title . '';                         echo $show_count == '1' ? ' ('.$post_count.')' : '';                         echo $after;                     }                  }                  $options = get_option("dot_most_recommended_posts");             if (!is_array( $options ))             {                 $options = array(                     'title' => 'Most recommended posts',                     'number' => '10',                     'show_count' => '1',                 );             }                  $title = $options['title'];             $numberOf = $options['number'];             $show_count = $options['show_count'];                  echo '
';                 dot_most_recommended_posts($numberOf, '
', '
', $show_count);             echo '
';      The above code is abstracted from this plugin http://wordpress.org/plugins/i-recommend-this/. Now the data displayed using above code is accurate. Based on the number of votes received a list of displayed. I want to know the best way to avoid using raw queries and using WP_Query instead. I tried with the below code but it seems to display some only those posts which have a vote count of 9. **Updated code with WP_Query** - https://gist.github.com/hchouhan/6727363               <?php     $query_top_10_showcase = new WP_Query(         array(             'post_type' => array( 'showcase' ),             'orderby' => 'meta_value',             'meta_key' => '_recommended',             'paged' => $paged         )     );          // Run the loop as normal     if ( $query_top_10_showcase->have_posts() ) :              while ( $query_top_10_showcase->have_posts() ) : $query_top_10_showcase->the_post();                  $url = get_post_meta( $post->ID, '_dot_showcase_url', true );             $recommended = get_post_meta( $post->ID, '_recommended', true );     ?>
         <?php the_title() ?> - <?php echo $recommended; ?>
          <?php     endwhile;          else:          // no posts found          endif;     wp_reset_postdata();     ?>


In admin panel, use a form to create a post?

I'm unfortunately working with rather thick headed clients who insist they need a "form" to fill out instead of the normal WP WYSIWYG Post editor. I tried to tell them that they could hide the parts that were confusing them, but apparently that won't work. Is there any way to create a simple 4 line form, in the admin panel, that creates a post with the content from those 4 lines? Any existing plugins I could use to do this? I've already tried a custom post type but the "large box" for adding content is apparently too hard to grasp because they keep wanting "lines" in a form. I just need the output to be consistent. A simple post, something like: Item: _whatever they type_ Amount: _whatever they type_ Model: _whatever they type_ Description: _whatever they type_ They can't handle writing the word "Item" themselves, and want a form to do it. Essentially, that's what I'm dealing with. Anyone have any ideas?


Buddypress - Adding Tags in Profile

There exist a way to add tags like: skills, favorite books, etc. to the profile? Thanks in advance.


How to override .htaccess with new rules without ftp or edit it manual

I want script will add new rules to current `.htaccess` and user no need to ftp or edit it manually. Example, I use timthumb for resize image on my theme and want rewrite the URL and current `.htaccess` will be something like this.               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^images/thumb/(.*) timthumb.php?filename=$1     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>      Question How to add the new rule to the `.htacces` on my theme option. Enable Mod rewrite for Timthumb? : [Yes] [No] If click [Yes] `RewriteRule ^images/thumb/(.*) timthumb.php?filename=$1` will automatic added to current `.htaccess` Let me know


removing <li> tags from wp_list_pages() using PHP

as the title states, I am trying to remove the `<li></li>` tags from the list that gets generated with `wp_list_pages()`. My thinking is to somehow run a for/foreach loop through the menu items and remove the `<li></li>` tags using `str_replace()`, but first I would need to parse the returned list into an array or something to traverse through the list items... Any ideas on how I can accomplish that? or maybe a better way of going about it? Thanx in advance!


Multiple Drop-Down custom taxonomies search

I know this question is asked many times on stack-exchange, but I am with something new I want to have three Drop Down Boxes and a search button, the drop-down boxes will contain terms of 3 custom taxonomies, when I will select three values in it and hit search, I will get results which will be having these three terms in that post It sounds weird but this is really a helpful search for a website I am having a code(which I found on some website) which is working, but just for categories and only gives one drop down box, I want to make it for custom taxonomy which will be having 3 drop-down boxes, here is my code:               function wp_search_form($form) {     $form = '<form method="get" id="searchform" action="' . get_option('home') . '/" >
' . __('Search for:') . '     <input type="text" value="' . attribute_escape(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />     <input type="submit" id="searchsubmit" value="'.attribute_escape(__('Search')).'" />
     '.wp_dropdown_categories('show_option_all=All Categories&hide_empty=0&echo=0&selected='.intval($_GET['cat']).'').'
     </form>';     return $form;     }      After writing this I have to just echo it, `<?php echo wp_search_form(''); ?>` I edited according to my view, I just changed a single line to display the drop-down of custom taxonomy but when hitting on search it gives me No results found, Code I changed is this `'.wp_dropdown_categories('taxonomy=location&hide_empty=0&echo=0&selected='.intval($_GET['cat']).'').'` Location is my custom taxonomy name


Highlight posts that belong to current sub category

I'm trying to highlight list items that belong to the same category as that of the current category page. For an example, I have a category called _food_ , with the subcategories: _breakfast_ , _lunch_ and _dinner_. If you navigate to the sub-category _lunch_ – in a loop that calls all posts regardless of category – I want all list items that are associated to _lunch_ , to be highlighted. Firstly I use `get_category` and `->term_id` to define the ID of the category we're currently on. Secondly, in the loop, I use `get_the_category` and `[0]->cat_ID` to retrieve the ID (but only the first in the array) of each individual list item. Lastly, I use `in_array` to see if there is a match between the two arguments, and if so echo a value. My problems lies in the `$categories[0]->cat_ID`. If a list item is associated to more than one category, retrieving only the first one in the array is no good. How do I create an argument that will output all category IDs associated with a list item in a loop?               <?php     $thisTrueCat = get_category( get_query_var( 'cat' ) );      ?>               <!-- loop start -->          <?php      $categories = get_the_category();      $categories_id = $categories[0]->cat_ID;                 ?>               <?php if( in_array( $thisTrueCat->term_id, array($categories_id) ) ) { echo 'cat-hi'; }?>


retrieve the oldest post id

I'm trying to get the ID of the oldest post with the `post_type = job_listing` and `post_status = publish`. I'm using the code below but it does not work. Could anyone please help me `$oldestID = mysql_query("select id from wp_posts where post_type = 'job_listing' and post_status = 'publish' order by post_date ASC");` Thanks!


next_posts_link not working for loop called with ajax

On my homepage I display a loop of posts that I allow to be replaced by ajax search results and other custom loops. Those results are returned in a template with a `custom wp_query`. The issue is `next_posts_link` isn't returning the correct link for page 2 for the search loop. What I get is a link to `http://mysite.com/wp-admin/admin-ajax.php?paged=2`. Below is the entire setup I use to return the results. What do I need to change to get the right pagination? //script               jQuery(document).ready(function($){     $('#searchsubmit').click(function(e){         $('#boxes').empty();         e.preventDefault();         var search_val=$("#s").val();         var $panel = $(this).closest(".panel-container").find(".panel");         $.post(             WPaAjax.ajaxurl,             {                 action : 'wpa56343_search',                 search_val : search_val             },             function( response ) {                 $('#boxes').append( response ).masonry( 'reload' );                 $panel.hide("slow");                 $('.trigger').removeClass("active");             }         );       });          });      //function to pass query params               add_action('wp_ajax_wpa56343_search', 'wpa56343_search');     function wpa56343_search(){      global $wp_query;      $search = $_POST['search_val'];      $args = array(         's' => $search,         'posts_per_page' => 10      );      $wp_query = new WP_Query( $args );           get_template_part( 'search-results' );          exit;     }      //Custom search query search-results.php               <?php       while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>             <------content----->          <?php endwhile; ?>          <?php if ( $wp_query->max_num_pages > 1 ) : ?>          <div class="infinitescroll">       <?php next_posts_link( __( 'Load more posts', $wp_query->max_num_pages ) ); ?>     </div>          <script type="text/javascript">      // Infinite Scroll      var href = 'first';      $(document).ready(function() {     $('#boxes').infinitescroll({         navSelector : '.infinitescroll',         nextSelector : '.infinitescroll a',         itemSelector : '#boxes .box',         loadingImg : '<?php echo get_bloginfo('stylesheet_directory') ?>/images/loading.gif',         loadingText : 'Loading...',         donetext : 'No more pages to load.',         debug : false     }, function(arrayOfNewElems) {         $('#boxes').masonry('appended', $(arrayOfNewElems));         if (href != $('.infinitescroll a').attr('href'))         {             href = $('.infinitescroll a').attr('href');         }     });       });      </script>      <?php endif; ?>


Limit Media Library to Given Folder

I have made a plugin that uses the Media Library to allow users to upload files to a specific directory - using the `upload_dir` filter. I would like to know if there is a way (i.e. a filter) I can use to limit the media library to displaying only files contained within my custom folder? If possible, I want the user to be able to choose only files that have been uploaded to the custom folder when interacting with the Media Library instantiated by my plugin.


How do I create a featured post within a custom post type?

Do I do this exactly the same way as I would with normal posts? I use a $featured_cat global variable and pull that out. Should I do the same here? Or should I use an associated custom taxonomy? Or perhaps I am over-thinking it? Would there really be a benefit with taxonomies? _What's the right approach here, guys?_


How can i move search results onto a specific page?

I was wondering if it is possible to have the wordpress search results displayed on a different page? At the moment they are displayed on `http://www.mysite.com/?s=searchterm` but I would like them displayed on my **search-results** template page, so `http://www.mysite.com/search/?s=searchterm`. Is this possible? Any help greatly appreciated, S.


How to make the Awake or Unite theme to use the featured image as post image?

How can I make the Awake or Unite WP theme to use the post image from featured image instead of manually entering the post image URL in each post ?


Conditional statements using category and Tags

I want to use conditional statements in WordPress. How can I get the current category and tag outside of The Loop? I tried this but it did not work for me.               <?php     $category = get_the_category();      echo $category[0]->cat_name;     ?>


Cannot upload anything via wordpress

I've just recently installed a local installation of Wordpress 3.5.2 on my laptop, running ubuntu 12.10. I installed following the guide from here. So far, everything else is working, except I cannot upload any media files via `Media Library -> Add New`. The file seems to upload as the progress bar climbs from 0 to 100%. However after that, wordpress cannot display the thumbnail or the image anywhere. After looking at the uploads folder, it's empty. So I figured it's a permissions problem, after following directions from the support forums, no dice. Wordpress is installed to `/usr/share/wordpress`. The uploads folder is by default in `/var/lib/wordpress/wp-content/uploads`. I've got `755` for `wp- content/` and `777` for `uploads`. Folders are owned by `www-data`. I can't see any errors, the files merely won't appear anywhere. I can manually copy files to the `uploads/` folder as any user because of the permissions and I can view `http://localhost/wordpress/wp-content/uploads/file.jpg` with a web browser. I have no themes or additional plugins installed. I've added `define('WP_DEBUG', true);` to my config-file but no errors are displayed. EDIT: Here's a line from `/var/log/apache2/error.log` if it's of any help.               [Thu Jun 27 22:35:02 2013] [error] [client 127.0.0.1] PHP Warning:  Creating default object from empty value in /usr/share/wordpress/wp-admin/includes/update.php on line 92, referer: http://localhost/wordpress/wp-admin/upload.php      EDIT2: Here's are example directory listings with permissions               msvalkon@Lunkwill:/var/www$ ll     total 20     drwxr-xr-x  2 www-data www-data 4096 Jun 27 12:21 ./     drwxr-xr-x 15 root     root     4096 Jun  7 10:06 ../     -rw-------  1 www-data www-data   46 Jun 27 12:21 .bash_history     -rw-r--r--  1 root     root      200 Jun 27 11:46 index.php     -rw-r--r--  1 root     root       11 Dec 14  2012 .profile     lrwxrwxrwx  1 msvalkon www-data   21 Jun 20 11:45 wordpress -> /usr/share/wordpress//          msvalkon@Lunkwill:/usr/share/wordpress$ ll     total 164     drwxr-xr-x   5 msvalkon www-data  4096 Jun 27 13:41 ./     drwxr-xr-x 349 root     root     12288 Jun 20 11:51 ../     lrwxrwxrwx   1 msvalkon www-data    23 Sep 13  2012 .htaccess ->  /etc/wordpress/htaccess     -rw-r--r--   1 msvalkon www-data   395 Jan  8  2012 index.php     -rw-r--r--   1 msvalkon www-data  9202 Sep 13  2012 readme.html     -rw-r--r--   1 msvalkon www-data  4264 Dec 14  2011 wp-activate.php     drwxr-xr-x   9 msvalkon www-data  4096 Jun 27 12:48 wp-admin/     --- SNIP ---     drwxr-xr-x   5 msvalkon www-data  4096 Jun 27 12:48 wp-content/               msvalkon@Lunkwill:/var/lib/wordpress$ ll wp-content/     total 28     drwxrwxrwx 7 msvalkon www-data 4096 Jun 27 12:58 ./     drwxrwxrwx 3 msvalkon www-data 4096 Jun  5 18:17 ../     drwxrwxrwx 2 msvalkon www-data 4096 Sep 13  2012 blogs.dir/     drwxrwxrwx 2 msvalkon www-data 4096 Jun 27 12:48 languages/     drwxrwxrwx 2 msvalkon www-data 4096 Jun 27 12:48 plugins/     drwxrwxrwx 2 msvalkon www-data 4096 Jun 27 12:48 themes/     drwxrwxrwx 2 msvalkon www-data 4096 Jun 27 13:17 uploads/


Text not translaet in user specific language in Wordpress 3.5.2 QTranslate Plugin, how do i solve it?

I am using WordPress 3.5.2 for multilingual site using QTranslate Plugin. I have created a website whit IN STYLE theme of "elegant theme" How do I translate the rotation text on the home page? I don't use pages, i select the "Feature Category from drop down menu and post from the category are to the slide. I see the ET Setting and i add text both the title and Description. This Values Appear on home page in place of the pagès normal title. My site is in 3 languages, Russian, English and Chinees. how can I translate? Now I have the same title in Russian, English and Chinees version site, I need to have different titles in three languages. is it possible? how can I do? ![enter image description here](http://i.stack.imgur.com/k0nl4.png)


Advanced custom fields sort repeater by date

I have a repeater field on a page template to show small snippets with a link that needs to be sorted by date (recent 1st). I'm using the current code, but there isn't any sorting in place.                       <?php if(get_field('in_the_news')): ?>                 <?php while(has_sub_field('in_the_news')): ?>                             <article id="post-<?php the_ID(); ?>" class="open post type-post  format-standard hentry" role="article">
<a href="<?php the_sub_field('link'); ?>" rel="bookmark" target="_blank"><?php the_sub_field('title'); ?>

<?php the_sub_field('publisher'); ?> -                                      <?php                                      //the_sub_field('published_date');                                     /*if(get_sub_field('published_date'))                                     {                                         $date = DateTime::createFromFormat('Ymd', get_sub_field('published_date'));                                         echo 'Published: ';                                         echo $date->format('F j, Y');                                          }*/                                     ?>     <?php       //NO PHP 5.3 support. this instead.     $date = get_sub_field('published_date');     // $date = 19881123 (23/11/1988)          // extract Y,M,D     $y = substr($date, 0, 4);     $m = substr($date, 4, 2);     $d = substr($date, 6, 2);          // create UNIX     $time = strtotime("{$d}-{$m}-{$y}");          // format date (23/11/1988)     echo date('d/m/Y', $time);     ?>


Active class to current link

How do I add the active class to the current link that the user is viewing? I have a mixture of pages and custom post types in my main nav menu and I know that wordpress has `.current_page_item` that can be used but when I tried that nothing happened. I'm slightly confused about how to implement it. Currently the menus for the site are being pulled in using:               <?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>      AND: `<?php wp_nav_menu( array('menu' => 'Mobile Menu' )); ?>` - for mobile state.


wp_count_posts on all post types?

I have 5 different custom post types, Is there any way to count all the publish posts regardless of post_type through any inbuilt functions Like               wp_count_posts(array('post','books','video'))      any ideas


How to get particular data from wp_list_comments outside the loop?

I need some help,very much new to wordpress. I need only comment title and comment date from `wp_list_comments` function in my post, calling from outside loop, after declared $postid as global variable. Now I am getting all the information about the comment such as author, date,title,comment etc. So how can I get a particular detail as above?


Trying to access custom post redirects to home page

I just started using WordPress and it seems I need more practice and advice to make it behave the way I want it to. I inherited an already working site from another guy. Now I have to actually add new functionality to it, but I got stuck. I am trying to add a custom post type and make posts of that type actually show. For that, I mostly copy-pasted code from other places in the site. The code I use to create a new post category is the following:                 function theme_setup() {              //Other code that creates other post categories                   //My new stuff         register_post_type(             'contest',             array(                 'label' => 'Concursuri',                 'public' => true,                 'menu_position' => 5,/*below Posts*/                 'capability_type' => 'post',                 'supports' => array('title', 'editor', 'thumbnail', 'custom-fields'),                 'taxonomies' => array('contests'),                 'hierarchical' => true,                 'query_var' => 'contest',                 'rewrite' => array('slug' => 'contest/%categorie%', 'with_front' => false),                 'feeds' => true, 'pages' => true,             )         );         register_taxonomy(             'contests',             'contest',             array(                 'label' => 'Categorii Concursuri',                 'public' => true,                 'hierarchical' => true,                 'rewrite' => array('slug' => 'contest', 'with_front' => false),             )         );              //Then some other stuff, and at the end:              //flush_rewrite_rules(false); //Removed and using visit to permalink instead     }     add_action('init', 'theme_setup');                    add_filter('post_type_link', 'events_permalink_structure', 10, 3);     function events_permalink_structure($post_link, $post, $leavename) {         $arr = array(             //Some elements here, then mine             'contest' => 'contests',             //Some more elements here         );         foreach ($arr as $post_type => $tax) {             if ($post->post_type == $post_type) {                 $terms = wp_get_object_terms($post->ID, $tax);                 if (!empty($terms)) // link of the form http://www.site.com/<taxonomie>/%categorie%/<nume>                     $post_link = str_replace('%categorie%', $terms[0]->slug, $post_link);                 else // link of the form http://www.site.com/<taxonomie>/%material%                     $post_link = str_replace('/%categorie%', "", $post_link);             }         }         return $post_link;     }          function add_rewrite_rules($rules) {         $newrules = array();         //Some other similar rules, then my new rule         $newrules['^contest/(\d+)/([^/]+)/?'] = 'index.php?post_type=contest&contest=$matches[2]';         return $newrules + $rules;     }     add_filter('rewrite_rules_array', 'add_rewrite_rules');      Now, after adding this code to functions.php, I get a new link in the admin page, which allows me to add new posts of this type. I can add them (no problem), I can preview them by accessing a link like ' **?post_type=contest &p=2873&preview=true**', I can even query them after posting with code like this:                           <?php                 $query = new WP_Query(array(                     'posts_per_page' => 5,                     'post_type' => 'contest',                     'orderby' => 'date',                     'order' => 'DESC'                 ));                 if ($query->found_posts) { ?>                      ...display a list of posts in some way...                      <?php } wp_reset_query(); wp_reset_postdata(); ?>      However, when I try to actually access the post, it redirects me to the homepage. This happens from the links I created (they look like this: ' **/contest/#post-2873** ' - which is similar to other links created for other custom posts), from the edit page from WordPress (which looks like this: ' **/contest/test/** '), or if I manually enter the url like: ' **?post_type=contest &p=2873**'. Trying to access ' **/contest/** ' also redirects me to my homepage. I searched for similar problems, which suggest I should visit the permalinks page before trying again. I did that, and also pressed 'Save Changes' in there, but it still doesn't work. I also tried other stuff, like not adding a rewrite rule for this, but the results are always the same. I feel like I'm missing something simple here, but I don't know what. Can you please help me solve this one? I don't necessarily want to play with php, so if there is an UI for doing what I'm trying to do, that would also be great. Thanks! Edit: it's been a couple of days, still no results. Tried other stuff, such as editing .htaccess, making a custom type with a different name, not adding a taxonomy, and so on. No results yet. Help!


Separate DB by yearly archive of Wordpress

I have large DB of blog post I already export it by year and wanted to make archive by year doing it on subdomain, like `2012.mysite.com` I stack looking for solution on internet, I wondering if their are someone done this before? and can advise me a good solution, all I wanted is to separate to another db by year for archiving. I have a knowledge in PHP and MYSQL.


meta_query compare not doing what I want it to do

I'm trying to run a query that only shows posts if it's meta value has a date string that is LESS than the current date's string. An example is below;               <?php         $current = date('Ymd'); // Eg: today would be 20131011         $date = get_post_meta($post->ID, 'event_date', true); // (Eg; 19690816)         $args (             'post_type' => 'event',             'posts_per_page' => -1,             'meta_query' => array(                 'key'     => 'event_date',                 'value'   => $current,                 'compare' => '<',                 'type' => 'numeric'             )          );     ?>      But it doesn't seem to be working. The `$date` value is defined by a meta box and returns a string in the same format as the `$current` value above so it's basically just comparing 2 numeric values against each other. Anyone have any ideas? I've tried it the opposite way, using the greater than symbol and that doesn't want to work either. I've quadruple checked the post type name, the values, etc and all are correct.


Can wp_list_comments output into variable?

Is there any way how to output `wp_list_comments()` into a variable? Something like `$output = wp_list_comments(array('reverse_top_level' => false ), $comments);` I am writing a plugin and it would be handy to use standard WordPress function instead of writing my own.


Is there a way to add a link with add_post_meta?

I am trying to put a link in the post meta with this code               $authorEmail = get_the_author_meta('user_email');     $authorEmailLink = ''.$authorEmail.'';     add_post_meta($post->ID,'Author Email',$authorEmailLink,true);      The `$authorEmailLink` is a valid link because I can echo it to the page. However, when I put it on the page, it just displays the plain text email. Is there something I am not doing or a way to get around this?


Get top level page parent title

How do I get the page title of the upper most parent page of the page the visitor is currently on? Let me describe: I have this page structure:   * Example Title 1      * Example Title 1-1        * Example Title 1-1-1       * Example Title 1-1-2     * Example Title 1-2   * Example Title 2   * Example Title 3   * Example Title 4 Here is what I want to return:   * User is on `Example Title 1` return `Example Title 1`   * User is on `Example Title 1-1` return `Example Title 1`   * User is on `Example Title 1-1-1` return `Example Title 1`   * User is on `Example Title 2` return `Example Title 2` Normally what I would do is check `$post->parent` and if `0` then return page title else return title of page above. Problem is that $post->parent will only go back one level. I need to use some sort of recursive function that keeps going back until `$post->parent == 0`. Now I can manage this myself but the only way I could think of doing it would be to use get_post() each time but imagine I'm 8 layers deep (we need to go deeper). That would involve loading 8 pages to finally get to the top level. Anyone have a better way to do this?


How to rename wordpress Widget

I want to rename "Widget" to something else Like "Block" or something else. please help me. **EDIT** Per the user's comment below, she wants to change `class="widget"` to `class="block"` (or any arbitrary class name) in the rendered, sidebar Widget.


The hook for the AJAX Add to Cart button?

Anyone here ever had the need to add the AJAX add to cart button (the one located on product archives) on a custom query post output? Do you mind sharing the hook? I can't seem to find the correct one.


the_content not working on one of two Multisite sites

I have a multisite with two subsites (sub-domain setup) both sites have the same theme, same plugins but the first one is in Hebrew and the Second in English. On certain templates (not all) in the English site "the_content()" doesn't work (it works just fine on the Hebrew site). This is on a custom-post-type, but not all CPT's suffer from the same problem, it seems to be rather random as to which post-type doesn't work (but consistent as to the fact that they continue not to work). I checked everything, the loop seems to be OK (the_excerpt() and the_title() work just fine), but specifically the_content() isn't working (and get_the_content()), the only way that displays the content is $post->post_content. I turned all the plugins off and checked (no effect) So my workaround for now is               echo apply_filters('the_content', $post->post_content);       which should supposedly sanitize it correctly (this works). again, same template on the first site works just fine with the_content() (once I applied the workaround, it doesn't use it of course anymore. I am using roots theme http://www.rootstheme.com/ Can anyone help? What am I missing?


Strategies for coping with hyperagressive spambots?

A couple of my sites are getting slammed by a hyperagressive distributed spambot. It's just pure link spam. It all comes from one user name, but from a variety of IPs. Akismet is catching the spam, so my sites aren't defaced. But it's affecting performance. What is best practice, if any, for mitigating this? **Edit** There are about 400 of these in 24 hours. They're coming from a rotating bunch of IP addresses. There are between five and ten hits from each address.   * 60.173.9.*, 60.173.10.* and 60.173.11.*   * 112.123.168.*  Both of these address ranges are assigned, according to apnic.net, to ISPs in China. (I'm guessing malware-infested cybercafes, but who knows?) Again, is there a best practice to deal with this junk? Or just let akismet do it?


Custom post doesn't show featured image

I'm probably missing something but somehow my custom post type doesn't display the featured image input field when creating the post. I have the featured image already registered in my functions.php and it does show up at pages and regular posts. But not at my custom post type. This is the code that I've used to enable the featured images               add_theme_support('post-thumbnails');      And the code to register the custom post type               add_action( 'init', 'create_post_type' );     function create_post_type() {     register_post_type( 'vacature',         array( 'labels' => array(                 'name' => __( 'Vacatures' ),                 'singular_name' => __( 'Vacature' ),             ),         'public' => true,         'has_archive' => true,         'supports' => array( 'title', 'editor', 'thumbnail', 'comments' ),         )         );     }


WordPress plugin installation

I am using the simple `add_filter` function to output the content.               add_filter('the_content', 'my_name');          function my_name( $content ){       // code       return $content;     }      When I activate the plug-in output of the function `my_name` is shown in all pages. How can I restrict the output to only one page?


Differences when using the the_time and the_date functions

I have some doubts about how work the WordPress **the_date()** functions definied into **general-template.php** In a page I show the posts archive using this code snippet into a loop:               <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                     <a href="<?php the_permalink(); ?>"                         title="<?php printf(__('Permalink to %s', 'your-theme'), the_title_attribute('echo=0')); ?>"                        rel="bookmark"><?php the_date("d/m/Y");  echo " - "; the_title(); ?>

        The problem is that for some posts the **the_date()** function give me the date of the post and for other posts not. I attach a screnshot of what I obtain: ![enter image description here](http://i.stack.imgur.com/drFce.png) As you can see some posts are shown as something as: **DATE - POST TITLE** but some other posts are shown as **POST TITLE** without the date before the post title. This seems to me very strange because all the posts have a publishing date. So I tried to use the debugger and see what happens when the **the_date()** function have this code:               function the_date( $d = '', $before = '', $after = '', $echo = true ) {         global $currentday, $previousday;              if ( $currentday != $previousday ) {             $the_date = $before . get_the_date( $d ) . $after;             $previousday = $currentday;                  /**              * Filter the date a post was published for display.              *              * @since 0.71              *              * @param string $the_date The formatted date string.              * @param string $d        PHP date format. Defaults to 'date_format' option              *                         if not specified.              * @param string $before   HTML output before the date.              * @param string $after    HTML output after the date.              */             $the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );                  if ( $echo )                 echo $the_date;             else                 return $the_date;         }              return null;     }      and it contains this conditional statment:               if ( $currentday != $previousday ) {      and I see that for some posts the value of **$currentday** and of **$previousday** is the same so the function **return null** Also reading the funcion documentation I can find:               /**      * Display or Retrieve the date the current post was written (once per date)      *      * Will only output the date if the current post's date is different from the      * previous one output.      *      * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the      * function is called several times for each post.      *      * HTML output can be filtered with 'the_date'.      * Date string output can be filtered with 'get_the_date'.      So what exactly represents thes 2 variable? and why if they are the same the date is not returned? How can I fix this problem and show the date?


List subpages in order

This may be a very basic question, but I'm a beginner. How can I list my subpages in alphabetical order? I have 14 subpages total. This is what I was told to use but my page is a mess.               [subpages page=27 items=12 order=alphabetical desc]


Moving from one test to multiple final environments

I'm working on a WordPress website in the following test environment URL:               www.example.com/wordpress.      Once the site is complete and everything is tested, I want to deploy to three live environments in different languages:   * `www.example.com/nl`   * `www.example.com/fr`   * `www.example.com/en` My concern: what if I just copy everything from `/wordpress` to `/en`? I know all links will be broken, and also know how to fix this with this tool. But what if I, let's say, copy everything from `/wordpress` to `/fr` and `/nl` and delete all the pages in order to rebuild them in the correct language? What about the page id's, and the database? Is this a "safe" way to do such a thing, or are there easier methods?


Displaying links to all posts of the same category on the post page

I want to display the links to all posts of the same category of the current post on that page. I wrote the following code in the single.php file.               <?php $categories_of_this_post = get_the_category(); ?>     <?php $fist_category_id = $categories_of_this_post['0']->term_id; ?>     <?php $this_post_ID = get_the_ID(); ?>

         <?php query_posts( array ( 'cat' => $fist_category_id, 'orderby' => 'date', 'order' => 'ASC' ) ); ?>         <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                 <?php if (get_the_ID() != $this_post_ID) : ?>                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?>                 <?php else : ?>                 <?php the_title(); ?>                 <?php endif; ?>
         <?php endwhile; else: ?>
<?php _e('Sorry, no articles written under this category.'); ?>
         <?php endif; ?>

      But this code returns all the posts found on the WordPress website. Where it goes wrong?


Get meta field value of all catgories

I'm setting a meta field for the category and getting the meta value of each field like this:               $cat_meta = get_option( "meta_field_$cat1" );     if (isset($cat_meta['color'])){         $cat1_color = $cat_meta['color'];     }      Can I get the non empty meta field value of all categories using a loop?


How to get both image attachment ID and url

I am using advanced custom fields repeater-field to get the image url like this:               <?php the_sub_field('billede'); ?>      But I also want to get the attachment ID for the image, to be used for something else. Is this possible? :)


How to turn this .htaccess rule into a dynamic rule with add_rewrite_rule, et al?

In .htaccess, I have this:               RewriteRule ^land/(.*) /?land=1&exper=$1 [QSA,L]      which makes sth like this: domain.com/land/exper1 fill in the $_GET with $_GET['land'] = 1 and $_GET['exper'] = exper1 Great. I want to take this out of .htaccess and add the rule dynamically, that is, look for other querystring values like 'ocean' instead of 'land'. I want the values to be filled into $_GET or some other var where I can evaluate them. I cant figure out if add_rewrite_rule is sposed to actually overwrite my .htaccess, but all the things i've tried, flush_rewrite_rules(true), etc arent doing it.


Tags meta box don't show when creating a new post type

After creating new custom post type with `register_post_type()` function, I don't see the Tags meta box when adding a page of new post type. It seems that tags metabox should be added manually.   If so, how can I add it?


remove all custom post created

i will automatically create a lot of post with the wp_insert_post function               <?php wp_insert_post( $post, $wp_error ); ?>       all those custom post type will be call "house" and then after some testing, i what all those post and the revision to be deleted, to clear and clean the DB... so how i do that ? i do all my request with $wpdb what is the query to delete/remove all post_type = house and there revision ?


new WP_Query all post in a category inside the loop

Im trying to get a list of post in a category with this:               $category = get_the_category();          $args = array(          'post_type'           => array('post', 'entrevista'),         'cat'                 => $category[0]->term_id,         'post__not_in'        => array(get_the_ID()),         'ignore_sticky_posts' => 1,         'posts_per_page'      => -1         );          $queryScience = new WP_Query( $args );          unset($args);     ?>          <?php if ( $queryScience->have_posts() ) : while ( $queryScience->have_posts() ) : ?>         <option value="<?php echo get_permalink($queryScience->post->ID); ?>"><?php echo ucwords(get_the_date('M Y', $queryScience->post->ID)); ?></option>     <?php endwhile; endif; wp_reset_query(); wp_reset_postdata(); ?>      I think it goes infinity loop because shows more than 40.000 results. What am I doing wrong?


How to separate HTML and Wordpress files

I want to separate the HTML and PHP code so that the HTML guys can easily work on their files without disturbing the PHP code, but couldn't find any proper solution or Start point to begin. Please help me out. My assumptions: I will create a desired array and pass it to the view of HTML where I will loop through the HTML elements BUT HOW TO DO IT.


Does an article (post) id ever change?

So I'm working on a plugin for wordpress, and a novice at it as well. I need to use the ID of a wordpress post, or blog article rather, as a unique reference id, or lets say in database terms, a Unique or Primary key. Does the ID ever change on a blog? ## Extra background info..: I'm using this function to get the id of a unique post:               the_ID();      Also, the URL of a blog post on my test site has a parameter with a number (ID number?):               ?p=87      But I've seen blogs where the title is included in the URL instead of the parameter p=87. When I print out the function **the_ID();** , it returns the parameter number 87. Can I be certain that it doesn't change and use it on external sites for linking purposes?


When to use wp_schedule_single_event for async / non-blocking processes?

I have noticed this pattern in some plugins lately:               <?php     function MY_CRON(){       wp_schedule_single_event(time(), 'MY_ACTION');     }     add_action('save_post', 'MY_CRON');          function MY_FUNCTION(){       // YOUR CODE HERE     }     add_action('MY_ACTION', 'MY_FUNCTION');      It will avoid running complex functions on hooks that you want to be snappy. It could be 'save_post', a call via AJAX or like in my case a new order in Woocommerce. It's outlined in more detail in these articles:   1. Asynchronous functions in Wordpress   2. Use WP Cron to Trigger Asynchronous Background Tasks in WordPress on Post Save or Update **I was hoping to get some opinions from other developers about this pattern.** My problem with this approach is that a) if you have low traffic on your site it may never run due to the way how WP Cron works. And b) if it's really complex stuff you are doing that takes, say, 10 seconds to complete, won't that delay the page rendering the next time WP Cron is triggered by a page load? So my admin actions are really snappy and I close the browser but the next user who is visiting the site is getting an additional 10 seconds loading time? So all I'm doing is passing on the waiting time to somebody else? In some cases this could even be myself. So my conclusion was to disable WP Cron and schedule a call to wp- cron.php?doing_cron via crontab. But won't that block my site while it's running as well?


map_meta_cap woes

I have created a custom post type and want it to behave like a page. Certain roles need to have access to it and not to posts or pages. So I created my custom post type with a capability-type and capabilities like so:               function add_team_page_post_type($name, $args= array()) {     add_action('init', function() use($name, $args) {             $args = array(                 'labels' => team_page_post_type_labels( 'Team Page' ),                 'public' => true,                 'publicly_queryable' => true,                 'show_ui' => true,                 'show_in_menu' => true,                 'query_var' => true,                 'rewrite' => true,                 'capability_type' => array('team', 'teams'),                 'capabilities' => array(                     'publish_posts' => 'publish_teams',                     'edit_posts' => 'edit_teams',                     'edit_post' => 'edit_team',                     'edit_others_posts' => 'edit_others_teams',                     'delete_posts' => 'delete_teams',                     'delete_post' => 'delete_team',                     'delete_others_posts' => 'delete_others_teams',                     'manage_posts' => 'manage_teams',                     'read_private_posts' => 'read_private_teams',                     'read_post' => 'read_team',                 ),                 'map_meta_cap'=> true,                   'has_archive' => true,                 'hierarchical' => true,                 'menu_position' => null,                 'supports' => array('title',                     'author',                     'editor',                     'thumbnail',                 ));                  register_post_type( $name, $args );         });     }          add_team_page_post_type('team_page', array());      And am assigning them to various roles like so:               add_action( 'init', 'my_custom_capabilities', 0);     function my_custom_capabilities(){          $role_object = get_role( 'administrator' );         $role_object->add_cap( 'publish_teams');         $role_object->add_cap( 'edit_teams');         $role_object->add_cap( 'edit_team');         $role_object->add_cap( 'edit_others_teams');         $role_object->add_cap( 'delete_teams');         $role_object->add_cap( 'delete_team');         $role_object->add_cap( 'delete_others_teams');         $role_object->add_cap( 'manage_teams');                 $role_object->add_cap( 'read_private_teams');         $role_object->add_cap( 'read_team');     }      Upon further research I've found I needed to include a `map_meta_cap()`function which I did like so :               add_filter( 'map_meta_cap', 'my_map_meta_cap', 10, 4 );          function my_map_meta_cap( $caps, $cap, $user_id, $args ) {          /* If editing, deleting, or reading a team, get the post and post type object. */     if ( 'edit_team' == $cap || 'delete_team' == $cap || 'read_team' == $cap ) {         $post = get_post( $args[0] );         $post_type = get_post_type_object( $post->post_type );              /* Set an empty array for the caps. */         $caps = array();     }          /* If editing a team, assign the required capability. */     if ( 'edit_team' == $cap ) {         if ( $user_id == $post->post_author )             $caps[] = $post_type->cap->edit_posts;         else             $caps[] = $post_type->cap->edit_others_posts;     }          /* If deleting a team, assign the required capability. */     elseif ( 'delete_team' == $cap ) {         if ( $user_id == $post->post_author )             $caps[] = $post_type->cap->delete_posts;         else             $caps[] = $post_type->cap->delete_others_posts;     }          /* If reading a private team, assign the required capability. */     elseif ( 'read_team' == $cap ) {              if ( 'private' != $post->post_status )             $caps[] = 'read';         elseif ( $user_id == $post->post_author )             $caps[] = 'read';         else             $caps[] = $post_type->cap->read_private_posts;     }          /* Return the capabilities required by the user. */     return $caps;     }      This comes from an article by Justin Tadlock http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom- post-types The problem is that I can only view my cpt and not edit or delete it. Am I guessing the problem is with the last function but I can't find much documentation on it.


Where is the right .mo file inside the language repository?

I need to translate my Wordpress in Italian. Following the instruction written on WordPress in Your Language, I've searched my .mo file inside the Language Repository but I've some problems. The folder structure is not as expected, there are lots of folders that don't make me any sense:               branches/     buddypress/     mu/     rosetta/     tags/     trunk/      I've read the instructions about the repository but they mention just some of these folders. I've tried to find the .mo file opening all the folder, but there are lots of .mo files (for example under branches/3.5/messages) I've searched into some forums but everybody says just "go to the repository and download your .mo file" like there is just one file. What am I missing?


Is there anything that Joomla or Drupal can do that can't be done in WordPress?

I have a client who wants to use Joomla, because they were told it was good. I'm trying to convince them that WordPress is a much more user-friendly option. I've played with Joomla (and Drupal) once before, and I found the learning curve incredibly steep (probably due to their obscure terminology). I consider myself quite technically savvy, and if I found it hard, I'm sure my less technically competent clients will find it even more obscure and difficult to learn. So far, I have yet to come across anything a client would need that couldn't be done in WordPress, but before I tell them that, I wanted to check that this is, indeed, the case. Is there anything that Joomla or Drupal can do that WordPress can't (especially now with custom post types in WP 3+)?


Query meta field using between

I'm trying to Query some lattitude and logitude and then I get some long numbers and apperently the Query dont like that. Let says I have these in the database               Meta-key: lat      Meta-value: 54.3415000      Meta-key: lng     Meta-value: 10.1254100      and do a query like this:               $args['meta_query'] =              array(                 'relation' => 'AND',                  array(                     'key'       => 'lat',                     'value'     =>  array( '53.82659686199116', '54.946076335668714' ),                     'type'      => 'NUMERIC',                     'compare'   => 'BETWEEN',                 ),                 array(                     'key'       => 'lng',                     'value'     =>  array( '8.429260683593725', '11.889954042968725' ),                     'type'      => 'NUMERIC',                     'compare'   => 'BETWEEN',                 )             );      Then it works, **BUT** , when it looks like this:               $args['meta_query'] =              array(                 'relation' => 'AND',                  array(                     'key'       => 'lat',                     'value'     =>  array( '54.10933293482647', '54.66906633195788' ),                     'type'      => 'NUMERIC',                     'compare'   => 'BETWEEN',                 ),                 array(                     'key'       => 'lng',                     'value'     =>  array( '9.294434023437475', '11.024780703124975' ),                     'type'      => 'NUMERIC',                     'compare'   => 'BETWEEN',                 )             );      Then it does not work, even it is still between the 2 numbers. Anyone have a clue what is going on here ? Must be some MYSQL stuff. **EDIT:** Here is what a mysql request looks like:               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON     (wp_posts.ID = wp_postmeta.post_id)INNER JOIN wp_postmeta AS mt1 ON      (wp_posts.ID = mt1.post_id) WHERE 1=1 AND wp_posts.post_type = 'branchenbuch'      AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future'      OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending'      OR wp_posts.post_status = 'private') AND ( (wp_postmeta.meta_key = 'lat'      AND CAST(wp_postmeta.meta_value AS SIGNED) BETWEEN '54.1833340338'      AND '54.4636527622')AND (mt1.meta_key = 'lng' AND CAST(mt1.meta_value AS SIGNED)      BETWEEN '9.76272625977' AND '10.6278995996') ) GROUP BY wp_posts.ID      ORDER BY wp_posts.post_date DESC LIMIT 0, 10


How to override a function call in functions.php?

In functions.php of a theme makes a call to `show_admin_bar(false)` which hides admin bar in front end:               if (!is_admin())     {         wp_deregister_style( 'bp-admin-bar' );         if ( function_exists( 'show_admin_bar' ) )         {             show_admin_bar( false );             remove_action( 'bp_init', 'bp_core_load_buddybar_css' );         }     }      I want to make admin bar appear in front end for the `admin` users. To do this, I added the following code to a plugin:               add_action('plugins_loaded', 'show_admin_bar_to_admins', 100);     function show_admin_bar_to_admins()     {         if (current_user_can('manage_options')) {             show_admin_bar(true);         }     }      But this call didn't make a difference. I put `100` as the priority value such in order to make this function to be called later than the call inside `functions.php`. But it didn't make a difference. Is there a way to make a function call inside a plugin to be executed later than the call inside `functions.php`.


Is using %postname% for permalinks really that bad for performance?

I've seen in various places, including the Wordpress admin and on this page, that using string based identifiers is "strongly not recommended for performance reasons". I understand that looking up a string in the database is slower than looking up an integer, but in my experience it's never a huge difference, assuming the slug field has a fulltext index. Why is there such a strong discouragement of using this method?


Use tag interface for hierarchical taxonomy?

Custom taxonomies are great. I registered a bunch of new taxonomies and wrote an importer to import our hierarchical taxonomy into WordPress a la XML. The problem is one taxonomy has about 1,100 terms and browsing a checklist of 1,100 things is cruel and unusual punishment. Is there any way to have a hierarchical taxonomy but use the Tag interface (search box with auto complete) instead? > **Update:** this code from Bainternet's answer gets most of the way there > (adds tag interface for the specified taxonomy, with working autocomplete > and correctly populated "most used" tag cloud), but terms are not saved on > post save. If the post had terms before, they will be deleted on save. So I > am still looking for an answer. (This same code saves terms just fine if the > taxonomy is registered with `hierarchichal`set to false, but the point of > the question is to use the tag interface on a hierarchical taxonomy.)               //remove default metabox     //change TAXONOMY_NAME to your taxonomy name     add_action( 'admin_menu' , 'remove_post_custom_fields' );     function remove_post_custom_fields() {         remove_meta_box( 'issuediv' , 'post' , 'normal' );      }                    //add our custom meta box     add_action( 'add_meta_boxes', 'my_add_custom_box' );           function my_add_custom_box() {         add_meta_box(      //      'myplugin_sectionid',             'tagsdiv-issue',             __( 'New and Improved Issue Tags', 'textdomain' ),             'tags_like_custom_tax',             'post'          );      }           //call back function to display the metabox      //change TAXONOMY_NAME to your taxonomy name       function tags_like_custom_tax(){          $tax_name = 'issue';          global $post;          $taxonomy = get_taxonomy($tax_name);          $disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : '';          ?>          <div class="tagsdiv" id="<?php echo $tax_name; ?>">

<?php echo $taxonomy->labels->add_or_remove_items; ?>
                     <textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php echo $disabled; ?>><?php echo get_terms_to_edit( $post->ID, $tax_name ); // textarea_escaped by esc_attr() ?></textarea>
                 <?php if ( current_user_can($taxonomy->cap->assign_terms) ) { ?>
                     <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->name; ?>
<?php echo $taxonomy->labels->add_new_item; ?>

<input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />                     <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" />

<?php echo esc_attr( $taxonomy->labels->separate_items_with_commas ); ?>
                 <?php } ?>

               <?php if ( current_user_can($taxonomy->cap->assign_terms) ) { ?>
<a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->choose_from_most_used; ?>
               <?php }      }      The original question is borrowed from the Wordpress forum post here.


Custom URL parameters in template files

**SETUP** I want to pull a query variable from the URL and use it on my single post template (single.php). For example: mysite.com/2011/07/29/testPost/?myvar=someValue To do so, I added the custom query variable to functions.php like so:               add_filter('query_vars', 'parameter_queryvars' );          function parameter_queryvars( $qvars ) {         $qvars[] = 'myvar';         return $qvars;     }      Then in single.php and index.php I added the following code to test if the custom variable was set and echo a string if true. I also printed the contents of $wp_query->query_vars so I could see if my custom variable was there:               <?php         global $wp_query;         if( isset( $wp_query->query_vars['myvar'] )) {             echo 'custom variable recognized';         }         print_r($wp_query->query_vars);     ?>      **PROBLEM** When I access a URL like mysite.com/2011/07/29/testPost/?myvar=someValue, which uses the single.php template, the echo command is not displayed and the output of print_r() shows that my 'myvar' is absent from the list of query_vars. Output from single.php:               Array ( [p] => 0 [page] => 0 [year] => 2011 [monthnum] => 7 [day] => 29 [name] => testpost [error] => [m] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author_name] => [feed] => [tb] => [paged] => 0 [comments_popup] => [meta_key] => [meta_value] => [preview] => [s] => [sentence] => [fields] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [update_post_meta_cache] => 1 [post_type] => [posts_per_page] => 150 [nopaging] => [comments_per_page] => 50 [no_found_rows] => [order] => DESC [orderby] => wp_posts.post_date DESC )      However, when I access a URL like mysite.com/?myvar=someValue, which uses the index.php template, the echo command is output and you can see the first variable output by print_r() is the 'myvar' I am looking for:               Array ( [myvar] => someValue [error] => [m] => 0 [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author_name] => [feed] => [tb] => [paged] => 0 [comments_popup] => [meta_key] => [meta_value] => [preview] => [s] => [sentence] => [fields] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [meta_query] => Array ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [update_post_meta_cache] => 1 [post_type] => [posts_per_page] => 150 [nopaging] => [comments_per_page] => 50 [no_found_rows] => [order] => DESC [orderby] => wp_posts.post_date DESC )      **QUESTION** Why would the custom query variable be properly set on an index.php page but not on single.php? I have tested with all plugins off and tried with default permalinks, but got the same results.


Does WordPress MultiSite use separate MySql databases?

I ask because I cannot find the options from a plug-in I created on my second blog. Adding this plug-in to the main site and the options show up. I am confused because there is a column in **wp_options** table **blog_id** and I was expecting there to be more than one value there.


register_taxonomy() take much queries

Sorry for my poor English, I'm russian. I have a problem by adding a lot of taxonomies. When I added about 80 taxonomies, I get the following results(without caching): before: 44 queries 0.352 seconds after: 206 queries 0.703 seconds What's wrong? I calculate that 1 registered taxonomy take 2 server query.. Please, help me..


add_action before theme setup

I have a class which loads the image sliders on some add_action. There is a function/method "render_slider" which renders the sliders on the page based on the slider selected. The theme tries to get the image slider object before the sliders are loaded. I tried with init,plugins_loaded,to load the slider. But still I get the error object not found               class Sliders {       public function __construct() {         add_filter( 'add_sliders', array( $this, 'add_sliders' ) );         add_filter('plugins_loaded',array($this,'load_sliders'),10);       }       public function add_sliders($sliders) {       }       public function  load_sliders() {            $sliders_to_load = apply_filters( 'add_sliders', array() );          foreach ( $sliders_to_load as $slider )             $this->sliders[ $slider->id ] = $slider;       }       public function render_slider($slider_type = ''){             switch($slider_type){               case 'rotator' : $rotator = $this->sliders[$slider_type];break; //Object Not Found               default: break;           }       }     }


Problem With Order Item Meta In Woocommerce

I'm following Xatic's tutorial to help me add custom data to products. I've managed to be able to have that data on the cart page. However, it doesn't display in the order page in the admin backend. What can I do to solve this? Here's what I've got so far               add_action( 'wp_enqueue_scripts','enqueue_wc_scripts' );     add_action('woocommerce_before_add_to_cart_button','extend_product_options');     add_filter('woocommerce_after_single_product_summary','prescription_form');          add_filter('woocommerce_add_cart_item_data', 'custom_add_item_data', 10, 2);     add_filter('woocommerce_get_cart_item_from_session','wc_get_cart_item_from_session',10,2);     add_filter('woocommerce_get_item_data', 'xatik_wc_get_item_data', 10, 2);          add_action('woocommerce_add_order_item_meta', 'xatik_wc_order_item_meta', 10, 2);          load_child_theme_textdomain('yit', get_stylesheet_directory().'/languages');     load_child_theme_textdomain('woocommerce', get_stylesheet_directory().'/languages');               function enqueue_wc_scripts(){              wp_enqueue_script( 'custom-js',  get_stylesheet_directory_uri().'/js/custom.js' );          }               function extend_product_options(){              echo '
';         echo '<input type="hidden" name ="presc_right_axis" value=""/>';         echo '<input type="hidden" name ="presc_right_sphere" id="rsphere" value=""/>';         echo '<input type="hidden" name ="presc_right_cilinder" value=""/>';         echo '
';     }               function prescription_form(){              echo '
';         echo '
Olho Direito
                 *Esfera                     <select name="right_eye" id="right_eye_select" class="required-entry product-custom-option validation-passed" title="" onchange="opConfig.reloadPrice()">                             <option value="10">+10.00</option>                             <option value="9.75">+9.75</option>                                                 </select>
';     }               function custom_add_item_data($cart_item_meta, $product_id){              //var_dump($_POST);         if(isset($_POST['presc_right_sphere'])){                  $cart_item_meta['presc_data']['presc_right_sphere'] = $_POST['presc_right_sphere'];         }              return $cart_item_meta;     }               function wc_get_cart_item_from_session($cart_item, $values) {              //var_dump($values);         //var_dump($cart_item);         if (isset($values['presc_data'])) {             $cart_item['presc_data'] = $values['presc_data'];         }              return $cart_item;     }               function xatik_wc_get_item_data($other_data, $cart_item) {                  if (isset($cart_item['presc_data'])) {                      $data = $cart_item['presc_data'];                      $other_data[] = array('name' => 'Olho Direito', 'value' => $data['presc_right_sphere']);             }         return $other_data;     }               function xatik_wc_order_item_meta($item_id, $cart_item) {              var_dump($item_id);         var_dump($cart_item);              if ( ! empty( $cart_item['presc_data'] ) )             woocommerce_add_order_item_meta( $item_id, 'Olho Direito', $cart_item['presc_right_sphere'] );               }


If $var is empty, return 404.

For security reasons, to detect if somebody is manipulating `GET` parameters of the plugin I'm writing, I need to return a `404` if the security query I perform returns nothing. How can I force that? I tried with:               if (security($_GET['id'])) {         [...]     } else {         global $wp_query;         $wp_query->set_404();     }      found it in other posts, but it is not working.


How to show a post if was published less than two hours ago?

I want to show posts only that were posted less that 2 hours ago and have the custom field "¿directo?" with the value "Sí". These are my progresses, but they don't work: Functions.php:               function is_time_to_show_post($hora, $minutos, $dia, $mes)     {         $now = current_time( 'timestamp' );         $hour_now = date( 'H', $now ); // 24h format         $minutes_now = date( 'i', $now ); // 24h format         $month_now = date( 'n', $now ); // 24h format         if($hour_now > $hora +2){ //same day, have passed 3 hours or more             return 'no';         }         if(($hour_now - $hora <= 2 && $hour_now - $hora) != 0 && ($minutes_now - $minutos) >= 0 ){ //same day, have passed two days or more             return 'no';         }         if($minutes_now <= 59 - $minutos && $hour_now == 0){ //in less than two hours, day change             return 'no';         }         else{             return 'yes';         }     }      For example, tests in search.php:
                         <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                             <?php                             $directo = get_post_meta( the_post().get_the_ID(), '¿directo?', true);                             $mostrar = true;                             if($directo   == 'Sí'        &&      is_time_to_show_post(   the_post().get_post_time('G', false, null,false)   , the_post().get_post_time('i', false, null,false)  ) == 'yes'     ){                             }else if($directo   == 'Sí'){                                 $mostrar = false;                             }                                  if($mostrar){                                 echo '
';                                 get_template_part( 'content', the_post().get_post_format() );                                 echo '
';                             }                                  ?>                         <?php endwhile; wp_reset_query(); endif; ?>


background image in post with images on top

I am trying to create a post that consists of a background image with images over the top of it. The idea is that the top images are links overlay on the background. I have used the following css:                   #costume {      background-image :url('http://localhost/wp-content/plugins/custom_costume_plugin/images/background.jpg');     position: absolute;     background-attachment:fixed;     height: 1190px;     width: 1500px;     top: 400px;     background-repeat:no-repeat;     }          #lefthand {     position: absolute;     height: 38px;     width: 88px;     top: 400px;      left: 600px;     text-decoration: none;     }          #righthand {     position: absolute;     height: 38px;     width: 88px;     top: 400px;      left: 200px;     text-decoration: none;     }          #head {     position: absolute;     height: 38px;     width: 88px;     top: 31px;     left: 400px;      text-decoration: none;     }          #chest {     position: absolute;     height: 38px;     width: 88px;     top: 200px;      left: 400px;     text-decoration: none;     }          #legs {     position: absolute;     height: 38px;     width: 88px;     top: 600px;      left: 400px;     text-decoration: none;     }          #feet {     position: absolute;     height: 38px;     width: 88px;     top: 800px;      left: 400px;     text-decoration: none;     }      The post consists of the following HTML:

         \\(Link to image)

         \\(Link to image)

         \\(Link to image)

         \\(Link to image)

         \\(Link to image)

         \\(Link to image)

      The image inside the lefthand div is displaying ok but there is no background image in the post for the costume div. I can see the stylesheet in view source. What am I missing?


How can I add columns to the post edit listing to show my custom post data?

When you click on "Posts" or "Pages", you get a paged listing of your posts or pages with the following columns: _Title | Author | Categories | Tags | Date_ I have a plugin which gives an SEO score for each post and page. I would like to add two columns to the list view when viewing posts or pages, one for the post's "seo score" and one for the posts "seo keyword" so that the column listing becomes: _Title | Author | Categories | Tags | Date | SEO Score | SEO Keywords_


List taxonomies in a dropdown in theme's option panel

I want to show a dropdown in the option's panel for choosing a "featured product category" which is a custom taxonomy. I do this way:               register_taxonomy("Catalogs",         array("kmproduct"),         array("hierarchical" => true,               "label" => "Catalogs",               "singular_label" => "catalog",               "rewrite" => true   ));      and in my `theme_options.php` i have:               ...     array( "name" => "Homepage featured category",             "desc" => "Choose a category from which featured posts are drawn",            "id" => $shortname."_feat_cat",             "type" => "select",             "options" => $wp_tax,             "std" => "Choose a category"),      and I can't get the taxonomies list:               $args=array(   'name' => 'Catalogs');          $output = 'names'; // or objects         $taxonomies = get_taxonomies($args,$output);          $wp_tax = array();       foreach ($taxonomies as $category_list ) {            $wp_tax[$category_list->ID] = $category_list->name;      }          array_unshift($wp_tax, "Choose a category");      What's wrong? I can't get it to work :(


The plugin generated 80 characters of unexpected output!

I'm getting this message each time I activate my plugin: _The plugin generated 80 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin._ The only way I can suppress the message is to wrap my activation function code in a conditional (**see below). How should I rewrite this to prevent the alert?               function myPlugin($post)     {         echo "Whatever is here throws an unexpected output alert when the plugin isa activated";     //I can place code here without issue, but anything that is output via echo throws the alert.     }     register_activation_hook(__FILE__, 'myPlugin');      Wrapping the function code in the conditional suppresses the alerts:               function myPlugin($post)     {         global $pagenow;         if ( is_admin() && $pagenow !== 'plugins.php' ) {             echo "No more alerts when its wrapped this way";             }     }      ?>


How to Access Global $multipage or Global $numpages outside the loop?

I am writing a code in the header that pertains to link rel='prev' and link rel='next' thing but I need to check if the post is multipage. I check out these global variables: $numpages $multipage However they don't work in header.php or outside the loop? Example code to verify in header (just a test, but it does not work):               <?php     global $wp_query;     global $numpages;     global $multipage;     If ($multipage) {     echo 'This is a multipage post';     } else {     echo 'This is not multipage';     }     ?>      I am wondering how to do this, can somebody help me please? Thanks.


Need help with friendly URL's in Wordpress

I'm creating som custom templates in Wordpress and I'm passing some data in the URL's. Currently my URL looks like this: http://www.mysite.com/designers/?id=43&name=designer+name The URL contains designer ID and designer name. I would really like to use this: http://www.mysite.com/designers/designer+name/ My permalink structure is set to `/%category%/%postname%/` My .htaccess file looks like this:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>     # END WordPress      I've looked at http://codex.wordpress.org/Using_Permalinks, but not become any wiser. I got two questions:   1. Is there any point in changing the above URL regarding SEO   2. How can I get the "pretty" URL? * * * **UPDATE**   I'm adding some more info for clarification.   * I'm developing the site myself    * The template is 100% custom template    * Based on info from $_GET, I load data from my custom DB table and display this on page    * My site has an avarage of between 3-400 unique visitors per day. At peak I have 2000 unique visitors per day.   * I'm developing an online fashion magazine   * My URL is currently being created like this:  `Url = get_permalink().'?bid='.$brand->id.'&name='.$brand->name;`   * I've used similar method here:   http://storelocator.no/search/?brandID=4673&storeID=0&brand=Moods+of+Norway Using Custom Post Type was an option I considered, but I needed my own table structurem because designers / brands are linked up against galleries (and more links to other tables to come). So saving brands data in WP POST table was not going to work. So I need to know this:   * **What do I need to do with my Permalink structure?**   * **What do I need to do with my .htaccess file?**