How to: Retrieve an attachment image from post and output it

If anyone can help me I would be gratefull! * * * I got a _gravity form_ with the post_type fields including the submit image when submited it displays the:   * title   * content    * image    * tags **So my question is:** When I go to single.php I posted a code: `get_related_author_posts();` which calls the authors last two posts in function.php. _Please take a look at the code, that contains/illustrates the problem:http://pastie.org/1926079_ * * * I need a little help from my friends the wordpress gurus :) Thank You all in advance. I'm still learning the more advanced functions but this is where I'm stuck:)


menu link to custom post_type?

is there a way to add a custom post_type (directors) link to a menu? I can add the individual director posts but not the link to all of them. I'd like to avoid using custom links as this will be used in several sites and not always at the root. (so making a default /directors/ wont always work). PLus i'd like it to behave like normal menu links when active etc. best, Dan.


Settings API erases itself?

I have two forms created using Settings API, and when I save one of them the other one gets erased and vice versa. Here's the whole code so you could paste it into your functions.php file and see for yourself:               // Register settings     function registerSettings() {          register_setting('XX_theme_settings', 'XX_theme_settings' );          add_settings_section('theme_options', 'Theme Options', 'theme_options_generate', 'page1' );      add_settings_field( 'XX_Option1', 'Option 1', 'text_input', 'page1', 'theme_options', 'XX_Option1' );     add_settings_field( 'XX_Option2', 'Option 2', 'text_input', 'page1', 'theme_options', 'XX_Option2' );      add_settings_field( 'XX_Option3', 'Option 3', 'textarea', 'page1', 'theme_options', 'XX_Option3');       add_settings_field( 'XX_Option4', 'Option 4', 'textarea', 'page1', 'theme_options', 'XX_Option4');            add_settings_section('theme_options2', 'Theme Options2', 'theme_options_generate2', 'page2' );      add_settings_field( 'XX_Option5', 'Option 5', 'text_input', 'page2', 'theme_options2', 'XX_Option5' );     add_settings_field( 'XX_Option6', 'Option 6', 'text_input', 'page2', 'theme_options2', 'XX_Option6' );      add_settings_field( 'XX_Option7', 'Option 7', 'textarea', 'page2', 'theme_options2', 'XX_Option7');       add_settings_field( 'XX_Option8', 'Option 8', 'textarea', 'page2', 'theme_options2', 'XX_Option8');               };          add_action('admin_init', 'registerSettings');          //Generate section 1         function theme_options_generate() {          echo 'This is a Settings Section 1';      }     //Generate section 2     function theme_options_generate2() {          echo 'This is a Settings Section 2';      }          //Generate text input callback         function text_input($args) {         $options = get_option('XX_theme_settings');         echo "<input id=". $args ." name='XX_theme_settings[". $args ."]' size='40' type='text' value='{$options[$args]}' />";         }          //Generate textarea callback          function textarea($args) {         $options = get_option('XX_theme_settings');         echo "<textarea id=". $args ." name='XX_theme_settings[". $args ."]' rows='7' cols='50' type='textarea'>{$options[$args]}</textarea>";      }          //Add admin pages     function registerMenus() {          add_menu_page('Theme Options', 'Theme Options', 'edit_theme_options', 'theme_menu_slug', 'theme_options_page');      add_menu_page('Theme Options2', 'Theme Options2', 'edit_theme_options', 'theme_menu_slug2', 'theme_options_page2');           };          add_action('admin_menu', 'RegisterMenus');           //Generate Page1 form     function theme_options_page() { ?>        <form action="options.php" method="post">        <?php settings_fields('XX_theme_settings'); do_settings_sections('page1'); ?>
  <input name="Submit" type="submit" class="button-primary" value="<?php _e('Save Changes'); ?>" />
         </form>
<?php echo var_dump(get_option('XX_theme_settings')); ?>
          <?php }          //Generate Page2 form     function theme_options_page2() { ?>         <form action="options.php" method="post">        <?php settings_fields('XX_theme_settings'); do_settings_sections('page2'); ?>
  <input name="Submit" type="submit" class="button-primary" value="<?php _e('Save Changes'); ?>" />
         </form>
<?php echo var_dump(get_option('XX_theme_settings')); ?>
          <?php } ?>      I know I'm not validating data (yet), but I guess it should just work (and not earse the whole array every time) out of the box, right? What went wrong?


plugin_dir_url() adds path to url

For some reason I get the following output from               var_dump( plugin_dir_url( __FILE__ ) );      > http://local.dev/wp-content/plugins/C:/development/xampp/htdocs/vanilla/wp- > content/themes/twentyeleven/ in a local install. Note: I deactivated **all** plugins and added the line on top of the `functions.php` file of the default and unmodified TwentyEleven Theme


