Using pagination with specific custom post type

Alright.. I've been looking alot on the internet in search of a solution for this.. so far i found nothing that could explain me how to solve it.. When i click on Page suivant from the navigation div all it does is redirecting me to home page instead of loading the same page and showing the next 12 post from 'bateaux' which has 18 posts in it.               <?php                       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                      $args = array(                     'post_type' => 'bateaux',                     'post_status' => 'publish',                     'orderby' => 'menu_order',                     'posts_per_page' => 12,                     'caller_get_posts' => 1,                     'paged' => $paged                 );                      query_posts($args);                      while (have_posts()): the_post();                      $attachment_id = get_field('image_supplementaire_1');                  $image_attributes = wp_get_attachment_image_src( $attachment_id );                    ?>
                 <?php                          if ($attachment_id != NULL)                     {                      ?>                     <a href="<?php echo add_query_arg( 'action', 'Consulter', the_permalink()); ?>" title="<?php the_field('titre'); ?>"><img alt="<?php the_field('titre'); ?>" src="<?php echo $image_attributes[0]; ?>" width="155px" height="133px" />                 <?php                          }                     else                      {                      ?>                     <a href="<?php echo add_query_arg( 'action', 'Consulter', the_permalink()); ?>" title="<?php the_field('titre'); ?>"><img alt="<?php the_field('titre'); ?>" src="<?php bloginfo( 'template_directory' ); ?>/Images/img_default.jpg" width="155px" height="133px" />                 <?php                          }                      ?>
<?php the_field('titre'); ?>

<?php the_field('prix'); ?>$
                 <a href="<?php add_query_arg( 'action', 'Consulter', the_permalink()); ?>" class="details" title="Détails" >Détails
                 <?php                      endwhile;                   ?>

<?php previous_posts_link('« Page précédente') ?>

<?php next_posts_link('Page suivante »') ?>

              <?php                  wp_reset_query();              ?>      Any tips ? Thks!


Wordpress Numeric Pagination with Query String

So I have a dynamic loop which is affected by a query sting in the URL.. For example I have 3 categories and when they click the category it just adds a query to the URL:               Dogs     Cats     Other      and then my custom loop will pull the query values to show relative posts               $args = array('post_type' => 'animals', 'posts_per_page' => 4, 'category' => $queryString);     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $wp_query = new WP_Query($args);      I then have my pagination code which is working as expected but it doesn't change the posts.. I have a feeling its because of the url structure.. http://example.com/animals/page/2/?view=cats any help from you awesome people!


WordPress and pagination

Let me paste code first:               <?php      $category = get_the_category();     $category_id = get_cat_id( single_cat_title("",false) );     $args = array(         'posts_per_page'   => 5,         'post_type'        => array('post', 'shows', 'hosts'),         'orderby'          => 'post_date',         'order'            => 'DESC',         'category'         => $category_id     );          $myposts = get_posts( $args );     foreach ( $myposts as $post ) {     ?>         <!-- My Markup was here -->     <?php }     if( function_exists('wp_pagenavi')) { wp_pagenavi(); }     ?>      Everything works fine except pagination (I mean pagenavi). Any suggestion?


Blog Page pagination not working, loads Page 1 each time

I don't know what to do here but pagination is driving me crazy! As you can see, "Older" points to blog/page/2 but when clicked, the site stays on blog/. I'm using wp-pagenavi for pagination. The site url is http://www.grassroottech.com/blog Sorry, here is the blog template page: (embedding not working - http://pastebin.com/AtU7AYfD) ## blog template
     <?php     //Fix homepage pagination     if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } else if ( get_query_var('page') ) {$paged = get_query_var('page'); } else {$paged = 1; }          $temp = $wp_query;  // re-sets query     $wp_query = null;   // re-sets query     $args = array( 'post_type' => array('post'), 'orderby'=>'date', 'order'=>'DESC', 'posts_per_page' => 10, 'paged' => $paged);     $wp_query = new WP_Query();     $wp_query->query( $args );     while ($wp_query->have_posts()) : $wp_query->the_post();      ?>

             <?php if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {?>
                 <img src="<?php echo get_template_directory_uri();?>/timthumb.php?src=<?php echo thumb_url();?>&h=84&w=84&zc=1" alt="" class="boximg-pad" />
             <?php } ?>
             <div class="postbox <?php post_class(); ?>">
<a href="<?php the_permalink();?>"><?php the_title();?>

            <?php the_excerpt(__('Continue reading »','example')); ?>

               <?php echo __('Posted at ','ecobiz');?><?php the_time( get_option('date_format') ); ?> |                <?php echo __('By ','ecobiz');?>: <?php the_author_posts_link();?>  |                                        <?php echo __('Categories ','ecobiz');?>: <?php the_category(',');?>  |                <?php comments_popup_link(__('0 Comment','ecobiz'),__('1 Comment','ecobiz'),__('% Comments','ecobiz'));?>

         <?php endwhile; ?>


Pagination not working in category listing

I can't get pagination inside categories listings to work. I'm using a custom query, with the `get_query_var('paged')`:               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args=array(     'post__not_in'=>$essentielle_excluded_posts,     'category_name' => 'concours-fun',     'paged'=>$paged,      'posts_per_page'=>5,     );     query_posts($args);      Also tried the Category Pagination Fix plugin. My permalink structure: `/%category%/%postname%-%post_id%.html` Example of the error: http://www.essentielle.be/concours-fun/page/2 Any idea as to what else i should check?


NextGEN Gallery- using shortcode for different galleries on different pages

> **Possible Duplicate:**   >  conditional shortcode not working I have a salon website with a gallery page wherein the user must first select a stylist prior to viewing their individual gallery. I planned on using NextGen to house the images in stylist specific galleries, and using the NextGen shortcodes on each stylists page. However, this doesn't seem to be working. For example, when viewing Rebecca's page, the gallery doesn't show despite having the shortcode in the WP Page content field. Any ideas what could be causing the problem? The only solution I can come up with is to create a different page template for each stylist and utilize the shortcode there, but surely there is a better route to take? relevant from gallery.php:

PARLOUR GALLERY

REBECCA HAEHNLE | CHRIS KELLER | BILLY MALLOY | VERONICA JONES | ABBEY CASTELLANO | QUARTIA FUTRELL | ROOSEVELT OXENDINE | NICOLE LUESCHOW | MEREDITH NOWLIN | MARICEL YALUNG | STEPHANIE BRANDT

                                 <?php                                           query_posts( 'tag=apples' );                                           if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                                                <?php endwhile; else: ?>                                        <?php endif; ?>

      functions.php               <?php function nggallery( $shortcode ){ echo do_shortcode( $shortcode ); /* NextGen Gallery */ } ?>      **ETA** I am definitely open to alternative methods for having different galleries on different pages if there are any. Insight is welcomed!


Different background-image by category

