How to manage a URL with pageX in it in order to generate a 404 page?

So I have done all this on a brand new WP install to rule out any potential effects from anything else. WP is setup with a static page as the home page. Permalinks are setup as simply %postname% and changes are saved to the .htaccess. When I go to http://example.com the homepage displays as expected. When I go to http://example.com/page88 the homepage again is displayed (no 404 error, a HTTP200 is returned). Note 404 pages are workings. Digging into this using the DEBUG BAR plugin it shows that this is matching a WP rewrite rule:               Request:     page66          Query String:     paged=66          Matched Rewrite Rule:     page/?([0-9]{1,})/?$          Matched Rewrite Query:     &paged=66      This is confirmed by outputting paged as outlined in the Wordpress Codex here. This does show that it is page 88. The question is how best to manage this? Obviously I would like a 404 page to be generated but I'm not clear how best to check that it is applicable. There were a number of related solutions from an old question here however they did not work. Thanks for your help.


List Taxonomies: Don't list taxonomy if it has no post - depending on custom post-meta?

This might be complicated to explain and I don't know if there is a solution to that!? I have a custom-post-type named "wr_event" and a hierarchical custom-taxonomy named "event_type". The custom-post-type has a meta-box for `event_date` and all posts associated with this post-type are sorted by this `event_date`. I have one special condition in my loop to query if the `event_date` has already taken place - in that case it's not shown but only listed in my archives. Just like you can use `wp_list_categories()` I wrote a custom function that lists all taxonomy-terms exactly the same way. And now my question: When I use my custom `wr_list_taxonomy()` function it lists all taxonomies that have a post associated with it. Just like `wp_list_categories()` lists only the categories that have a post associated with it. If there would be a taxonomy-term that doesn't have posts it wouldn't be listed. I wonder if it's somehow possible to "exclude" a taxonomy-term or simply not list it if all posts associated with it have an `event_date` that has already taken place. Sounds complicated right? So I have this function that works like a charm.               function wr_list_taxonomy($taxonomy, $orderby, $hierarchical) {         $show_count   = 0;         $pad_counts   = 0;         $title        = '';              $args = array(           'taxonomy'     => $taxonomy,           'orderby'      => $orderby,           'show_count'   => $show_count,           'pad_counts'   => $pad_counts,           'hierarchical' => $hierarchical,           'title_li'     => $title         );              return wp_list_categories( $args );     }      It lists all terms and only lists them if posts are in them. However I have posts ("events" in my case) in all taxonomy-terms, but have terms whose events are all over. And if the "events" in a term are all over (and therefore the term-page doesn't list anything as I wrote above because I filter them by todays date) I don't want this function `wr_list_taxonomy()` to print this term. Is that somehow possible?


Hide cart when empty

