title: Edit different parts of a page seperately

text: I'm an experienced PHP developer without a lot of wordpress knowledge (yet!). I have to put together a fairly simple Wordpress page in the next few days. To get started I need to create a custom home page that will pull in content from three other discrete parts and present them in one layout. I'd like to structure it so that on the administrative end you'd have three different pages or posts to edit and the content (an image, some copy, and a link) from each would get pulled into the front page and presented there. What technique should I research for this? A custom page template? Custom fields? Any help is appreciated.


title: Exclude / Blacklist Permalinks

text: I'm building a website and I was wondering if it is possible to exclude certain permalinks from beings used. For example: if my website has a demo of a project running on `www.example.com/demo/` and a user creates a page called demo, I don't want WordPress to create a permalink like `www.example.com/demo/`. Is there a way to exclude these permalinks? So that WordPress will take the next available permalink? Like `www.example.com/demo-2/` or something?


title: Custom styles and scripts for specific admin screen

text: Which is the best way to load different scripts and/or styles for different admin pages? For example:   1. edit.php (a style, a script)   2. edit.php?post_type=page (another style, another script)   3. edit.php?post_type=_my_custom_post (none script, yet another style) end so on... the get_current_screen() function should help the process, but I'm not sure which actions to use and how. Any suggestions would be very appreciated, thank you very much.


title: Custom taxonomy - category results

text: Hello I make my own custom taxonomy               register_taxonomy(     'ingredients',     array('wine'),     array(         'hierarchical' => true,         'labels' => array(             'name' => 'Wyszukiwarka',             'singular_name' => 'Wyszukiwarka',             'search_items' => 'Wyszukaj kategorie',             'popular_items' => 'Popularne kategorie',             'all_items' => 'Wszystkie kategorie',             'edit_item' => 'Edytuj kategorie',             'update_item' => 'Aktualizuj kategorie',             'add_new_item' => 'Dodaj nową kategorie',             'new_item_name' => 'Nazwa nowej kategorii',             'separate_items_with_commas' => 'oddziel składniki przecinkiem',             'add_or_remove_items' => 'Dodaj lub usuń kategorie',             'choose_from_most_used' => 'Popilarne kategorie',             'menu_name' => 'Wyszukiwarka'                  ),         'show_ui' => true,         'update_count_callback' => '_update_post_term_count',         'query_var' => true,         'rewrite' => array('slug' => 'ingredient')     )     );      when I want go to any category like: http://jaroslawwroblewski.pl/luxurywinestory/ingredients/bordeaux/ or http://jaroslawwroblewski.pl/luxurywinestory/ingredients/saint-emilion/ I have "Page Not Found" and back to home page... How can I display results for /ingredients/bordeaux/ ?


title: Edit draft from other author

text: I need that editors in my blog can read and edit drafts from other authors. I've tried some access manager plugins:   1. Advanced Access Manager   2. User Role Editor But none of these helped me. I've also looked for similar questions like this and this, but again, nothing found. How can I do this? It is possible?


title: Checked checkbox?

text: I'm working on adding a checkbox to my user registration page to opt-in to my e-mail list, and I'm not sure the proper way to have the checkbox ticked off by default. This is what I've got so far:               // Checkbox to join list     add_action( 'register_form', 'email_opt_in' );          function email_opt_in() { ?>         <p>         <label style="font-size:13px;">         <input type="checkbox" name="email_opt_in" id="email_opt_in" class="input" value="1" <?php checked( $_POST['email_opt_in'], 1 ); ?> tabindex="99" style="width:12px;padding:0;margin: 0 3px 0 0;font-size: 13px;" />          Join our famous e-mail list         </label>         </p>         <br/><?php     }      I'm using checked which works great, but I want the checkbox to be checked by default. Is adding `checked="checked"` to `input` the right thing to do, or is there a better way to do it? Thanks in advance!


title: require_once() error after moving Wordpressto another server

text: I got this type of error after moving Wordpress site to other server. I don't have mistakes in config and dont understand why this error occured? Any suggestions to what might be causing these errors               Warning: require_once() [function.require-once]:      Unable to access /public/sites/www.glasloodje.nl/wp-admin/includes/bookmark.php      in /public/sites/www.glasloodje.nl/wp-admin/includes/admin.php on line 17          Warning: require_once(/public/sites/www.glasloodje.nl/wp-admin/includes/bookmark.php)      [function.require-once]: failed to open stream: No such file or directory      in /public/sites/www.glasloodje.nl/wp-admin/includes/admin.php on line 17          Fatal error: require_once()      [function.require]: Failed opening required      '/public/sites/www.glasloodje.nl/wp-admin/includes/bookmark.php'      (include_path='.:/usr/share/php:/usr/share/pear')      in /public/sites/www.glasloodje.nl/wp-admin/includes/admin.php on line 17


title: Best practice (forward compatibility) for theme options

text: So here is what I'm wondering... You all know about Option-tree and similar frameworks that theme authors are using for their theme option pages. You also all know that since 3.4 WordPress introduced their Customization API. Obviously they will want theme authors to use it instead of the frameworks metnioned. And obviously this will be the good way, since it's native. However, their is one issue... WP Customizer doesn't provide enough space. Imagine you have options such as these: ![enter image description here](http://i.stack.imgur.com/UnRh2.png) I can think of a way to import all of them into the Customizer... that also goes for social links, layout options, background pattern options and so on... One way I can think of is creating separate admin pages for these... but if you get that approach chances are that you will end up with few different pages for your options.. and that will surely confuse guys using your theme. So what we should do? Please, let me know your thoughts.


title: WP New Post Problem

text: I **cannot access** "New Post" OR "New Page" from WP admin. I have this as the URL:               http://www.infogurushop.com/wp-admin/options-general.php?page=sharing      and sometimes get this as the URL:               http://www.infogurushop.com/#axzz2gxAGAT3z       What is going on?


title: Taxonomy based permalinks

text: With my website I work with my own taxonomy. And I want that the taxonomy is intergrated with the permalink. So if an news page has a taxonomy, the permalink change. Like this: mysite.com/%custom_tax%/blog/%postname% And if it's a page this: mysite.com/%custom_tax%/%postname% But if there is no taxonomy I want: mysite.com/blog/%postname% And if it is an page: mysite.com/%postname% How can I easily do this? I already set up the %custom_tax% :               add_filter('post_link', 'custom_tax_permalink', 10, 3);     add_filter('post_type_link', 'custom_tax_permalink', 10, 3);               function custom_tax_permalink($permalink, $post_id, $leavename) {         if (strpos($permalink, '%custom_tax%') === FALSE) return $permalink;              // Get post         $post = get_post($post_id);         if (!$post) return $permalink;              // Get taxonomy terms         $terms = wp_get_object_terms($post->ID, 'custom_tax');           if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;         else $taxonomy_slug = '';                   flush_rewrite_rules();         return str_replace('%custom_tax%', $taxonomy_slug, $permalink);     }


title: Style of a theme

text: Firstly I apologise for what no doubt is a probably relative straight forward question for someone with the relevant experience: Is it possible to change the complete look of a theme however keeps its functions? I've seen a word press theme that I like but its visually 'ugly'. Its a complicated website with a lot of functions however i'm interested in knowing whether the style of it can be completely changed. In a nutshell.... Can I buy a mercedes benz, take the chassis off and put a Ferrari chassis over the top whilst keeping the brakes , gearbox, etc!?!??! This is the theme: http://demos.appthemes.com/?theme=jobroller There is a 'child theme' that I like (I may not be upto speed on the terminology)


title: Filtering posts by post meta data

text: I want to filter posts in such a way that only posts, for which `get_post_meta($post->ID, "project_cat", true)` (it returns a post ID) is equal to my specified value, are shown. Any way to do this? I am especially interested in ways to do it compatible with WP-Paginate plugin.


title: Define specific category name in PHP

text:
Might be a really simple question... I am trying to pull out a category name in PHP and display it on my page. I have multiple category sections on this page, and each need to pull their respected name as an _h2_. Here is what I am currently doing:

<?php the_category(); ?>

             <?php query_posts('category_name"theCategoryName"');             while (have_posts()) : the_post(); ?>                 #code...             <?php endwhile; ?>

      When I **query_posts** for my `theCategoryName` I get the content needed for that section, however, a couple lines above where I have `the_category()` printing out, this stays the same name for all of my different sections. For example, if the cateogry name was "cats" then for all my sections that have an _h2_ show the text "cats". Lets say this particular section is suppose to be "dogs" instead of "cats", how would I achieve this? Hope this makes sense.. * ** _EDIT_ *** So here is an updated version of my code, but I am still having issues. `the_category();` for each section still shows up as the same name. AND it seams as though the category name changes if I create a new post with a different category. For example, if I create "cars" then both of the below category names change to "cars".

