title: wp_handle_upload: get custom checkbox value from media uploader

text:
I found a snippet to add a checkbox to media uploader using action **post- upload-ui** Snippet found here               /**      * Add checkbox to set autocreate on upload      */     function fifteenccgal_autocreate_post_on_image_upload_form_tweaks()     {         ?>                      <input  type="checkbox"                      id="fifcc_autocreate"                      name="fifcc_autocreate"                      value="1"                      <?php echo ((FIFTEENCCGAL_AUTOCREATE_DEFAULT_STATE == 1) ? 'checked="checked"' : '')?>" />              Auto-create a Photo Post for each uploaded image?

                  <?php     }     add_action('post-upload-ui', 'fifteenccgal_autocreate_post_on_image_upload_form_tweaks');          ////     // You might also wish to set a default value on load. WordPress provides a suitable hook…     ////          /**      * Initialise the value to reflect the checkbox default      */     function fifteenccgal_autocreate_post_on_image_upload_post_params_init($params)     {         $params['fifcc_autocreate'] = FIFTEENCCGAL_AUTOCREATE_DEFAULT_STATE;         return $params;     }     add_filter('upload_post_params', 'fifteenccgal_autocreate_post_on_image_upload_post_params_init');      My question is: how can I handle the user choice on upload? I tried something like that               add_filter('wp_handle_upload', 'my_wp_post_upload');          function my_wp_post_upload($fileinfo){             if(!empty($_POST)) {         ob_start();         var_dump($_REQUEST);         var_dump($_FILES);         $datapost = ob_get_clean();         $fpp = fopen("wp_handle_upload.txt", "a");         fwrite($fpp, $datapost);         fclose($fpp);             }     }      To understand what wp_handle_upload is passing but I get only               array(4) {       ["name"]=>       string(10) "band_1.jpg"       ["action"]=>       string(17) "upload-attachment"       ["_wpnonce"]=>       string(10) "f3c98e2267"       ["post_id"]=>       string(3) "177"     }     array(1) {       ["async-upload"]=>       &array(5) {         ["name"]=>         string(10) "band_1.jpg"         ["type"]=>         string(10) "image/jpeg"         ["tmp_name"]=>         string(14) "/tmp/phpn3I1HG"         ["error"]=>         int(0)         ["size"]=>         int(34789)       }     }      No way to get the checkbox choice here? Thanks


title: Gallery requires a featured image but does not show it in posts/pages

text: I've encountered a weird bug with my theme's gallery. If I add a gallery, and do not specify a featured image, it will not show in the post/page. If I add a featured image, it will show the gallery but it will ignore the featured image. I want to know what causes this? Perhaps I need to edit something in the media.php?


title: Posts Admin Pagination Items Count

text: Does anyone know what the wordpress post admin item count is based off of? I'm seeing a mismatch between this number and what my Draft + Published posts total is. Please see screenshot attached. Thanks!! Posts Admin Screenshot


title: WP Insert post with post_thumbnail