Could someone help me with this syntax: At the moment I have a simple link to my shopping cart like this:               <?php if ( is_woocommerce_activated() && isset( $woo_options['woocommerce_header_cart_link'] ) && 'true' ==     $woo_options['woocommerce_header_cart_link'] ) { ?>      And I want to add the condition to show my mini-cart when contents are greater than 0. I found the code below, but I can't figure out where to put this condition in the line above.               <!-- <?php         if ( is_woocommerce_activated() && sizeof( $woocommerce->cart->cart_contents ) !== 0) {             appply_mini_cart();         }         ?> -->      I would appreciate some guidance! Thanks


Increase Comment Author Gravatar Size On WordPress Default Comment Function

I am new to WordPress theme development. I am designing a new theme and using less codes and file as I am starting from basic. I am adding comments and comment form in my `single.php` using `<?php comments_template(); ?>` only. This one line is showing my blog comments, comment navigation, comment form all things. But its showing my commenters gravatar in `32px` size that I want to increase. I know that if I will use `comments.php` then I can do it but **How To Increase Comment Author Gravatar Size?** in this circumstances.


Hiding certain panels in dashboard

I want to hide certain panels in the dashboard, for example the `Excerpt` panel. This metabox has an `id` of `postexcerpt`. Is it a good idea to simply add some CSS rule like `#postexcerpt { display: none }` in the admin's CSS? Or may this cause hidden problems down the line?


using jquery serialize in ajax operation for plugin

I am writing a plugin with dynamic no. of input fields in form. To submit form via ajax, I have used jquery serialize() function.               $(".submit").submit(function( event ) {             event.preventDefault();             var data = {                 action: 'wpaie_ajax_action',                 operation: 'import',                 importData: $(this).serialize()     //do some operation             };             $.post(ajaxurl, data, function(response) {                  });         });      Ajax is working fine and data is also serialized but I am not able understand how to read the form input fields. If I am using `echo $_POST["importData"]`, it is showing me serialized data but what should be the correct way to read that serialized data.


Can I use theme options to change two things at once?

Possible noob question -- please be nice. I'm doing up a theme options page using the sample from Themeshaper, and one of the options I want to have is to set the width of the sidebar. To do this with the CSS I already have, I need to change class attributes in my HTML in two places (one for the main column width, one for the sidebar). The Themeshaper code is fine for adding little theme option tweaks, but I can't figure out how to get a single option to modify two places in the code at once. Possibly (hopefully!) a simple question, but beyond my current abilities. Any help greatly appreciated. Thanks. **Update:** I should clarify that I'm not a programmer, and I'm already waaay out of my depth. That said, here's what I'm going for... In my theme options page, I want to have a drop-down menu with two options: 'wide sidebar' and 'narrow sidebar'. One of these will be the default. Changing the default needs to modify two CSS classes. I appreciate Rarst's answer below but I simply don't know enough about PHP to be able to get it to work. Is there a simple(r) explanation for how to get this to happen? Again, sorry if this is basic stuff.


Different widgets in sidebar on sub-children pages?

I'm working on project, where I have different widgets on pages and also different order. Example - on About page I may have **chat widget** , then **e-mail sign-up widget** , then **testimonials widget**. On other page I may have **testimonials widget** only, followed by **chat widget**. I'm using this code to show widgets on pages and children pages               <?php if ( is_front_page() ){  ?>                 <?php }elseif ( is_page('areas-we-service') || $post->post_parent == '16' ){ ?>     Do stuff here        <?php }elseif ( is_page('products') || $post->post_parent == '14' ){ ?>     Do stuff here      <?php }else{ ?> <?php } ?>      and it work. The problem is that it not work on subchildrent pages e.g. Product -> Product 1 -> Product 1.1 On Product 1.1 I don't have widgets. So, my question is, how to change code above to show widgets on subchildren, sub- subchildren etc. pages. Thank you!


Hooking in to plugins

I'm working on a plugin that would ideally be able to do things when a user does something through a _different_ plugin. I can add custom hooks in those plugins but obviously this wouldn't work well for when I want to distribute my plugin. Is there a good way to add hooks to other people's plugins from my own plugin? Is the only real solution to ask the author to include custom hooks so that other developers can build off of their work? Example: I want to do something in my plugin when someone retweets an article. If there was a custom hook in whatever the popular retweet plugin is that I could hook in to and fire off of, that would be great. There isn't, so I can modify their plugin to include it, but that only works for my copy, and I don't want to try to redistribute that. Do we just need to try and be better plugin developers so that we can all play nice together?


Modifying a JS file with data from plugin settings

I have a plugin that, among other things, has a javascript file that requires a few user specific settings. What would be the best way to get those settings into javascript from the plugin's settings parameters? In other words, if I make those settings part of the settings page where the user can enter them, how would I best be able to get those values into javascript? Would I have to use something to append some script tags and set them via PHP on every page load? Would setting a cookie be a better way to do this?


How to create link to posts in WP-Markdown

I am using WP-Markdown plugin for writing posts. In one post I wanted to add a link to another post, but since I am using Markdown editor I had to add the URL (permalink using month and name) of the post manually. This might cause troubles when the date or name of the post changes. I was thinking about writing something like `[1]:[post#51]` and it will result in permalink to post with id 51. Does the plugin support this or should I dig inside and write a code for this? Thanks


Load php file with jquery in single.php

I implemented in my worpdress theme ios button switch and when someone click the button the script load a php file with the text: on or off Here is the code:                 <script type="text/javascript">          $('#1').iphoneSwitch("<?php echo get_user_meta( $current_user->ID, '_fbpost_status', true); ?>",       function() {        $('#ajax').load('<?php bloginfo( 'template_url' ); ?>/includes/ajaxswitch/on.php');       },       function() {        $('#ajax').load('<?php bloginfo( 'template_url' ); ?>/includes/ajaxswitch/off.php');       },       {         switch_on_container_path: '<?php bloginfo( 'template_url' ); ?>/includes/ajaxswitch/iphone_switch_container_off.png'       });      So on.php have only the "Activated" text and of.php "Stoped" text. The on and off files have not included the wordpress variables. How can I include them? To make a update in db. Or do you know any better method for doing the update?


Tags to Post-ID mysql query. Tag Search

Im trying to implement a tag-based search. When i specify certain tags, tagged posts will be searched and the post-id will be displayed that matches the searchcriteria. Currently it only works for a single tag.               $query = "SELECT DISTINCT $wpdb->posts.ID FROM $wpdb->terms         LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id)         LEFT JOIN $wpdb->term_relationships ON ($wpdb->terms.term_id = $wpdb->term_relationships.term_taxonomy_id)         LEFT JOIN $wpdb->posts ON ($wpdb->term_relationships.object_id = $wpdb->posts.ID)             WHERE $wpdb->term_taxonomy.taxonomy = 'post_tag' " . $substring;      Substring looks like following:               $substring = "AND $wpdb->terms.slug IN ('tag1','tag2')"      And here is the problem. It does not look for single posts that match all criteria. Instead it 'collects' all posts with all tags searched. For example:               // postid1 -> tag1     // postid2 -> tag2     // postid3 -> tag1, tag2          $substring = "AND $wpdb->terms.slug IN ('tag1')"     //Output: postid1, postid3 - - - CORRECT     $substring = "AND $wpdb->terms.slug IN ('tag1','tag2')"     //Output: postid1, postid2, postid3 - - -WRONG!          //Expected: postid3      So far i have no idea howto solve it in a single mysql query. Maybe im missing something. Thanks for your help in advance.


Given multiple admin accounts, how can I make it so that only admin with X username can edit posts

My question is pretty much in the title. I have 2 or more administrators, but I only want the admin with X username to edit the title of the posts while others can only view them. Feel free suggesting solutions that involve scripting or the use of plugins. Thanks! Note: This is only for the backend/dashboard.


How to display posts from multiple post type in random order in wordpress?

I want to display posts from multiple post types (photo, post), with one post from "photo" post type and another post from "post", in the same loop. Can anyone help me? Here is my code:               <?php     $args = array(         'post_type'=> array('photo', 'post'),         'orderby' => 'date',         'posts_per_page' => 10,         'paged' => get_query_var('paged'),     );     $query=new WP_Query($args);          if ( $query->have_posts() ) while ( $query->have_posts() ) : $query->the_post(); global $post;         $post_type=$post->post_type;         if($post_type=='photo'){ ?>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>

         <?php }           if($post_type=='post'){ ?>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>

         <?php }      endwhile;     ?>


using advanced custom field to control css hover color

this is a bit challenging for me: I am using the great Advanced Custom Field plugin on my site to create different color scheme to each of my taxonomy. I created a field called **taxonomy_color** and echoed out the color like so:               <h4 style="color: <?php the_field('taxonomy_color', 'magazine_'. $tax_term->term_id); ?>;">Hello
      *** magazine_ is the name of my taxonomy.** This is fairly easy and it works perfectly, however, everything becomes more complex when I want to change my **hover** and **active** class too. since changing the hover and/or active state requires a reference to the stylesheet I was thinking about creating a dynamic stylesheet called: **style.php** and trying to pass the custom field onto that stylesheet and using this method will allow me to control the hover and active states too. this is the code I generated for my **style.php** :               <?php         header("Content-type: text/css; charset: UTF-8");     ?>     .slider-mag-template .bottom .nav li.activeSlide a,.slider-mag-template .bottom .nav li a:hover { color: <?php the_field('taxonomy_color', 'magazine_'. $tax_term->term_id); ?>;}      I can see in the site that the page is connected to my dynamic style.php but it doesn't read the field **taxonomy_color** from there. can anyone suggest? even using a different method? Thanks a lot


How to create a file archive in WordPress?

I've installed WordPress for my school's website. I have a task of creating a file archive, an uploader and a file viewer for the website. The file archive would store files on the server, "in the background". The uploader would enable users to upload files and tag them. And a file viewer would allow users to view and download files as per their tags. Both the uploader and the viewer would have to be integrated into the page. If there is a plugin that does something like this, but displays its results in the admin panel - _that would be acceptable as well_. But it would have to be intuitive and easy to use. All registered users of the site should be able to view and download the files. And only the ones with a specific file upload privilege should be able to upload them. I'm not sure whether what I want can be accomplished with the built-in media archive. I don't only want to upload media - but other file types such as documents, programs, etc. Is there a plugin that would enable registered users to upload files without using the admin panel, but just the site itself? All the download links to the files have to be included automatically in the Downloads page too. Some form of a file manager would be great.


The problem is that it redirects to 404 page

The format of the link is ok, it works. But when I open the post did not lead me to the single-customtypes but the 404 page.               add_action('init', 'tdd_add_rewrite_rules');     add_filter('post_type_link', 'tdd_permalinks', 10, 3);          function tdd_add_rewrite_rules()          {              // Register custom rewrite rules              global $wp_rewrite;         $wp_rewrite->add_rewrite_tag('%pasager%', '([^/]+)', 'pasager=');         $wp_rewrite->add_rewrite_tag('%z_localitatea2%', '([^/]+)', 'z_localitatea2='); //[COPY] COPY THIS LINE TO ADD MORE VARIABLES         $wp_rewrite->add_rewrite_tag('%z_destinatia2%', '([^/]+)', 'z_destinatia2='); //[COPY] COPY THIS LINE TO ADD MORE VARIABLES              $wp_rewrite->add_permastruct('pasager', '/pasager/%z_localitatea2%-%z_destinatia2%-%post_id%.html', false); //[EDIT] TO ADD MORE SLUGS, ADD /%VARIABLE2% BETWEEN %VARIABLE1% & %POST_TYPE%          }          function tdd_permalinks($permalink, $post, $leavename)     {              $no_data = 'no-data';              $post_id = $post->ID;              if($post->post_type != 'pasager' || empty($permalink) || in_array($post->post_status, array('draft', 'pending', 'auto-draft')))                  return $permalink;              $var1 = get_post_meta($post_id, 'z_localitatea2', true); //[COPY] COPY THIS LINE TO ADD MORE VARIABLES         $var2 = get_post_meta($post_id, 'z_destinatia2', true); //[COPY] COPY THIS LINE TO ADD MORE VARIABLES              $var1 = sanitize_title($var1); //[COPY] COPY THIS LINE TO ADD MORE VARIABLES         $var2 = sanitize_title($var2); //[COPY] COPY THIS LINE TO ADD MORE VARIABLES              //[COPY] COPY THE BELOW LINES TO ADD MORE VARIABLES          if(!$var1)                 $var1 = $no_data;              //[COPY] END COPY HERE         if(!$var2)                 $var2 = $no_data;              //[COPY] END COPY HERE         if(!$var3)             $var3 = $post_id;              //[COPY] END COPY HERE              $permalink = str_replace('%z_localitatea2%', $var1, $permalink); //[COPY] COPY THIS LINE TO ADD MORE VARIABLES         $permalink = str_replace('%z_destinatia2%', $var2, $permalink); //[COPY] COPY THIS LINE TO ADD MORE VARIABLES         $permalink = str_replace('%post_id%', $var3, $permalink); //[COPY] COPY THIS LINE TO ADD MORE VARIABLES              return $permalink;          }              add_action( 'init', 'create_post_type' );         function create_post_type() {                 register_post_type( 'pasager',                         array(                                 'labels' => array(                                         'name' => __( 'Pasager' ),                                         'singular_name' => __( 'Pasager' )                                 ),                         'public' => true,                         'has_archive' => true,                         'rewrite' => false,                         )                 );         }             $args = array(              );                  register_post_type( 'pasager', $args );             function post_type_labels( $singular, $plural = '' )     {         if( $plural == '') $plural = $singular .'s';              return array(             'name' => _x( $plural, 'post type general name' ),             'singular_name' => _x( $singular, 'post type singular name' ),             'add_new' => __( 'Add New' ),             'add_new_item' => __( 'Add New '. $singular ),             'edit_item' => __( 'Edit '. $singular ),             'new_item' => __( 'New '. $singular ),             'view_item' => __( 'View '. $singular ),             'search_items' => __( 'Search '. $plural ),             'not_found' =>  __( 'No '. $plural .' found' ),             'not_found_in_trash' => __( 'No '. $plural .' found in Trash' ),             'parent_item_colon' => ''         );     }


Array sorting by custom field date

I want to order the array by a date field called `date_start` but how do I include a meta key for this if I already have one?               $currentshowid = get_the_ID();     $today = date('Y-m-d');     $args = array(         'meta_key' => 'show_id',         'meta_value' => $currentshowid,         'orderby' => 'meta_value_num',         'order' => ASC,         'meta_query' =>array(             'relation' => 'AND',             array(                 'key' => 'date_end',                 'value' => $today,                 'compare' => '>=',             ),         ),     );


WordPress Database Charset/Collate

Is there an easy way of getting the charset and collation of the DB tables in WordPress without resorting to SQL queries?


Custom image sizes add to metadata

I want to put resized files in original file metadata.               //Original file     $aid = wp_insert_attachment($attachment, $file['file'], $post_id);     $a = wp_generate_attachment_metadata($aid, $file['file']);     //Croped images from original     $path_300x200 = path_to_file_300x200.jpg     $path_100x100 = path_to_file_100x100.jpg          crop_image($file['file'], $path_300x200, 300, 200, 85, true);     crop_image($file['file'], $path_100x100, 100, 100, 85, true);          $file1= getimagesize( $path_300x200 );     $info1 = array(     'file' => wp_basename( $path_300x200 ),     'width' => $file1[0],     'height' => $file1[1],     );     $metadata1['sizes']['300x200'] = $info1;     $a_300x200 = wp_generate_attachment_metadata($aid, $metadata1);     wp_update_attachment_metadata($aid, $a_300x200 );          $file2= getimagesize( $path_100x100 );     $info2 = array(     'file' => wp_basename( $path_100x100 ),     'width' => $file2[0],     'height' => $file2[1],     );     $metadata2['sizes']['100x100'] = $info2;     $a_200x200 = wp_generate_attachment_metadata($aid, $metadata2);     wp_update_attachment_metadata($aid, $a_100x100 );      I get in database: _wp_attachment_metadata a:2:{s:5:"width";N;s:6:"height";N;} What I am doing wrong? UPDATE:               //Original file     $aid = wp_insert_attachment($attachment, $file['file'], $post_id);     $a = wp_generate_attachment_metadata($aid, $file['file']);     //Croped images from original     $path_300x200 = path_to_file_300x200.jpg     $path_100x100 = path_to_file_100x100.jpg          crop_image($file['file'], $path_300x200, 300, 200, 85, true);     crop_image($file['file'], $path_100x100, 100, 100, 85, true);          $file1= getimagesize( $path_300x200 );     $info1 = array(     'file' => wp_basename( $path_300x200 ),     'width' => $file1[0],     'height' => $file1[1],     );     $metadata['sizes']['300x200'] = $info1;               $file2= getimagesize( $path_100x100 );     $info2 = array(     'file' => wp_basename( $path_100x100 ),     'width' => $file2[0],     'height' => $file2[1],     );     $metadata['sizes']['100x100'] = $info2;          $a['sizes']=$metadata;      //$a is generated original file metadata, and I added value to the key "sizes".          wp_update_attachment_metadata($aid, $a );      Is it right solution ? The problem is that when I want to delete original photo it only deletes original photo, but not resized... any thoughts ?


Post content in another div on the same page

Im am trying to build a wordpress site that contains a sliding div that comes from above. So on the home page you see the post and normaly when you click the title of that post, you go to that page, but i want it to open the div and slides down. If you look at my example and press X the div comes down, an should give you the content. If you click the link CENTRE FOR URBAN POTENTIAL ROTTERDAM, NEDERLAND ARCHITECTUUR you will see a blank page, but with a X if you click that one the div comes down with the content. I was play arround in the single.php that managed me to get some content. But i dont know how to go further..., i tried the WP-ShowHide and Slide Div , but wont get me anywhere .. is it even possible todo in Wordpress? Regards, Marcel


How to get WordPress to save upload file beyond web root

I am using nginx on a multisite install. I am trying to get WordPress to save uploads to a folder beyond the webroot :               /home/mydomain/file_secure      as opposed to               /home/mydomain/public_html/wp-content/uploads      I have successfully moved the uploads directory around inside the webroot with the following filter:               add_filter('upload_dir', 'my_upload_dir');     $upload = wp_upload_dir();     //remove_filter('upload_dir', 'my_upload_dir');          function my_upload_dir($upload) {         global $blog_id;         $upload['basedir'] = '/home/mydomain/file_secure/'.$blog_id;         $upload['subdir'] = '';         $upload['path'] = $upload['basedir'] . $upload['subdir'];         $upload['url']  = $upload['baseurl'] . $upload['subdir'] . '/file_secure.php?file=';                   return $upload;     }      This path is writable. It even creates the directories `file_secure` and `25` ($blog_id)               $upload['basedir'] = '/home/mydomain/file_secure/'.$blog_id;      I have looked through the core code in WordPress 3.9 `wordpress/wp- includes/functions.php` at the function wp_upload_dir() and noticed that the function description states that               * Checks the 'upload_path' option, which should be from the web root folder,      * and if it isn't empty it will be used.      I assumed that when it found my path to be outside the webroot that it should have thrown an error, but I can't find where. Needless to say, the upload did not make it to the wanted directory. On a side note, I plan to access the uploaded files from a script in the front end that will serve up the content. `file_secure.php` Any help / direction here would be much appreciated. I would really hate to find out that I need to hack the WP core in order to make this possible; but maybe it could become available in a future release. I would much rather all of the wp-content be located outside of the webroot. UPDATE: all I seem to be able to do when changing the upload path from the `upload_dir` filter is create the folder where I want the file to go; but it does not actually save the file there. It reverts back to the default settings. ANOTHER UPDATE: WordPress seems to think that the file exists because it creates an attachment post, but there is no file in the intended directory and the URL on the attachment simply has the default URL structure and not the one that I set above. So now I am trying to investigate what is going on during the attachment post creation. If anyone can spot what I may be doing wrong, please let me know.


What are trackbacks?

I was wondering what are trackbacks. I found this to be an option in Wordpress, and I am wondering if I should add them to pages and posts. Thank you for your help and support!


Displaying Custom Taxonomy without a hyperlink

I would love some help on how I can best display the custom taxonomy of a post as text only (and not as link within an tag). I have a small template file that is called by a few other pages, and the job of that template file is to render a citation for an article - here's the complete code:

<?php the_category(' | '); ?>
        <?php the_terms( get_the_ID(), 'ehp_volumes' ); ?>        <?php the_field('ehp_citation'); ?>
      This portion of that php file:               <?php the_terms( get_the_ID(), 'ehp_volumes' ); ?>      Does its job in displaying the taxonomy - but it is wrapped in a hyperlink. Is there an attribute that will just return the text of taxonomy? Do I need to use a variable instead?


how to set Gallery Setting default Media File

When i create Gallery default is: Attachment page how to change default is media file or remove Attachment page . I don't want select is. ![enter image description here](http://i.stack.imgur.com/eSSFG.png)


Internet Explorer ignore my css

I am creating my personal blog, but Internet explorer are _*_ * me. About 5 hours I am trying to figure out what I am doing wrong, well what is my problem ? Well, I created breadcrumb for my website, only for specific custom types - reviews. All browsers are ok with this, but internet explorer (I have IE 10) are pushing my sidebar away. If you open for example this my review http://milanchymcak.com/reviews/fix- redirect-virus-review - if you open it in firefox or chrome, its ok. But in Internet explorer my sidebar is gone. I don't know what to do. So I was looking for answer on google and everybody is telling that this will fix that               <!--[if IE 6]><link rel="stylesheet" type="text/css" href="ie.css" /><![endif]-->     <!--[if IE 7]><link rel="stylesheet" type="text/css" href="ie.css" /><![endif]-->     <!--[if IE 8]><link rel="stylesheet" type="text/css" href="ie.css" /><![endif]-->     <!--[if IE 9]><link rel="stylesheet" type="text/css" href="ie.css" /><![endif]-->     <!--[if IE 10]><link rel="stylesheet" type="text/css" href="ie.css" /><![endif]-->        But this doesnt work at all. Internet Explorer ignores this too. I will be very happy for any help.


Using the WordPress 3.5 Media Uploader window as a modal popup

I have a general question: is it possible to use the new WordPress 3.5 Media Uploader window for other purposes (i.e., as a modal popup window for content)? I would like to do this and have spent a lot of time trying to figure out if/how to do it but have had NO luck. I'm basically looking to replace the Thickbox popup as the way my shortcode panel is presented in the admin panel. Has anyone done this or something similar? Can anyone point me to something that covers this or some variation on the theme? Many thanks, Andrew.


Featured images disappear after DB export/import?

I'm upgrading my blog right now from 3.2.1 to 3.5.2. However, for one section the featured images have seem to disappeared. The database is identical since I just did a dump/restore a few minutes ago. Other sections are fine, but for this one I am no longer receiving an array when I do `wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full');` even though all the parameters are correct. I checked my edit post page on wp-admin and there is no longer an image under `Featured Images` as there was before. Is there a way to recover these images without having to upload them one by one? I'm pretty sure it's not a permalink issue, since I did the settings > permalink > save thing already.


single post navigation order (NOT chronological)

in my main loop i show only posts of the 'artworks' post type, orderby=rand. when i view a single artwork and use the next / prev nav, it disregards the main query and goes by chronological order - as described in the codex: http://codex.wordpress.org/Template_Tags/next_post_link how can i store and use the random order generated at first to alter the post navigation order? any ideas? the order would be randomized upon the reload of the home page, but within each session each 'random order' should be consistent. so, for example: 1- home page i see posts in a random order (4,7,1,8,6,3). i click on post 8. 2- on the single view of post 8, the 'next' post would be 6, and the previous would be 1. etc.. 3- i should be able to go through back and forth and the order would be consistent. 4- if i click on the title of the website or reload it again (not just history>back, but an actual reload). then there should be a new random order.


How to set a default one (i.e. Uncategorized) in Custom Taxonomy?

I'm using Custom Post Type and Custom Taxonomy in a project of mine. Just before delivering the site I found a serious bug. I used a simple `WP_Query()` with the following arguments:                         new WP_Query( array(                                   'post_type' => 'feeds',                                   'meta_key' => 'feed_arena',                                   'meta_value' => 1,                                   'order'=> 'DESC',                                   'posts_per_page' => 30,                                   'post_status' => 'publish'                               ) );      But if I delete all my custom Taxonomies (my Custom Taxonomy is "feed- categories"), it generates a fatal error, because all the posts under Feeds (CPT) become null-categorized ( **not** Uncategorized). As we can see that, in WordPress Default Post Categories there is an `Uncategorized` category that can't be deleted and is the default one, where's other categories have a "delete" button. ![Uncategorized Category - no delete button](http://i.stack.imgur.com/JDMjF.png)   ![Other Categories - there's a delete button](http://i.stack.imgur.com/blusY.png) Is there a way, we can assign a Default One for Custom taxonomy too?   So that, if all the other categories deleted, at least there'd be a default.


Which database table does "Featured images" save under?

I'm having an issue while upgrading WP from 3.2.1 to 3.5.2, where one section's Featured images have all been deleted. When I visit that section's edit post pages, the featured image thumbnails that were once there are no longer there. Is this a database issue? I just dumped/restored my database an hour ago. I'm wondering if the WP database upgrade deleted my data. Which table do the featured images data go under? I'm wondering if I could just dump/restore that table again, but I don't know which one it is. My images are still there, but the links to them don't seem to exist in the database.


Wordpress widget in custom theme

I created a custom theme and writing a basic widget for my wordpress based website. If I paste the code in functions.php the code works fine, however if I paste the code in a separate file and keep it in the plugins directory, it doesn't show up in the admin > appearance > widgets. The problem to keep the widget code in functions.php is it collides with some plugins I care. I tried wp_register_widget as a wild guess but to no avail. Here is the widget code (You can remove the 'include' line to test the code)               class Similar_Apps_Widget extends WP_Widget {              public function __construct() {                 parent::__construct(             'Similar_Apps_Widget', // Base ID             __('Similar Apps', 'text_domain'), // Name             array( 'description' => __( 'Similar Apps Widget', 'text_domain' ), )              );         }              public function form( $instance ) {              }              public function update( $new_instance, $old_instance ) {              }              public function widget( $args, $instance ) {                   ?>
Similar Apps
 <?php              include (TEMPLATEPATH . '/include/' . get_field('similarapps'). '-similar-products.php');              }     }     register_widget( 'Similar_Apps_Widget' );      and here is the functions.php code where I define the widgets placement               <?php           if (function_exists('register_sidebar')) {          register_sidebar(array(         'name' => 'Widgetized Area',         'id'   => 'widgetized-area',         'description'   => 'This is a widgetized area.',         'before_widget' => '
',         'after_widget'  => '
',         'before_title'  => '
',         'after_title'   => '
'     ));          register_sidebar(array(         'name' => 'Page Widget',         'id'   => 'page-widget',         'description'   => 'Page Widgets.',         'before_widget' => '
',         'after_widget'  => '
',         'before_title'  => '
',         'after_title'   => '
'     ));          }               ?>      and here is where it is inserted into the theme
              <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('page-widget')) :     else : ?>         <?php endif; ?>


How do I batch create revisions of all posts?

I cleaned up an old-site from pasted tags, manually created lists, etc, and I'd like to keep the old posts as "revisions", so we can easily "compare" with the old posts and retrieve/revert the original content if needed. So I should either injecting the revision rows in the new DB or just naturally create them in the old WP installation, by batch-updating all the posts… …or starting from the new cleaned-up dev installation and injecting the revisions. The problem is the old site didn't even use revisions (version 1.6 or 2 or so), so before I even try anything, I should MAKE wordpress to generate the right revisions itself (so the injections just adds content in existing rows, not whole rows with missing references etc) I know there are several places where the revisions and actual posts are linked/related/referenced so the process should be mostly done by wp functions and the fewer manual DB manipulations. Thanks.


How to list posts with disabled/closed comments, with pagination?

i'm interested how to display all posts (from all categories) that have closed/disabled comments? I have tried using the comments_open() function inside the loop, that works, i don't know how to enable pagination on it, and here's why: wp query - here's the query that displays all posts, i set here how many per page should be displayed if (!comments are open) i list the posts so, the problem here is that i want to show 10 posts per page -the loop actually goes through 10 posts, and displays any post of the given 10 that has closed comments, and then creates a second page with 10 posts and does the same etc... I need a filter inside the loop itself, so i display 10 posts with disabled comments PER PAGE. Pls, can anyone help with this?


passing multiple parents value into a shortcode

I need to pass a few values into the parent attribute of the wp_query. However I'm using a shortcode, so, If I pass a single value works perfect, but if I need to send multiple values it breaks, would be a great holiday gift if some1 could help me with it. By default, it works with the current post ID $thePostID, however If I need to retrieve the parent I'm using the parent attribute. Take a look at my code.                function andrew_child_loop_shortcode_new ( $atts ) {           global $post; $thePostID = $post->ID;           extract ( shortcode_atts (array (             'posts' => 20,             'parent' => $thePostID,             'exclude' => array(0)           ), $atts ) );           ///////$atts[ 'parent' ] = explode( "," $atts[ 'parent' ] );           ///////extract( $atts );           $output = '

';              $args = array(                 'orderby' =>  'menu_order',                 'order' => 'ASC',                 'post_parent' => $parent,                 'post_type' => 'page',                 'post__not_in' =>  array($exclude),                 'posts_per_page' => $posts                );           wp_reset_query();           $i=0;           $andrew3_query = new  WP_Query( $args );             $output .= '
';           while (  $andrew3_query->have_posts()) { $i++ ; $andrew3_query->the_post();             $output .= '
';             if(has_post_thumbnail()):;             $output .= ''.                         get_the_post_thumbnail(get_the_ID(), 'blog-post-carousel').                         '';             else :;             $output .= ''.                           ' ';                  endif;             $output .=                         '
'.                    get_the_title().                    '
'.                    '
'.                    get_the_excerpt().                    '
'.                    '
';                }           wp_reset_query();           $output .= '
';           return $output;         }         add_shortcode('display_childs_multiple', 'andrew_child_loop_shortcode_new');        I'm calling the parent this way [display_childs_multiple parent="10,15,20"]


advice on creating a 'related posts' query like the one used on stackexchange

One of the things that I most enjoy about the stackexchange website is the 'related questions' that show up on the sidebar when I am viewing a question (or show up as I am typing my question). It is readily apparent to me that the logic being used there is much more advanced than 'normal' wp functionality. I know this would be a very proprietary kind of question, but is there any available documentation on the functions being used to generate the list? I am looking for something a bit more advanced than simply using tags for relating posts. *I was going to use YARPP but after reading a number of comments on how that plugin can bring a site to its knees, I figured it would be best to ask first.


Fixing category count

Somehow my post counts are incorrect due to inserting rows via php. I have the following code to update the count, is it correct?               global $wpdb;     $result = mysql_query("SELECT term_id,term_taxonomy_id FROM $wpdb->term_taxonomy where taxonomy = 'category'");     while ($row = mysql_fetch_array($result)) {       $term_taxonomy_id = $row['term_taxonomy_id'];             $countresult = mysql_query("SELECT object_id FROM $wpdb->term_relationships WHERE object_id IN (SELECT ID FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish') AND term_taxonomy_id = '$term_taxonomy_id'");       $count = mysql_num_rows($countresult);       mysql_query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term_taxonomy_id'");             }


Remove a script from a template file using wp_dequeue_script

I thought I had read it was possible to use `wp_enqueue_script()` and `wp_dequeue_script()` directly in individual template files. However, when I add                 wp_dequeue_script( 'myscript' );      to the top of page.php, `myscript` still gets loaded. Is it possible to do what I'm trying to do?


Delete all Tag Links from Posts

We're working on this site: http://granthammond.staging.wpengine.com/ which will no longer be using tags, i need a way to strip / remove all the tag links in the post content, for example: any hyperlinks containing `/tag/` need to go, in their entirety,               Tagged with: Nashville Real Estate      i need to remove the whole `<a>` element. for all tags, across all posts. as usual, any and all assistance is appreciated.


Using source control with WordPress

I just recovered from a pretty bad crash using Server 2008 Shadow copy. Ultimatly I didn't lose more than a few hours of work but a loss is a loss. I've decided to move to version control to prevent this from happening again. What I'm interested in knowing is how does one handle the mysql directory? And how do you handle a development site and a live site (trunk and branch) running at the same time? I assume you wouldn't be able to move a development database to production with the posts being consistently updated. Any thoughts would be appreciated.


What is the best practice to get a site from local to online?

I develop my sites on a local xamp setup. When I´m done I need to get the site to my customer´s domain. Can I use vault press or backupbuddy for this, or is there a better process ?


What would causes search to return incorrect results?

Recently our site began no longer returning correct search results. When searching it returns one result that's unrelated to the inquiry. I've turned off all plugins and reverted back to a day when I thought it was working properly to no avail. What could possibly cause this to occur? You can see in the image below that the result is not related to the inquiry. ![enter image description here](http://i.stack.imgur.com/0j4Mo.png) Here's an example of a page with the title and terms related to the inquiry. ![enter image description here](http://i.stack.imgur.com/1DmCn.png) The front end also returns inaccurate results![enter image description here](http://i.stack.imgur.com/1O7qd.png)


Ideal WP multisite server setup for up to 1000 sites?

I plan to host up to 1000 sites for a large non-profit. Each site could get quite a bit of traffic. What is the ideal setup? VPS, *ngix, mem-cache etc?


How do I use the control callback when creating a simple dashboard plugin

On this page: http://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget The function **wp_add_dashboard_widget** is described. It states:               wp_add_dashboard_widget($widget_id, $widget_name, $callback, $control_callback = null)      How do you use the $control_callback, properly? I am completeley stuck, as I have defined it but cannot use it. I need to create a form within this widget which is why I am using the control_callback. **EDIT:** as a side note I am using Wordpress 3 and Multisite


Extending body classes in front- and backend

I want to extend both body classes for the front-end as well as for the admin area. I have seen some snippets floating around, which led me to the following               add_filter('body_class','add_custom_body_classes');     add_filter('admin_body_class', 'add_custom_body_classes');      Now it seems to me, that I do have to do a type check like the following, because in the case of the backend extension the variable is a string and not an array.               function add_custom_body_classes($classes) {         $someClassA = 'someText';         $someClassB = 'someText';              if (is_array($classes)) {             $classes[] = $someClassA;             $classes[] = $someClassB;         }         else {             $classes .= ' ' . $someClassA;             $classes .= ' ' . $someClassB;         }         return $classes;     }      Is this correct or what is it I am missing?


Custom post type category not displaying in custom post type

I've created a new custom post type (lets call it "Reviews") on the backend of my Wordpress. It works fine for the most part but the Categories I create within that Custom Post Type are not displaying on the meta box. For example, in a normal post, it should say "In Category X". In the custom post type, that field is empty. Here are two examples: Working properly: http://gamingsirs.com/?p=1 Not working: http://gamingsirs.com/?reviews=test               <?php $category_list = get_the_category_list( __( ', ', 'standard' ) ); ?>     <?php if( $category_list ) { ?>     <?php printf( '' . __( '%1$s', 'standard' ) . '', $category_list ); ?>     <?php } // end if ?>      You can see the category area is blank. Any suggestions on how to make it show would be greatly appreciated.


Menu items id's - are they 100% unique?

With regards the menu item id's WP generates such as `menu-item-814`, are these 100% unique in nature? I know they are unique at the time, but are they always unique? Meaning that if I was to delete something that had the id of 814, is it possible that some other menu item could now be assigned this ID? ...or if WordPress was updated do they still keep the same ID's? I ask because I want to assign something to a certain menu button via JavaScript but on the off chance the button is removed I don't want to be applied to a new button that has now been assigned that ID.


Rewrite rules for varying nested terms of custom taxonomy

I've searched the net an the only working solution to this seems to be this post by Jeff which does everything except handle nested terms. Does anybody know how to change the rewrite based on the term depth? Thanks in advance


Get list of all Grandchild Pages

I have the following page hierarchy, all of which are under a top page (TOP) with ID = 1:   * mid1      * gc1     * gc2   * mid2      * gc3     * gc4 I would like to make submit `WP_Query` query that will return random pages that are grandchildren of TOP - in this example, I want to randomly select from gc1, gc2, gc3 and gc4, but exclude mid1 and mid2. What is the best way to do this?


Excluding a custom taxonomy term breaks wp_get_post_terms

I'm trying to exclude one custom taxonomy from an archive page, and then show the terms of the returned posts. When I run WP_Query to exclude the custom term, it returns the posts correctly, but no longer fetches the terms array when using `wp_get_post_terms()`. I suspect that not querying in the positive prevents it from fetching the terms. Here's what my code looks like:               $query = new WP_Query(              array( 'tax_query' => array(                     array(                         'taxonomy' => 'documenttype',                         'field' => 'slug',                         'terms' => array('pressreleases'),                         'operator' => 'NOT IN'                     ),                      ) )              );     //then later, in the loop ...     $terms = wp_get_post_terms($query->post->ID,'documenttype');     // var_dump($terms) shows an empty array


How to include form for WP_Filesystem()?

I've used a bit of code to try and write a dynamic.css file to a theme folder and it works fine. BUT, it doesn't work on certain shared hosting situations so the request_filesystem_credentials() function is invoked. This produces a really ugly ftp form with no connect/submit button. I then followed the great Otto's tutorial on this to try and use a decent form instead but the end result is a nice looking form that gives the error "Error saving file!" after entering the correct ftp details. When installing plugins and themes on this site the same ftp credentials work perfectly. So I abandoned Otto's code, for now, and went back to my original code but I can't get it to work properly. This is really frustrating as the plugin option-tree requires this css file to be stored in this location and writeable. I don't need to show Otto's code as it works for everyone else!! However, here's my original code that must have something important missing:-                   function load_dynamic_css(){          global $wp_filesystem;         if( empty( $wp_filesystem ) ) {         require_once( ABSPATH .'/wp-admin/includes/file.php' );         WP_Filesystem();         }              $url = wp_nonce_url('themes.php?page=ot-theme-options','ot-theme-options');         if (false === ($creds = request_filesystem_credentials($url, '', false, false, null) ) ) {         return; // stop processing here         }              if ( ! WP_Filesystem($creds) ) {         request_filesystem_credentials($url, '', true, false, null);         return;         }              $css_file = get_template_directory() . '/dynamic.css';          if (!file_exists($css_file)) {          $wp_filesystem->put_contents( $css_file,'',0666);         }         }         add_action( 'after_setup_theme', 'load_dynamic_css' );      Can anybody please help? I just need to save the empty file, dynamic.css, with 0666 permissions if the file does not already exist on theme activation. The option-tree plugin will then be able to write css to this file. I'm sorry if this has been asked before but I can't see it anywhere on the web. Thanks.


Custom Post hierarchical to custom taxonomy

I have created a custom post type and a custom taxonomy. The issue is that I can not make the custom posts hierarchical with the categories it is in. I have the following code,               function AppManager_custom_post() {       $labels = array(         'name'               => _x( 'APKS', 'post type general name' ),         'singular_name'      => _x( 'APK', 'post type singular name' ),         'add_new'            => _x( 'Add New APK', 'APK' ),         'add_new_item'       => __( 'Add New APK' ),         'edit_item'          => __( 'Edit APK' ),         'new_item'           => __( 'New APK' ),         'all_items'          => __( 'All APKs' ),         'view_item'          => __( 'View APK' ),         'search_items'       => __( 'Search APKs' ),         'not_found'          => __( 'No APK found' ),         'not_found_in_trash' => __( 'No APKs found in the Trash' ),       );       $args = array(         'labels'        => $labels,         'description'   => 'Holds Apps and meta data',         'public'        => true,         'menu_position' => 5,         'supports'      => array( 'title', 'thumbnail', 'excerpt' ),         'has_archive'   => true,           'hierarchical'  => true,         'rewrite'       => array('slug' => 'APKs')       );       register_post_type( 'apps_post', $args );       flush_rewrite_rules();     }     add_action( 'init', 'AppManager_custom_post' );      And I have the following to create the taxonomy,               function AppManager_custom_taxonomy() {       $labels = array(         'name'              => _x( 'App Categories', 'taxonomy general name' ),         'singular_name'     => _x( 'App Category', 'taxonomy singular name' ),         'search_items'      => __( 'Search App Categories' ),         'all_items'         => __( 'All App Categories' ),         'parent_item'       => __( 'Parent App Category' ),         'parent_item_colon' => __( 'Parent App Category:' ),         'edit_item'         => __( 'Edit App Category' ),         'update_item'       => __( 'Update App Category' ),         'add_new_item'      => __( 'Add New App Category' ),         'new_item_name'     => __( 'New App Category' ),         'menu_name'         => __( 'App Categories' ),       );       $args = array(         'labels'       => $labels,         'hierarchical' => true,         'rewrite'      => array( 'hierarchical' => true, 'slug' => 'Apps' )       );       register_taxonomy( 'appCategory', 'apps_post', $args );          }     add_action( 'init', 'AppManager_custom_taxonomy', 0 );      No matter how I try the hierarchical function it never maps to the category that I add it to. Is it possible?


Wordpress automatically adding comments to inserted PHP code how to disable?

When I insert my PHP code using a button in the Wordpress page/post editor to add custom scripted php items such as buttons, authors, infopanes and such my own custom scripted item, which includes a bunch of connecting to a database and filling in information automatically from a database in a table it inserts <--php ?--> instead of me mentioning tags, I've installed exec-php which allows me to use the php tags. If I copy all code myself in the wordpress text editor the tags won't be changed into comments and everything works perfectly in the page, the table loads and inserts information from the table I extract out of the database. However if I use the button (Shortcodes it is called) and insert all extract same code in the Wordpress page post box it adds comments to my php, i was wondering if there is a way to turn this off so it doesn't break my code. I tried using a different plugin which used [insert_php] and [/insert_php] it worked in making the tags dissappear but it didn't actually do anything itself, it didn't connect to the database or fill in the tables.


Is there any simple wordpress search template that works with existing searchforms?

I want to replace my theme's search functionality with new functionality that searches trough text widgets. Almost all content of my site is provided trough text widgets (they are static pages). Is there any default wordpress search template that I can use and that will work with my existing search forms? In regards to Toscho's questions asked here:   1. My site doesn't have that much content, so slowness is not a problem.    2. Search results may point to a specific page, the page that hosts the widget   3. I want only to display results from text widgets.


Post-ID in url differs from $post->ID

I've got a page with a blogroll in the left column and a sidbar in the right one. When I try to retrieve the page-id inside of the sidebar like:               echo $post->ID;     echo get_the_ID();      The result is **3726** but the page URI is **page_id=3722** ! I'm really confused now. I badly have to catch the real page id to be able to use custom fields (with the right values). EDIT: I just noticed that 3726 is the id of the last blog element being displayed. But how to grab the page id?


Get all the terms and pass them as values for a shortcode parameter?

I'm using a WP theme which has the `food_menu` custom post type set up and the `food_menu_categories`* as its taxonomy. I'm not a developer, so I apologize if I use wrong terms regarding php/wp/ development. My theme's Food Menu page template runs its own custom function to query and filter the posts created under the `food_menu` custom post type. What I mean with _filter_ is that the theme has an option that allows me to filter the categories of its custom post type while creating a page within the WP dashboard. Depending on my settings, this might result on a page that displays only the posts assigned to the custom taxonomy (categories) or on a page that display _All Food Categories_ , which I guess it's a function to display all the posts based on the terms of the `food_menu_categories` custom taxonomy. As for now, I'm able to create new posts and assign them to the custom categories I've created, so far so good, everything works as intended. However, I'm now trying to pass all the terms in `food_menu_categories` custom taxonomy as values for a parameter to use it with a shortcode that belongs to the Ajax Load More Posts plugin. Here's the shortcode:               <?php echo do_shortcode('[ajax_load_more post_type="food_menu" taxonomy="food_menu_categories" taxonomy_terms="'.$item_cat->slug.'" order="ASC" orderby="menu_order" offset="3" posts_per_page="3" max_pages="none" button_label="Mais Itens"]');?>       I'm trying to output all the terms of my theme's `food_menu_categories` custom taxonomy as values for the `taxonomy_terms="' '"` parameter in the shortcode by using `.$item_cat->slug.`, which is part of an existing function of my theme's custom post type page template (please see the loop part), however, it outputs only the first term of the `food_menu_categories` custom taxonomy. The deal is I'm able to create a page that displays all the posts within the `food_menu_categories` custom taxonomy, while I'm also able to create a page that displays only the posts assigned to a specific category within the `food_menu_categories` custom taxonomy, so in order to use the Ajax Load More Posts shortcode smartly, I'd need a way to check if the page is loading all the `food_menu_categories` custom taxonomy terms, and if yes use the terms slugs or names as values for the shortcode parameter. Here's the page template and its functions:               <?php     /*     Template Name: Food Menu     */     get_header();          $food_cats = rwmb_meta('verona_food_categories', 'type=taxonomy&taxonomy=food_menu_categories');     $food_cats_array[0] = 'All Food Categories';     if($food_cats) {         foreach($food_cats as $food_cat) {             $food_cats_array[$food_cat->term_id] = $food_cat->name;         }     }     $args = array(         'paged'=>$paged,         'post_type' => 'food_menu',         'posts_per_page' => ot_get_option('food_items_number', '18', '', '', ''),     );     if($food_cats){         $args['tax_query'][] = array(             'taxonomy'  => 'food_menu_categories',             'field'     => 'slug',             'terms'     => $food_cats_array,         );     }     $food_menu_loop = new WP_Query($args);          $count = 1;     ?>                       <?php             if(ot_get_option('food_categories_order') != 'random') {                 $args = array(                     'orderby'       => 'name',                     'order'         => ot_get_option('food_categories_order'),                     'hide_empty'    => 1                     );             } else {                 $args = array(                     'orderby'       => 'none',                     'hide_empty'    => 1                     );             }                  if(empty($food_cats)) {                 $terms = get_terms('food_menu_categories', $args);             } else {                 $terms = wp_get_post_terms( $post->ID, 'food_menu_categories', $args );             }                  $menu_order = array();             foreach ($terms as $key => $row)             {                 $menu_order[$key] = $row->menu_order;             }             array_multisort($menu_order, SORT_ASC, $terms);                           $count = count($terms);                 if ( $count > 0 ){                          foreach ( $terms as $term ) {                              $meta = get_option('first_section');                         if (empty($meta)) $meta = array();                         if (!is_array($meta)) $meta = (array) $meta;                         $meta = isset($meta[$term->term_id]) ? $meta[$term->term_id] : array();                              if(isset($meta['icon'])) {                             $images = $meta['icon'];                             foreach ($images as $att) {                                 // show image                                 echo wp_get_attachment_image($att);                             }                         }                              echo '
';                         echo 'slug.'">';                         echo $term->name;                         echo '';                         echo '
';                          }                 }             ?>      The Loop & other stuff:               <?php while ($food_menu_loop->have_posts()) : $food_menu_loop->the_post();       $pricetag = rwmb_meta('verona_price');       $currency = rwmb_meta('verona_currency');       // Full image for lightbox       $fullsize = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');       $lightbox_img = $fullsize[0];            // Isotope slugs       $item_classes = '';       $item_cats = get_the_terms($post->ID, 'food_menu_categories');        if($item_cats) {         foreach($item_cats as $item_cat) {       $item_classes .= $item_cat->slug . ' ';        }      }     ?>


Wordpress site_url embedded in header_image() return value

I am developing a wordpress theme and am currently working on implementing a custom header functionality for the theme. Initially, I had no issue with applying a custom header image to the theme, but all of a sudden the `header_image()` began returning a value such as: `http://site_url/wp- content/themes/themename/img/headerimage.png` It seems that the `site_url()` function is not being executed and is embedded in the return value for `header_image()`. When using both `home_url()` and `site_url()` I am receiving the correct address // Code in header.php for displaying image               <?php $header_image = get_header_image();     if ( ! empty( $header_image ) ) { ?>          <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">            <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />               <?php }     ?>      // Code in custom-header.php for setting up custom header               function sens_gamer_custom_header_setup() {         $args = array(             'default-image'          => get_template_directory_uri() . '/img/sensationalgamerlogo1.png',             'width'                  => 221,             'height'                 => 90,             'header-text'            => false,             'wp-head-callback'       => 'sens_gamer_header_style',             'admin-head-callback'    => 'sens_gamer_admin_header_style',             'admin-preview-callback' => 'sens_gamer_admin_header_image',             'uploads'                => true,         );              $args = apply_filters( 'sens_gamer_custom_header_args', $args );              if ( function_exists( 'wp_get_theme' ) ) {             add_theme_support( 'custom-header', $args );         } else {             // Compat: Versions of WordPress prior to 3.4.             define( 'HEADER_IMAGE',        $args['default-image'] );             define( 'HEADER_IMAGE_WIDTH',  $args['width'] );             define( 'HEADER_IMAGE_HEIGHT', $args['height'] );             add_custom_image_header( $args['wp-head-callback'], $args['admin-head-callback'], $args['admin-preview-callback'] );         }     }     add_action( 'after_setup_theme', 'sens_gamer_custom_header_setup' );               if ( ! function_exists( 'get_custom_header' ) ) {         function get_custom_header() {             return (object) array(                 'url'           => get_header_image(),                 'thumbnail_url' => get_header_image(),                 'width'         => HEADER_IMAGE_WIDTH,                 'height'        => HEADER_IMAGE_HEIGHT,             );         }     }               if ( ! function_exists( 'sens_gamer_header_style' ) ) :          function sens_gamer_header_style() {              // If no custom options for text are set, let's bail         // get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value         if ( HEADER_TEXTCOLOR == get_header_textcolor() && '' == get_header_image() )             return;         // If we get this far, we have custom styles. Let's do this.         ?>                  <?php     }     endif; // sens_gamer_header_style


Count posts returned by get_posts in external PHP script

I'm using WP from an external PHP script by including the `wp-load.php` file. All functions and everything works as expected so far, except one thing: I can't get the `$wp_query->found_posts` to work after I fetch posts with `get_posts()` function. Any hints what should I be using instead? Thanks!


wp_get_archives(); Change output of link

Is it possible to edit the output of the wp_get_archives link at all? I'd like to prefix the link with a string. At the moment the output is something like url.com/2013/10 what I'd like it to do would be url.com/gallery/2013/10. "gallery" being a custom post type, at the moment the get_archives just goes to the standard posts archive, which is what it's supposed to do. Is it possible to duplicate the function and add a prefix somehow there? Any help greatly appreciated :)


When using a user role editor how to find out any plugins' or themes' role?

Suppose I'm using a Theme which has a custom panel in the admin area, or I'm using a Plugin, has similar Admin menu button. But all such button are only visible to Administrator. When I'm loggin in from an editor account they are gone. But I need them badly. I want an Editor can have access to those panels, and I want to let them the privilege. In that case I'll need to know the theme's or plugin's specific ROLE's or CAPABILITIES' name and then I'll need to assign 'em to a certain user. But here comes the million dollar question:   * HOW COME I FIND OUT A THEME'S OR PLUGIN'S SPECIFIC CAPABILITIES?              //suppose you have a custom role called 'architect' and you want to add a capability called `can access architect zone`     global $wp_roles;     $wp_roles->add_cap( 'architect', 'can_access_architect_zone' );      code cited from:this link How can I assume that the plugin or theme uses the 'can_access_architect_zone' as its capability?


Problem getting single_template filter to work - I want to serve a different single.php file for posts in a certain category

I am trying to customize the behavior of my blog to serve a specific single post template based on the category the post is assigned to. I came across this filter in my parent theme which is what gave me the idea. The theme is Photo Workshop by Graph Paper Press.               //add single post template depending on category slug          add_filter('single_template', 'gpp_single_template');          function gpp_single_template($single) {         global $wp_query, $post;                  foreach((array)get_the_category() as $cat) :                  // single posts template based on category slug             if(file_exists(TEMPLATEPATH . '/single-' . $cat->slug . '.php'))                 return TEMPLATEPATH . '/single-' . $cat->slug . '.php';                  //else load single.php               elseif(file_exists(TEMPLATEPATH . '/single.php'))                 return TEMPLATEPATH . '/single.php';              endforeach;              return $single;     }      Instead of overriding the file it uses (which may not be possible because it's included using TEMPLATEPATH), I thought it would be a better idea to just remove their filter & then add my own. Essentially, I'm not really trying to do something different than their code, but I want it to look in the child theme directory first which is why I am using the `locate_template()` function. In addition to that, I wanted to hard-code the highest priority template. My version of the filter from my child theme's `functions.php`:               // remove the stock filter     remove_filter('single_template','gpp_single_template');          // add the new one     add_filter('single_template', 'single_template_override');          //add single post template depending on category slug     function single_template_override($path) {         global $wp_query, $post;                  $categories = get_the_category();              $cat_slugs = array();         foreach ($categories as $cat) {             $cat_slugs[] = $cat->slug;         }              $templates = array();              // add in the top priorities if present         if (in_array('fine-art', $cat_slugs)) {                  // add to the beginning             $templates[] = 'single-fine-art.php';              }                   foreach($cat_slugs as $cat_slug) :                  // single posts template based on category slug             $filename = 'single-' . $cat_slug . '.php';                  // if not already in the array, add it             if (!in_array($filename, $templates)) {                 $templates[] = $filename;             }              endforeach;              $found = locate_template($templates, false);              if ($found) {                  return $found;              } else {                  return $path;              }     }      For some reason posts with the Fine Art category are not pulling the `single- fine-art.php` template. I have dug into the depths of the wordpress core to see where this filter is applied and everything seems like it should work to me. The filter can be found in `get_single_template()` which passes it's parameters to `get_query_template()`. Any help would be much appreciated!


Loop through all media library images and return those where caption contains the text carousel

Im new to Wordpress but I'm looking for a way to loop through all the images that have been uploaded to the media library and output the SRC, description and caption of the image when the caption contains the word 'carousel'. Is this possible?


Autogenerateing associated page on parent custom post type publishing

Goal: Automatically generate a child page whenever a custom post type ive created is published. Creation (and publication) of the main post type is done using a frontend form using the Custom-Metaboxes-and-Fields-for-WordPress plugin found here: https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for- WordPress/blob/master/init.php Say my post type is called "projects". whenever a "project" is published id like there to be a child page created ("Development")on which there will be commenting and and editing. hopefully the premalink structure could be like: websitename.com/project-name/development/ . Must i create another custom post type for this? how do i make it auto-generate on "project" publish and be associated with its specific parent? Ive read Automatically create child pages when saving a (parent) page. Not sure if its exactly what i need- how do i edit its code so it auto-generates on "project publish, not on update?


Where should I hook into admin?

Where should I hook into the admin backend to check and see if the user is "active" as defined by the Membership Plugin. Or in other words, where can I hook into the WP admin header to check an if- statement and redirect if it fails?


WP Northwind for Theme Development?

Is there any tool online that can quickly populate a WordPress3 database with faux information to assist in theme development? Perhaps creating 8 categories, inserting a dozen or so posts into each, adding a thumbnail for each, etc.


Custom query with query_posts doesn't show post without certain meta_key

I'm using query_posts to sort order certain categories. My code look like this:               query_posts('category_name=abs&orderby=meta_value_num&meta_key=field_ordering&order=DESC');      This does show post in exact sorting model as I specify. However, query above doesn't display that post doesn't have `meta_key` 'field_ordering' set in database. My problem is, I don't want to set it on ALL post, but I still can display the data. Any solutions?


how to embed external webpage in my wordpress page

I have two pages to embed within my WP site. Both contain data from an external site which runs our events management database. This data is presented on two pages - one for catering menus offered to our customers, the other is an inquiry/contact form. Two page links are given for embedding into my site. The information submitted by the customer on either page is collected onto our database within the third party site. Is this possible?


Getting the Intersection of Two Custom Taxonomy Terms for a Custom Post Type?

( **Moderators note** : Was originally titled _"How to get_posts of a custom post type that is in two custom taxonomies?"_ ) I have a custom post type that has two taxonomies which are separate, one called _"Project Type"_ and one called _"Package"_. I need to get a list of projects which are of _"Project Type"_ `A` **and** _"Package"_ `A`. I tried using following code:               $args = array(       'post_type' => 'portfolio',        'numberposts' => -1,        'project_type' => 'A',        'package' => 'A'     );      $my_posts = get_posts($args);        But this gets all the posts that are _EITHER_ in Project Type A OR Package A. Is there any way to say in `get_posts()` that I want to return only those posts that are in _BOTH_ taxonomies?


Routing 'fake' sub sub posts

I currently have these custom permalink rules: /%category%/%postname%/ I'd like /%category%/%postname%/%sometext% to display the same as /%category%/%postname%/ - from there, I will either use PHP or jQuery to display different content on the page. EG: /about-us/team/mike to display the /about-us/team page, and then I'll highlight 'Mike's bio' with jQuery. Thanks


How to install a translation for a WP plugin?

So I installed this plugin http://wordpress.org/extend/plugins/wp-email/ I need a Spanish translation. There is a link that takes you to a list of translation files: http://plugins.trac.wordpress.org/browser/wp-email/i18n/ So I downloaded wp-email-es_ES.mo and wp-email-es_ES.po How do I install a translation?


Why won't this jQuery code work?

Tearing my hair out a little bit here! I'm trying to create multiple image- selection boxes so users can upload as many images as they like to the species profile they've created. I'm using the following code in a .js file: jQuery(document).ready(function() {                   var i = 2;              jQuery('a#add_media').click(function() {             input_code = '
' +                 '<input id="upload_image-' + i + '" type="text" size="36" name="upload_image" value="" />' +                 '<input id="upload_image_button-' + i + '" type="button" value="Upload Image" />' +                 '
';             jQuery(input_code).appendTo('#upload_wrapper');             i++;         });              jQuery('[id^="upload_image_button"]').click(function() {             str = jQuery(this).attr('id');             substring = str.substring(str.length, str.length - 1);             id_to_pass = 'upload_image-' + substring;             alert(id_to_pass);             tb_show('', 'media-upload.php?type=image&TB_iframe=true');             return false;         });              window.send_to_editor = function(html) {             imgurl = jQuery('img',html).attr('src');             jQuery('#' + id_to_pass).val(imgurl);             tb_remove();         }          });      If I then view the DOM using Firebug, I can see that my input boxes appear correctly:
     Attach Image
     <input id="upload_image-1" type="text" value="" name="upload_image" size="36">     <input id="upload_image_button-1" type="button" value="Upload Image">

     <input id="upload_image-2" type="text" value="" name="upload_image" size="36">     <input id="upload_image_button-2" type="button" value="Upload Image">

     <input id="upload_image-3" type="text" value="" name="upload_image" size="36">     <input id="upload_image_button-3" type="button" value="Upload Image">
      Yet only the first button opens the upload frame? Thanks in advance.


How to retrieve sticky post in raw sql?

How I could made a sql query who retrieve all the sticky post in a wordpress database? This is because we use a new app over the old wordpress website database, and I don't know where Wordpress "store" the sticky attribute. Thanks in advance


How to order a taxonomy's terms numerically, from lowest to highest using get_terms

I'm using `get_terms` to output a taxonomy's terms, which are all numbers: For example: 4, 6, 8, 10, 12 How can I order these numerically, so they appear exactly as above? What I'm getting is actually: 10, 12, 4, 6, 8 I can see why it's done this (thinks 10 is first because it starts with a 1) but how can I fix it? I've tried all the ordering options on the codex for `get_terms` but can't seem to get them in order. Here's an example of what I have so far. I've even tried ordering by id and entering them in order but it still muddled it up. $taxonomy_array = get_terms('taxonomy-name', 'hide_empty=0');


Filter out built-in wp_nav_menu classes but keep custom class

Im trying to remove / filter our all the classes from the wp_nav_menu, EXCEPT the custom ones that i insert (in the "CSS Classes (optional)" field) when creating the menu in the admin. I found a function that removes EVERYTHING, but thats no good anybody got any ideas? thanks!


Which is the simplest theme for Wordpress to use it as your base?

I am building a new theme for my site, and I was wondering which is the simplest/lite theme with only the files needed like single.php index.php author.php and so on. I have read about wordpress themes and what files I have to include but I will have to code the default functions like wp-comments if I start from here. So I am looking for a lite theme to start over.


Help running a MySQL query to update all wp_#_options tables in a Multisite install

I'd like to run a query through my WordPress database that updates the blog_public values on all individual sites. I'm stuck on how to have the statement look for wp_2_options, wp_3_options, etc. I can do it individually with something like this:               UPDATE wp_10_options     SET option_value = REPLACE(option_value, '1', '0')      But am stuck on how to run a query that would go across all the tables. Any help? Thanks in advance :)


Want to redirect if search query match exact title of any post

I am using WordPress 3.3.1 and new to this system. I want to redirect the search query to the post if query exactly matches post title of some post. I also want it to run before any search query function and hooks or filter. I have made some changes in query.php in include folder               $search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}'))";      and wrote some plugin function like this:               add_action('template_redirect', 'single_result');     function single_result() {         if (is_search()) {             global $wp_query;             if ($wp_query->post_count == 1) {                 wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );             }         }     }      I have also some function that need to run just after this search query and has "get_header" hooks. So far the search query match and redirect is not matching and returning as aspected. It most of the time slips out and don't redirect perfectly. I want search and redirect to be very perfect. Any help will be highly appreciated and thankful. Thank you.


How to stop a specific person to comment on my blog?

I need to permanently prevent a specific person to comment on my blog on wordpress.com How can I do this, please ? My theme is iTheme2


How to get relative URL of medium sized featured image?

How to show featured image (medium sized) relative URL (relative to the website root)? I need something like this: `uploads/214/07/image-600x400.png` I tried with this:               if ( has_post_thumbnail()) {         $medium_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium');         echo $medium_image_url[0];       }      It works fine, I get path of medium sized featured image, but with domain name too, and I need it without domain name. Also I tried like this:               global $wpdb;     $the_thumbnail_id = get_post_thumbnail_id($post->ID);     $the_thumbnail_name = $wpdb->get_var( "SELECT meta_value FROM $wpdb->postmeta WHERE post_id = '$the_thumbnail_id' AND meta_key = '_wp_attached_file'" );     //     echo $the_thumbnail_name;      This works fine, I get just relative path, but "full" sized featured image path, and I need "medium" sized featured image path. Can anyone help me, maybe redesign (adding some parameter for "medium" size) of second function, or some new approach?


passing argument to get_template_part() or a better way to code

I have this include … `event-list.php`               <?php     /**      * The loop that displays upcoming events      */     ?>          <ul class="event-items">     <?php              $yesterday = time() - 24*60*60;         $args = array(              'post_type' => 'wr_event',              'posts_per_page' => -1, // show all posts              'meta_key' => 'event_date',              'orderby' => 'meta_value_num',              'order' => 'ASC',             'meta_value' => $yesterday,             'meta_compare' => '>'                    );              $loop = new WP_Query( $args );         while ( $loop->have_posts() ) : $loop->the_post();             get_template_part( 'inc/event', 'item' );         endwhile;         wp_reset_postdata();     ?>     </ul>      As you can see it's a custom query that compares a meta_key with the current date and only retrieves posts that are "newer" than yesterday. however in my archives I want to do it the other way around. On my index.php I have this `<?php get_template_part( 'inc/event', 'list' ); ?>` So this template above is getting executed and only retrieves events that are fresher than the last 24hours. In my `archives.php` though I'd like to reverse the `meta_compare` value from ">" to "<" so I get the rest of the posts. Is there a clever way of doing this? So in my archives.php I have this as well … `<?php get_template_part( 'inc/event', 'list' ); ?>` Can I somehow pass the 'meta_compare' value to this template? So I can have and use the same template file in my index.php and in my archives.php but with different 'meta_compare' values. Any ideas on that?


wp_next_scheduled() with jQuery Countdown

I'm working with the jQuery Countdown timer for the first time and I wanted to integrate it into my Wordpress site to display the time until the next scheduled cron event. When the countdown has reached 0, it grabs the next timestamp and begins counting down to that, and so on... ## What I have so far ### jQuery               /*      * Initialize the schedule countdown      */          var nextScheduledEvent = new Date( <?php echo wp_next_scheduled( 'execute_cron_events' ); ?> );          $('#countdown-table').countdown({         until: nextScheduledEvent     });      I'm not quite sure how to go about this, or if I am even on the right track. Does anyone have ideas suggestions that might help out? Thanks.


Custom excerpt function re-factoring

This may be more of a php best practices question, but here goes... I am using a custom excerpt trim function:               function new_wp_trim_excerpt($text) { // Fakes an excerpt if needed         global $post;         if ( '' == $text ) {             $text = get_the_content('');             $text = apply_filters('the_content', $text);             $text = str_replace(']]>', ']]>', $text);             $text = strip_tags($text, '
');             $text = preg_replace('@@si', '', $text);             $excerpt_length = 100;             $words = explode(' ', $text, $excerpt_length + 1);             if (count($words)> $excerpt_length) {                 $dots = '…';                 array_pop($words);                 $text = implode(' ', $words).$dots.'
ID) . '">Read More »</p';             }             else             {                 $text = get_the_content();             }         }         return $text;     }          remove_filter('get_the_excerpt', 'wp_trim_excerpt');     add_filter('get_the_excerpt', 'new_wp_trim_excerpt');      Basically, for posts over a hundred words, a "faked" excerpt is produced of the first 100 words, with a "Read More" link. Posts having less than 100 words are outputted in their entirety. You can see this at work here: http://www.mbird.com/ Complicating this matter is **1)** that an author can choose to override the excerpt per post. Also, **2)** there is a function that tries to find an image that can serve as a post thumbnail from the post attachments if none is specified. All these things act as flags, determining the layout of the post on the index page. For example, if a full post is output, it needs to have extra padding to avoid the image wrap CSS I have in place, and it shouldn't have a teaser thumbnail. If no teaser thumbnail can be found for a excerpt it needs to avoid the same. Etc etc. Anyway, in order to determine what the layout out wrapper should be, I end up reusing a lot of the `new_wp_trim_excerpt` function in my page template to sniff if an excerpt or a full post will happen. Like so:               <?php         while (have_posts ()) : the_post();             global $excerpt_checkbox_mb;              $exmeta = $excerpt_checkbox_mb->the_meta(); //override excerpt?             $text = get_the_content('');             $text = apply_filters('the_content', $text);             $text = str_replace(']]>', ']]>', $text);             $text = strip_tags($text, '
');             $text = preg_replace('@@si', '', $text);             $excerpt_length = 100;             $words = explode(' ', $text, $excerpt_length + 1);             if (count($words) > $excerpt_length) {                 $word_count = true;             } else {                 $word_count = false;             }         ?>      Then I use that to determine if an image should be hunted for:               <?php             if (($exmeta['cb_single'] != "yes") && $word_count) { // we're printing an excerpt, get a teaser image!                 get_the_image(array(                     'meta_key' => null,                     'image_class' => 'thumb',                     'callback' => 'find_image'                 ));             }             ?>      And finally what the wrapper should be:               <?php $image = find_image(); ?>                                      <?php if (($exmeta['cb_single'] == "yes") || !$word_count) : ?>
         <?php the_content();                         elseif ($image) : ?> // we found an image, apply css psuedo-col
          <?php the_excerpt();                         else : ?> // no image, reduce padding
                  <?php the_excerpt();                         endif; ?>
       Anyway, it seems bad to reuse so much of the `new_wp_trim_excerpt` function to sniff, especially since I have to change `$excerpt_length` in two places! But I can't really figure out an elegant way to re-factor. I was considering adding another function that both parts can call on, that would return array containing a bool regarding `count($words) > $excerpt_length` and optionally the text itself, but that still seems clunky. If you've somehow managed to read all this, help!


