Setting post_id for single.php based on URL without a redirect

I'm migrating a Joomla! database to Wordpress and the website has to remain exact regarding URLs. The Joomla site has its posts with .html extensions, and the importer I created maps the Joomla file URL to the Wordpress post_name as such: joomla-site.com/Title-of-Joomla-Content.html -> Wordpress DB::post_name title- of-joomla-content I can access right-out-of-the-box the post on the Wordpress install by of course: wordpress-site.com/Title-of-Joomla-Content But I need to change how the permalink system responds. I don't want to use a redirect (which shows in headers), so I'm trying to hook in a function that will select the post ID differently if the URL ends with .html. Since Wordpress only is activated when a file is not found, real .html files are unaffected. So having a blanket check and change function for any .html files isn't a problem. I've attempted this:               function custom_redirect() {      global $post_id,$wpdb;      if (substr($_SERVER['REQUEST_URI'],-5) == '.html') {         $check = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name=%s AND post_status = 'publish'",substr(basename($_SERVER['REQUEST_URI']),0,-5)));         if ($check > 0) $post_id = $check;         // Need to set the post ID for the wp_query here.      }     }          if (!is_admin()) add_action( 'init', 'custom_redirect' );      The above code correctly selects the post ID correctly, but I'm not sure what function or hook to use to force the post (single.php) to display it. I was able to use the following to set the post ID for every archive.php run, but this doesn't affect the single.php file which simply calls the function the_post.               function force_ID($query) {      $query->set('post_id', '96');     }     add_action('pre_get_posts','force_ID');      I have a feeling it might be something simple like changing a global instance of $wp_query, but I'm not sure the best way to do this. Using an init hook probably is too high in the order of execution too.


Passing postid of Testimonial Custom Post in Shortcode Parameter

I am trying to create Testimonial custom post and display using shortcode               function create_post_type() {         register_post_type(             'testimonials',//new post type             array(                 'labels' => array(                     'name' => __( 'Testimonials' ),                     'singular_name' => __( 'Testimonial' )                 ),                 'public' => true,                 'supports' => array('title','editor','thumbnail','custom_fields'),                 'hierarchical' => false             )         );       }     add_action( 'init', 'create_post_type' );          //adding the URL meta box field     function add_custom_metabox() {         add_meta_box( 'custom-metabox', __( 'Link' ), 'url_custom_metabox', 'testimonials', 'side', 'low' );     }     add_action( 'admin_init', 'add_custom_metabox' );          // HTML for the admin area     function url_custom_metabox() {         global $post;         $urllink = get_post_meta( $post->ID, 'urllink', true );              //validating!         if ( ! preg_match( "/http(s?):\/\//", $urllink ) && $urllink != "") {             $errors = "This URL isn't valid";             $urllink = "http://";         }               // output invlid url message and add the http:// to the input field         if( isset($errors) ) { echo $errors; }     ?>
         URL:
             <input id="siteurl" size="37" name="siteurl" value="<?php if( isset($urllink) ) { echo $urllink; } ?>" />
     <?php     }          //saves custom field data     function save_custom_url( $post_id ) {         global $post;                 if( isset($_POST['siteurl']) ) {             update_post_meta( $post->ID, 'urllink', $_POST['siteurl'] );         }     }     add_action( 'save_post', 'save_custom_url' );          //return URL for a post     function get_url($post) {         $urllink = get_post_meta( $post->ID, 'urllink', true );              return $urllink;     }          //registering the shortcode to show testimonials     function load_testimonials($a){              $args = array(             "post_type" => "testimonials",             "id"       =>  $post->ID         );              if( isset( $a['rand'] ) && $a['rand'] == true ) {             $args['orderby'] = 'rand';         }         if( isset( $a['max'] ) ) {             $args['posts_per_page'] =(int) $a['max'];         }         if( $a['id'] ) {         $posts_in = array_map( 'intval', explode( ',',$a['id'] ) );         $args['post__in'] = $posts_in;         }         //getting all testimonials         $posts = get_posts($args);              echo '
';             echo '
';                  foreach($posts as $post)             {                      $url_thumb = wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID));                 $link = get_url($post);                 echo '
';                 echo '
';                     if ( ! empty( $url_thumb ) ) { echo ''; }                     if ( ! empty( $post->post_content ) ) { echo '
'.$post->post_content.'
'; }                     echo '
'.$post->post_title.'
';                     if ( ! empty( $link ) ) { echo 'Visit Site
'; }                 echo '
';                 echo '
';             }                  echo '
';         echo '
';     }     add_shortcode("testimonials","load_testimonials");          add_filter('widget_text', 'do_shortcode');      and the shortcode for display i used is               <?php echo do_shortcode('[testimonials id=3751]'); ?>      I want to pass post id in shortcode and display that particular post id in my page. I am trying to do this but it not showing any output please suggest me where i am wrong your suggestions help me a lot.


Static Page > Post Page displays data from latest blog post instead of the page details

Background I have created a Page called Blog. I have selected "A Static Page" > Post Page > Blog In the "home.php" I am displaying all post with `while(have_post())` This is working fine. It is displaying all post. The issue I am having is when I return the page title with `<?php the_title(); ?>` is returns the most recent post's title which is "Post 6" instead of "Blog" the name of the page. I am also displaying the content of the "blog" page as well but again it is displaying the content of the most recent post. So how do I display the page content of the page blog?               <?php get_header(); ?>          <?php the_title(); ?>

     <?php if ( have_posts() )  { ?>
             <?php                  while ( have_posts() ) {                 the_post();             ?>
                      <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">                     <?php if ( has_post_thumbnail() ) { ?>                         <?php echo get_the_post_thumbnail(); ?>                     <?php } ?>
<?php the_title(); ?>
                     <?php the_excerpt(); ?>
                  <?php } ?>
              <?php } else { ?>         No Post         <?php } ?>

         <?php get_sidebar(); ?>

           <?php get_footer(); ?>      **ANSWER** This did the trick $news_page = get_queried_object(); echo $news_page->post_title;


How To Download WordPress Audio Attachments

I've been searching high and low trying to figure out how to create download links for audio files uploaded to a post. I know how to display the audio url directly into the theme template, but when it's clicked, it just starts to stream the audio right in the browser. I need a way to prompt the file to download once clicked. Looking for more of a snippet for the functions.php file than a plugin.


Trouble using wordpress functions in a pop-up modal form

I'm working on a plugin and I've added a button to the tinymce editor that pops up a modal form, with options for the shortcode, and then inserts the shortcode with the selected options in to the post. The modal pops up a php file with an html form and some javascript in it. I'd like to use wp_dropdown_categories() inside of the form instead of having a text input for cats. Here's a snippet. I have the original textbox I was using for category commented out and I was trying to stick that wp function in instead but it's not working. WHat am I missing here? I can't figure out if there's something I need to be calling like a class or some global variable.                   <?php          ?>             <head>         <title>Box Shortcode</title>               ...Some more html and some js...                          <input type="radio" name="tax" value="category" id="selcat">              <?php wp_dropdown_categories(); ?> //This doesn't work                   <!--<div class="input-append">             <input type="text" name="category" id="catselection" class="categorynamebox" placeholder="Category" value="" disabled="disabled" />         </div>-->         <label for="randomcat">         <input type="checkbox" id="randomcat" disabled="disabled" >         Use a random category         </label>              ..some more html and js...              </body>         <?php              ?>


Drop Down Filter with CPT as Options for Search Form

I am trying to figure out how to create a drop down to use as a filter with the search form. I would like the options to be the different post types. I've seen on other sites that -               <select name="posttype">             <option name="product" value="product" style="color: #000;">Legal Documents</option>             <option name="videos" value="videos">Legal Advice - Videos</option>     <option value="link">Legal Advice - Links</option>     <option value="text">Legal Advice - Articles</option>              <option value="post_type_c">An Attorney</option>         </select>      What do I have to change or add to the search results page so that then correct post types are shown and filtere?


How to integrate noimage picture in this code

How can i integrate a image if there is no attached image? I'm using this code with success to integrate no-image picture if is no picture is attached to post.               <?php     if ( ! $img = get_field('img_actor', $post_object->ID ) )         $img = '/wp-content/uploads/noimage1.jpg';     ?>     <img class="actor_img" src="/scripts/timthumb.php?src=<?php echo urlencode($img); ?>&h=70&w=50&zc=1"      Ok for this, but how can I integrate this code into my GD Star Rating code. Gd Star Rating is a plugin that rate's the posts - GD Star Rating               foreach ($all_rows as $row) {         if ($widget["image_from"] == "content") {          $row->image = gdFunctionsGDSR::get_image_from_text($row->post_content);         }      else if ($widget["image_from"] == "custom") {          $post_custom_id = get_post_meta($row->post_id, $widget["image_custom"], true);     $row->image = get_bloginfo('url')."/scripts/timthumb.php?src=".get_bloginfo('url')."/wp-content/uploads/".get_post_meta($post_custom_id,"_wp_attached_file",true)."&h=70&w=55&zc=1";              }                                 }      The link for full code https://github.com/MaineLearning/MaineLearning/blob/master/wp- content/plugins/gd-star-rating/code/t2/render.php How i add in a page to display the count of posts.               <?php      wp_gdsr_render_rating_results(array('template_id' => 48, 'rows' => 1, 'select' => 'persoane', 'min_votes' => 0, 'min_count' => 0, 'excerpt_words' => 0, 'image_from' => 'custom', 'image_custom' => 'img_actor', 'image_resize_x' => 55, 'image_resize_y' => 70, 'publish_days' => 1, 'rating_size' => '12', 'review_size' => '12', 'rating_thumb_size' => '12'));     ?>


Show posts from two or more custom taxonomy terms

I want to show posts which are filed 2 or more custom taxonomy terms. For example, I want to show the posts from custom post type "Classified" and filed under Books _and_ House terms. The code below show posts which are marked in _either_ of the terms. I want only the posts marked in _both_ the terms:               $args = array(         'posts_per_page' => 10,  // Number of posts per page         'post_type' => 'classifieds',   // Custom Post Type like Movies         'tax_query' => array(             array(                 'taxonomy' => 'classifieds_tags',   //Custom Taxonomy Name like Genre                 'field' => 'slug',                 'terms' => array(                     'books',    //Tags or Categories like Drama or Comedy                     'houses'                 )             )         )     );


Return value of add_menu_page

I've read this on codex and seem some themes use it but never understood how it worked. > `(string) $hookname` used internally to track menu page callbacks for > outputting the page inside the `global $menu` array I can't seem to understand the codex's explanation. Can some one enlighten me on how can we use the return value and what are the uses of it?


WP-PageNavi gives me a 404 when using WP Query

I see that there are a lot of similar questions here at WPSE, and I've tried many of the suggestions mentioned trying to solve my problem but with no success. I have a category called News. In this category I want to run a custom query using WP Query to fetch and display articles, spread out through multiple pages using the plugin WP-PageNavi. I manage to get the plugin to display the links (go back/forward or to a particular page) but when I click on either one I end up with a 404 page. My permalink settings is "category/post-name/", for example I have "x.com/news/sample-news/. When trying to access let's say "x.com/news/page/2/" it gives me a 404. Here's the code -               <?php $paged = get_query_var('paged') ? get_query_var('paged') : 1;     $news = new WP_Query( array('category' => 3, 'paged' => $paged, 'posts_per_page' => 4, 'orderby' => 'date', 'order' => 'DESC') );     while ($news->have_posts()) : $news->the_post(); ?>
     <?php the_post_thumbnail( array(466,9999), true ) ?>
<?php the_title() ?>

<?php the_date() ?>
     <?php the_content() ?>
          <?php endwhile; if($news->max_num_pages>1)      if(function_exists('wp_pagenavi'))     wp_pagenavi( array('query' => $news) );?>      Using these plugins: Advanced Custom Fields, WP-PageNavi


No HTML/Visual mode option in admin panel (New Post)

There is no option for switching html to visual mode in add new post page of my admin panel there is no js error in console reinstalled WP from WP updates admin panel too, and there are no 404 on any js file either home page url is http://bankpo.in couldnt upload image so giving a link for screenshot http://img641.imageshack.us/img641/3476/clipboard02lr.jpg


why does twenty eleven theme mix up the css measurement units?

I'm wondering why does WordPress's default theme mix up the css measurement units? For example:               .one-column.singular #author-info {     margin: 2.2em -8.8% 0;     padding: 20px 8.8%;}      Wouldn't be easier to understand and to work if all them were pixel based? Thanks


Give users a maximum upload capacity; limit the number of files a user can upload OR limit the number of files per upload

I'm using the Media Library on the front end of my website and I'd like to stop users from being able to spam my server by uploading an unlimited number of files. As such, I'd like to do one or maybe all of the below:   1. Give users a maximum upload capacity; i.e. users can upload up to 10 megabytes of files.   2. Limit the number of files a user can upload on a per-post basis   3. Limit the number of files a user can upload when they click the "Insert" button, i.e. the Flash uploader and Classic uploader will only let you upload, for instance, 2 files at a time. None of these are bullet-proof but they'd hopefully make such "spamming" a difficulty. Thanks in advance,


Exclude plugins on Main site on Multisite installation?

I am using wordpress Multisite installation . 1)I want to run my website faster .Especially the main site.There are near about 50 plugins .I want to exclude many of these plugins on Main site and activate to other sub-sites.Could any body tell me how to do it? I have other three questions related to plugins on multisite installation: 2)Is there any chance for too much load on server or trouble loading pages if I Use 50 + plugins? 3)For two months I installed many plugins and un-installed them .Now i doubt that if the traces of these deleted plugins affect the server load. Is that true? If so how can I get rid of them ? 4)Some of the plugins would be activated on some sub-sites and active on some other sub-sites.So does the plugins on the sub-sites which are not active affect the server load? Thanks in Advance !