I am trying to put different body background-image for each category.               body {      background-color: #000;      background-image: url(img/bg.png);      background-repeat: no-repeat;      background-position: center top;      font-size: 14px; color: #555;      font-family: Arial, Helvetica, Verdana, sans-serif; }      I only want different `background-image: url(img/bg.png);` for each catecory. I found one possible method. It's like that:               <link rel="stylesheet" href="" type="text/css" media="screen,projection" />      <? php if( is_category(1) ) { ?>      <link rel="stylesheet" href="" type="text/css" media="screen" />      <?php }      elseif ( is_category (2) ) { ?>      <link rel="stylesheet" href="" type="text/css" media="screen" />      <?php }      elseif ( is_category (33) ) { ?>      <link rel="stylesheet" href="" type="text/css" media="screen" /> <?php }      else { ?> <?php } ?>      Still, I´m pretty sure it is not the best possible way to achieve my goal, because: 1) It looks for the whole stylesheet 2) It makes queries inside the header.php which might not be the best way considering page speed My idea is to create different body classes:               body.apple { code here }     body.area { code here }     body.usa { code here }     body.bolt { code here }     body.jennifer { code here }      ... or whatever. I just need php to load different body classes from a single stylesheet for different categories. Does anyone have a good solution?


Custom post types - Use post_id in permalink structure when using has_archive => true

I recently asked this question Custom post types - Use post_id in permalink structure and solved it but as I have enabled `'has_archive' => true` the solution given no longer works. Let me explain: I'm after this structure:   * `archive-events.php` => /news/events/   * `single-events.php` => /news/events/%post_id%/%postname% To get `post_id` in a single event permalink I've had to add `%post_id%` to the CPT slug but when enabling `has_archive => true` the archive page becomes the slug; in this case becoming `/news/events/%post_id%/` which is invalid. So my question: > How do I have post_id in permalink structure when using has_archive => true


posts going to 2 pages/categories only show up in 1

I have a portfolio website where my portfolio updates are supposed to go to both my portfolio and blog pages, as well as show thumbnails for the posts on my homepage. The thumbnails work perfectly; if a post is to go in two categories, the thumbnails show up in both categories. My trouble is with the blog- posts marked to go in both blog and portfolio categories only show up in my portfolio. Here's what I'm using for the blog:
         <?php query_posts('cat=-4'); ?>         <?php if(have_posts()) : while(have_posts()) : the_post('cat=-3,4'); ?>

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

             <?php the_content('read more...'); ?>

<?php the_date(); ?> | <?php the_tags('tags:', ', ', '
'); ?>

         <?php endwhile; ?>         <?php else : ?>
I'm not sure what you're looking for.
         <?php endif; ?>
      Any ideas what could be causing this or how to remedy?


page-name.php doesn't execute on custom template

This one has me stumped. I have a page named 'Login.' I also have a file uploaded in my theme directory called 'page-login.php'. If I select a default theme template, page-login.php executes like it should. However, when I use a custom template that I created for modal use, page- login.php does not execute. This is my custom template:               <?php      /*     * Template Name: Modal     * Author: Me     * URL: myurl.com     */     ?>          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">         <head>         <meta http-equiv="Content-type" content="text/html; charset=utf-8" />         <meta name="MSSmartTagsPreventParsing" content="true" />         <meta http-equiv="Imagetoolbar" content="No" />         <title>Email A Friend</title>         <style type="text/css">             body {font-size:13px;}         </style>         <link rel='stylesheet' id='gforms_css-css'  href='<?php bloginfo('url'); ?>/wp-content/plugins/gravityforms/css/forms.css?ver=1.6.2.1.1' type='text/css' media='all' />         <script type='text/javascript' src='<?php bloginfo('url'); ?>/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>         <link rel="stylesheet" href='<?php bloginfo('stylesheet_directory'); ?>/style.css' type="text/css" media="screen" />     </head>     <body class="email">         <div id="emailForm">             <?php if (have_posts()) : while (have_posts()) : the_post(); ?>             <?php the_content(); ?>             <?php endwhile; endif; ?>             <?php wp_footer(); ?>         </div>     </body>     </html>


WordPress ajax call for not logged in users, doesn't work

I have on frontend search box, I have implement autocomplete for it, and when I'm logged in, it works great for me. But when I'm not logged in, I get 302 as result of ajax call, response headers have location in it, so it is trying to redirect, I do not know why. I notice a lot of posts around this issue, but none of the posts/questions didn't help me. My Code, that works when users are logged in, but doesn't work when users are not logged in, please help. # jQuery               $.ajax({         type: 'POST',         url: MyAjax.ajaxurl,         data: {             action : 'myajax-submit',             term : request.term,             _ajax_nonce : MyAjax.ajax_nonce         },         dataType: "json",         beforeSend: function(jqXHR, settings){         },         success: function(data, textStatus, jqXHR){             response(data);         },         error: function(jqXHR, textStatus, errorThrown){             response([{                 'value':'Error retriveing data',                 'id':1             }]);         },         complete: function(jqXHR, textStatus){         },         statusCode: {                             }     });      # php               add_action('wp_ajax_myajax-submit', 'myajax_submit');               add_action('wp_ajax_nopriv_myajax-submit', 'myajax_submit');              function myajax_submit() {             global $wpdb;                  //check_ajax_referer('myajax_nonce', '_ajax_nonce');                  if (isset($_POST["term"])) {                 $q = strtolower($_POST["term"]);                      .....                      $json_response = array();                      ...                      header("Cache-Control: no-cache, must-revalidate");                 header("Pragma: no-cache");                 header("Content-type: text/x-json");                      print json_encode($json_response);                      die();             }     }


Custom thumbnail size for each post format

I want to customize each post format his thumbnail without creating many size in all posts, for example: Instead of :               add_image_size( "standard-format", $width, $height, true );     add_image_size( "video-format", $width, $height, true );     add_image_size( "image-format", $width, $height, true );     ... etc      I want a condition or somthings like this, to custom each post format his Thumbnail size:               if( $post_format == "standard" ) {        add_image_size( "simple-thumb", $width, $height, true );     }     ...


Search by meta_query

I am building a Wordpress site with an events feature. The events page was made with custom post types. I want to make it possible for people to search/ filter events by dates. For example, they can search for all events happening between 2nd December, 2011 and 1st March, 2012 and get results from events that have their dates between the months of December and March (ie. december, january, february and march). I want to know the best way to go about this. Any ideas? You can see an example of what I want to achieve by looking at the "Search events by date" feature on this page http://www.londontown.com/events Here is the code for the start and end date meta boxes:               $prefix = 'ghes_';          add_filter( 'ghes_meta_boxes', 'ghes_sample_metaboxes' );          function ghes_sample_metaboxes( $meta_boxes ) {              global $prefix;              $meta_boxes[] = array(             'id' => 'event_meta',             'title' => 'Event Metabox',             'pages' => array('event'), // post type             'context' => 'normal',             'priority' => 'high',             'show_names' => true,             'fields' => array(                       array(                     'name' => 'Event Start Date',                     'desc' => 'field description (optional)',                     'id' => $prefix . 'event_start_timestamp',                     'type' => 'text_date_timestamp'                 ),                  array(                     'name' => 'Event End Date',                     'desc' => 'field description (optional)',                     'id' => $prefix . 'event_end_timestamp',                     'type' => 'text_date_timestamp'                 )      Here is how the date data is saved:               case 'text_date_timestamp':                     echo '<input class="ghes_text_small ghes_datepicker" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? date( 'm\/d\/Y', $meta ) : $field['std'], '" />', $field['desc'], '';                     break;      And this is what I have for my search box:               <form action="<?php bloginfo('url'); ?>" method="get" id="searchform" class="form_search">                  Event Search:                             <select name="event_cat">                 <option value="0">Select...</option>                 <?php                 $theterms = get_terms('event_cat', 'orderby=name');                 foreach ($theterms AS $term) :                     echo "<option value='".$term->slug."'".($_GET['event_cat'] == $term->slug ? ' selected="selected"' : '').">".$term->name."</option>\n";                 endforeach;                 ?>             </select>                                                             <?php _e('between','ghes'); ?>:          <input class="ghes_text_small ghes_datepicker" type="text_date_timestamp" name="ghes_event_start_timestamp" id="ghes_event_start_timestamp" value=""/>'                 <input type="hidden" id="ghes_event_start_timestamp" name="start" value="" />                      <?php _e('and','ghes'); ?>          <input class="ghes_text_small ghes_datepicker" type="text" name="ghes_event_end_timestamp" id="ghes_event_end_timestamp" value=""/>'                 <input type="hidden" id="ghes_event_end_timestamp" name="end" value="" />                                       <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('search_events'); ?>" />             <input type="submit" value="<?php _e('Search','ghes'); ?>" class="em-events-search-submit" />                </form>      How do I get the form to process the "date search" data and display results between the dates users select? Is the search form missing anything? Is there something I should add to functions.php to make this work? I have been looking for an answer for almost two weeks now and really want to learn how this works. Please share your thoughts if you have an idea of how to get this to work. Thanks in advance.


How to make two pages in wordpress to display recent pages and popular pages

I am creating a new wordpress blog. I want to make two pages on the blog. One page to display the popular post and another page to display the recent post. Popular post should be affected according to the page view, social share, comments. Once the post is shown on the popular page it should be there forever. New post will come there but the previous post will not be gone from there. Normally Popular post are like most poplular in 24 hours or something like that. It is ok but once it is shown it should not be gone after another 24 hours. May be in 24 hours 10 post are shown as popular and in another 24 hours another 5 post, but on the popular page all the post should be shown not only 5 post from this 24 hours but from previous 24 hours. Any suggestion how to write this code. or any plugins. I know the rules of this forum. I should not ask any plugin but any code is also recommended. But i can also go with plugins.


register_theme_directory somehow "fails" when folder is outside of WP-Folder

This is a simple skeleton for WordPress, that makes it possible to have just "themes" and "plugins" under version control: https://github.com/sourcerer-mike/WordPress-GIT-Skeleton When doing `register_theme_directory(__DIR__ . '/themes');` with a folder that is outside of WP, the theme is shown in the backend and can be activated. But when viewing the front end the page stays blank. I guess it's up to the folder being one level above and unreachable for the client. But the server can access it, so I think I've done something wrong. Is there any solution to have themes outside of WP but still working? (otherwise `register_theme_directory` is kind of useless) Or is there a better solution to have those two outside? (I also need to take care of not so experienced developer here) My folder structure is like this:               ├── plugins     ├── public (document root of apache)     │   ├── wp-admin     │   ├── wp-content     │   │   ├── plugins     │   │   └── themes     │   │       ├── twentyeleven     │   │       ├── twentyten     │   │       ├── twentythirteen     │   │       └── twentytwelve     │   │       └── twentyfourteen     │   └── wp-includes     ├── themes     │   └── foo     └── uploads      As soon as I change to theme "foo" the frontend stays white and empty (no single output).


Select Venue from dropdown list and reuse stored address information in meta_box

**UPDATED CODE 12/12/2011** Here is the code in functions.php. I put the code for output in my events page. For now there has been on output.               <?php     // Custom Meta Data for Events        $meta_box['event'] = array(         'id' => 'event-meta-details',         'title' => 'Event Information',         'context' => 'normal',         'priority' => 'high',         'fields' => array(             array(                 'name' => 'Start Date',                 'desc' => '(Enter yyyy/mm/dd)',                 'id' => 'start_date',                 'type' => 'text',                 'default' => ''             ),             array(             'name' => 'Venue',             'desc' => 'Venue of Event',             'id' => $prefix . 'event_venue',             'type' => 'radio',             'options' => array(                 array('name' => 'Spruce Gallery', 'value' => 'Spruce  Gallery'),                 array('name' => 'Pine Gallery', 'value' => 'Pine Gallery'),                 array('name' => 'Oak Gallery', 'value' => 'Oak Gallery')             )         )              )     );               ///////////////      function get_related_event_data( $venue, $field = 'all' ) {     $event_data = array(         'Spruce Gallery' => array(             'address' => 'Test Address 1',             'phone_no' => '344-333-2333',             'url' => 'http://www.url1.com'         ),         'Pine Gallery' => array(             'address' => 'Test Address 2',             'phone_no' => '444-333-3333',             'url' => 'http://www.url2.com'         ),         'Oak Gallery' => array(             'address' => 'Test Address 3',             'phone_no' => '555-666-6666',             'url' => 'http://www.url3.com'         ),     );     if( !isset( $event_data[$venue] ) )         return;          // Optionally return all fields(note: you can't echo arrays, so be sure to loop over the data if pulling all fields     if( 'all' == $field )         return $event_data[$venue];          if( !isset( $event_data[$venue][$field] ) )         return;          return $event_data[$venue][$field];     }          ///////////////      Here is the code I put on the page. I put in a test echo to make sure that the `$venue` was getting information and it is, but the address does not display.               <?php           $venue = get_post_meta( $post->ID, 'event_venue', true );     echo $venue;          echo get_related_event_data( $venue, 'address' ); ?>      Old Post. Here is the code that fills in my meta boxes.                // Custom Meta Data for Events        $meta_box['event'] = array(         'id' => 'event-meta-details',         'title' => 'Event Information',         'context' => 'normal',         'priority' => 'high',         'fields' => array(             array(                 'name' => 'Start Date',                 'desc' => '(Enter yyyy/mm/dd)',                 'id' => 'start_date',                 'type' => 'text',                 'default' => ''             ),             array(             'name' => 'Venue',             'desc' => 'Venue of Event',             'id' => $prefix . 'event_venue',             'type' => 'radio',             'options' => array(                 array('name' => 'Spruce Gallery', 'value' => 'Spruce  Gallery', 'venue_url' => 'http://www.sprucegallery.com/'),                 array('name' => 'Pine Gallery', 'value' => 'Pine Gallery'),                 array('name' => 'Oak Gallery', 'value' => 'Oak Gallery')             )         )              )     );      Here is the code for saving the information.               // Add meta boxes to admin panel only needs to be added once     add_action('admin_menu', 'plib_add_box');          //Add meta boxes to post types     function plib_add_box() {         global $meta_box;              foreach($meta_box as $post_type => $value) {             add_meta_box($value['id'], $value['title'], 'plib_format_box', $post_type,  $value['context'], $value['priority']);         }     }          //Format meta boxes     function plib_format_box() {       global $meta_box, $post;          // Use once for verification     echo '<input type="hidden" name="plib_meta_box_nonce" value="',  wp_create_nonce(basename(__FILE__)), '" />';          echo '
';          foreach ($meta_box[$post->post_type]['fields'] as $field) {     // get current post meta data     $meta = get_post_meta($post->ID, $field['id'], true);                echo '
'.                   ''. $field['name']. '	'.                   '';           switch ($field['type']) {               case 'text':                   echo '<input type="text" name="'. $field['id']. '" id="'. $field['id'] .'" value="'. ($meta ? $meta : $field['default']) . '" size="30" style="width:30%" />'. ' - '. $field['desc'];                   break;               case 'textarea':                   echo '<textarea name="'. $field['id']. '" id="'. $field['id']. '" cols="60" rows="4" style="width:97%">'. ($meta ? $meta : $field['default']) . '</textarea>'. '
'. $field['desc'];                   break;               case 'select':                   echo '<select name="'. $field['id'] . '" id="'. $field['id'] . '">';                   foreach ($field['options'] as $option) {                       echo '<option '. ( $meta == $option ? ' selected="selected"' : '' ) . '>'. $option . '</option>';                   }                   echo '</select>';                   break;               case 'radio':                   foreach ($field['options'] as $option) {                       echo '<input type="radio" name="' . $field['id'] . '" value="' . $option['value'] . '"' . ( $meta == $option['value'] ? ' checked="checked"' : '' ) . ' />' . $option['name'];                   }                   break;               case 'checkbox':                   echo '<input type="checkbox" name="' . $field['id'] . '" id="' . $field['id'] . '"' . ( $meta ? ' checked="checked"' : '' ) . ' />';                   break;           }           echo     ''.'
';       }            echo '
';          }          // Save data from meta box     function plib_save_data($post_id) {         global $meta_box,  $post;              //Verify nonce         if (!wp_verify_nonce($_POST['plib_meta_box_nonce'], basename(__FILE__))) {             return $post_id;         }              //Check autosave         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {             return $post_id;         }              //Check permissions         if ('page' == $_POST['post_type']) {             if (!current_user_can('edit_page', $post_id)) {                 return $post_id;             }         } elseif (!current_user_can('edit_post', $post_id)) {             return $post_id;         }              foreach ($meta_box[$post->post_type]['fields'] as $field) {             $old = get_post_meta($post_id, $field['id'], true);             $new = $_POST[$field['id']];                  if ($new && $new != $old) {                 update_post_meta($post_id, $field['id'], $new);             } elseif ('' == $new && $old) {                 delete_post_meta($post_id, $field['id'], $old);             }         }     }          add_action('save_post', 'plib_save_data');      `I want to save and reuse multiple data points about multiple venues in an event CPT with meta boxes. I have the CPT and meta boxes that can save the event venue that I enter as well as times and dates. The goal is to have a drop down list of venues. When one of the venues is selected then the information for that venue - Address, URL, Phone #, etc. would be selected as well. I planned to write out the information as an array but am not sure how to do that. Each time I try it doesn't work. What is the best way to store multiple points of information without having to type them in each time? Worst case I will make a `meta_key` for each bit of information and enter it by hand, but that seems like pointless data entry. There must be a better way. Thank you in advance.


Turn off image captions in gallery view?

I've set up my loop-attachment.php to show the gallery of thumbnails above the main, selected image using this code from the WordPress Codex:               <?php         $gallery_shortcode = '[gallery id="' . intval( $post->post_parent ) . '" size="mini-thumbnail" columns="10"]';         print apply_filters( 'the_content', $gallery_shortcode );     ?>      However, if the image has a caption, it shows up underneath its image, throwing off my neat little grid of images. I don't want to turn captions completely off or not use them at all, because after the grid and below the main 960x540 image, I want to do an "Image Summary" kind of section, with the filename, original size, caption, description, etc. Is there a way to turn off captions in the above code? The gallery shortcode section of the WordPress Codex doesn't have anything on it.


Registering AJAX callback function that is part of a class without instantiating the class in function.php

I'm not even sure if this is possible. But nevertheless I thought of asking. I'm in habit of wrapping/grouping AJAX calls for a particular need within a class. See below.               class my_class {         function __construct() {             $this->hooks();         }              function hooks() {             add_action('wp_ajax_my_action', array($this, 'my_action_callback'));         }              function my_action_callback() {             // do something         }     }      Now in order for the AJAX callback to work, I must add the following to `functions.php` (without wrapping it inside any function) to instantiate the class and make the callback work.               $my_class = new my_class;      This adds `$my_class` to the `global` namespace. Something that I would like to avoid. Any idea on how I can register the AJAX callback function without instantiating the class in `functions.php`?


Insert image in comment reply

I have searched everywhere but can not find a plugin that allows users to upload an image into their Reply to a comment. It is a photographic blog so has to have this ability. I did try a couple but none actually worked! Anyone any ideas please?


Exclude Random Redirect from caching?

* I have just deployed the W3 Total Cache plugin on my dedicated server (`moillusions.com`), but am not sure if it works already (server load still high).   * I have a very important random link generator: `moillusions.com/?random` yet am not sure how to exclude this from caching? (so it's always a different link when clicked)


Understanding wp_add_inline_style

I am trying to get my head round the wp_add_inline_style() function in WordPress.               //setting inline css.     function my_styles_method() {         wp_enqueue_style(             'custom-style',             get_template_directory_uri() . '/css/custom_script.css'         );             $color = get_theme_mod( 'my-custom-color' ); //E.g. #FF0000             $custom_css = "                     .mycolor{                             background: {$color};                     }";             wp_add_inline_style( 'custom-style', $custom_css );     }     add_action( 'wp_enqueue_scripts', 'my_styles_method' );      I understand most of it but I am not understanding this bit:               wp_enqueue_style(        'custom-style',         get_template_directory_uri() . '/css/custom_script.css'     );      Is this a dependency? or a blank css file so that code is written to it? If its dependant then why? I just want to load custom css into the theme so it can be more customisable. Thanks


Taxonomies specific to Page attribute template

Edit 2: So having worked a lot on this I have come along way and have a solution that indeed allows me to filter taxonomies by page template, however it isn't very DRY or very flexible. Ideally I would like to make this even more flexible so that I can use it to link several templates and taxonomies. The problem I ran into was that if I define the taxonomies array outside of the function it doesn't work even though I am passing it through as an argument. Im having one of those days where I have looked at this code for so long that I cant see the wood for the trees. Can anyone possibly help by giving some tips on refactoring this to make it more DRY. Thanks.               function create_taxonomy($name,$type = 'page') {         // create a new taxonomy         register_taxonomy(             strtolower( str_replace(' ','-', $name ) ),             $type,             array(                 'label'     => __( $name ),                 'sort'      => true,                 'args'      => array( 'orderby' => 'term_order' ),                 'rewrite'   => array( 'slug' => strtolower( str_replace(' ','-', $name ) ) )             )         );              //return strtolower(str_replace(' ','-', $name));          }               function case_study_taxonomy($template,$taxonomies){              $current_template = get_post_meta($_GET['post'], '_wp_page_template', true);              if ($current_template == $template){                  $taxonomies = array(                      create_taxonomy('Project Type'),                 create_taxonomy('System Finishes'),                 create_taxonomy('Client'),                 create_taxonomy('System Installer'),                 create_taxonomy('Architect'),                 create_taxonomy('Partnering Contractor'),             );                  foreach($taxonomies as $taxonomy){                      add_action( 'admin_menu', $taxonomy );                  }              }             }          case_study_taxonomy('template-case-study.php',$taxonomies);


Author_meta ONLY if it exists

I'd like to ONLY show the authors website link if it exists, but I can't work out the exact syntax for it. I have this                       if ( get_the_author_meta('user_url') ) : // If a user has filled out their decscription show a bio on their entries                   echo  the_author_meta('user_url');                  endif;      But I need to wrap it in a link and give that link a class, like this               <a class="meta-website" href="<?php the_author_meta('user_url') ?>">Author's Website      The problem is when I add another 'echo' before the_author_meta one it just breaks the site.


Get current url with parameters passed

How can I get the current url in a wordpress page? I have enabled clean urls, but I want the url without the clean urls. For example               http://example.com/?page_id=1      instead of               http://example.com/my-page


can't understand _e function well

<?php _e( $text, $domain ) ?>          $domain      (string) (optional) Domain to retrieve the translated text Default: 'default can't understand the second argument well. when i custom a theme, where the $domain's value shows on the theme, what value should i give it to.? could i write the $domain part optionally?i see some themes using its theme name as the $domain. but the document says **Domain** to retrieve the translated text.it's not a domain. why? some using other strings which doesn't have any relevance of the theme?


WP doesn't show Array Custom Fields?

I'm wondering why WordPress doesn't list PHP `array()` and any serialized data in Custom Fields in Admin Panel (for Pages, Posts etc.)? Only Custom Fields containing strings and numbers show up and can be edited by user manually. Edit: Why aren't post meta values displayed if they are stored as a non-string value, meaning, stored as either arrays or a serialized value ? Example: If a post has a meta key 'custom-meta' with a string value as 'yes', it is displayed in the meta box, but if it has an array value like `array('value' => 'yes')`, it is not displayed in the meta box. Can I enable this?


Rewrite wp-login.php URLS to static pages?

I'm struggling with getting a few things in WP to redirect. I'm using a front-end profile / profile editor, and I'm also using a front-end login/register. Naturally I would like to redirect the standard wp-login.php URLS to specific ones. Mainly : `http://www.mysite.com/wp-login.php?action=lostpassword => http://www.mysite.com/login/forgot/` `http://www.mysite.com/wp-login.php?action=register => http://www.mysite.com/register/` `http://www.mysite.com/wp-login.php , http://www.mysite.com/wp- login.php?action={anything} , etc => http://www.mysite.com/login/` I've tried to use RewriteRule's in my .htaccess file, namely : `RewriteRule ^login$ http://yoursite.com/wp-login.php [NC,L]` to test out rewrites, and nothing happened. I have also been somewhat unsuccessful with `add_rewrite_rule()` If anyone could point me towards the right direction, it would be much appreciated! Thanks, Tre


Remove Save Draft & Preview Buttions.. and also Statius: Draft & Visibility: Public

I want to remove the entire section that says Save Draft, Preview and Status: Draft and Visibility: Public. I want to not show it. Its ok if it is still fuctional. Attached is the part I do not want to display. Can someone show me how to do it? Here is the area I want to not display: http://kind.s3.amazonaws.com/removethissection.jpg


Schedule event every second thursday of the month

I'm working on an email system and they want it automated to send out emails every second thursday of the month. I've got the PHP sorted out and ready to fire a callback to send the emails, but I'm a complete newbie when it comes to cron and scheduling events. Essentially, I have this:               echo date('M d Y', strtotime('first thursday this month'));     echo date('M d Y', strtotime('-5 hours'));     if(date('MdY',strtotime('first thursday this month')) == date('MdY',strtotime('-5 hours'))){         send_emails();     }else{         echo 'DO NOT SEND EMAILS';     }      So it checks if the current day (-5 hours for timezone) is the 'second' thursday of the month (PHP bugs out and adds a week to the date). I'm not sure if that's what I'm going to need to do to schedule an event or what. Currently it runs when the plugin page is visited, but I'd like it to be its own process that runs regardless or not whether a page is visited. Any help is greatly appreciated! Thanks!


Using one WP_Query object within the loop of another WP_Query object

I'm creating two different WP_Query objects, one for each of two different post types I'm using. In creating my output, I'd like to loop through one of the objects, and at the same time loop through the other object as well, so I can output pieces of them together. Here's an example of what I'd like to accomplish:               $rotator_args = array(         'post_type' => 'rotator',         );          $rotator = new WP_Query($rotator_args);          $numrotators = $rotator->post_count;           $testimonial_args = array(         'post_type' => 'testimonial',         'posts_per_page' => $numrotators,         );          $testimonial = new WP_Query($testimonial_args);          while ( $rotator->have_posts() ) :          $rotator->the_post(); //setup the rotator posts         $testimonial->the_post(); //this breaks things, understandably         $rotator_image = get_the_post_thumbnail($rotator->ID, 'large');         $testimonial_image = get_the_post_thumbnail($testimonial->ID, 'large');         $return .= '
' . $rotator_image . '
';         $return .= '
' . $testimonial_image . '
';     endwhile;     return $return;      However, that doesn't work. Taking out `$testimonial->the_post();` (and the associated `$testimonial` related code) fixes things.


How to manipulate "add media" pop-up

Is there any way to add your own button next to "insert into post" button on the "add media" pop-up? I would like the button to add my own shortcode tags around the inserted image. The desired result:               [myshortcode][/myshortcode]      instead of just:


wp-content Folder Permissions (777 OK?)

I seem to be having issues with folder (and maybe file) permissions getting changed possibly by an FTP client. The WordPress install is using https. It started primarily with permissions in the wp-content/uploads folder not allowing anything to upload to the Media Library. Changing the uploads folder's permissions to 777 fixes this. Is there any risk in having the uploads folder and/or the entire wp-content folder permissions set to 777? I couldn't seem to find a clear answer at http://codex.wordpress.org/Changing_File_Permissions. Although I assume it changes from host to host.


get_categories hierarchical order like wp_list_categories - with name, slug & link to edit cat

I need to find a way to list all categories - empty or not - in a hierarchial list - like wp_list_categories - also showing the slug, cat name and a link to edit in the admin. Here is what I have so far:               $args = array(             'orderby'   => 'name',             'order'     => 'ASC',             'hide_empty'    => '0',       );          $categories = get_categories($args);          foreach( $categories as $category ) {               $cat_ID = $category->term_id;         $cat_name = $category->name;         #$cat_desc = $category->description; if ( !$cat_desc { $cat_desc = 'Nada!' } );         $cat_count = $category->count;              echo '
'.$cat_name.'';         echo ' / View ( '. $cat_count . ' posts )  ';         #echo ' / Desc: '. $cat_desc . '';         echo ' / Edit';         echo '
';            }      All is good, but not nicely ordered - just an alphabetical list.


why category__and and category__in wont work togather?

I am having an issue here. I want to get all the post that are related to the current post at the same time it will also have a common category term. for example: Post XYZ has categories car, Truck, and Bus. So i want to get any posts that have car or truck or bus at the same time it will also have category "Toronto" What would be the query?


Admin post list - adding an option to the date filter dropdown

I've been asked if I can add an option for "Today" and "Yesterday" to the date filter dropdown at the top of the post list in the WordPress admin view. (This is the list that shows recent month/years.) ![Date filter dropdown in post management list](http://i.stack.imgur.com/lns2d.gif) Does anybody know any filter or action hook I could use to add a couple of options to this list? People have discussed adding a whole custom list here and here, but how about adding an option to one of the default lists?


Can I use a Custom Meta Value inside of 'get_the_terms'?

I have a custom Page Template, and this is the code that I am trying to manipulate to change depending on a custom meta value that I write for specific Pages.               $terms = get_the_terms($post->id, 'custom-taxonomy' );      On the Page CPT, I have a custom meta field "Taxonomy Name", and the custom meta value is "Custom Taxonomy" What I am trying to do with the code above is:               $terms = get_the_terms($post->id, get_post_meta($post->ID,'metafield-taxonomy-name',TRUE) );      Obviously (through actually trying it ;)), that snippet doesn't work since the meta value is not passing through in quotes. Is there a way I can achieve this, so that 'get_the_terms' can be changed dynamically depending on the meta value that I give it? Thanks! Roc.


Wordpress address URL keeps dropping the www

My Wordpress Address (URL) in general settings keeps losing the www from the URL - I type in http://www.domain.com and it saves and works fine. Next time I go in the address has changed to http://domain.com. So again I change it, I get logged out and I log back in and it looks fine until next time and it has changed again. This is the only setting which changes (site address keeps the www) and I have checked my htaccess and cannot see anything untoward and there are no parked domains etc - any idea what could be causing this? Most of the time it doesn't cause any issues but sometimes when I visit the site it defaults to the non www version which could be detrimental to SEO as well as it affects my SSL for some secure pages as I only have the SSL for www.domain.com so I would like to fix it if I can.


How do you get a valid DateTimeZone when the user has it set to a custom timezone?

Taking a look at this question: How to get WordPress Time Zone setting?, I see that I can use               get_option('timezone_string');      to get a time zone string to use in my WordPress widget. I want to pass this string into a PHP DateTimeZone object, which I can do like this:               $dateTimeZone = new DateTimeZone(get_option('timezone_string'));     $dateTime = new DateTime("now", $dateTimeZone);      This works fine most of the time - HOWEVER, if the user is using the custom offsets under the Admin Settings menu (ie. UTC +8:00), then the timezone_string is empty, and the DateTimeZone throws an exception. I need to get a DateTime object that is local to the user's website, and UTC +8:00 IS a valid offset. So what can I do to get a local DateTime if they are using one of these time zones?


Why won't my custom widget stay in the sidebar after a reload?

After I drag my custom widget into a widget area and reload the page it's gone. Any ideas?               <?php         add_action('widgets_init','register_postTypeWidget');              function register_postTypeWidget(){             register_widget('postType_widget');         }              class postType_widget extends WP_Widget {             function postType_widget() {                   $widget_ops = array( 'classname' => 'postType_widget', 'description' => __('Display Posts by Post Type') );                   $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'postType_widget' );                   $this->WP_Widget( 'postType_widget', __('Posts by Post Type', 'postType_widget'), $widget_ops, $control_ops );               }              function widget($args, $instance) {                 extract($args);                  echo "hello world";                  }             function update( $new_instance, $old_instance ) {                        $instance = $old_instance;                      $instance['title'] = strip_tags( $new_instance['title'] );                 $instance['postTypeSelect'] = strip_tags( $new_instance['postTypeSelect'] );                 $instance['postTypeNumber'] = strip_tags( $new_instance['postTypeNumber'] );                 $instance['selectedPostTag'] = strip_tags( $new_instance['selectedPostTag'] );                 $instance['showDate'] = strip_tags( $new_instance['showDate'] );                 $instance['showAuthor'] = strip_tags( $new_instance['showAuthor'] );                      return $instance;                  }             function form( $instance ) {                 $defaults = array( 'title' => __(''), 'postTypeSelect' => __(''), 'postType_number' =>  __(''), 'selected_postTag' =>  __(''), 'show_date' =>  __(''), 'show_author' =>  __('') );             $instance = wp_parse_args( (array) $instance, $defaults);                     $args = '';             $output = 'object';             $post_types = get_post_types( $args, $output );             $posttags = get_tags();         ?>
                     <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title'); ?>                     <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />

                     <label for="<?php echo $this->get_field_id( 'postTypeSelect' ); ?>"><?php _e('Select Post Type'); ?>                     <?php                          echo '<select name="postTypeSelect" style="width:100%;">';                         echo '<option value="">Select Post Type</option>';                         foreach($post_types as $post_type) {                             if($instance['postTypeSelect'] == $post_type->name)                                 echo '<option value="'.$post_type->name.'" selected >'.$post_type->label.'</option>';                             else                                  echo '<option value="'.$post_type->name.'" >'.$post_type->label.'</option>';                         }                         echo '</select>';                     ?>

                     <label for="<?php echo $this->get_field_id( 'postTypeNumber' ); ?>"><?php _e('Number of Posts'); ?>                     <?php                          echo '<select name="postTypeNumber" style="width:100%;">';                         echo '<option value="">Number of Posts</option>';                         for($x=1; $x < 11; $x++) {                             if($instance['postTypeNumber'] == $x)                                 echo '<option value="'.$x.'" selected >'.$x.'</option>';                             else                                 echo '<option value="'.$x.'" >'.$x.'</option>';                         }                         echo '</select>';                     ?>

                     <label for="<?php echo $this->get_field_id( 'selectedPostTag' ); ?>" style="display:block;width:100%;"><?php _e('Show Only Posts with These Tags (optional)'); ?>                     <?php                         foreach($posttags as $postTag){                             if($instance['selected_postTag'] == $postTag->term_id)                                 echo '<input type="checkbox" name="selectedPostTag[]" value="'.$postTag->term_id.'" checked />'.$postTag->name.'
';                             else                                 echo '<input type="checkbox" name="selectedPostTag[]" value="'.$postTag->term_id.'" />'.$postTag->name.'
';                         }                     ?>

                     <label for="<?php echo $this->get_field_id( 'additional_options' ); ?>" style="display:block;width:100%;"><?php _e('Additional Options'); ?>                     <?php if($instance['show_date'] == 'show_date'): ?>                         <input type="checkbox" id="<?php echo $this->get_field_id( 'showDate' ); ?>" name="<?php echo $this->get_field_name( 'showDate' ); ?>" value="showDate" checked />Show Date
                     <?php else: ?>                         <input type="checkbox" id="<?php echo $this->get_field_id( 'showDate' ); ?>" name="<?php echo $this->get_field_name( 'showDate' ); ?>" value="showDate" />Show Date
                     <?php endif; ?>                          <?php if($instance['show_author'] == 'show_author'): ?>                         <input type="checkbox" id="<?php echo $this->get_field_id( 'showAuthor' ); ?>" name="<?php echo $this->get_field_name( 'showAuthor' ); ?>" value="showAuthor" checked />Show Author
                     <?php else: ?>                         <input type="checkbox" id="<?php echo $this->get_field_id( 'showAuthor' ); ?>" name="<?php echo $this->get_field_name( 'showAuthor' ); ?>" value="showAuthor" />Show Author
                     <?php endif; ?>
         <?php             }         }     ?>


Optimizing site speed by localizing paths

I read an article (which I didn't save) that argued you can improve the performance of your site by changing all file paths to full paths, so for instance, instead of `<img src="<?php bloginfo('template_directory'); ?>/images/headers/image.jpg" />` we go with `<img src="http://domain.com/.../images/headers/image.jpg" />`. My platform has its own theme, meaning that it will only be updated if we update it. So changing paths should not be an issue. Also, the article suggested that you do the same type of changes everywhere, e.g. script files, `functions.php`, plugins (if you can be bothered to redo it every time they update...). So the question is, how much performance will this improve? Surely sending less requests on a page load should make some very minor, but noticeable, improvement?


foreach error on false boolean from get_terms

I'm grabbing an array of page ids that were created in another function which I use regularly- that's all good. The issue I have is in the below function. Some pages have not been assigned an "interest" from the options in the interest taxonomy. Therefore the $terms array has some false booleans from the pages without terms. When the foreach runs into these false booleans a php error appears on the screen, although the loop continues running and works as expected in all other ways. How can I stop this error from showing up? I need some sort of error catcher for the false booleans but not sure how to go about it. Any advice is much appreciated!               foreach ($campids as $campid){                 $terms = get_the_terms($campid, 'interests');                      foreach($terms as $term){                     $camp_int = $term->name;                          if ($camp_int == $interest){ // include only camps with the correct location                         $camps[$i]['id']=$campid;                         $camps[$i]['interest']=$camp_int;                     }                 }                 $i++;             }


List first letter of categories - issue upon spcecial characters (danish letters)

I have a alphabetic list of custom taxonomies (Topics), all taxonomies are grouped by a index letter - A, B, C etc. The list uses the first letter of "Topic", to show as a index letter for each alphabetic group. The alphabetic groups works perfect, but when it shall show the Danish letters Æ, Ø and Å, I get faulty letters like � instead of Å. I the database is set to utf8_danish_ci and so is wp-config.php I really cannot figure out how to control $letter to show Æ Ø Å. Any help is much apreciated :) enter link description here Code used:               <?php $list = '';      $tags = get_terms( 'topic' );      $groups = array();     if( $tags && is_array( $tags ) ) {     foreach( $tags as $tag ) {     $first_letter = strtoupper( $tag->name[0] );     $groups[ $first_letter ][] = $tag;}     if( !empty( $groups ) ) {     foreach( $groups as $letter => $tags ) {     $list .= "\n\t" . '

' . apply_filters( 'the_title', $letter ) .'

';     $list .= "\n\t" . '
';     foreach( $tags as $tag ) {     $lower = strtolower($tag->name);     $name = str_replace(' ', ' ', $tag->name);     $naam = str_replace(' ', '-', $lower);     $list .= "\n\t\t" . '
'.$name.'
';     }}}}else $list .= "\n\t" . '
Beklager, men ingen emner blev fundet
';print $list;     echo "
";     ?>


Can't get pagination to work

I'm trying to create pagination on a blog post page where one page displays 13 blog posts and then displays some links to go to another page. Now just to get it working, I'm using this code:               <?php     /*     Template Name: Blog     */     ?>          <?php get_header(); ?>

                              <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                              <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
<?php the_title(); ?>

<?php the_tags('Tags: ', ', ', ''); ?>

                                    <?php endwhile; ?>                                <?php else : ?>

Not Found

Sorry, but the requested resource was not found on this site.

                              <?php endif; ?>
                               <?php $horizontalRuleCounter = 0; ?>                         <?php $verticalRuleCounter = 1; ?>                         <?php $postCounter = 0; ?>                          <?php $args = array( 'category_name=blog', 'posts_per_page' => 13 );                         $loop = new WP_Query( $args );                         while ( $loop->have_posts() ) : $loop->the_post();                             if ($postCounter == 0) { ?>

<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>

<time datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_time('F jS, Y'); ?></time> <?php _e("by", "bonestheme"); ?> <?php the_author_posts_link(); ?>
                                     <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail('bones-thumb-465'); ?>                                     <?php the_excerpt();                                      $postCounter = 1;                             echo '
';                             } else {                             echo '
'; ?>                                 <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail('bones-thumb-300'); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>

<time datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_time('F jS, Y'); ?></time> <?php _e("by", "bonestheme"); ?> <?php the_author_posts_link(); ?>
                                      <?php                                     echo '
';                                     meta('agent-title');                                      echo '
';                                 the_excerpt();                              echo '
';                                      if ($verticalRuleCounter % 2) {                                      ?>

                                     <?php                                 } else {                                 }                                                                  $verticalRuleCounter = $verticalRuleCounter +1;                                   if ($horizontalRuleCounter % 2) {                                      ?><img class="responsive" src="<?php echo get_template_directory_uri(); ?>/images/horizontalRule.png"><?php                                 }                                 $horizontalRuleCounter = $horizontalRuleCounter +1;                                 }                         endwhile; ?>                         <? // php wp_pagenavi(); ?>     <?php          global $paged;     $temp = $wp_query;     $wp_query = null;          $wp_query = new WP_Query( array('post_type' => 'post','posts_per_page' => 2, 'paged' =>     $paged ) );      while (have_posts()) : the_post();      // Your post content.     endwhile;     echo paginate_links( $args );     global $wp_query;          $big = 999999999; // need an unlikely integer          echo paginate_links( array(     'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),     'format' => '?paged=%#%',     'current' => max( 1, get_query_var('paged') ),     'total' => $wp_query->max_num_pages,     'prev_text'    => __('Previous'),     'next_text'    => __('Next')     ) );          ?>
                           <?php get_sidebar('blog'); // sidebar blog ?>

       Now it displays the links but when I click to go to the next page, it change the url but it still is displaying the posts from the first page. What am I doing wrong? Thanks in advance!


Wordpress javascript images

After moving to wordpress the images of weather cannot be retrieved even though the javascript code runs fine.Here is the code that i am using to retrieve images in javascript:               customIcons: 'files/img/icons/weather/' .       Your help would be appreciated.


wp_trash_post retrashes already trashed comments?

I have a few mail- and update_user_meta functions that fires when a post, comment or child comment gets thrashed. So when I trash a comment with trash_comment, a mail get sent to the author: "Hey, your comment got trashed." Cool, it works well. But... When I trashed the related post... The author of the already thrashed comment gets the exakt same mail once more. This function removes a point from the authors score list a post where they have commented gets moved to the trash-bin:               // Remove 1 point if their comment get moved to the "pre-trash-bin"     function trashed_comments_points_delete( $post_id, $statuses ) {              if ( is_array( $statuses ) ) {                  foreach ( $statuses as $comment_id => $status ) {                      deleteAPointFromUser( $comment_id );                 authorPOSTCOMMENTnotification( $comment_id );                  }              }          }     add_action( 'trashed_post_comments', 'trashed_comments_points_delete', 10, 2 );      Here's the mail function:               // Mail author when their comment is sent to "pre-trash-bin" when question is trashed     function authorPOSTCOMMENTnotification($comment_id) {       $comment = get_comment($comment_id);       if ( $comment->comment_parent != 0 ) return;      $author = get_userdata($comment->user_id);        $headers = "MIME-Version: 1.0" . "\r\n";        $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";        $headers .= "From: Blabla.com <noreply@blabla.com >" . "\r\n";        $subject = "Your comment got trashed";           $message = "Your comment got trashed";             wp_mail($author->user_email, $subject, $message, $headers);     }      wp_trash_post function:               // Delete 1 to the current Point Score     update_user_meta($authorid, 'points', $currentQPointNumber-1);       }     add_action('wp_trash_post', 'deletePointFromUser');          // Mail author when their questions is deleted/trashed     function authorNotification($post_id) {        $post = get_post($post_id);         // Only if it's a post         if( $post->post_type != 'post' ) return;        $author = get_userdata($comment->user_id);        $headers = "MIME-Version: 1.0" . "\r\n";        $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";        $headers .= "From: Blabla.com <noreply@blabla.com >" . "\r\n";        $subject = "Your post got trashed";          $message = "Your post got trashed";             wp_mail($author->user_email, $subject, $message, $headers);               }     add_action('wp_trash_post', 'authorNotification');      So the actions gets called twice, thus the user ends up losing two points instead of one. Basically, I don't want to send a mail or update the user meta when a comment that has already been trashed, is being trashed again when trashing a post. Any ideas?


Search template content

I have used templates for each page created from wp backend for my site. Like, e.g, Template named 'about' for 'About Us' page. On the template I retrieve posts of specific category using WP Query. I have used Ajaxy Live Search plugin for search functionality. The problem I am facing is that, the content that is displayed from the template is not considered during search. But the text that is directly put in page is available for search. Please suggest me a way to get data from templates searched as well.


Loop spesific category title + Foundation reveal

I would like to make a list of a spesific post category title. In this list I want the reveal function from Foundation to open the post + its title. How do I make this? I'm kinda new to making loops and builing custom things in the function-area. This is the code of the list right now:

1

2

      Would be great with some help (:


Prevent Menu Shortcode From Formatting

I'm trying to insert shortcodes into menu links (as I need to display a latest post link). I've figured out how to get the do_shortcode part done.   However, when I insert a shortcode as the menu link [latest_posts var="val"], it immediately gets formatted like so http:(forward-slash forward- slash)latest_postsvar=val. I'm using 3.5.1, and I was wondering what is the filter/action I can use to disable this.


use both type of permalink in my theme

How to use one type of permalink `/%category%/%postname%/` for some posts and to use `/sample-post/` for some other posts. If I had this link like:               (website_name == codedesign) Do you want to learn jQuery?      show as               http://example.com/codedesign/jquery/learn-jquery           any thing about phpmyadmin. >>       show as               http://example.com/codedesign/phpmyadmin      Can we do any thing like this, or we can just use one type of permalink? The pourpose of this question is: Some times I have posts with out any category, I mean no category related to them, so they will get under the uncategorized category. I don't want the user see this: `Uncategorized"` and just see the post name when the posts is filed under the `uncategorized` category.


Custom code for WordPress dynamic menu

Without using plugins, how can I create a custom WordPress navigation menu to produce the following code?

What We Do

What We Do

What We Do

      For `class="bottom_section_full"` I want to use `ul`, and for `class="bottom_part"` I want to use `li`. I also want to use a field for images. Is possible to build a dynamic menu like this in WordPress?


What can I replace '.get_bloginfo('url').' with to return the current URL rather than the home address?

I am using the Any Mobile Theme Switcher plugin to switch between full and mobile themes automatically. The only problem with it is that the 'switch to mobile site' and 'switch to full site' links takes you to the home page instead of the current page. The relevant bit of code seems to be this:               function show_theme_switch_link_func( $atts ){             $desktopSwitchLink      = get_option('show_switch_link_for_desktop');             global $shown_theme;             global $status;             if ($shown_theme){                     $return = ''.get_option('desktop_view_theme_link_text').'';             } else {                     if ((!empty($status)) || ($desktopSwitchLink == 'yes')){                             $return = ''.get_option('mobile_view_theme_link_text').'';                     }             }             return $return;     }      Can I replace `'.get_bloginfo('url').'` with something that will return the current URL instead of the home address?


Change Default Content when Creating a Post based on Previous Category Choice

I'm working on a system that forces users (unfamiliar with wp) to choose a category before creating a new post, and then adds some appropriate html layout styling to help them. The following code works if they choose category "x". How can it be adapted to cope with a couple of alternative category situations? Human Code Required:   * If the new post is category X: add this html.   * If the new post is category Y: add this html instead.   * If the new post is any other category: add this html. Existing Code - Inserts some html to new posts if the category is "X":               // This function will only be called when creating an empty post,     // via `get_default_post_to_edit()`, called in post-new.php     function wpse14403_wp_insert_post( $post_id )     {         wp_set_post_categories( $post_id, $_REQUEST['category_id'] );     }          add_filter( 'default_content', 'wpa70073_default_products_content' );          function wpa70073_default_products_content( $content ) {              // change this to your desired category ID         $products_category_id = 4;              if(              isset( $_REQUEST['category_id'][0] )             && $products_category_id == $_REQUEST['category_id'][0]              )             return 'some html styling';     }      UPDATE: Tried adding this to the end, but it didn't work...               // change this to your desired category ID          $products_category_id = 4;................              if(              isset( $_REQUEST['category_id'][0] )             && $products_category_id == $_REQUEST['category_id'][0]              )             return 'Some html styling';              if ( $products_category_id = '6' ) {             return 'Some alternative html styling';         } else {             return 'Some default html styling';         }     }      Also tried editing the code along the lines of the cpt thread suggested below, but again no luck :(               add_filter( 'default_content', 'wpa70073_default_products_content' );     function wpa70073_default_products_content( $content ) {         switch($content->category){             // change this to your desired category ID             case'4':                 $content='cat 4 content';                 break;             case'6':                 $content='news content';                 break;             default:                 $content='default content';                 break;         }         return $content;     }


Can't create new CPTs when menu hidden

I am adding a large number of custom post types and taxonomies so it is often visually clearer if I DO NOT have them all added to the admin menu's top level. Instead I would prefer to add them under an appropriate sub-menu. I have done that without too much effort with this two step approach:   1. Hiding CPT using the 'show_ui' property when registering the CPT   2. Adding them back in using the add_submenu_page() call For instance, here's an example of the the add_submenu_page call for a CPT called "companies":               add_submenu_page (LG_ADMIN_MENU,"Companies","Companies","manage_options",'edit.php?post_type=companies');      By taking these two steps I can now view the CPT, I can modify existing attributes, I can even delete a record but what I can't do is add a record. When I click on the "Add New" button it comes back with a white screen that only says "Invalid post type". Now if I simply turn on the normal top-level menu (leaving all other settings alone), I get the menu now showing up both as a submenu (from my add_submenu_page call) and as a top-level menu (because I've turned that back on with "show_ui". I can then add new items with no problem.


Is it necessary to use wp_reset_query() in a WP_Query call?

I'm using the following code to retrieve posts:               <?php     $featuredPosts = new WP_Query();     $featuredPosts->query('showposts=5&cat=3');     while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?>

     By <?php the_author() ?>

     <?php the_excerpt(); ?>
     <?php endwhile; ?>      Do I need to use `wp_reset_query()` If I have to use it where should I place it?


How to run JS, PHP and etc. inside WP post?

I would like to try little web apps with WordPress. Just to accept some values for few fields and present the output using AJAX. What are all the necessary modifications on WordPress? So, far I've tried some plugins like exec-php. But, I am in need of a better advice/suggestion.


Replacing select2 in admin backend for all selects

I originally posted this question as a javascript question here, but think maybe it would be better asked here. I tried adding select2 to all wordpress admin screens. However, since many selects are created dynamically, I needed to find a way to recognize the dynamic selects. I got it working, but the dynamic selects do not load with the right width and positioning. Take for example the http://example.com/wp-admin/edit.php page. When clicking quick edit, select2 does not find the correct width and positioning of the new selects. If you look at the source, you can see that the dropdown with the following style attributes:               style="width:0; top:0; left:0;       Because of this, it doesn't show when you click on it. However, if you click on a new select and then click again right below it, it updates the styles, but now moves the select2 overlay just to the right of the selects. Here is an example plugin if anyone wants to test it followed by some screenshots:               <?php          /**      * Plugin Name: Admin Select2 Not Working Everywhere      * Plugin URI:       * Description: Adds select2 to all admin screens      * Version: 1.0      * Author: Bryan Willis      * Author URI:       * License: GPL2      */          function enqueue_select2_jquery() {         wp_register_style( 'select2css', 'http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.css', false, '1.0', 'all' );         wp_register_script( 'select2', 'http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js', array( 'jquery' ), '1.0', true );         wp_enqueue_style( 'select2css' );         wp_enqueue_script( 'select2' );         }     add_action( 'admin_enqueue_scripts', 'enqueue_select2_jquery' );          function select2jquery_inline() {         ?>     <style type="text/css">     .select2-container {margin: 0 2px 0 2px;}     .tablenav.top #doaction, #doaction2, #post-query-submit {margin: 0px 4px 0 4px;}     </style>             <script type='text/javascript'>     jQuery(document).ready(function ($) {        $("select").select2();         $( document.body ).on( "click", function() {             $("select").select2();           });     });     </script>            <?php      }     add_action( 'admin_head', 'select2jquery_inline' );       ![enter image description here](http://i.stack.imgur.com/w5p79.png) ![enter image description here](http://i.stack.imgur.com/z4HKp.png) ![enter image description here](http://i.stack.imgur.com/IMxFz.png) ![enter image description here](http://i.stack.imgur.com/KLOdz.png)


Jquery integration with my theme

I want to add a slide side ways jquery to my website, I tried the following code, but seems not to be working Jquery code:-                                        Div & CSS code:
                 Content
Contact me

Hello

Welcome to my Blog

      When I tried the above code into my header file, and the div code in the footer file, The DIV box appears to be slided outside but doesn't goes inside , the jquery is not working and the image contact_tab.gif is not displayed and my google maps on my website doesn't loads, I know this is because of wrong integration of jquery but I don't know how to integrate it with wordpress themes


custom image size with New Media Manager in wordpress 3.5

The last update broke my workflow, as the method of using custom image size inside the media manager has definitely changed. i'm trying to add my previously registered image sizes to the new dropdown.


Finding and disabling 'rogue' stylesheet from header: Source Sans Pro

I just recently set up a local WordPress development environment and imported the content from the live site into it using WordPress' built-in export and import functionality. Unfortunately, this showed up in the header, and is making the local site extremely slow when working offline:               <link rel="stylesheet" id="open-sans-css" href="//fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&subset=latin%2Clatin-ext&ver=3.8.1" type="text/css" media="all">      I'm fairly certain I remember adding this reference to a theme several months ago in its dedicated "Theme Settings" section of the admin interface. Said theme is no longer installed, and I can't even recall its name. I've gone through and searched all the current theme's files just to make sure that I hadn't added this to the current theme and simply forgotten; and, no, I hadn't. My question: How can I discover what is adding this reference; and, more importantly, remove it?


Add popup window to TinyMCE buttons

I'm looking for a good tutorial on how to create a popup window with a TinyMce button that would allow the user to select from multiple options, enter text into inputs, etc. I know how to create a button that displays a single prompt window, but that's about it and I've been searching for hours. Anyone know some links? Thanks!


Is there a plugin for posting inline comments, like in MS Word?

I want to make a cookbook style wordpress website, on which visitors can place comments inline. Like you do in a paper book with a pen: between the lines. Or like how MS Word handles comments. Does anyone know a plugin that makes this possible? I've searched and searched, but all I found was this and it was of no use: http://stackoverflow.com/questions/196993/wordpress-having-comments-inline- ajax-like-in-stackoverflow I don't get it to work and the developers page is nothing more than a logo.


Settings API - save an array of options as one setting (array_push?)

## 1. Basic settings API callback. Using Settings API my $sanitize_callback validating function looks like:                   (...)         if($type == "foo") {            $valid_input[$id] = $option[$id];         }                else if($type == "bar") {            $valid_input[$id] = wp_filter_nohtml_kses($input[$id]);         }          (...)      It's almost the same as in this great theme by Chip Bennett: https://github.com/chipbennett/oenology/blob/master/functions/options- register.php#L95 ## 2. Avoiding option updating. After form submit all options are being updated and it's values are being overwritten with $input. What if I don't want to update one of them (let's say it's `$type` is `multiple_settings`) but instead create an array and add new options to it? How do I do that? I was trying things like:                   else if($type == "multiple_settings") {            $valid_input[$id][] = $input[$id]; // creates an array but still overwrites            $valid_input[$id] = array_push($valid_input[$id], $input[$id]); //returns NULL          }       With no luck. **[edit]** Maybe it has something to do with the way I save my settings (return of validation function below)?                   $options = get_option('XX_theme_settings');          $valid = array_merge($options,$valid_input);         return $valid;       Thanks!


How to use a variable as a function name?

I'm trying to loop a function that will let users create a few custom posts, but I have a problem with the function name. Here is an example: How can I write this:               function register_cpt_1_mdframework_price(){      … like this:               function $myvar(){      This is how I solved it, but it's neither nice nor clever – any better idea?               <?php         $numcpost = of_get_option('how_many_custom_posts');         do {             switch ($numcpost){                 case 1:                     require_once MDCP_DIR . 'cpost/cpostloop1.php';                     break;                 case 2:                     require_once MDCP_DIR . 'cpost/cpostloop2.php';                     break;                 case 3:                     require_once MDCP_DIR . 'cpost/cpostloop3.php';                     break;                 case 4:                     require_once MDCP_DIR . 'cpost/cpostloop4.php';                     break;                 case 5:                     require_once MDCP_DIR . 'cpost/cpostloop5.php';                     break;             };         --$numcpost;     }while ($numcpost > 0);      ### File: cpostloop1.php               <?php         $numcpost = 1;         add_action( 'init', 'register_cpt_'.$numcpost.'_mdframework_price', $numcpost );         $singcpost = of_get_option('custom_posts_name_s_n'.$numcpost.'');         $plurcpost = of_get_option('custom_posts_name_p_n'.$numcpost.'');         $desccpost = of_get_option('custom_posts_name_d_n'.$numcpost.'');         $imgcpost = of_get_option('custom_posts_name_i_n'.$numcpost.'');         function register_cpt_1_mdframework_price(){             $labels = array(                  'name' => _x( $plurcpost, 'mdframework_custom_created_post'.$numcpost.'' ),                 'singular_name' => _x( $singcpost, 'mdframework_custom_created_post'.$numcpost.'' ),                 'add_new' => _x( 'Add New', 'mdframework_custom_created_post'.$numcpost.'' ),                 'add_new_item' => _x( 'Add New'.$singcpost.'', 'mdframework_custom_created_post'.$numcpost.'' ),                 'edit_item' => _x( 'Edit'.$singcpost.'', 'mdframework_custom_created_post'.$numcpost.'' ),                 'new_item' => _x( 'New'.$singcpost.'', 'mdframework_custom_created_post'.$numcpost.'' ),                 'view_item' => _x( 'View'.$singcpost.'', 'mdframework_custom_created_post'.$numcpost.'' ),                 'search_items' => _x( 'Search'.$plurcpost.'', 'mdframework_custom_created_post'.$numcpost.'' ),                 'not_found' => _x( 'No '.$plurcpost.' found', 'mdframework_custom_created_post'.$numcpost.'' ),                 'not_found_in_trash' => _x( 'No '.$plurcpost.' found in Trash', 'mdframework_custom_created_post'.$numcpost.'' ),                 'parent_item_colon' => _x( 'Parent '.$singcpost.':', 'mdframework_custom_created_post'.$numcpost.'' ),                 'menu_name' => _x( $singcpost, 'mdframework_custom_created_post'.$numcpost.'' ),             );             $args = array(                  'labels' => $labels,                 'hierarchical' => true,                 'description' => $desccpost,                 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),                 'taxonomies' => array( 'category', 'post_tag', 'page-category', 'high', 'middle', 'low', 'special', 'last_minute' ),                 'public' => true,                 'show_ui' => true,                 'show_in_menu' => true,                 'menu_position' => 5,                 'menu_icon' => $imgcpost,                 'show_in_nav_menus' => true,                 'publicly_queryable' => true,                 'exclude_from_search' => false,                 'has_archive' => true,                 'query_var' => true,                 'can_export' => true,                 'rewrite' => true,                 'capability_type' => 'post'             );         register_post_type( 'mdframework_custom_created_post_'.$numcpost.'', $args );         }


Trending Topics Plugin

I am looking for a trending topics plugin as displayed on techcrunch. I have searched alot to find the vertical displaying plugin. If anyone could help out, I would be very thankful. ## EDIT: Here is a visual image of how it should look like. ![enter image description here](http://i.stack.imgur.com/oxi92.png)


Get all children of custom post type using get_pages

I am using the `get_pages` function to display all pages within my custom post type, like this:               <?php                     $args = array(                         'post_type'    => 'pcct_product',                         'sort_column'  => 'post_title',                         'menu_order'   => 'ASC'                     );                          $pages = get_pages($args);                      foreach ( $pages as $pagg ) {                     $option = '<option value="' . get_page_link( $pagg->ID ) . '">';                     $option .= $pagg->post_title;                     $option .= '</option>';                     echo $option;                 }                 ?>      I want to be able to display ONLY the children in this custom post type. Has anyone got any suggestions of how I can go about that?


MySQL Syntax Error upon restoring database from backup

Performed a bad import to my Wordpress install and decided to restore from the mqSQL backup (full export) I had made minutes earlier. Dropped all tables in the database and then did an import from my .sql file. I encounter the error below in PHPmyAdmin and find that only 22 of my 44 tables were imported, so I assume the import was aborted. Was my MySQL db backup corrupt or something? The export/download seemed to go smoothly. My error is #1064, You have an error in your SQL syntax, check the manual... (see image) Charset appears to be UTF-8 and I'm importing in UTF-8               -- Host: localhost     -- Generation Time: Apr 15, 2013 at 07:01 PM     -- Server version: 5.5.23     -- PHP Version: 5.2.17          SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";     SET time_zone = "+00:00";               /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;     /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;     /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;     /*!40101 SET NAMES utf8 */;      ![sql import error](http://i.stack.imgur.com/Y8UsM.png)


Automatically add this attribute to the gallery shortcode

When inserting a gallery it adds the following shortcode:               [gallery columns="6" ids="18,150,146,23,147,17,21,20,22"]      I would like it to automatically add link="file" as the last attribute, whenever a shortcode is added. Like so:               [gallery columns="6" ids="18,150,146,23,147,17,21,20,22" link="file"]


Unable to use Custom RSS Feeds because of wrapper.php conflict

Since the implementation of `wrapper.php` in my WP theme, we are unable to remove the `header()` and `footer()` from the custom page template, causing a header already sent error. The Feed: http://yoast.com/custom-rss-feeds-wordpress/


How do I use wp_editor() in widget form?

I'm trying to use the built-in Rich-text (wp_editor()) editor in Wordpress for my widget, but I can't seem to find any simple way to use it.. I know you can use it, as Black Studio TinyMCE can do it, but how? **My form function**               function form($instance)     {         $instance = wp_parse_args((array) $instance, array( 'box1' => '', 'box2' => '', 'box3' => '', 'box4' => '' ));         $box1 = $instance['box1'];         $box2 = $instance['box2'];         $box3 = $instance['box3'];         $box4 = $instance['box4'];         $boxqty = $instance['boxqty'];          ?>
<label for="<?php echo $this->get_field_id('boxqty'); ?>">Number of blocks: (1-4) <input class="widefat" id="<?php echo $this->get_field_id('boxqty'); ?>" name="<?php echo $this->get_field_name('boxqty'); ?>" type="text" value="<?php echo attribute_escape($boxqty); ?>" />

<label for="<?php echo $this->get_field_id('box1'); ?>">Box 1:          <textarea class="widefat mceEditor" id="<?php echo $this->get_field_id('box1'); ?>" name="<?php echo $this->get_field_name('box1'); ?>">  <?php echo $box1; ?></textarea>

<label for="<?php echo $this->get_field_id('box2'); ?>">Box 2:            <textarea class="widefat" id="<?php echo $this->get_field_id('box2'); ?>" name="<?php echo $this->get_field_name('box2'); ?>"><?php echo $box2; ?></textarea>

<label for="<?php echo $this->get_field_id('box3'); ?>">Box 3:      <textarea class="widefat" id="<?php echo $this->get_field_id('box3'); ?>" name="<?php echo $this->get_field_name('box3'); ?>"><?php echo $box3; ?></textarea>

<label for="<?php echo $this->get_field_id('box4'); ?>">Box 4:            <textarea class="widefat" id="<?php echo $this->get_field_id('box4'); ?>" name="<?php echo $this->get_field_name('box4'); ?>"><?php echo $box4; ?>      </textarea>
     <?php        wp_editor('Test text', 'test-editor');     }


Rename attachments during upload no matter what filetype

Here's the function I use for WP to rename images during upload on the fly and set the image's filename to match the post slug.               function wpsx_5505_modify_uploaded_file_names($arr) {          // Get the parent post ID, if there is one     if( isset($_REQUEST['post_id']) ) {         $post_id = $_REQUEST['post_id'];     } else {         $post_id = false;     }          // Only do this if we got the post ID--otherwise they're probably in     //  the media section rather than uploading an image from a post.     if($post_id && is_numeric($post_id)) {              // Get the post slug         $post_obj = get_post($post_id);          $post_slug = $post_obj->post_name;              // If we found a slug         if($post_slug) {                  $random_number = rand(10000,99999);             $arr['name'] = $post_slug . '-' . $random_number . '.jpg';              }          }          return $arr;          }     add_filter('wp_handle_upload_prefilter', 'wpsx_5505_modify_uploaded_file_names', 1, 1);      I am trying to modify this function so that it's no longer limited to images only (in this particular case, for example, I want WP to rename both images and mp3's during upload), and can't get it to work. Another issue with this function is that it only successfully renames attachments if the post was published prior to uploading attachments. WP autosaves posts almost immediately after filling out the post title field, the post slug is created at that moment, so why is publishing the post a necessary step? Would there be a way to modify this function to make it work with just autosave? Thank you very much in advance for your help.


How to enqueue the style using wp_enqueue_style()

I'm developing a theme. I added the codes (below) into the `header.php`. But I posted it into the WP theme repository, and it's under review, and the reviewer informed me to enqueue the style with `wp_enqueue_style()`/ `wp_enqueue_script()`. But can't understand how to implement it with the function. I've seen the directed `wp_enqueue_style();` in Codex, but can't understand how to put the whole bunch of codes with their conditions.               <style type="text/css">     <?php     // If the menu presents, then CSS loads          if ( has_nav_menu( 'secondary' ) ) {     ?>     .sec-menu{     width: 100%;     background: #333;     height: 26px;     font-size:16px;     text-transform:uppercase;     }     <?php } ?>     <?php     if ( has_nav_menu( 'primary' ) ) {     ?>     #access{     background-color: #333;     height: 26px;     }     <?php } ?>     <?php     if ( !has_nav_menu( 'primary' ) && !has_nav_menu( 'secondary' ) ) {     ?>     .sec-menu,     #access{     border-bottom: 2px solid #333;     }     <?php } ?>     </style>        * HOW TO?


Why html tags are being appended to my pictures?

I have a WordPress Network installation. In main site, there is no problem (at least related to on I'm talking about it here) but meanwhile in the other site (my subdomain site) pictures appear to be gone! Actually They are corrupt and when I opened one of them, I found some html codes are appended to them. This problem has been occurred to me before. If I re-update the WordPress and then all sites, the problem seems to be solved but, after some time it will show up again. Some month ago I had this problem and couldn't find a solution. Time passed and it went by itself or maybe some WordPress updates made it gone. I checked plugins last time and deactivating them was no help. This is the HTML code appended to pictures.
..


How to hide sub categories in sidebar

i want to hide subcategories in widget sidebar . just in widget sidebar i was added in style.css this code               .children { display:none;}      but this code do hide to the threaded comments what is the way to hide just sub categories in sidebar


Add logo in navigation bar before menu items in twenty thirteen?

I am customizing the twenty thirteen theme and want to add a logo image in the navigation bar before menu items like this link. I have tried different approaches but didn't work. Would appreciate any suggestions in this regard.


Automatically increase comment karma on comment save

I don't know why, but it seems like the comment karma column is not used very much in plugins or otherwise. What would I need to do to hook into adding points to the comments karma column when a logged in user saves a comment?


JSON API not showing full content

I am trying to create a Windows Store App using IdeaPress (https://github.com/ideanotion/ideapress/issues), which relies on the JSON API Plugin (http://wordpress.org/extend/plugins/json-api/other_notes/). Unfortunately requesting recent_posts returns just content up to the               <!--more-->       tag. I'd like to display the whole post, though. Any ideas on how to do this? This is my json code: http://wp7app.de/api/get_recent_posts/?dev=1


How to use hyperdb to separate and share a user dataset between wordpress installs?

I'm looking for a way to separate my users and usermeta table to be in a different database than my main WP install. The end goal is sharing these table over a number of WP installs. From what I read, HyperDB should allow for this, however their documentation is a little sparse when it comes to creating and linking datasets --- which is where I believe I should be looking. I've tried something along the lines of this without success:               $wpdb->add_database(array(         'host'     => DB_HOST,         'user'     => DB_USER,         'password' => DB_PASSWORD,         'name'     => 'my_user_db_name',         'write'    => 0,         'read'     => 1,         'dataset'  => 'user',         'timeout'  => 0.2,     ));          $wpdb->add_table( $user, $wpdb->base_prefix . 'users' );     $wpdb->add_table( $user, $wpdb->base_prefix . 'usermeta' );      But this wasn't successful. Any help would be appreciated. Thanks in advance. ~Cam


One post out of more than twenty shows odd picture (from post) in the header

(WP 3.5.1) My blog has a header picture showing its name. But for some reason exactly one post shows a picture in the header which is actually used within the post itself. http://www.joyofdata.de/blog/frequency-of-character-combinations/ I don't even know how I would acomplish such feat if I wanted - given that the header code as far as I know is included from header.php and hence keeps the same references in every single post... How do I find out what the reason is, so I can change the header image back to the right one !? * * * ![enter image description here](http://i.stack.imgur.com/YObwe.png) * * * ![enter image description here](http://i.stack.imgur.com/IaZdt.png)


WooCommerce Product Page Loop - Output All Product Thumbnails

http://69.89.31.200/~horologi/shop/      I'm working on the site above and the client has requested that on the shop page, all the product information is displayed on that page, including all product thumbnails. I have copied the WooCommerce template files into my theme directory so I can modify them, and have been messing around with the loop- shop.php file. What I tried first was simply adding the following code into the product page loop:
          <?php if ( has_post_thumbnail() ) : ?>              <a itemprop="image" href="<?php echo wp_get_attachment_url( get_post_thumbnail_id() ); ?>" class="zoom" rel="thumbnails" title="<?php echo get_the_title( get_post_thumbnail_id() ); ?>"><?php echo get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) ) ?>          <?php else : ?>              <img src="<?php echo woocommerce_placeholder_img_src(); ?>" alt="Placeholder" />          <?php endif; ?>          <?php do_action('woocommerce_product_thumbnails'); ?>      I pulled that code from the product-image.php file. Unfortunately it outputs the thumbnails full-size. I wasn't sure of the 'best practice' way of doing this. Any help is greatly appreciated. Thank you!


How To Make Sure That My Action Hook Executes Last

How can I make sure that `my_function` action hook on 'wp_head' is executing last? One hack, that I'm using, is to give `999999` (a big number) as the third argument. But maybe some other hook on 'wp_head' is giving even bigger number than this one.               function my_function() {         ?>         <style>             .custom-class{                       background: blue;             }         </style>         <?php        }     add_action('wp_head', 'my_function', 999999);


Change wordpress Multisite default site from side id 1 to side id 2

I have a multsite installation with canonical setup like `site1.domain.com` and `site2.domain.com` etc. How do I change the default root site from site `1` to site `2`? I tried to change these two values in `wp-config` to `5` instead of `1` and there was no effect:               define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      Is there a tutorial out to do this?


Perform action on WPMU blog deletion

Hi guys :) I know there is the `wpmu_new_blog` action hook which enables us to perform an action when a new WPMU blog is created. Is there something similar to this which enables us to perform an action when a WPMU blog is deleted? Something which looks like this: `add_action('blog_deletion_hook', 'function_to_perform')`


Ajax not working for logged in users

I have this plugin "DWQA" in which the ajax calls work perfectly fine when the user is not logged into the site. But the moment user logs in to the site the ajax calls dont work. The variables that are passed to the admin-ajax.php return null. How does ajax call differ in wordpress in case of logged in and logged out users ? Any way to make them same if yes ?


Difference between get_userdata() and get_currentuserinfo()

I've already read the WordPress documentation for those functions, but is still unclear for me where is the difference between: `get_userdata()` vs `get_currentuserinfo()` As far as I know the `get_userdata()` require a parameter such as `user_id` or something else that's all, and `get_currentuserinfo()` does not. Am I wrong?


Need Random Category Nav Menu

I have set my category navigation menu to display home and 5 of my categories and their respective posts when the category tab is clicked, as that is all the space there is to display in the menu bar. I have more than 20 categories and I want the 5 category tabs to randomly display the categories on each browser refresh, so that all categories have a random chance to get displayed within the 5 category tabs. The menu code in my header template is currently :-

             <?php if ( is_home() ) { ?>
<a href="<?php echo get_option('home'); ?>" rel='nofollow'>Home
             <?php } else { ?>
<a href="<?php echo get_option('home'); ?>"rel='nofollow'>Home
             <?php } ?>     <?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-header' ) ); ?>
      which displays the standard category menu. How can I achieve this?