How would one change the default url structure of attachments?

When I click on post images it redirects in a page with a url like this: `http://localhost/?attachment_id=897`. Can I set the default image link like `http://localhost/wp-content/uploads/2012/05/dice.jpg` instead of `http://localhost/?attachment_id=818`? Also how to style the attachments page? Should I have a page like attachments.php?


Calling static method in the Widget Class

I have a widget               class Xwidget extends WP_Widget{     function cron_addB(){}          }      I want to run a cron job that calls that function from outside the class               function xxx_cron_activation() {   ;         if ( !wp_next_scheduled( 'xxx_followers' ) ) {         wp_schedule_event(time(), 'hourly', 'xxx_followers');     }     }     add_action('wp', 'xxx_cron_activation');          add_action('xxx_followers',array('Xwidget',"cron_addB"));      Cron is being triggered but the function is not being executed


Widget textarea input gets formatted

I've built a small widget for my website   It has a couple of inputs, and a `<textarea>` among others.   Whenever someone inputs to the textarea it adds a tab at the begining   and changes every ' to \'   After a couple of times I save the same input,   I just get sentences that were > It's nice to > It\\\\'s nice the code for the Textrea:                        <textarea rows="5" cols="40" id="cat_<?php echo $i ?>_text" name="cat_<?php echo $i ?>_text">             <?php echo $text ?>             </textarea>      Any ideas?