text: Insert post thumbnail with ' **wp_insert_post** ', i'm trying this code but does not work, the field ' **get_field('imagem_do_produto')** returns the url of the image, why not work?               <?php $exists = get_page_by_title( get_field('fornecedor'), OBJECT, 'fornecedores');         if(empty($exists)){             $insert_post = array(                 'post_status' => 'publish',                 'post_type' => 'fornecedores', // post_type which is created posting                 'post_title' => get_field('fornecedor'), // Custom field to generate the post type                 'post_thumbnail' => get_field('imagem_do_produto') // returns URL of image for feature image             );             wp_insert_post($insert_post);         }     ?>      he code creates the post, but only the title or content.   I wanted to add a highlighted image for this post to be created. tnks


title: How to get featured image removed from post, but to stay on page?

text: Here is the example of my post: http://garthlaidlaw.com/govan-portrait/ I don't need the cropped featured image file I uploaded to appear at the top of the post - it's overkill. I would however like it to stay on the blog page: http://garthlaidlaw.com/blog/ I'm very new with website code, so any basic help would be appreciated. I often have trouble figuring out where to post code in the Editor, so please be very specific! Thank you for your help and time. Garth Laidlaw


title: How do I get my theme scripts to load in a custom theme built from Bootstrap

text: I have created my own theme, pretty much from scratch, using Bootstrap 3.x. If just refer to the scripts from my footer.php file, it works. However, if I try to do it the right way, using wp_register_script, followed by wp_enqueue_script. The only thing I get loaded is the bootstrap.js script. My code is here: http://pastebin.com/u8LF9w0P It is very short. Also, at the risk of sounding naive, how is the functions.php inside my theme being called? Is it just automatically called if it exists in a theme directory? I'm not getting not found errors in the console, I'm just seeing that only bootstrap.js or bootstrap.min.js is being loaded and nothing else. The files are there in the right place. I know that because when I just call them using wp functions like get_stylesheet_dir() to use in a script tag in footer.php, all works fine. Thanks, Bruce


title: Dynamic number within shortcode

text: I need to write a dynamic shortcode. The original says: [... width="940" height="200" ...] I need to have this: [... width="`<php>`" height="`<php>`" ...] How do I get this to happen?? Thanks, Floyd


title: Show Sticky Posts in Category Archive

text:
I'd like to be able to show sticky posts at the top of category pages. I'm using archive.php for my category page. I'm using the code below to display sticky posts at the top of my category archive page followed by the rest of the posts within that category. This works fine, until there are no sticky posts to display within the category and then it duplicates the posts list.               <?php        // get the current category     $category = get_the_category();     // get the sticky post in the category, order by title - ascending     query_posts(array( 'post__in' => get_option('sticky_posts'), 'orderby' => 'title', 'post_date' => 'DESC' , 'cat' => ''.$category[0]->cat_ID.'' ));     ?>     <?php if (have_posts()) : ?>     <?php     if ($cat)     {echo "
Articles in " . get_the_category_by_ID($cat) . "
";}     ?>
               <?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?> Updated on <?php the_modified_date(); ?> at <?php the_modified_time() ?>
         <?php endwhile; ?>
             <?php endif; ?>               <?php        // get the sticky post in the category, order by title - ascending     query_posts(array( 'post__not_in' => get_option('sticky_posts'), 'orderby' => 'title', 'post_date' => 'DESC' , 'cat' => ''.$category[0]->cat_ID.'' ) );     ?>     <?php if (have_posts()) : ?>
               <?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?> Updated on <?php the_modified_date(); ?> at <?php the_modified_time() ?>
         <?php endwhile; ?>
             <?php if(function_exists('wp_page_numbers')) { wp_page_numbers(); } ?>              <?php else : ?>
Sorry, no articles have been published in the <?php if ($cat) {echo "" . get_the_category_by_ID($cat) . "";} ?> category.
             <?php include (TEMPLATEPATH . '/searchform.php'); ?>          <?php endif; ?>      Any help would be greatly appreciated! Thanks.


title: Why is save_post hook not running?

text: I am trying to save my meta box, I have something like               function xxx_meta_box_callback() {         add_meta_box('xxx-meta', 'xxx Details', 'xxx_meta_box', 'xxx-post-type', 'side', 'default');         add_action('save_post', 'xxx_save_meta_box');         error_log('meta box cb');     }          function xxx_save_meta_box($post_id, $post) {         error_log('running ...');         die('OK!!!');     }         I am getting "meta box cb" ok in my error log, but `xxx_save_meta_box()` does not seem to run. Why is that?


title: Is this a bad implementation of wp_enqueue_script for conditional usage?

text: Conditionally Including scripts whether js or css in xhtml document head...has been a generally tricky affair, especially if you want to enqueue something, based on a shortcode or custom meta field or a widget. If you know that you need your script for sure,you would just do what the Wordpress Codex suggest by using wp_enqueue_script with following hooks,               * init     * template_redirect     * admin_print_scripts      But sometimes you require a more nuance inclusion of a script or stylesheet. Script inclusions based on shortcodes for example. The issue with shortcodes is that you couldn't really tell if a shortcode has been used, unless you apply strpos() on the content. The reason for this is because, the 'init' + 'template_redirect' + 'admin_print_scripts' hooks fire before the WP_Query object is set, i believe. So it can get tricky for conditionally including scripts for shortcodes and other triggers. To circumvent this, you can use strpos() with 'the_posts' hook, which gets fired before wp_head. But one of the drawbacks is that its an extra pass at the data. Discussed at http://beerpla.net/2010/01/13/wordpress-plugin-development-how- to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/ Additionally, i havn't seen examples of this enqueue scripts with this hook being able inject js or css in the head of the document Scribu suggest, using a flag variable, and sending it to the footer, http://scribu.net/wordpress/optimal-script-loading.html ...but that's not feasible for css style sheets that should be included in the head portion of the document I've been pondering the best compromise,and wanted to know your thoughts. basically, my hook of choice is wp_head, because i have access to the WP_Query object, in case i need to search for the shortcode, or use a conditional tag, or even widget usage detection. If i know that i need to inject css or js, then i can just recall the wp_print_scripts() function, after figuring out if the page needs my js or css. Here is a framework for script inclusion on WP 3.1...i've used it successfully for js inclusion. Havn't tried it for CSS yet, but i suspect it will work the same.               add_action("wp_head","add_conditional_scripts", 20);     function add_conditional_scripts() {        global $posts, $wp_scripts;              foreach ($posts as $post) {              if ( condition_gets_met == true ) :                  wp_enqueue_script( "scripthandle" , get_home_url().'/js/scriptfilename.js, array('jcycle'), '1.0', true);   // This will add to the $wp_scripts variable             endif;         }             wp_print_scripts(); // This uses the $wp_script object, will print, out the newly enqueue script     }      Note that the *condition_gets_met is a stand in for strpos check or a conditional tag, or custom_meta_field check. Any feed back or criticisms of doing it this way would be great.


title: Allow contributors to add categories, but not delete

text: I used a plugin called "User Role Editor" to allow contributors to add categories, but it also lets them delete categories. Any suggestions?


title: Show multiple categories in query using redux framework variable

text: Stuck on trying call an option variable using the Redux Framework - that is utilizing multi-category select - inside the query. Here's what I have as my query:               $the_query = new WP_Query(array(     array( 'category__and' => $my_options['featured_section']  ),     'posts_per_page' => 1      ));      while ( $the_query->have_posts() ) :      $the_query->the_post();      This doesn't work. The output of `$my_options['featured_section']` is:               Array ( [0] => 20 [1] => 16 )      I have two categories selected in the options area, which are ID 20, and ID 16. Any idea why this won't call the correct categories?


title: custom autocomplete search

text:
I try to implement an autocomplete search but I have some troubles to make it works correctly. When I write in search input some words, the autocomplete search doesn't filter the results and always display all my posts. So it doesn't search at all... And I've also some difficulties to understand the way to display custom result, like the tumbnail, the title and the category for each finded post. Here my scripts:               require_once ($admin_path . "search_autocomplete.php");          function search_ac_init() {           wp_enqueue_script( 'search_ac', get_template_directory_uri() . '/js/search_ac.js', array('jquery','jquery-ui-autocomplete'),null,true);          wp_localize_script( 'search_ac', 'MyAcSearch', array('url' => admin_url( 'admin-ajax.php' )));     }      add_action( 'init', 'search_ac_init' );      in search_autocomplete.php :               <?php          add_action( 'wp_ajax_search_autocomplete', 'search_autocomplete' );       add_action( 'wp_ajax_nopriv_search_autocomplete', 'search_autocomplete' );           function search_autocomplete(){           $posts = get_posts( array(               'search' =>$_REQUEST['term'],           ) );            $suggestions=array();           global $post;           $args = array('post_type' => array('post', 'portfolio'), 'posts_per_page' => 10, 'post_status'  => 'publish');         $myposts = get_posts($args);         foreach ($myposts as $post): setup_postdata($post);               $suggestion = array();               $suggestion['label'] = esc_html($post->post_title);               $suggestion['link'] = get_permalink();               $suggestions[]= $suggestion;           ?>                //<a class="link" href="<?php echo get_permalink(); ?>");>             //
                 //<img class="<?php echo  wp_get_attachment_url( get_post_thumbnail_id()); ?>"/ >             //
             //
<?php echo the_title(); ?>
             //
<?php echo $post_type; ?>
         //         // I want to display like above         <?php            endforeach;           $response = $_GET["callback"] . "(" . json_encode($suggestions) . ")";           echo $response;             exit;       }            ?>      and search_ac.js :               jQuery(document).ready(function ($){           var acs_action = 'search_autocomplete';           $("input#search").autocomplete({               minLength: 3,             source: function(req, response){                   $.getJSON(MyAcSearch.url+'?callback=?&action='+acs_action, req, response);               },               select: function(event, ui) {                   window.location.href=ui.item.link;              },                 open: function(event,ui){                 var len = $('.ui-autocomplete > li').length;                 var ImgAtocompleteWidth = 60*(1/ratio);                 $(".image-autocomplete").width(ImgAtocompleteWidth);                 $('#input-count').show();                 $('#clearInput').show();                 if (len==1) {                     $('#input-count').html(len+' result');                 } else {                     $('#input-count').html(len+' results');                     }                 },             close: function( event, ui ){                    $('#input-count').html('')                                  .hide();                 $('#clearInput').hide(100);                 if( $('#noMatches').is(':visible') ) {                         $('#clearInput').show(100);                  }                    },             focus: function (event, ui) {                 titleinput = ui.item.value;                 ui.item.value= $.trim(titleinput);                 $( "input#search" ).val( ui.item.value );                 $('#input-count').show();                 return false;             },               }).focus(function(event, ui){                 $(this).autocomplete("search");             })       });


title: Change TinyMCE Block Format Labels

text: For the sake of my site editors, I'm trying to rename the Headings in the TinyMCE dropdown. I looked into filtering options but came up totally empty. I've also tried a javascript solution but haven't gotten anywhere with that. When I run `jQuery('#mce_4 a').text('Heading');` in the browser console, it works like a charm, yet when I put it into an javascript file and put it in the `.load()` function nothing happens. (The file itself is fine as it's running other functions already.) If I run `console.log(jQuery('#mce_4 a'));` in my file, it comes up empty as if there isn't any DOM object matching that selector. The TinyMCE editor buttons are not in an iframe themselves, so that doesn't seem to be the issue either. I would be thrilled with a PHP or JS solution.


title: How to get error object returned by wp_create_user

text: I'm creating a registration widget for my wp site and it works as expected, however if the user already exists I need a way of retrieving that information. I'm using ajax to make the call here is my code:               $.post(AjaxRequest.ajaxurl, {                         action: "send_wlm",                         user_login: formdata[0].value,                         user_email: formdata[1].value,                         user_practice_role: formdata[2].value,                         user_practice_level: formdata[3].value,                         user_practice: formdata[4].value                     }, function (response) {                         console.log(response);                     });      PHP               public function wlm_user_level (){         global $wpdb;         $random_password = wp_generate_password( $length=12,     $include_standard_special_chars=false );         $user_name = $_POST['user_login'];         $user_email = $_POST['user_email'];         $user_id = wp_create_user( $user_name, $random_password, $user_email ); }      My only question is, I know that it returns an error object but how do I get that object to return it from my ajax call?


title: Dynamic navigation for custom post type (pages)

text: I have a set of custom post types with the `capability_type` argument set to `'page'` I want to include these in `wp_list_pages()` or similar so I can use the dynamic classes (such as `.current_page_item` and the like). I've read this post but I'm not sure it's exactly what I'm looking for, can anyone help me out with a code sample / more in-depth explanation.


title: Query posts by searching for a string in a meta field

text: I'm trying to see if I can make this happen with the built-in meta_query function. I'm taking a `$_GET` variable and want to return posts that contain that string inside the meta_key `urls`. So far, the below _seems_ like it would be the most appropriate, but it's not returning values like I expected.               $search = '%' . $search . '%';     $args = array(         'meta_query' => array(             array(                 'key' => 'urls',                 'value' => $search,                 'compare' => 'LIKE',             )         )     );     $helpquery = new WP_Query($args);      Any ideas on making this work, or should I resort to a more direct `$wpdb` query? ## Update #1 I see this being marked as a duplicate, but my question is specifically regarding whether this can be done with the `meta_query` or not.


title: List of a specific Custom Post Type in Custom Template

text: My WP 3.6 has created a custom template using `register_post_type()` named `movie`. I inserted few `movie` via `Admin Dashboard > Movie`. For Permalink, I have set to Post Type, therefore, for example, `movie1` (instance of Custom Post Type `movie`), the URL is: > http://example.com/wordpress/movie/movie1 If I want to show a list of `movie` with link `http://example.com/wordpress/movie/`, which custom template file has to be created? I already have `single.php`, `single-movie.php` for displaying the `movie1`. But how about a list of `movie` ?


title: After Upgrade to Buddypress 1.2.6 from 1.2.5.2 , admin bar area displayed incorrectly for guest-visitors

text: I'm using WP 3.0.1 , and Buddypress 1.2.6 , Theme - Blogs-Mu theme (from WPMU DEV) I was using BP 1.2.5.2 , and the theme worked fine. I just upgraded to BP 1.2.6 , and now found a problem ... Hide admin bar for logged out users? is checked to Yes ... Now logged out user view a white space at the top (look in the image, a whitespace just below the addressbar) , if the admin bar visibility is turned on for guest visitors the admin bar is displayed instead of the white space .. http://img153.imageshack.us/img153/4278/whitespaceu.jpg While using it with BP 1.2.5.2 there was no such white space ? If any other information is need please gladly ask for it , i will try my level best to provide as much information possible , I just want this issue resolved .


title: Featured Image of Video from oembed

text: For Wordpress, I want to auto generate thumb of the video embedded on a page using oembed? And then save it as a featured image of the post. Any idea how to do this?


title: Title customize

text: I have a site of classifieds under Wordpress. I create a menu, and I fill with the cities. Each city call a .php file and show the ads for that city. I used Redirection Plug-in for convert the origal URL to a canonical URL The problem is what the title of page: (Example: http://etc.com/barcelona/) it´s always of the web. "Anuncios Clasificados" and I want what the name will Anuncios Barcelona How can I customize the title for each city? Thanks


title: Change the look of the media uploader

text: I have been trying to find out for a while now if there is a way to totally change the look of the pop up media uploader. How can I alter the content and the layout of that page? Which hooks should I use, and will that be forwards compatible?


title: Using predefined html in new posts

text:
I hope to make my life easy by doing this. I have 2 types of posts. On the first post I have a table and each post from the respective category will fill a table row. I will show you how a posts of mine looks like the following:
SA Spurs	     Miami Heat

     GAME MATCHUP
 // I have another table whitin a table row //
     2SAS	     vs	     1MIA
      .      .      .      .      .

      The table's head is predefined in the custom page template that's why I only use the in my posts. I was wondering if it is possible to have my tds/divs/p look like inputs in the post textarea that are predefined with the classes and respectives IDs so I would only type in new content everytime I want to add new content to the table. I've been looking into CPTs but I either didn't get it right or it cant be done with it. Other method I can think about is to hack the textarea displayed in my dashboard, but there's a drawback from this, I also have a 2nd post style and I dont know what to do. Hope I've been clear enough. Thanks for any help.


title: Decrease file size upload in Media

text: By default, I have a 2m limit of uploads. I want to decrease this number. I found out that this code:               function custom_file_max_upload_size( $file ) {         $size = $file['size'];         if ( $size > 1000 * 1024 ) {                 $file['error'] = __( 'ERROR: you cannot upload files larger than 1M', 'textdomain' );               }         return $file;     }     add_filter ( 'wp_handle_upload_prefilter', 'custom_file_max_upload_size', 10, 1 );      works by adding to functions. However, it does not update the upload size information when the user is on upload screen. It still displays `Maximum upload file size: 2MB`. How can I change that text to 1mb? Or alternatively, a different approach to decrease the file size (that does **not** include editing php.ini or htaccess...)


title: Multisite - Protect categories from deletion?

text: **UPDATE: For anyone following this thread, the plugin solution does work, but seems to have a problem on my multisite format. I have now tested on 3 individual installs and on 3 multisites. On the multisites, the red "undeletable" marker appears next to the categories in the array, but they can get deleted. This may well be down to a problem with my particular install, as it works properly with newly created subsites.** Original Post: Working on a multisite & would like a way to protect a couple of default categories from being deleted by site owners. I'm already using the "members" plugin to define admin roles, but the only option there is "manage categories", and if I disable that capability they can't delete categories, but they can't create new ones either. Any way to allow new categories but not to delete a few special ones??


title: Display post x of y within category

text:
I'm currently using this class in my single blog posts to get a total post count and number my posts (post 89 of 90, etc...)               class MY_Post_Numbers {          private $count = 0;     private $posts = array();          public function display_count() {         $this->init(); // prevent unnecessary queries         $id = get_the_ID();         echo sprintf( '
Post number%s/%s
', $this->posts[$id], $this->count );     }          private function init() {         if ( $this->count )             return;         global $wpdb;                $posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date " ); // can add or change order if you want          $this->count = count($posts);              foreach ( $posts as $key => $value ) {             $this->posts[$value] = $key + 1;         }         unset($posts);        }     }     $GLOBALS['my_post_numbers'] = new MY_Post_Numbers;     function my_post_number() {     $GLOBALS['my_post_numbers']->display_count();     }      I would like to make it category specific. Is that possible? So instead of 89 of 90 it will say 8 of 10 because it's only looking within that post's specific category.


title: How to query custom post type with 3 custom taxonomies linked to it

text: I'm new to WordPress but I would like to know how can one get a custom post type linked to 3 custom taxonomies. I have created a custom post type called "product" and created three custom taxonomies and linked them to the product post type. My aim is to make a product have category, brand and type..which are the three custom taxonomies I have created. Here is my `functions.php` file. My goal is to come up with something like this where "Ved" is the category name, "Stuv" is the brand name, and "Braskaminer" is the type name of the product and lastly "stuv 16 H", "Hwam 2630" etc. are the respective products. I will really appreciate if I can get some guidance on how I can use WordPress functions to achieve this.


title: How to add a span class in the post title?

text: I need to add a span class in the post title, something like this: ![See this picture \(a picture is worth a thousand words!\).](http://i47.tinypic.com/2hek0ev.png) How to do that? Is this possible?


title: Creating a rotating header /image slider using theme customization

text: So I'm learning WP and I want to create a rotating image slider for the header (like in this) using Theme Customization API. But I can't figure out how to and what setting should I use to take the images and store it for later animation in HTML/JS. Help?


title: Is there a flowchart for wordpress loading sequence?

text: So like wp must load series of files from, `index.php -> ... -> wp-header.php -> ... ->functions.php` ...and so on upon execution. Also there must be a similar flowchart for functions callings, conditionals and such _during_ the execution. Is such a flowchart(s) available anywhere?


title: How can I rewrite a URL to pass requests to a custom method via AJAX? (I can't use admin-ajax.php)

text: I have to build a WordPress plugin which gives out HTML for an AJAX call. However, because of the server environment I cannot use the traditional `admin-ajax.php`. Someone told me that I could build a custom page using url-rewrite ex: `/my- ajax-calls/` So when I send a request to that page it would be:               jQuery.get("/my-ajax-calls/param1/param2/",...);      Then I could use `param1` & `param2` and give the appropriate HTML. I know how to build plugins, how do I rewrite the URL to connect it with a method that generates the HTML?


title: My new WordPress blog keeps refreshing in Chrome browser

text: My new WordPress [blog]: http://wuyajun.info/ keeps refreshing in Chrome browser, gets loading error in Firefox, but works normal in IE. Plugins installed that may cause the problem: Facebook AWD All in One. Hope someone can help me on this, thank you. Nathan * * * Nov 15, 2011 update Just to clarify the refreshing problem was not due to PHP cache, for my situation. The function "Activate FB Connect" of WP plugin "Facebook AWD All in One" caused this problem. After I deactivates this function (NOT the whole plugin), this problem gets resolved. Hope this followup can help.


title: How do I display a list showing custom post types nested within a taxonomy?

text:
So I have a custom post type called `Video` and a taxonomy called `category` that I use to group videos togheter, so I want to list them like this:               Taxonomy NAME 1     VIDEO 1     VODEO 2          Taxonomy NAME 2     Video 1     Video 2      So I tried something but it doesn't work, the problem is that for each video I also display the taxonomy name like this:               Taxonomy Name 1     Video 1     Taxonomy Name 1     Video 2      So this is not what I want, mabe you guys can figure it out, what I do wrong:               <?php get_header();?>     <?php         $args = array( 'post_type' => 'Video');         $loop = new WP_Query( $args );     ?>     <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>             <?php $fg = get_the_terms(get_the_ID(),'category'); ?>             <?php foreach($fg as $term): ?>
<?php echo $term->name; ?>
                     <?php wp_reset_postdata(); ?>                     <?php                             $posts = new WP_Query(array('post_type' => 'Video', 'category' => $term->name) );                             while ( $posts->have_posts() ) : $posts->the_post();                                 the_post_thumbnail();                                 ?>                                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?>                                 <?php                             endwhile;                     ?>             <?php endforeach; ?>     <?php endwhile; ?>          <?php get_footer(); ?>      If someone can help please do it :( I can't get this


title: Rewriting URLs with Query Strings

text: I've been (unsuccessfully) attempting to prettify some URLs in a website I'm building in Wordpress, from something like this - http://www.ralphmackenzie.com/daviddalegallery/portfolios/exhibitions- events/?cpt_item=the-grantchester-pottery to something like this - http://www.ralphmackenzie.com/daviddalegallery/portfolios/exhibitions- events/the-grantchester-pottery After doing a good bit of reading (I'm a bit of a novice here, so bear with me if I've made any obvious mistakes) and I believe I should be rewriting the URLs through Wordpress. I've followed a very similar requirement through this - Prettified page URL w/ query var redirects to prettified page URL w/o query var \- but I just can't figure out where I'm going wrong. This is the code I have, and I've inserted this into my theme's functions.php file -               function setup_filter_rewrites()     {         add_rewrite_rule('portfolios/exhibitions-events/([^/]*)/?', 'index.php?pagename=portfolios/exhibitions-events&cpt_item=$matches[1]', 'top');     }     add_action( 'init', 'setup_filter_rewrites' );            function setup_filter_query_vars( $query_vars )     {         $query_vars[] = 'cpt_item';         return $query_vars;     }     add_filter( 'query_vars', 'setup_filter_query_vars' );        Again, my apologies if I'm missing something obvious here, though I have remembered to flush every time! Any help is greatly appreciated, and if you need any more info let me know.


title: What are the standard admin CSS id/class tags?

text: Is there a list of WordPress CSS id/classes that i can use to build plugin option screens that look and feel more like a normal WordPress option page? i have found some through serendipity but it would have been nice to ahve a list. An example is this class: button-primary That makes a button look like this: ![buttom-primary](http://i.stack.imgur.com/3onRu.png)


title: How can I make uploaded images in the editor load with HTTPS?

text: I have the admin section of my site using HTTPS. This works pretty well except that the images inside the TinyMCE editor (the post and page rich text editor) load with http instead of https and so I get an "insecure content" warning. I don't want to change the actual url of the image for front-end users; that is to say when someone visits the blog post normally I want the image to load with plain HTTP. But when I'm editing it should be loaded with HTTPS. How can I do that?


title: Making my AJAX powered WordPress Crawlable

text: I read the following and try to apply this scheme to my website running WordPress: http://code.google.com/intl/fr-CA/web/ajaxcrawling/index.html If you visit my website at http://www.visualise.ca/ you will see that it loads the posts within the home page and the url becomes http://visualise.ca/#!/anne-au-cherry when this post is loaded. A static version of the same content is available for the crawler at http://visualise.ca/anne-au-cherry but if a visitor using a browser visits it he will be redirected to http://visualise.ca/#!/anne-au-cherry (this is done with javascript). In order to provide the crawler with the needed `?_escaped_fragment_=` I used a WordPress hack I've found on the net: http://www.wordpress- fr.net/support/sujet-54810-add-action-parse-request and now the GoogleBot can see the content of my AJAX powered pages. I thought it was all done. But when I paste a post link to Facebook (i.e.) it is unable to read the content of the page so I guessed that my website isn't really respecting the scheme described in the Google documentation since Facebook is supporting it (If you paste http://twitter.com/#!/gablabelle it will work). So since I'm using the jQuery.address plugin to get my hashbang (#!) I went to their website and downloaded their sample files to see what were the differences between their files and mine and realized that they were probably using a php function to create the needed HTML snapshots: https://github.com/bartaz/jquery- address/blob/master/samples/crawling/index.php because this is why, I guess, Facebook can't read mine.               <?php              error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));              $fragment = $_REQUEST['_escaped_fragment_'];         $file = 'data/' . (isset($fragment) && $fragment != '' && $fragment != '/' ? preg_replace('/\//', '', $fragment) : 'home') . '.xml';         $re = '/(^<[^>]*>)|(\n|\r\n|\t|\s{2,4})*/';              $handle = fopen($file, 'r');         if ($handle != false) {             $content = preg_replace($re, '', fread($handle, filesize($file)));             fclose($handle);         } else {          $content = 'Page not found!';             header(php_sapi_name() == 'cgi' ? 'Status: 404' : 'HTTP/1.1 404');         }          ?>      So my guess is that I could maybe use a similar php function to serv the HTML snapshots instead of using the WordPress hack but I would need to adapt it to WordPress. The problem is that I'm no programmer and I did my best so far. My post are in this format: http://visualise.ca/#!/anne-au-cherry and the static version is available at http://visualise.ca/anne-au-cherry (Where anne- au-cherry is the slug of the post and changes depending on the page we are viewing). So my question is could someone confirm that I'm on the right path and if possible also help creating that php function? Many thanks for your time and help!


title: Loop custom post type by taxonomy (Category)

text: I created a custom post type in my function.php of the theme and some a taxonomy for them. I added 2 categories in my taxonomy (first, second) and added some post in my new custom post. I want to make a loop that will select from my custom posts only the ones in the first category (Taxonomy) Or I want a archive that will display all my custom posts, but separated by the taxonomy like First category: one post, another post Second Category: this post, next post


title: Modify functions.php to add a term 'uses-theme' set to theme name on post save

text: I need to automatically (without anything visible to the user in the UI and without user intervention) 'mark' a post in a sub-blog with the theme it was set to when the user posted. As I understand it I have to use `wp_insert_term()` once to insert this new term 'uses-theme' into the terms table in the database. Then I have to add an action containing `wp_set_post_terms()` (with the value of `get_current_theme()`), to some core function that is executed when a post is created or saved. I don't have access to the core .php files, so I'm looking for some way of adding this to the **functions.php**. If it's easier to automatically **tag** or **categorize** , I will do that. I just don't know how to hook it in. **UPDATE:** I just realized I get the blogid in the post meta. If I could look up the stylesheet_directory or similar "bloginfo" field from the database, the problem would be solved. But I'm looking at the blogs table, and it doesn't have those bloginfo fields - and get_bloginfo() only returns info about the CURRENT blog. If I knew how to look up stylesheet information from the blog id, I would be home! **How?**


title: Only make custom image size if uploaded via Thickbox and attached to certain page

text: I am trying to make it so that WP will create another size image for me, but only when the image is uploaded via the Thickbox, and only when it will be attached to a certain ID. Does anybody know how to do this? The following works, but will create an image of that size for every upload, which is just inefficient.               add_action('after_setup_theme', 'set_image_upload_size');     function set_image_upload_size(){              if(!{is Thickbox upload} || !{is attached to page 6838}) : // Don't know how to check this...             return false;         endif;              /** Add an upload size for the footer images */         add_image_size('footer-logo', 60, 40, false);          }


title: Does WP read itself?

text: I was looking at my server logs and I saw something strange. Every day, sometimes multiple times a day, I see a sequence of hits like this: > 67.210.126.90 - - [17/Dec/2012:04:36:09 -0800] "GET /blogs/about/ HTTP/1.0" > 200 18075 "-" "WordPress/3.5; [my blog URL]" > > 67.210.126.90 - - [17/Dec/2012:04:36:11 -0800] "GET /blogs/3/a-star-is-born/ > HTTP/1.0" 200 13301 "-" "WordPress/3.5; [my blog URL]" > > 67.210.126.90 - - [17/Dec/2012:04:36:12 -0800] "GET > /blogs/8/107655531126398381/ HTTP/1.0" 200 9462 "-" "WordPress/3.5; [my blog > URL]" > > 67.210.126.90 - - [17/Dec/2012:04:36:14 -0800] "GET > /blogs/9/107659020500242493/ HTTP/1.0" 200 9715 "-" "WordPress/3.5; [my blog > URL]" > > ... > > 67.210.126.90 - - [17/Dec/2012:11:38:52 -0800] "GET /blogs/17493/bonus/ > HTTP/1.0" 200 13671 "-" "WordPress/3.5; [my blog URL]" > > 67.210.126.90 - - [17/Dec/2012:11:38:53 -0800] "GET /blogs/17496/monday-cat- > blogging-367/ HTTP/1.0" 200 10019 "-" "WordPress/3.5; [my blog URL]" > > 67.210.126.90 - - [17/Dec/2012:11:38:55 -0800] "GET /blogs/17497/start-your- > ipods-363/ HTTP/1.0" 200 10418 "-" "WordPress/3.5; [my blog URL]" That is, something on 67.210.126.90 (which is nasa.lunarpages.com, the server where the blog is hosted) is fetching every single blog post I've ever made, in order. I assume Wordpress is doing this, but I've searched for hours and couldn't find any info about why Wordpress would do that (or even if Wordpress does that at all). It doesn't make a lot of sense that Wordpress would do that - it can just read the posts from the DB, after all, it doesn't need to render them. But as far as I know, I'm not running anything else on my account. But, if it's not Wordpress, I'm truly stumped. I have no idea what else on the hosting server would be doing a GET on all pages. Anyone ever seen anything like this?


title: Getting admin notices working for plugin errors

text: I'm beginning with creating plugins and I don't quite understand the process of displaying error messages. e.g. I use the php readfile function to download a file from a hidden location. If something goes wrong e.g. the file isn't found, how do you display a message **at that moment**. I know you need to use add_action for 'admin_notices' but I can't quite figure out where you are supposed to put the add_action calls. As far as I can tell, you have to create a function my_download_file which tries the download and echo's a `<div class="error">`. Then 'somewhere' you need to call `add_action('admin_notices', 'my_download file');`. This, from reading the Action Reference, then gets called when admin_notices are being printed out. But does it always get called, or does it only get called when do_action gets called?


title: Importing posts in custom post type into new website

text: I have two wordpress installs. One in root directory and other in subdirectory of the same domain. I want to transfer posts of subdirectory **into a custom post type of main site**. Post of subdirectory (to be transferred) have several taxonomies so should I import and transfer taxonomies first? If yes then how to? and do all this transfer?


title: Query WP data with the WPDB API from outside WordPress

text: I'm working on a project with WP, a bit like a plugin, but not quite one. I'm encountering an issue, when trying to include a file that contains some custom SQL functions in a class, in a completely different file, I get redirected to `http://example.com/folder1/file.php/wp-admin/install.php` Which states that I've already installed WP and I need to uninstall it before I can install it again.. But I'm not trying to install/re-install WP. ^ That sounds kinda complicated, let me give an example: I have `file1.php` and `file2.php`. `file1.php` contains many SQL functions that I wrote to access the DB which WP uses. And `file2.php` contains a class that includes `file1.php`, so I can use some of the SQL functions in the class. Now, I first tested it with calling some SQL functions (`from file1.php`) in the class and came across this issue. After some debugging (removing lines, one by one), the issue was the line that includes `file1.php` (the file with all the SQL functions in it) So for some reason, everytime I include `file1.php` in `file2.php` I get redirected to: `http://example.com/folder1/file2.php/wp-admin/install.php` Any ideas why this is happening and how I can fix it? **Forgot to mention something:** `file1.php` (with all the SQL functions) does include `wp-config.php` to get the DB info, which could be related to this issue, right?


title: Extend the list of MIME-types supported by the builtin uploader in 3.3

text: # Goal I want to be able to extend the list of mime-types supported by the builtin uploader in wp 3.3.1 For example when I try to upload an .apk file to our class blog, I get a `Sorry, this file type is not permitted for security reasons.` error. # Question In 3.3 has there been any changes to the way the file type whitelist is managed that is causing me not to be able to fix this? # Already tried Activating wp codex and going to the Network Admin Settings page, adding to the Upload file types. That doesn't work, no change. Also I have tried the 'upload_mimes' method by adding the code to functions.php. That doesn't work, no change. And lastly I have tried the PJW Mime Config which doesn't even work for the examples the user provided. Granted this plugin was last edited in 2009


title: Working with get_posts parameters/arrays/strings

text:
I'm transitioning all my query_posts queries to get_posts after a lot of research about how bad it is for performance. My solution is get_posts but working with it is confusing me. Here is what I have:                   $posts = get_posts('showposts=-1&offest=10&post_type=any');                 foreach ($posts as $post) :                     ?>
                         <a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
                         <?php if (has_post_thumbnail()) {                             the_post_thumbnail('thumbnail');                         }?>                         <?php the_content();?>
<?php endforeach; ?>      It works but some of the params don't, such as offset and "any" post type is to vague.               $posts = get_posts('showposts=-1&offest=10&post_type=any');      The codex tells us that we can also use an array:               $query = new WP_Query( array( 'post_type' => array( 'post', 'page', 'movie', 'book' ) ) );      But this is a common problem I don't know how to handle. How do I get dynamic parameters into the array, or where can I find the rules for parameters in string format like my code?


title: wp-admin page is blank

text:
Something is wrong with my wp-admin page, it just shows up blank. I am pretty sure it has to do with my function.php file there is no whitespace on the top or bottom, but when I delete it completely, the wp-admin folder works again. here is the functions.php file               <?php          add_action("manage_posts_custom_column",  "booktime_custom_columns");     add_filter("manage_edit-booktime_columns", "booktime_edit_columns");          function booktime_custom_columns($column){         global $post;              switch ($column) {             case "name":                 the_excerpt();             break;             case "address":                 $custom = get_post_custom();                 echo $custom["address"][0];             break;             case "phone":                 $custom = get_post_custom();                 echo $custom["phone"][0];             break;             case "date":                 $custom = get_post_custom();                 echo $custom["date"][0];             break;             case "bottles":                 $custom = get_post_custom();                 echo $custom["bottles"][0];             break;              }     }          function booktime_edit_columns($columns){         $columns = array(             "cb" => "<input type=\"checkbox\" />",             "title" => "Post should show",             "description" => "name",             "address" => "address",             "phone" => "phone",             "date" => "date",             "bottles" => "bottles"         );              return $columns;     }          ?>          <?php     add_action("admin_init", "admin_init_booktime");          function admin_init_booktime(){              add_meta_box("name", "name", "name", "booktime", "normal", "low");          }     ?>          <?php     function name() {         global $post;         $custom = get_post_custom($post->ID);         $name = ( !empty($custom["name"][0]) ) ? $custom["name"][0]: "";         ?>
Name:
             <input type="text" name="name" value="<?php echo $name; ?>"/>
         <?php     }     ?>          <?php     add_action('save_post', 'save_details_booktime');          function save_details_booktime(){         global $post;         $custom_meta_fields = array( 'name' );              foreach( $custom_meta_fields as $custom_meta_field ):             if(isset($_POST[$custom_meta_field]) && $_POST[$custom_meta_field] != ""):                 update_post_meta($post->ID, $custom_meta_field, $_POST[$custom_meta_field]);             endif;         endforeach;          }     ?>      EDIT: I turned wp-config debug on and I get the following               Parse error: syntax error, unexpected '<' in /Users/anderskitson/Sites/fiftyfity/wp-content/themes/fiftyfityNew/functions.php on line 61


title: Any Facebook component doesn't work on Wordpress website after update. Why?

text: I have a problem after updating plugins and `Wordpress`. All my Facebook widgets that I have been using disappeared. In code I see:                   <fb:like href='http://facebook.com/...' send='false' layout='standard' show_faces='false' width='200' height='65' action='like' colorscheme='light' font='lucida grande'></fb:like>      and the script:                   <script type="text/javascript">       window.fbAsyncInit = function() {     FB.init({"appId":"...","channelUrl":"http:\/\/...\/?sfc-channel-file=1","status":true,"cookie":true,"xfbml":true,"oauth":true});       };      (function(d){        var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}        js = d.createElement('script'); js.id = id; js.async = true;        js.src = "//connect.facebook.net/pl_PL/all.js";        d.getElementsByTagName('head')[0].appendChild(js);      }(document));          </script>     <script type="text/javascript">         (function() {             var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');                  request = true;                  b[c] = b[c].replace( rcs, ' ' );             b[c] += ( window.postMessage && request ? ' ' : ' no-' ) + cs;         }());     </script>      Is there anything missing? What could be changed during update? If you need a full code.


title: Add Standard Page Attributes Metabox for Page Parent

text:
I have a custom post type 'product' supplied to me by a Wordpress eCommerce plugin that does not offer the option to change the Page Parent in the Page Attributes Metabox. I'd like to remedy that. I found this post on Wordpress StackExchange, but it deals specifically with the Page Template element of the Page Attributes Metabox. Can anyone extrapolate on the very good answer provided in this other WSE question to suit my purposes? It can even include all the Page Attributes Metabox options. It doesn't have to be stripped down to Page Parent. But Page Parent is the one I need. * * * Edit #2: Here is what I have so far. The metabox shows up with the appropriate drop down, but I can't save the parent_id. It seems like the admin/post.php page isn't catching the $_POST['parent_id'] variable. Is there some feature of Wordpress that doesn't allow non-hierarchical custom post types to have parent ids? Or should I be looking somewhere in the Woocommerce code?                   function product_attributes_meta_box($post) {             $dropdown_args = array(                 'post_type'        => 'page',                 'exclude_tree'     => $post->ID,                 'selected'         => $post->post_parent,                 'name'             => 'parent_id',                 'show_option_none' => __('(no parent)'),                 'sort_column'      => 'menu_order, post_title',                 'echo'             => 0,                 'child_of'         => 282, // Sales Page             );                  $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post );             $pages = wp_dropdown_pages( $dropdown_args );             if ( ! empty($pages) ) {     ?>
<?php _e('Parent') ?>
     <?php _e('Parent') ?>     <?php echo $pages; ?>     <?php             } // end empty pages check         }         add_action('add_meta_boxes','add_post_template_metabox');         function add_post_template_metabox() {             add_meta_box('postparentdiv', __('Page Parent'), 'product_attributes_meta_box', 'product', 'side', 'core');         }         add_action('save_post','save_post_parent',10,2);         function save_post_parent($post_id,$post) {           if ($post->post_type=='product' && !empty($_POST['parent_id'])           ) {             update_post_meta($post->ID,'_parent_id',$_POST['parent_id']);           }         }      * * * Edit #3: I changed the custom post type 'product' to `hierarchical => true` but the post.php page is still not catching the $_POST['parent_id'] variable. I also tried commenting out `remove_meta_box( 'pageparentdiv', 'product', 'side' );` in the woocommerce.php file and removing ALL of my custom code above, but the Parent Page is still not being saved.


title: How come my first blog post and my home page have the same title?

text: I am putting together a new blog and for some reason the home page took the title and description of the initial post. Is there a way to just set the home page title/description separately? I am trying to edit it via YoastSEO, but I get this screen when I try to set my Home title/description: ![enter image description here](http://i.stack.imgur.com/TQ2wp.png) But what I was expecting was the form fields for title/description. Thank you!


title: Wordpress multiple widget in single plugin

text:
In my plugin in need to create two widget. One is :social rank" another is "Profile Rank". This is the code which i am using here.                   <?php         add_action( 'widgets_init', 'src_load_widgets' );          function src_load_widgets() {         register_widget( 'Widget_SRC' );     }     function src_load_widgets() {         register_widget( 'Widget_Rank ' );     }          class Widget_SRC extends WP_Widget {              function Widget_SRC() {                  $widget_ops = array( 'classname' => 'src', 'description' => __('Several social networks counts and ranking system', 'src') );                    $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'social-rank' );                     $this->WP_Widget( 'social-rank', __('Social Rank', 'src'), $widget_ops, $control_ops );         }                   function widget( $args, $instance ) {             extract( $args );                $title = apply_filters('widget_title', $instance['title'] );                 echo $before_widget;                  if ( $title )                 echo $before_title . $title . $after_title;                  echo do_shortcode('[SocialRank]');                        echo $after_widget;         }              function update( $new_instance, $old_instance ) {             $instance = $old_instance;                  $instance['title'] = strip_tags( $new_instance['title'] );             return $instance;         }              function form( $instance ) {                  $defaults = array( 'title' => __('Social Rank', 'src'));             $instance = wp_parse_args( (array) $instance, $defaults ); ?>
                 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'hybrid'); ?>                 <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
                      <?php         }     }             class Widget_Rank extends WP_Widget {                      /**                  * Widget setup.                  */                 function Widget_Rank() {                     /* Widget settings. */                     $widget_ops = array( 'classname' => 'rank', 'description' => __('Display profile rank based on vote & social counts.', 'rank') );                          /* Widget control settings. */                     $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'profile-rank' );                          /* Create the widget. */                     $this->WP_Widget( 'profile-rank', __('Profile Rank', 'rank'), $widget_ops, $control_ops );                 }                      /**                  * How to display the widget on the screen.                  */                 function widget( $args, $instance ) {                     extract( $args );                          /* Our variables from the widget settings. */                     $title = apply_filters('widget_title', $instance['title'] );                          /* Before widget (defined by themes). */                     echo $before_widget;                          /* Display the widget title if one was input (before and after defined by themes). */                     if ( $title )                         echo $before_title . $title . $after_title;                          echo do_shortcode('[SocialRank]');                          /* After widget (defined by themes). */                     echo $after_widget;                 }                      /**                  * Update the widget settings.                  */                 function update( $new_instance, $old_instance ) {                     $instance = $old_instance;                          /* Strip tags for title and name to remove HTML (important for text inputs). */                     $instance['title'] = strip_tags( $new_instance['title'] );                     return $instance;                 }                      /**                  * Displays the widget settings controls on the widget panel.                  * Make use of the get_field_id() and get_field_name() function                  * when creating your form elements. This handles the confusing stuff.                  */                 function form( $instance ) {                          /* Set up some default widget settings. */                     $defaults = array( 'title' => __('Profile Rank', 'rank'));                     $instance = wp_parse_args( (array) $instance, $defaults ); ?>
                         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'hybrid'); ?>                         <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
                              <?php                 }             }              ?>      But it is not displaying me second widget. I have found this but not able to get how to solve it http://stackoverflow.com/questions/5247302/php- namespace-5-3-and-wordpress-widget/5247436#5247436


title: Set tax_query conditionally with new WP_Query

text: I have a page template with a custom query:               <?     $filter = explode(' ', $_GET['filter']); // "page/?filter=taxonomy+term"     $paged = get_query_var('paged') ? get_query_var('paged') : 1;          $query = new WP_Query(array(       'post_type' => 'articles',       'paged' => $paged,       'tax_query' => array(         array(           'taxonomy' => $filter[0],           'terms' => $filter[1],           'field' => 'slug'         )        )     ));      This works fine but when there are no filters I don't want to query the taxonomy, so I thought of doing this:               $query = new WP_Query(array(       'post_type' => 'articles',       'paged' => $paged,     ));          if (! empty($filter[0])) {       $query->set('tax_query', array(         array(           'taxonomy' => $filter[0],           'terms' => $filter[1],           'field' => 'slug'         )       ));     }      But it doesn't work like it did before, when there are no filters it shows nothing and when there's any filter it just shows everything. So I'm guessing the taxonomy is not getting set in the query. What am I doing wrong?


title: Order posts by date

text: I'm a girl and excuse my English. Maybe its easy and I'm dumb to know it. But here is the problem I want to output on the homepage the posts from the lastest 3 days. Like this:               30/03/12      post 1 post 2 post 3               29/03/12      post 1 post 2 post 3               28/03/12      post 1 post 2 post 3 I tried:               $loopday = '';     if ( have_posts() ) : while ( have_posts() ) : the_post();       if ($loopday !== get_the_time('D M j')) {         $loopday = get_the_time('D M j');         echo $loopday;       }       the_title();       the_content();     endwhile; endif;      But this code only orders the latest 10 posts. For example: On 30/03/12 I have 5 posts On 29/03/12 I have 4 posts On 28/03/12 I have 3 posts So the 3rd day is missing now 2 posts. Also I want to use this on the archive page. 3 days a page. On page 2 the next 3 days. I'm really hopeless.. xx


title: Any way to include custom fields in WP_Query results?

text: Looking for a way to include custom fields in the output of WP_Query. I am managing a site where nearly every post type has a lot of custom fields defined and it would be much nicer not to have to run get_post_custom in almost every loop.


title: HTTPS page link in menu

text: Ok, so I have a wordpress site with a lot of pages and menus that I've defined in the appearance/menus section of wordpress. One of my pages has a little payment form on, which I'd like to link to with https://blahlbah.com/thepage.. and for all the other pages I'd like them to remain as http. Even if I set an absolute link to the https page all the other pages being relative links become https also after you visit that page. Is there a plugin or a hack or something to just specify that one page as https? Cheers, John.


title: How do I edit wp_head and/or functions.php to remove rss-feed which isnt used and dont validate?

text: When using w3.org's validation tool Unicorn I get the following error/warning: URI: http://energyshop.se/hem/feed/ This feed does not validate. After looking into my source its there crystal clear in the `<head>: <link rel="alternate" type="application/rss+xml" title="energyshop.se » Hem kommentarsflöde" href="http://energyshop.se/hem/feed/" />` Now, how do I remove this feed since I dont use it? Thanks in advance!


title: Share users across multiple sites on same database, but with different domains

text: I am trying to implement a single sign-on solution between a Wordpress and a non-WP site, under different domains. I am aiming to setup a ghost WP install on the non_WP site domain, to be able to load WP in the background, and facilitate cross-domain cookie sharing and authentication Basically I have setup a fresh install of WP, using the database of my original WP site, and I would like to share the users.


title: Is it possible to load wp-content/uploads from another server?

text: I just recently moved to my new CentOS server and I did a fresh installed and before I use to be with my Mac OS [Xserver] So what happen I was thinking about CDN and though that maybe this will somehow apply to some of the condition where it will make my site load faster because this is from another server. How or is it even possible for me to get the wp-content/uploads from another server?


title: Help with custom post type and custom taxonomy issue with rewrites

text: so I have this custom post type and taxonomy which i set the rewrite to books because I want the URL to the specific book to be http://domain.com/books/booktitle So this is what I have so far:               $args = array(       'labels' => $labels,       'public' => true,       'publicly_queryable' => true,       'exclude_from_search' => false,       'show_ui' => true,        'show_in_nav_menus' => true,       'query_var' => true,       'show_in_admin_bar' => false,       'capability_type' => 'post',       'has_archive' => true,        'hierarchical' => false,       'menu_icon' => get_template_directory_uri() . '/images/books16x16.png',       'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),       'rewrite' => array( 'slug' => __( 'books', 'xxr' ) ),       'taxonomies' => array( 'book-cats' )     );      register_post_type( 'books', $args );          register_taxonomy( 'book-cats',          array( 'books' ),          array(  'hierarchical' => false,          'labels' => $labels,          'query_var' => true )          );      Ok so the CPT works and everything is ok in the backend. However in the front end, I am not able to go to the specific book that I created. For example, I created a book title Nomo, so I type http://domain.com/books/nomo but it goes to page not found. An even more strange finding is I have a custom query that pulls all the CPT on my homepage and it does show everything just fine. But if you however over the book link, it gives a URL of http://domain.com/uncategorized/nomo ??? I am puzzled...Why would it say uncategorized when a category is set for this? My permalinks are set to /%category%/%postname%/ if that means anything and yes I have refreshed the permalinks already and still same issue. NOTE: It used to work...not sure what happened... Any help appreciated.


title: How to add a specific div element to the first post in a row?

text:
I was asking how to add a custom div element to the latest recent post that was uploaded. How can I do this? My code:
                     <?php                          $args = array('post_type' => 'portfolio', 'posts_per_page' => -1, 'paged' => $paged);                         $loop = new WP_Query($args);                         $count = 0;                     ?>                          <?php if ($loop) : while ($loop->have_posts()) : $loop->the_post(); ?>
                          <?php if ($count == 1) echo '
NEW
'; ?>                          <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">                                                      <?php the_post_thumbnail('thumbnail-portfolio'); ?>
<?php the_title(); ?>

<?php the_excerpt(); ?>

                     <?php endwhile; ?>                     <?php else : ?>
No portfolio items were found! I'm not sure what you're looking for.
                     <?php endif; ?>                     <?php wp_reset_query(); ?>
      I have tried it with: `<?php if ($count == 1) echo '<div class="newest">NEW</div>'; ?>` But this is not working. Hope someone has a solution!


title: Disable wordpress comments API

text: We're using the disqus plugin on our wordpress site, so anyone commenting should have a login through disqus. Yet, I'm still seeing spammers trying to post through the regular comments API. They're not getting through to the post, but they're clogging my inbox as admin. How do I disable this API - I only want to accept comments that come from a logged in Disqus user?


title: Changing the wp db prefix after installation?

text: I have nearly completed a project but forgot in the first place to change the wp_ db prefix on install. Now i am a little bit worried to change it afterwards in fear of breaking the whole installation. Therefor the question if these described methods still work with 3.8.x or has anything change since then? http://www.wpbeginner.com/wp-tutorials/how-to-change-the-wordpress-database- prefix-to-improve-security/ http://digwp.com/2010/10/change-database-prefix/ and have only table and field names to be changed? cuz i also saw a few prefixes starting with _wp_ instead of wp_ ? Best regards Ralf


title: broken permalinks in responsive layout

text: In full view (when I can see all items in the top menu) my url to pages works well - the url is mypage.com/mysite. When I resize my window so I can see the drop-down top menu for pages, or see my page in my cell phone the pages links are broken. The links to my pages now does not contain page name but page id - mypage.com/111. Why would the behavior be different? This is very strange for me…. My hosting is on newarlyfreespeech. I have added .htaccess with correct premissions and save several times. I see that after saving permlink settings the file changes. .htaccess is located in the root of my wordpress install. Running WP 3.5.1 + theme should be also compatible with 3.5.1. Any help more than appreciated.


title: How should I store a log for my plugin

text: I have a plugin that sends data to a server as part of a `transition_post_status` action. The server sends a response each time. I want to keep a log of these responses (permanently) that I can display in a table to the user somewhere, like so:               Date | Response     ------------------     1/1  | OK     1/2  | Status code 2      What's the best way to do this? Should I create a new database table, or is there a more convenient way? Some background: I've tried using the WP_Logging() class, but it doesn't seem to work correctly when called through an action.


title: Menu capability in Wordpress

text: Is it possible to specify two usergroups (e.g. admins and editors) into the admin menu capability field ? I tried the following but it doesnt work:               add_submenu_page(          'my-top-level-handle',          'Page title',          'Sub-menu title',           array('administrator', 'editor'),          'my-submenu-handle',          'my_magic_function'     );      error message: Warning: Illegal offset type in isset or empty in C:\wamp\www\wordpress\wp- includes\capabilities.php on line 712


title: Listing the most popular 8 city (custom fields) as used in posts

text: Hi there i am creating a theme for a classifieds website and want to list the top 8 popular city which mentioned as posts custom fields. That means the top 8 cities which have the most classifieds. it will looks like this http://i50.tinypic.com/6f7fww.png i saw some examples of sorting custom fields but couldn't manage to make it work properly.


I'm customizing the WordPress registration form, and I need to display an list of options from a select on form submission. I was using the following code to capture the selected option of the select:               <option value="Medicine" id="option-1" <?php if($_POST['name_of_select']=='Medicine') {?> selected="selected" <?Php } ?>>Medicine</option>      Here's a jQuery code to generate the list:               function list(array_list) {              $("#formOptions").html(""); //reset child options         $(array_list).each(function (i) { //populate child options             $("#formOptions").append("<option value=\""+array_list[i].value+"\">"+array_list[i].display+"</option>");         });          }      And the options of list:               var Option 1 = [         {display: "Medicine", value: "Medicine" }];      Since the list is loaded according to another option previously selected. Now I'm using jQuery to generate the list of options select field. But when user send a form, the value of the selected option does not sent. The option is sent blank. My question is: How do I capture the selected option and pass in sending the registration form? I appreciate any tip


title: Get post only from 'standard' post format

text: I use the following codes to get posts **only** from ' **image** ' post format and it works.               <?php if( has_post_format('image')){ ?>        <?php the_post_thumbnail(); ?>     <?php } ?>      I also need to get posts **only** from ' **standard** ' post format with the following codes, but it get post from all post formats.                <?php if( has_post_format('standard')){ ?>          <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?>      <?php } ?>      Any solutions?


title: Is there a way to share a template/markup with the JSON API so that it doesn't need to be declared both in PHP and in JS?

text: **Current Setup** I'm using WP's JSON API on a custom post type archive to query some posts. I then parse the returned JSON object to output my markup accordingly. I also have a single post type template for when JSON isn't available (JS turned off etc.) Currently this means I'm declaring my markup in two places;once in the JS function that renders the JSON output, and again in the single post template. **What I'd to Achieve** While the above approach works, I'd like to find a way to declare the markup in one location only; this will make maintenance and alterations easier easier, and **avoid me having to put markup into my JS.** I've read this post and had a look at `wp_localize_script` but I gather that let's you pass PHP _variables,_ not the actual PHP itself. I had thought I could write all the markup _as_ an array, but that seems a tad cumbersome, and seems at odds with keeping the concept of templating in general. Is there a smarter way of doing this? Perhaps some way of programatically reading the markup and turning it into an array? **Update** I may have found an answer using `get_template_part()` and Handlebars.js, so if there are no other good answers I may post and then accept it.


Some way to Flush or Overwrite all Imported Content in a Site for a Fresh Import - How?   * Is there an easy quick way to do this? To delete all Pages, Posts, Comments and stuff that got imported?    * Or some way to force a FLUSH of the information when I import a new .XML?    * I've imported a bunch of wrong content into several sites    * I would like to give them a FRESH start, preferably without having to Re-Create Fresh Sites on Multisite WP 3.5.1 Network   * Make it go back to the state when a Fresh New Site was created With relation to other links I've read:   * Import and replace existing page/post content   * Can I overwrite existing posts with Import tool?   * How do I re-import overwriting all posts/comments?   * Wordpress Import Function   * Import and replace existing page/post content   * Is there a way to trigger an automatic import of a WP backup on creation of a new WP multisite site? I haven't gotten a conclusive answer here. Not even when I put together all the LEARNING from the links I've read (posted). **Is there a way to combine all the above knowledge to create solution steps for this?** **Shouldn't there be a Plugin, Script or some Tool in the Wordpress Admin/ Developer's Tool chest to do this sometime when needed?** **Is there something like this out there?**


title: Quirky behavior in multi-server environment

text: I have a wordpress setup running in AWS on a handful of EC2 instances. Each instance is identical, all pointing to the same shared RDS instance (database). I had to do some S3 bucket mounting magic to get media uploads working and shared across servers in real-time, which was fine. But I'm seeing some other weird behavior.   1. While editing a post, hit preview --> redirected to homepage   2. Open blog, type in search term, hit enter --> redirected to homepage Both issue are intermittent, sometimes they work, sometimes they fail. The only pattern seems to be the load balancer configuration. If it round-robins, then failures are intermittent. It I turn on sticky sessions (you hit the same server for a period of time), no failures occur. Thus, I believe that load a paging from ServerA, and then posting to ServerB, results in a failure that redirects you to the homepage. I have looked through the wordpress and nginx error logs, and not seen anything interesting. Does wordpress do some sort of server-state dependent nonce/xss protection that could cause these sorts of issues? Other ideas?


title: get_posts seems to be skipping the last Post

text: I have custom post type (Events) with 6 events.               $posts = get_posts( array('post_type' => 'events') );     echo '<!-- ';     print_r($posts);     echo ' -->';      This code shows the 5 with the most recent published date. I should perhaps note that we have been changing the published date as a hacky sort of way to change the post display order. I'm not sure when the event started being omitted, or if this is related, but there it is. Does anyone have any insight as to why this kind of thing would happen? Thanks.


title: Ninja Forms - pull in some post related information

text: I am building a real estate website. There is a custom post type, called "Agents", that holds all the contact info, like the email address. I also have a custom post type called "Properties" where you can choose the agent who is in charge of it. On the property detail page, there is a Ninja Contact Form. I need to pull the agents email address into that form to overwrite the Administrator Email Address that was put in, in the form settings. Does that make sense to someone? $agent_email depends on $post->ID the agent email address need to be included in ninja_forms_form_2, overwriting the administrator email from form settings. Is there anyone out there who can start working on this with me? On my own, I am lost. I can provide more information if needed. Thanks to all. Mark


title: Is it a good idea to rename the "index.php" in "wp-admin" folder to avoid being hacked?

text: My wordpress has been hacked for 2 or 3 times. How can I increase its security? Is it a good way to rename the `index.php` in `wp-admin` directory?


title: What's the easiest way to stop WP from ever logging me out

text: After a certain amount of time WP logs out all users and forces them to log back in again. For development environments on my local machine this is obnoxious and absolutely unnecessary. Is there an API-driven way of disabling the auto-logout indefinitely? Ideally I'd like something I can add to `wp-config.php` along with other dev-setup- related settings. A plugin would be overkill for me so I won't consider it an answer, but you might as well post it as an option.


title: Conditional Custom Image Header

text: I thought there was a conditional for a custom image header that could check whether an image had been added (not whether the feature was enabled, but actually being used). I wanted to use it to add a body class, but I can't find it again. Does anyone know of how to check if the site has a custom header?


title: Online Payment System for a Conference

text: I need to create an online registration form for a conference. It should accept credit card payments. Is WP e-Commerce suitable for this? Thank you.


title: How do I remove 'Home' from homepage title?

text: On the site I am working on, currently page titles have this format:               Page title | Site name      This is fine, but I want the Page title removed from the homepage, as the Google search result for the homepage has 'Home' in it. So how do I change the title for just the homepage, from...               Home | Site name      to..               Site name      ? This is the relevant part in `header.php`:               <title><?php                       global $page, $paged;                  wp_title( '|', true, 'right' );                  // Add the blog name.             bloginfo( 'name' );                  // Add the blog description for the home/front page.             $site_description = get_bloginfo( 'description', 'display' );             if ( $site_description && ( is_home() || is_front_page() ) )                     echo " | $site_description";                  // Add a page number if necessary:             if ( $paged >= 2 || $page >= 2 )                     echo ' | ' . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) );                  ?></title>


title: meta_query dates from an array

text: I have the below query which isn't returning anything. The query is meant to look for the date (2014-03-01) that is in the array, which it is. Any ideas? Or would I need to use a custom SQL query?               // the income_dates array looks like this     // a:3:{i:0;s:10:"2014-02-01";i:1;s:10:"2014-03-01";i:2;s:10:"2014-03-29";}          $args = array(         'post_type' => 'income',         'meta_query' => array(              array(                 'key' => 'income_dates',                 'value' => "2014-02-01",                 'type'  => 'date',                 'compare' => 'IN'             ),         )     );


title: generate custom style css file

text: I am creating a theme and working on custom css part to be generated (created) a custom css file for it. for example, when users setup fonts, there will be created a custom css file in a specific folder. the file looks like this "custom-font-css-103838.css" Is there anybody knows how to create css file? ps) if my question is not fit here, I will remove it. thanks.


title: I am trying to get metabox image with custom size

text: I am trying to get meta box image with custom image size. i used this code to get image but image is not displaying.               <?php         $img_src = get_post_meta( $post->ID, 'project_options', true );         $img_src = wp_get_attachment_image_src($img_src, 'size_300_190');     ?>          <img src="<?php $img_src['mobile_image']; ?>" alt="" />      and if i remove this line               $img_src = wp_get_attachment_image_src($img_src, 'size_300_190');      then image get visible. > I gave this custom size before uploading image.


title: Minify style.php in head of index.php

text: I currently have a WordPress theme options page. I read all the theme options styles in `style.php` which I then include in the head of my website. Does anyone know how to minify this `style.php` file? most of the "on-the-fly" scripts offer an solution, but it changes the header which results in an error message "headers already sent". `header.php`:               <style>         <?php require_once('css/style.php');?>     </style>      `style.php`:               <?php     ?>     body {         background-color:<?php global $variable; echo $variable['color-background'];?>;         font-family:<?php global $variable; echo $variable['typography6']['font-family'];?>;     }          a {         color: <?php global $variable; echo $variable['link-color']['regular'];?>;     }          <?php          ?>      Does anyone have a solution?


title: Custom CSS class or ID on menu items that have a Submenu

text: If I want to apply a style to only an item in a menu that has a submenu, how can I select that with CSS?


title: Caching of SQL queries

text: Within one plugin file I have several calls to the same option in the database via get_option(). Does WordPress do a database query every time I use get_option()? Would it be better to get the option once and store it in a global variable?


title: RSS feed for deleted posts and comments

text: I need to create a feed (RSS or Atom) of posts and comments that have been deleted (ie moved to Trash). What's the best way of doing this? Right now I'm thinking about creating 2 pages templates containing a SQL / $wpdb query that returns posts and comments with trashed status (and then creating new pages eg deletedposts / deletedcomments) Any better ways? Main reason for doing it this way is easy routing - ie the URLs are created for me. How would I handle the routing if I put this in a plugin and don't create pages?


title: Where do I USE add_rewrite_rule?

text: I need to add a RewriteRule to my site. I have tried in .htaccess with no luck, it doesn't get parsed, so I'm all but giving up on that. I found the documentation on add_rewrite_rule, but have no idea where I'm supposed to use it. I am not writing a plugin. I need to put in one simple rule. I went to the functions.php file in what is the current theme folder. Is this the one I use? I inserted the following:               add_action( 'init', 'add_news_rule3' );     function add_news_rule3()      { add_rewrite_rule( '^/content/([^/]*)/([^/]*)\.htm$', '/content/$matches[1] [NC,R=301,L]', 'top' ); }       I've also tried, based on a post I saw elsewhere:               add_action( 'generate_rewrite_rules', 'add_news_rule' );     function add_news_rule($wp_rewrite)     { $new_rules = array('^/content/([^/]*)/([^/]*)\.htm$' => '/content/$matches[1] [NC,R=301,L]');      $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; }           add_filter('rewrite_rules_array','add_news_rule2');      function add_news_rule2($rules)     { $new_rules = array('^/content/([^/]*)/([^/]*)\.htm$' => '/content/$matches[1] [NC,R=301,L]');      return $new_rules + $rules; }


title: How to use the_excerpt in a filter hook?

text: I was hoping to process the_excerpt just like one would with the_content, but no such luck. How can I pass the excerpts of a Posts Page, through my plugin? I've tried variations on this:               add_filter('the_excerpt', 'my_function');      But alas, no go. Suggestions? **EDIT: It looks like my filter call won't work when called from within another function, but it DOES work if it's at the same level of the function I'm calling, like so:**               add_filter('the_excerpt', 'my_filter');          function my_filter($content) {         die('hello');     }      Any ideas why this is?


title: Why do I have stray bullet from <?php wp_list_categories>?

text:
On this page, I have a stray bullet at the right of the side search jobs navigation? Why is this? It may that I am missing something simple. I just have been at for awhile. http://shs.merms.info/2010/12/30/shs-team-celebrates- successful-quarter/

<?php wp_list_categories('title_li=Categories
'); ?>


title: How can I optimize this code?

text: I have an Advanced Custom Fields Checkbox that I'd that I need to do some checks on. If a checkbox is ticked in the back end, it outputs an appropriate image on the front end. I've got some code that "works" but I think there's gotta be a much more efficient way to do it. Here's the code               $gluten = 'gluten.png';     $vegan = 'vegan.png';     $vegetarian = 'vegetarian.png';     $dish = get_field('diet_friendly');          if( in_array( 'gluten', get_field('diet_friendly') ) )      {         echo '';      }     if( in_array( 'vegan', get_field('diet_friendly') ) )      {         echo '';      }      Here's the array of the checkbox field               array(2) { [0]=> string(6) "gluten" [1]=> string(5) "vegan" }


title: Restrict custom post type view by user role

text: I've created a custom post type and created a couple of custom user roles and want to be able to restrict the view of the post type based on the specific roles. Is there a straightforward way to restrict this?


title: Get Posts shortcode plugin and meta_query?

text: I'm using Get Posts plugin to list posts with post type "project". I want to filter the list by two custom fields: year (ex. 2006) and state (ex. Completed). I added `meta_query` to the plugin's `get_post` args and tried the shortcode:               [get_posts post_type="project" meta_query="array(array('key' => 'state', 'value' =>      'Completed'),array('key' => 'year','value' => '2006'))" suppress_filters="false"]      This is not working, though I can get both "state" and "year" to work by their own using `meta_key` and `meta_value`. Can someone put me in the right direction?


title: Where should I put "run once" plugin pages?

text: Where should I put an administration page that should only be used once? I am creating a plugin that will index all used HTML tags in your posts, so you can cleanup posts if you change themes and want to replace old incorrect `<font>` tags with headers or other semantic markup. When you install this plugin it should scan your old posts once to fill up the index (custom taxonomy). I don't want to do this on plugin installation because it might take a long time if you have many posts, and thus a separate page with an AJAX-approach to transform batches of posts might be better. It's probably nitpicking, but should I put this extra page in the menu (under _Tools_?) and just leave it there, or should a use a trick to only display it when needed? Via a link in the plugin actions, or maybe a DB setting that you can use to hide the menu item? The plugin should remain installed (because it updates on post inserts and edits), and maybe sometimes you want a rescan (if you did a bulk change via the database). As plugin users, does it bother you to have menu options that you almost never use?


title: How can I convert everything from category X to have post format Link

text: My "links" come in from Windows Live Writer, from a perl based delicious sync directly to the database and who knows where from. They all have in common that the category is 'Daily-Links'. So I think I will schedule a cron that every day checks for all posts in the category 'Daily Links' and then adds the post format type 'format-link' to it. (since e.g. WLW does not support 'post formats') Or is there a better approach? I wanted to kick this off by running a SQL query since it are probably hunderds of posts (for each object_id,term_taxonomy_id pair which has not already term_taxonomy_id=(id of format-link) AND which has the term_taxonomy_id of (the specific category) DO add the term_taxonomy_id of the format-link) But... maybe there is already a WP function call for this? Is there?


title: troubles with get_post_meta (and saving it)

text: im having trouble using "add post meta" and "get post meta" : i have a new meta box in my taxonomy : i always have the value "empty meta" inside the input field, even after i enter anything : like 'banana' , i publish the article, and same thing : inside the field there is one more time "empty meta" ... (is it a problem with $post->id? i never really know if $post will be 'understood' depending how it is used)               /* Prints the box content */         function myplugin_inner_custom_box() {             // Use nonce for verification             wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );             $met = get_post_meta($post->ID, 'champ', true)? get_post_meta($post->ID, 'champ', true) : 'empty meta';                  /* input */             echo '';             _e("Description field : ", 'myplugin_textdomain' );             echo ' ';             echo '<input type="text" id="champ" name="champ" value="'.$met.'" />';      also, i tried to make the meta appear in my page, so i put :               <?php     if ( get_post_meta($post->ID, 'champ_key', true) ) {     $meta = get_post_meta($post->ID, "champ_key", true );     } else {     $meta = 'allo';     }     ?>      but nothing appears on the page. Do you know how i could go ahead with those post meta? Thanks **EDIT** here's the complete code : if somebody could try it, i might doing something wrong, but i can't find out what. (the whole code is inside a widget page)               /*      *      * add meta box : habillage      *      */     add_action( 'add_meta_boxes', 'myplugin_add_custom_box' );     add_action( 'save_post', 'myplugin_save_postdata' );          /* Adds a box to the main column on the Post and Page edit screens */     function myplugin_add_custom_box() {     add_meta_box(         'test1',         __( 'My test1', 'myplugin_textdomain' ),         'myplugin_inner_custom_box',         'post'     );     add_meta_box(         'test2',         __( 'My test2', 'myplugin_textdomain' ),         'myplugin_inner_custom_box',         'movies'     );     }               /* Prints the box content */     function myplugin_inner_custom_box() {     global $post;     // Use nonce for verification     wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );     $met = get_post_meta($post->ID, 'champ', true)? get_post_meta($post->ID, 'champ', true) : 'empty meta';              /* input */     echo '';     _e("Description field : ", 'myplugin_textdomain' );     echo ' ';     echo '<input type="text" id="champ" name="champ" value="'.$met.'" />';                         /* select list */     echo '';     _e("Description for this field", 'myplugin_textdomain' );     echo ' ';     echo '<select name="my_list_field" id="my_list_field">';          print_r ($post->ID);          global $post;          $s_query = new WP_Query( array(     'suppress_filters' => false,     'post_type' => 'movies'));     while($s_query->have_posts()):$s_query->the_post();              $sname = $post->post_title;         $s_output2 ='';         $s_output2 .= '<option value="'.$post->ID.'" >';         $s_output2 .= $post->post_title.' : allo';         $s_output2 .= '</option>';         echo $s_output2;          endwhile ;     echo '</select>';     wp_reset_query();     }               /* When the post is saved, saves our custom data */     function myplugin_save_postdata( $post_id ) {       // verify if this is an auto save routine.       // If it is our form has not been submitted, so we dont want to do anything       if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )           return;            // verify this came from the our screen and with proper authorization,       // because save_post can be triggered at other times       if ( !wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename( __FILE__ ) ) )       return;            // Check permissions       if ( 'page' == $_POST['post_type'] )       {         if ( !current_user_can( 'edit_page', $post_id ) )         return;       }       else       {         if ( !current_user_can( 'edit_post', $post_id ) )             return;       }       // OK, we're authenticated: we need to find and save the data       //$mydata = $_POST['myplugin_new_field'];       // Do something with $mydata       // probably using add_post_meta(), update_post_meta()       add_post_meta($post->ID, "champ_key", 'banana');          return $post_id;     //return $mydata;     }     ?>


title: how to config the home page locally

text: I am new to wordpress and apache. Following the introduction i found from google, i installed the apache(2.2.17)+mysql(5.5.11)+php(5.2.17)+wordpress(3.1.1) successfully on my PC. But when I login with the right user name and password, it just go into the wp-admin directory but not the homepage. I guess I missed some configurations of the apache server or something else. Could anyone can help on this, or give a link. thanks for help.


title: Conditional hook based on the core function that is calling it

text: In a Multisite, I'm applying the filter `get_blogs_of_user` to sort the "My Sites" admin bar menu, where the sites are listed by **`blogname`** : ![admin bar multisite my-sites](http://i.stack.imgur.com/KCjM1.png) What happens is that I'd like another order elsewhere, where the sites are listed by **`domain`**.   For example, the sites that appear in the Users screen (`/wp- admin/network/users.php`): ![user sites](http://i.stack.imgur.com/K8FOQ.png) The question is: for achieving that, I'm using `debug_backtrace`, but am not sure if this is working by accident or if the logic stands (?!). I found that checking for `debug_trace()->trace[4]['function']` I get to know where in the core the function `get_blogs_of_user` is being called. ## Sample code               add_filter( 'get_blogs_of_user', 'bf_reorder_users_sites' );          function bf_reorder_users_sites( $blogs ) {         $trace = debug_backtrace();         // my_debug_dump();              if( 'initialize' == $trace[4]['function'] )             uasort( $blogs, 'bf_uasort_by_blogname' );         else             uasort( $blogs, 'bf_uasort_by_domain' );              return $blogs;     }          function bf_uasort_by_domain( $a, $b ) {         return strcasecmp( $a->domain, $b->domain );     }          function bf_uasort_by_blogname( $a, $b ) {         return strcasecmp( $a->blogname, $b->blogname );     }      ## Debug `my_debug_dump()` lists `$trace[4]['file']` and `$trace[4]['function']`, and prints:               File:: /wp-path/wp-includes/admin-bar.php     Function:: initialize     --------     File:: /wp-path/wp-includes/class-wp-admin-bar.php     Function:: get_active_blog_for_user     --------     File:: /wp-path/wp-admin/admin-header.php     Function:: wp_user_settings     --------     File:: /wp-path/wp-includes/admin-bar.php     Function:: is_user_member_of_blog     --------     File:: /wp-path/wp-admin/includes/class-wp-list-table.php     Function:: display_rows     --------     File:: /wp-path/wp-admin/includes/class-wp-list-table.php     Function:: display_rows     --------     File:: /wp-path/wp-admin/includes/class-wp-list-table.php     Function:: display_rows


title: How can I return shortcode output to the top of the content?

text: I have a shortcode called update which is used as follows               [update title='' date=''] this is some update, etc. etc. 2 paragraphs or more [/update]      This outputs some html that wrap the title, date and content in some html. Along wit this, I would like spit out a single line at the top of the content that outputs just the title and date with an anchor that jumps to the point where the update was created. I've looked high and low, but I cant seem to find a way to position the shortcode just above the content. Any help appreciated! Thank you


title: Wordpress apply_filters() Arguments Missing

text: I'm customizing a Woocommerce Wordpress site. In the Woocommerce product class (`class-wc-product.php`) the `get_price` function applies a filter as follows:               function get_price() {         return apply_filters('woocommerce_get_price', $this->price, $this);     }      In my functions.php I want to add a filter as follows:               add_filter('woocommerce_get_price', 'custom_price');          function custom_price($price, $product) {         ...     }      When I call this I get the following PHP warning:               Warning: Missing argument 2 for custom_price()      Why is the second argument missing? Is `$this` not sent to the filter call?


title: Faceted Navigation in Wordpress

text: have anyone managed to succesfully implement faceted navigation in wordpress? Using taxonomies and categories I think that it can be done but don't know how to implement the "url" part of faceted navigation and also how to implement the filters. http://experiencinginformation.wordpress.com/2010/09/04/faceted-navigation- seo-and-facets/ Thanks a lot