Trying to hide buttons from Attachment window

To simplify the Media Library layout to users when uploading an image, sometimes i hide the following fields:               function myAttachmentFields($form_fields, $post) {              if ( substr($post->post_mime_type, 0, 5) == 'image' ) {                $form_fields['image_alt']['value'] = '';      $form_fields['image_alt']['input'] = 'hidden';           $form_fields['post_excerpt']['value'] = '';      $form_fields['post_excerpt']['input'] = 'hidden';           $form_fields['post_content']['value'] = '';      $form_fields['post_content']['input'] = 'hidden';           $form_fields['url']['value'] = '';      $form_fields['url']['input'] = 'hidden';           $form_fields['align']['value'] = 'aligncenter';      $form_fields['align']['input'] = 'hidden';           $form_fields['image-size']['value'] = 'thumbnail';      $form_fields['image-size']['input'] = 'hidden';           $form_fields['image-caption']['value'] = 'caption';      $form_fields['image-caption']['input'] = 'hidden';              }              return $form_fields;          }          add_filter('attachment_fields_to_edit', 'myAttachmentFields');      Question: How do I hide the Insert into post button and the Set image text link. Thanks in advance


Making a wordpress page the index on the site?

Is it possible to make a "page, not a blog post" the main entry on your site? I'd like to be able to create a summary of the latest content as the first page the user visits on my site. I'm using Wordpress 3.0.3


Include latest author posts with pagination in single template?

I've inserted a `WP_Query` in my single.php template to show the last 12 posts of an author. Everything works ok, the 12 posts are being shown. Now, I want to have it paginated. So the user can see more than 12 posts. Here is my `WP_Query` and pagination code:               <?php                      $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;                      $args = array(                     'author'=> get_the_author_meta( 'ID' ),                       'posts_per_page' => 12,                       'paged'          => $paged,                       'order'    => 'DESC',                          'post_type' => 'post',                          );                     $query1 = new WP_Query( $args );                          // The Loop                      while ( $query1->have_posts() ) : $query1->the_post();                           get_template_part( 'content', get_post_format() );                      endwhile;            ?>
<?php _e( 'Post navigation', 'twentytwelve' ); ?>

<?php next_posts_link( __( '← Older posts', 'twentytwelve' ), $query1->max_num_pages ); ?>

<?php previous_posts_link( __( 'Newer posts →', 'twentytwelve' ) ); ?>
               <?php wp_reset_postdata(); ?>      Nothing is shown for page 2.


Connecting Wordpress gallery to custom categories (taxonomy)

I want to use the Wordpress gallery to show all pictures of one category in a gallery (on a fixed page), which I do not have to update all the time by inserting the pictures manually. So I added the category feature into media with this function:               function is_add_categories_to_attachments() {     register_taxonomy_for_object_type( 'category', 'attachment' );     }     add_action( 'init' , 'is_add_categories_to_attachments' );      Great, that worked. In the media menu I can add as many categories I want to now. In my case I made three of them, named alpha, beta and gamma. Then I wanted to post a gallery on a fixed page with one category:               [gallery type="squares" category="alpha" order="DESC" orderby="ID" link="file"]      But that did not work and I had to use the post_gallery filter in my child's functions.php, so that I can change the code there, but I have absolutely NO CLUE how to enter the category recognisation into that gallery_shortcut:               function is_gallery($output, $attr) {     $post = get_post();          static $instance = 0;     $instance++;          if ( ! empty( $attr['ids'] ) ) {         // 'ids' is explicitly ordered, unless you specify otherwise.         if ( empty( $attr['orderby'] ) )             $attr['orderby'] = 'post__in';         $attr['include'] = $attr['ids'];     }          // Allow plugins/themes to override the default gallery template.     $output = apply_filters('post_gallery', '', $attr);     if ( $output != '' )         return $output;          // We're trusting author input, so let's at least make sure it looks like a valid orderby statement     if ( isset( $attr['orderby'] ) ) {         $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );         if ( !$attr['orderby'] )             unset( $attr['orderby'] );     }          extract(shortcode_atts(array(         'order'      => 'ASC',         'orderby'    => 'menu_order ID',         'id'         => $post ? $post->ID : 0,         'itemtag'    => 'dl',         'icontag'    => 'dt',         'captiontag' => 'dd',         'columns'    => 3,         'size'       => 'thumbnail',         'include'    => '',         'exclude'    => '',         'link'       => ''     ), $attr, 'gallery'));          $id = intval($id);     if ( 'RAND' == $order )         $orderby = 'none';          if ( !empty($include) ) {         $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );              $attachments = array();         foreach ( $_attachments as $key => $val ) {             $attachments[$val->ID] = $_attachments[$key];         }     } elseif ( !empty($exclude) ) {         $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );     } else {         $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );     }          if ( empty($attachments) )         return '';          if ( is_feed() ) {         $output = "\n";         foreach ( $attachments as $att_id => $attachment )             $output .= wp_get_attachment_link($att_id, $size, true) . "\n";         return $output;     }          $itemtag = tag_escape($itemtag);     $captiontag = tag_escape($captiontag);     $icontag = tag_escape($icontag);     $valid_tags = wp_kses_allowed_html( 'post' );     if ( ! isset( $valid_tags[ $itemtag ] ) )         $itemtag = 'dl';     if ( ! isset( $valid_tags[ $captiontag ] ) )         $captiontag = 'dd';     if ( ! isset( $valid_tags[ $icontag ] ) )         $icontag = 'dt';          $columns = intval($columns);     $itemwidth = $columns > 0 ? floor(100/$columns) : 100;     $float = is_rtl() ? 'right' : 'left';          $selector = "gallery-{$instance}";          $gallery_style = $gallery_div = '';     if ( apply_filters( 'use_default_gallery_style', true ) )         $gallery_style = "         ";     $size_class = sanitize_html_class( $size );     $gallery_div = "
";     $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );          $i = 0;     foreach ( $attachments as $id => $attachment ) {         if ( ! empty( $link ) && 'file' === $link )             $image_output = wp_get_attachment_link( $id, $size, false, false );         elseif ( ! empty( $link ) && 'none' === $link )             $image_output = wp_get_attachment_image( $id, $size, false );         else             $image_output = wp_get_attachment_link( $id, $size, true, false );              $image_meta  = wp_get_attachment_metadata( $id );              $orientation = '';         if ( isset( $image_meta['height'], $image_meta['width'] ) )             $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape';              $output .= "<{$itemtag} class='gallery-item'>";         $output .= "             <{$icontag} class='gallery-icon {$orientation}'>                 $image_output             </{$icontag}>";         if ( $captiontag && trim($attachment->post_excerpt) ) {             $output .= "                 <{$captiontag} class='wp-caption-text gallery-caption'>                 " . wptexturize($attachment->post_excerpt) . "                 </{$captiontag}>";         }         $output .= "</{$itemtag}>";         if ( $columns > 0 && ++$i % $columns == 0 )             $output .= '
';     }          $output .= "