Removing permalink from post thumb in twentyeleven

possibly a simple thing to do but I'm not sure how it's done - I want to remove the permalink from a post thumb, in the default twentyeleven theme. Looked through content.php and the other templates and I can't see where to do this - is this something which should be handled as a custom filter in functions.php?


How can I combine posts of different types in one hierarchy?

I'd like to create a custom post type and add this as a child post of some but not all existing standard posts (which are not pages). Is this possible? Can I, for example, create a custom post type and then include this in other posts using a shortcode? Is there a better way to do this using custom taxonomies?


wp_dropdown_pages() in theme admin page

Scratching my head on this one. I have a theme option page, where I need the user to select a page to show at X location. I am using wp_dropdown_pages() to list my pages, and they show. But, I can't seem to be able to save the data/option and make sure the correct option is selected. Page list displaying correctly               $args = array(,     'echo'             => 1,     'selected' => $home_galleryselect,     'name'             => 'home_galleryselect');      wp_dropdown_pages($args);       function to update               function theme_options_validate($input) {     $input['home_galleryselect'] = (int) $input['home_galleryselect'];     return $input;       }       Help! thx


Limit access to posts/pages by user roles

I'm looking for a way to protect content by user roles. Example: you have to be registered to view posts (frontend). If a user is a subscriber he can read post 1, 2 and 3, but if the user is a contributor he can view post 1,2,3 and 4,5,6... does anyone know how I can do this?


