Trying to use WP_Query to display a custom post type

I'm trying to use WP_Query in function.php to display a custom post type on a certain page. I just can't seem to get it to work, can anyone see issues with my code? nothing is output at all and there are apparently no errors.               /*** add venues to venue page ***/     add_action( 'woo_post_inside_after', 'venue_loop' );          function venue_loop() {       if ( is_page(123) ) {         $args = array(           'post_type' => 'tribe_venue',           'orderby' => 'title',            'order' => 'DESC',           'posts_per_page' => 10         );              $venue_posts = new WP_Query($args);              if ( $venue_posts->have_posts() ) {            while( $venue_posts->have_posts() ) {              $venue_posts->the_post();             $output .= '
' . get_the_title() . '
';           }         }         return $output;       }     }


wp_mail recipient

I am new at this and seeking help, I'm really need a light at the end of the tunnel, so if you can help me, please do it! I will be very grateful! The question is, what do I do to when someone fills out a form and send, wordpress sends this form to the existing users in the website, and filtered by location / service you choose in form? It is possible to do something like this in wordpress? I quite understand html / css / javascript bases, and very little php. maybe that's the problem. In my view I think it should be doing some modifications here and there ... I found something similar here, but in my case, my group emails would have to be filtered by the parameters they chose the form. I apologize if I'm not being clear, or if I'm asking for much, really needed was a guide to help me deal with these problems, but if you can solve this I will already be very happy :) Greetings to all


Install and Update plugins on a VPS Wordpress installation

I have installed Wordpress. Everything works smooth except one thing: I cannot ftp through Wordpress - meaning I cannot update or install plugins. Using my vps root user and password doesn't work (but it works using Filezilla). Any idea what are the steps needed to enable this feature? Is it a permission issue, or maybe I need to create dedicated users on the VPS?


How to make the Wordpress Editor not accept HTML?

So basically, I am using the Wordpress editor on my site and I do not want my users posting ANY HTML in it at all since it can cause some problems. My Wordpress Editor is currently like this:               <?php wp_editor( get_the_content() , 'post_content'); ?>      In simple terms, I would basically like it to just look like a simple HTML `textarea`, and strip all HTML tags (like what the PHP function `strip_tags` does. Although, I cannot get this PHP functionality working with a simple `textarea`... Not to sure why, just a coding problem with my theme. So yes, is something like this possible?


Multiple taxonomies, what should the permalink look like?

I need to implement a list of a custom post_type that has to be able to filter them by two taxonomies, I found this answer that helps out with the `wp_query` syntax My question is, now, how should the url look like? The post_type: `ad` and the taxonomies are `area` and `category` Current posts url is: `/category/bikes` wich works or `/ads/area/area-5` wich works But how sould I generate the slug for the page where is filtering by `category==bikes` and `area==area-5` ? -EDIT- Outside wp I would rewrite something like this (for this example): `/ads/(bikes|cars)/(area-5|area-3)` to: `/posts.php?type=ads&category=bikes&area=area-5` But I don't see how to work around that in wp Any ideas? thanks!


Wordpress Theme that returns all posts as a JSON object?

Are there any Wordpress themes that will just return a JSON object that can be processed by Javascript to display a list of postings?


Is wp_deregister_script the best way to deal with unneeded plugins in a page?

I use some "heavy duty" plugging, like syntaxhighlighter, GD star rating etc. i create a de-register.php file which i use to deregister scripts and styles whenever they are not used. **Example:**               add_action( 'wp_print_styles', 'my_deregister_styles', 100 );     function my_deregister_styles() {              if (is_home()) {             wp_deregister_style('bbp-default');             wp_dequeue_style('bbp-default');             wp_deregister_style('bbp-default-rtl');             wp_dequeue_style('bbp-default-rtl');                  wp_deregister_style('edd-styles');             wp_dequeue_style('edd-styles');                  wp_deregister_style('onp-sociallocker');             wp_dequeue_style('onp-sociallocker');         }     }      In this page i have about 200 lines since i am de-registering the css and js files of 5 plugins (or so) when ever they are not being used. For that end i created some checkbox metaboxes in each post where i can click and say "i use rating here" (for example). **My question is.**   Is my way wrong? Does the whole process of using wp_deregister_style and wp_deregister_script defeats the purpose? Does the actual use of those actions slows my site down? Is there a better way to only use plugins and the styles and scripts they come with when i need them and only then? **I have of course read and searched** but couldn't find anything else.   Would love to hear of any solution you think might fit.


Check if post belongs to any category

In my homepage loop, I have something that will show which category the post is in. It will say something like "Posted 4 hours ago in Sports by ...". However, when there is no category set, it will omit the category (obviously) and just say "Posted 4 hours ago in by ...". My question is: how do I check if a post belongs to _any_ category in WordPress. I know that the function `in_category()` exists, but I would like to avoid having to type out all of the categories, in case they change, or whatever. Thanks!


Author page: Comments and Ratings?

I have a mult-author site where the author page gets high traffic. People want to know more about them. I have modified the author page to show more info, some custom fields, etc. but what I'd really like to do is turn on Comments for the author.php page (so that OTHER logged in users can leave review-like messages for the Author), and ultimately offer a star-ratings type of effect so that Users can "rate" the author. I have searched for plugins and other functions but it seems like everything is for Posts or Products or something. Any insight is greatly appreciated!


Using wp_tag_cloud('format=array') to print tag names without links?

I'm trying to pull just the tag names as an array collection in order to write them out as a simple listing, without links, but the array that's returned does not send the name as an indexible item.               array(2) {       [0]=> string(129) "tag 1"       [1]=> string(127) "tag 2"     }      Is there another method I can use to get the entire site's tag collection with just the tag names? This is my current code, but because of the array indexes, I get the links as well.               $tagNames = wp_tag_cloud('format=array');     echo implode($tagNames,", ");


Post Via Email - How to send Attachments with it (e.g. PDF File or JPEG Image)?

In regards to the 'Post via Email' feature, does anyone know of a way to send an attachment with it? In this case it would be a PDF document.


Transfer from register plus to register plus redux plugin

register plus no longer works with WP 3.0 and has been replaced by register plus redux. I haven't found anything about upgrading to that plugin and keeping all the data, does anybody have any experience with that?


Plain image uploading - no links, no classes, no sizes

When I upload a photo into the post it turns out like this                     Is there a way so it will just look like this?


Display image for first sticky post only

Working on news paper site here i am using sticky.I want display first 6 sticky post its displaying very good but problem is that every sticky showing there post image(feature image) here i just want display image for the first sticky only and for other 5 sticky i want display only tittle of the post.
     <?php           $args = array(                 'category_name' => 'महाराष्ट्र',                 'post__in' => get_option( 'sticky_posts' ),                 'showposts' => '6',                  );          $the_query = new WP_Query( $args );              while ($the_query -> have_posts()) : $the_query -> the_post(); ?>

<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(array(342,173), array ('class' => 'alignleft1')); ?>

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

           <?php          endwhile;          ?>


How can I externally retrieve a post's custom sized image

I would like to be able to display my last X wordpress posts in the sidebar of my phpBB3 forums. Since I can't use WP's functions (because trying to use WP's functions into phpBB3 generates conflicts), I have to use a hand-made php script. So, my question is, has anyone a custom php script that would enable me to retrieve, from a given wp post ID, it's first image in a given size* ?   * Knowing that each of my wordpress post may have several images, and that I generate several custom image sizes when adding an image to a post.   * The size I want is 300x100 and is cropped, so I guess that if i can retrieve the image's filename, I just would have to add -300x100.jpg at the end to get the correct filename. Cheers !


How to enqueue script if widget is displayed on page?

I created a widget that uses a jquery plugin, and I used is_active_widget to enqueue the script, it's working fine but it's also including the script even on pages that doesn't show this widget. so is there a way to only enqueue the script if this widget is showing ? thanks in advance.


How to determine if a post was last edited in the Visual Editor

Is there any way to determine whether a post was last edited using the Visual or HTML editor? Perhaps by hooking into an action?


Counter problem, infinite loop when post_per_page equals X

(updated) I´m using this query to loop divs in to my front page slider. I use counters to split 4 posts into a slider, then open a new slider etc. Also a counter to set a class to every fourth post (to fix margin). This worked great until I wanted to use the 'post_per_page' argument. If I put it to -1 or something dividable by 4, I get an infinite loop that loops in all posts ad infinitum. So. It´s pretty clear that my problem has to do with the counters. I´m not a coder myself and put this code together from different sources and with the help of the almighty internet. This is what my full query looks like:
     <?php      $args = array(     'post_type' => 'fastighet',     'posts_per_page' => -1,     'orderby' => 'ASC'                  );     ?>     <?php $query = new WP_Query( $args ); ?>      <?php if( $query->have_posts() ) : ?>
          <?php $count = 0; ?>         <?php while ($query->have_posts()) : $query->the_post(); $c++;     if( $c == 4) {     $style = 'thumbnail-fourth';     $c = 0;     }     else $style=''; ?>           <div class="fastighet-thumbnail <?php echo($style) ?>" id="post-<?php the_ID(); ?>">
             <a href="<?php the_permalink();?>"><?php the_post_thumbnail( 'admin-list-thumb', array( 'alt' => ''.get_the_title().'', 'title' => ''.get_the_title().'' )); ?>

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

           <?php $count++; if ( ( $count % 4 ) == 0 && $query->have_posts() ) { ?>

     <?php } endwhile; ?>
     <?php endif; ?>          <?php wp_reset_query(); ?>
      Can anybody see what´s wrong with this? How I could modify it to allow me to use 'posts_per_page' like I should be?


Add default Backgrounds

Is there code or a plugin that would make it possible to add default backgrounds, like you can with default headers in Twenty ten. Seems like the same frame work for backgrounds and headers.


What would cause edit buttons for plugins to disappear?

in the plugins page, under each plugins' name usually there are buttons/links like "Deactivate | Edit | Settings". Recently on one of my sites the "Edit" (and "Settings") button has disappeared. I have just "Deactivate" or "Activate | Delete". My question is - what could cause this? I am logged in as an administrator, so I should see the buttons. I suspect that something might have vent wrong with the installation of the last plugin but I am not sure. Is there some scenario when these buttons get disabled (hidden) or do I have a bug / error?


Posts are being displayed from old to new, in ascending order

I developed a site for a client using a premade theme called "Adapt". When I was developing on my own server, the blog posts were posting as they should in descending order (i.e. new to old with new being on top). However, when I moved the completed work to my client's server and imported his blog posts from his old site, the posts started displaying in ascending order (i.e. old to new with old being on top). I've tried deactivating all plugins but the problem remains. I've also tried adding `<?php query_posts($query_string . '&orderby=date&order=DESC'); ?>` right before `<?php if (have_posts()) : ?>`, but nothing changed. The funny thing is that the blogs on the archive pages are behaving as they should. The posts are shown from new to old, with new being on top. Below is the code for the index page where the blogs are behaving this way. Any help in getting this sorted out would be appreciated. Thank you.               <?php get_header(); ?>              <?php if (dt_is_sidebar_active('homepage_ad')) : ?>
                     <?php dynamic_sidebar('homepage_ad'); ?>
         <?php endif; ?>

                         <?php get_sidebar(); ?>

                      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                                               <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">                              <?php if ( has_post_thumbnail() ) : ?>

                                                                      <?php the_title(); ?>                                     <?php dt_overlay_icon(); ?>
                             <a href="<?php the_permalink(); ?>"><?php dt_image(300, ''); ?>
                         <?php endif; ?>                              <?php the_category(', '); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

                                  <?php $format = get_post_format(); ?>                             <?php if ($format == "image" || $format == "gallery" || $format == "video") : ?>                             <img src="<?php echo get_template_directory_uri(); ?>/images/icon-<?php echo $format; ?>.png" alt="<?php echo $format; ?>" />                             <?php endif; ?>                                  <?php dt_excerpt(20); ?>
                              <a class="read-more" href="<?php the_permalink(); ?>"><?php _e('Read More', 'engine'); ?>
                                  <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' '.  __('ago', 'engine'); ?>                                  <?php comments_number(__('No Comments', 'engine'), __('1 Comment', 'engine'), __('% Comments', 'engine')); ?>

                 <?php endwhile; endif; ?>                      <?php get_template_part('includes/index-loadmore'); ?>

                 <?php dt_pagination(); ?>

          <?php get_footer(); ?>      Edit: This (in `functions.php`) was the culprit:               function excludeCat($query) {         if ( $query->is_home ) {             $query->set('cat', '-5377');         }         return $query;     }     add_filter('pre_get_posts', 'excludeCat');


How to create a theme option-menu page to save user values

I've created a wordpress theme and new in wordpress development I want to create option page to take some values from user and I've little bit done with that but confused where and how to save that data I want to create user interface in short.


How can I add programmatically custom taxonomy terms to a custom type post when saving posts?

**Scenario:** there is a 'Recommended Books' section on the website which uses the _'book' custom post type_ and the _'author' custom taxonomy_. I'm using Amazon Product Advertising API for retrieving book data and covers. When adding a new 'book' into WordPress, the user copies the book ID (ASIN) into the post edit field, and clicks 'Publish'. Then, when saving the post, the post title (book title) and the author taxonomy term should be programmatically filled in through Amazon. (These are used to offer 'Order by' functionality on the front end.) Currently I'm using `wp_insert_post_data` to hook into the 'book' saving process, and the `wp_set_object_terms` function to try to add the custom taxonomy term to the 'book'. **The problem is:** the `wp_set_object_terms` function doesn't seem to work. It won't add anything, albeit returns an array which, according to Codex, should mean success. Though the returning array is odd (as far as I see). When using post ID 107 and term ID 3 (instead of an author string, for testing purposes) the returning array displays the following with `print_r`:               Array     (     [0] => 3     )      (Also tried with `wp_set_post_terms`, and it makes no difference.) My complete function:               // Function to automatically retrieve and store Amazon Book data (title and author) when adding 'book' type posts     if( function_exists('asa_item') ) {         add_filter( 'wp_insert_post_data', 'filter_handler', '99', 2 );         function filter_handler( $data , $postarr ) {                  // Proceed only if book is added/edited             if ( $postarr['post_type'] !== 'book')                 return $data;                  // Try to Extract ASIN from post body; ignore everything else             if ( preg_match( '/([0-9A-Z]{10})/', $data['post_content'],  $matches) ) {                 // Successful, store ASIN                 $book_asin = $matches[0];                 // Wrap ASIN in AmazonSimpleAdmin shortcode (with 'cover' template) automatically for user convenience                 $data['post_content'] = '[asa cover]' . $matches[0] . '[/asa]';             } else {                 // Unsuccessful: set to draft, return and show error message                 $data['post_status'] = 'draft';                 add_filter('redirect_post_location', 'my_redirect_post_location_filter_1', 99);                 return $data;             }                  // Retrieve and store book data from Amazon with AmazonSimpleAdmin plugin             $book_data = explode( "<sep>", asa_get_item( $book_asin, 'book_data' ) );             /******************              * index 0 = title              * index 1 = author              ******************/                  // Check data; if no data, set to draft, return and show error message             if ( $book_data[0] == '' ) {                 $data['post_status'] = 'draft';                 add_filter('redirect_post_location', 'my_redirect_post_location_filter_2', 99);                 return $data;             }                  // Fill in Post Title with Amazon data if empty             if ( $data['post_title'] == '' )                 $data['post_title'] = $book_data[0];                  // Fill in Author tag with Amazon data if missing             if ( ! has_term( $book_data[1], 'author', $postarr['ID'] ) ) {                 wp_set_object_terms( $postarr['ID'], $book_data[1], 'author' );             }                  return $data;         }     }


W3 Total Cache - How to disable "Performance" menu under multisite?

I am running a multisite install with domain mapping and W3 Total Cache set up on each of the sites. I don't use a network in the traditional sense - each site is generally independent. I only have the second checkbox checked in "Domain Options" for the mapping plugin, if that gives you any sort of idea. Each site's administrators can still see the Performance menu and change its options, however. I would like to disable this. Best method?


excludeCat function reverses order of blog posts

I'm using the code below to remove category #5377 from the query on the home page. However, this code is also reversing the order of blog posts for some reason. How can I alter this code to _only_ remove category #5377 and keep the same order of posts?               function excludeCat($query) {         if ( $query->is_home ) {             $query->set('cat', '-5377');         }         return $query;     }     add_filter('pre_get_posts', 'excludeCat');      Edit 1: Full `index.php` code:               <?php get_header(); ?>              <?php if (dt_is_sidebar_active('homepage_ad')) : ?>
                     <?php dynamic_sidebar('homepage_ad'); ?>
         <?php endif; ?>

                         <?php get_sidebar(); ?>

                      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                                               <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">                              <?php if ( has_post_thumbnail() ) : ?>

                                                                      <?php the_title(); ?>                                     <?php dt_overlay_icon(); ?>
                             <a href="<?php the_permalink(); ?>"><?php dt_image(300, ''); ?>
                         <?php endif; ?>                              <?php the_category(', '); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

                                  <?php $format = get_post_format(); ?>                             <?php if ($format == "image" || $format == "gallery" || $format == "video") : ?>                             <img src="<?php echo get_template_directory_uri(); ?>/images/icon-<?php echo $format; ?>.png" alt="<?php echo $format; ?>" />                             <?php endif; ?>                                  <?php dt_excerpt(20); ?>
                              <a class="read-more" href="<?php the_permalink(); ?>"><?php _e('Read More', 'engine'); ?>
                                  <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' '.  __('ago', 'engine'); ?>                                  <?php comments_number(__('No Comments', 'engine'), __('1 Comment', 'engine'), __('% Comments', 'engine')); ?>

                 <?php endwhile; endif; ?>                      <?php get_template_part('includes/index-loadmore'); ?>

                 <?php dt_pagination(); ?>

          <?php get_footer(); ?>      Edit 2: Added `<?php global $wp_query; var_dump($wp_query->query_vars); ?>` just before `<?php if (have_posts()) : while (have_posts()) : the_post(); ?>` in the code above and got this:               array(61) {       ["error"]=>       string(0) ""       ["m"]=>       string(0) ""       ["p"]=>       int(0)       ["post_parent"]=>       string(0) ""       ["subpost"]=>       string(0) ""       ["subpost_id"]=>       string(0) ""       ["attachment"]=>       string(0) ""       ["attachment_id"]=>       int(0)       ["name"]=>       string(0) ""       ["static"]=>       string(0) ""       ["pagename"]=>       string(0) ""       ["page_id"]=>       int(0)       ["second"]=>       string(0) ""       ["minute"]=>       string(0) ""       ["hour"]=>       string(0) ""       ["day"]=>       int(0)       ["monthnum"]=>       int(0)       ["year"]=>       int(0)       ["w"]=>       int(0)       ["category_name"]=>       string(0) ""       ["tag"]=>       string(0) ""       ["cat"]=>       string(0) ""       ["tag_id"]=>       string(0) ""       ["author"]=>       string(0) ""       ["author_name"]=>       string(0) ""       ["feed"]=>       string(0) ""       ["tb"]=>       string(0) ""       ["paged"]=>       int(0)       ["comments_popup"]=>       string(0) ""       ["meta_key"]=>       string(0) ""       ["meta_value"]=>       string(0) ""       ["preview"]=>       string(0) ""       ["s"]=>       string(0) ""       ["sentence"]=>       string(0) ""       ["fields"]=>       string(0) ""       ["menu_order"]=>       string(0) ""       ["category__in"]=>       array(0) {       }       ["category__not_in"]=>       array(0) {       }       ["category__and"]=>       array(0) {       }       ["post__in"]=>       array(0) {       }       ["post__not_in"]=>       array(0) {       }       ["tag__in"]=>       array(0) {       }       ["tag__not_in"]=>       array(0) {       }       ["tag__and"]=>       array(0) {       }       ["tag_slug__in"]=>       array(0) {       }       ["tag_slug__and"]=>       array(0) {       }       ["post_parent__in"]=>       array(0) {       }       ["post_parent__not_in"]=>       array(0) {       }       ["author__in"]=>       array(0) {       }       ["author__not_in"]=>       array(0) {       }       ["ignore_sticky_posts"]=>       bool(false)       ["suppress_filters"]=>       bool(false)       ["cache_results"]=>       bool(true)       ["update_post_term_cache"]=>       bool(true)       ["update_post_meta_cache"]=>       bool(true)       ["post_type"]=>       string(0) ""       ["posts_per_page"]=>       int(6)       ["nopaging"]=>       bool(false)       ["comments_per_page"]=>       string(2) "50"       ["no_found_rows"]=>       bool(false)       ["order"]=>       string(4) "DESC"     }


A fresh installation show no css

I just had a fresh installation of `Wordpress` 3.9.1, but all pages have no styling (not the site nor the admin). It is showing just perfect in `firefox` while `chrome` messing it up. When I inspect element, there's no `CSS` attached to the pages. So where the problem came from?


Display post_meta in Shortcode

Simple shortcode turning overcomplicated               <?php     function recent_posts() {          $q = new WP_Query(        array( 'orderby' => 'date', 'posts_per_page' => '1')      );          $list = '
';          while($q->have_posts()) : $q->the_post();     //$location = bloginfo('template_directory');     $imgsrc = get_post_meta($q->ID, 'blog-left-image', true);          $list .= '
' . get_the_title();     $list .= '';     $list .= '
';          endwhile;          wp_reset_query();          return $list . '
';          add_shortcode("recent_posts", "recent_posts");?>      Thought this would be straightforward. Want to create a shortcode to display the post thumbnails. **Problem is** , the get_post_meta(...) outputs nothing and the bloginfo('template_directory') doesn't concatenate correctly.


muliple wordpress multisite installs on the same sever

I want a separate production and test/dev instance. Is it possible to have two installs of wordpress multi on the same server, using different databases or do I need 2 servers, one for test and one for production? I want to have a test instance where I can try out plugins, setting changes etc, without affecting my production instance


List taxonomy terms for post as checkboxes

I'm modifying the plugin `Wordpress Frontend User` for my custom post type(s). What I need to edit is the custom taxonomy terms. In order to do this, I need to list my terms as labels and have checkboxes associated with the labels (in the end associated with the taxonomy when I send a post update). What I have now is as follows:               $jobsTerms = get_terms('jobtype',array( 'taxonomy' => 'jobtype' ));      foreach($jobsTerms as $term){         echo "<label for='term-" . $term->slug . "'>" . $term->name . "</label>";         echo "<input type='checkbox' name='term" . $term->slug . "' value='" . $term->name . "' />     }      But other than that, I'm lost as to how to check to see if that post has a term selected (if so add `checked=checked` to the input). I'm also lost as to how to update this taxonomy when I click submit (which fires a couple custom `update_post_meta` calls and a `wp_update_post` call. Any help?


Sort by Custom Post Type (Multiple Loop)

I have changed my set-up slightly to have 2 separate post types "Premium Listing" and "Free Listing" and a taxonomy for Listing_category. Here is an example of my Loop The idea is to display Premium listings followed by Free listings on the archive page of my taxonomy. This seems to work however when I add it to my taxonomy_listing_category.php I get results that are not specific to my taxonomy. For instance http://www.domain.com/listing_category/carriers/ should show 1 Premium and then Free listings with taxonomy Carriers, however it shows all taxonomies. The code is below               <?php   $args = array(         'post_type' => 'premium_listing',         'orderby' => 'rand',         );         $the_query = new WP_Query( $args );     ?>          <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) :     $the_query->the_post(); ?>     <?php the_title(); ?>     <?php endwhile; else: ?>     <?php get_template_part( 'inc/posts/post-404' );?>     <?php endif; ?>          <?php rewind_posts(); ?>          <?php   $args = array(         'post_type' => 'free_listings',             'post_per_page' => 1,         'orderby' => 'rand',         );         $the_query = new WP_Query( $args );?>          <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) :     $the_query->the_post(); ?>     <?php the_title() ;?>     <?php endwhile; else: ?>
Sorry, there are no posts to display
     <?php endif; ?>      My theme doesnt have an archive.php so I have used the index.php as the basis for creating taxonomy_listing_category.php Any ideas Richard. Richard


Tabbed theme options query about add_settings_section callback function

I have been building a tabbed option page based on some tutorials I found, using the settings API. Here is the code http://pastebin.com/bbSnhFP5 . It's all actually working fine for me but it's not ideal and I'm sure there's a better way around it. The problem is that when I used this tutorial as a base and adapted it to use `add_settings_section()` and `add_settings_field()` calls, I ended up with code which used `register_setting()` (as opposed to perhaps `add_theme_page()`) to make the distinction between the tabs ( this is the way the tutorial did it ). This meant that I had to use `do_settings_fields()` to print the fields instead of `do_settings_sections()` because `do_settings_sections()` prints out the entire page of options (as defined by `add_theme_page()`) on every tab. The end result of this is that while I need to have the `add_settings_section()` calls ( because I'm using `do_settings_section()`) and therefore I need to have callbacks for them, the callbacks cant actually be made to do anything because as far as I know the only way to print out these callbacks is to use `do_settings_sections()` which I cant use, so it seems like I'm missing something. As a sort of hack I have used a switch statement to allow me to put some text at the start of each page but I feel there must be a better way of doing this and some way of allowing multiple sections per tab. Can anyone add anything?


Include jQuery plugin in Wordpress

Wordpress already comes with jQuery. But what if I want to use a jQuery plugin on the entire blog? What's the best way to include on the entire site? And what if I only want to include it on one particular post/page?


How to make pages that arent indexed for ajax applications

I'm using a content section on my homepage to switch through multiple loops with ajax tabs and to do that a tutorial told me to make multiple pages and assign each page with a different template which contains the loop I want to display. But by doing that I'm creating top level pages that display loops on a blank page without styling. That makes me think they will get indexed and I'll have the unstyled pages showing up in searches. What's the right way to do this?


How I can internationalize variables within the function _e () __ (), etc?

I have intro function variables and i wish internationalize dynamic. I have the follow code:               _e($widget['description'], MyStaticClass::$i18n_prefix);      When I run the poedit this internationalization (`$widget['description']`) is not done. How I can it dynamic? Thanks


automatic send email at custom time

I want to send an automatic email every day at 10:00 I tried this code               $timeN = date('H:i');     $timeS = date('10:00');     if ($timeS == $timeN) {         $to = get_option('admin_email');         $nfrom = "my site";         $subject = "test";         $body = " Hello";         $headers = 'From: "'. $nfrom .'" <' . $to . '>';         wp_mail=$mail($to, $subject, $body, $headers);     }      It works if I refresh the page. If the page has been refreshed or opened 10 times it is sends 10 messages. How can i fix it? I am sorry, I'm not a programmer and do not speak English well.


Enabling Widgets By Default in Custom Theme Development

In WP theme building, if a sidebar is not active, can I turn it on? Also, if the sidebar is active, and doesn't contain any widgets, can I add some? I'm a theme and plugin developer, but this is something I haven't learned to do yet.


WP_query taxonomy + get all posts with two terms from same taxonomy

This is a follow up question to Add_query_arg + two times the same argument? I want to get the post count from all posts tagged with 2 different tags from same taxonomy               $args2 = array(         'post_type' => 'custom',         'tax_query' => array( 'relation' => 'AND' )     );     $args['tax_query'][0] = array(          'taxonomy' => 'events',         'field' => 'slug',         'terms' => 'tag1'      );     $args['tax_query'][1] = array(         'taxonomy' => 'events',         'field' => 'slug',         'terms' => 'tag-2'      );     $query = new WP_Query($args);     echo $query->post_count;      With this code I only get the post_count for one of these tags. How i do get both? I couldn't find an answer at Wordpress codex. Help is much appreciated.


get_option and list of options

I'm trying to retrieve some values stored in the option panel of WordPress, however the list of the options I found on the site seems not complete. Perhaps it's me looking in the wrong place. What for getting the name of the author of a given post?


Paginate Comments Using WP_Comment_Query

I'm creating a page of all comments on my site. The below query is basically what I need except I want the option to paginate through all the comments instead of loading them all on one page. I've read a few question on pagination and comments but they mainly relate to wp_list_commments. I've read this answer by Pippin but it doesn't give much details. Can anyone point me in the right direction? I don't feel this is a duplicate question and it would improve the Wordpress codex page for WP_Comment_Query if they could explain how to paginate.               <?php     $args = array(        'number' => 20        'offset' => 20     );          // The Query     $comments_query = new WP_Comment_Query;     $comments = $comments_query->query( $args );          // Comment Loop     if ( $comments ) {         foreach ( $comments as $comment ) {             echo '
' . get_the_title($comment->comment_post_ID) . '
';             echo '
' . $comment->comment_content . '
';         }     } else {         echo 'No comments found.';     }     ?>


Extract & Display the REAL first image attached to a post - extend the_post_thumbnail()

I have an interesting problem which I am sure someone here can solve. I have gone through a bunch of different plugins and code snippets in search for _the perfect code to extract a primary image to be associated with a post_. If the new WP 3.0 featured image element is used then there is of course no issue but there are a bunch of situations where a post may not have a "featured image" assigned. In these situations if you were to use the standard code of:               <?php echo the_post_thumbnail( array(200,200) ); ?>      in your template... nothing is going to be displayed. For these type of situations I am looking for the perfect solution. Essentially, what I need is the ability to have a type of "failover" when the_post_thumbnail does not exist but I also still need the ability to set the image size just like I can with the code from the_post_thumbnail. This "failover" I believe should have two steps to it:   1. Check the "Media Gallery" for this post and locate the image with the highest sort order (or added post parent as shown in the plugin below)   2. If no sort order is set or if blank then extract the first image from the post content. The good news is that for the two points above I seem to have found two separate snips of code which take care of these requests individually (copied below for review) however nothing which combines all three of these elements in one. So, to recap: Instead of doing a bunch of if/then calls to check if a post thumbnail exists and then running a check against the code below I was hoping that someone might be able to provide a clean/combined function which would allow me to echo a single function along with size variables which can achieve all three these goals as mentioned above. HERE ARE THE BITS OF CODE MENTIONED ABOVE: * * * **FOR #1: Get the First Image based off the order from the Media Gallery:** This code works by first looking for any attachments in the wp_posts database table that have a “post_parent” ID that matches the current post and as a second step for posts with multiple image attachments, returning the attachment with its “menu_order” field set to “1″. If no image attachments match the current post ID, the plugin returns “false”.               // AUTOMATICALLY EXTRACT IMAGES BASED ON ASSOCIATED GALLERY ORDER     // THIS CODE EXTRACTS THE FIRST IMAGE BASED ON THE ORDER IN THE MEDIA GALLERY     // PLUGIN FROM: http://mekosh.org/projects/ordered-thumbnails        function ordered_thumbnails( $display = 'true', $class='' ) {         global $post;         // get all image attachments for this post         $images = get_children( array( 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', order=>"asc" ) );         // if the post has image attachments         if( $images !== false ) {             // find the image in position 1             foreach($images as $i) {                 if ( $i->menu_order == 1 ) {                     $img_id = $i->ID;                 }             }             // if the images were unordered             if ( $img_id == '' ) {                 $i = array_slice( $images, 0, 1 );                 $img_id = $i[0]->ID;             }             // get image data             $image = wp_get_attachment_image_src( $img_id, 'thumbnail' );             $result = array(                 'url'       => $image[0],                 'width' => $image[1],                 'height'    => $image[2]             );             // should the image be displayed or should data be returned as an array?             if ( $display == 'true' ) {                 return _e( '' );             } else {                 return $result;             }         } else {             // post does not have any image attachments             return (bool) false;         }        }     // create template tag "ordered_thumbnails"        add_action( 'ordered_thumbnails', 'ordered_thumbnails', 2 );      * * * **FOR #2: Extract the first image from the post content**               // THIS CODE GETS THE FIRST IMAGE EXTRACTED DIRECTLY FROM THE POST CONTENT              function bm_extract_string($start, $end, $original) {         $original = stristr($original, $start);         $trimmed = stristr($original, $end);         return substr($original, strlen($start), -strlen($trimmed));         }         function getFirstImage() {         $content = get_the_content();         $pic_string = bm_extract_string('src="','" ',$content);         $imagesize = getimagesize($pic_string);         list($width, $height, $type, $attr) = getimagesize($pic_string);         $link = get_permalink();         $title = get_the_title($post->post_title);         echo '';         }


Limit CPT to only have a single view page sometimes

Imagine a CPT, let us call it "News". This News Post type is mainly used for displaying short News inline on the front page. But some of those News will be longer, mandating to only display an excerpt on the front page and having a single view. The rule would probably be that I put the text used on the front page in the excerpt all the time, while only entering content sometimes. What I've thought of so far: If none would need a separate page I'd just disable `publicly_queryable` for it. Just leaving a single view for everything and doing a redirect back to the frontpage if the content is empty sounds like a dirty hack. Just filtering those without content probably wouldn't suffice. What about rewrite rules? Plugins that generate Sitemaps? Search? Is there anything else I missed? I am mainly looking for hints on the general direction to implement this, not necessarily an implementation.


In WordPress 3.x, I can't access posts from all blogs in the network

I use WordPress a ton, but I'm somewhat new to multisite. Now that 3.0 has brought multisite into the main core, shouldn't there be an easy loop function that allows you to display the most recent posts from across your network, in a loop, for me to output in PHP as I want? Does anybody know if this exists and I'm just missing it?


get_term_by seems to be failing

Code:               print_r($wp->query_vars);     echo "

".get_query_var('term');     echo "

".get_query_var('taxonomy');     $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy') );     echo "

$term";      Output:               Array ( [titles] => windows-powershell-v2 [taxonomy] => titles [term] => windows-powershell-v2 )           windows-powershell-v2          titles      As you can see, the first three lines run fine. The fourth line fails with no error - but it terminates page execution. The specified term does indeed exist in the taxonomy; this is being reached with the URL /titles/windows- powershell-v2/. Any idea what I'm doing wrong?


How to show the same content on multiple URLs?

A client currently has a website set up with three distinct sub-sites (run off a single WordPress install), each with a slightly different theme (same layout, different colour scheme. I currently have it set up so each sub-site is a page, with all of it's pages as children. The header.php checks which page is the parent and includes the appropriate style. The problem comes with pages that are identical throughout the site, which the client wishes to have accessible from each sub-site as a separate page. For example the about page, should be accessible from /site1/about and /site2/about and use the theme for the site that has requested it, but display the same content on both. I could just create the child pages, and set the rel="canonical" to reference the original, but from a maintenance point of view, it would preferable to have a single page that the content is pulled from on each of the sub sites. And so to the question, how do I get several URLs/pages to pull their content from a single source? EDIT: Here's an example of the desired structure:   * **www.example.com** \- Displays links to the three main services, as well as general information   * **www.example.com/about** \- Displays information about the client, styled to match www.example.com   * **www.example.com/service1** \- Displays navigation related to the specific service, styled in it's own individual colour, alongside generic links (about, contact)   * **www.example.com/service1/about** \- Displays the navigation and stylesheet for /service1, but using the content from www.example.com/about (and with a canonical link reference to www.example.com/about) This is then repeated for /service2 and /service3.


Custom options below pages/posts editor?

I want to add permanently boxes below Visual/HTML editor for each page/post. I've never played with custom fields before, and I'm not sure is it way to go? If yes ten tell me, good people of StackExchange, how to achieve something like that (grey boxes): ![enter image description here](http://i.stack.imgur.com/eerx1.png)


How to add a random image to a post from gallery and only show one? I know how to add an image and a gallery. I need to have one image from the galley show on the page at random each time the page is loaded. The page should only show one image at a time. Is there a plugin or short code to do this? I know how to make gallery's random, but they show all the images. **Answer** :               $args = array(                      'post_type' => 'attachment',                     'numberposts' => 1,                     'orderby' => 'rand',                     'post_status' => null,                     'post_parent' => get_the_ID(),                     'post_mime_type'  => 'image'                 );                  have_posts(); //must be in the loop                 the_post(); //set the ID                      $images = get_children( $args );                                  if ($images) {                 foreach ( $images as $attachment_id => $attachment ) {                         echo wp_get_attachment_image( $attachment_id, 'full' );                     }                 }                 wp_reset_query();


One register_sidebar function works, the other doesn't?

Here's how I have my code set up in the functions file:               register_sidebar(array(         'name' => 'Latest Updates',         'before_widget' => '<span>',         'after_widget' => '</span>',         'before_title' => '',         'after_title' => ''     ));     register_sidebar(array(         'name' => 'BBRB Loves (Video Width - 200px)',         'before_widget' => '',         'after_widget' => '',         'before_title' => '',         'after_title' => ''     ));      The first `register_sidebar` function gets called in header.php and the second function gets called in index.php. When I put in opening and closing `<span>` tags in the second function (i.e. `before_widget` and `after_widget`), the correct tags get outputted. But when I put in the same opening and closing `<span>` tags in the first function, nothing gets outputted but the default `<div class="textwidget">foobar</div>`. The only difference between the two is that one is called in the header and the other is called in the index. However, BOTH widgets show up in the dashboard and when I fill them with text, they both get outputted—just not the before/after tags. What am I doing wrong?


How i can i add a split button or list box to the WordPress TinyMCE instance

I have added a custom button to the tinymce to insert my shortcodes, but I have so many and I want to make a splitbutton instead and I can't figure how. Anyone can help. Here's the code that I've used to create the normal button: in functions.php :               /**     Hook into WordPress     */          add_action('init', 'onehalf_button');       /**     Create Our Initialization Function     */          function onehalf_button() {             if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {          return;        }             if ( get_user_option('rich_editing') == 'true' ) {          add_filter( 'mce_external_plugins', 'add_plugin' );          add_filter( 'mce_buttons', 'register_button' );        }          }     /**     Register Button     */          function register_button( $buttons ) {      array_push( $buttons, "|", "onehalf" );      return $buttons;     }     /**     Register TinyMCE Plugin     */          function add_plugin( $plugin_array ) {        $plugin_array['onehalf'] = get_bloginfo( 'template_url' ) . '/js/tinymce_buttons.js';        return $plugin_array;     }      and in the custom plugin .js               // JavaScript Document     (function() {         tinymce.create('tinymce.plugins.onehalf', {             init : function(ed, url) {                 ed.addButton('onehalf', {                     title : 'One Half Column',                     image : url+'/mylink.png',                     onclick : function() {                          ed.selection.setContent('[one_half]' + ed.selection.getContent() + '[/one_half]');                          }                 });             },             createControl : function(n, cm) {                 return null;             },         });         tinymce.PluginManager.add('onehalf', tinymce.plugins.onehalf);     })();      I've found something here http://tinymce.moxiecode.com/tryit/listbox_splitbutton.php but can't figure out how to implement it into WP. Anyone can help? Thanks.


Get page content by category or tag

I'm trying to sort of emulate the Views behaviour in Drupal with Wordpress, but doing it in theme templates. Now, I have pages that are assembled by using wp_query in the template to get posts belonging to a certain category. But now I also want to be able to create another page which performs a query to get all the pages above, but only the content actually in those pages, not the content in the posts within them. Taking this a step further, I would actually have wanted to be able to refer to specific fields within the target page and display them. The end result should be a sort of post list on this page with the titles and introductions of each of the "assembled" pages. I should mention that I am quite new to both Drupal and Wordpress, and am pretty much testing them both out to try to decide what suits my site best (not a blog!) So far I have liked the Views and Panels approach of Drupal, but in most other aspects Wordpress has seemed more suitable. But how would one go about doing the above task in Wordpress? I have managed to get the desired result by doing this (at least getting the page in question, and only the content in it, not the posts. But I cannot select more granular information though):               $my_query = new WP_Query( array( 'post_type' => 'page', 'post__in' => array( 76, 151 ) ) );      But that means having to specify particular page ids, which is undesirable. I want it to be possible for users to add pages to be included in the summary page just by adding a tag or category on them. I have not been able to manage to use categories or tags to select the same content as above though (even though I have plugins installed to allow both on pages).


Is it possible to export WordPress from command line? I don't mean use `mysqldump` to export the database, but create the xml file used to easily import to another WordPress installation.


Special Formatting for WordPress Plugin Description?

Last question, I am supplying the Description of my plugin see the part of this called "Customizing the Plugin Information Box", and I can't get any HTML format to work. It just prints off like normal text. Wondering how to get formatting in this?


Widgetize Buddypress Activity Plus plugin?

Is there anyway to widgetize the Activity Plus plugin so I can display the post form in a widget area on my Genesis News child theme front page? I'm using the BP Sitewide Activity Widget to display the activity stream in a widget area and it has an optional post form but it doesn't display the Activity Plus buttons. I tried to copy the php from the Activity Plus plugin into the php widget (by Peplamb)but it didn't work. I also tried to use the genesis_after_header hook, to no avail. I don't know php - I just know "cut&paste." So I wasn't able to determine if there was a particular part of that php to use. Any help?


Custom Portfolio String

I have a field on my portfolio admin page which shows the url when the user write a url(obviosly). I want to when the user write in the field, elements appear along with it. And if the field is empty dont shows anything. The code that shows what the user is writing in this field is:               <?php echo get_post_meta($post->ID, '_url', TRUE);?>      I tried:               <?php if (strpos($post->ID,'_url') !== true) {   ?>                  [CONTENT] <?php echo get_post_meta($post->ID, '_url', TRUE); ?> [/CONTENT]          <?php } ?>


Taking WordPress table prefixes into account

Given the code below how would I account for the table prefix that can change from installation to installation? Is there a better way to write it than an SQL query? Is there a variable I've missed that provides the table prefix for times like this?               // setting posts with current date or older to draft     if (!wp_next_scheduled('sfn_expire_hook')){         wp_schedule_event( time(), 'hourly', 'sfn_expire_hook');     }     add_action( 'sfn_expire_hook', 'sfn_show_expire');     function sfn_show_expire(){         global $wpdb;         $server_time = date('mdy');         $result = $wpdb->get_results("SELECT * FROM GrandDn4wP_posts WHERE post_type = 'show' AND post_status = 'publish'");         if( !empty($result)) foreach ($result as $a){             $show_time = get_the_time('mdy', $a->ID);             if ( $server_time > $show_time ){                $my_post = array();                $my_post['ID'] = $a->ID;                $my_post['post_status'] = 'draft';                wp_update_post( $my_post );             }         } // end foreach     }


At what point during a typical request does the $wpdb object become available?

I've wrote some custom SQL queries inside a class method and noticed they seem to work if I hook the method to the `wp` action. If I hook to the `plugins_loaded` action, they don't seem to work. **My question:** At what point during a typical request does the `$wpdb` object become available? Refs:   * http://codex.wordpress.org/Plugin_API/Action_Reference   * http://codex.wordpress.org/Class_Reference/wpdb


Adding a new layout for genesis

I have added a new layout for the genesis framework called "modalwindow". This layout should only display the content because it is a modal window loading page content (I don't want any of the header, sidebars, footers, menus or anything else displayed, just the content from that page). What do I add for it to only display the content of that page with nothing else? ie: code to remove header, sidebars, footers, menus, etc. At the moment I have selected the "modalwindow" layout for the page in WP admin- now need to strip everything from the content. Code:               // from "/themes/genesis/lib/structure/layout.php"          <?php     /**      * Controls layout structure.      *      * @package Genesis      */          add_filter( 'content_width', 'genesis_content_width', 10, 3 );     /**      * This function filters the content width based on the user selected layout.      *      * @since 1.6      */     function genesis_content_width( $default, $small, $large ) {              switch ( genesis_site_layout() ) {             case 'full-width-content':                 $width = $large;                 break;             case 'content-sidebar-sidebar':             case 'sidebar-content-sidebar':             case 'sidebar-sidebar-content':                 $width = $small;                 break;             default:                 $width = $default;         }              return $width;          }          add_filter('body_class', 'genesis_custom_body_class', 15);     /**      * This function/filter adds custom body class(es) to the      * body class array. It accepts values from a per-post/page      * custom field, and only outputs when viewing singular page.      *      * @since 1.4      */     function genesis_custom_body_class( $classes ) {              $new_class = is_singular() ? genesis_get_custom_field( '_genesis_custom_body_class' ) : null;              if ( $new_class ) $classes[] = esc_attr( sanitize_html_class( $new_class ) );              return $classes;          }          add_action('genesis_meta', 'genesis_load_stylesheet');     /**      * This function loads the stylesheet.      * If a child theme is active, it loads the child theme's stylesheet,      * otherwise, it loads the Genesis stylesheet.      *      */     function genesis_load_stylesheet() {              echo '<link rel="stylesheet" href="'.get_bloginfo('stylesheet_url').'" type="text/css" media="screen" />'."\n";          }          add_filter('body_class', 'genesis_header_body_classes');     /**      * This function/filter adds new classes to the       * so that we can use psuedo-variables in our CSS file,      * which helps us achieve multiple header layouts with minimal code      *      * @since 0.2.2      */     function genesis_header_body_classes($classes) {              // add header classes to $classes array         if ( ! is_active_sidebar( 'header-right' ) )             $classes[] = 'header-full-width';              if ( 'image' == genesis_get_option('blog_title') || 'blank' == get_header_textcolor() )             $classes[] = 'header-image';              // return filtered $classes         return $classes;          }          add_filter('body_class', 'genesis_layout_body_classes');     /**      * This function/filter adds new classes to the       * so that we can use psuedo-variables in our CSS file,      * which helps us achieve multiple site layouts with minimal code      *      * @since 0.2.2      */     function genesis_layout_body_classes($classes) {              // get the layout         $site_layout = genesis_site_layout();              // add new class to $classes array         if ( $site_layout ) $classes[] = $site_layout;              // return filtered $classes         return $classes;     }          add_action('genesis_after_content', 'genesis_get_sidebar');     /**      * This function outputs the sidebar.php file      * if specified in theme options or in-post options      *      * @since 0.2      */     function genesis_get_sidebar() {              // get the layout         $site_layout = genesis_site_layout();              // don't load sidebar on pages that don't need it         if ( $site_layout == 'full-width-content' ||             $site_layout == 'modalwindow' ) return;              // output the primary sidebar         get_sidebar();     }          add_action('genesis_after_content_sidebar_wrap', 'genesis_get_sidebar_alt');     /**      * This function outputs the sidebar_alt.php file      * if specified in theme options or in-post options      *      * @since 0.2      */     function genesis_get_sidebar_alt() {              // get the layout         $site_layout = genesis_site_layout();              // don't load sidebar-alt on pages that don't need it         if ( $site_layout == 'content-sidebar' ||             $site_layout == 'sidebar-content' ||             $site_layout == 'full-width-content' ||             $site_layout == 'modalwindow' ) return;              // output the alternate sidebar         get_sidebar('alt');          }      Code:               // from "/themes/genesis/lib/functions/layout.php"          <?php     /**      * Register default Genesis layouts.      *      * @package Genesis      */          add_action('genesis_init', 'genesis_create_initial_layouts', 0);     /**      * Creates the initial layouts when the 'init' action is fired      *      * @since 1.4      */     function genesis_create_initial_layouts() {              genesis_register_layout( 'content-sidebar', array(             'label' => __('Content-Sidebar', 'genesis'),             'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/cs.gif',             'default' => true         ) );              genesis_register_layout( 'sidebar-content', array(             'label' => __('Sidebar-Content', 'genesis'),             'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/sc.gif'         ) );              genesis_register_layout( 'content-sidebar-sidebar', array(             'label' => __('Content-Sidebar-Sidebar', 'genesis'),             'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/css.gif'         ) );              genesis_register_layout( 'sidebar-sidebar-content', array(             'label' => __('Sidebar-Sidebar-Content', 'genesis'),             'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/ssc.gif'         ) );              genesis_register_layout( 'sidebar-content-sidebar', array(             'label' => __('Sidebar-Content-Sidebar', 'genesis'),             'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/scs.gif'         ) );              genesis_register_layout( 'full-width-content', array(             'label' => __('Full Width Content', 'genesis'),             'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/c.gif',         ) );              genesis_register_layout( 'modalwindow', array(             'label' => __('Sizing Guide Layout', 'genesis'),             'img' => CHILD_URL . '/images/stcsb.gif',         ) );     }          /**      * This function registers new layouts by modifying the global      * $_genesis_layouts variable.      *      * @since 1.4      */     function genesis_register_layout( $id = '', $args = array() ) {              global $_genesis_layouts;              if ( !is_array( $_genesis_layouts ) )             $_genesis_layouts = array();              // Don't allow empty $id, or double registrations         if ( !$id || isset( $_genesis_layouts[$id] ) )             return false;              $defaults = array(             'label' => __( 'No Label Selected', 'genesis' ),             'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/none.gif',         );              $args = wp_parse_args( $args, $defaults );              $_genesis_layouts[$id] = $args;              return $args;          }          /**      * This function allows a user to identify a layout as being the default      * layout on a new install, as well as serve as the fallback layout.      *      * @since 1.4      */     function genesis_set_default_layout( $id = '' ) {              global $_genesis_layouts;              if ( !is_array( $_genesis_layouts ) )             $_genesis_layouts = array();              // Don't allow empty $id, or double registrations         if ( !$id || !isset( $_genesis_layouts[$id] ) )             return false;              // remove default flag for all other layouts         foreach ( (array)$_genesis_layouts as $key => $value ) {             if ( isset( $_genesis_layouts[$key]['default'] ) ) {                 unset( $_genesis_layouts[$key]['default'] );             }         }              $_genesis_layouts[$id]['default'] = true;              return $id;          }          /**      * This function unregisters layouts by modifying the global      * $_genesis_layouts variable.      *      * @since 1.4      */     function genesis_unregister_layout( $id = '' ) {              global $_genesis_layouts;              if ( !$id || !isset( $_genesis_layouts[$id] ) )             return false;              unset( $_genesis_layouts[$id] );              return true;          }          /**      * This function returns all registered Genesis Layouts      *      * @since 1.4      */     function genesis_get_layouts() {              global $_genesis_layouts;              if ( !is_array( $_genesis_layouts ) )             $_genesis_layouts = array();              return $_genesis_layouts;          }          /**      * This function returns the data from a single layout,      * specified by the $id passed to it.      *      * @since 1.4      */     function genesis_get_layout( $id ) {              $layouts = genesis_get_layouts();              if ( !$id || !isset( $layouts[$id] ) )             return;              return $layouts[$id];          }          /**      * This function returns the layout that is set to default.      *      * @since 1.4      */     function genesis_get_default_layout() {              global $_genesis_layouts;              $default = '';              foreach ( (array)$_genesis_layouts as $key => $value ) {             if ( isset( $value['default'] ) && $value['default'] ) {                 $default = $key; break;             }         }              // return default layout, if exists         if ( $default ) {             return $default;         }              return 'nolayout';          }          /**      * This function checks both the custom field and      * the theme option to find the user-selected site      * layout, and returns it.      *      * @since 0.2.2      */     function genesis_site_layout() {              // If viewing a singular page/post         if ( is_singular() ) {                  $custom_field = genesis_get_custom_field( '_genesis_layout' );             $site_layout = $custom_field ? $custom_field : genesis_get_option( 'site_layout' );              }              // If viewing a taxonomy archive         elseif ( is_category() || is_tag() || is_tax() ) {             global $wp_query;                  $term = $wp_query->get_queried_object();                  $site_layout = $term && isset( $term->meta['layout'] ) && $term->meta['layout'] ? $term->meta['layout'] : genesis_get_option( 'site_layout' );              }              // If viewing an author archive         elseif( is_author() ) {                  $site_layout = get_the_author_meta( 'layout', (int)get_query_var('author') ) ? get_the_author_meta( 'layout', (int)get_query_var('author') ) : genesis_get_option('site_layout');              }              // else pull the theme option         else {                  $site_layout = genesis_get_option( 'site_layout' );              }              // Use default layout as a fallback, if necessary         if ( !genesis_get_layout( $site_layout ) ) {             $site_layout = genesis_get_default_layout();         }              return esc_attr( apply_filters( 'genesis_site_layout', $site_layout ) );          }          /**      * A helper function that outputs the form elements necessary to select a layout.      *      * You must manually wrap this in an HTML element with the class of 'genesis-layout-selector'      * in order for the CSS and Javascript to apply properly.      *      * @since 1.7      */     function genesis_layout_selector( $args = array() ) {              /** Merge defaults with user args */         $args = wp_parse_args( $args, array(             'name'     => '',             'selected' => '',             'echo'     => true         ) );              $output = '';              foreach ( genesis_get_layouts() as $id => $data ) {                  $class = $id == $args['selected'] ? 'selected' : '';                  $output .= sprintf( '
 <input type="radio" name="%4$s" id="%5$s" value="%5$s" %6$s />',                     esc_attr( $data['label'] ),                     esc_attr( $class ),                     esc_url( $data['img'] ),                     esc_attr( $args['name'] ),                     esc_attr( $id ),                     checked( $id, $args['selected'], false )             );              }              /** Echo or Return output */         if ( $args['echo'] )             echo $output;         else             return $output;          }          /**     * A helper function to do the logic, and potentially echo/return a structural wrap div.     *     * @since 1.6     */     function genesis_structural_wrap( $context = '', $output = '
', $echo = true ) {              $genesis_structural_wraps = get_theme_support( 'genesis-structural-wraps' );              if ( ! in_array( $context, (array) $genesis_structural_wraps[0] ) )             return '';              switch( $output ) {             case 'open':                 $output = '
';                 break;             case 'close':                 $output = '
';                 break;         }              if ( $echo )             echo $output;         else             return $output;          }          /**      * Helper function for returning layout key 'content-sidebar'.      *      * @since 1.7      */     function __genesis_return_content_sidebar() {         return 'content-sidebar';     }          /**      * Helper function for returning layout key 'sidebar-content'.      *      * @since 1.7      */     function __genesis_return_sidebar_content() {         return 'sidebar-content';     }          /**      * Helper function for returning layout key 'content-sidebar-sidebar'.      *      * @since 1.7      */     function __genesis_return_content_sidebar_sidebar() {         return 'content-sidebar-sidebar';     }          /**      * Helper function for returning layout key 'sidebar-sidebar-content'.      *      * @since 1.7      */     function __genesis_return_sidebar_sidebar_content() {         return 'sidebar-sidebar-content';     }          /**      * Helper function for returning layout key 'sidebar-content-sidebar'.      *      * @since 1.7      */     function __genesis_return_sidebar_content_sidebar() {         return 'sidebar-content-sidebar';     }          /**      * Helper function for returning layout key 'full-width-content'.      *      * @since 1.7      */     function __genesis_return_full_width_content() {         return 'full-width-content';     }          /**      * Helper function for returning layout key 'modalwindow'.      *      * @since 1.7      */     function __genesis_return_modalwindow_content() {         return 'modalwindow';     }


404 when fetching image from wp-content/uploads/

I get 404 status when fetching images, and the http still contains that image. Image shows up in a browser, but the 404 code breaks some applications. calls to wp-content/uploads/ are redirected in .htaccess:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteRule (.*) /index.php?getfile=$1 [L]     </IfModule>      Why do I get a 404 status if the image is in there and is served?


custom user tables supported in SharDB plugin?

I'm trying out the SharDB plugin, but it doesn't seem to be respecting my CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE declarations -- it is querying `$shardb_prefix.users` instead of my custom table name. Anyone know if this plugin is supposed to support the CUSTOM_USER_TABLE definitions? Thanks!


How to remove the tagline from the HTML <title>?

I'm using the default Wordpress 2011 theme on a new blog I'm setting up. I've got everything basically setup fine for now. I have experience with PHP/MySQL and HTML/CSS, but haven't used WordPress as yet. When I set the blog up, it asked for a tagline under general settings, which I provided. This is showing below the blog heading, which is fine, however I don't want it to appear in the HTML title. At the moment the `<title>` element looks like this: "Blog Name | Tagline". I just want the blog name. How can I change this?


Admin Table Filtering not Working for Custom Post Type

When I attempt to filter a custom post type's admin table(CPT's posts) using the select dropdown, the filtered table that loads shows 0 items. This is the url structure that is being created by submitting the filter table form (I've added linebreaks for readability): {HOST}/wp-admin/edit.php   ?s   &post_status=all   &post_type=dog   &action=-1   &dog=labrador   &filter_action=Filter   &paged=1   &mode=list   &action2=-1 There are no errors, I've tried numerous tutorials and countless tweaks and can't seem to get anything to take. Anyone have any idea what might be going on? I can add any filters, actions, functions, declarations I've used to this question if they would be of use -- just let me know what would be helpful to see.


Output the_title() inside the_content()

I'm sure this isn't possible but thought I'd ask. I have a testimonials section, the html of each testimonial is like so
           the testimonal here blah, blah, blah, blah, blah, blah, blah, blah           Name of person
      Now in WP I have the testimonials as a Custom post type. The Name of person is the title and the testimonial is the content. Can I output the testimonial post so it's like the html. So it would be the_title inside a 'em' which is inside the 'p' of the_content. I know I could add the name inside the content in wordpress and then make that italic but I know the client wouldn't like doing this.


Select a Sidebar from Page Creation

I'm building a WP site that needs to have the ability for unique widgets on a per-section basis. I've built out the page structure of the site, then built the sidebar structure of the site. It goes like this...               Services (section - uses Services sidebar)         Service Name (page - uses Services sidebar)         Service Name (page - uses Services sidebar)     Industries (section - uses Industries sidebar)         Industry (page - uses Industries sidebar)         Industry (page - uses Industries sidebar)      While on a Service Name post creation page, I'd like to have a Select dropdown in a meta box on the side that allows for the selection of a registered sidebar. For instance, while creating a new Service Name page, I'd like to select the Services sidebar as the desired sidebar for that page. Then, I could reference that object in my sidebar.php file. The reason I want this setup is because I have nothing to tie to that says "if this page falls under the Services parent page, I'd like this sidebar to show up every time." I _could_ use conditionals and tie to page name, page ID, slug, etc... but this isn't flexible and doesn't fit the CMS request. What if the client changes Services to Our Services? what if they recreate the Services page and it gets a new ID? I can't restrict my client to these conventions. I can't rely on Widget Logic plugin or anything like it because the client would have no idea how to use it; it clearly wasn't built for the technologically-challenged crowd. Any help or advice with this would be super-helpful. And if my logic in how I'm building this isn't right, please feel free to tell me I'm a big dummy and explain how this would be done best. Thank you!


Executing Arbitrary Code at a Specific URL without Creating a Post or Page?

I am trying to figure out which hooks I can tie into in order to read the incoming URL prior to the query actually being run. A quick look tells me maybe `wp_loaded` or `posts_selection` would be good choices but would hate to miss out on something obviously better for my needs. `template_redirect` sounded promising but seems to be called after content is selected so I do not think that is going to work. I thought the rewrite code might help, but the likes of `generate_rewrite_rules` do not seem to allow for arbitrary code to be executed... it seems to all be geared toward redirecting to existing content. My goal is to write redirection code that I need to not be tied to an existing piece of content. I have found several plugins that do similar things, but all seem to require that a post or page be added to the system for the redirect to be attached to. For instance, I want `/foo/bar` to redirect to `/baz`, but I don't want to have to create a page `foo` or a sub-page of `foo` called `bar`.


Do something when user creates post (that's pending)

How do i do something when a (normal) user creates a post (that is submitted for approval) I currently have:               function emailinvestment( $new_status, $old_status, $post_id ) {                  if ( $old_status != 'new' && $new_status != 'pending' ) {                      // Do something (not working atm)                  }         }              add_action('transition_post_status','emailinvestment', 10,3);      Thanks for taking a look at this one :)


Display posts on a separate page from certain authors?

I've been working on this for days. I've tried the WP codex, Google searching, etc, and I know I'm not doing something right but my patience has run out :( . I have 3 authors. I am trying to display their posts on separate pages so it's not cluttering the main page and I can use a static page. I have templates made for all 3 I want to call 5 posts from each author ID to show on their page. If one of my author IDs is 4, what would be the best code to use? Can someone give me an example? I would appreciate any help I can get!


Redirect missing pagination to base page

I have a strange problem with wp_redirect that I can't seem to solve myself. I'm trying to redirect previously existing pages back to the root of the page so: http://example.com/slug/page/5/?sort=no-image would redirect back to http://example.com/slug/?sort=no-image in case the page number doesn't exist anymore. I hooked into template_redirect with the bellow function but for some reason I end up in a redirect loop. What am I doing wrong? Edit: Forgot to mention that the URL ending in the redirect loop also has a query string appended.               function filter_redirect() {     global $wp_query, $wp;     $requested_url = add_query_arg( $_SERVER['QUERY_STRING'], '', trailingslashit(home_url( $wp->request )) );     $redirect_url = preg_replace('#/page/[0-9]+?(/+)?$#', '/', $requested_url);     $current_page = (get_query_var('paged'));     if ($current_page > $wp_query->max_num_pages) {     wp_redirect($redirect_url,301);     exit();     }     }     add_action('template_redirect', 'filter_redirect' );


Should I remove_filter in order to replace a filter?

If a plugin modified one of wp's filters by "add_filter", and I want to discard the modification and modify the wp's filter by my own codes. Should I remove the plugin's filter before I add my own filter?


Use wordpress for school results?

I want to use wordpress as a school results script. Create a database of students, subjects and results. And the end-user query a name of an ID to get results & data for specific student. Is there such a plugin to do so?


Recent post by custom select query

Hi this is the code which displays recent post from all category. but I want to dispaly post from any single category. I dont want to change the code please help.               function mdv_recent_posts( $no_posts = 5, $before = '
', $after = '
', $hide_pass_post = true, $skip_posts = 0, $show_excerpts = false, $include_pages = false ) {     global $wpdb;               $time_difference = get_settings( 'gmt_offset' );     $now = gmdate( "Y-m-d H:i:s", time() );     $request = "SELECT ID, post_title, post_excerpt, post_date, comment_count FROM $wpdb->posts WHERE post_status = 'publish' ";               if ( $hide_pass_post )         $request .= "AND post_password ='' ";     if ( $include_pages )         $request .= "AND (post_type='post' OR post_type='page') ";     else         $request .= "AND post_type='post' ";     $request .= "AND post_date_gmt < '$now' ORDER BY post_date DESC LIMIT $skip_posts, $no_posts";     $posts = $wpdb->get_results( $request );     $output = '';          if ( $posts ) {         foreach ( $posts as $post ) {             $post_title = $post->post_title;             $permalink = get_permalink( $post->ID );             $date=date('F j, Y', strtotime($post->post_date));             $output .= $before . ''.$date.'' . esc_html( $post_title ) ;             if ( $show_excerpts ) {                 $post_excerpt = esc_html( $post->post_excerpt );                 $output.= '
' . $post_excerpt;             }             $output .= $after;         }     } else {         $output .= $before . "None found" . $after;     }     echo $output;     }


Use different template than author.php for get_author_posts_url()

I have a client that wants two pages for each author profile:   First Page - has user info, bunch of social media links, etc. Using author.php for this.   Second Page - list of author posts   I've built everything, and here's my question: **Is there a way to have get_author_posts_url() use a template other than author.php?**


Does wp track views for posts?

I want to do a query and sort posts by views. Is this possible? I'm not even sure where to start..


Custom Taxonomy Sort For a Custom Query

I am trying to custom sort taxonomies on a custom query I have written for one of my website I cannot use any custom plugin as I have tried and they do not work with my current setup.               add_action('init', 'ecommerce_create_post_type', 1);     function ecommerce_create_post_type() {          // Create new Latest-News custom post type     $labels = array(     'name' => _x('Products', 'post type general name'),     'singular_name' => _x('Products', 'post type singular name'),     'add_new' => _x('Add New', 'Product'),     'add_new_item' => __('Add New Product'),     'edit_item' => __('Edit Product'),     'new_item' => __('New Products'),     'view_item' => __('View Products'),     'search_items' => __('Search Products'),     'not_found' =>  __('No Products found'),     'not_found_in_trash' => __('No Products found in Trash'),      '_builtin' =>  false,      'parent_item_colon' => ''       );     $args = array(     'labels' => $labels,     'public' => true,     'publicly_queryable' => true,     'exclude_from_search' => false,     'show_ui' => true,      'query_var' => true,     'sort' => true,     'register_meta_box_cb' => 'icom_meta_boxes',     'rewrite' => array(             'slug' => 'products',             'with_front' => false         ),     'capability_type' => 'post',     'hierarchical' => true,     'menu_position' => 20,     'supports' => array('title','editor','thumbnail','custom-fields','excerpt'),     'menu_icon' => ICOMMERCE_DIR.'/images/cart.png'       );        register_post_type('products',$args);            // Product categories, is heirarchical and can use permalinks     $labels = array(             'name' => _x( 'Product Categories', 'taxonomy general name' ),             'singular_name' => _x( 'Product Category', 'taxonomy singular name'),             'search_items' => __( 'Search Categories'),             'all_items' => __( 'All Product Categories'),             'parent_item' => __( 'Product Category'),             'parent_item_colon' => __( 'Parent Product Category:'),             'edit_item' => __( 'Edit Product Category'),             'update_item' => __( 'Update Product Category'),             'add_new_item' => __( 'Add New Product Category'),             'new_item_name' => __( 'New Product Category Name')             );          register_taxonomy( 'icomcat', 'products', array(         'rewrite' => array(         'slug' => 'product-category',         'with_front' => false,         'sort' => true,         ),         'labels' => $labels,     ) );     }      using the following code , I am fetching the latest products                 <?php     global $wpdb;     $prefix=$wpdb->prefix;     $latest_products = $wpdb->get_results(       "SELECT a.term_id, a.name        FROM ".$prefix."terms a,".$prefix."term_taxonomy b        WHERE b.parent=".$prodcatid."        and a.term_id=b.term_id        and b.taxonomy='icomcat'        order by a.name desc");      if ( count( $latest_products ) > 0 ) {$count=0;     echo '

  <?php $current_category = single_cat_title("", false); ?>

';         foreach ( $latest_products as $latest_product ) { $count=$count+1;      ?>      I am trying to sort these results using the date field. as you can see I am firing               $latest_products = $wpdb->get_results(       "SELECT a.term_id, a.name        FROM ".$prefix."terms a,".$prefix."term_taxonomy b        WHERE b.parent=".$prodcatid."        and a.term_id=b.term_id        and b.taxonomy='icomcat'        order by a.name desc");       but my results are not sorted by date.


Speeding SQL queries for a large database?

I am using a WordPress plugin called feedwordpress in order to run a planet like website on wordpress (See it here). The plugin is great except for one thing - it hogs down my (VPS) server into submission once every week or so. In a recent e-mail exchange with the webadmin he wrote the following: > It does look like the increased mysql resource usage is being caused by slow > queries being run by r-bloggers.com. Here is a copy of some of the logs that > are being produced. You would need to optimize this site and database > further to have it running as efficiently as possible. If these changes have > already been made, your best option would be to look into a large upgrade > for your VPS due to the high level or resources and traffic that your site > needs and sees. Here are the logs:               # Time: 110614 16:11:35     # User@Host: rblogger_rblogr[rblogger_rblogr] @ localhost []     # Query_time: 104 Lock_time: 0 Rows_sent: 0 Rows_examined: 54616     SELECT SQL_CALC_FOUND_ROWS wp_rb_posts.* FROM wp_rb_posts WHERE 1=1 AND ((guid = '235cbefa4424d0cdb7b6213f15a95ded') OR (guid = 'http://www.r-bloggers.com/?guid=235cbefa4424d0cdb7b6213f15a95ded') OR (guid = 'http://www.r-bloggers.com/?guid=235cbefa4424d0cdb7b6213f15a95ded') OR (MD5(guid) = '235cbefa4424d0cdb7b6213f15a95ded')) AND wp_rb_posts.post_type IN ('post', 'page', 'attachment', 'revision', 'nav_menu_item') AND (wp_rb_posts.post_status = 'publish' OR wp_rb_posts.post_status = 'future' OR wp_rb_posts.post_status = 'draft' OR wp_rb_posts.post_status = 'pending' OR wp_rb_posts.post_status = 'trash' OR wp_rb_posts.post_status = 'auto-draft' OR wp_rb_posts.post_status = 'inherit' OR wp_rb_posts.post_status = 'private') ORDER BY wp_rb_posts.post_date DESC LIMIT 1570, 10;     # User@Host: rblogger_rblogr[rblogger_rblogr] @ localhost []     # Query_time: 237 Lock_time: 0 Rows_sent: 0 Rows_examined: 54616     SELECT SQL_CALC_FOUND_ROWS wp_rb_posts.* FROM wp_rb_posts WHERE 1=1 AND ((guid = '235cbefa4424d0cdb7b6213f15a95ded') OR (guid = 'http://www.r-bloggers.com/?guid=235cbefa4424d0cdb7b6213f15a95ded') OR (guid = 'http://www.r-bloggers.com/?guid=235cbefa4424d0cdb7b6213f15a95ded') OR (MD5(guid) = '235cbefa4424d0cdb7b6213f15a95ded')) AND wp_rb_posts.post_type IN ('post', 'page', 'attachment', 'revision', 'nav_menu_item') AND (wp_rb_posts.post_status = 'publish' OR wp_rb_posts.post_status = 'future' OR wp_rb_posts.post_status = 'draft' OR wp_rb_posts.post_status = 'pending' OR wp_rb_posts.post_status = 'trash' OR wp_rb_posts.post_status = 'auto-draft' OR wp_rb_posts.post_status = 'inherit' OR wp_rb_posts.post_status = 'private') ORDER BY wp_rb_posts.post_date DESC LIMIT 570, 10;     # Time: 110614 16:18:13     # User@Host: rblogger_rblogr[rblogger_rblogr] @ localhost []     # Query_time: 257 Lock_time: 0 Rows_sent: 0 Rows_examined: 54616     SELECT SQL_CALC_FOUND_ROWS wp_rb_posts.* FROM wp_rb_posts WHERE 1=1 AND ((guid = '956e208f101562f6654e88e9711276e4') OR (guid = 'http://www.r-bloggers.com/?guid=956e208f101562f6654e88e9711276e4') OR (guid = 'http://www.r-bloggers.com/?guid=956e208f101562f6654e88e9711276e4') OR (MD5(guid) = '956e208f101562f6654e88e9711276e4')) AND wp_rb_posts.post_type IN ('post', 'page', 'attachment', 'revision', 'nav_menu_item') AND (wp_rb_posts.post_status = 'publish' OR wp_rb_posts.post_status = 'future' OR wp_rb_posts.post_status = 'draft' OR wp_rb_posts.post_status = 'pending' OR wp_rb_posts.post_status = 'trash' OR wp_rb_posts.post_status = 'auto-draft' OR wp_rb_posts.post_status = 'inherit' OR wp_rb_posts.post_status = 'private') ORDER BY wp_rb_posts.post_date DESC LIMIT 570, 10;     # Time: 110614 16:19:02     # User@Host: rblogger_rblogr[rblogger_rblogr] @ localhost []     # Query_time: 83 Lock_time: 0 Rows_sent: 0 Rows_examined: 54616     SELECT SQL_CALC_FOUND_ROWS wp_rb_posts.* FROM wp_rb_posts WHERE 1=1 AND ((guid = '6c589e661f03a67b0529fab2f080bfd3') OR (guid = 'http://www.r-bloggers.com/?guid=6c589e661f03a67b0529fab2f080bfd3') OR (guid = 'http://www.r-bloggers.com/?guid=6c589e661f03a67b0529fab2f080bfd3') OR (MD5(guid) = '6c589e661f03a67b0529fab2f080bfd3')) AND wp_rb_posts.post_type IN ('post', 'page', 'attachment', 'revision', 'nav_menu_item') AND (wp_rb_posts.post_status = 'publish' OR wp_rb_posts.post_status = 'future' OR wp_rb_posts.post_status = 'draft' OR wp_rb_posts.post_status = 'pending' OR wp_rb_posts.post_status = 'trash' OR wp_rb_posts.post_status = 'auto-draft' OR wp_rb_posts.post_status = 'inherit' OR wp_rb_posts.post_status = 'private') ORDER BY wp_rb_posts.post_date DESC LIMIT 1440, 10;      Which leads me to my question - what in this logs might indicate to me what is happening (why should such queries take so long?)? is it possible to optimize these? If so, how? Thanks, Tal


Persistent sidebar.php

This sidebar does not let itself be aligned either on the left or on the right, so that the content below (the posts) can be placed next to it. Sidebard on one side, posts on the other. This is the page: http://www.joaoalexandre.com/wordpressteste/artigos/ And this is the index.php: http://pastebin.com/F9khFceg


how do we display all posts from a particular category in homepage?

I am trying to show all the posts of a particular category on my home page. There are over 70 posts in that category. I would like have a pagination so that only 10 posts are displayed and have pagination set so users can move to next page by clicking the page nos. Can this be possible? Here is the current code that i have                  global $post;             $args = array( 'numberposts' => 5, 'offset'=> 0, 'ORDER BY'=>'date', 'order'=>'desc','category' => 1 );             $myposts = get_posts( $args );             foreach( $myposts as $post ) :  setup_postdata($post);                //  while(have_posts()):the_post();                 $attrs = array(             'src'   => $src,             'class' => "",             'alt'   => get_the_title(),             'title' => get_the_title(),         );      Thanks Prady


3 Columns, 3 Categories, One Archive, and Pagination

I have three columns, each displaying 2 posts, each from different categories and each being a new query. These three columns are shown on thier parent category page, which is set to display 6 posts per page.               $soundPosts = new WP_Query('posts_per_page=2&cat=4&paged=' . get_query_var( 'paged' ));     $viewsPosts = new WP_Query('posts_per_page=2&cat=5&paged=' . get_query_var( 'paged' ));     $wordsPosts = new WP_Query('posts_per_page=2&cat=6&paged=' . get_query_var( 'paged' ));      At the moment pagination kind of works, but not properly. It is using the pagination for the main parent category.

<?php previous_posts_link('< Previous') ?>

<?php next_posts_link('Next >','') ?>

      The pagination kind of works, as the parent category contains the posts, and is set to show 6 posts, but it doesn't always work as the posts aren't always equally distributed throughout the columns. How can I manually build the navigation links, so they run off the queries above, rather than the archive's default pagination? And how and the end of all records can I make the archive return a 404 page, for use with infinte scroll. Also of note, I am aware of this question / answer, but don't think it is an accpetable solution, or is in fact the same setup I have currently. Thanks alot for any pointers!


<a>tag in register_sidebar

I use this sidebar widget between thumbnail posts. When I insert `<a href="example"><img src="example2"></a>` tag in widget, its size and position show post`s size and position affected by an inline property. I want unaffected by the inline property like iframe tag. Is it possible?               add_action( 'widgets_init', 'wpse_1111_register_ad_widgets' );                  function wpse_1111_register_ad_widgets()             {                 // used on the first page of main loop only                 register_sidebar(                     array (                         'name'          => 'front Widget 1',                         'id'            => 'front_widget_1',                         'before_widget' => '
',                         'after_widget'  => '
'                      )                 );                 register_sidebar(                     array (                         'name'          => 'front Widget 2',                         'id'            => 'front_widget_2',                         'before_widget' => '
',                         'after_widget'  => '
'                     )                 );               }         add_action( 'loop_start', 'wpse_1111_show_ad_widgets' );              function wpse_1111_show_ad_widgets()         {                  static $count = 0;                  if ( is_single() )             return;                  if ( 'loop_start' === current_filter() )                 return add_action( 'the_post', __FUNCTION__ )                     && add_action( 'loop_end', __FUNCTION__ );                  $count += 1;                  if ( 7 === $count )                 dynamic_sidebar( 'front_Widget_1' );              if (  13 === $count or 'loop_end' === current_filter() ) {                 dynamic_sidebar( 'front_Widget_2' );                 remove_action( 'the_post', __FUNCTION__ );             }          }


Why does this line of code make photo albums appear?

In a theme I built from scratch I'm using the WP Photo Album Plus plugin. Per some books I've been using as guides, I need to include this code in the header in order to make comments work in a blog:               <?php if ( is_singular() ) wp_enqueue_script ( 'comment-reply'); wp_head() ; ?>      I've been including this line in the header of all my custom themes, whether the site includes a blog or not (my sites are all business sites, some with blogs included but none are primarily or only blogs). This site didn't have a blog so I removed that line of code. Doing that caused the photo albums to stop appearing on the pages. The shortcodes appeared as text instead. The albums were still in the admin and the plugin was still there, and everything else still worked. Can anyone explain the connection? Thanks!


Is there a variable for a template parts name?

One you have called a template with `get_template_part()` (or `locate_template()`) is there a way to know what template you are in. For example if you call `get_template_part('loop','archive');` from `archive.php` and then are working in your loop-archive.php file. is there a way to define a variable that has the name of the current template part.... so `$template = 'loop-archive'`. better still, maybe in two parts so 'loop' and 'archive' but I can do that with some string splitting. Question #10537 seems sort of related but doesn't seem to cover template _parts_.


Structure for projects and clients

I have a client who has requested a WP based portfolio where they will present their projects and clients, filtered by categories and tags. They also wish to filter all projects done for a particular client. I decided to use regular posts for the projects, but I'm unsure as to what would be a good setup for clients.   My idea is to have a custom post type named clients, in which the user can create clients that are then made available in a custom field select list in each post. This would make for a robust structure but it seems a bit unnecessarily to have to use a custom post type simply to achieve this. Any ideas on a more effective approach?


Automatically Generated Menu pages

I am a designer for a website, which I had a developer build in wordperss for me. Each time a new page is created, it is automatically added to my menu bar. Is this something the developer has built into the code, or is it something I can turn off?


Changed PHP handler to DSO - weird custom fields problem

I have a problem for my website. The homepage lists articles (external links) that are put in categories and that also mention the article source (website where the article is published). These sources are custom fields that I fill on the wordpress post editor. The problem is that every article shows now the same source, while I have mentionned a different source for each article. Weird stuff have been happening since I changed my PHP handler to DSO. The problem happened after I changed the handler, so I have high doubts that this might be related. Do you see a workaround to this please ? Thanks