\n";          return $output;     }     add_filter("post_gallery", "is_gallery",10,2);      Can you show me how to insert the category feature into the galley_shortcode? Thank you in advance. * * * Would that be correct then?               function is_gallery($output, $attr) {     $post = get_post();          static $instance = 0;     $instance++;          if ( ! empty( $attr['ids'] ) ) {     // 'ids' is explicitly ordered, unless you specify otherwise.     if ( empty( $attr['orderby'] ) )         $attr['orderby'] = 'post__in';     $attr['include'] = $attr['ids'];     }          // Allow plugins/themes to override the default gallery template.     $output = apply_filters('post_gallery', '', $attr);     if ( $output != '' )     return $output;          // We're trusting author input, so let's at least make sure it looks like a valid     orderby statement     if ( isset( $attr['orderby'] ) ) {     $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );     if ( !$attr['orderby'] )         unset( $attr['orderby'] );     }          extract(shortcode_atts(array(     'order'      => 'ASC',     'orderby'    => 'menu_order ID',     'id'         => $post ? $post->ID : 0,     'itemtag'    => 'dl',     'icontag'    => 'dt',     'captiontag' => 'dd',     'columns'    => 3,     'size'       => 'thumbnail',     'include'    => '',     'exclude'    => '',     'link'       => ''     ), $attr, 'gallery'));          $id = intval($id);     if ( 'RAND' == $order )     $orderby = 'none';          $beta_attachments = new WP_Query( array(     'post_type' => 'attachment',     'post_status' => 'inherit',     'posts_per_page' => 0,     'category_name' => 'beta', // note: use category SLUG     ) );          $beta_id_array = array();     foreach ( $beta_attachments as $beta ) {     $beta_id_array[] = $beta->ID;     }     $beta_ids = implode( ',', $beta_id_array );          $gamma_attachments = new WP_Query( array(     'post_type' => 'attachment',     'post_status' => 'inherit',     'posts_per_page' => 0,     'category_name' => 'gamma', // note: use category SLUG     ) );          $gamma_id_array = array();     foreach ( $gamma_attachments as $gamma ) {     $gamma_id_array[] = $gamma->ID;     }     $gamma_ids = implode( ',', $gamma_id_array );          $alpha_attachments = new WP_Query( array(     'post_type' => 'attachment',     'post_status' => 'inherit',     'posts_per_page' => 0,     'category_name' => 'alpha', // note: use category SLUG     ) );          $alpha_id_array = array();     foreach ( $alpha_attachments as $alpha ) {     $alpha_id_array[] = $alpha->ID;     }     $alpha_ids = implode( ',', $alpha_id_array );          if ( !empty($include) ) {     $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );          $attachments = array();     foreach ( $_attachments as $key => $val ) {         $attachments[$val->ID] = $_attachments[$key];     }     } elseif ( !empty($exclude) ) {     $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );     } else {     $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );     }          if ( empty($attachments) )     return '';          if ( is_feed() ) {     $output = "\n";     foreach ( $attachments as $att_id => $attachment )         $output .= wp_get_attachment_link($att_id, $size, true) . "\n";     return $output;     }          $itemtag = tag_escape($itemtag);     $captiontag = tag_escape($captiontag);     $icontag = tag_escape($icontag);     $valid_tags = wp_kses_allowed_html( 'post' );     if ( ! isset( $valid_tags[ $itemtag ] ) )     $itemtag = 'dl';     if ( ! isset( $valid_tags[ $captiontag ] ) )     $captiontag = 'dd';     if ( ! isset( $valid_tags[ $icontag ] ) )     $icontag = 'dt';          $columns = intval($columns);     $itemwidth = $columns > 0 ? floor(100/$columns) : 100;     $float = is_rtl() ? 'right' : 'left';          $selector = "gallery-{$instance}";          $gallery_style = $gallery_div = '';     if ( apply_filters( 'use_default_gallery_style', true ) )     $gallery_style = "     ";     $size_class = sanitize_html_class( $size );     $gallery_div = "
";     $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );          $i = 0;     foreach ( $attachments as $id => $attachment ) {     if ( ! empty( $link ) && 'file' === $link )         $image_output = wp_get_attachment_link( $id, $size, false, false );     elseif ( ! empty( $link ) && 'none' === $link )         $image_output = wp_get_attachment_image( $id, $size, false );     else         $image_output = wp_get_attachment_link( $id, $size, true, false );          $image_meta  = wp_get_attachment_metadata( $id );          $orientation = '';     if ( isset( $image_meta['height'], $image_meta['width'] ) )         $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape';          $output .= "<{$itemtag} class='gallery-item'>";     $output .= "         <{$icontag} class='gallery-icon {$orientation}'>             $image_output         </{$icontag}>";     if ( $captiontag && trim($attachment->post_excerpt) ) {         $output .= "             <{$captiontag} class='wp-caption-text gallery-caption'>             " . wptexturize($attachment->post_excerpt) . "             </{$captiontag}>";     }     $output .= "</{$itemtag}>";     if ( $columns > 0 && ++$i % $columns == 0 )         $output .= '
';     }          $output .= "

\n";          return $output;     }     add_filter("post_gallery", "is_gallery",10,2);      ## Update hi Chip, I understood your idea/solution now and tried it (well, copied it over thanks to you). I think the logic is working, but in practise use it does not. I used the code like that and it does not "see" the categories. Therefore it just shows an empty content (below navigation, of course). people.php:                <?php      /**      * Template Name: People Gallery      */           get_header(); ?>          <?php          $people_attachments = new WP_Query( array(     'post_type' => 'attachment',     'post_status' => 'inherit',     'posts_per_page' => 0,     'category_name' => 'people', // note: use category SLUG     ) );          $people_id_array = array();          if ( $people_attachments->have_posts() ) : while ( $people_attachments->have_posts() ) : $people_attachments->the_post();          $people_id_array[] = get_the_ID();          endwhile; endif;     // Important!     wp_reset_postdata();          $people_ids = implode( ',', $people_id_array );          echo do_shortcode( '[gallery link="file" columns="5" order="DESC" orderby="ID" include="' . $people_ids . '"]' );          ?>          <?php var_dump( $people_id_array ); ?>          <?php // get_sidebar(); ?>          <?php get_footer(); ?>      Working now


Limit roles displayed in users.php depending on custom role

I have setup my WordPress installation with a custom role called **'regional_manager'** I have given this role the capability to add_users and managed to create a custom snippet for my functions.php file which only lists subscribers in the Role drop down. This means that the regional_manager role can only create new users with a role of subscriber. Now I would like to prevent them from seeing all other users when they go to               www.mydomain.com/wp-admin/users.php      Is there a simple way to do this and does anyone have an example of something similar they can point me in the direction of?


Remove last comma from this query

I'm having trouble fixing this for working in ie8, i find out thats last comma is problem, but dont know how to fix it. this is current code.               <?php $args = array( 'post_type' => 'katalog', 'posts_per_page' => 999 );     $loop = new WP_Query( $args );      if ($loop->have_posts()) :      while ($loop->have_posts()) : $loop->the_post(); ?>          <?php global $post; $thumb=wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full'); $thumb2=wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium'); $url = rwmb_meta( 'smb_katalozi' ); ?>     {image : "<?php echo $thumb[0] ?> ", title : "<?php echo get_the_title() ?>", url : "<?php echo post_permalink( $url ); ?>"},          <?php endwhile; else: endif; ?>      and the output is this               {image : "img url", title : "title", url : "url"},     {image : "img url", title : "title", url : "url"},      and i want it to be               {image : "img url", title : "title", url : "url"},     {image : "img url", title : "title", url : "url"}      so, its different just by last comma. * * * Got it to work with this code               <?php         $args = array( 'post_type' => 'katalog', 'posts_per_page' => 999 );         $loop = new WP_Query( $args );          $post_count = 0;         $te = $loop->post_count;         $total = $te-1;         if ($loop->have_posts()) :          while ($loop->have_posts()) : $loop->the_post();          global $post;  $thumb=wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full'); $thumb2=wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium'); $url = rwmb_meta( 'smb_katalozi' );         if ($post_count == 0 || $post_count !== $total) { ?>             {image : "<?php echo $thumb[0] ?> ", title : "<?php echo get_the_title() ?>", url : "<?php echo post_permalink( $url ); ?>"},         <?php } if ($post_count == $total) { ?>             {image : "<?php echo $thumb[0] ?> ", title : "<?php echo get_the_title() ?>", url : "<?php echo post_permalink( $url ); ?>"}         <?php }         $post_count++;         endwhile; else: endif;         ?>


How to check "From Email" via WordPress before an email is sent