<?php the_category(); ?>

             <?php              $q = new WP_Query('category_name="cats"');             if($q->have_posts()) {                 while ($q->have_posts()) : $q->the_post(); ?>                     #code...                 <?php                  endwhile;              }             wp_reset_postdata();             ?>

<?php the_category(); ?>

             <?php              $q = new WP_Query('category_name="dogs"');             if($q->have_posts()) {                 while ($q->have_posts()) : $q->the_post(); ?>                     #code...                 <?php                  endwhile;              }             wp_reset_postdata();             ?>

      Is my code syntax correct? or am I just all over the place with this :(


title: Modal window from within Wordpress admin

text: How can get a modal window to work from within the wordpress admin? I want to create a modal window that will work from a meta box within the wp- admin. Any ideas?


title: setting a different theme for specific category in wordpress

text: I was wondering if and how is it possible in Wordpress to set a different theme for a specific category of contents (in my case the blog). I'm on WP 3.3.1. Thank you so much in advance. Any help will be sincerely appreciated.


title: Wordpress with CAS+LDAP and standard WP accounts

text: I have a wordpress site setup with the wpCAS-w-LDAP plugin for logins. It's working perfectly except for one thing. We have some users who can't login using the CAS system since they don't have an account there (outside our control). Therefore we want to enable some kind of system where the user first is prompted if he/she want to login using CAS or with a standard wordpress account. Do you know of any plugins like this?


title: Selectively applying action based on role

text: I've added an action to my functions.php file that forces a plugin (Content Scheduler) to act on posts, even when it wasn't explicitly enabled by the person writing the post. I've got that working, but I want it to work only when the author's role is one that I've specified, and better yet, work differently for different roles. The role-checking code isn't working. I'm attempting to call the "user_has_role" function (which I am calling successfully elsewhere in the same file, so I know that part should work), but either it is not working in this context, or it is not getting called at all.               function user_has_role( $roles_to_check=array() ) {       if( ! $roles_to_check ) return FALSE;       global $current_user;       get_currentuserinfo();       $user_id = intval( $current_user->ID );       if( ! $user_id ) { return FALSE; }       $user = new WP_User( $user_id );        return in_array( $roles_to_check, $user->roles, FALSE );     }          function my_function($post_id, $post) {         $is_role1 = user_has_role( array('role1') );         $is_role2 = user_has_role( array('role2') );         if ($is_role1) { $flag = 1; }         if ($is_role2) { $flag = 2; }         if ($flag != null) {                 // do Content Scheduler stuff         }     }          add_action( 'save_post', 'my_function', 10, 2);      Thanks in advance.


title: Muliple featured images (or just images) per post

text: Is there a way to have multiple "featured" images (or just images) per post...I mean without putting it into the regular text editor. I would like to have some control where the images go...hence make it work the way the featured image works (i.e. a separate meta box)


title: why do HTML Comments in the WYSIWYG break the page display?

text: This question is about HTML code comments `<!-- like so -->` rather than about post/page comments. I specify the WYSIWYG, but this problem arose in the HTML view, not the Visual. I've been building a site for a client, and she came to me with a problem — she had tried to comment out part of her page content, and it had drastically changed the behavior of the page! I looked into it, and was pretty surprised to find that putting a comment anywhere into the content would completely remove that entire block of content. And not just that, it seemed to be confusing WordPress as to what `the_content()` for that page even was. The content from the sidebar, if there was one, or the footer, if there was no sidebar, would work its way into the main content display area. The only context in WP I've seen `<!-- this -->` before was in using the DagonDesign sitemap generator plugin, which you display by putting a `<!-- commented out shortcode -->` into the page content. That seems to have been co-opted for a special purpose, but is there a purpose for the comment tag that I am not familiar with? Does anyone have insight into what's going on here?


title: How can I dynamically generate an image with a static image URL?

text: What I'm trying to do is very simple. Whenever someone visits, say `site.com/socialproof.png`, I want it to use a rewrite rule to point it to a file in my plugins folder. Can I do this with WP's rewrite rules or do I need to manually add it to the `.htaccess` file? What would I use as the rewrite rule to do this? Thanks!


title: Wordpress Plugin Receive a Link

text: I'm writing a Wordpress plugin. The plugin should allow every user to rate posts (1 to 5 stars). What actually works is to read the rating from storage and show the stars. So there are five `<a>` links after every post, indicating the ranking by different colours. The stars are linked because I want to let the visitor rate my post by clicking on one of the stars. My question is now, how can I prepare my plugin file to receive the link, (save the rating into storage), and sending the user back to the article page. I other words... **How can I run a plugin function if the user follows a link?**


title: Added a new template file to a theme - get Call to undefined function error

text: I added a new file in the theme folder and it doesn't seem to be working properly. The first line `get_header();` creates an error `Fatal error: Call to undefined function get_header()` like it's not seeing any includes. Any ideas why that happens? All files in the same theme folder work just fine except this one.


title: Strip <p> from <blockquote> or something better?

text:
Looking for some help on something that has me really contemplating not using blockquotes for the moment! I have this code:               <?php         $show_after_p = 1; $content = apply_filters( 'the_content', get_the_content() );         if(substr_count($content, '
') > $show_after_p) {             $contents = explode('
', $content); $p_count = 1;             foreach($contents as $content) {                 $content = str_replace('
', '', $content);                 echo wpautop($content);                 if($p_count == $show_after_p) { get_template_part('_templates/box'); } $p_count++;             }         }     ?>      The reason for the wpautop is to fix a short code in the content, and the way that inserting the box in before the first `<p>` rather than after. Anyway, since the box is addded before the first `<p>` tag, in a blockquote, it inserts in-between:

The quote

      So I'm looking for a way to strip the `<p>` from the `<blockquote>` (I realise it's not semantically correct, but the internet will have to heal with it!) OR something better.. Also I've added the `functions` tag in case someone from there could turn this into a function since I do have more than one post type this would apply to :]


title: Wordpress plugin: render only page content using ajax call

text: I'm writing a plugins that renders json data from an API request and I need to implement an infinite scroll in a content page. The problem is when I render the content with an ajax call, it renders all the page instead. This is what I have done so far:               function enable_pagination() {         jQuery(function($) {             $('#show-more-button a').click( function(e) {                 e.preventDefault();                 $.ajax( {                     url: document.URL,                     data: { 'page': 2 },                     type: 'POST',                     dataType: 'html',                     error: errorHandler                 }).done( function( response ) {                     $('.list').append( response );                 });             });         });     }      **EDIT: ADDING EVENTS_CONTROLLER CODE**               public function festival( Array $shortcode_params ) {                 $collection_edition = $shortcode_params['collection_edition_id'];                 $festival_name = $shortcode_params['name'];                      if ( is_numeric( $collection_edition ) && $collection_edition > 0 ) {                     $this->initialize_params();                     $this->initialize_api_client();                     $date = array_key_exists( 'date', $this->params ) ? $this->params['date'] : date( 'Y-m-d' );                     $category = $this->params['category'];                     $page = isset( $this->params['page'] ) ? $this->params['page'] : 1;                     $events_by_festival = $this->api_client->from_day( $date, $collection_edition, $category, $page );                          // pagination                     if( $this->isAjax() )                         return View::render( "events/partials/_list.php", array( 'events' => $events_by_festival ) );                     else                         return View::render( "events/festival.html.php", array( 'date' => $date, 'category' => $category, 'festival' => $festival_name, 'events_by_festival' => $events_by_festival ) );                 }                 return false;             }               private function isAjax() {                 return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';             }      View is a custom class with some helpers ex: for rendering.               /**              * Render the template, returning it's content.              * @param $data array Data made available to the view.              * @param $template string view file name to render              * @return string The rendered template.              */             public static function render( $template, $data ) {                 extract( $data );                 ob_start();                 include( "views/$template" );                 $content = ob_get_contents();                 ob_end_clean();                 return $content;             }      document.URL refers to an events_controller action that, when ajax request, returns only events_list partial view. As I said before, in this case, ajax response contains, other than content, also the header, sidebar, footer, etc.... There is a clean way to achieve this? Thank you in advance


title: thickbox to WordPress theme not working for front end user picture uploading

text: I use this piece of code in "WP-Member" plugin for profile picture, it is working fine but there is a problem. If I try to change the user avatar from front end, TB_iframe is not popping up, it is spreading to whole webpage as you can seen in the attached image. Here is my code               ' . ( 'Update Picture','wp-members' ) . '      Here it's image: ![enter image description here](http://i.stack.imgur.com/h4WZA.png)


title: Why does my sidebar get dragged down on this specific uid?

text: My sidebar is getting dragged down on uid=1: http://www.mrgeek.me/contributors/?uid=1 Now, the other contributor pages have the same underlying markup, yet they work fine. For example, uid=3, http://www.mrgeek.me/contributors/?uid=3. I need to know what is happening and what should I do?


title: How-to exclude terms from the main query the most performant way?

text: This Q is a follow up to this answer on the Q: "How to exclude a specific term for the search?". ## 4 ways to filter out posts that have a specific term               Type                | Pro                   | Contra     --------------------------------------------------------     Run a new query     | Easy to implement     | Add. Queries                                                 | Add. time to execute the DB call + processing the parsing of the results     Inside the loop     | Easy to implement     | Sometimes Add. Queries                                                 | Add. time to execute     Modify the query    | Full control          | Hard to implement                                                 | Needs a lot of knowledge (preparing, DB interaction)     Add new query parts | No perform. impact    | Hard to get around                         | Secure                         | Full core support      The first type _imho_ is _not_ an option. The "Types" 2 & 3 are already answered in the other Q and both still have some backdraws. ### Question:   1. How to add an additional `tax_query` argument to the main query using (for e.g.) the `pre_get_posts` filter?   2. Do you know additional ways to modify the main query?


title: How to enable customer login to customer specific admin page

text: I would like to build a website that will let visitors register and get access to their own personal admin page. So user #1 will input his login and password and get access to his admin page with his parameters. User #2 will see his own parameters, etc. Is this possible using wordpress themes and plugins? and if yes, which theme or plugin would you advise?


title: Front end editor to pending post(for contributors)

text: I'm wanting to create a landing page where new users can come to answer interview questions. The user will answer the questions that are embedded in the edit area under the normal Wodpress WYSIWYG editor. Then they can enter a username and password. Once they click submit the post will go to their newly created user profile area for later editing. The admin would also be able to publish it from there. I figure there is no exact plugin for this but I'm curious how easily it can be done. I've got a form for this now but it doesn't have the WYSIWYG editor and it doesn't allow for users to create a profile at the same time. I'm basically trying to avoid making the user create a username and password, then have to go to the backend to answer the questions(create content) in the backend. Having all this on the front end in a landing page would increase conversions/make it easier for users. Thanks in advance for the help!


title: How do I get post attachments in menu_order in Wordpress?

text: I'm struggling to get menu_order to work for images attached to a post. I am trying to pull all of the images attached to a specific post in the order specified via the drag-and-drop interface in the media window. Here is the code pulling the images:               $args = array(         'post_type' => 'attachment',         'post_mime_type' => 'image',         'output' => 'ARRAY_N',         'order' => 'ASC',         'orderby' => 'menu_order',         'post_parent' => $post_id /* This is defined elsewhere */     );      $images =& get_children($args); This is not pulling the images in the order shown in when looking at the attached images in the media window of the post edit page. The order is instead ordered by date. Can anyone shed some light on this issue? I disabled the category order plugin I was using, and this did not remedy the problem. EDIT: Thanks to gdaniel for your help! I realized after following your advice and checking the image posts in my database that they all had a menu_order value of 0. I was able to temporarily fix this issue using the code in this forum post. I'm looking for a way now to change the menu order on the event of drag and dropping images. Thanks to kaiser for his suggestions!


title: What Defines What Category A Post Picks (if in multiple)

text: If I have a post in multiple categories, what defines what category shows up in the URL? Assuming I have permalinks setup as `/%category%/%postname%` is it the ID or the name?


title: Loading individual category post via dynamic tabs

text: I've been searching for a navigation solution for my wordpress site's front page that loads individual categories and their corresponding post through dynamic tabs. These are tabs or buttons that load content without the entire page needing to reloaded itself. I assume I'd need to make individual post loops for each category in order for it to work. If I could get some advice on this subject to start me on my way, I would be very grateful. I'm quite new to Ajax and jquery in general. Thanks again in advance! UPDATE: I've looked through Wordpress Answers for similar topics on the subject to narrow my question a bit since it was a bit too loaded. I did find another post with code that did work! "Using ajax on categories and wordpress loopsUsing ajax on categories and wordpress loops " Now that I know that the code from this post will work, I just need it to display post from all categories when first loading up my webpage's front page. At the moment it won't load any post from the loop unless you click on a link. Plus, I'll need an "All" link in the list of categories that can list all post from the site. Any help would be greatly appreciated.


title: WP_Query do not include posts with a certain value in a custom field -

text: I am trying to grab the 5 most recent posts and have it exclude posts in an array that is already defined ($exclude), sticky posts and any posts that are checked off as a featured post (i.e. with the custom field "my_featured_post" set to 1) I tried:               $args = array('post__not_in' => $exclude,         'ignore_sticky_posts' => 1,         'posts_per_page' => 5,         'meta_query'=> array(             array(             'key'=>'my_featured_post',             'value'=>'1',             'compare'=>'!='             )         )     );     $query = new WP_Query($args);      and :               $args = array('post__not_in' => $exclude,                           'ignore_sticky_posts' => 1,                           'paged'=>1,               'posts_per_page' => 5,               'meta_key'=>'my_featured_post',               'meta_value'=>'1',               'meta_compare'=>"!="                              );      Neither returned any posts. If i remove the references to meta in either query, it returns a mix of posts set as "my_featured_posts" and not set as such. Am I going about this wrong? Thanks, gS


title: wp_nav_menu action/filter help

text: Maybe an odd question, I have a site that makes heavy use of nav menus. I'm looking to improve my site's performance, and since the menus hardly ever change, I wrote some PHP to spit them out into static files. What I can't figure out though, is if there is a way for me to hook into `wp_nav_menu` so that I can get the `theme_location` name (so that I can determine which static file to output) and then prevent `wp_nav_menu` from hitting the database and putting together the menu. If I add in this filter:               add_filter('wp_nav_menu_args', 'my_wp_nav_menu_args_filter');     function my_wp_nav_menu_args_filter($args = array()) {         //$args['walker'] = new my_walker_class();         return array();//$args;     }      and then either return `false` or an `empty array` I still seem to get a nav, or an error generated in my custom walker. So is there no way to prevent a nav from being generated and from wp hitting the db trying to do it? Thanks.


title: Edit the_content() function so to add a div wrapper

text:
Currently my article is displayed like this:

         <img class="size-full wp-image-61891 colorbox-78559"

       blabla

      I want to modify the_content() function so that body is wrapped around a div with an id, so that I can easily refer to it. My desired output:

         <img class="size-full wp-image-61891 colorbox-78559"

       blabla

      How to obtain this behaviour? What file do I have to modify?


title: My plugin won't return anything

text:
I am trying to write a simple plugin to insert some post links in a post at the right place. The query part works okay in a template, but my attempt at a displaying via plugin just returns a blank space.               //tell wordpress to register the wafunitslist shortcode     add_shortcode("waf-units-list", "wafunitslist_handler");          function wafunitslist_handler() {         wafunitslist_function();     }          function wafunitslist_function() {     ?>     <?php $country = get_post_meta(get_the_ID(), "Country", true); ?>     <?php $operator = get_post_meta(get_the_ID(), "Operator", true); ?>          <?php query_posts('cat=738&meta_key=Operator&meta_value='.$operator.'&orderby=title&posts_per_page=-1&order=ASC' ); ?>          <?php        // Reset and setup variables        $output = '';        $temp_title = '';        $temp_link = '';             // the loop        if (have_posts()) : while (have_posts()) : the_post();                $temp_title = get_the_title($post->ID);           $temp_link = get_permalink($post->ID);                // output all findings - CUSTOMIZE TO YOUR LIKING           $output .= '
'.$temp_title.'
';             endwhile; else:                $output .= 'nothing found';             endif;             wp_reset_query();        return $output;     }          ?>      Replacing 'return' by 'echo' shows a list of links at the top of the post, but 'return' gives nothing. What am I doing wrong? This is driving me a bit crazy. Thanks for any help.


title: Determining the compatibility of Settings API & Multisite

text: New to this forum so forgive any protocol infringements on my part and feel free to criticize so in the future I don't again. Down to the nitty gritty. I'm working on a project and am very new to multisite and utilizing the Settings API. I decided the best way to learn was directly from the WP Codex. As I was reading the codex page on Settings API I discovered the following note. "NOTE: _When using the Settings API, the form posts to wp-admin/options.php which provides fairly strict capabilities checking. Users will need 'manage_options' capability (and in MultiSite will have to be a Super Admin) to submit the form._ " I've looked around the Internet but all the references I see seem to point to issues with building custom settings pages for the Network level. I am looking to build a custom template utilizing Settings API and replicate that for multiple organizations under one network. But each individual site would use its own settings, I am not looking for anything where it is changed once across all the sites. Example is each site would list its school name and upload that logo. Each individual admin for each site would be responsible for providing that information. Would this be possible and what the codex is referring to. I also came across the following article on this forum. Again it seems to refer to Network portion of Wp-Admin. Settings API in Multisite - Missing update message


title: remove class from code

text: How can I remove the class from the following code and use it without the functions. I tried removing the functions and class and add it in functions.php but it did not work.               class someclass {              function __construct() {                 add_action('init', array(&$this, 'action_admin_init'));                     add_action('admin_enqueue_scripts', array(&$this, 'action_admin_scripts_init'));               }              function action_admin_scripts_init() {             wp_localize_script( 'jquery', 'myscript', array('folder' => SCRIPT_URL) );         }              function action_admin_init() {             add_filter( 'some_filter', array(&$this, 'register_some_filter') );         }          }


title: Would Amazon AWS Services be a good alternative to my current hosting provider?

text: My WP sites keep crashing my server because I have huge amounts of load in a short amount of time. The server has to be rebooted every few minutes. We have tried everything but nothing seems to work...would Amazon AWS Services be a good alternative? If so, which AWS services would work best?


title: Default sort on admin columns with meta date hides draft posts with empty date value

text: I have a custom post type of 'gigs' and a metabox (using meta-box plugin ) with event start date and time saved like: 2013-11-29 20:30. If I save a draft with no time/date set then it shows up in the published or draft posts admin column as expected. However when I try to order the default screen to have future gigs at the top then the gigs without a date yet don't show up in the list, although there is one added to the counts of 'all' and 'draft' in the status row selector at the top. I am using the following ( based on http://wordpress.stackexchange.com/a/66478/7401 )               /* Sort posts in wp_list_table by column in ascending or descending order. */     function custom_post_order($query){     global $prefix;         /*              Set post types.             _builtin => true returns WordPress default post types.              _builtin => false returns custom registered post types.          */         $post_types = get_post_types(array('_builtin' => false), 'names');         /* The current post type. */         $post_type = $query->get('post_type');         /* Check post types. */         if(in_array($post_type, $post_types) && $post_type == 'gigs'){             /* Post Column: e.g. title */             if($query->get('orderby') == ''){                 $query->set('orderby', 'meta_value');             }             if($query->get('meta_key') == ''){                 $query->set('meta_key',  $prefix . 'startdatetime');             }         }     }     if(is_admin()){         add_action('pre_get_posts', 'custom_post_order');     }      Is there a way to get the event with no date/time included in the default admin list, preferably at the top?


title: gettext does not translate when called in ajax

text: When loading content in gettext calls (__(), _e(), etc.) they translate fine when I render the page in the browser normally (PHP delivers the content to the browser), however when I make AJAX calls, the gettext does not translate. I thought maybe it was that word specifically, but when I use the gettext call in content that is loaded from the server normally (not through ajax) it translates. I'm using WPML, but I don't think that has anything to do with it? Is there anything special I have to do or add the load_plugin_textdomain function call to a specific action hook? It's added to the "plugins_loaded" action right now. I use WordPress ajax methods as described in their docs and I get all the data, just don't get gettext translations. As advised here are snippets of the code that has the problem. I did not incldue the gettext .pot and .mo files, as I know those work (bc/ other text in there gets translated in the rest of the plugin itself). I just state what their name is and where they reside relevant to the plugin root.               //gettext files     // languages/my-plugin-fr_FR.pot     // languages/my-plugin-fr_FR.mo          //Javascript files     // js/main.js     (function($){            function getResources() {             $.ajax({                 type: "POST",                 url: ajax_object.ajaxurl,                 dataType: "json",                 data: {                                         action: 'get_resources'                                }             })             .done(function(data) {                 if (typeof data == "object" && data.hasOwnProperty("html")) {                                    $(".my-selector").empty().html(data.html);                 } else {                    alert("error on server");                               }             })             .fail(function() {                 alert("error on server");               });         }            $(document).ready(function() {          getResources();       });          })(jQuery);     // end js/main.js               <?php     //MyPlugin class          class MyPlugin {           /// This value will be used as a unique identifier for translations       public static $theme_domain_name = 'my-plugin';            public function init() {          if (!is_admin()) {                    //any scripts and styles needed for the plugin to work in the front end           add_action( 'wp_enqueue_scripts', array($this,'add_scripts_styles') );              }              add_action('wp_ajax_get_resources', array($this,'ajax_get_resources'));         add_action('wp_ajax_nopriv_get_resources', array($this,'ajax_get_resources'));       }            public function ajax_get_resources() {                     $html = "";                  //just an example of returning post objects             $posts = get_posts();                  $html .= $this->get_resources_html($posts);                  echo json_encode(array('html'=>$html));                  die();       }            public function add_scripts_styles() {          wp_register_script('main-js', plugin_dir_url(__FILE__) . 'js/main.js', array('jquery'), '20131023' );          wp_enqueue_script('main-js' );          wp_localize_script('main-js', 'ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );       }            public function get_resources_html($resources) {          $load_more_text = __('Load more',MyPlugin::$theme_domain_name);                      //$html .= < do some other work on the resource posts provided >               $html .= <<<LOAD                       {$load_more_text}                   LOAD;              return $html;       }     }     ?>          <?php     //root plugin file my-plugin.php          require_once dirname( __FILE__ ) .'/MyPlugin.php';          $MyPlugin = new MyPlugin();              add_action("plugins_loaded",function() {         load_plugin_textdomain(MyPlugin::$theme_domain_name , false, dirname( plugin_basename(__FILE__) ) . '/languages/');     });          $MyPlugin->init();     ?>


title: URL Rewriting if it is a single post / redirecting post - post type

text: I have a unique kind of question that I've been wrapping my brain around. Google is penalizing us with duplicate content because you can access our single blog posts both by going to:               http://www.domain.com/blog/the-post-slug      as well as :               http://www.domain.com/the-post-slug      The option we really want is:               http://www.domain.com/blog/the-post-slug      and if a user or googlebot happens to goto:               http://www.domain.com/the-post-slug       redirect them to:               http://www.domain.com/blog/the-post-slug      I know this is a particular situation, but we have many custom post types in our system. So our structure looks like this.               http://www.domain.com/food/pizza     http://www.domain.com/ice-cream/strawberry     http://www.domain.com/fireworks/bottle-rockets      Ideally, what I would like to do is find some kind of filter that logically checks if the post_type is post and redirect:               http://www.domain.com/the-post-slug       to               http://www.domain.com/blog/post-slug      I tried modifying the register_post_type for the post object, and adding with_front => false and adding blog to the slug, but that doesn't work. I was able to add /blog/%postname%/ to the permalink structure, and I was successfully able to have a decent structure going that was working, but I got stuck on the taxonomies. When I went to a taxonomy page, I had to goto:               http://www.domain.com/blog/the-taxonomy/flavors      and:               http://www.domain.com/the-taxonomy/flavors       was giving me a 404. So even if I can find a way to make the taxonomies work to where I can do:               http://www.domain.com/the-taxonomy/flavors      that would be awesome! As another side note, I also added with_front to the register_taxonomy, but that was not doing anything either. I even hard flushed the rewrites on all the changes I did. I know this is a lot, but my brain cannot go any further.. lol TIA! Any insight on this?


title: wordpress meta_box data don't save

text:
I made this metabox with an input item and two select items(a dropdown and a checkbox). When i write something in the input item or i select something it disappear when i update the post. Another bug: the permalink take the name from the selected value of another metabox and not from the title...how can i fix that? This is my code, i hope you can help me.               add_action('add_meta_boxes','program_detail');     function program_detail(){     add_meta_box('orario_id', 'Dettagli Programma', 'program_options','palinsesto', 'normal');     }          function program_options($post){               $values = get_post_custom( $post->ID );     $text = isset( $values['orario'] ) ? esc_attr( $values['orario'][0] ) : ”;     $selected = isset( $values['giorno'] ) ? esc_attr( $values['giorno'][0] ) : ”;     $check = isset( $values['replica'] ) ? esc_attr( $values['replica'][0] ) : ”;          ?>
Giorno:       <select name="giorno" id="giorno">         <option value="lunedì"<?php selected( $selected, 'lunedì' ); ?>>Lunedì</option>         <option value="martedì"<?php selected( $selected, 'martedì' ); ?>>Martedì</option>         <option value="mercoledì"<?php selected( $selected, 'mercoldì' ); ?>>Mercoledì</option>         <option value="giovedì"<?php selected( $selected, 'giovedì' ); ?>>Giovedì</option>         <option value="venerdì"<?php selected( $selected, 'venerdì' ); ?>>Venerdì</option>         <option value="sabato"<?php selected( $selected, 'sabato' ); ?>>Sabato</option>         <option value="domenica"<?php selected( $selected, 'domenica' ); ?>>Domenica</option>       </select>               Ora (formato hh:mm):           <input type="text" name="orario" id="orario" value="<?php echo $text; ?>" />

Selezionare se è la replica

      <input type="checkbox" id="replica" name="replica" <?php checked( $check, 'on' ); ?> />       Replica
          <?php     }                         add_action( 'save_post', 'program_options_save' );       function program_options_save( $post_id ){     if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id;     if ( ! current_user_can( 'edit_post', $post_id ) )     return $post_id;          if( isset( $_POST['orario'] ) )       update_post_meta( $post_id, 'orario', wp_kses( $_POST['orario'], $allowed )  );            if( isset( $_POST['giorno'] ) )       update_post_meta( $post_id, 'giorno', esc_attr( $_POST['giorno'] ) );            // This is purely my personal preference for saving check-boxes       $chk = isset( $_POST['replica'] ) && $_POST['replica'] ? 'on' : 'off';       update_post_meta( $post_id, 'replica', $chk );      }


title: Googles jQuery: Are There Avantages to Using It?

text: Are there any good reasons to pull Google's jQuery from their servers as opposed to using the one included with Wordpress? I'm confused as to why I might want to use Google's library. Doesn't Wordpress, with its frequent updates, keep the latest version? Or am I missing something? Thanks.


title: Image resizing - TimThumb vs convert on upload?

text: I'm using jQuery Supersized to display a full screen background slideshow on my blog, and I'm using mobile detection to serve a smaller version of the images to mobile devices so it will load faster. Which option do you think would be better?   1. Use TimThumb to dynamically resize the image size and jpeg quality   2. On upload of the image, create another version for mobile devices e.g. myimage_mobile.jpg Also, how do these conversion options compare in quality to resizing in photoshop? Thanks


title: Associate Taxonomies Across Post Types

text: Let's say I've created two custom post types, one called post_type_author and another called post_type_book. In each of these two custom post types, I've created a non-hierarchical taxonomy for tags. What is the best way to associate these two custom post type's taxonomies? Also, if I wanted to link these two along with the default "post" post type, how would that be done? What I want is to use the same non-hierarchical taxonomy "tags" for each of the three post types, so that a tag permalink called "Chicago", for example, will pull a post called "Saul Bellow" from the "post_type_author" custom post type. It should also pull a post called "Great Chicago Landmarks" from the "post_type_book" custom post type tagged "Chicago" AND another post from the default "post" post type that was also tagged "Chicago". Do I create two additional taxonomies and link them to the "post" post type taxonomy? Or is there a better way? I hope this makes sense and thanks very much.


title: search this custom post type

text: I am trying to be able to search a particular custom post type on my blog. The custom post type is named: **website_bookmarks** I have modified my search form with a hidden field               <input type="hidden" name="post_type" value="website_bookmarks" />       So on my search page in the URI I will see...               www.mydomain.com/?s=mysearchterm&post_type=website_bookmarks      The problem is it ONLY shows search results for my regular blog post and no results from my custom post type. It should not be showing any results for my blog post and ONLY results for my custom post type **website_bookmarks** Can someone help me? I can not figure out why it will not work and it will work on other people blogs simply by changing the search form to what I did above.


title: WP-PageNavi plugin doesn't work with multiple pages of search results

text: I'm using Dilectio theme and WP-PageNavi plugin. The plugin creates links to multiple pages perfectly on every page except for the search results page. For example, when I search for the keyword "lamp," it indicates there are 2 pages of search results. When I click on page 2, it takes me to page 2 of my blog, not page 2 of the search results. Can someone please help me fix this?


title: Pretty URLs or permalinks for attachments

text: Theres a way to convert links like: http://www.localhost.lh/?attachment_id=41 into: http://www.localhost.lh/attachment/id or: http://www.localhost.lh/author/attachment/id


title: Export blog posts with MathJax to LaTeX document?

text: I use MathJax to blog my mathematical thoughts. Is it possible to convert my WordPress posts (with plenty of math) into a LaTeX document? The plugin should prompt me to select posts for the paper, and should do the rest automatically.


title: Is there a way to use latex \cite{reference} in wordpress?

text: I am using QuickLatex plugin and it works great. But when I tried to cite some references using \cite{paper1}, it did not seem work.               [latexpage]     Here is a citation \cite{example}.          \begin{thebibliography}          \bibitem{example}     Robert C. Merton, On the Pricing of Corporate Debt: The Risk Structure of Interest Rates. \textit{Journal of Finance} 1974; \textbf{2}:449–470.          \end{thebibliography}      Any help?


title: Display Multiple Values of Same Key

text: I am going to put multiple value on custom field using same key (my key is link). So the value will be value A and value B And heres my custom field code for single value:               <a href="<?php $key="link"; echo get_post_meta($post->ID, $key, true); ?>" target="_blank">Images Source      So the question is ,how to display multiple value one? as you can see I have my code for single value already above.


title: Gallery shortcode numerical sorting

text: When I try to sort a Gallery created through the `[gallery]` shortcode by numerical titles I get them sorted in **alphabetical** order. That means that they are sorted like so:               1, 3, 34, 4, 56, 6, etc.      rather than so:               1, 3, 4, 6, 34, 56, etc.      Doing some research I came across **the section of the codex (in`WP_Query`)** explaining this issue. Apparently, setting the `orderby` parameter to `meta_value_num` would enable numerical sorting. Since `[gallery]` internally uses `get_posts()` (`wp- includes/media.php::714`), which in turn uses `WP_Query`, I thought the same rules would apply. Changing the `order_by` attribute in the shortcode to `meta_value_num` doesn't do the trick. I guess that most likely this is the case because I cannot set up the required `meta_key=keyname`. But not only can I not specify the meta key, I don't have one, and **I don't need one** because I mean to sort them numerically by title.


title: Simultaneous admin updates causes custom fields to not update

text: Okay, I have another doozie of a problem and although I'm still in the middle of trying to figure out exactly what's going on and what kind of help I might need, I thought I'd throw something up here and see if anyone else had seen an issue like this before. My site is currently running Wordpress 3.6 on a Linux server, and is hosted with Rackspace. At it's most basic level, my problem concerns updating custom fields for a post when the post is saved/updated. I've configured a few custom meta boxes that show up for a given post type (products, in this case). These custom meta boxes contain inputs and specifications for each of these products on both their own front-end post page and for other front-end pages on my site. I've attached a save function to the save action for the post (update button), so that the information contained in these meta boxes is all saved into a number of custom fields. I've accomplished this through the following method. Insert meta box:               function create_custom_products_taxonomies(){         register_post_type( 'products',             array(                 ...other inputs...                 'register_meta_box_cb' => 'products_meta_box',                 ...other inputs...             )         );     }     add_action('init', 'create_custom_products_taxonomies');          function products_meta_box() {         add_meta_box('custom_product_info', __('Top 10 Product Listings'), 'add_custom_page_product_info', 'products', 'normal', 'high');     }      Function definition:               function add_custom_page_product_info() {         ...code to populate meta box...     }      Save definition:               function save_acpi_data() {         ...code to save information in meta box...     }     add_action('save_post', 'save_acpi_data');      I add this all mostly just to show how I'm doing things. The way I have my code set up, is that the save function checks for data from the custom meta boxes and then saves the information into appropriately-named custom fields. I also have the save function set up to clean up after itself and delete any custom fields that are present which don't have associated meta box information present upon the post save/update. My problem comes in ONLY when there are multiple people logged into the admin side of my site and are updating/saving these pages. (We have approximately 700 products on the site and it takes multiple people to keep the site updated appropriately.) When this condition occurs, the data that is within my custom meta boxes (custom fields?) is somehow being deleted and is thus disappearing from my site. Right now my working theory is that the data that is getting passed through Wordpress on the admin-side page load and/or post save is getting truncated somehow. I'm basing this on the fact that when we have about 6-7 people logged into the admin side of the site and working on it, that the quad-core server we have the current site hosted on pegs the CPU to 100% for brief but repeated periods of time. Additionally, I've noticed that within my apache error logs, and during the times when multiple people are updating the site and data disappearing, there are errors showing up like the following:               Script timed out before returning headers: async-upload.php, referer: wp-admin/post.php?post=75064&action=edit&message=1     Script timed out before returning headers: async-upload.php, referer: wp-admin/post.php?post=75262&action=edit&message=10     Script timed out before returning headers: async-upload.php, referer: wp-admin/post.php?post=75269&action=edit&message=6      repeated multiple times. This issue with data loss hasn't been apparent before this last week, but then again prior to this last week there have only been 2-3 people working on the site at a given time. I also haven't been able to duplicate this problem to even the slightest degree on a second development server (identical server setup, Wordpress version, and theme code) when I'm the only person logged into the admin side. This most recent push of changes to our site has come after finding a few persistent errors on nearly every product page and wanting to fix all the errors within a reasonable amount of time. I'd like to just ignore the problem and say that it'll be over and gone as soon as these issues are fixed, but I know that it'll crop up again later, and besides, the issues that it's causing for the current site right now are quite impactful. We have a backup of the site and the team that's responsible for keeping it up are just having to copy this lost data from the backup to the current site. Over and over and... you get the picture. Right now I'm trying to mitigate the problem by checking that the amount of information present in my custom meta boxes is consistent with what is present when my save function goes to save (and cleanup) all the pertinent custom fields. (Check data on post save) I haven't yet been able to come up with a way to check if the data is being truncated on the admin-side page load and then deleted when the post is saved. In this case, the custom fields on the page would show as empty after a page load, even though the data would still be present in the database and "should" be showing. (Check data on admin page load for post) I've already scrubbed my entire site for php errors by accessing the information presented by setting WP_DEBUG to true, running through the front and back ends of the site with the Debug Bar plugin active, and also by scouring my apache error logs (apart from those errors mentioned above). I think this sufficiently describes the problem I'm seeing. I guess my questions for the community are:   1. Has anyone else ever seen this kind of behavior? (Lacking the "clean up" portion of my save function, this issue would present itself as information within meta boxes not being saved/updated to their corresponding custom fields when the post is saved.)   2. Is there something else I should be looking at? My only other option is to turn off the "clean up" portion of my save function and make the other guys manually delete all of the custom fields associated with the information they want to delete, which would be tedious for them but keep the site from deleting random information that we don't want gone. If I can't figure out a solution to this issue relatively soon, I may have to resort to this undesirable option. I'd rather just solve the problem though. Guess that's what I get for being an engineer though. :)


title: Issue on adding Icons to Custom Post Type

text: Can you please take a look at following code and let me know why i am not able to add icons to custom post type?               add_action( 'admin_head', 'my_icons' );     function my_icons() {?>     <style type="text/css" media="screen">      #menu-posts-product .wp-menu-image {      background: url(<?php bloginfo('url') ?>/wp-content/themes/BootWp/img/contactLensemenu.png) no-repeat 6px !important;}      .icon32-posts-product {      background: url(<?php bloginfo('url') ?>/wp-content/themes/BootWp/img/contactLensepage.png) no-repeat !important;         }     </style>     <?php }       I have checked the root and image file existence, they are all correct but the code not working


title: Category slug not showing for Custom Post Type

text: I have a Custom Post Type called 'shows' which makes use of the default Wordpress Category function. I can see my 'shows' posts on `/category/%postname%` URL's, but when I post the URL the slug looks like this: ![](http://i.stack.imgur.com/jzCnT.png) Any idea why `/shows/%category/%postname%` isn't pulling in the category? Live URL's look like this: ![](http://i.stack.imgur.com/2VWBv.png)


title: Missing Posts in Custom Taxonomy List

text: Symptom: A custom post type assigned to a taxonomy does not appear in the admin table listing all posts with a specific term attached. From my dashboard if I click on the taxonomy under the custom post type I get a list of terms. One term was showing 3 posts but when I clicked on the number 3 the resulting list showed only 2 posts. As a test I created a new custom post and assigned it to the same term. Now the list of terms shows that this term has 4 posts attached.However, clicking on the number 4 still gives me a list of 2 posts. I moved the posts to other terms and got the same result- namely 2 posts are still missing. I don't know where to look analyze this problem. I suspect I'm either doing something very stupid (I've checked the obvious things like the custom post being published) or perhaps something in my database is corrupted. I don't think there is any useful code I can provide. It seems to me that the problem is associated with the posts.I have a working version of this in a development site, which works perfectly. Now I attempting to recreate the same situation on the production site and this odd symptom has appeared. I'd appreciate any suggestions on additional information I might provide here or any likely investigations I can make to find the source of the problem.


title: Limit WP_get_archives by category?

text: I have two categories on a site - news which contains news posts and blog - which contains blog posts. Each page has a wp_get_archives in the sidebar. I'd like to limit the archive listing by category but after looking at the codex this does not seem possible. http://codex.wordpress.org/Function_Reference/wp_get_archives               <?php wp_get_archives('type=monthly&limit=12'); ?>      That code lists the archives for all the posts, but I want to list archives for just that category. Am I using the wrong function? Or is this not possible?


title: How we get_post_meta without post id

text: I want to get my all `posts-meta`, But on the base of `key`. For example the main query for getting the post-meta is                <?php $meta_values = get_post_meta($post_id, $key, $single); ?>       Now i want to get this `post-meta` on the base of `key` only. My current query to get the post-meta is               <?php echo get_post_meta($post->ID, 'custom_tags'.$userID, true); ?>      And i want to remove `$post->ID` from this query is there any way to get this. Thanks


title: WP_query multiple custom fields not working

text: I am currently using WP 3.1 and trying to get WP_QUERY to work with the custom fields. My argument is as follows:               $args = array(     'post_type' => 'post',     'meta_query' => array(         'relation' => 'OR',         array(             'key' => 'name',             'value' => "$s",             'compare' => 'LIKE'         ),         array(             'key' => 'address',             'value' => "$s",             'compare' => 'LIKE'              )       )     );      Basically searching the custom fields address and name, matching address OR name. I am not getting any results and printing the SQL query I am getting:               SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts     INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)     INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)     WHERE 1=1 AND wp_posts.post_type = 'post'     AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')     AND wp_postmeta.meta_key = 'name'     AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%tom%'     AND mt1.meta_key = 'address'     AND CAST(mt1.meta_value AS CHAR) LIKE '%tom%'     ORDER BY wp_posts.post_date DESC LIMIT 0, 10      So not sure why the SQL is not showing OR, highlighted in bold, but showing AND. I have also tried changing the relation, from OR to AND and the SQL remains identical. Not sure what I am doing wrong having followed the documentation located at: https://codex.wordpress.org/Class_Reference/WP_Query Also tried this:               $meta_query[] = array('key' => 'name','value' => $s ,'compare' => 'LIKE');     $meta_query[] = array('key' => 'address','value' => $s ,'compare' => 'LIKE');          $args = array(     'post_type' => 'post',     'relation' => 'OR',     'meta_query' => $meta_query     );          $the_query = new WP_Query( $args );      Appreciate your help Colin


title: Drop-down filter doesn't retrieve custom taxonomies

text: **Wordpress 3.0.4:** ![enter image description here](http://i.stack.imgur.com/DObG1.png) **Wordpress 3.1 RC4:** ![enter image description here](http://i.stack.imgur.com/guQgt.png) **functions.php (The last part is the one involved in filtering and displaying the drop-down menu):**               <?php          /**      * Create the Page Content custom post type and the Page Section custom taxonomy      */     add_action('init', 'my_init_method');          if (!class_exists('YourSite_PageContent')) {         class YourSite_PageContent {             static function on_load() {                 add_action('init',array(__CLASS__,'init'));                 add_filter('manage_page_content_posts_columns',                     array(__CLASS__,'manage_page_content_posts_columns'));                 add_filter('manage_posts_custom_column',                     array(__CLASS__,'manage_posts_custom_column'),10,2);                 add_action('restrict_manage_posts',                     array(__CLASS__,'restrict_manage_posts'));                 add_filter('parse_query',                     array(__CLASS__,'parse_query'));             }             // Register custom post types and custom taxonomies             static function init() {                 register_post_type('page_content',array(                     'labels' => array(                         'name' => __( 'Page Content' ),                         'singular_name' => __( 'Page Content' ),                         'add_new_item' => 'Add New Page Content',                         'edit_item' => 'Edit Page Content',                         'new_item' => 'New Page Content',                         'search_items' => 'Search Page Content',                         'not_found' => 'No Page Content found',                         'not_found_in_trash' => 'No Page Content found in trash',                     ),                     'public' => true,                     'hierarchical' => false,                     'taxonomies' => array( 'page_sections'),                     'supports' => array('title','editor','thumbnail','custom-fields'),                     'rewrite' => array('slug'=>'page_content','with_front'=>false),                 ));                 register_taxonomy('locations','page_content',array(                     'hierarchical' => true,                     'labels' => array(                         'name' => __( 'Locations' ),                         'singular_name' => __( 'Page Section' ),                         'add_new_item' => 'Add New Page Section',                         'edit_item' => 'Edit Page Section',                         'new_item' => 'New Page Section',                         'search_items' => 'Search Page Section',                         'not_found' => 'No Page Sections found',                         'not_found_in_trash' => 'No Page Sections found in trash',                         'all_items' => __( 'All Page Sections' ),                     ),                     'query_var' => true,                     'rewrite' => array( 'slug' => 'locations' ),                 ));                 register_taxonomy('page_sections','page_content',array(                     'hierarchical' => true,                     'labels' => array(                         'name' => __( 'Page Sections' ),                         'singular_name' => __( 'Page Section' ),                         'add_new_item' => 'Add New Page Section',                         'edit_item' => 'Edit Page Section',                         'new_item' => 'New Page Section',                         'search_items' => 'Search Page Section',                         'not_found' => 'No Page Sections found',                         'not_found_in_trash' => 'No Page Sections found in trash',                         'all_items' => __( 'All Page Sections' ),                     ),                     'query_var' => true,                     'rewrite' => array( 'slug' => 'page_sections' ),                 ));                 // Add initial terms                 if (!get_option('yoursite-page-content-initialized')) {                     $terms = array(                         'Footer',                         'Header',                         'Front Page Intro',                         'Front Page Content',                     );                     foreach($terms as $term) {                         if (!get_term_by('name',$term,'page_sections')) {                             wp_insert_term($term, 'page_sections');                         }                     }                     update_option('yoursite-page-content-initialized',true);                 }             }             //Arrange the position of elements in the table             function manage_page_content_posts_columns($columns) {                 $columns = array(                     'cb' => '<input type="checkbox" />',                     'title' => 'Name',                     'locations_column' => 'Locations',                     'page_sections_column' => 'Page Sections',                     'author' => 'Author',                     'date' => 'Date',                 );                 return $columns;             }             function manage_posts_custom_column( $column,$post_id ) {                 global $typenow;                 if ($typenow=='page_content') {                     $locations_taxonomy = 'locations';                     $page_sections_taxonomy = 'page_sections';                     switch ($column) {                     case 'locations_column':                         $locations_column = get_the_terms($post_id,$locations_taxonomy);                         if (is_array($locations_column)) {                             foreach($locations_column as $key => $locations) {                                 $edit_link = get_term_link($locations,$locations_taxonomy);                                 $locations_column[$key] = '' . $locations->name . '';                             }                             echo implode(' | ',$locations_column);                         }                         break;                     case 'page_sections_column':                         $page_sections_column = get_the_terms($post_id,$page_sections_taxonomy);                         if (is_array($page_sections_column)) {                             foreach($page_sections_column as $key => $page_sections) {                                 $edit_link = get_term_link($page_sections,$page_sections_taxonomy);                                 $page_sections_column[$key] = '' . $page_sections->name . '';                             }                             echo implode(' | ',$page_sections_column);                         }                         break;                     }                 }             }             function parse_query($query) {                 global $pagenow;                 $qv = &$query->query_vars;                 if ($pagenow=='edit.php' &&                     isset($qv['taxonomy']) && $qv['taxonomy']=='page_sections' &&                     isset($qv['term']) && is_numeric($qv['term'])) {                         $term = get_term_by('id',$qv['term'],'page_sections');                         $qv['term'] = $term->slug;                     }             }             function restrict_manage_posts() {                 global $typenow;                 global $wp_query;                 if ($typenow=='page_content') {                     $taxonomy = 'page_sections';                     $page_sections = get_taxonomy($taxonomy);                     wp_dropdown_categories(array(                         'show_option_all' =>  __("Show All {$page_sections->label}"),                         'taxonomy'        =>  $taxonomy,                         'name'            =>  $taxonomy,                         'orderby'         =>  'name',                         'selected'        =>  $wp_query->query['term'],                         'hierarchical'    =>  true,                         'depth'           =>  3,                         'show_count'      =>  true,  // This will give a view                         'hide_empty'      =>  true,   // This will give false positives, i.e. one's not empty related to the other terms. TODO: Fix that                     ));                 }             }         }         YourSite_PageContent::on_load();     }      Any suggestions?


title: Prevent Title Edit In post.php

text: I am looking for a way to disable the editing of a post's title when on post.php. I want the title of a post to remain "fixed", but editing of the content to be possible.                function my_remove_meta_boxes() {          if( !current_user_can('delete_published_posts') ) {                remove_meta_box('titlediv', 'post', 'normal');          }        }        add_action( 'admin_menu', 'my_remove_meta_boxes' );`      This will completely remove the title box, which somewhat achieves the goal, but I would ideally like to still be able to actually display the Title - just that it can't be edited


title: Rename "Add Media" Button To "Add Images"

text: I would like to rename the "Add Media" button (just above the post editor interface) to be "Add Images". I can't seem to find the appropriate filter for this. There seems to be a filter that has now been deprecated but I can't figure out what the new method is. The legacy filter was `media_buttons_context`.


title: Why are my WordPress post queries so slow?

text: I'm working on a larger WordPress site and trying to troubleshoot why my site is so slow. I've installed W3 Total Cache and have run multiple page speed and plugin tests with no luck. What's strange is that my pages load within 2 - 3 seconds but the initial server connection ("waiting for server") takes about 10 - 15 seconds. I looked into /var/log/mysqlslow.log and found massive queries like this one:               # Time: 131107 16:47:15     # User@Host: username/pw @ localhost []     # Query_time: 13.970453  Lock_time: 0.310980 Rows_sent: 3  Rows_examined: 16925     SET timestamp=1383871635;     SELECT distinct ID FROM wp_posts  INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE post_type = 'post' AND post_status = 'publish' AND ID<>1000040979 AND ID IN ('30460', '49942', ...      The IDs in parenthesis go on for pages and pages. They are incredibly long. Does anyone have a clue what's happening here and why these queries are so long?


title: Can't get simple meta queries to work

text: I cannot get this simple meta query to work and I have no idea why. I have a custom post type registered, called 'ef_project'. I have a few test posts created using post type, each with a postmeta field called 'project_status' - the values can be 'draft', 'inactive', 'expired' and I have created a few posts with each value. The query DOES return the 'ef_project' posts I created, but does not filter the list down to posts with a project_status meta field of 'draft' - instead it displays any ef_project post regardless of its 'project_status' meta field value. What am I doing wrong here?               // The Query     $the_query = new WP_Query(         array(         'post_type' => 'ef_project',          'meta_query' =>             array(                 array(                     'key' => 'project_status',                     'value' => 'draft',                     'type' => 'string',                     'compare' => '='                 )             ),         )     );          // Test Loop     if ( $the_query->have_posts() ) {         while ( $the_query->have_posts() ) {             $the_query->the_post();             echo '<li>' . get_the_title() . ' -  Status: ' . get_post_meta(get_the_ID(), 'project_status', true) .  '</li>';         }     }


title: Running a Gallery Shortcode in a Custom Fields Widget

text: I am creating a website for a Fringe Adelaide Venue, we have planned on displaying a gallery on each artist page. We are already using Custom Fields to place some unique content in a Custom Fields widget that we are including on the page. We have tried to place and execute the gallery shortcode inside of the Custom Fields widget, with no success. We need it to be in the widget so we can position it properly. The theme is Gantry, I am able to change plugins if necessary, but not theme. I have spent all day yesterday researching a solution and still have not succeeded. EDIT: The Widget we are using for Custom Fields is Custom Field Widget Cheers, Thomas


title: Custom Field: Display only if a specific key is selected outside the loop

text: I might be doing this all wrong. I have a custom field called "enable_adsense" and the value can be either "yes" or "no" What I'm trying to do is display something if the value is "yes" and something else if it's "no". Here's what I have so far:                   <?php     global $post;     $enable_adsense = get_post_meta($post->ID, 'enable_adsense', true);     var_dump($enable_adsense);     if ($enable_adsense == 'yes') { ?>              Adsense code goes here          <?php } else { ?>


title: Order users by number of posts (includes custom post type)

text: I am using the function below to count posts for users (including custom post types). I am putting together a list of users and want to order them by this count function. The orderby options for the get_users() function are limited, and post_count doesn't include custom post types. How can I order my users using this function? Function:               function foo_count_posts( $userid, $post_type = '', $post_status = 'publish') {         global $wpdb;              $query = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = $userid AND (post_type = 'post' OR post_type='foo') AND post_status = '$post_status'";          $counter = $wpdb->get_var($query);               return apply_filters( 'get_usernumposts', $counter, $userid );       }      Then I call the function to get the count:               echo foo_count_posts($user_id);


title: WordPress site seems convinced that it's still at its old URL

text: I had a demo environment set up in `/subdirectory/` and then moved it to my root directory to make the site live.   * Used the wp migrate db plugin to export my database with the new paths, then replaced all the database tables with my new export.   * I did a search and replace in PHPmyAdmin and replaced `/subdirectory` with `/`, just to make sure nothing was missed.   * _Copied_ all the content from `/subdirectory` to my the site's root Upon doing this, my site worked at the root URL, however, I noticed that the `bloginfo('template_directory');` and `get_template_directory_uri();` functions get the old URL! (`/subdirectory/wp-content/themes/my-theme/`). If I remove the `/subdirectory/` files, the site doesn't load (I just see a blank page). I went to my `index.php` to check on where `wp-blog-heaer.php` was being loaded from, making sure that it was referencing my root directory. I also added               update_option('siteurl', 'http://www.mysite.com' );     update_option('home', 'http://www.mysite.com' );      to both wp-config files. I even used the Search and Replace Database Script recommended in the Wordpress Codex to make sure I didn't miss anything in the database like serialized strings. Can't decipher why my site still thinks that it's in the old URL. Any ideas? _edit:_ My root .htaccess seems fine also. No mention of /subdirectory               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress


title: How to display custom user meta from registration in backend?

text: I'm considering using the hooks for the WordPress registration form to add some custom fields: https://codex.wordpress.org/Customizing_the_Registration_Form My question is, if it's even possible, how do I display some of these custom fields in the backend Users > All Users? For example if I have fields for 'zip code' and 'address', how would I display this data in the backend? Thanks.


title: Why only one post (and no pagination) on this variation of the loop?

text: This is my WP loop:               // fetch latest news stories     $paged = (get_query_var('page')) ? get_query_var('page') : 1;     $posts = get_posts(array(         'numberposts' => 3,         'paged' => $paged,     ));          // show results     if ( have_posts() ) {         while ( have_posts() ) {             the_post();              // display info about the post         }     }      Here's the problem: only the first post is showing, and the pagination isn't showing at all. Interestingly, I use the same code (from `// show results` down, since Wordpress sets up the posts to display for search results automatically) to display the results on my search page, and it works perfectly. I'd like to use this same display code (again, from `// show results` down) on all my blog-related archive pages: date archives, main blog page, tag-based archive, etc. I just need it to show more than one post and let my pagination show...


title: remove_query_arg() on rewrite rule

text: I'm attempting to add a `Back to Search Results` link which in essence will simply link back to the starting search page - for example `/?s=test`. I've taken a look at the global query vars and do see there is a `paged` query argument available -- which does do the job when the permalink structure is set to the default - for example `/?s=test&paged=2` run through `remove_query_arg(array('paged'))` corectly becomes `/?s=test`. But, when you visit a second page of search results and you use anything but the default permalink structure - it is not removing `page/2` which is what the default pagination structure outputs. I believe I could just use `$_GET['s']` and append that onto the site URL.. but I figured I'd ask here to see if there is a better way to do this. Thanks!


title: Get total number of pixels, size in megapixels and aspect ratio based on image width and height?

text: Is it possible to show total number of pixels, size in MP, aspect ratio of current featured image? For example I use this to echo image dimensions of full sized featured image of current post.               if ( has_post_thumbnail()) {        $full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');          // echo image width     echo $thumb_image_url[1];     // echo image height     echo $thumb_image_url[2];      And I get for example dimensions: 2048 x 1536. Is it possible to make separate functions to calculate:   1. Total number of pixels width x height? (example 2048 x 1536 = 3.145.728 pixels)   2. Transform total number of pixels in megapixels? (3.14 megapixel)   3. Function to calculate aspect ratio based on image width and height? (1,33:1 - 4:3 (screen)) More info about megapixel and aspect ratio calculator on: http://web.forret.com/tools/megapixel.asp * * * I would go little further also. I think it is possible to get aspect ratio as: standard (lansdcape), portrait or square (approximately). Standard (most used) image aspect ratio width / height is 4:3, landscape, which is mathematically also 1:1.3333333333333 (example 1600 x 1200 pixels photo). Portrait would be 0.75 (example 1600 x 1200 pixels photo). And square would be 1:1 ((example 1200 x 1200 pixels photo). What I think would be great is to make function which will check result of aspect ratio. If it is 1.33 (or even better if it is more than 1.2 in case image is little cropped) than to return "Landscape image". If it is 0.75 (or even better if it is less than 0.8 in case image is little cropped) than to return "Portrait image". If it is more that 0.8 but less than 1.2 than to return "Square like". Any suggestions?


title: Help Me Choose RSS or XML-RPC

text: **Scenario:** I have a mother site `example.com` which has a blog and say about 12 category. I also have 12 other wordpress site. Some in the subdomain of `example.com` and some are different domains. 12 Sites represent 12 category. When I Post on a category the post should be also posted to a appropriate category site. When I think about it I can do it via RSS and XML-RPC. But which one is the best choice for this purpose? I have to place code in the mother site for xml- rpc and child sites for RSS (using simplepie) **Here is some more Point that I have to focus:**   1. If i edit, delete posts on parent site the child site should be modified.   2. If I use xml-rpc What is the right way to save the username and password for child sites? Does xml-rpc on wordpress supports sending hashed password?   3. Using RSS is it possible to update or delete post according to mother site? Please share your experience to help me choose the better solution. Thanks!


title: Customizing the a tag with Semantic UI

text:
I'd like to use Semantic UI to aid development of a Wordpress template for a project. For a submenu I intend to use one of the Secondary sub menus found just at the bottom of the Pointing section. The problem I'm facing is that WP doesn't seem to allow customization of the tag. In Semantic UIs example, this is the code they use to generate a secondary sub menu, how would I implement this with WP?
                 Home                        Messages                        Friends
      So far I've implemented a menu by using the following code:
                    <?php wp_nav_menu( array( 'theme_location' => 'about-menu' ) ); ?>
      Though by doing this, WP displays the menu without any styling _underneath_ the rest of the menu items. Almost as though they're being pushed out. Can anyone help me with this?


title: Combining fancybox with multiple thumbnail plugin

text:
I'm combining fancybox(jquery) with multiple post thumbnail plugin. Basically the idea is when the user click the featured image post it will display the image on the secondary featured image. Here is the code that i'm working on.                    <?php query_posts('posts_per_page=-1&cat=10'); if(have_posts()) : while(have_posts()) :the_post(); ?>
                        <a class="fancybox" href="<?php MultiPostThumbnails::get_the_post_thumbnail(get_post_type, 'secondary-image'); ?>"><?php if ( has_post_thumbnail()) { $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large'); echo '';  } ?>

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

         <?php endwhile; endif; wp_reset_query();?>      The problem right now whenever i click the featured, it displays the featured image in the fancybox instead of the secondary image and the featured image disappears once i close the fancybox. Has anyone tried this approach when creating post featured image with fancybox. Here is a screenshot of what the output looks like ![enter image description here](http://i.stack.imgur.com/Ak1Ph.jpg) and here is a screen shot of what is set in the secondary image ![enter image description here](http://i.stack.imgur.com/3GqLv.jpg) This is the link for the website i'm building at the moment - http://digitalspin.ph/pluma/?page_id=8 http://i255.photobucket.com/albums/hh140/testament1234/second- image_zpsfb2bd810.jpg


title: Get the url of custom login page in the registration page

text: I am having trouble in getting the url of the page from where I click the register link. Scenario: The url of the login page is: > http://abcd.com/wp- > login.php?redirect_to=http%3A%2F%2Fabcd.com%2Fxtreme%2F&page=1406 And I when I click register link it should add the redirect_to link in the register page like this: > http://abcd.com/wp- > login.php?action=register&redirect_to=http%3A%2F%2Fabcd.com%2Fxtreme%2F&page=1406 I have used the following code but its not taking redirect_to parameter:               add_action( 'registration_redirect', 'redirection_link' );     function redirection_link( $redirect_to ) {       wp_redirect($GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI']);       exit;      }


title: related posts - pulling tags from a specific post type

text:
I'm currently using the following bit of code to display related posts on my single template.                   <?php             $orig_post = $post;             global $post;             $tags = wp_get_post_tags($post->ID);                  if ($tags) {                 $tag_ids = array();                 foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;                 $args=array(                     'tag__in' => $tag_ids,                     'post__not_in' => array($post->ID),                     'posts_per_page'=>5, // Number of related videos that will be shown.                     'caller_get_posts'=>1                 );                      $my_query = new wp_query( $args );                 if( $my_query->have_posts() ) {                     echo '

Related Videos

';                          while( $my_query->have_posts() ) {                     $my_query->the_post(); ?>
                         <a class="related-thumb" href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('related-thumb'); ?>
                             <a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?>

                          <? }                          echo '

';                 }             }                  $post = $orig_post;             wp_reset_query();      I'm wondering if there is a way I can pull tags from only a certain post type. Maybe adding something like `'post_type=videos'` somewhere? Not sure where, though. Can someone help me out? Thank you.


title: Updating to new 3.0.5

text: What is the best way to back up my data before I update to the newest version. And is it important I update?


title: Retrieving IDs of child pages which are in a different post type

text: I have a normal page, which has subpages in a custom post type. I've tried to get_pages based on the child_of parameter but it returns nothing. What is the best way to do this?


title: How do you create a "virtual" page in WordPress

text: I'm trying to create a custom API endpoint in WordPress, and I need to redirect requests to a virtual page in the root of WordPress to an actual page that ships with my plug-in. So basically, all requests to the one page are actually routed to the other. Example:   `http://mysite.com/my-api.php` => `http://mysite.com/wp-content/plugins/my- plugin/my-api.php` The point of this is to make the url for the API endpoint as short as possible (similar to `http://mysite.com/xmlrpc.php` but to ship the actual API endpoint file with the plug-in rather than requiring the user to move files around in their installation and/or hack core. My first stab was to add a custom rewrite rule. However, this had two problems.   1. The endpoint always had a trailing slash. It became `http://mysite.com/my-api.php/`   2. My rewrite rule was only ever partially applied. It wouldn't redirect to `wp-content/plugins...`, it would redirect to `index.php&wp-content/plugins...`. This lead to WordPress displaying either a page not found error or just defaulting to the homepage. Ideas? Suggestions?


title: Split WP install between 2 databases?

text: Is it possible for Wordpress to work from two databases? The reason I ask is that we're approaching our 100mb limit for database size on our host (1and1) but have up to 100 databases, so what I was hoping to do is essentially 'add on' another database for when the limit is reached?


title: Wordpress noob, assign custom stylesheet using @import or if? Didn't work for me

text: I'm trying to import independent stylesheets for the blog page, gallery page and the contact page but I'm having some trouble getting this to work.               <link rel="stylesheet" type="text/css" href="<?php bloginfo('http://www.dannysgallery.com/tracy/wp-content/themes/infocus/styles/deep_blue.css'); ?>" media="screen" />     <?php if(is_page_template('contact-4')) :?>     <link rel="stylesheet" type="text/css" href="<?php bloginfo('http://www.dannysgallery.com/tracy/contact-4'); ?>/contactstyles.css" media="screen" />     <?php endif;?>      This is the header:               <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">     <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>     <head profile="http://gmpg.org/xfn/11">     <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />          <title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title>          <link rel="stylesheet" href="<?php echo bloginfo('template_url'); ?>/lib/scripts/prettyPhoto/css/prettyPhoto.css" type="text/css" media="screen"/>     <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />          <?php require(WEBTREATS_INCLUDES . "/var.php"); ?>          <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('template_directory'); ?>/styles/<?php echo $color_scheme; ?>" />          <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />     <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />     <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />          <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>     <?php wp_head(); ?>           <meta name="disable_cufon" content="<?php echo $cufon_disable; ?>" />     <meta name="slider_speed" content="<?php echo $slider_speed; ?>" />     <meta name="slider_disable" content="<?php echo $slider_disable; ?>" />          <?php     $css_style_path = str_replace('.css', '', $color_scheme);     if($css_style_path == 'black') {         $css_style_path = '/images';     }else{         $css_style_path = '/styles/' .$css_style_path;     }     $template_dir = get_template_directory_uri();     if(is_home()) { ?>          <script type="text/javascript">     /* <![CDATA[ */     jQuery.preloadImages("<?php echo $template_dir.$css_style_path; ?>/home_feature.jpg","<?php echo $template_dir.$css_style_path; ?>/stage.jpg","<?php echo $template_dir.$css_style_path; ?>/header.jpg","<?php echo $template_dir; ?>/images/slider_inactive.png","<?php echo $template_dir; ?>/images/buttons.gif","<?php echo $template_dir.$css_style_path; ?>/buttons.gif","<?php echo $template_dir; ?>/images/slider_active.png","<?php echo $template_dir.$css_style_path; ?>/drop.png","<?php echo $template_dir.$css_style_path; ?>/dropR.png","<?php echo $template_dir.$css_style_path; ?>/drop_sub.png");     /* ]]> */     </script>     <?php } ?>          <!--[if IE 6]>     <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/styles/ie6/ie6.css" type="text/css" media="screen" />     <script src="<?php echo WEBTREATS_JS; ?>/DD_belatedPNG_0.0.8a-min.js"></script>     <script>         DD_belatedPNG.fix('#default_logo, .slider_frame');     </script>     <![endif]-->          </head>      Can anyone explain to me how to get this to work? Thank you Dan


title: Ajax mousedown call getting "cancelled" when clicking link

text: I'm trying to track registered user activity, specifically, when they click a link to a file for download. The filesystem plugin is WP-Filebase. I found that when I added a click() handler through jQuery, it wasn't happening, so I switched to a mousedown() handler for my Ajax-based tracking. What appears to be occurring (based on Firebug's Network activity monitor) is that if I press the mouse (mousedown) and then release, the resulting file download dialog box that occurs cancels the mousedown activity (Network tab shows the mousedown Ajax call as "cancelled"). The Ajax call therefore never makes it to the server and so I don't get my tracking. On the other hand, if I press the mouse and DON'T release for a while, I do get to see my test Ajax response, (an alert()). This is not viable for obvious reasons. Is there another solution? Can _both_ the mousedown and the anchor click work together, or will one always cancel the other? EDIT, here's some code that's behaving as I described (linkx.js):               (function($) {         $(document).ready(function(){             $('.wpfilebase-attachment a').mousedown(function(){                 var postParams = {};                 postParams['action'] = ZGAjax.TRACKING_ACTION;                 postParams[ZGAjax.FILE_ID_PARAM] = this.id;                      $.post(                     ZGAjax.ajaxurl,                      postParams,                     function( response ) {                         alert( response );                     }                 );                      return true;             });              });     })(jQuery);      And the handler on the php side...               // Add AJAX tracking of file downloads.     // First, add the link tracking script and create a global namespace to hold the admin_url() for the AJAX call     if (!is_admin()) add_action('wp_enqueue_scripts', 'gsn_add_tracking_script');     function gsn_add_tracking_script(){         wp_enqueue_script( 'zg-link-tracker', SCRIPTS_URI . '/linkx.js', array('jquery'), '1.0' );         wp_localize_script( 'zg-link-tracker', 'ZGAjax', array(              'ajaxurl' => admin_url( 'admin-ajax.php' ),             'TRACKING_ACTION' => TRACKING_ACTION,             'FILE_ID_PARAM' => FILE_ID_PARAM         ) );     }            // Works in conjunction with linkx.js      add_action( 'wp_ajax_' . TRACKING_ACTION, 'gsn_track_downloads' );          function gsn_track_downloads() {         // get the submitted parameters         $file_id = $_POST[FILE_ID_PARAM];              // generate the response         $response = json_encode( array( 'success' => true, 'file_id' => $file_id ) );              // response output         header( "Content-Type: application/json" );         echo $response;              // IMPORTANT: don't forget to "exit"         exit;     }      The PHP side is pretty textbook, and really just sends me back a confirmation that it worked. And it DOES work, if I keep my mouse button held down long enough for the entire transaction to complete. If I release, and thus allows the download to begin, I never get the confirmation. Firebug tells me that the Ajax request is "cancelled" so it's not even a matter of the transaction piggy-backing on top of the download transaction (which was a wild theory in the first place).


title: How to extract image width from add_image_size?

text: How can I extract the width of an image as defined in `add_image_size` for use as a template variable? For example if my theme defines the size _small_ as `add_image_size( 'small', 195, 146, true );` _195_ would be the variable. I am trying to build a dynamic _mshots_ url.