How to redirect a virtual page (e.g. /blog) to the home page?

I want my to reach my website's main page when entering an url like: http://example.com/blog However, I can't seem to get it to work with a typical rewrite rule:               RewriteRule ^/blog$ /      I'm always taken to my site's 404 page. Works fine if I specify a specific file (e.g. "/foo.html") instead of "/", but "/index.php" doesnt't work. How can I make this work?


Creating directory in uploads - wp_mkdir_p() or WP_Filesystem?

I don't think I ever had practical need to create folders/files in WP before, but for a plugin I need cache (for resized images) folder in `wp- content/uploads`. Which raises the question - do I really need to go through all the process with `Filesystem API` (including messily asking for FTP credentials when needed), or `wp_mkdir_p()` is good enough for this?


Edit the "Post updated. View post" link

Is it possible to edit the "Post updated. View post" link and remove the "View post" entirely? Also change the "Post" to the name of a cpt? Thanks guys! Update: Here is the code I used and it worked like a charm. I hope this helps others! In my example I use "Contact" as my cpt: ![enter image description here](http://i.stack.imgur.com/0RQL8.png) `               add_filter('post_updated_messages', 'contact_updated_messages');     function contact_updated_messages( $messages ) {          $messages['contact'] = array(     0 => '', // Unused. Messages start at index 1.     1 => sprintf( __('Contact updated. View Contact'), esc_url( get_permalink($post_ID) ) ),     2 => __('Custom field updated.'),     3 => __('Custom field deleted.'),     4 => __('Contact updated.'),     /* translators: %s: date and time of the revision */     5 => isset($_GET['revision']) ? sprintf( __('Contact restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,     6 => sprintf( __('Contact published. View Contact'), esc_url( get_permalink($post_ID) ) ),     7 => __('Contact saved.'),     8 => sprintf( __('Contact submitted. Preview Contact'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),     9 => sprintf( __('Contact scheduled for: %1$s. Preview Contact'),       // translators: Publish box date format, see http://php.net/date       date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),     10 => sprintf( __('Contact draft updated. Preview Contact'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),     );          return $messages;     }      `


How to enable suggested edits?

I like the idea of enabling any user of my website to suggest edits to a page. Much like the edit system on Stack Exchange but different in that anyone should be able to edit, not just registered users. All edits would go through an approval process. How could I implement that?


Which freelance sites are recommended to find WordPress developers/programmers, etc

I've been using drupal for a few years and it's overkill. I want to pay someone to migrate my content (blog posts and pages) over to wordpress without spending more than is necessary. Is there a specific site such as odesk, elance, guru, rentacoder, etc. that is popular with wordpress programmers and tends to have the best rates? Thanks...


How we count the user draft posts

I am trying to use the total posts count currently i am using the this query               $args=array(     'author' => $userID,     'post_type' => 'post',     'post_status' => $poststatus,     'posts_per_page' => 212     );     <?php echo count_user_posts($args); ?>      `$poststatus` have 2 options `draft` and `publish`. But when i run this query one condition work good and that is `publish`. but when i try to run `draft` it not showing correct count of draft posts. So tell me where i am wrong in the query.


Restrict certain actions to plugin-specific admin menu pages only

I'm working on a plugin and want to restrict some things to my plugin-specific admin menu pages only. Therefore, I write the slugs being returned when adding (sub)menu pages into an array so I can check later on the current page against it. The problem seems to be that `get_current_screen` is returning **`null`** when called from/before `admin_init`. I add the menu pages, however, hooked to `admin_menu` \- which is before `admin_init`. Here is the **not working** code:               add_action( 'admin_menu', 'my_admin_menu' );     function my_admin_menu() {         // Set up plugin admin menu         $menu_pages = array();         $menu_pages[] = add_menu_page( ... );         $menu_pages[] = add_submenu_page( ... );              $screen = get_current_screen(); // UNFORTUNATELY, $screen is null here         $screen = $screen->id;         foreach ( $menu_pages as $page ) if ( $screen === $page ) {             // Do plugin-specific stuff         }     } // function my_admin_menu      So, do I really have to store the pages array in a way that I can access it later in a function hooked somewhere after `admin_init`? I thought about just using the page slugs where I defined the pages and then forget about it. As toscho pointed out, one may use the _slugs_ as hooks (what they actually are):               $page = add_menu_page( ... );     add_action( $page, ... );      However, when in need of the **current screen** , that hook is located too early in the chain, so one could/should use `add_action( 'load-' . $page, ...);` instead.


Disable Jquery UI post tabs

Hey all, I'm using Jquery UI tabs with the WordPress Post Tabs plugin and it works like a charm. However, I'd like to auto disable or hide tabs that do not have any data. I've worked with Jquery quite a bit but I'm lost in this mess. Any help would be appreciated. Thanks! Jquery Tabs Information from the official site Initialize a tabs with the disabled option specified.               $( ".selector" ).tabs({ disabled: true });      Get or set the disabled option, after init.               var disabled = $( ".selector" ).tabs( "option", "disabled" );     //setter     $( ".selector" ).tabs( "option", "disabled", true );      * * * Found in wordpress-post-tabs.php line 105                  <script type="text/javascript">         jQuery(function() {         <?php          if($wpts_count and $wpts_count!=0){            for($i=0;$i<$wpts_count;$i++) {   ?>             jQuery("#tabs_<?php echo $i;?>").tabs({ cookie: { expires: 30 } });             //getter             var cookie = jQuery("#tabs_<?php echo $i;?>").tabs( "option", "cookie" );             //setter             jQuery("#tabs_<?php echo $i;?>").tabs( "option", "cookie", { expires: 30 } );             <?php if(isset($wpts['fade']) and $wpts['fade']=='1'){ ?>                 //fx for animation                 jQuery("#tabs_<?php echo $i;?>").tabs({ fx: { opacity: 'toggle' } });                 //getter                 var fx = jQuery("#tabs_<?php echo $i;?>").tabs( "option", "fx" );                 //setter                 jQuery("#tabs_<?php echo $i;?>").tabs( "option", "fx", { opacity: 'toggle' } );            <?php }}} ?>          });     <?php if($wpts['reload']=='1') { ?>         function wptReload(ar)         {          location.href=location.href.split(/\?|#/)[0] + '#' + ar;            location.reload(true);          return false;         }     <?php } ?>         </script>


Troubles with making a custom template for posts

Is it possible to make a template for all posts in a custom post type? For example I would like to be able to change an adsense ad or some other element on every post by simply editing a custom template. I have been experimenting with templates that are pretty static, but I am stumped on which one to copy/edit for the posts.


Difference between esc_url() and esc_url_raw()

http://core.trac.wordpress.org/browser/trunk/wp-includes/formatting.php#L2239 I'm confused about when should either of them be used. Assuming I have this URL: `http://site.com/?getsomejavascript=1`, which is dynamically generated javascript:   * if I include the script with `esc_url(add_query_arg('apples', 420))`, I get `http://site.com/?getsomejavascript=1&apples=420` and it breaks because of those `#038;` references   * if I use `esc_url_raw(add_query_arg('apples', 420))` I get the correct URL: `http://site.com/?getsomejavascript=1&apples=420` but in the documentation I find out that esc_url_raw should only be used to escape URLs inserted in the database...


What characters are allowed as a shortcode tag and how should they be sanitized?

I am working on a plugin where the user can define shortcode tags himself. What would you suggest to allow in there? My thought is only allow ascii characters. So how do I sanitize? `strip_tags` and then regex to allow only `a-z, 0-9` or is there a better solution? Does WordPress have filter for that? Could I maybe use the filter WordPress uses for slugs? thanks for the answers i will just do this, if there must be one ascii char anyway then i just require three.               foreach ( $shortcodes as $key => $var ) {          $var = preg_replace('/[^a-z0-9_]/', '', $var ); // strip away everything except a-z,0-9 underscore          if ( strlen($var) < 3 )         continue; // if less then 3 chars AFTER the strip don't save


loop over all custom taxonomies for current custom post type and their values

What I want to do: I have four custom post types. I only want to use one, which I can do like this: `$current_posttype = get_post_type( $post->ID ); // get current post type `. Next up, I want to loop through all the custom taxonomies that are attached to that custom post type. So, for example:               custom post type: movies     custom taxonomy 1: genre     custom taxonomy 2: rating     custom taxonomy 3: year     and so on..      I want to output the following (for the current post):               genre: Western     rating: 4     year: 2000      What I do know is that I can use the following code to output all terms of a custom taxonomy.               // Get terms for post      $terms = get_the_terms( $post->ID , 'genre' );           // Loop over each item since it's an array      if ( $terms != null ){         foreach( $terms as $term ) {          // Print the name method from $term which is an OBJECT      if ( $term->name != null ) {      ?></br><?php print $term->name ;      // Get rid of the other data stored in the object, since it's not needed      }      else {      }       unset($term);     } }       What I don't know is how to loop over this, with a foreach loop. I can't figure it out. Any help or suggestions? Thanks.


How to modify the default feed via a function

I am trying to add a functionality to the default wordpress feed. The problem is i managed to do this modifying the rss feed php file. The problem number two that i have in mind is when wp gets an update also that file will be updated and my code will disappear. So i am looking to for a way to insert my code as a filter or something else for the rss feed. Note: **My code does not modify the default feed content, instead i want to display another feed from external site.**               add_filter( 'the_name_for_the_rss_filter', 'my_function' );          function my_function( $some_var ){ global $some_var;          if($some_var == true){          // let's say:      // echo file_get_contents("http://example.com/feed/");     // exit(0);          }          }


why is the current page title being output?

this is in my sidebar.php file, which is pulled in in the header.php file (is this bad practice?). anyways, the last item in the list is the current page title, despite my query_posts with an args of only the custom post type of newsletters               <?php        if (function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar Widget')) : else : ?>

Newsletters

       <?php          $args = array ('post_type' => 'newsletters');         query_posts($args);         if (have_posts()) : while (have_posts()) : the_post();?>
<a href="<?php the_field('pdf');?>"><?php the_title();?>
            <?php wp_reset_query(); endwhile; endif; ?>


Resolve a custom post type name vs. page permalink conflict (same slug)

I have a custom post type called "visningshus", and also a Page with that slug. This is as it should (must) be. Currently, "http://my-site.com/visningshus" lists all posts of that type. I want to show the page that has that permalink slug instead. How can I make Wordpress not make the post type name take precedence, but instead the permalink, and show the Page?


wordpress JSONAPI introspector always limits number at 10?

I'm a little new to Wordpress and the JSON API so forgive me if this is a newbie question but i'm trying to get _all_ of the posts of a few different custom post types and return them as JSON via my own JSON controller (extending the JSON API) if I do this:               $posts = $json_api->introspector->get_posts(array('post_type' => array('post','tweet','gallery','video','music'), 'post_parent' => 0, 'order' => 'ASC', 'orderby' => 'date', 'numberposts' => 100000000000));     echo count($posts);      I only get "10" posts but there are a lot more in the db. Whereas if I do this:               echo count(get_posts(array('post_type' => array('post','tweet','gallery','video','music'), 'post_parent' => 0, 'order' => 'ASC', 'orderby' => 'date', 'numberposts' => 100000000000)));      I get "74", the correct number of posts in the db. Essentially the JSON API is limiting the returned value to only 10 posts. I'm pretty sure I can hack the JSON API plugin to allow more but that seems like it would mess up my code for any API upgrades. Is there a way to set the JSONAPI->introspector post number to "all" Thanks [Mods: I have cross posted this in stack overflow a minute ago but wasn't sure which site would be better to post this question please let me know and I'll remove as appropriate]


Add a drop down list to comment form?

Can somebody help me to create a drop-down menu or (radio buttons) in Wordpress comment form, so that a new user could make a selection of their user roles (for example teachers + students) ?   1. Output from dropdown list or radio button would appear somewhere in the comments area.    2. The best of all would also be if WordPress which already automatically populate   email, login name would also display new extra field info (dropdown list OR   radio button) to logged in users who already has their user roles assigned   3. I don't want to use a plugin for that.   4. I know that there a lot of tutorials about adding extra custom fields to the comment form including this web where I have found 3 similar requests unfortunately marked as duplicates, on my opinion they are not dups at all, because there's no code or tutorial for using known values as (select - dropdown- radio) button.


Secure way to use name_save_pre?

I created a custom post where I need to change the post name regarding to the custom field and taxonomy values. This is how I did it:               add_filter('name_save_pre', 'save_name');     function save_name($name_to_ignore) {              global $post, $meta_box, $wpdb;               $this_post_id = $post->ID;              // verify nonce -- checks that the user has access          if ( !isset($_POST['wp_nonce']) || !wp_verify_nonce( $_POST['wp_nonce'], basename(__FILE__) )) {             return $post_id;         }              if ($_POST['post_type'] == 'mytype') :               $name1 = $_POST['term1'];               $name2 = $_POST['term2'];               $name3 = $_POST['custom_field_1'];               $name4 = $_POST['custom_field_2'];               $my_post_name = $name1."-".$name2."-".$name3."-".$name4."-".$this_post_id;             endif;             return $my_post_name;     }      I just want to is it secure to save the data this way. Cause I read somewhere else (which is I forgot where), said that using $_POST['Custom_field']; is very easy to get hacked. Is it true?


How to make wordpress folder (/wordpress) redirect to /?

I have my website setup with Wordpress in its own folder. The URL website.com/wordpress is currently a 404 (which makes sense since the page doesn't exist), but I want it to redirect back to the root. I've tried using the Redirection plugin to setup the redirect, but it is still a 404. Any ideas?


Functions.php code that only runs on localhost?

I would like to run an add_action in functions.php only if the theme is being loaded from my localhost development site. How would I get this to run only on localhost?               function livereload(){     ?>         // mycode      <?php     }     add_action('headway_body_close', 'livereload');


custom post type and taxonomies in a php class

I used this class in the tutorial to create two custom post types http://code.tutsplus.com/articles/custom-post-type-helper-class--wp-25104 According to `add_taxonomy()` function if the taxonomy already exists then `$E2` will be added to that taxonomy. this is achieved by using `taxonomy_exists()`               if( ! taxonomy_exists( $taxonomy_name ) )     {         /* Create taxonomy and attach it to the object type (post type) */         // register_taxonomy()     }     else     {         /* The taxonomy already exists. We are going to attach the existing taxonomy to the object type (post type) */        // register_taxonomy_for_object_type()     }      here logic is correct but when ever i register a taxonomy for two post_type's only the second post_type will get this taxonomy, first post_type will not be registered with taxonomy               $E1 = new Custom_Post_Type('E1');        $E2 = new Custom_Post_Type('E2');          $E1->add_taxonomy( 'tax1' );        $E2->add_taxonomy( 'tax1' );      upon debugging i found out that `taxonomy_exists()` returns false even when taxonomy is registered. I tried making $wp_taxonomies global since it holds all taxonomies, but no use. so problem is with detecting whether a taxonomy is already registered or not.


Good way to store content and settings for an RSS plugin

I am building an RSS reader plugin and I'd like some advice on how to store the data and settings for this plugin. The idea is to be able to enter a set of feed sources and associate each one of these sources with one or more categories. Thus you can have several categories e.g. sports, politics each having their own associated feed sources. So for example:   * Sports      * ESPN.com     * Sportingnews.com When the feed items from these feed sources are imported every few hours via Cron they are then stored as custom post types. Each feed item must of course be associated with the feed source. When it comes to display feed items the plugin will use this logic:   1. Check which category is being called (via shortcode)   2. Check which feed sources are associated with that category   3. Get feed items associated with feed sources identified in step 2 I am still unsure about how all this data needs to be stored. The plugin will have a settings page and for that I am settled about storing everything in the wp_options table. However when it comes to the feed sources, categories and feed items, I'm still confused how to store them best. Any suggestions on how to do this? I've been reading about the CPTonomies plugin which seems to do what I need, but I want the functionality in built into this plugin and I cannot use another external plugin.


Thumbnail & Category link aside post

I've been trying to figure out for days how http://quotelicious.com was able to place thumbnails and category links in a separate box alongside the actual post. Any ideas?


Making images in posts link to the image file rather than the attachment page

So I've got a bunch of content with images inserted into them. The users inserting content have done the default option of linking to the attachment page which isn't great. I've altered the               image_default_link_type setting to make this link to the **file** by default now. But I'd like to use a light box or something to display images on the site, which requires the to go to the image file, not the attachment page. Whilst I can make this work for images added since the default was changed, I was wondering if there was any solution that could make this change for me that was not going through and altering the content of each post? TIA, Dan.


Add menu headings to Wordpress sub menus

I'm using the native Wordpress menu. I have two top-level links with sub menus - I'd like for those sub menus to display the name of the parent menu item. So if I have a parent menu item named "Gardens" containing a sub menu of "Flowers" and "Plants", that sub menu should say "Gardens" at the top, and then list the sub menu links below it. I've gotten as far as creating a walker to insert some H3 heading text in the sub menu. It looks like this:               class Subnav_Header_Walker extends Walker_Nav_Menu     {         function start_lvl( &$output, $depth = 0, $args = array() ) {             $heading = 'Heading Text Here';             $indent = str_repeat("\t", $depth);             $output .= "\n$indent

" . $heading . "
\n";         }         function end_lvl( &$output, $depth = 0, $args = array() ) {             $indent = str_repeat("\t", $depth);             $output .= "$indent
\n";         }     }      It's not great, but it's working. Now I just need some code to get the name of the parent menu item. Can anyone help me with this? Thanks!


How to list categories and subcategories in JSON format?

I need to integrate this plugin with my WordPress site, and the categories must be in this format:                "Option 1": {"Suboption":200},      "Option 2": {"Suboption 2": {"Subsub 1":201, "Subsub 2":202},                     "Suboption 3": {"Subsub 3":203, "Subsub 4":204, "Subsub 5":205}                    }      How can I get that?   I tried the options of the json-api. And this is the walker:                 class MyWalker extends Walker_Category {         var $tree_type = 'category';              var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');              function start_lvl( &$output, $depth, $args = array() ) {             if ( 'list' != $args['style'] )                 return;                  $indent = str_repeat("\t", $depth);             $output .= "$indent:{";         }              function end_lvl( &$output, $depth, $args = array() ) {             if ( 'list' != $args['style'] )                 return;                  $indent = str_repeat("\t", $depth);             $output .= "$indent}\n";         }              function start_el($output, $category, $depth , $args = array() ) {             extract($args);             $cat_name = esc_attr( $category->name );             $cat_name = apply_filters( 'list_cats', $cat_name, $category );             $output .= '"' . $cat_name.'=>'.$depth . '",';         }              function end_el($output, $page, $depth = 0, $args = array() ) {             if ( 'list' != $args['style'] )                 return;                  $output .= "\n";         }     }


wordpress illegal string offset 'parameter' error

I am getting the error illegal string offset when creating a checkbox in the admin. my code look like this.               <input  type="checkbox"  id="slideThre" name="custom_settings[checked]" value="1" <?php checked(1, $custom_options['checked']);?>/>      There is no error when I check the box and save. The error appear when I uncheck the box and save. What could be wrong? thanks.


bloginfo() and get_template_directory_uri() with SSL?

I have a Wordpress theme I'm attempting to put on an SSL-only website. There is no non-SSL version of the site. The Wordpress theme uses various functions like `bloginfo('pingback_url')`, `bloginfo('template_directory')`, `get_template_directory_uri()`, etc... All the typical functions for a theme. All of these functions generate `http` links, not `https`, so therefore none of them load, since a non-SSL version of the site does not exist. How do I force Wordpress to use `https` for EVERYTHING?


Can I use one wordpress plugin twice in a website?

I'm using Contact Form 7. I have used it once in my wordpress website as a simple contact form. Now I have to add another contact form for registration process if someone would like to apply for a job. Now, do I have to install again the plugin? Or can I use it again? I would like also to add some function on the registration form for the applicants.


Protocol neutral URLS with wp_enqueue_script (SSL issues)?

How do I use wp_enqueue_script so that I get protocol neutral URLs? Here is how I'm currently using it: `<?php wp_enqueue_script('name', get_bloginfo('template_directory'). '/js/name.pack.js'); ?>` I saw that `home_url()` is protocol aware so I figured `theme_url()` would be also but I'm getting the error below when I use it. `Call to undefined function theme_url()`


query_posts result differs from wp_query request result

I have a multisite Wordpress setup (3.5.1, I cannot risk updating) on which I am querying some posts after having switched to the correct blog. I have a query_posts function with the following parameters:               $posts = query_posts('posts_per_page=5&paged=1&post_status=publish&orderby=date&order=desc');      from this query of posts the query_vars becomes (`$GLOBALS['wp_query']->query_vars`):               Array (         [posts_per_page] => 5          [paged] => 1          [post_status] => publish          [orderby] => date          [order] => desc          [error] => [m] => 0          [p] => 0          [post_parent] =>           [subpost] =>           [subpost_id] =>           [attachment] =>           [attachment_id] => 0           [name] =>           [static] =>           [pagename] =>           [page_id] => 0           [second] =>           [minute] =>           [hour] =>           [day] => 0           [monthnum] => 0           [year] => 0           [w] => 0           [category_name] =>           [tag] =>           [cat] =>           [tag_id] =>           [author_name] =>           [feed] =>           [tb] =>           [comments_popup] =>           [meta_key] =>           [meta_value] =>           [preview] =>           [s] =>           [sentence] =>           [fields] =>           [menu_order] =>           [category__in] => Array ( )           [category__not_in] => Array ( )           [category__and] => Array ( )           [post__in] => Array ( )           [post__not_in] => Array ( )           [tag__in] => Array ( )           [tag__not_in] => Array ( )           [tag__and] => Array ( )           [tag_slug__in] => Array ( )           [tag_slug__and] => Array ( )           [ignore_sticky_posts] =>           [suppress_filters] =>           [cache_results] => 1           [update_post_term_cache] => 1           [update_post_meta_cache] => 1           [post_type] =>           [nopaging] =>           [comments_per_page] => 50           [no_found_rows] =>      )      The query Wordpress says it executes to find these posts is then (`$GLOBALS['wp_query']->request`):               SELECT SQL_CALC_FOUND_ROWS wp_5_posts.ID      FROM wp_5_posts      WHERE 1=1 AND wp_5_posts.post_type = 'post' AND (wp_5_posts.post_status = 'publish')      ORDER BY wp_5_posts.post_date desc LIMIT 0, 5      If I execute this query on the database the resulting IDs are:               12059     12046     12038     12030     12026      However, if I loop over the posts:               foreach($posts as $p){         echo($p->ID."<br>");     }      I get the following ID's:               11741     11721     11643     12059     12046     12038     12030     12026      Does anyone know how this is possible? The array $posts is empty before calling query_posts and I do not understand why these posts occur in the array. If I select these posts in my MySQL database by hand there is no noticeable difference between them that would make the first three special in some way, and all three are older than the other 5 requested. Thanks in advance!


Why is Posts page selected when showing single Custom Post Type?

In Settings-Reading I have selected a static page from my "Front page displays". My Front page is "Home" and my Posts page is "News". I have also added a Custom Post Type called "Project" without an archive or a slug and I have added a page "Projects" which uses the template `projects.php`. So far so good, all is working, except one thing. When I visit a single Project (CPT), in my top navigation "News" becomes selected. In the body-tag it gets the class `single single-project postid-114 single-format-standard logged-in` And in the nav-menu News has a class of `page_item page-item-6 current_page_parent`. I don't understand why this (News getting the `current_page_parent`-class) would be happening, as I expected that none of the page_items would become selected. Two questions:   1. How can I get rid of this?   2. And ideally, how can I make it so that "Projects" becomes selected? Below a screenshot to (hopefully) clarify things. ![enter image description here](https://img.skitch.com/20110623-8gs8e2cx6eeb2qgata5mn8s7j.jpg)


making an index from custom taxonomies and tags of posts (not hierarchical taxonomy)

i have attached custom taxonomies to posts. now i'm looking for the best way, architecturally speaking, for automatically creating list that would look like this: **energy (32):**   * how to build a solar system (asaf)   * how to fix a solar panel (saar)   * managing your lead-acid deep-cycle battery (ofra)   * hybrid system design (asaf)    * take the green pill (saar) _more energy? ->_ explanation: it should query all instances of a specific taxonomy (let say tags, and afterwards i'll do the same with other taxonomies as well) and make a list of that will have the tag name as a title with number of posts in the tag in brackets, and a list of the newest posts under that list with the author name in brackets.each post should link to the post, and name of author should link to the author page. in the bottom it should have a generic link to that specific tag archive page. the function i'm trying to build should generate that list automatically for every tag that has more then 10 posts tagged. the next difficulty level is to make it show every post only one time (for posts that are tagged with number of tags it will show the post only on the first tag). i've tried to find a plugin that i can tweak to doing that but i could not find any thing close enough, so i decided to build it myself. what i'm asking is for everything between a a tip for the road and a "yesterday i've developed the same function, it's working great, here's the code. have fun". Cheers, Asaf.


How to return HTTP 404 when no search results found?

When user search and there is no results found wordpress still return 200 OK. I want to change it to 404 Not Found. Is it possible to return 404 Not Found header in search.php? If yes, how to do that?. Thanks.


image.php content pulled with AJAX

I made a custom gallery set on my single-page theme where it lists the titles of the gallery post type, and when clicked, the thumbnails are ajaxed below. Then, I made another ajax to watch the thumbnails and show the full size image on the right. To get the content of the full size image, I created the image.php file and ordered it to have the same structure of where it will be attached. All worked fine and well until I click on the thumbnail and the ajax kicks in, but the image itself doesn't load. When inspecting the code for the image.php, I noticed that it pulls the image in question using some php that I don't fully get:

          <?php if (have_posts()): while (have_posts()) : the_post(); ?>                                <?php if ( wp_attachment_is_image( $post->id ) ) : $att_image = wp_get_attachment_image_src( $post->id, "full"); ?>                 <img src="<?php echo $att_image[0];?>" width="<?php echo $att_image[1];?>" height="<?php echo $att_image[2];?>" alt="<?php $post->post_excerpt; ?>" />             <?php else : ?>                 <a href="<?php echo wp_get_attachment_url($post->ID) ?>" title="<?php echo wp_specialchars( get_the_title($post->ID), 1 ) ?>"><?php echo basename($post->guid) ?>             <?php endif; ?>                        <?php endwhile; ?>          <?php else: ?>          <?php endif; ?>

      So my question is: Is it really possible to bring the image from image.php with ajax? Maybe it needs the address bar to get the post id or something. I'm having this suspicion because ajax is not adding anything there. Here is the ajax that should bring up the image:               $(document).ready(function() {                   $('#thumbnails').on('click','a', function(event) {                  var aCarregar = $(event.target).attr('href')+' #texto-galeria';             $('#texto-galeria').fadeOut('fast',carregarConteudo);             $('#carregando').remove();             $('#conteudo-galeria').append('Carregando...');             $('#carregando').fadeIn('normal');                       function carregarConteudo () {                 $('#texto-galeria').load(aCarregar,'',mostrarNovoConteudo);             }             function mostrarNovoConteudo () {                 $('#texto-galeria').fadeIn('normal',esconderCarregando);             }             function esconderCarregando () {                 $('#carregando').fadeOut('normal');             }                  return false;         });          });      By the way, without the ajax, the image.php displays the image nicely. Thank your for you time!


Set a payment method programatically

Having a hard time trying to figure this out. I'm wanting to set the payment method for the Woocommerce checkout so that the user doesn't have to choose. The only choice they have is PayPal. I wanted to use:               global $woocommerce;     $gateways = $woocommerce->payment_gateways()->get_available_payment_gateways();     $gateways["paypal"]->set_current();      But this doesn't seem to work. I've tried putting this in "init" and at the top of the "form-checkout" template but no joy.


How to add user email to url address?

How can I automatically give user email address to url? I have this url:               /trk?o=80&p=663&s1=&s2=&s3=&email=      And I need get WordPress user email to the end of this url `&email=`


Unable to get wp_get_attachment_url to show

I'm trying to show a link to the full size image of an attached image. I took a code for Wordpress' Twelve Thirteen theme:               <?php      $metadata = wp_get_attachment_metadata();     printf( '%3$s',     esc_url( wp_get_attachment_url() ),     esc_attr__( 'Link to full-size image'),     __( 'View Full Size' ),     $metadata['array'],                                     $metadata['array']     );     ?>      It shows on the twelve thirteen theme with a magnifying class and the text 'Full Resolution (width x height). It doesn't show the theme 'terrifico' I'm using. What am I doing wrong?


WP is ignoring .htaccess rewritten URL

I have two domains being served from the same WP install. _edit: **not** multi-site_ In `wp-config.php` I have `define('WP_SITEURL', "http://$hostname/wordpress");` etc. The two domains will have similar content, but we want to be able to have them at the same path, e.g. `domain1.com/about-us` and `domain2.com/about-us`. I've therefore set up these two pages `\dom1\about-us` and `\dom2\about-us`, and in my `.htaccess` I have:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /          RewriteCond %{HTTP_HOST} dom1 [NC]     RewriteRule ^((about\-us|etc).*) /dom1/$1 [NC,QSA,L]          RewriteCond %{HTTP_HOST} dom2 [NC]     RewriteRule ^((about\-us|etc).*) /dom2/$1 [NC,QSA,L]          RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>     # END WordPress      I get _(edit: WordPress)_ 404 error pages for the above URLs. I've added `print_r($_SERVER);` in my 404 template and get the following (simplified output).               Array     (     [REQUEST_URI] => /about-us/     [REDIRECT_REDIRECT_STATUS] => 200     [REDIRECT_STATUS] => 200     [HTTP_HOST] => dom1.dev     [SERVER_NAME] => dom1.dev     [REDIRECT_URL] => /dom1/about-us/     [QUERY_STRING] =>      [SCRIPT_NAME] => /index.php     [PHP_SELF] => /index.php     ...     )      Doesn't that mean that the rewrite has worked, but WP is not using it? Many thanks in advance.


create a permalink based on a post type

I want to create a permalink based on a post type. I am using twitter bootstrap nav walker file. In this way:               example.com/#home     example.com/career     example.com/#testinomial     example.com/contact      i am new in wordpress


Edit different parts of a page seperately

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.


Exclude / Blacklist Permalinks

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?


Custom styles and scripts for specific admin screen

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.


Custom taxonomy - category results

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/ ?


Edit draft from other author

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?


Checked checkbox?

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!


require_once() error after moving Wordpressto another server

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


Best practice (forward compatibility) for theme options

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.


WP New Post Problem

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?


Taxonomy based permalinks

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);     }


Style of a theme

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)


Filtering posts by post meta data

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.


Define specific category name in PHP

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 :(


Modal window from within Wordpress admin

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?


setting a different theme for specific category in wordpress

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.


Wordpress with CAS+LDAP and standard WP accounts

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?


Selectively applying action based on role

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.


Muliple featured images (or just images) per post

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)


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

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?


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

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!


Wordpress Plugin Receive a Link

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?**


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

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.


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

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 :]


Wordpress plugin: render only page content using ajax call

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


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

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)


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

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?


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

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?


How to enable customer login to customer specific admin page

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?


Front end editor to pending post(for contributors)

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!


How do I get post attachments in menu_order in Wordpress?

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!


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

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?


Loading individual category post via dynamic tabs

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.


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

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


wp_nav_menu action/filter help

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.


Edit the_content() function so to add a div wrapper

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?


My plugin won't return anything

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.


Determining the compatibility of Settings API & Multisite

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


remove class from code

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') );         }          }


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

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?


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

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?


gettext does not translate when called in ajax

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();     ?>


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

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?


wordpress meta_box data don't save

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 );      }


Googles jQuery: Are There Avantages to Using It?

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.


Image resizing - TimThumb vs convert on upload?

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


Associate Taxonomies Across Post Types

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.


search this custom post type

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.


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

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?


Pretty URLs or permalinks for attachments

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


Export blog posts with MathJax to LaTeX document?

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.


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

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?


Display Multiple Values of Same Key

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.


Gallery shortcode numerical sorting

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.


Simultaneous admin updates causes custom fields to not update

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. :)


Issue on adding Icons to Custom Post Type

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