title: Image picker widget

text:
I want to create a custom widget so the user can select 2 images from the media library via a dropdown box and display them in a sidebar. So I need the widget to display 2 drop downs, which each show the TITLE of the images in the media library. I then need to save the url of these two images to use in the front-end (labelled `<?php $IMAGEVAR ?>` in the `widget` function. Here is my widget template ->               <?php     class Image_Picker extends WP_Widget     {       function Image_Picker() {         $widget_ops = array('classname' => 'Image_Picker', 'description' => 'Pick 2 images from media library');         $this->WP_Widget('Image_Picker', 'Image Picker', $widget_ops);       }            function form() {       //WIDGET BACK-END SETTINGS         echo '<select name="link1">';         echo '<option value="image1" selected>Image 1 Title</option>';         echo '<option value="image2">Image 2 Title</option>';         echo '<option value="image3">Image 3 Title</option>';         echo '</select>
';         echo '<select name="link2">';         echo '<option value="image1" selected>Image 1 Title</option>';         echo '<option value="image2">Image 2 Title</option>';         echo '<option value="image3">Image 3 Title</option>';         echo '</select>';       }            function update() {       //WIDGET SAVE FUNCTION       }            function widget() {       //WIDGET FRONT-END VIEW       ?>
<img src="<?php $IMAGEVAR ?>" alt="" width="203" height="271" border="0">

<img src="<?php $IMAGEVAR ?>" alt="" width="177" height="207" border="0">
          <?php       }     }          // Add class for Random Posts Widget     add_action( 'widgets_init', create_function('', 'return register_widget("Image_Picker");') );          ?>      I have been doing this as a meta box for posts, but I need to make a widget version and can't work out how to implement it. I have added in a front-end template to illustrate how it works as a widget, this template will show as a widget if you include it in your `functions.php`, but obviously it won't do anything... Any help is greatly appreciated, cheers.


title: Is there any hook for theme activation ? or something similar?

text: I know this has been asked before however my question is different. So. I have a plugin that creates custom post types on the fly. the plugin also has a function to create template files for each of those custom post types. it simply goes to those theme folder and create template page for each of the current theme. this works perfectly for the current themes. however what happened if the admin added another theme and active it ? So i am looking for a way to detect activation and then run the function to create the template page for that theme. My first idea was to check theme activation hook which i dont think going to work. Anyone with a different idea ?


title: Possible to add "Even/Odd Classes" to image attachments via wp_get_attachment_image?

text: Im looking for a way to add an alternating even/odd class directly to each image attachment when its outputted via my function below:               <?php     function nongallery_img_slide( $post_id = null ) {         if ( $post_id == null ) return;         $images = get_posts(             array(                 'numberposts' => -1,                 'post_type' => 'attachment',                 'post_mime_type' => 'image',                 'post_parent' => $post_id,                 'orderby' => 'menu_order',                 'order' => 'ASC',                 //'exclude' => get_post_thumbnail_id( $post_id )             )         );         if ( count( $images ) > 0 ) {             foreach ( $images as $image ) {                 echo wp_get_attachment_image( $image->ID, 'photogallery-img' );             }         }     }     ?>      Can this be done?   Thanks!


title: How to enable qTranslate languages tabs in custom plugin page

text: For example, I have created a custom post creator. I am using `wp_editor()` to generate "WYSIWYG" editors for content. I am using `qTranslate` for multi-language user experience. Unfortunately I am forced to create a separate "WYSIWYG" editor for every language translation. Overkill. How to enable / implement `qTranslate` language tabs as they are in default post creator.


title: PHP error about plugin which is not installed

text: I vaguely remember having Broken Link Checker installed on my Wordpress website. It is no longer installed. Wordpress is installed in network mode, and on only one of the network websites, I receive the following error at the top of my admin page: > Warning: fopen(/...wp-content/plugins/broken-link-checker/broken-link- > checker.php) [function.fopen]: failed to open stream: No such file or > directory in /.../wp-includes/functions.php on line 3594 > > Warning: fread() expects parameter 1 to be resource, boolean given in > /.../wp-includes/functions.php on line 3597 > > Warning: fclose() expects parameter 1 to be resource, boolean given in > /.../wp-includes/functions.php on line 3600 Why does this error occur when the plugin is no longer installed? Wordpress version is 3.6.1 I don't recall seeing this on WP v3.6 or lower.


title: Move Category into Subcategory, Keep URL structure

text: The site I'm working on now was a small blog which then expanded into something quite a bit larger than what they first thought. Example below               -Pizza     -Chinese     -Italian      What I need is either all the posts under one category               - Reviews      Or a structure like               - Reviews      - Pizza      - Chinese      etc..      They started using categories as tags instead of tags themselves, and there are about 15 categories that could be all moved into a parent category. For future purposes I need to move them all under the same category (keeping the category they're in now is optional, but preferable) The one thing that does need to remain the same is the URLs. This is both for disqus comments & for SEO purposes. I've tried to use the Term Management Tools plugin to move to a parent category, and that works, but I get the url of `http://example.com/reviews/pizza/post-name` instead of my original `http://example.com/pizza/post-name`


title: Whats wrong with this transient? Not caching as expected

text:
I am trying to cache the returned data from a query using WP_Query. It doesn't seem to be storing any where near the time I have specified. Sometimes its refreshing on every page load. What might I be doing wrong?               <?php          // get our transient data if it exists         // prevents pummelling the database with multiple random queries         $tipsloop = get_transient ('homepage_tipsloop');         if (!$tipsloop )           {            echo 'THIS IS NEW TRANSIENT DATA';            $tipsloop = new WP_Query( array( 'cat' => '8', 'posts_per_page' => '1' , 'orderby' => 'rand') );             set_transient ('homepage_tipsloop' , $tipsloop , MINUTE_IN_SECONDS * 5 ); // cached for 5 minutes           }     ?>               <?php while ($tipsloop->have_posts()) : $tipsloop->the_post();          echo get_the_post_thumbnail($page->ID, 'homefooter-thumb'); ?>
             <?php the_content(); ?>

           MORE TIPS
     <?php endwhile;  ?>


title: What do comments with [...] mean?

text: I get a bunch of comments that simply repeat the title with '[...]'. ie:               [...] Some cool post title [...]      Is this spam or is wordpress doing something wrong? I have the akismet plugin enabled.


title: Retrieve current and localized month

text: instead of writing array of months in desired language, and doing a function to replace date('m') with localized month... I believe there should be some fast and easy way to echo current month, after all its Wordpress? I have define('WPLANG', 'hr');


title: How to order by post meta name in wp admin?

text: I am trying to order by post meta name which I added for post. Post meta is "_merchant_id" an I know how to sort by merchan_id but I don't know how to sort by merchant name. I am sorting by merchant id like this:               public function column_orderby( $vars ) {             if ( isset( $vars['orderby'] ) && is_admin() ) {                 switch ( $vars['orderby'] ) {     case 'merchant':      $vars = array_merge( $vars, array(          'meta_key' => '_merchant_id',          'orderby' => 'meta_value_num'      ) );          break;     ...      Merchant is another post type ("merchant"). How can I sort by merchant name? **UPDATE (improved explanation by screenshot):** ![enter image description here](http://i.stack.imgur.com/xmFef.png)


title: Slow wp-admin due to "SELECT DISTINCT post_mime_type FROM wp_posts WHERE post_type = 'attachment'"

text: The media library on a large site is slow in wp-admin. I did some research by looking into slow queries in the sql and found that this query is causing the slow response:               SELECT DISTINCT post_mime_type FROM wp_posts WHERE post_type = 'attachment'      It takes around 17 seconds and it's about 759000 rows of type 'attachment' in the db. What would be the best way to optimize it or cache the distinct types? I don't want to change anything in core files.


title: Best way to abort plugin in case of insufficient PHP version?

text: You write a plugin which requires PHP 5.1. Someone tries to install it on a server with PHP 4. How do you deal with that in a safe and user-friendly manner?


title: Custom CSS not being added by plugin

text: I am attempting to add custom css through my plugin. I do have wp_head() called in my header. My code is -               /**     * Enqueue plugin style-file     */     function prefix_add_my_stylesheet() {             wp_enqueue_script('style1', plugins_url('style1.css', __FILE__) );     }     add_action( 'wp_enqueue_scripts', 'prefix_add_my_stylesheet' );      I can access style1.css when I               echo plugins_url('style1.css', __FILE__);      So I know it exists and is available. I do not get any errors and the style sheet does not show. I am placing the above code inside mysite/wp- content/plugins/mycustomplug/plugin.php Can anyone let me know why this may not be loading? Nothing errors out so I assume my syntax is correct.


title: Only display posts that are in multidimensional meta_value

text:
So i want to retrive a list with the posts that are in the meta_key "_blocks" and in that there is a multidimensional array with "areas" called left, right ,top etc. And within them there are assigned post_id:s. Like this:               Array     (     [left] => Array     (     [0] => 450     [1] => 452     [2] => 460     [3] => 451     [4] => 454     [5] => 449     [6] => 455     )          [right] => Array     (     [0] => 460     [1] => 455     [2] => 454     [3] => 453     )          )      The query look like this now.. Im a little confused right now how to archive this.. Before this im running a foreach as you can see on $areas as $area. And `$type_areas` holds etch post_type:s.               $args = array(         'post_type' => $type_areas[$area['area']],         'posts_per_page' => '-1',         'meta_key' => '_blocks',         'meta_query' => array(           array(             'key' => 'left',             'value' =>  '450', // just testing...             'compare' => 'IN',           )         )     );          $query = new WP_Query( $args );          while ( $query->have_posts() ) : $query->the_post();             $output .= '
post->ID .'" data-area="'. $area['area'] .'">
'. get_the_title() .'
'. $query->post->post_type .'
';          endwhile;      **UPDATE** So i ended upp with a simple SQL-query:               $sql = 'SELECT post_id FROM kwido_postmeta WHERE meta_value REGEXP \'"'. $area['area'] .'";a:[[:digit:]]+:{[^}]*"'. $mainpost->ID .'"\'';     $results = $wpdb->get_results( $sql, ARRAY_A );      That looks after the current post_id and area with a regex, then if found get the post_id..               $post_ids = array();          foreach ( $results as $result ) {         $post_ids[] = $result['post_id'];     }      With the post_id:s i make the query with `post__in` parameter which accept arrays.               $args = array(         'post_type' => $type_areas[$area['area']],         'posts_per_page' => '-1',         'post__not_in'   => $post_ids     );          $query = new WP_Query( $args );


title: Sanitizing and validating email field

text: Should I use `is_email()` to validate an email field? In WP. I've put the email field in a widget. I would really appreciate some help.               function update($new_instance, $old_instance) {          $instance = $old_instance;          $instance['email'] = is_email($new_instance['email']);              return $instance;          }      And               <p>         <label for="<?php echo  $this->get_field_id('email'); ?>">          <?php _e('Email'); ?>  </label>          <input class="widefat" id="<?php echo $this->get_field_id('email'); ?>" name="<?php echo $this->get_field_name('email'); ?>" type="email" value="<?php echo $email; ?> " />         </p>         <?php         }      Is using `is_email()` correct for this? Thank-you!


title: How can i use GET METHOD on wordpress plugin admin page

text:
I am building a custom plugin which i plan to sell, but i am having problem storing my get request values in the plugin url. I have this url: /wp-admin/admin.php?page=step-one&filename=Styles_For_Less- Styles_For_Less_Product_Catalog.txt and when the submit button on that page is clicked it should go to page with this url: /wp-admin/admin.php?page=step-two&filename=Styles_For_Less- Styles_For_Less_Product_Catalog.txt&header=0&delimiter=%7C&quoted=&step2=Step+2+%3E%3E But i doesn't instead it goes here: /wp-admin/admin.php?header=1&delimiter=%2C&quoted=&step2=Step+2+%3E%3E               <form method="GET" action="<?php echo admin_url( "admin.php?page=step-two&filename=$filename&", "http" ); ?>">

             Header Row:	             <?php echo $header; ?>

             Delimiter:	             <?php echo $delimiter; ?>

             Quoted:	             <?php echo $quoted; ?>

<input type="submit" value="Step 2 >>" name="step2">       <input type="reset" value="Reset" name="B2">
     </form>      Any help greatly appreciated.


title: Pagination w/Static Front Page

text:
I'm trying to add pagination to my frontpage. It's currently set to Settings --> Reading --> Static Page --> Frontpage: home I'm using a custom template for the homepage. I have my template-home.php open and it looks like this:               <?php     /*     Template Name: Home     */     ?>          <?php get_header(); ?>

                                                 <?php// wp_reset_query(); ?>                           <?php                  if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }                 elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }                 else { $paged = 1; }                      query_posts('posts_per_page=3&paged=' . $paged);                  ?>                                            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                             <?php /* Widgetised Area */ if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( 'Homepage Main' ) ); ?>
                           <?php the_content(); ?>

                                       <?php /* Widgetised Area */ if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( 'Homepage Sidebar' ) ); ?>                                   <?php endwhile; ?>

<?php next_posts_link(__('← Older Entries', 'framework')) ?>

<?php previous_posts_link(__('Newer Entries →', 'framework')) ?>

                                            <?php echo paginate_links(); ?>             <?php endif; ?>

          <?php get_footer(); ?>      I read the "static front page" section of this page an it's not working for me. When I run the template it duplicates all my posts, show 6 posts and duplicates my header section. however my Settings --> Reading --> Says 5


title: get USER ID in functions.php using user_register action

text:
I am having trouble of getting the ID in user_register filter in functions.php... Here is what I got               add_action( 'user_register', 'sendanotheremail' );     function sendanotheremail($user_id) {             $user = new WP_User($user_id);             $user_login = stripslashes($user->user_login);             $user_email = stripslashes($user->user_email);             $getid      = $user->ID;             global $wpdb;             $getunion = $wpdb->get_results("SELECT value from wp_bp_xprofile_data where user_id = $getid AND field_id = 4", "ARRAY_N");             $message  = sprintf(__('New user registration on %s:'), get_option('blogname')) . "\r\n\r\n";             $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";             $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";             $message .= "
 Please go here to approve the new user Approve/Deny";             if(!($getunion)) {                     $message .= "nothing there";             }             else {                     $message .= "yes";             }     $headers = 'From: xxx <xxx@xxx.com>';     add_filter('wp_mail_content_type',create_function('', 'return "text/html";'));     wp_mail('xxx@xxx.com', 'New User Registration to xxx website', $message, $headers);     }      I am testing the getunion if its empty I am returning "nothing there". _**So all of the other variables are getting me email with right data, but $getunion is empty..._** When I pass manually the ID here               $getunion = $wpdb->get_results("SELECT value from wp_bp_xprofile_data where user_id = $get_id AND field_id = 4", "ARRAY_N");      it works... So how can I get the ID?


title: Get content from one Wordpress website to another

text:
I have been at this for days and now feel like I am way off track out of desperation and lack of knowledge. Pretty much I am trying to "scrape" public info from one Wordpress install to a separate Wordpress site. The sites are on different domains, servers and databases. Site A (the one I need to grab the content from) uses an RSS Feed which I have been able to successfully pick up. However each post contains an image ( i dont know if it is featured or not) and I really need to know how to get that image to display. At first I ran my own loop and was picking up everything aside from the image, then I tried just setting up Simplepie in the theme and still could not get the images to pick up. Then I was trying a method described on here about XMLRPC and still no luck. I am about to pull my hair out and I just dont have enough knowledgebase on the subject to get what I need done. How can I get the feed and image to display from Site A to Site B? I have read so much stuff I feel like I am so lost. Any help would be greatly appreciated, thanks **EDIT** Here is what I have been using which works as far as picking up the feed but not images                   <?php function custom_dashboard_feed() {                $feed = fetch_feed( 'http://mugshots.starnewsonline.com/feed' );          if ( ! is_wp_error( $feed) ):          // Get a maximum of 5 items          $maxitems = $feed->get_item_quantity( 5 );          $items = $feed->get_items( 0, $maxitems );          foreach ( $items as $item ):          ?>
          <a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?> <?php echo $item->get_date( 'F j, Y' ); ?>
               <?php if (has_post_thumbnail( $post->ID ) ): ?>     <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>     <img src="<?php echo $item->get_image_url ?>" height="200" width="200" />
     <?php endif; ?>          <?php echo $item->get_description(); ?>
          <?php          endforeach;          else: // Returned WP_Error, unable to fetch the feed. ?>
There was an error fetching the feed, please try again later
          <?php endif; ?>               <?php     } ?>          <?php $mugshots = custom_dashboard_feed(); echo $mugshots; ?>


title: What is the preferred way to add custom javascript files to the site?

text: I've already added my scripts, but I wanted to know the preferred way.   I just put a `<script>` tag directly in the `header.php` of my template. Is there a preferred method of inserting external or custom js files?   How would I bind a js file to a single page? (I have the home page in mind)


title: Add JavaScript in admin in custom plugin

text: > **Possible Duplicate:**   >  What is the preferred way to add custom javascript files to the site? I was reading few posts here about this, but all answers are about wp_enqueue_script or something. I'm looking for solution to embed custom JavaScript variable (created by json_encode()) in footer or in header but in admin add_action 'wp_footer' and 'wp_head' are not called. How to embed custom code - not include file.


title: Highlight Author Comments issues

text: So a few days ago I added the following code to Geek for Him and obviously missed the nested comments portion. This is implemented on many other sites of mine, without Standard Theme of coarse and working fine. Am I missing something? Check out the link here - geekforhim dot com is the site A comment is made, I comment (highlight works) someone comments below me and it's highlighted also. Any help would be greatly appreciated.               .commentlist li.bypostauthor, li.comment-author-admin {     background-color: #E0E0E0 !important;     }      So I have figured out that fi I add a background to               #comments ul.children {     background:none repeat scroll 0 0 #FFFFFF;     margin:10px 0 0 25px;     padding:0;     }      it works, but its very ugly. Any cleaner ideas? See image below on what seems to messed up I have noticed that the comments themselves are one. What I mean by this is that 4 nested comments below one all equal one comment. This is not correctly coded in my mind and probably a bug fix? Any ideas or workarounds do let me know. _**UPDATED_** With the guidance below I was able to figure out what I was after. Thanks to t31os!!


title: Encoding Method for URLs?

text: Is there a method or API that WordPress uses to encode the URLs similar to how it generates part of the URL when using the title in the URL? I am writing a plugin that generates URLs and would like to use the same method as everything else is. For instance, I type "This is my blog post" in the title and "this-is-my-blog- post" gets generated.


title: Problems with wierd characters and my plugin

text: There are special characters that can cause problems in word press, like the infamous microsoft word smart quotes. However, there are many that are captured and dealt with. My collegue and I have written a plugin that, even if it just passes the content through, stops wordpress from handling many of these characters properly. It shows particularly on foreign language web sites like a German one where special characters are handled just fine until my plugin is activated. Why is this so?


title: Custom Link In Wordpress Media "Attachment Details" Upload Screen

text: When you click "Add Media" and from there select an image from that media library screen on the right you get a breakdown (the attachment details) related to that particular image. Right below the image there are some image details and then the links > Edit Image > Delete Permanently. How can I add a custom link to appear right there (preferably) above the "Edit Image" link with a function? I searched around and the closest I could find it how to add custom fields to the media upload screen nearest to the bottom options in the right when an image is selected. I couldn't find and I'm not sure how to take that snippet and take the field area to be just a link instead. I used in my description above "image" just for visual purposes. I want the link to appear for all files from the media upload screen, not just images if someone is thinking that. Thanks a lot!


title: Exclude categories from the_category();

text: function the_category_filter($thelist,$separator=' ') {         if(!defined('WP_ADMIN')) {             //list the category names to exclude             $exclude = array('Something','Something Else','Blah','YAY');             $cats = explode($separator,$thelist);             $newlist = array();             foreach($cats as $cat) {                 $catname = trim(strip_tags($cat));                 if(!in_array($catname,$exclude))                     $newlist[] = $cat;             }             return implode($separator,$newlist);         } else             return $thelist;     }     add_filter('the_category','the_category_filter',10,2);      I am using that code, to get the_category(); to exclude some categories. But it ain't working, as it is supposed to...


title: Use a wordpress page to display a certain category

text: I'm trying to set up a portfolio page on my wordpress website, and I would like the following construct:   * /blog/ where I blog all kinds of things, including portfolio entries   * /portfolio/ where I show just posts from my portfolio category   * some regular /pagename/ pages (about, contact, etc) I want the portfolio section to have a separate style (and even html probably) than a regular category overview. So if someone clicks one of the categories in my blog they still see the normal /category/randomcategory/ overview page. This means I can't just change the category php page and/or the css, because the portfolio page is different from the regular view. Is there a way to set up my page so that it shows the posts in the category portfolio the way I want?


title: Theme Demo in live Site

text: I don't know how to explain this question but let me try, Just Imagine I've a website called xyz.com and in xyz there are 10 themes uploaded and in homepage i'll show name & screenshot of all 10 themes if someone click on activate / demo then that theme will be activated in his ip address only till his session destroy after it when he visit again after sometime he can see old theme. Means if someone wanted to buy theme from my site he can able to view it directly from my site.


title: How to prevent people from seeing an attachment to a scheduled post that's released in future?

text: I'm developing a website for a large corporation. They release financial documents on specific dates and times. I've developed a custom form to upload these pdfs to articles, and custom loops that display only these attachments on specific pages. When the date of the article is set in the future, the attachments are released when they should and the system works pretty well. The only thing is, that for the company it's super-important that there is no access to the attachment-files before the date when it's supposed to come out. So if anyone can guess the name of the attachment they can just go to wp- content/uploads/financialdocument10.pdf and read it before it's supposed to come out. Is there any ideas how to prevent this? My only idea so far is to add some random characters to the file name so it's impossible to deduce it's name on the the basis of previous filenames. Thanks!


title: Changing the default header name

text: Is it possible to change the default header.php file to something else for security reasons? It seems header.php is target for malicious attacks. I know all that, we have different named headers, I am talking about the default one. For example instead of header.php rename it to imcool.php and I don't appreciate the negative point. All the default files index.php, admin as a user, header are always targets for malicious attacks including injection.


title: Why is Wordpress loading a different sized post thumbnail?

text:
I have a custom theme where I'm using post thumbnails as BG images for a slider. The thumbnails and some other info are entered using a custom post type. However, even though I'm uploading 1440x833 images, the image wordpress loads is always 1024x593. Why is it even creating a 1024 version of these thumbnails? Here's the relevant code in index.php.                    <?php         $args = array(             'post_type' => 'home-slider',             'posts_per_page' => 5,             );     ?>               <?php $homeslides = new WP_Query( $args ); ?>

                                            <?php if ( $homeslides->have_posts() ) : while ( $homeslides->have_posts() ) : $homeslides->the_post(); ?>             <?php $slideimage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'home-slides' ); $url = $slideimage['0']; ?>
                 <div class="slide-image" style="background: url(<?php echo ($url); ?>) no-repeat center center;">

<?php the_field('slide-title') ;?>

<?php the_field('slide-subtitle') ;?>

                  <?php endwhile; endif; ?>

      Here's where I'm declaring the thumbnail size (functions.php).               // This theme uses a custom image size for featured images, displayed on "standard" posts.         add_theme_support( 'post-thumbnails' );         set_post_thumbnail_size( 320, 180, true ); // primary size         add_image_size( 'home-slides', 1440, 833, true ); // thumbnail size in home slider      } Thanks for your help!


title: WP Feed namespace attr issue

text: Having a strange issue (well, strange to me) where an xmlns:media namespace attr is being added to one feed but not the other. How do I get rid of the "xmlns:media" attr? I don't even know why it's being added to one feed but not the other. For example: http://pridemoreproperties.agentfire.com/feed/ Notice the "xmlns:media" being added. http://landandvillage.com/feed/ These are on the same WP install (WP Multisite) and both using the genesis theme.


title: sidebar - widgets versus code - options

text: I decided to use Widgets in my sidebar on the advice of another designer who thought the site would take too long to load if I used the images I'm using for titles and branding. I'm dissatisfied with the outcome because the Image and Text widgets create too much white space in between sections, and I'm limited in what I can control. I have two related questions. Does anyone know of an Image or Text Widget that will allow me to minimize the white space between sections? My images are very tightly cropped, so there's no reason for the white space other than the widgets creating it. The second question is: if I decide not to use widgets at all, and just program the sidebar.php file to refer to image files in the media library and enter in the appropriate text -- is it detrimental to the site's functionality? I see a lot of very customized wordpress sidebars online, and I can't imagine they are using widgets. But maybe they are using a technique that is over my head? This is a twenty twelve child theme. Guidance appreciated. The site is at internalcompass.us/castle right now. kb


title: Why does Wordpress search returns same number of results for every search query?

text: I am hitting a brick wall, I am searching something on a site I am building and on every search it returns 10 results when I know in the index in relevanssi it shows more for the term I am searching on. Does anyone know what the issue is with it? Thanks, Mark


title: Post titles and thumbnails as links to custom post types?

text:
I am struggling with the php structure. How do I need to rewrite the code to get the links to the titles and thumbnails of the custom posts?
         <?php $pfportfolio = new WP_Query( 'post_type=portfolio', 'posts_per_page=-1' );?>         <?php while ( $pfportfolio->have_posts() ) : $pfportfolio->the_post();?>              <?php             echo '
ID, 'location', '', ' ', '' ) ).'">';             **echo '';             the_title();             echo '';             echo '
';             the_post_thumbnail('home-feat');             echo '
';**             echo '
';?>              <?php endwhile; ?>             <?php  wp_reset_postdata(); ?>
      I assume I need to integrate somehow               <a href="<?php echo get_permalink(); ?>">      but unfortunately I just dont understand how :(. Thanks so much for any help!


title: Are there any official or unofficial guidelines for the styling of a widget?

text: I've designed a sidebar widget and found that on many themes the widget looks fine. However, certain themes make the widget look out of place (clashing with colors, bad contrast, etc.) Are there any guidelines on how to properly style widgets so that they match _most_ websites?


title: Post thumbnail not displaying in correct position

text:
I'm using the following as part of a shortcode I'm creating:               $loop = new WP_Query(array('post_type' => 'client', 'posts_per_page' => $limit, 'orderby' => $orderby));               if($loop){             $preoutput = '
';             $postoutput = '
';             while ($loop->have_posts()){                 $loop->the_post();                   $output .= '

hello
'.the_post_thumbnail();                  $output .= '

'.get_the_title().'
'.get_the_excerpt().'

';                   $finaloutput = $preoutput . $output . $postoutput;             }         }      However, the post thumbnail doesn't appear in the markup, it appears just at the top of the post - why would it do this?


title: Link images to post

text:
Link images to post. Hi all I'm sure this is simple but I can't see how to do it. I know how to add images to a post - Click in the post, Add Media, choose thumbnail. This gives me an thumbnail in the post. I think what I want to do is link thumbnails to the post so I can control where the thumbnails appear on the page. I have a template like this.
             <?php                      $car_args = array(                     'post_type' => 'post',                     'category_name' => 'car',                     'order' => 'asc'                 );                      $cars = new WP_Query($car_args);                      if($cars->have_posts()):                     while($cars->have_posts()):                         $cars->the_post();             ?>

<?php the_title(); ?>
                            <?php the_content(); ?>

                      <?php endwhile; endif; ?>                 <?php wp_reset_postdata(); ?>
      I have posts about car's with category name 'car', I'm using the category name in the WP_Query. Some of these posts have images. If there are images with the post I would like to add them as a list in the aside.


title: Pagination customization

text: I am working to develop this type of pagination: ![here](http://i.stack.imgur.com/vIV5L.jpg) I am taking values and displaying them on same page and my code snippet is below and couldn't make it why it is not working.               <?php     if ($_SERVER['REQUEST_METHOD'] == 'GET')      {         global $paged;         if(empty($paged)) $paged = 1;         else { $paged = $_GET['paged']; }             if(isset($paged) && is_numeric($paged) && ($paged <= $pages) && ($paged >= 1))              //validation             {                     if($pages == '')                 {                     global $wp_query;                     $pages = $wp_query->max_num_pages;                         if(!$pages) $pages = 1;                 }                        if(1 != $pages)                 { ?>              <form action="#" method="get" >                      page                 <input type="text" name="paged" value="<?php echo $paged; ?>">                 of <?php echo $pages; ?>                 <input type="submit">              </form>                      <?php                  if($paged > 1) echo "‹ Prev Page";                 if ($paged < $pages) echo "Next Page ›";                  }             }      }       ?> Please suggest.


title: two columns of posts on homepage, one of them "favorites"

text: I'm using a child theme of Twenty Twelve in wordpress. Here's where I am developing the site: http://internalcompass.us/castle/ You'll notice the two columns of posts on the homepage. I have one labeled recent posts and one labeled favorites. In actuality, both columns are the same - recent posts organized by date. I'd like to actually create a set of posts that populate the second column, so my client can select recommended posts or her favorite posts for that column. I'd like the first column to be recent posts. I'm hearing crickets on the Wordpress Support forum, likely because this is a pretty technical q. sooooo Any info is appreciated. I'm sure I can somehow label posts and add code to the index.html to populate the second column. I just am not yet equipped with the info to know what code to add. Peace & thx


title: Ignoring slug capitalization on rewrite rule for custom post type archive page

text: I'm declaring a custom post type 'games' with a rewrite rule:               'rewrite' => array('slug' => 'Games','with_front' => false),      So the resulting url for the games archive is `<mysite>.com/Games` - This works fine. With a Game entry titled "Example", visiting `<mysite>.com/games/Example` it automatically redirects to `<mysite>.com/Games/Example` no problem. This is what I want. * * * However when visiting the archive of the `Games` type, it will not redirect if I change the capitalization:   * With the slug set to `Games` visiting `<mysite>.com/Games` works but visiting `<mysite>.com/games` will redirect to a blog post or page with 'games' in its url.   * With the slug set to `games` visiting `<mysite>.com/games` works but visiting `<mysite>.com/Games` will redirect to a blog post or page with 'games' in its url. **Notes** :   * Yes, I flush my permalink settings after changing the rewrite rules. Since the url works for the non-archive pages this is not the issue.   * I use the custom `Month and name` permalink setting.   * I do have `archive-games.php` defined and working in my theme directory. * * * Is there a way of ensuring that any case variation of 'games' links to the archive, and not some random blog post? In other words, is it possible to tell wordpress to ignore the capitalization and always redirect to `<mysite>.com/Games` even if the user enters `<mysite>.com/gAMeS`? I just want it to be convenient for users that happen to type the url in manually and forget to capitalize it. I could change the slug to lower case 'games' by default, but then   1. It doesn't look as nice   2. Again, if a user types "Games" with caps, They are linked to a seemingly random page.


title: Restrict access to certain dashboard pages based on user id

text: I have a client who want's to be given admin access to the dashboard of the test installation of her website on my server. She hasn't paid me yet so I don't want her to be able to go into the themes menu, copy the theme code and run off without paying. So, is there a way that I can give her admin access while also blocking her from viewing the Appearance > Editor menu?


title: register and insert category manually

text: I am registering custom taxonomies ....               <?php     add_action( 'init', 'create_book_tax' );          function create_book_tax() {         register_taxonomy(             'genre',             'product',             array(                 'label' => __( 'Genre' ),                 'rewrite' => array( 'slug' => 'genre' ),                 'hierarchical' => true,             )         );          ?>      It is successfully creating Taxonomy of **Genre** under **Product** Post type. Now I want to manually add categories inside **Genre** and it will also be heirarchical so I can again insert new category inside newly created category. Please tell me how to manually create category.


title: get_locale() behaving strange in same functions.php file

text: I'm developing a multi-language web portal for my client - in English and Bengali. Instead of using multisite, I installed Polylang plugin. It's working fine through the website. For different CSS styles, and different font-sizes I'm loading a separate stylesheet with:               function styles_and_scripts(){        wp_register_style( 'main-style-bangla', get_template_directory_uri() . '/style-bangla.css', '', '', 'screen' );             // load seperate stylesheet for Bangla        if( get_locale() == 'bn_BD' ) {            wp_enqueue_style( 'main-style-bangla');        }     }          add_action( 'wp_enqueue_scripts', 'styles_and_scripts' );      It's working just fine, and loading different CSS when I'm switching to Bengali. I'm trying the same method for applying filters for Bengali Numerals and Strings etc. with these functions and filters. So I'm doing something like this in my `functions.php`:               if( get_locale() == 'bn_BD' && !is_admin() ) {             add_filter( 'get_the_time', 'make_bangla_number' );             add_filter( 'the_date', 'make_bangla_number' );             add_filter( 'the_time', 'make_bangla_number' );             add_filter( 'get_the_date', 'make_bangla_number' );                  add_filter( 'get_the_time', 'make_bangla_months' );             add_filter( 'the_date', 'make_bangla_months' );             add_filter( 'the_time', 'make_bangla_months' );             add_filter( 'get_the_date', 'make_bangla_months' );     }      But it's not working. I tried to figure out why?               $my_locale = get_locale();     var_dump( $my_locale );      It's returning "`en_US`" in both the languages. You can see the image below for proof: ![enter image description here](http://i.stack.imgur.com/GCRRO.png) Why the same bit of code in the same `functions.php` file is behaving strange in different cases? I then changed the placement of the code just after the enqueue portion, but it's still not working. :( ## UPDATE I found a function from Polylang documentation saying: `<?php pll_current_language($value); ?>` (Source^) will retrieve the current language. I tried `var_dump(pll_current_language());` it returns nothing. Then I managed to find the following code:               function site_current_language() {         global $polylang;         echo $currentLang = pll_current_language('locale');              return $currentLang;     }     //add_action( 'init', 'site_current_language' );  // it does not print     add_action( 'wp', 'site_current_language' );    // it prints      It's working fine, it's echoing the current `$locale`. But instead of echoing this, if I tried returning, it's returning `boolean false`. I tried `global $polylang; var_dump($polylang);` without any function or hook, it's showing that it is failing to find the `curlang` within. But if I do the same inside my style/script enqueue fuction, it's getting the current language. So I suspect there's something related with the proper hook. Note, the hook `init` is failing to echo, but `wp` is echoing. I think we should find a proper hook to get it work. But how, I don't know.


title: making a plugin that moves other plugins wp_head actions to wp_footer

text: I am grappling with implimenting jQm on wordpress and have hit the obstacle that most plugins dont work on jQm ajax loaded pages. However, taking the example of the sharethis plugin, I have found that it will run on the ajax loaded page if I change this               add_action('wp_head', 'st_widget_head');      to this               add_action('wp_footer', 'st_widget_head');      in the sharethis.php file The thing is that I want to try and do this leaving the initial plugin files untouched (so that wp updates will work and so that I can keep all my jQm specific plugin modification changes in one place- so they can all be turned off if jQm is turned off) So I think what I n eed to make to begin with is a plugin that loads last, that moves any plugins I specify to move their add_action wp_head to add_action wp_footer. I appreciate this is currently a very brute force solution, but so far this is the only chink of light I have found in what seems to be an impenetrable situation, which otherwise requires re-writing all the plugins I use to work with jQm. So any ideas on this would be very helpful in helping me create a more solid and maintainable solution to this, something like a 'jQm plugin fixer plugin' that I and the community could develop and maintain...


title: How to remove default style of header in wordpress metabox

text: I have the problem which when I create a header in my wordpress plugin metabox, it always apply the default style on my header: ![enter image description here](http://i.stack.imgur.com/pwHPk.png) even when I apply, my own style, `<h3 style="background-color: black; color:blue">Text Block Settings</h3>`, it only changes the text color but not the background color, why?? ![enter image description here](http://i.stack.imgur.com/fBRlL.png)


title: JS Plugin not executing the js correctly. Trying to make all internal links scroll smoothly

text: all right... I am attempting to create a plugin for my site that adds a js snippet to the head section when a front end page loads. The js is meant to add smooth scrolling to all internal links. First off, the plugin does load the script just fine. It's a snippet from: https://github.com/alextrob/SmoothAnchors Everyone else that uses the script seems to think it works great! But I can't get it to work for me. I am VERY new to JS so I wouldn't be surprised if i am doing something really dumb! But, none of the links on my site scroll... Here is my site: http://bigbrownbeaver.net here is the plugin code:               <?php     /*     Plugin Name: Smooth Scrolling Links     Plugin URI: http://bigbrownbeaver.net     Description:Adds a js smooth scrolling effect to all links on your site that point to other parts of a page or post     Version: 1.0     Author: Aaron     Author URI: http://bigbrownbeaver.net/newsletter/     */          /*  Copyright 2013  Aaron > BigBrownBeaver.Net          This program is free software; you can redistribute it and/or modify     it under the terms of the GNU General Public License, version 2, as      published by the Free Software Foundation.          This program is distributed in the hope that it will be useful,     but WITHOUT ANY WARRANTY; without even the implied warranty of     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     GNU General Public License for more details.          You should have received a copy of the GNU General Public License     along with this program; if not, write to the Free Software     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA     */          //load required script                    add_action('wp_head', 'smooth_scrolling_links');          function smooth_scrolling_links() { ?>     <?php if ( !is_admin() ) { ?>              <script type="text/javascript">         (function($) {                 $.fn.smoothscrolling = function() {                          function scrollto(destination, hash) {                              // Change the hash first, then do the scrolling.                         var scrollmem = $(document).scrollTop();                         window.location.hash = hash;                         $(document).scrollTop(scrollmem);                         $("html,body").animate({                             scrollTop: destination                         }, 400);                          }                          if (typeof $().on == "function") {                         $(document).on('click', 'a[href^="#"]', function() {                                  var href = $(this).attr("href");                                  if ($(href).length == 0) {                                      var nameSelector = "[name=" + href.replace("#", "") + "]";                                      if (href == "#") {                                     scrollto(0, href);                                 }                                 else if ($(nameSelector).length != 0) {                                     scrollto($(nameSelector).offset().top, href);                                 }                                 else {                                     // fine, we'll just follow the original link. gosh.                                     window.location = href;                                 }                             }                             else {                                 scrollto($(href).offset().top, href);                             }                             return false;                         });                     }                     else {                         $('a[href^="#"]').click(function() {                             var href = $(this).attr("href");                                  if ($(href).length == 0) {                                      var nameSelector = "[name=" + href.replace("#", "") + "]";                                      if (href == "#") {                                     scrollto(0, href);                                 }                                 else if ($(nameSelector).length != 0) {                                     scrollto($(nameSelector).offset().top, href);                                 }                                 else {                                     // fine, we'll just follow the original link. gosh.                                     window.location = href;                                 }                             }                             else {                                 scrollto($(href).offset().top, href);                             }                             return false;                         });                     }                 };             })(jQuery);                  $(document).ready(function() {                 $().smoothscrolling();             });         </script>     <?php }          }      Love to hear from you guys :)


title: Registration and Login form

text: I am creating practice website in which i have "register Here" and "login" link on which I want to open a registration form on click of Register Here and Login Form on click of Login. How can I do this?


title: How to Remove ALL Widgets from Dashboard?

text: I'm looking for a complete blank Dashboard. No widgets at all and preferably one column. There are snippets to remove the default WordPress widgets, but haven't found nothing about the ones added by plugins. Searched all over and seems that this hasn't been asked. ![Not blank WordPress Dashboard](http://i.stack.imgur.com/yHfgg.png)


title: Add custom field automatically (add_post_meta) with value based on number of words of article

text: In this topic our friend @toscho created a function that sets the font size according to the number of words in the post. Based on this function, I want to create a custom field whose value will be set depending on the number of words in the post. For example, if the post contains up to 200 words, automatically create custom field (add_post_meta) with value = 1; If your post contains more than 200 words, create custom field with value = 2. Any idea is welcome. Thank you.


title: Pagination shows same contents all pages

text:
Here is my loop                       $my_query = new WP_Query(array(                     'cat' => -399,                     'posts_per_page' => 6,                     'offset' => 5,                     'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1             ));             if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) : $my_query->the_post();                  $imgurl = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );                 $finalurl = get_stylesheet_directory_uri(). "/functions/thumb.php?w=180&h=180&a=t&src=".$imgurl;                 $date = get_the_date();                  $id = $post->ID;             ?>             .... loop contents ....                  <?php $finalurl = "";             endwhile;             else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
             <?php endif; wp_reset_query();             $id = ""; wp_pagenavi();      Pagination shows same content in all pages. I need your suggestion.


title: Add file extension to temporary file

text: I am using download_url() to download a temporary file and want to save this file in my uploads folder using media_handle_sideload. This works fine with files that have a file extension. media_handle_sideload dosent work with files that have no file extension. So when im trying to save for example this image it wont save, because the url has no file extension. Then I need to use `image_type_to_extension(exif_imagetype($imageurl));` to get the file extension for the image. How can I add this file extension to the temporary file? here is my code:               public function upload_image_from_url($imageurl) {                  // Get the file extension for the image             $fileextension = image_type_to_extension(exif_imagetype($imageurl));                  // Save as a temporary file             $tmp = download_url( $imageurl );                  $file_array = array(                 'name' => basename( $imageurl ),                 'tmp_name' => $tmp             );                  // Check for download errors             if ( is_wp_error( $tmp ) ) {                 @unlink( $file_array[ 'tmp_name' ] );                 return $tmp;             }                  $id = media_handle_sideload( $file_array, 0 );             // Check for handle sideload errors.             if ( is_wp_error( $id ) ) {                 @unlink( $file_array['tmp_name'] );                 return $id;             }                  $attachment_url = wp_get_attachment_url( $id );                       return $attachment_url;          }          Thanks.


title: the_author_meta('user_url', $author->ID) not working properly. how can I solve this?

text:
I have 2 authors and an admin on my blog. I am using the following code in my contributors.php               function contributors() {             global $wpdb;                  $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");                  foreach($authors as $author) {                  echo the_author_image($author->ID);                  echo the_author_meta('display_name', $author->ID) . '
' ;             echo the_author_meta('user_url', $author->ID) . '
';             echo the_author_meta('description', $author->ID) . '
' ;             echo the_author_meta('user_email', $author->ID) . '

' ;                  }             }                  contributors();      It's printing all authors' and admin's photo, name, description and email perfectly. but it not printing the user link correctly.   * for admin or user ID 1 it's printing the blog URL   * for 1st author or user ID 2, it's printing the correct URL.   * for 2nd author or user ID 3, it's printing nothing. what is the problem? how can I solve this?


title: sort by vote with GD STAR RATING plugin

text: Does anyone have any suggestions as to how I can get the sort by vote count to work with the GD STAR RATING plugin? I have added sorting parameters to a category list on my site but it still isn't ordering the posts by the number of thumbs up votes. http://uhurusoftware.com/category/contest/?gdsr_sort=votes&gdsr_order=asc Does anyone have suggestions of what I should check? Are there options I need to set in the GD STAR RATING admin panel?


title: Query posts by Custom Meta (checkbox) & Genesis Grid Loop

text:
I've been trying tons of things for the last 2 days. I'm at a standstill now. I read a ton of posts here but nothing has worked yet. I have a CPT 'artists'. This CPT contains a custom field checkbox called Featured Artists 'ecpt_featured_artist'. Within the Genesis Grid Loop on the Artists archive page 'artists-archive.php' I am able to target the Featured Artist like this:               $featuredartist = get_post_meta($post->ID, 'ecpt_featured_artist', true); ?>     <?php if( $featuredartist ) {         echo '

';     }      I'm currently using Bill Erickson's code to put the artists-archive in a grid... like this:                   function be_archive_post_class( $classes ) {         $classes[] = 'one-fourth';         global $wp_query;         if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 4 )             $classes[] = 'first';         return $classes;     }     add_filter( 'post_class', 'be_archive_post_class' );      **What i'm trying to accomplish:** I want to query ONLY post with the checkbox checked, and display them in the Genesis Grid, on a page called Featured Artists. Right now i'm attempting to do that via a page template. If there is a better way altogether to accomplish this, I'm open to suggestions. Right now, I can't even query the posts properly. My last failed attempt looked like this:               add_action('genesis_loop', 'gt_custom_loop');     function gt_custom_loop() {     global $paged;              $args = array(         'post_type' => 'artists',         'key' => 'ecpt_featured_artist',         'compare' => '=',         'type' => 'CHAR',         'value' => 1,         );         // Accepts WP_Query args          // (http://codex.wordpress.org/Class_Reference/WP_Query)         genesis_custom_loop( $args );          }      Any help appreciated! EDIT: I've reduced it down to minimal code ONLY in my functions.php file, with the page using the default page template. This code now 404's me on my 'page' Featured Artists:               add_action( 'pre_get_posts', 'pw_filter_query' );     function pw_filter_query ( $query ) {         if( $query->is_page('featured-artists')) {         $query->set('post_type', 'artists');         }        }      What is going on!?


title: Why can't I use an array of term slugs in WP_Query?

text: In `WP_Query`, a comma-separated list of term slugs works fine:               $query = new WP_Query ( array(            'customtaxonomy' => 'term1,term2'     ) );      ...but an array of slugs causes a warning:               $query = new WP_Query ( array(            'customtaxonomy' => array( 'term1', 'term2' )     ) );      > **Warning:** urlencode() expects parameter 1 to be string, array given in > /path/to/wp-includes/formatting.php on line 3253 Another WPSE post proposes that this could be WP looking for hierarchy in a hierarchical taxonomy, but I can't think of any way to make sense of this behaviour. Do you know why this is happening?


title: How brute-forcer knows that the password is cracked for target username?

text: There are very many brute-force attacks (mostly for 'admin' username) on WordPress sites. All these attacks are made automatically via post requests. _The question 1:_ **how brute-forcer knows that the password is cracked for target username?** The brute-forcer try the typical passwords like: '12345', 'qwerty' etc. And often site administrators have username 'admin' with typical password and this username is cracked sometimes via brute-force. Limit-login attempts plugin solve this problem pretty good by the way. _The idea and question 2:_ if we know for sure that it is brute-force attack (javascript-test or cookie-test solve this because brute-force-bots are not usual browser clients) than **is it good approach to tell brute-forcer nothing at all even if the password chosen correctly?** Discussion on WordPress.org forum. Update: **I developedSecurity-protection plugin**. Plugin adds cookie on login screen and checks if this cookie exists in the POST request. If cookie does not exist than it is brute-force request and the login attempt is blocked even if username and password are correct. Plugin sends fake WordPress login cookies to the brute-force bot and redirects it to the admin section to emulate that the password is cracked and many brute-forcers stop their attacks after this. It is really awesome :)


title: How to let user select role upon registration in Facebook-AWD?

text: I would like to use the plugin Facebook-AWD plugin. My site would provide two ways of registration (normal and register with Facebook). Users must select their role, ie: _buyer_ and _seller_. With normal registration, I can achieve this easily but if my users choose to register with Facebook-AWD they can't select between roles as the plugin is set up to register user with default role:               'role'=>get_option('default_role');      How can achieve this by adding a hook or action or filter to the plugin in order to preserve the plugin core for future update?               public function register_user()     {         $username = sanitize_user($this->me['first_name'], true);         $i = '';         while (username_exists($username . $i)) {             $i = absint($i);             $i++;         }         $username = $username . $i;         $userdata = array(             'user_pass' => wp_generate_password(),              'user_login' => $username,              'user_nicename' => $username,              'user_email' => $this->me['email'],              'display_name' => $this->me['name'],              'nickname' => $username,              'first_name' => $this->me['first_name'],              'last_name' => $this->me['last_name'],              'role' => get_option('default_role')         );         $userdata = apply_filters('AWD_facebook_register_userdata', $userdata);         $new_user = wp_insert_user($userdata);         //Test the creation                                  if (isset($new_user->errors)) {             wp_die($this->Debug($new_user->errors));         }         if (is_int($new_user)) {             //send email new registration             wp_new_user_notification($new_user, $userdata['user_pass']);             return $new_user;         }              return false;     }


title: Why is my footer missing

text: Hi for some reason my footer is missing on my site, and i don't know why. I have deactivated all plugins and it's still not there, I have checked the css and all, but the footer is still missing can someone tell me whats wrong. When I view the Source Code the Footer is there but It's not showing up. The Site is EricaVain.com Here are the files on gist --> https://gist.github.com/mihadaiko/5008645


title: Load Paginated Comments Inline

text: Currently my WordPress blog loads the comments in paginated results (loading all at once slowed down the blog too much); first displaying the oldest 50, after clicking "<< Older Comments" it will display the next 50 oldest comments and so on. I would like these comments to load inline with the current comments eliminating the need to load a new page and hide the first 50 comments. For clarity: I am not looking to infinite scroll the comments, I would still like the user to have to click on the "Older Comments" text in order to view more comments.


title: set_post_thumbnail_size vs add_image_size

text: What is the difference between set_post_thumbnail_size and add_image_size? Is set_post_thumbnail_size for all images, and add_image_size for sizing images individually? Thanks.


title: Mixing Custom Post Types and Page Templates in Wordpress 3.7.1

text: ### Overview I have a Custom Post Type called Locations. When the user visits **/locations** , I would like them to see some general information about all the locations. When the user visits **/location/{a-location}** , I would like them to see specific information about "a-location". Sounds easy enough. ### 1st Solution Attempt I created a Locations page in the Wordpress dashboard to hold the content for the /locations url. I then created an archive-locations.php file and a single- location.php. archive-locations.php pulls info out of the Locations page and it lists all of the custom post type Locations. When the user clicks on a link for a location, the user gets redirected to /locations/{a-location} and single-location.php gets called. This almost does the trick, but it just doesn't feel right and it's creating some other problems. ### The Problem When a user visits /locations I would prefer to be working with a page template for the Locations page (instead of the archive-locations.php page). I'm using the Yoast plugin to specify a custom meta title and description for each page. Since archive-locations.php is being used, all of this meta gets ignored. If I were working with a page template, my meta info would get recognized correctly. Also, logically, it feels like I should be working on the Locations PAGE, not an archive. The Locations PAGE is it's own entity with much more content then just an archive of custom post types. To try and force it into an archive concept seems like a stretch. ### 2nd Solution Attempt So I created a page-locations.php template for the Locations page and I was hoping that it would get called instead of the archive-locations.php. Unfortunately, it does not. I then tried removing the archive-locations.php thinking that maybe it was taking precedence. That didn't help either; Wordpress simply renders index.php. If I disable the Custom Post type and visit /locations, then my page template is called correctly. It looks like naming a custom post type the same name as a page causes Wordpress some issues. However, I need to be somewhat similar for the URL structures to work out. /locations needs to pull from a page template; /locations/{a-location} needs to pull from another php file. ### Question Is there any way to get page templates and custom post types with similar permalinks to work together? If not, I guess my only option is to enhance my header.php and be smarter about determining the title and description when I'm on /locations. Here's the code that registers my custom post type in case I'm doing something wrong:               $args = array(         'labels'        => $labels,         'description'   => 'Holds our location specific data',         'public'        => true,         'menu_position' => 20,         'supports'      => array('title', 'editor', 'thumbnail', 'page-attributes' ),         'hierarchical'  => true,         'has_archive'   => true,         'rewrite'       => array('with_front' => false, 'slug' => 'locations') //remove /news/ from the permalink when displaying a custom post type     );     register_post_type( 'locations', $args );      (I also tried changing has_archive to false, but it didn't help.)


title: 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter

text:
I found some code for creating multi-column WordPress loops and I found some code for entries grouped by letter of the alphabet. But I can't quite get the code to work together...the order is a bit messed up. EXAMPLE http://52words.org/w/ I would appreciate some assistance.                         <?php     $num_cols = 4; // set the number of columns here     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // for pagination     $args = array(       'orderby' => 'title',       'order' => 'ASC',        'posts_per_page' => '199',       'paged' => $paged,       'post_type' => 'wiki'       );     query_posts($args);     //end of query section     if (have_posts()) :       for ( $i=1 ; $i <= $num_cols; $i++ ) :         echo '
';         $counter = $num_cols + 1 - $i;         while (have_posts()) : the_post();           if( $counter%$num_cols == 0 ) : ?>                  <?php              $title=get_the_title();              $initial=strtoupper(substr($title,0,1));             if($initial!=$letter)               {               echo "
$initial

";               $letter=$initial;               }              { ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ); ?> <?php the_title_attribute(); ?>"><?php the_title(); ?>
          <?php }   ?>                <?php endif;           $counter++;         endwhile;         rewind_posts();         echo '

'; //closes the column div       endfor; ?>


title: Add Filter - Pass Variable (PHP < 5.3)

text: When using Anonymous Functions in PHP < 5.3 I get this error: `Parse error: syntax error, unexpected T_FUNCTION` This is especially troublesome for add_filters. For instance, if I want to make a filter for a custom excerpt **The Function**               function custom_excerpt($new_length = 20, $new_more = '...', $strip = false) {         add_filter('excerpt_length', function () use ($new_length) {             return $new_length;         }, 999);         add_filter('excerpt_more', function () use ($new_more) {             return $new_more;         });         $output = get_the_excerpt();         $output = apply_filters('wptexturize', $output);         $output = apply_filters('convert_chars', $output);         if(!$strip)             $output = '<p>' . $output . '</p>';         echo $output;     }      The function above accepts 3 parameters, lenth, read more, strip. You pass this function a new length such as '30' and it will give me an post excerpt of 30 words. The read more will replace the default `[...]` with the functions default `...`. The point of this is to use `the_excerpt()` and change the amount of words and remove the `[...]` My question now is how can I pass my `$new_length` variable to this filter in PHP < 5.3?


title: Custom filter for main search: how to exclude specific post_type from search results

text: Is there a way to use WP_Query's method, set(), in order to exclude a specific post_type from a global search. Here was my unsuccessful attempt:               function _search_all($query) {       if($query->is_search()) {                 // get rid of in the news                 $query->set('post_type__not_in', array(IN_THE_NEWS_SLUG));              if(isset($_GET['post_type'])) {             $query->set('post_type', $_GET['post_type']);         } /*else {             $query->set("post_type", array(FEATURES_ID, BRIEFS_ID, PRESS_RELEASES_ID));         }*/     }     return $query;     }     add_filter("pre_get_posts", "_search_all");


title: Creating distinct pages for author profiles and lists of posts by author

text: The site I'm currently working on includes profile pages for each author plus a method to search for posts by a specific author. So we would have a page at `/author/author-name/` that only displays a list of posts by that author and a page at something like `/author/author-name/profile/` that shows extended user info but no posts. By default Wordpress includes an `author.php` template that shows some basic user info and recent posts by the author. This is found at `/author/author- name/`. When looking for recommended ways to build a user profile, everything I have found recommends altering this file and using the same URL, however we would like to use both. The only way I can think of achieving this would be to allow the page to take a parameter so that `/author/author-name/?profile=1`, rewrite it in `.htaccess` so that it appears as `/author/author-name/profile/`. Then alter `author.php` to check for this parameter and use a separate template. I would like to avoid methods such as this and stay on the Wordpress rails as much as possible. Are there any plugins or other Wordpress approved methods I could use to solve this problem? (We're running 3.8 by the way).


title: WordPress Blog RSS Feed?

text: Actually I want to Add My WordPress Blog To **CodeProject** Article List for That I need Rss Feed so Whenever I Post Any Article On My Blog It Will Automatically Listed on CodeProject As Well. I want to Know **WordPress** Blog **RSS Feed** but dont know any thing about it, Help Will Be Appreciated..


title: Cron jobs for deactivated plugins

text: Hi I am using a plugin to view the cron jobs that are run by wordpress. I am noticing that there are jobs related to plugins I have deactivated and even deleted. Why is this so and how can I remove them?


title: Direct iPhone visitors to different stylesheet?

text: Is there a method whereby I can employ a different stylesheet (different to the style.css in my child theme) to visitors viewing on the iPhone?


title: Using filter in the widget causes fatal error

text: I'm adding a filter for a WordPress query in a widget. I'm adding as following:               function filter_where( $where = '' ) {          }     add_filter( 'posts_where', 'filter_where' );     $query = new WP_Query( $args );     remove_filter( 'posts_where', 'filter_where' );      It works fine, but if I use the same widget more than 1 times then I get the fatal error that the same filter cannot be re-declared. How can I use the filter so that the same widget can be used multiple times? This is the exact error I get:               Fatal error: Cannot redeclare filter_where() (previously declared in xxx.php:70)      Thanks.


title: Deleting sites and users automatically in multisite

text: I am trying to create a scheduled delete of sites and their users in WordPress multisite. The code I made is successful in deleting the sites but not the users, can anyone offer a fix?               <?php     register_activation_hook( __FILE__, 'wpchat_clear_sites_activation' );     /**      * On activation, set a time, frequency and name of an action hook to be scheduled.      */     function wpchat_clear_sites_activation() {         wp_schedule_event( 1386979200, 'daily', 'daily_clear_sites_hook' );     }               add_action( 'daily_clear_sites_hook', 'wpchat_clear_out_sites_daily' );     /**      * Clear out the sites and users      */     function wpchat_clear_out_sites_daily() {          require_once( ABSPATH . 'wp-admin/includes/admin.php' );         require_once( ABSPATH . 'wp-admin/includes/user.php' );              if( ! function_exists( 'wpmu_delete_blog' ) ) return;                  $users_to_keep = array( '1','4','43' );              $blogs_to_keep = array( '1','4' );              $all_sites = wp_get_sites();                  // Remove all blogs except for the main blog and the template blog         foreach ( $all_sites as $key => $val ) {                  $users = get_users( array( 'blog_id' => $val['blog_id'], 'fields' => ID ) );                  // Remove all users except for the test site admins             foreach ( $users as $user) {                       if ( ! in_array( $user['ID'], $users_to_keep ) ) {                     wpmu_delete_user( $user['ID'] );                 }             }                  if ( ! in_array( $val['blog_id'], $blogs_to_keep ) ) {                 wpmu_delete_blog( $val['blog_id'], true );                       }              }     }      The sites are deleted via cron or via direct function call, so cron is not the issue here, it's the way I'm trying to delete users.


title: Syling Custom Fields echo's from from functions.php

text: With the help of User Borek I've managed to get Custom Fields displaying on my siteby putting the below in the functions.php:               function custom_field_before_content() {     if(is_page() || is_single() || is_archive() ) {         echo genesis_get_custom_field('instrument');}     }     add_action( 'genesis_entry_header', 'custom_field_before_content' );      I'm having trouble putting an id or class on them though so I can style them. I am using a Genesis theme and I can't figure out how to do this. I have tried following this tutorial with no success. Does anyone know where I can put an id or class on these custom fields in a genesis theme? This is one of the pages where my custom fields are displaying: http://bethlehem-music.org/?p=18. Right above the image and under the title. Appreciate any help, Ciarán


title: How to prevent a function from running based on host (ie web vs local)?

text: I am using LiveReload to refresh my browser and compile my SASS. The browser extensions are not working so well for me, so I am adding the script to my footer. I'm trying to think of a way to prevent the function that adds it from running if it is on a live web server opposed to my local production environment XAMPP (in OSX 10.6.8). This is what I have now:               if (! function_exists('_sf_live_reload') && ! is_admin() ) :     function _sf_live_reload() { ?>     <script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>     <?php      }     add_action('tha_body_bottom', '_sf_live_reload');     endif;      Yes, I know I could just remember to manually delete it before uploading, but lets assume I forge things from time to time. Plus deleting and recreating this over and over again isn't the best solution anyway.


title: HTTP Error when uploading images over specific dimensions

text: Hello I have a reseller account with one wp 3.5 multisite on a shared hosting. Suddenly I can't upload photos after some random dimensions(It uploads the small sized ones just fine, but it has problems with the bigger ones).Specific any photo over than 511(width) i got http error , and any image less than 511(width) upload without any http error **Operating System :** Linux (64 Bit) **Server:** LiteSpeed **Apache version:** 2.2.23 **Entry Processes:** 20 **Virtual Memory Usage & Physical Memory Usage:** 1048576 KB (each) **I/O Usage:** 1024 KB/s **My PHP specs:**   * **PHP Version:** 5.3.18   * **mysql Client API version:** 5.1.65-cll   * **post_max_size** 60m (Local Value) - 60m (Master Value)   * **upload_max_filesize** 100m (Local Value) - 200m (Master Value)   * **memory_limit** 1024m (Local Value) - 1024m (Master Value)   * **max_input_time** 60 (Local Value) - 60 (Master Value)   * **max_execution_time** 3600 (Local Value) - 600 (Master Value) **functions.php of my theme:** http://pastebin.com/ddEQqVJy My multisite .htaccess is                   # BASIC SECURITY        <IfModule mod_security.c>        <Files async-upload.php>         SecFilterEngine Off         SecFilterScanPOST Off         </Files>         </IfModule>         #<IfModule mod_security.c>         #SecFilterEngine Off         #SecFilterScanPOST Off         #</IfModule>         php_value memory_limit 1024M         php_value max_execution_time 3600         php_value post_max_size 60M         php_value upload_max_filesize 100M         </IfModule>         #php_value memory_limit 128M         #php_admin_flag safe_mode off         # Prevent folder browsing         Options All -Indexes              <Files wp-config.php>         order allow,deny         deny from all         </Files>              # BEGIN feedburner and uploaded files adjustments.         <IfModule mod_rewrite.c>         RewriteEngine On         RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC]         RewriteRule ^feed/?.*$ http://feeds.feedburner.com/mysite [L,NC,R=302]         RewriteRule ^home?.*$ http://feeds.feedburner.com/mysite [L,NC,R=301]         RewriteRule ^wp-content/uploads/(.*)$ http://mysite.com/files/$1 [L,R=301]         RewriteRule ^wp-content/gallery/(.*)$ http://mysite.com/files/$1 [L,R=301]         RewriteRule ^wp-content/uploads/jw-player-plugin-for-wordpress/player/player.swf$ http://mysite.com/files/jw-player-plugin-for-wordpress/player/player.swf$1 [L,R=301]         </IfModule>              # BEGIN ANTISPAMBLOG REGISTRATION         <IfModule mod_rewrite.c>         RewriteEngine On         RewriteCond %{REQUEST_METHOD} POST         RewriteCond %{REQUEST_URI} .wp-signup.php*         RewriteCond %{HTTP_REFERER} !.mysite.com. [OR]         RewriteCond %{HTTP_USER_AGENT} ^$         RewriteRule (.*) http://die-spammers.com/ [R=301,L]              RewriteCond %{REQUEST_METHOD} POST         RewriteCond %{REQUEST_URI} .wp-comments-post.php*         RewriteCond %{HTTP_REFERER} !.*mysite.com.* [OR]         RewriteCond %{HTTP_USER_AGENT} ^$         RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]         </IfModule>              # BEGIN Watermark Hotlinked Images         <IfModule mod_rewrite.c>         RewriteEngine On         RewriteCond %{HTTP_REFERER} !^$         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?mysite.com  [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?google.\ [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?facebook.com [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?twitter.com [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?yahoo.\ [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?bing.\ [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?ixquick.com  [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?feeds.feedburner.com/mysite  [NC]         RewriteRule ^(.*\.(png|gif|jpe?g))$ http://mysite.com/wp-content/plugins/watermark-hotlinked-images/watermark.php?img=$1 [L]         </IfModule>              # END Watermark Hotlinked Images              #Begin gzip and deflate         <IfModule mod_deflate.c>          AddOutputFilterByType DEFLATE text/html text/css application/x-javascript text/plain text/xml image/x-icon         </IfModule>         <IfModule mod_expires.c>         ExpiresActive On         ExpiresByType text/html M3600         ExpiresByType text/css M3600         ExpiresByType application/x-javascript M3600         ExpiresByType image/bmp M3600         ExpiresByType image/gif M3600         ExpiresByType image/x-icon M3600         ExpiresByType image/jpeg M3600         </IfModule>              # BEGIN WordPress         RewriteEngine On         RewriteBase /         RewriteRule ^index.php$ - [L]              # uploaded files         RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]              RewriteCond %{REQUEST_FILENAME} -f [OR]         RewriteCond %{REQUEST_FILENAME} -d         RewriteRule ^ - [L]         RewriteRule . index.php [L]         #END WordPress      Update: This is my functions.php of my theme http://pastebin.com/ddEQqVJy We find the problem , the problem is on line 131               add_image_size('theme-thumb', 520, 497, true);      lines 267-275               if (function_exists('add_theme_support')) {         add_theme_support('post-thumbnails');         set_post_thumbnail_size(150, 250); // default Post Thumbnail dimensions     }          if (function_exists('add_image_size')) {         add_image_size('post-thumb', 310, 9999); //300 pixels wide (and unlimited height)         add_image_size('widget-thumb', 220, 180, true); //(cropped)     }      When we took them off it didn't show any "HTTP error" when we uploaded a photo on media. on function.php of Twenty Twelve use               // This theme uses a custom image size for featured images, displayed on "standard" posts.         add_theme_support( 'post-thumbnails' );         set_post_thumbnail_size( 624, 9999 ); // Unlimited height, soft crop      without giving any "HTTP error" is strange, do you know why is this happening? And how can I fix it?


title: How to track hits of a single media file?

text: I have multiple media files in my WordPress Media Library. Icons, Images, PDF's and the like. I would like to have a stat counter, that gives me a statistic of the downloads/hits of those files, individually. **I already use WP SlimStat** to track page view, and I am quite happy with it. However, **I have not found a possibility to track those media files.** How can I do this?


title: Moving a WP Multisite to a subdirectory

text: Firstly, I've read a number of posts on this process. However, for various reasons, the process remains difficult to implement or troubleshoot for lack of even abstracted examples, or maybe too abstracted. And there's a few "can not do" posts, nearly always followed up by "with 3.5, you now can" caveats, so whether one can remains ambiguous, though no doubt non-trivial. ## Summary: How to move a wordpress multisite (WPMS) from root.com to root/blogs? For this example, we're moving a WPMS from "root.com" to "root.com/blogs" I understand that I need to update the paths in the database and wp-config.php appropriately. It seems I may also have to update .htaccess? I'm also aware of the serialization issue with search/replace and mysql query updates. I have a WPMS that I've updated to 3.5. I've found the following tables with domain and path info ## Existing working configuration before move to subdirectory ### 1. wp_blogs               select blog_id, domain, path from wp_blogs;     +---------+-------------+--------+     | blog_id | domain      | path   |     +---------+-------------+--------+     |       1 | root.com    | /      |     |       2 | root.com    | /matt/ |     +---------+-------------+--------+      ### 2. wp_site               select * in wp_site;     +----+-------------+------+     | id | domain      | path |     +----+-------------+------+     |  1 | root.com    | /    |     +----+-------------+------+      ### 3. The blog_id corresponds to the wp_#_options tables which contain:               select option_name,option_value from wp_2_options      where option_name = 'home' or option_name = 'siteurl';     +-------------+--------------------------+     | option_name | option_value             |     +-------------+--------------------------+     | home        | http://root.com/matt/    |     | siteurl     | http://root.com/matt/    |     +-------------+--------------------------+      ### 4. In my **wp-config.php** I have the following WPMS-specific lines:               define('WP_ALLOW_MULTISITE', true);     define( 'MULTISITE', true );     define( 'SUBDOMAIN_INSTALL', false);     $base = '/';     define( 'DOMAIN_CURRENT_SITE', 'root.com' );     define( 'PATH_CURRENT_SITE', '/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      ### 5. Lastly, in my **.htaccess** , I have:               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # uploaded files     RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]     RewriteRule . index.php [L]      ## Updates required to move the site It seems to me that in order to move my site to the /blogs , I would: ### 1. Update wp_blogs to               mysql> update wp_blogs set domain=concat(domain, '/blogs'), path=concat(path, 'blogs/');     select blog_id, domain, path from wp_blogs where blog_id < 3;     +---------+-------------+--------------+     | blog_id | domain      | path         |     +---------+-------------+--------------+     |       1 | root.com    | /blogs/      |     |       2 | root.com    | /blogs/matt/ |     +---------+-------------+--------------+      ### 2. Update wp_site to               update wp_site set domain=concat(domain, '/blogs'), path=concat(path, 'blogs/');     select * from  wp_site;     +----+-------------+------------+     | id | domain      | path       |     +----+-------------+------------+     |  1 | root.com    | /blogs/    |     +----+-------------+------------+      ### 3. wp_#_options               +-------------+--------------------------------+     | option_name | option_value                   |     +-------------+--------------------------------+     | home        | http://root.com/blogs/matt/    |     | siteurl     | http://root.com/blogs/matt/    |     +-------------+--------------------------------+      ### 4. wp_config.php               define('WP_ALLOW_MULTISITE', true);     define( 'MULTISITE', true );     define( 'SUBDOMAIN_INSTALL', false);     $base = '/blogs/';     define( 'DOMAIN_CURRENT_SITE', 'root.com' );     define( 'PATH_CURRENT_SITE', '/blogs/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      **note:** I'm not clear how this step is appropriately updated ### 5. .htaccess I found vague "update .htaccess appropriately" instructions, but not specifics. Update RewriteBase? Which lines in .htaccess to I update when I move root.com to root.com/blogs? Missing from the above process will be the paths founds in posts. My druthers are to use the search and replace tool for that, after I've made this more fundamental updates; or am I wrong? _Update_ bungeshea suggests that, yes, I point RewriteBase to the "blogs" subdirectory, i.e.,               RewriteBase /Blogs      Finally, if you don't know about http://interconnectit.com/products/search- and-replace-for-wordpress-databases/ you should. It's excellent.


title: Taxonomy + post_type

text: I'm quite lost with taxonomies and custom post type.   * I have a taxonomy -> auteur    * I have custom_post-type -> citation (quote in french). I just want list all citations (quote) from an auteur (auteur = taxonomy) with a permalink structure like this :               www.myblogname.com/citation/auteur_name/      or               www.myblogname.com/auteur_name/citation/      or               www.myblogname.com/auteur/auteur_name/citation/      ( in fact the easiest way). what are the steps to do this job (and what is the template page to modify).


title: Category based on post id

text: I have the following:               $custom_loop = new WP_Query( array('category_name'=>$category, 'meta_key'=>'name', 'orderby' => 'meta_value', 'order' => 'ASC', 'posts_per_page'=>'-1'));      How can I tell it that if `$post->ID == 1` then `$category == 'first'` and if `$post->ID == 2` then `$category == 'second'` I suppose it should be an array of some sort, but I just can't figure out what?


title: creating a static HTML/JS/PHP page

text: i need to create a static page that allows me to code HTML/JS/PHP that connects to a separate MYSQL backend. how can i achieve such in wordpress page?


title: Setting name of attachment URL

text: I have a problem I need to fix with the URLs that are generated for the attachment pages of images with metadata. I’m working on a photography site where individual photos are displayed as attachments to a post, via `attachment.php`. The URL scheme for displaying these photos is something like this: `domain.com/project-name/attachment/attachment-name`. If I upload an image without any metadata, then the last part of the attachment URL is taken from the file name of the image. So, if the image is `ABCD.jpg`, then the URL is `domain.com/project-name/attachment/ABCD`. All good. However, if the image _does_ have a title in the metadata, then the URL is set to that title: `domain.com/project-name/attachment/omg-cool-photo`. Is it possible to have a metadata title with a photo, but to also have the URL that is set for the attachment to remain as the photo filename? If so, how? I took a look around but I couldn’t see anything about this here already. Sorry if it is and I missed it. Any help gratefully received! Thanks.


title: Posts with no meta field do not appear when sorting by meta field

text: I want to order my posts by a custom meta field "fieldA". I am using the following code:               $query->set( 'meta_key', 'fieldA);     $query->set( 'orderby', 'meta_value_num' );     $query->set( 'order', 'DESC' );      Ordering works fine but there is a problem. All posts which do not have the meta_key "fieldA" are not fetched. Any idea what's wrong? thx


title: What is the most efficient way of adding additional functionaliy for admin only

text: I'm trying to figure out the best approach to add additional functionality that will only be utilized by admins via /wp-admin. What's the best way to implement so that resources aren't being wasted. I.E. if statement each page load or any other code execution on each page load for areas not even pertaining to the dashboard. Thanks.


title: Comments orderby comment date not working

text:
I have a template to get the comment replies to a user and display it on a static page. It works reasonably well in so far as the correct comments are displayed but whatever I try I can't get the replies to order by comment date, the newest first, but instead they will order by their parent comment first and after that by date. Also, the pagination is not displaying. I would be most grateful for any help or hints here!               <?php      global $current_user;     get_currentuserinfo();     define('DEFAULT_COMMENTS_PER_PAGE',6);     $page = (get_query_var('page')) ? get_query_var('page') : 1;     $limit = DEFAULT_COMMENTS_PER_PAGE;     $offset = ($page * $limit) - $limit;     $param = array(         'status'=>'approve',         'user_id' => $current_user->ID,         'comment_parent' => 0     );     $parent_comments = get_comments($param); ?>     <?php foreach($parent_comments as $parent_comment) : ?>     <?php $parent_comment_id = $parent_comment->comment_ID;     $comment_args = array(         'orderby' => 'comment_date',         'status' => 'approve',         'parent' => (int)$parent_comment_id,         'offset' => $offset,         'number' => $limit     );     $comments_query = new WP_Comment_Query;     $comments = $comments_query->query( $comment_args );     if ( $comments ) : ?>         <?php foreach($comments as $reply) : ?>
             <?php echo $reply->comment_author; ?>has left a                 <a href="<?php echo get_comment_link( $reply->comment_ID ); ?>">reply to your <a href="<?php echo get_comment_link( $parent_comment->comment_ID ); ?>">comment
                 <?php echo apply_filters('the_content', $reply->comment_content); ?>

         <?php endforeach; ?>     <?php endif; ?>     <?php endforeach; ?>
          <?php $pages = ceil(count($comments)/DEFAULT_COMMENTS_PER_PAGE); ?>          <?php     $args = array(         'base' => 'http://mywordpress.example/user/replies/%#%',         'format' => '?page=%#%',         'total' => $pages,         'current' => $page,         'show_all' => False,         'end_size' => 1,         'mid_size' => 2,         'prev_next' => True,         'prev_text' => __('Previous'),         'next_text' => __('Next'),         'type' => 'plain');           echo paginate_links( $args );     ?>


title: get_queried_object() returns null on post date archive

text:
`get_queried_object()` returns `null` on post date archives (page type `is_date()`) and the main blog index page (page type `is_home()`). Is this intentional, or just an oversight? I was writing a wrapper around get_queried_object() to get the title of the current page, no matter what type of page it is, for use in a theme. I quickly realized that instead of using `get_query_object()` I should just duplicate the important bits from `wp_title()`, but before that I came across an interesting issue. It appears that `get_queried_object()` and its root function `WP_Query->get_queried_object()` return `null` for a couple of listing types, including the primary posts list output by index.php (page type `is_home()`) and post archives by date (page type `is_date()`). I tested this by throwing the following snippet into a number of template files in a number of locations, always after `get_header()` and before `the_post()`:
<?php         $queried_object = get_queried_object();         var_dump( $queried_object );     ?>
      This works perfectly on category archives, tag archives, custom taxonomy archives, and custom post type archives. `get_queried_object()` returns the query object, which can be used to extract a page title and other useful information. However, it fails in archive.php for standard post date archives and index.php for the normal blog posts home page list view. Digging into the source of `WP_Query->get_queried_object()` reveals something rather unsurprising: there is no check for page type `is_home()` or page type `is_date()`, so on those page types `$this->queried_object = null;` is not updated and the function returns `null`. So my question is, is this intended functionality (e.g. are you not supposed to use get_queried_object() on those pages), a technical limitation (is there not a meaningful object to return on those pages), or simply an implementation oversight? Is there even an equivalent of the custom post type object for the built-in "blog post" post type to display?


title: How to Create Editable Blocks of Text for the Homepage?

text: I'm making a site based on WordPress. It's not going to seem a blog or WP. Just a website. So WP acts like backend where the client can edit the text blocks. Question:   * How can I put block of text on my designed template wich users can edit from admin panel? Let's say something like this: ![homepage wireframe](http://i.stack.imgur.com/i1mku.png) The 3 top blocks (about us, mission, why us...), how do you fill them from admin panel? Or specific text from header or footer. Do I have to create 3 posts, and reference them on template through `get_post($id)`? Which is the best way to do it?


title: Selectbox Custom Post Type

text: I use a dropdownbox to show all custom types. On the archive page of the custom post type it works fine. If I put dropdownbox to another site, it doesn´t work anymore. The selectbox is empty. Any ideas?                 <input type="text" class="text-input" placeholder="Nutzungsdauer" value="" name="nutzungsdauer" id="nd">      function.php               function afa_type_dropdown( $post_type )     {     $posts = get_posts(     array(         'post_type'  => $post_type,         'numberposts' => -1     )     );     if( ! $posts ) return;          $out = '<select id="afa_select"><option>Anlagegut auswählen</option>';     foreach( $posts as $p )     {     $out .= '<option value="' . get_permalink( $p ) . '">' . esc_html( $p->post_title ) . '</option>';       }     $out .= '</select>';     return $out;     }


title: add_filter and changing output captions of image gallery

text: I'd like to change only one output of native WP Gallery (in media.php) On Smashing Magazine (link) author advises to change whole gallery_shortcode function. But I wondered if is possible to change only specific output ($captiontag) I wrote:               add_filter( 'captiontag', 'my_captiontag' );          function my_captiontag( $captiontag ) {      $output .= "       <{$captiontag} class='wp-caption-text gallery-caption'><p>       " . wptexturize($attachment->post_excerpt) . "       </p></{$captiontag}>";     }      but it doesn't work :(


title: determining if the user is logged in

text: I am new to wordpress, and trying to get my head around the idea of sessions and all. I read in a lot of places that session concept is not used in wordpress. Anyway, I downloaded the my-login-theme plugin. My question is, when a user navigates to some secured area, I want to check if that user is logged in or not. Once I check that, I want to get user details like email, and full name. Is this possible in wordpress? Thanks


title: post_date vs. post_modified - what's the difference?

text: Recently I was surprised to find out that `post_date` and `post_modified` fields contain the same values. Isn't a `post_date` supposed to hold the creation date for the post? And shouldn't only `post_modified` change for all future updates? For now they all get changed simultaneously for every update.