Real automated and unattended wordpress upgrade including plugins

I'm looking for a truly automated way to upgrade wordpress and its plugins, something that i could put in the crontab and configure it to run daily. I have several wordpress plugins (>20) and a multi-site wordpress installation and I don't want to spend my time doing the upgrades. I am willing to take the risk of a upgrade failure and have the sites offline until I manually resolve the problem. Please do not post solutions that are requiring manual intervention in order to make the update/upgrade.


Easy way to inject js in tinymce iframe?

I was wondering if there any direct hook to inject some javascript into tinymce iframe?


Conflict between mathax and wp-Typography

Basically and the two plugins mentioned above installed and functioning. But in math posts, my math code is getting hyphenated, so I get mathjax errors like: `Undefined control sequence \righ` (the intended command was `\rightarrow`). Searching I could not find anyone with a similar problem, so I resorted to the wisdom of SE :-) Ideas? EDIT: here are the links for the plugins: Mathjax-latex and wp-Typography.


Changing the header on post listing page in admin area

I want to display my custom menu in custom post listing page under the title of custom post type. For example there are post type and one small icon on custom post type listing page as well as add/edit custom post type page. Under that icon I want to add my custom menu from my custom plugin. ![snapshot](http://i.stack.imgur.com/mNGwA.png) Can I add my menu at that place? One more thing is that can I add "Cancel" link to the add/edit page for go to listing page?


Display multi-select box choices in a bullet list

I have a form that includes a multi-select box.               <form method="POST" action="">       <select name="countries[]" size="5" multiple="true">       <option value="bolivia">Bolivia</option>       <option value="canada">Canada</option>       <option value="ireland">Ireland</option>       <option value="mexico">Mexico</option>       <option value="united states">United States</option>       </select>       <input type="submit" value="Submit" size="5"></p>     </form>      The code is displayed with the following PHP code:               <?php bp_member_profile_data( 'field=Countries' ); ?>      How do I separate the results into a bullet list?


Tool bar in editor missing in WP

I am having somewhat amazing problem. My client is in sweden. When I check the site from my country (Nepal), everything is fine. But tool in editor in wordpress panel is missing in sweden. I checked with teamwork and remote desktop. And he was right. And tool bar is missing in all browsers ( i checked in firefox , safari and chrome) And this is problem in current project only. My other projects in WP is working fine. So getting crazy.. I have disabled all plugins, update wordpress to latest verion 3.4. And still the problem exists. Please kindly help me to solve this problem.


include jquery plugin file not working

My code for include js as follows:               function you_fancy_js(){         wp_register_script( 'custom-script', plugins_url( '/js/jquery.js', __FILE__ ), array( 'jquery', 'jquery-ui-1.8.18.custom.min', 'jquery.validate.min' ) );           wp_enqueue_script( 'custom-script' );     }     add_action('wp_enqueue_scripts','you_fancy_js');     add_action('admin_head','you_fancy_js');      The above code should include a js file. It is not working.


How to create a multidimensional array with multiple loops

I have this loop where I loop through every post of my CPT and fetch the title and the content of each post and put it into an array. That is no problem. But as it happens I have created a repeatable field with Advanced Custom Fields that is present in each of these posts. These fields contains images and captions that I want to add to the array. Here's my current code               $args = array(         'posts_per_page' => '-1',         'post_type' => 'work',         'orderby' => 'ID',         'order' => 'DESC',     );          $data = array('work' => array());          $loop = new WP_Query($args);     if( $loop->have_posts() ):         while( $loop->have_posts() ): $loop->the_post();             $id = $loop->post->ID;             $data['work'][$id] = array(                 'title' => apply_filters( 'the_title', $loop->post->post_title ),                 'content' => apply_filters( 'the_content', $loop->post->post_content ),                          );         endwhile;     endif;     wp_reset_postdata();      Which outputs               {         "work":{             "45":{                 "title":"Project 7",                 "content":"
I am the other text.<\/p>\n"             },         }     }      And what I'm looking to have is something like this               {         "work":{             "45":{                 "title":"Project 7",                 "content":"
I am the other text.<\/p>\n"                 "items":{                     "1":{                         "caption":"I'm an image",                         "url":"www"                     },                     "2":{                         "caption":"I'm another image",                         "url":"www"                     },                 }             },     }      The loop that fetches the different attachments looks like this..               <?php if(get_field('work')): ?>     <?php while(has_sub_field('work')):         $attachment_id = get_sub_field('image');         $caption = the_sub_field('caption');         $image = wp_get_attachment_image_src( $attachment_id, work );         endwhile; ?>          <?php endif; ?>      ..but I can't wrap my head around how I get the result from this loop into the array. If someone could point me in the right direction I'd be very happy! Thanks.


Problems wp_insert_post and save_posts filter

I'm having an issue with using wp_insert_post. I'm adding the ability for a post of one type to create a post of another type with the first post as the post parent. I was testing out a few things using the save_posts filter. I created a function that simply creates a post and then hooked that function to the save_posts filter. The problem I'm having is that it is adding posts exponentially to my mySQL table. The longer I let it run before I put a freeze on the server, the more posts get added. Is there a better way of doing this? Example code:               public function save() {         $my_child = array(                     'post_title' => $this->_child_type,                     'post_content' => "test content",                     'post_status' => 'publish',                     'post_type' => "video",                     'post_parent'=> 55                   );         $nindex = wp_insert_post($my_child);     }     add_action('save_post', array(&$this, 'save'));


Custom Post Type Archives with 0 Posts Redirects as 404

I'm working with the new custom post type archives in 3.1 and I noticed that when my post type has 0 posts, the archive for the type results in a 404. Looking at the order of hooks being processed, it's redirecting to the 404 template before even processing my archive-{post_type}.php template and reaching the conditional for available posts. Reading various articles and questions here had clued me in on flushing the permalink state after creating my types. This shouldn't be an issue, however, as the archive page works if posts for the type exist. I even went as far as setting my has_archive value to the post type slug rather than just true to no avail. Is there a way to force the archive template to be loaded and not generate a 404 regardless of post count while keeping the query in place?


Wordpress 3.0 embedded images

Wordpress 3.0 and newer does not allow you to remove the links placed on images without manually striping it withing the html. Any idea how to do that by default?