Is it possible to check an email from email via WordPress before an email is sent? I'm working on a phpmailer plugin to send WordPress email via Amazon SES (which requires all emails to be verified). I'm using WordPress multisite and would like to set a different verified email per site. So I would like to know if it is possible to get the variable that contains the from email to accomplish something similar to the following.               if(fromEmailVaribale == 'info@example.com'){      //Set from email       $phpmailer->SetFrom('info@example.com', 'Example.com');     }else{      //Set from email       $phpmailer->SetFrom('services@example.com', 'Services Example.com');     }


Handling embedded videos in excerpts

Background: I have a multisite install, where users have their own blogs. I'm working on a page for the main site which will list the most recently updated blogs and excerpts from the first three (WIP version here: http://threemix.co.uk/blog-network/ ) One of my users runs a video blog. Unfortunately, this messes up the excerpts when his is one of the most recent three updated blogs: more specifically, neither the excerpt nor a link to the post show (his blog is "Greg Does Reading" on the link above).
         <?php         $thisblogid = get_current_blog_id();         $blogs = get_last_updated('', 1, 12);         $blogno = 1;               foreach ($blogs as $blog) :              switch_to_blog($blog['blog_id']);              global $post;              $myposts = get_posts(array('numberposts'=>1));          ?>              <?php if ($blogno == 1) { ?>
         <?php } if ($blogno >= 1 && $blogno <= 3) { ?>             <li class="fresh col-<?php echo (($blogno % 3)); ?> <?php if (count($myposts) == 0) : echo('no-posts'); endif;?>">
<hgroup>             <a href="<?php bloginfo('url'); ?>">
<?php bloginfo('title'); ?>
             </hgroup>
             <?php $i = 0; foreach ($myposts as $post) : setup_postdata($post); ?>
                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                 <?php echo get_my_excerpt(15); ?>
             <?php $i++; endforeach; ?>

         <?php } if ($blogno == 3) { ?>
         <?php } if ($blogno > 3) {              // if not one of the first three posts ?>                 //ommitted for brevity                      <?php } $blogno++?>          <?php endforeach; ?>          <?php switch_to_blog($thisblogid) ; ?>
      The first three posts are generated in the inner tags. I am switching to each blog in order, taking the $post object of the most recent post, and using it in a custom loop. Two questions:   1. Why is the post's title not showing up? I can understand why the excerpt isn't, but not the post title.   2. How can I change my get_my_excerpt() function (which at the moment, just changes the length of the excerpt), to include embedded YouTube videos?


Shouldn't this be easy?! Custom post type/custom taxonomy permalink

So this is driving me absolutely insane. I've spend days trying to fix this and I can't work out why this is so difficult as surely this is a very common permalink structure! I looked through hundreds of answers and posts and none of them seem to solve the problem. I simply want this structure:               mysite.com/custom-post-type/custom-taxonomy-term/post-name      So I achieve the following:               mysite.com/literature - all literature posts     mysite.com/literature/fiction - all literature posts with 'fiction' term     mysite.com/literature/fiction/mybook - the post      Every time I try something I get 404 errors or the pagnination doesn't work. I don't understand why this is so hard! Any help really appreciated! Thank you ====================================================== ================== **ADDITIONAL INFORMATION** ================== Currently I'm registering the post type and taxonomy as follows:               register_post_type('literature',$args);     'rewrite' => array('slug' => 'literature/books','with_front' => false),          register_taxonomy('literature_category',array('literature'), array(     'rewrite' => array( 'slug' => 'literature','with_front' => false ),      If I register both as 'literature' I get a 404 on the mysite.com/literature page but this displays my permalink as: `mysite.com/literature/books/mybook` After following the advice on this question - Custom post types, taxonomies, and permalinks I've added this to my functions:               function filter_post_type_link($link, $post) {         if ($post->post_type != 'literature')             return $link;              if ($cats = get_the_terms($post->ID, 'literature_category'))             $link = str_replace('%literature_category%', array_pop($cats)->slug, $link);         return $link;     }     add_filter('post_type_link', 'filter_post_type_link', 10, 2);      And changed my post type to `'slug' => 'literature/%literature_category%'` And changed my taxonomy to `'slug' => 'literature'` This works great except that on `mysite.com/literature` pagination doesn't work so I get a 404 error on the following url: `mysite.com/literature/page/2/`


Recommended way to drop a pending query (in pre_get_posts)?

It looks like an e-commerce plugin's core query will be of no use to me in one particular template so I would like to discard it completely in favor of my own WP_Query loops in the template. It's not the main query, but a secondary loop query_posts() call that I'm trying to discard downstream. wp remove query has some good no-op pure SQL suggestions, but what would be a recommended way to stick one of those into that specific $query in pre_get_posts?


get page templates

I have this issue where I need to get all page templates. I know there are ways to get them based on their name. I know that I can include a page template but I am trying to include them in the loop on the index page. I just installed the 2012 theme, modified the header to include my scripts. I used a function that Milo offered from this site to load all posts and pages into the homepage which is working. Now I need to include all templates even those that I don't know their name. looking in the codex, I found a function called get_page_templates() that doesn't appear to be valid anymore. it gave this snippet                <?php          $templates = get_page_templates();         foreach ( $templates as $template_name => $template_filename ) {         echo "$template_name ($template_filename)<br />";         }      ?>      This code snippet should have done the trick but it gave me an invalid function error. I messed around with get_page_template() but all it would return for me is page.php Looking in the database in the _wp_post_meta, I see the field _wp_page_template and I can see that it holds all the template names that I need to include. I am just not sure how to get those names out of that field. I tried this               $template = get_post_meta($post->ID,'_wp_page_template',true);      but when I checked the value of $template, I found nothing. can you help?


Wordpress database error - Error in SQL syntax - I can't identify any error?

I am trying to write function that checks whether an email address is stored in my database or not. I've written the following PHP code::               function check_my_users( $email_address ) {          global $wpdb;          $my_table_name = $wpdb->prefix . 'my_users';               $result = $wpdb->get_var( $wpdb->prepare( 'SELECT email FROM %s WHERE email = %s', $my_table_name, $email_address ) );               if( $result !== NULL )              return true;               return false;      }      The function always returns false. Additionally, the following query is printed after calling the function: `SELECT email FROM 'wp_my_users' WHERE email = 'mail@example.com'`. Additionally, the following is written to the debug log:               WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''wp_my_users' WHERE email = 'mail@example.com'' at line 1 for query SELECT email FROM 'wp_my_users' WHERE email = 'mail@example.com' made by […]      (I added the elipsis) What is wrong with my function, why do I get that error? To me, everything looks good.


Will it make any different if I have CDN on the same host but just different directory?

I have read an article about CND or " Content Delivery Network " which this is really telling myself that if I host a wordpress self-hosting and having a load of traffic I should at least have CDN which will help me improve my loading speed or performance of my site. Come to my question, should CDN be hosted in a different host or if it is in different directory will still make my site load faster than what the default wp-content is? I'm currently hosting my wordpress on a MAC OS X Server with 16GB of ram everything running fine except some people saying that it does take a bit of time for completion of site downloaded. [upto 5 seconds] I'm having issue with w3 cache really can't use it because it makes my site messed in a way that it will only show one post randomly but once I deactivate it then everything worked fine. please if you can share your opinion about this. Thank


WordPress Authors not showing with User Submitted Posts plugin

I'm using the User Submitted Post plugin to allow people to post to my blog. However when i run `<?php wp_list_authors(); ?>` I see none of the authors listed on the posts page in the dashboard. Are these not users? How can i list the authors that submitted all my posts through this plugin?


Should I global $wpdb outside of any of my plugin's functions scope?

I know that the general advice to global variables is to not use them at all. Still, when doing something with the Wordpress database, it is required to do `global $wpdb;` to access the methods Wordpress provides for interacting with the database. Now I've written a small plugin that introduces several functions that need to interact with the Wordpress database. That means, in every function I have written `global $wpdb;`. After that, I build the table names needed dynamically: `$wpdb->prefix . 'my_table_name';`. This is a lot of redundant code in my opinion that even can produce a lot more work. For example, I changed the table names a few times during development and had to change it in every function of my plugin where I do `$wpdb->prefix . 'my_table_name';`. Now my question is: Is it a good idea to just `global` `$wpdb` outside of any function scope and then assign the tables names to global variables?   That way, everything would be a lot more flexible regarding table names (and maybe even performance?)


Apache rewrite rules and wordpress problem

I tried to fix my problem by using wordpress rewrite rules but sadly it took me so long I tried this approach. I got it working for one of my simpler problems but now I can't get it to work for my two variable rewrite.               # START Custom rules.     RewriteEngine On          RewriteRule ^examentraining/vak/([^/]+)/([^/]+)/?$ index.php?p=1316&vakname=$1&level=$2 [L]     RewriteRule ^examentraining/training/([^/]+)/?$ index.php?pagename=examentraining/training&trainingid=$1 [L]          # FIN customrules          # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      The second rule rewrites `index.php?pagename=examentraining/training$trainingid=VAKID => /examentraining/training/VAKID/`. This one works and has been tested. I would like my first example to also work, this one needs to rewrite `/index.php?p=1316&vakname=VAKNAME&level=LEVELNAME => /examentraining/vak/VAKNAME/LEVELNAME/`. `LEVELNAME` and `VAKNAME` are both strings that should be able to contain A-Z,a-z,_,&. I have tested this rewrite rule on multiple online tester but when I use it with wordpress it keeps failing. I enabled logging for .htaccess and I can see that the rewrite is functioning correctly but I can't follow it afterwards. The log: https://gist.github.com/ITWarrior/9292036 I hope somebody can help me, I have to get this done and I have tried al sorts of ways. EDIT 1 I added `remove_filter('template_redirect', 'redirect_canonical');` to my plugin. Now requesting /examentraining/vak/natuurkunde/vwo gets me to /examentraining/vak/natuurkunde/vwo but with an 404 not found wordpress error. The log of this request: https://gist.github.com/ITWarrior/9294435 The rewrite works fine and entering the url after the first rewrite actually gets me to the correct page (/index.php?p=1316&vakname=aardrijkskunde&level=vwo).


Combine category AND custom taxonomy in permalink structure

It seems like this question has been asked not infrequently, but I still can't make heads of it. I followed the Rewrite API Guide to look at how to merge, but I want something like this: Category = categories, built in. Food = custom taxonomy. When I enter http://mysite.com/food/category to find all posts in that category and that foot type, similar to http://mysite.com/index.php?category=category&food=food I'll also have pages, which aren't attached to a "food" or category, and the permalink fails if i simply put %foood%/%category%/ into the permalink settings. Does anyone have any recommendations?


Change menu with language?

My problem is that I have used a plugin called polylang and now it doesnät work with another more importent plugin so I need to find a solution. I use WPML on other sites and that is not an option here so you know. I allready have all posts and pages translated and I just want to use one menu in Swedish and one in English. No changes in permalinks what so ever. I found a solution in this post How to change menu according to the language? but I can't get it to work. Not sure that post is still active or the solution works with WP 3.6 so I ask again for any help. This is the menu code from the halifax theme from the header               <?php wp_nav_menu( array( 'container_id' => 'submenu', 'theme_location' => 'primary','menu_id'=>'web2feel' ,'menu_class'=>'sfmenu','fallback_cb'=> 'fallbackmenu' ) ); ?>      code from the functions.php                   register_nav_menus( array(             'primary' => __( 'Primary Navigation', '' ),         ) );          function fallbackmenu(){ ?>

 Go to Adminpanel > Appearance > Menus to create your menu. You should have WP 3.0+ version for custom menus to work.


Automatic publishing after some fixed intervals?

Is it possible to publish "pending posts" automatically after some interval around the clock, using WP Cron or something else? I receive over 2000 posts daily, submitted by visitors, and they all go to pending status. I cannot edit and schedule each post. Just looking for a way to auto-post the pending posts with some intervals. E.g. Publishing 20 posts after every 15 mins.


php code for image fetching

<?php       mysql_connect("localhost", "xxxxxx", "xxxxx") or die(mysql_error());       mysql_select_db("xxxxx") or die(mysql_error());       $data = mysql_query("SELECT         p1.*,         wm2.meta_value     FROM         xxxxx_posts p1     LEFT JOIN         xxxxxx_postmeta wm1         ON (             wm1.post_id = p1.id             AND wm1.meta_value IS NOT NULL             AND wm1.meta_key = '_thumbnail_id'         )     LEFT JOIN         xxxxx_postmeta wm2         ON (             wm1.meta_value = wm2.post_id             AND wm2.meta_key = '_xxxxxx_attached_file'             AND wm2.meta_value IS NOT NULL         )     WHERE         p1.post_status='publish'         AND p1.post_type='post'     ORDER BY         p1.post_date DESC")       or die(mysql_error());            Print "
";      while($info = mysql_fetch_array( $data ))       {                 Print "

";          Print $info['post_title'];     Print "

 ";            }       Print "
";      ?>       How to fetch the featured image in wordpress post //////


Multiplicate entry on update_post_meta

I have a metabox with an array of input:               <input type="text" name="activite_dates[]" size="30" />
     <input type="text" name="activite_dates[]" size="30" />
     <input type="text" name="activite_dates[]" size="30" />
     ...      And i'm saving it like this               update_post_meta( $post_id, "dates", $_POST['activite_dates'] );      The problem is that when i'm retrieving it I have to make a ugly function to read multiple dimension array               Array      (     [0] => Array         (             [0] => DATA1             [1] => DATA2             [2] => DATA3             [3] => DATA99         )          [1] => Array         (             [0] => DATA1             [1] => DATA2             [2] => DATA3             [3] => DATA99         )          [2] => Array         (             [0] => DATA1             [1] => DATA2             [2] => DATA3             [3] => DATA99         )      ) And when I'm saving it, it's only add to append to existent array               Array      (     [0] => Array         (             [0] => DATA1             [1] => DATA2             [2] => DATA3             [3] => DATA99             [4] => DATA1             [5] => DATA2             [6] => DATA3             [7] => DATA99         )          [1] => Array         (             [0] => DATA1             [1] => DATA2             [2] => DATA3             [3] => DATA99             [4] => DATA1             [5] => DATA2             [6] => DATA3             [7] => DATA99                  )          [2] => Array         (             [0] => DATA1             [1] => DATA2             [2] => DATA3             [3] => DATA99             [4] => DATA1             [5] => DATA2             [6] => DATA3             [7] => DATA99         )          )      So first, why do I have 3 value at the first level then my array is multiplied inside of the second level ? For information here is my code for the view :               $dates_gf = get_post_meta( $object->ID, 'dates', false );     foreach ($dates_gf as $date_gf) {         if (is_array($date_gf)){             foreach ($date_gf as $arr_date_gf) {                 ?> <input type="text" name="activite_dates_gf[]" value="<?php echo $arr_date_gf; ?>" size="30" />
 <?php             }         } else {             ?> <input type="text" name="activite_dates_gf[]" value="<?php echo $date_gf; ?>" size="30" />
 <?php         }     } ?>      Thank you very much !


Overwrite URL on blog posts

I would like to overwrite my URL on single blog posts. At the moment my posts are displaying as www.mydomain.co.uk/post-title, however I would like them to be as www.mydomain.co.uk/blog/post-title so /blog/ always displays before post item, I've tried to do that from permalink level but when I put /blog in Post name box it works, however all my single Custom posts are displaying as /blog/custom-post-item which is not what I'm after as I would only like that to happen for blog posts and not for custom post types. Any tips. Many thanks


TwentyTwelve, where is the excerpt box in add new?

When i try to add a new post, the is no excerpt box. Does anyone know a way to enable this?


How to fork a plugin?

I want to start giving back to the community, but writing a plugin from scratch is currently slightly beyond my skill level and creativity level (meaning, I don't know what kind of problem I can solve with a plugin! every time I think of something, I find a plugin or 6 that have already been written!). However, I have recently identified a very simple plugin that looks to be abandoned since WP 2.8, and I think I can modify it to be 3.1 compatible. I've asked, and it seems that the best way to update this plugin may be to simply fork it. So now my question: how do I do that? I'm new to SVN, so I'm totally uncertain as to where to go, how to start, etc etc. Can anyone guide me? :)


How can I tell which of my pages are single-view pages?

I am trying to understand what the `is_singular()` function does. And I found this definition:               is_singular() tag enables you to target single-view pages, regular page pages, and attachment pages       But the problem is that I am not sure how to determine which are single-view pages, regular pages, and category pages. What I really need to do is determine if a page is a category page. Thanks, Alex


Why are my paginated result links not working?

I've developed a custom post type for WordPress that has quite a few entries that require pagination. I used the *paginate_links* function and it creates the pagination appropriately, rendering links that look like this: http://mysite.com/people/page/5/ But whenever one of the links is clicked on it returns a 404 message error. I suspect this has something to do with permalinks and my .htaccess file, but the permalinks for my posts and pages work just fine, so I'm confused. Can anybody help me with this? Thank you! **EDIT** : Here is my query:               query_posts('post_type=peoplemanager&meta_key=people_lastname&orderby=meta_value&order=ASC&paged=' . get_query_var('paged'));      The name of the page where the output is displayed is "people."


How to integrate custom database table in Wordpress and using Wordpress functions

I'm on `Wordpress 3.0.4` and I'm having a hard time deciding which way to go. The following is my problem: I have a `mysql` database table `widgets`, with about 10 `properties` like _id, size, color_ etc. Now I'd like to integrate this table into `Wordpress`, preferably in such a way that I can get paginated lists of the `widgets`, show information on a single widget and have a flexible layout. Preferably, I would like the ability to change a custom template in such a way that I can change the position of each property on the page (So maybe I'd like to put e.g. the _size-property_ on top of the page on the left, later I might want to put it on the right bottom). What would be the best way to store the `widgets`, retrieve them by using as much `Wordpress` build-in functions and how can I get this flexible layout as well? I've written my own plugins before, so I have more than basic knowlegde on `Wordpress/PHP/MySQL`.


Sorting problem with 'query_posts' funcion in wordpress. Sort by custom field not working

0 down vote favorite Hi, I am working with wordpress where i have a event listing system. There is a custom field in my post called starting_time which is unix timestamp. Now i want to short all posts by starting_time by this query_post command:               query_posts(array(                    'post_type' => 'event',                    'meta_key' => 'end_time',                    'meta_compare' =>'>=',                    'meta_value'=>time(),                    'order_by' => 'start_date',                  'order' => 'ASC'     ));      But it not working. Here is the site http://citystir.com/events/. I am echoing the start_time in unix before the time remaining so you can see the value. And also my pagination is not working. May be i did something wrong in the query_post command. Please someone response. \--------------------- Update ----------------- i have found a wonderful post here **kovshenin.com/archives/customize-posts- order-in-wordpress-via-custom-fields** but i didn't get it worked. May be for lack of my knowledge. Please take a look at it and let me know if you have any suggestions. I will continue working on that. \-------------------- Resolved ----------------- Changed order_by to orderby. And also i came to know that we can use meta key multiple times if we want it will not conflict. Here is the final code:               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     query_posts(array(     'post_type' => 'event',     'meta_key' => 'end_time',     'meta_compare' =>'>=',     'meta_value'=>time(),     'meta_key' => 'start_time',     'orderby' => 'meta_value_num',     'post_per_page' => '-1',     'order' => 'ASC',     'paged' => $paged     ));      Thanks for all your hard work!


How to auto set screen option defaults

I want to make a function in my theme, which sets some things in the screen options tab on by default if you select my theme. This remains same for all users in the admin area. I don't care about their order, basically I just want to make sure custom fields and excerpt are ticked by default on the new/edit posts page. I've looked around alot but everything goes over my head and isn't working, I'm kind of new to wordpress so sorry if I didn't use the proper terms.


$_GET['updated'] does not work in Wordpress 3.1?

I tried the Satoshi Theme in Wordpress 3.1 and when the Theme Options are saved, they do get saved but the "Satoshi Options Saved." message is not displayed. (the message is displayed in Wordpress 3.0.4). **functions.php:**               /* -- Theme Options Page -- */     function theme_options_admin() {         $option_fields = array();         if ( $_GET['updated'] ) echo '

Satoshi Options Saved.

';         echo '<link rel="stylesheet" href="'.get_bloginfo('template_url').'/styles/functions.css" />';     ?>

Satoshi Options

                  <form method="post" action="options.php">                 <?php wp_nonce_field('update-options'); ?>

                         <?php                             include("options/custom-logo.php");                             include("options/custom-intro.php");                             include("options/frontpage-headline.php");                             include("options/featured-project.php");                         ?>

                         <?php                             include("options/contact-details.php");                             include("options/footer-text.php");                             include("options/google-analytics.php");                         ?>

                      <input type="hidden" name="action" value="update" />                 <input type="hidden" name="page_options" value="<?php echo implode(",", $option_fields); ?>" />                  </form>

     <?php     }     add_action('admin_menu', "theme_options_admin_init");     function theme_options_admin_init()     {         add_theme_page( "Satoshi Theme Options", "Theme Options", 8, __FILE__, 'theme_options_admin');     }


How to remove notice inside search.php when no results are found?

I have created search.php from Twenty Eleven theme search template. Search template works fine but i am having a problem when **no results are found**.      I am getting this PHP Notice: **_Notice: Trying to get property of non-object wp-includes/post-template.php on line 29_** Post-template line 29 looks like this:               function get_the_ID() {     return get_post()->ID;<-this is the source of the problem      }      I am assuming that this happens because `get_post()->ID` is not set (when no results are displayed) because inside my search template i have put this code:               <?php if ( !isset ($post->ID)) {     echo 'not set';<- this will echo "not set" if NO results are found and                     PHP notice will be displayed:(                    }     else{     echo 'set';<- this will echo "set" if results ARE found and                     PHP notice will NOT be displayed       }     ?>      So my question is how to SET `$post->ID` (if it is not set) in order to remove PHP Notice?   Any help is massively appreciated Thank You!! Search php code:               <?php           get_header(); ?>      <?php get_sidebar(); ?>      <?php get_sidebar('secondary'); ?>      <?php if ( !isset ($post->ID )) {       echo 'not set';        }        else{        echo 'set';        }        ?>

<?php printf( __( 'Search Results for: %s' ,'your-override' ), '' . get_search_query() . '' ); ?>
         <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>              <div <?php post_class();?> id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

                     <?php the_post_thumbnail();           echo '
' . get_post(get_post_thumbnail_id())->post_excerpt . '
';?>
             <?php  // let's enable more link on pages...             global $more;             $more = 0;             ?>                 <?php the_content(); ?>

<?php the_meta(); ?>

                      <?php _e('Filed under:'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php  the_author(); ?>
<?php the_tags('Tags:', ', ', '
'); ?>                 <?php _e('Posted on: '); ?><?php the_time('l, F jS, Y'); ?>
                                <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>

      <?php endwhile; ?>
         <?php         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, $paged ),         'total' => $wp_query->max_num_pages         ) );          ?>
     <?php else : ?>

<?php _e( 'Nothing Found'); ?>

<?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.'); ?>
                     <?php get_search_form(); ?>

                   <?php endif; ?>

                <?php get_footer(); ?>


What's the best way to include php code in to pages?

I'm currently creating a bunch of (empty) pages and performing conditionals such as is_page('Blabla') on it, which increases my page.php significantly. I'm already using require_once for different content, but is there a cleaner way of doing this?


Strange Cached File in Super Cache

I installed super on one of my blogs recently and it has been working fine but I have noticed that it is caching this http://www.mydomain.com/.needs-rebuild which i believe is part of super cache what is the deal? Cheers


Create a custom taxonomy template that loops through child categories in term order?

We're building a site that sells Biking Gear We're using the Genesis Theme Framework, and developing a custom child theme. It has a Custom Post Type for Products, made with the "Custom Post Type UI Plugin". It also has a custom taxonomy for product-categories, we've created a template for the custom post type taxonomy archive : `taxonomy-products-category.php` The template needs to be able to loop through all the Posts in the product categories, but sort through them in term_order. For Example, `/product-categories/cycling/` needs to loop trough the child categories of 'Cycling' in the order we've set them up ( term_order, I think ) Also, if it's a child category, as seen in the menu on the left, the template just loops through that category, so if a user clicks on 'cycling', the template displays all the posts in the cycling category, grouped by sub- category ( jerseys, shorts, vests... ) and outputs the archive headline above each, I'm at a loss for how to cleanly so this, I've tried cobbling together a number of snippets that has resulted in failure, and am turning to the community for advice.


Using wp_enqueue_script on shortcode function handler

I have this code               function this_is_my_shortcode(){         wp_register_script('per-pas-belanja-online', plugins_url('js/per-pas-belanja-online.js', __FILE__), array('jquery'), '1.0.0');         wp_enqueue_script('per-pas-belanja-online');         return '
Blah
';     }     add_shortcode('bubba', 'this_is_my_shortcode');      The div is appear on the page, but the script is not. What mistake i have done ?


Customizing Comments

Hi I want to customize the text with the arrows pointed at at the image I have uploaded. I have managed to customize some but I cannot find the file to customize the rest.![enter image description here](http://i.stack.imgur.com/eXlKt.jpg) Many thanks its on local host, and it is a custom theme.


Theme Options Page - Select, Radio, Tabs

The code below is my theme options page (submenu - under "Appearance"). All options work fine except "select" and "radio"... They don't appear in the page as the other options do. I have been searching around the internet and trying different solutions for 3 days but there were no ways to make them appear. After that I would like to seperate the sections in different tabs which is also something I can't do. I have read the related documentation and some tutorials I found but nothing did the trick yet... Any help? Thanks!                   <?php     $themename = "WIS";          $shortname = "wis";          $version = "1.1";          $option_group = $shortname.'_theme_option_group';     $option_name = $shortname.'_theme_options';               add_action('admin_init', 'wis_add_init');          function wis_add_init() {         $file_dir = get_template_directory_uri();              wp_enqueue_style("wisCss", $file_dir."/functions/theme-options.css", false, "1.0", "all");              wp_enqueue_script("wisScript", $file_dir."/functions/theme-options.js", false, "1.0");          }          // Create custom settings menu     add_action('admin_menu', 'wis_create_menu');          function wis_create_menu() {         global $themename;         //create new top-level menu         add_theme_page( __( $themename.' Theme Options' ), __( 'Theme Options' ), 'edit_theme_options', 'wisgentheoptpag', 'wis_settings_page' );     }          // Register settings     add_action( 'admin_init', 'register_settings' );          function register_settings() {        global $themename, $shortname, $version, $wis_options, $option_group, $option_name;         //register our settings         register_setting( $option_group, $option_name);     }          // Create theme options          global $wis_options;          $wis_options = array (          array("name" => __('RSS Feeds/Facebook/Twitter','wis'),                  "type" => "section"),          array("name" => __('Set up social links.','wis'),                  "type" => "section-desc"),          array("type" => "open"),          array("name" => __('Custom Feed URL','wis'),                  "desc" => __('You can use your own feed URL (with http://). Paste your Feedburner URL here to let readers see it in your website.','wis'),                  "id" => "feedurl",                  "type" => "text",                  "std" => get_bloginfo('rss2_url')),          array("name" => __('Delete Extra Feeds','wis'),                  "desc" => __('WordPress adds feeds for categories, tags, etc., by default. Check this box to remove them and reduce the clutter.','wis'),                  "id" => "cleanfeedurls",                  "type" => "checkbox",                  "std" => ""),          array("name" => __('Twitter ID','wis'),                  "desc" => __('Your Twitter user name, please. It will be shown in the navigation bar. Leaving it blank will keep the Twitter icon supressed.','wis'),                  "id" => "twitterid",                  "type" => "text",                  "std" => ""),          array("name" => __('Facebook Page','wis'),                  "desc" => __('Link to your Facebook page, with http://. It will be shown in the navigation bar. Leaving it blank will keep the Facebook icon supressed.','wis'),                  "id" => "facebookid",                  "type" => "text",                  "std" => ""),          array("type" => "close"),          //FOOTER          array("name" => __('Footer','wis'),                  "type" => "section"),          array("name" => __('Customize footer of your website.','wis'),                  "type" => "section-desc"),          array("type" =>"open"),          array("name" => __('Footer Text','wis'),                  "desc" => __('Enter your footer text or HTML here.','wis'),                  "id" => "footer_text",                  "std" => "",                  "type" => "textarea"),          array("name" => __('Hide Footer Navigation Links','wis'),                  "desc" => __('Select to hide the navigation bar in the footer. If you want to customize the footer navigation, go to Menus under the Appearance tab in the dashboard.','wis'),                  "id" => "hide_footer_nav",                  "std" => "",                  "type" => "checkbox"),          array("name" => __('Hide Footer Credits','wis'),                  "desc" => __('Select to hide the credit line in the footer. Thanks for sending us a generous contribution.','wis'),                  "id" => "hide_footer_credit",          array("name" => __('Theme Styles','wis'),                  "type" => "section"),          array("name" => __('Choose a color scheme and add custom CSS styles.','wis'),                  "type" => "section-desc"),          array("type" => "open"),          array("name" => __('Colour Scheme','wis'),                  "desc" => __('Select a colour scheme for the theme. Future versions will have multiple styles.','wis'),                  "id" => "alt_stylesheet",                  "type" => "select",                  "options" => $alt_stylesheets,                  "std" => "default.css"),          array( "name" => __('Custom Styles','wis'),              "desc" => __('Want to add any custom CSS code? Put in here, and the rest is taken care of. This overrides any other stylesheets. eg: a.button{color:green}','wis'),              "id" => "custom_css",              "type" => "textarea",              "std" => ""),          array("type" => "close"),                  "std" => "",                  "type" => "checkbox"),          array( "type" => "close"),          //ADVERTISEMENTS --- POST ADS          array("name" => __('Advertisements','wis'),              "type" => "section"),          array("name" => __('Show ads on your blog.','wis'),                  "type" => "section-desc"),          array("type" => "open"),          array("name" => __('Header Display Ad','wis'),                  "desc" => __('You can show a display ad in header. Paste the code here for 600px by 60px ad.','wis'),                  "id" => "topbanner",                  "std" => "",                  "type" => "textarea"),          array("name" => __('Ad Above Posts','wis'),                  "desc" => __('Enter your Adsense code or other ad network code here. This ad will be displayed at the beginning of posts, below title on Post Pages and Pages with ad-supporting template. It is very basic and effective option for putting ads on your blog. If you want more functionality, get a specialized Ad plugin.','wis'),                  "id" => "posttop_adcode",                  "std" => "",                  "type" => "textarea"),          array("name" => __('Ad Below Posts','wis'),                  "desc" => __('Enter your Adsense code (or other ad network code) here. This ad will be displayed at the end of post content on Post Pages and Pages with ad-supporting template. Please make sure that you do not activate more ads than what is allowed by your ad network. Adsense allows up to 3 on one page.','wis'),                  "id" => "postend_adcode",                  "std" => "",                  "type" => "textarea"),          array("type" => "close"),          //Analytics Code          array("name" => __('Tracking & Other Codes','wis'),          array("name" => __('Theme Styles','wis'),                  "type" => "section"),          array("name" => __('Choose a color scheme and add custom CSS styles.','wis'),                  "type" => "section-desc"),          array("type" => "open"),          array("name" => __('Colour Scheme','wis'),                  "desc" => __('Select a colour scheme for the theme. Future versions will have multiple styles.','wis'),                  "id" => "alt_stylesheet",                  "type" => "select",                  "options" => $alt_stylesheets,                  "std" => "default.css"),          array( "name" => __('Custom Styles','wis'),              "desc" => __('Want to add any custom CSS code? Put in here, and the rest is taken care of. This overrides any other stylesheets. eg: a.button{color:green}','wis'),              "id" => "custom_css",              "type" => "textarea",              "std" => ""),          array("type" => "close"),                       "type" => "section"),          array("name" => __('Insert Web tracking & analytics and other codes here.','wis'),                  "type" => "section-desc"),          array("type" => "open"),          array("name" => __('Analytics & Tracking Code','wis'),                  "desc" => __('You can paste your Google Analytics or other codes in this box. The codes will be automatically added to the footer.','wis'),                  "id" => "analytics_code",                  "type" => "textarea",                  "std" => ""),          array("type" => "close")          );          function wis_settings_page() {        global $themename, $shortname, $version, $wis_options, $option_group, $option_name;     ?>

     <?php screen_icon(); ?>
<?php echo $themename; ?> <?php _e('Theme Options','wis'); ?>

<?php _e('Customize your WordPress blog with these settings. ','wis'); ?>
     <?php if ( isset ( $_POST['reset'] ) ): ?>     <?php // Delete Settings     global $wpdb, $themename, $shortname, $version, $wis_options, $option_group, $option_name;     delete_option('wis_theme_options');     wp_cache_flush(); ?>

<?php _e( $themename. ' options reset.' ); ?>

          <?php elseif ( isset ( $_REQUEST['updated'] ) ): ?>

<?php _e( $themename. ' options saved.' ); ?>

     <?php endif; ?>          <form method="post" action="options.php">          <?php settings_fields( $option_group ); ?>          <?php $options = get_option( $option_name ); ?>               <?php foreach ($wis_options as $value) {     if ( isset($value['id']) ) { $valueid = $value['id'];}          switch ( $value['type'] ) {          case "section":          ?>

<?php echo $value['name']; ?>          <?php break;          case "section-desc":          ?>              <?php echo $value['name']; ?>

          <?php          break;          case 'text':          ?>

<?php echo $value['desc']; ?>
                  <label for="<?php echo $option_name.'['.$valueid.']'; ?>"><?php echo $value['name']; ?>                  <input name="<?php echo $option_name.'['.$valueid.']'; ?>" id="<?php echo $option_name.'['.$valueid.']'; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( isset( $options[$valueid]) ){ esc_attr_e($options[$valueid]); } else { esc_attr_e($value['std']); } ?>" />
          <?php          break;          case 'textarea':          ?>

<?php echo $value['desc']; ?>
                  <label for="<?php echo $option_name.'['.$valueid.']'; ?>"><?php echo $value['name']; ?>                  <textarea name="<?php echo $option_name.'['.$valueid.']'; ?>" type="<?php echo $option_name.'['.$valueid.']'; ?>" cols="" rows=""><?php if ( isset( $options[$valueid]) ){ esc_attr_e($options[$valueid]); } else { esc_attr_e($value['std']); } ?></textarea>
          <?php          break;          case 'select':          ?>

<?php echo $value['desc']; ?>
                  <label for="<?php echo $option_name.'['.$valueid.']'; ?>"><?php echo $value['name']; ?>                  <select name="<?php echo $option_name.'['.$valueid.']'; ?>" id="<?php echo $option_name.'['.$valueid.']'; ?>">                  <?php foreach ($value['options'] as $option) { ?>                          <option <?php if ($options[$valueid] == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?>                  </select>
          <?php          break;          case "radio":          ?>

<?php echo $value['desc']; ?>
                  <label for="<?php echo $option_name.'['.$valueid.']'; ?>"><?php echo $value['name']; ?>                    <?php foreach ($value['options'] as $key=>$option) {                 if ( isset ( $options[$valueid] ) ) {                     if ($key == $options[$valueid] ) {                         $checked = "checked=\"checked\"";                         } else {                             $checked = "";                         }                 }else{                     if($key == $value['std']){                         $checked = "checked=\"checked\"";                     }else{                         $checked = "";                     }                 }?>                      <input type="radio" id="<?php echo $option_name.'['.$valueid.']'; ?>" name="<?php echo $option_name.'['.$valueid.']'; ?>" value="<?php echo $key; ?>" <?php echo $checked; ?> /><?php echo $option; ?>
                      <?php } ?>
          <?php          break;          case "checkbox":          ?>

<?php echo $value['desc']; ?>
                  <?php if( isset( $options[$valueid] ) ){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>                  <input type="checkbox" name="<?php echo $option_name.'['.$valueid.']'; ?>" id="<?php echo $option_name.'['.$valueid.']'; ?>" value="true" <?php echo $checked; ?> />                  <label for="<?php echo $option_name.'['.$valueid.']'; ?>"><?php echo $value['name']; ?>
          <?php          break;          case "close":          ?>

          <?php     break;          }          }          ?>               <input class="button button-primary" type="submit" name="save" value="<?php _e('Save All Changes', 'wis') ?>" />          </form>          <form method="post" action="">                    <input class="button button-secondary" type="submit" name="reset" value="<?php _e('Reset', 'wis') ?>" />     <input type="hidden" name="action" value="reset" />     <?php _e('Caution: All entries will be deleted from database.','wis') ?>                    </form>

          <?php } ?>


Shortcode to find and replace URL

I'm trying to create a shortcode that will search within some specified text for a link and replace it with one that I specify. For example:               [scode]Click on this link[scode]     [scode]Click on this link[scode]      ...will both be changed to:               [scode]Click on this link[scode]      I'm trying to put together a function that will search for links and replace them with the one that I specify. Here's what I have right now:               // Adds [hide] shortcode for hiding content from non-registered users.          function hide_text( $atts,$content) {         if ( is_user_logged_in () ) {             return $content;         }         else {             $pattern = '(?<=href=("|\'))[^"\']+(?=("|\'))';             $newurl = "http://replacementurl.com";             $content = preg_replace($pattern,$newurl,$content);             echo $content;               }         }     add_shortcode( 'hide', 'hide_text' );      This just crashes the site, though. I'm not a PHP expert (much less an expert on regex), but are there at least any glaring irregularities in my code? Or perhaps there's just a better way to go about this and I'm making it way more complicated than it needs to be? **UPDATE:** As suggested, I turned on debug log, which showed me that I had an extra `}` in the code. Updated code is shown above. Now the site isn't crashing, but the link and text within the shortcode is completely erased, just blank.


Filtering custom post type on a combination of custom taxonomies and custom fields?

I have a custom post type "artist". It has an associated custom taxonomy "artist_type" with terms "voice", "actor", "corporate" An "artist" also has custom fields for gender, location, agerangefrom and agerangeto. The latter 2 fields stipulate the age range that an actor/artist can act in. I'm displaying artists according to their artist_type taxonomy — so using taxonomy-artist-type.php to display "/artist_type/voices/" and "/artist_type/actors"/ and "/artist_type/corporate/" That's all fine. But I need to add in a filter so that a user can narrow down each of these three categories according to the custom fields mentioned above: gender, location etc I came across a site here that does something similar here: http://artists.derricktalentelite.com.au/?post_type=actor&gender=male I'm getting confused on how to set this up in my scenario. DO I need to be using meta_query and/or pre_get_posts? The user needs to be able to combine filters, for e.g., on the voices page: male in the age range from 20-30 based in London. How do I formulate the query string in the url to pass these parameters? Any clues on how best to proceed would be appreciated.


Let user select their own category

I would like to let category editor appear to any user and user can edit their preferred category(ies). **For example:** the category is about kind of job or profession and there are 10 categories(professions). When user login, they can edit profile and they can choose their profession as well. I can imagine that creating a custom taxonomy and let it appear in every user's menu. But how can I store individual user's selection? Is it possible to display a list in profile and let the user to check and save? How it should be implemented? Any idea is appreciated. Thanks.


Get the amount of posts on a given page

When you go to something like: site.com/?cat=2&page=2 you might see 3 posts, the page before might have 5 posts. I am looking for a way to count the posts on a given page. so if I am on page 2, with three posts, said function should return 3. any idea?


How can I list posts with different formats depending on order?

Let's say I have a regular main page listing posts, like in any regular WP blog. Now, I'd like to achieve this: if it's the first post in the list, use some layout, if second, another layout, if third, then another layout and so on. Even better: if it's post 1, 5, 9, 15, 22 -> use layout 1 . If it's 2,3,8, 12,14 -> use layout 2 (basically, adding re-usable code) For reference:               post 1 ->
....
     post 2 ->
....
     post 3 ->
....
     post 4 ->
....
     post 5 ->
....
      (so there's no "every given number of posts, use layout x", but "if in spot X, use layout X") I know I can do this with CSS, it's a snap, but it's not smart at all, since I want to use different post-thumbnail sizes, so loading big images for small sizes is ridiculous. I tried looking for WP conditionals, if_post and what not, but couldn't find anything, so really no clue on how to achieve this (without using masonry, which will have the same post_thumbnail problem) Any ideas on how to do this? Thanx in advance and Happy New Year for everybody! :)


Dynamically adding Captions to images

I have a site where the author has included Amazon Affiliate links. They've done this by adding the URL to product images. I'm wondering if there's a way to add a function that will automatically add a wp-caption below these images if they're linked to Amazon. Basically the condition would need to be: if an href containing an image is linked to a domain including 'amazon', add a caption below that image that says "Buy Now". The caption would also have the same link as that image. I've been able to do this with some hacky jQuery, but it doesn't always fire properly. I think there might be a better way... Thanks


Facebook like counter in custom field

is it possible then someone click on like, to take action to update post custom field with counts ? I just found only with http://graph.facebook.com/URL Maybe will be smarter solution ? Or ideas ?


Using Templates with Custom Post Type UI

I'm using this nifty little plugin called Custom Post Type UI to add custom post types to my WordPress site and am having a little trouble working out the best way to apply a page template to my custom post types. Does anyone know the best way to achieve this? Any help is appreciated. Thanks in advance!


Stop loading more posts if none left AJAX

I'm using the following JavaScript to load more pages in #work_items (see live at http://mtthwbsh.com):               jQuery(document).ready(function($){     $('.older a').live('click', function(e)  {     e.preventDefault();     $('.navigation').prepend("

");          var link = jQuery(this).attr('href');          var $content = '#work_items';     var $nav_wrap = '.navigation';     var $anchor = '.navigation .older a';     var $next_href = $($anchor).attr('href'); // Get URL for the next set of posts          $.get(link+'', function(data){     var $timestamp = new Date().getTime();     var $new_content = $($content, data).wrapInner('').html(); // Grab just the content     $('.navigation .loader').remove();     $next_href = $($anchor, data).attr('href'); // Get the new href     $($nav_wrap).before($new_content); // Append the new content     $('#rtz-' + $timestamp).hide().fadeIn('slow'); // Animate load     $('.older a').attr('href', $next_href); // Change the next URL     $('#work_items .navigation:last').remove(); // Remove the original navigation     });          });     });      Currently, if you are on the last page of posts and click "load more" again, it loads the same last page again. I'd like to conditionally not run the function if no pages are left (and replace the button with something like "no more posts"). How would I go about doing this? Here is the markup I'm using for the pagination:
     <?php $paged = (get_query_var('page')) ? get_query_var('page') : 1;       $args=array('category_name'=>'portfolio','posts_per_page'=>4,'paged'=>$paged       );       query_posts($args); ?>     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

              <a href="<?php the_permalink(); ?>">         <?php             if ( has_post_thumbnail() ) {             the_post_thumbnail();             }            ?>

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

          <?php endwhile; ?>      Another unrelated issue I'm having is that I am targeting every fourth post with nth-child(4n)to clear a margin, but for some reason after the first set of posts it starts targeting the first post of the next set. Is there something weird about how WordPress handles the order of elements? Thanks for your help!


conditional statement for active permalinks

I'm looking for a way to create an if...else statement hinging on whether pretty permalinks are active or not. So I need something which returns true when permalinks are changed from the default.               if (pretty_permalinks_are_on) {        do this;         } else {            do that;         }      Sort of thing. Just have no idea about the 'pretty_permalinks_are_on' part. If anyone would extend the hand of compassion and throw some crumbs to a php noob, I'd be a grateful learner :)


WordPress blog or WordPress website

I have created a WordPress blog. http://www.lifegetsdigital.com.wordpress.com I am planning to eventually move all the posts to a website of my own from the free WordPress service. Is it good move the blog to a private domain now or should i move after making some[say 100] posts using the free wordpress service? My primary concerns for not staying with WordPress is 1) Lack of google adsense support 2) Limited facebook integration 3) I believe plugins can be better installed and managed in our own server. Soliciting advice. Thanks


In woocommerce who is responsible for sending the receipt email?

I'm writing a Paypal Pro woo commerce extension to allow it to accept credit card directly on my websites. When I test things, everything works well. The only thing that I don't get is an email notification. So I would like to know does my gatway class need to send the receipt email or the internals of the WooCommerece should take care of that for successful order?


Force category-slug.php to show page, even if it doesn't exist

I have a custom query in category-slug.php, which works fine unless the category doesn't have that number of pages itself. If the category only has 5 pages of posts, but the query I put in has 7, it'll show 404 for pages 6 and 7. Pretty sure the reason for this is that category-slug.php checks to see if there is a page for that category before it gets to the query I have in the file. Is there a way for me to force it to run the page instead of showing a 404?


Naming Admin Menus and Submenus

I'm building a plugin that requires its own set of admin pages. I know how to create the top-level link and how to add sub-menus to it. However, what seems to happen is when I create the top-level link, it also automatically adds a submenu page of the same name if I add another submenu page to it. I'm simply looking for a way to change the name of my first submenu page so that it is different from the parent name. (i.e. in the admin panel, expanding the "Links" menu shows an "All Links" submenu page. Mine would instead say "Links" on top and then "Links" instead of "All Links")


How to edit homepage in Wordpress?

I'm gonna add a bit of code/edit my homepage in Wordpress, but I can't find the page's main file to edit. Take a look at this: http://uaral.tk This is my homepage. Now look at the page source in your browser. I want to edit these codes. But I can't find it anywhere in the website directory. It seems to be a html file, but can't find anything on the host to edit. I'm a total newbie, so please explain it clear. I'm using WordPress 3.6.1 and Wallbase theme. Thanks.


Set active class in a Php foeach

I have the following code to display a list of taxonomies in Wordpress. It works and my only concern is the active class (li class="active"). Err, how do I go about making it dynamic?
                 <?php                    echo '
All
'; # this remains static and unchanged                              if ( $count > 0 ) {                                  foreach ( $mylinks as $mylink ) {                         echo '
';                         # get current webdirectory and link to taxonomy menus                         echo'slug . ' class='. $mylink->slug .'" >';                         echo $mylink->name;                         echo "";                         echo "
";                     }                 }                ?>


Is there a full explanation on how to share a database with two Wordpress sites on same server?

I have read that you can have two wordpress database tables (using different table prefixes) to share the same database. I understand the concept but does any know of or can anyone provide an outline on the processes involved when using search for example. I would ideally, like to search from one site and be able to get results from both sites (_wp1 posts and _wp2 posts). How would I set this up? Current setup: Site one: Free site blog content, 5000 + posts, big database. Search will only return free content (_wp1) Site two: (new) A premium paid content subscription service featuring new blogs. Search will return new premium content (_wp2) AND the original free content. So is it best to write all posts from the free site and just set whether its premium, or should I separate where the blogs are written? Custom field filters need to work with this (assuming the posts have the same post setup on both). Thanks


How To Get Custom Post Type Category Title

I have a CPT called campsites and in there I have different categories ie. derbyshire, staffordshire, nottinghamshire etc. What I want to do is that when you click on a category eg. derbyshire, ideally I'd like it to say at the top of the page Campsites in derbyshire. Please help.


Can a plugin deactivate and delete itself once installed and activated?

I have a unique plugin whose purpose is to set up a new WordPress site with a theme, default widgets, default plugins, custom menus, pages, posts, etc. The plugin does everything it needs to do when activated and never runs again. I'm looking for suggestions on how I might, as the last step in the activation routine, deactivate and delete the plugin. Any help, suggestions, or example references appreciated.


comments reply script not working

Sadly my "reply" link for threaded comments is not working. ### The current situation: First i load the comments reply script (check if scripts content load: works) into the `<head>` using two functions (the first `wp_register_script()` at the init hook, the second `wp_print_scripts()` at the wp_head hook): Then i add the Reply link:               comment_reply_link(           array(               'reply_text'   => __( 'Reply', OXO_TEXTDOMAIN )             ,'depth'        => isset( $args['args']['depth'] ) ? $args['args']['depth'] : (int) 3             ,'max_depth'    => isset( $args['args']['max_depth'] ) ? $args['args']['max_depth'] : (int) 5          )         ,get_comment_ID()         ,$post->ID     );      which produces this html-output (example)               Reply      **I got everything according to any recommendation i read:** My comments are within a `<div id="comments">` and the comments form above it within a `<div id="respond">`. I still get dropped to the #respond-anchor and the comment form above the comments (`http://localhost/wordpress/?p=149&cpage=2&replytocom=11#respond`), instead of getting the comment form displayed below the comment i want to reply to. ### What may i do wrong? Google, tutorials, how-to and else were so far of no help. Everything seems to be according to the recommended standard... Thanks a lot.


Creating separate feeds for custom post types

My site has a few custom post types, news, events, you-tube, etc. I'd like to create an rss feed for each post type as well as a main with all. I've experimented an bit and found how to combine them into one but I haven't determined how to segment each. Do I need to create separate feed-rss.php for the templates as well as a custom function? This is the function I'm currently using to combine them into one feed.               //Custom post feeds     function myfeed_request($qv) {         if (isset($qv['feed']) && !isset($qv['post_type']))             $qv['post_type'] = array('post', 'youtube', 'event', 'news' );         return $qv;     }     add_filter('request', 'myfeed_request');


Change site url when moving site to another url?

Is it really neccessary to put `WP_HOME`, `WP_SITEURL` in `wp-config.php` or set these settings via admin panel every time when moving a WordPress instance to another url (for example: moving from dev environment to production)? Is there any better strategy?


An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration

I'm running WordPress on localhost WAMP server and whenever I go to "Plugins" or "Dashboard > Updates" or even to "Dashboard" nothing loads (no WordPress news, no updates, I'm not able to search for plugins or update them). In "Plugins" section I see this when I try to search for something: > An unexpected error occurred. Something may be wrong with WordPress.org or > this server’s configuration. If you continue to have problems, please try > the support forums. Have anyone encountered this issue before? It happened overnight a few weeks ago for me. It was working for a long time and then one day it stopped. What I already did:   * Searched Google and WordPress.org support forums. This issue is mentioned hundreds of times and there is no solution   * Checked php.ini, Apache's config, .htaccess, enabled potentially related PHP/Apache modules, checked if WAMP is set to "online" (my WAMP is accessible from other network computers now).   * Allowed every permission for WAMP in "Allow a program through Windows Firewall".   * Deactivated all plugins and themes other than the default one.   * Checked [Settings > General] to see if URLs are valid and they are.   * Resaved [Settings > Permalinks].   * **Installed another WordPress on this localhost and it works**. So, why the first one doesn't?