How to hook something before edit_form_title?

It's amazing to use the `edit_form_after_title` hook to enqueue something just below the post editor's title field. But there is nothing opposite to this like: _`edit_form_before_title`_. Searching over the Internet, found the trac treasure with a solution saying: > _Add an`edit_form_top` hook to the post edit form._ That's pretty! But that's not exactly what I's looking for. That's taking the whole top part of the form, not behaving like the Title field on the editor.   ![edit_form_top hook renders like this](http://i.stack.imgur.com/mnH9s.png) Is there any solution/hook I can use so that the thing I'm hooking looks exactly like the Title field (not taking the whole top part of the form, but renders on the left part only.)? ### EDIT And also, if I use `edit_form_top` then if I use any input field to add meta_value to the post, then it'll be failed because `edit_form_top` adds the _thing_ **outside the form**. SPECIFICALLY, I need to add a custom input field to add meta_value to the post. I don't want to use any plugin.


Wordpress Shortcode loads at the top

I tried all solutions of the topics here but I haven't been able to find a solution. I made a Plugin for a Shortcode. My problem is that the plugin code get always loaded above the content. I already found out that it comes from the use of `echo`. Instead I should use `return`. But as soon I replace the `echo` the plugin stops working! ;( It would be great if someone could help me. Thank you!               function sublime_video_playlist() {     wp_enqueue_script('sublime_video', '' .plugins_url( '/js/sublime_playlist.js' , __FILE__ ). '');          global $post;          $attachments = get_children( array(                     'post_parent'    => $pageChild->ID,                     'post_type'      => 'attachment',                     'numberposts'    => 1, // show all -1                     'post_status'    => 'inherit',                     'post_mime_type' => 'video',                     'order'          => 'ASC',                     'orderby'        => 'menu_order ASC'                     ) );               if ( $attachments ) {            echo '

';       echo '
Videos
';            echo '
';            $args = array(         'post_type' => 'attachment',         'post_mime_type' => 'video',         'numberposts' => null,         'post_status' => null,         'orderby' => 'title',         'post_parent'    => $post->ID     );          $attachments = get_posts($args);          if ($attachments) {         foreach ($attachments as $attachment) {             echo '
';             echo '<video width="568" height="320" id="video';             echo $attachment->ID;             echo '" data-settings="autoresize:fit" poster="';             echo '" preload="true">';             echo '<source src="';             echo wp_get_attachment_url ($attachment->ID);             echo '" /></video>';             echo '
';              }              echo '
';          $args = array(         'post_type' => 'attachment',         'post_mime_type' => 'video',         'numberposts' => null,         'post_status' => null,          'orderby' => 'title',         'post_parent' => $post->ID     );      $attachments = get_posts($args);          if ($attachments) {         foreach ($attachments as $attachment) {             echo '
ID;             echo '">   ID));             echo '" width="144" height="71" />
';          }     }               echo '

';                  if(function_exists('render_tnwsc_button')) {                     echo render_tnwsc_button();                 }         echo '
';          }     }     }     add_shortcode('video_playlist', 'sublime_video_playlist');  ?>


Rewriting a page driven by custom fields to populate a page dynamically, like posts

I'm relatively new to Wordpress and I received a site theme that was developed by outsourced developers. Due to the inevitable scope creep, i've had to modify pages to work with the new scope. http://dsi.sva.edu/news-and-events/ This page is populated by custom fields. Since it's a news page, we want the newest article to appear top left in the grid of pictures. Because the backend is set up with custom fields, we would need to manually re-enter all of the custom fields just to get the new article to appear before the others. Can anybody recommend a way of rewriting the backend to allow for this? Or at least refer me to articles that may help? Also, as new lines of posts are added to the bottom of the page, they're pushing the page up upon load, causing the header to get pushed up. Is there any way to fix that as well? Thanks! Thanks! Thanks!


How to disable Multisite sign-up page?

If we try to access a non-existant Multisite site, e.g., `http://site1.example.com` or `http://example.com/site1/`, we are redirected to `http://example.com/wp-signup.php?new=site1`. How to block this and redirect the browser to another page?


Is there a way to hide a user's posts from their Activity feed?

I'm helping out a friend who runs a paid membership site, and he recently discovered that any public user can access some of the pay content by going to a particular user's Activity feed. He's asked me to fix this for him, but I think it'll require delving into the theme code, and I'm not at all familiar with the WordPress ecosystem (I'm an experienced web programmer, but only with Python and Drupal). Is there some general kind of thing I should be looking for to figure out how to prevent this content from showing up on the creator's Activity log page? The site is using the Iconic One Pro theme, and the Paid Memberships Pro plugin to handle the pay wall.


Display post X of Y in category

I am trying to display a post number ( **X** ) on each single.php, based on what number that post is in it's category, followed by the total number of posts ( **Y** ) in the category. So if there is 10 posts in my category "photos", the latest post should be "1/10". **I found this solution for Y:**               <?php     $category = get_the_category();      echo $category[0]->category_count;     ?>       **This solution almost does what I want for X** , but it is not based on category, and includes all posts: http://wordpress.org/support/topic/show- post-number#post-1294235 Can anyone help? :-)


Is it advisable to run multisite from its own directory?

I have to create a bilingual site. I've decided to take the multisite approach, creating a different site for each language and linking those two version with a plugin. I intend to use subfolders like these:               example.com/en     example.com/es      I have already created a first draft for the English version of this web (just a regular version of WordPress without multisite functions) which is working from within its own folder. I was hoping to be able to just activate multisite for that version and run `index.php` from the root (once I've finished working on the contents). But I've read that it's difficult to get the multisite working if it isn't installed directly to the domain, the problem is that I can't take down the current site on the main domain right now. My question is: should I activate multisite functions from within the current directory? Or would it be better if I create a new installation at the root directory in my host?


Page template not displaying

I dont get why this isnt working. I have a custom page template, page- politics.php. It should look similar to this page: ![banking transaction page](http://i.stack.imgur.com/MXR0q.png) But its displaying this: ![campaign contribution page](http://i.stack.imgur.com/AfSZW.png) Ive double, triple checked that the right template is assigned to the right page. ![page settings for campaign office page](http://i.stack.imgur.com/NuqpT.png)


Prevent moveform() to moving the original location of comment form

I have a post with comment enabled, also enabled threaded comment with max level 3. Each time I want to do a comment reply, the form comment box is moving to the comment which I want to reply. But I don't want the original location of form comment moving to the comment I want to reply, instead, I want the form duplicated. One form comment stay in the original position, and the other one is located on the comment I want to reply. How I can solve this problem? Thank you.


Sort posts in dashboard using custom field; also include posts where field isn't set

I'm using a pre_get_posts filter found on this question thread here, to sort a custom post type in the dashboard:               function xyz_event_sort_order( $wp_query ) {         if ( is_admin() ) {             $post_type = $wp_query->query['post_type'];             if ( $post_type == 'event' ) {                 $wp_query->set( 'meta_key', 'x_start_date' );                 $wp_query->set( 'orderby', 'x_start_date' );                 $wp_query->set( 'order', 'DESC' );             }         }     }     add_filter( 'pre_get_posts', 'xyz_event_sort_order' );      The filter sorts the events as expected, but events where the custom field has not been set (old events imported from another WP install) will, obviously, no longer show at all. I'm trying to do a meta_query that uses EXISTS and NOT EXISTS and still sorts by the meta_key specified above, but have had no luck. Anybody know how I might also include events where *x_start_date* is missing and then add date as a second orderby option like: `( 'orderby', 'x_start_date date' );`


plugin_action_links Filter Hook Deprecated?

http://adambrown.info/p/wp_hooks/hook/plugin_action_links_%7B$plugin_file%7D Says the hook is deprecated. However, the {$prefix}plugin_action_hook_{$plugin_file} is not. I poked around the `wp- admin/includes/class-wp-plugins-list-table.php` file for the hook, and found this:               $actions = apply_filters( $prefix . "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );      `$prefix` is defined a few lines above:               $prefix = $screen->is_network ? 'network_admin_' : '';      Since I was able to get my add_filter call to `plugin_actions_row_{$plugin_file}` to work, I'm assuming the filter hook is still there. Well, sort of: the filter is still available as it's not a network admin screen. Correct? And one could use...               add_filter( 'network_admin_plugin_action_links_{$plugin_file}', 'do_something' )      ...to put a link into the network's plugin screen?


Setting selected term_id with wp_dropdown_categories?

I'm using this code to get the term_id of a custom taxonomy. The drop down does list the terms of the taxonomy Type. When I print the $terms variable I see the term ID of the post i'm editing on the front end. Why isn't the term ID being set as the selected option?               $terms = get_the_terms( $current_post, 'Type' );     print_r($terms);     wp_dropdown_categories( 'taxonomy=Type&hierarchical=1&hide_empty=0&id=cat&show_count=0&selected=' . $terms[0]->term_id );      This is the output of the array               Array ( [25] => stdClass Object ( [term_id] => 25 [name] => Sativa [slug] => sativa [term_group] => 0 [term_icon] => http://pothwy.com/wp-content/themes/GeoPlaces/images/default.png [term_price] => 0 [term_taxonomy_id] => 53 [taxonomy] => Type [description] => [parent] => 0 [count] => 4 [object_id] => 563 ) )      Output of HTML               <select name="cat" id="cat" class="postform">         <option class="level-0" value="25">Sativa</option>         <option class="level-0" value="52">Indica</option>     </select>


Changing "submitted on date" of comments

How do I change the "submitted on date" of a comment to an earlier date? I want to change the date that is displayed to the readers. As far as I know, I can change the date of the post by clicking the "quick edit" option. Is there something similar I can do with comments?


Our shortcode dropdown box in Tinymce is not working in WordPress 3.9?

Hi since the new version is about to be released I thought I would download it and see if my theme works still. Everything works great apart from the dropdown box which is now longer showing. Here is the codes we used to show it in previous versions. PHP CODE:               function register_ppp_shortcodes( $buttons ) {        array_unshift( $buttons, "Shortcodes" );        return $buttons;     }          function add_ppp_shortcodes( $plugin_array ) {        $plugin_array['Shortcodes'] = get_template_directory_uri() . '/js/Shortcodes_js.js';        return $plugin_array;     }          function ppp_shortcodes() {             if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {           return;        }             if ( get_user_option('rich_editing') == 'true' ) {           add_filter( 'mce_external_plugins', 'add_ppp_shortcodes' );           add_filter( 'mce_buttons', 'register_ppp_shortcodes' );        }          }          add_action('init', 'ppp_shortcodes');      JS CODE:               /*global tinyMCE, tinymce*/     /*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:true, undef:true, unused:true, curly:true, browser:true, devel:true, maxerr:50 */     (function() {     "use strict";                 tinymce.create('tinymce.plugins.Shortcodes', {                  init : function(ed, url) {               ed = ed;                 url = url;             },             createControl : function(n, cm) {                      if(n==='Shortcodes'){                     var mtb = cm.createListBox('Shortcodes', {                          title : 'Shortcodes',                          onselect : function(p) {                             var selected = false;                             var content = '';                             switch (p){                                  case 'H1 Title':{                                      var h1titleclass = prompt("Would you like a custom class?", "");                                      selected = tinyMCE.activeEditor.selection.getContent();                                      if(h1titleclass != ''){                                     h1titleclass = 'class= "'+h1titleclass+'"';                                 }                                      if (selected) {                                     content = '[h1'+h1titleclass+']' + selected + '[/h1]';                                 } else {                                     content = '[h1'+h1titleclass+'][/h1]';                                 }                                      tinymce.execCommand('mceInsertContent', false, content);                                  } // finished shortcode                             break;                                  case 'H2 Title':{                                      var h2titleclass = prompt("Would you like a custom class?", "");                                      selected = tinyMCE.activeEditor.selection.getContent();                                      if(h2titleclass != ''){                                     h2titleclass = 'class= "'+h2titleclass+'"';                                 }                                      if (selected) {                                     content = '[h2'+h2titleclass+']' + selected + '[/h2]';                                 } else {                                     content = '[h2'+h2titleclass+'][/h2]';                                 }                                      tinymce.execCommand('mceInsertContent', false, content);                                  } // finished shortcode                             break;                                  }                             }                     });                               // Add some menu items                     var my_shortcodes = ['H1 Title','H2 Title'];                          for(var i in my_shortcodes){                       if (true) {mtb.add(my_shortcodes[i],my_shortcodes[i]);}                     }                          return mtb;                 }                 return null;             }                   });         tinymce.PluginManager.add('Shortcodes', tinymce.plugins.Shortcodes);     })();      Can anyone point me in the right direction on where to start. I know very little about tinymce as you can tell :( Thanks


Use .htaccess to redirect homepage to its permalink

How can I get WordPress to preserve my permalink that I have set for the homepage? I would like the homepage's URL to be `www.example.com/homepage-title`, not `www.example.com`. Its permalink is already set to `www.example.com/homepage- title`, but on navigation to the site I would like it to redirect to `www.example.com/homepage-title` instead of `www.example.com`.


How to create/modfiy WP_Query to search in post title OR custom field?

I need to modify or create a WP_Query that will search for a search term in both the post title OR a custom field (called 'my_field'). I have been reading and trying for hours, but I am right back to this code (below) which, alas, only searches in 'my_field' and does not take the post_title into account.               function my_pre_get_posts_2( $query ) {     if ( is_admin() && $query->is_main_query() && $query->query['post_type'] === 'post' && isset($query->query['s']) ) {              $search_word = $query->query['s'];              $args = array(             //'s' => $search_word, //If I include this line, the WP query seems to AND post_title and my_field. If I comment out this line, the WP query only searches in my_field             'post_type' => 'post',             'meta_query' => array(                 'relation' => 'OR',                 array(                     'key' => 'my_field',                     'value' => $search_word,                     'compare' => 'IN'                 ),                 array(                     'key' => 'post_title',                     'value' => $search_word,                     'compare' => 'IN',                 )             )         );              //$query = new WP_Query( $args ); //Need to modify the existing WP_Query         $query->init();         $query->parse_query($args);     }          }     add_action( 'pre_get_posts', 'my_pre_get_posts_2' );      The reason I need to do this is because I need to modify the behaviour of the the 'Search Posts' button in the 'All Posts' (admin) page so that whatever the admin user searches for, it will return the posts that have a matching post title OR my_field value.


One loop for sticky, one for all the rest - how, without specifying category?

I have styled an archive page to display one sticky post at the top with special design, and then to display all the rest of the posts in that category (except the sticky post) listed in standard title/excerpt format. I have specified the target category for both loops: Sticky only:               <?php $args = array(     'cat' => 3,     'posts_per_page' => 1,     'post__in'  => get_option( 'sticky_posts' ),     'ignore_sticky_posts' => 1                       );          query_posts( $args );?>      All the rest:               <?php      $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;     $sticky = get_option( 'sticky_posts' );                          $args = array(         'cat' => 3,         'ignore_sticky_posts' => 1,         'post__not_in' => $sticky,         'paged' => $paged,         'orderby' => 'menu_order',           'order' => 'ASC'      );      query_posts( $args ); ?>      I have made custom category.php templates for each category with the 'cat' ID added manually in each loop. My question: Is it possible to do this without manually setting the cat ID? I have tried but end up with all posts rather than just the category variable. thx - Steve


Can't get result from sql using ajax result

I'm using an AJAX form to feed the code something to lookup in db. Separate table, not WP options. I'm getting the result from AJAX, but when I try to do the sql it just returns 0. This is the function:                  function myajax_inputtitleSubmit_func() {         // check nonce         $nonce = $_POST['nextNonce'];            if ( ! wp_verify_nonce( $nonce, 'myajax-next-nonce' ) )             die ( 'Busted!');              $zipcode = $_POST['zip'];         // generate the response         global $wpdb;         $tablename  = "{$wpdb->prefix}levering";              $sql    = "SELECT Levering FROM {$tablename} WHERE Zip LIKE %s";         $result = $wpdb->get_var($wpdb->prepare($sql, $zipcode));         return $result;         while($row = mysql_fetch_array($result)) {              $response = $row['Levering'];             }              // response output         header( "Content-Type: application/json" );         echo $response;         die();         // IMPORTANT: don't forget to "exit"         exit;     }


How to make a slideshow shortcode based on the Wordpress gallery shortcode?

This is the wordpress function for the gallery shortcode, i would like to understand how this works so i can implement a slideshow shortcode and adding the img id only as gallery shortcode does.                   function gallery_shortcode($attr) {     $post = get_post();          static $instance = 0;     $instance++;          if ( ! empty( $attr['ids'] ) ) {         // 'ids' is explicitly ordered, unless you specify otherwise.         if ( empty( $attr['orderby'] ) )             $attr['orderby'] = 'post__in';         $attr['include'] = $attr['ids'];     }          // Allow plugins/themes to override the default gallery template.     $output = apply_filters('post_gallery', '', $attr);     if ( $output != '' )         return $output;          // We're trusting author input, so let's at least make sure it looks like a valid orderby statement     if ( isset( $attr['orderby'] ) ) {         $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );         if ( !$attr['orderby'] )             unset( $attr['orderby'] );     }          extract(shortcode_atts(array(         'order'      => 'ASC',         'orderby'    => 'menu_order ID',         'id'         => $post ? $post->ID : 0,         'itemtag'    => 'dl',         'icontag'    => 'dt',         'captiontag' => 'dd',         'columns'    => 3,         'size'       => 'thumbnail',         'include'    => '',         'exclude'    => '',         'link'       => ''     ), $attr, 'gallery'));          $id = intval($id);     if ( 'RAND' == $order )         $orderby = 'none';          if ( !empty($include) ) {         $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );              $attachments = array();         foreach ( $_attachments as $key => $val ) {             $attachments[$val->ID] = $_attachments[$key];         }     } elseif ( !empty($exclude) ) {         $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );     } else {         $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );     }          if ( empty($attachments) )         return '';          if ( is_feed() ) {         $output = "\n";         foreach ( $attachments as $att_id => $attachment )             $output .= wp_get_attachment_link($att_id, $size, true) . "\n";         return $output;     }          $itemtag = tag_escape($itemtag);     $captiontag = tag_escape($captiontag);     $icontag = tag_escape($icontag);     $valid_tags = wp_kses_allowed_html( 'post' );     if ( ! isset( $valid_tags[ $itemtag ] ) )         $itemtag = 'dl';     if ( ! isset( $valid_tags[ $captiontag ] ) )         $captiontag = 'dd';     if ( ! isset( $valid_tags[ $icontag ] ) )         $icontag = 'dt';          $columns = intval($columns);     $itemwidth = $columns > 0 ? floor(100/$columns) : 100;     $float = is_rtl() ? 'right' : 'left';          $selector = "gallery-{$instance}";          $gallery_style = $gallery_div = '';     if ( apply_filters( 'use_default_gallery_style', true ) )         $gallery_style = "         ";     $size_class = sanitize_html_class( $size );     $gallery_div = "
";     $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );          $i = 0;     foreach ( $attachments as $id => $attachment ) {         if ( ! empty( $link ) && 'file' === $link )             $image_output = wp_get_attachment_link( $id, $size, false, false );         elseif ( ! empty( $link ) && 'none' === $link )             $image_output = wp_get_attachment_image( $id, $size, false );         else             $image_output = wp_get_attachment_link( $id, $size, true, false );              $image_meta  = wp_get_attachment_metadata( $id );              $orientation = '';         if ( isset( $image_meta['height'], $image_meta['width'] ) )             $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape';              $output .= "<{$itemtag} class='gallery-item'>";         $output .= "             <{$icontag} class='gallery-icon {$orientation}'>                 $image_output             </{$icontag}>";         if ( $captiontag && trim($attachment->post_excerpt) ) {             $output .= "                 <{$captiontag} class='wp-caption-text gallery-caption'>                 " . wptexturize($attachment->post_excerpt) . "                 </{$captiontag}>";         }         $output .= "</{$itemtag}>";         if ( $columns > 0 && ++$i % $columns == 0 )             $output .= '
';     }          $output .= "

\n";          return $output;


the_excerpt() or get_the_excerpt with shortcode escape

I have few posts which have a dropcap shortcode wrapped around the first character like so:               [dropcap]T[/dropcap]his is a dropcap.       The replacement for this shortcode yields:               This is a dropcap.      However, when I call the_excerpt() or get_the_excerpt() on these posts, its returning:               "his is a dropcap".      I need it to return "This is a dropcap" as if no shortcode exists.


Finer level user access to WordPress pages/posts

Let's say there are four pages/posts > p1, p2, p3, p4 and four users > u1, u2, u3, u4 in Wordpress. How do I restrict access for p1, p2 to u1, u2 and restrict access for p3, p4 to u3, u4? I tried a couple of plugins, but none of them were giving a finer level access as mentioned above.


Gallery backend only

I'm using Wordpress to power the blog section of my website, and also my event timeline (using custom post type admin area). I'm looking to add the option to create image galleries, and include them in posts using a custom tag. I would like to handle the entire front end integration myself, just using the db data and files uploaded by a gallery plugin. Are there any good back end only solutions for creating galleries or should I just roll my own?


Amazon Cloudfront + WP Super Cache

Using WP Super Cache - I have switched to Amazon Cloudfront from MaxCDN. Amazon Cloudfront does not gzip resources as MaxCDN does hence i am facing a very low page speed test. This Amazon Help page explains how to compress files Hence, I have set up my .htaccess file as below:               AddType x-mapp-php5 .php      AddHandler x-mapp-php5 .php     AddType application/x-font-woff woff     AddType application/x-font-ttf ttf     AddType application/vnd.ms-fontobject eot          # compress text, HTML, JavaScript, CSS, and XML     AddOutputFilterByType DEFLATE text/plain     AddOutputFilterByType DEFLATE text/html     AddOutputFilterByType DEFLATE text/xml     AddOutputFilterByType DEFLATE text/css     AddOutputFilterByType DEFLATE application/xml     AddOutputFilterByType DEFLATE application/xhtml+xml     AddOutputFilterByType DEFLATE application/rss+xml     AddOutputFilterByType DEFLATE application/javascript     AddOutputFilterByType DEFLATE application/x-javascript          # remove browser bugs     BrowserMatch ^Mozilla/4 gzip-only-text/html     BrowserMatch ^Mozilla/4\.0[678] no-gzip     BrowserMatch \bMSIE !no-gzip !gzip-only-text/html     Header append Vary User-Agent          # Set Expires Headers     <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">     Header set Expires "Thu, 15 Jan 2015 20:00:00 GMT"     </FilesMatch>          <IfModule mod_headers.c>       <FilesMatch "\.(js|css|xml|gz)$">         Header append Vary: Accept-Encoding       </FilesMatch>     </IfModule>          # Set the cache-control max-age     # 1 year     <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">     Header set Cache-Control "max-age=31449600, public"     </FilesMatch>     # 2 DAYS     <FilesMatch "\.(xml|txt)$">     Header set Cache-Control "max-age=172800, public, must-revalidate"     </FilesMatch>     # 3 DAYS     <FilesMatch "\.(html|htm)$">     Header set Cache-Control "max-age=604800, must-revalidate"     </FilesMatch>          # Turn off the ETags     Header unset ETag     FileETag None          ServerSignature Off     LimitRequestBody 10240000     ErrorDocument 500 /error.php          RewriteEngine On     RewriteCond %{REQUEST_FILENAME} !-f     RewriteRule \.(jpg|jpeg|png|gif|ico|swf|bmp)$ - [nocase,redirect=404,last]               ############################################################################################     #Section 1     RewriteEngine On     IndexIgnore *     Options +FollowSymLinks -Multiviews -Indexes     ############################################################################################     # ----------------------------------------------------------------------     # CORS-enabled images (@crossorigin)     # ----------------------------------------------------------------------          # Send CORS headers if browsers request them; enabled by default for images.     # developer.mozilla.org/en/CORS_Enabled_Image     # blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html     # hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/     # wiki.mozilla.org/Security/Reviews/crossoriginAttribute          <IfModule mod_setenvif.c>       <IfModule mod_headers.c>         # mod_headers, y u no match by Content-Type?!         <FilesMatch "\.(gif|png|jpe?g|svg|svgz|ico|webp)$">           SetEnvIf Origin ":" IS_CORS           Header set Access-Control-Allow-Origin "*" env=IS_CORS         </FilesMatch>       </IfModule>     </IfModule>               # ----------------------------------------------------------------------     # Webfont access     # ----------------------------------------------------------------------          # Allow access from all domains for webfonts.     # Alternatively you could only whitelist your     # subdomains like "subdomain.example.com".          <IfModule mod_headers.c>       <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">         Header set Access-Control-Allow-Origin "*"       </FilesMatch>     </IfModule>     ############################################################################################     RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]     RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]     RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]     RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})     RewriteRule ^(.*)$ index.php [F,L]     ############################################################################################     # Deflate files to fasten the loading     <IfModule mod_deflate.c>         SetOutputFilter DEFLATE         AddOutputFilterByType DEFLATE application/x-httpd-php text/html text/xml text/plain text/css text/javascript application/javascript application/x-javascript image/jpeg image/jpg image/png image/gif font/ttf font/eot font/otf     </IfModule>     <IfModule mod_headers.c>         # properly handle requests coming from behind proxies         Header append Vary User-Agent     </IfModule>     <IfModule mod_deflate.c>         # Properly handle old browsers that do not support compression         BrowserMatch ^Mozilla/4 gzip-only-text/html         BrowserMatch ^Mozilla/4\.0[678] no-gzip         BrowserMatch \bMSIE !no-gzip !gzip-only-text/html         # Explicitly exclude binary files from compression just in case         SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|pdf|swf|ico|zip|ttf|eot|svg)$ no-gzip     </IfModule>     ############################################################################################      Still resources coming from Amazon CDN are not compressed - I am thinking I need to verify proper Cache Control settings but I can't figure it out as yet. Has anyone else experienced this?


Frontend Post Excerpt field mapping

I'm trying to create a form with gravity forms. I need to merge two fields to one Excerpt. I can't give the Excerpt field a merge tag. So I'm trying to use an custom field. My question is now: what is the WP Parameter to map the Excerpt to the post. I've tried: the_ excerpt, _excerpt, post_excerpt, etc. But it never appears in the Excerptfield...


Allow duplicate permalink slugs for posts in different categories

I have my permalink format set to `/%category%/%postname%/` and I have two posts with the same permalink slug, but in different categories. Ideally, the two permalinks should look like this:               http://example.com/category-1/post-title/     http://example.com/category-2/post-title/      But when I publish the second post, then its slug is changed to `post- title-2`, which makes the resulting URL `http://example.com/category-2/post- title-2/`. How can I use the same slug for multiple posts that are in different categories? This WordPress Support topic suggests using an outdated plugin that doesn't work anymore.


Separate attachment images from post loop

I'm trying to create an array of images for a slideshow gallery script, so need to separate the images from the post loop - any ideas of the best way to achieve this and make it easy to add images? I can use a script to grab attachments (see below) but it seems a bit messy as:   1. image uploaded appear in the post text area and then meed to be deleted otherwise there is duplication.   2. you can't delete and image except by going into the media library and deleting it there.  http://digwp.com/2009/08/awesome-image-attachment-recipes-for-wordpress/ Would the better option be to use something like the more fields plug-in and create multiple text fields to post the urls of photos in? So they use the media library to upload images and grab the urls to put in the post. Ideally I'm trying to get a simple scenario where they just upload the images in one go as a gallery or individual images, write their gallery description text, and save.


Can I delete plugin files using FTP?

Due to a PHP upgrade on my server, one of my installed plugins stopped working and throws a fatal error. As I can't login to admin area of the site as a result of the plugin failure I can't uninstall that plugin. Now can I delete plugin's files directly using FTP? Will this cause any problems? **Update** I've found, the culprit plugin was unnecessary, I've removed the plugin files using ftp, now site is back, no errors. But I dontt know if this is the proper way. If that plugin were necessary, I would reply the files using new available version.


wp_insert_user function not adding password field to database

I have a project in which i made a custom registration page but the problem is that my password field value not added to the database while email and username properly added. I could not understand why password value not stored. this is my php code.                   $pwd1 = $wpdb->escape(trim($_POST['pwd1']));         $pwd2 = $wpdb->escape(trim($_POST['pwd2']));         $first_name = $wpdb->escape(trim($_POST['first_name']));         $last_name = $wpdb->escape(trim($_POST['last_name']));         $email = $wpdb->escape(trim($_POST['email']));         $username = $wpdb->escape(trim($_POST['username']));                     if( $email == "" || $pwd1 == "" || $pwd2 == "" || $username == "" ||                      $first_name              == "" || $last_name == "") {             $err = 'Please don\'t leave the required fields.';         } else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {             $err = 'Invalid email address.';         } else if(email_exists($email) ) {             $err = 'Email already exist.';         } else if($pwd1 <> $pwd2 ){             $err = 'Password do not match.';                } else {                  $user_id = wp_insert_user( array ('user_login' => apply_filters('pre_user_user_login', $username), 'user_pass' => apply_filters('pre_user_user_pass', $pwd1 ), 'user_email' => apply_filters('pre_user_user_email', $email), 'role' => 'subscriber' ) );             if( is_wp_error($user_id) ) {                 $err = 'Error on user creation.';             } else {                 do_action('user_register', $user_id);                      $success = 'You\'re successfully register';             }              }      this is my html code

Username:            <input type="text" id="username" name="username" required="required"

First Name:                <input type="text" name="first_name" >

Last Name:           <input type="text" name="last_name" >

Email:           <input type="text" name="email" >

Password:         <input type="password" name="pwd1" >

Confirm Password:         <input type="password" name="pwd2" >

      please tell me what is wrong with this.


Are custom tables a good solution for adding lots of data to the site?

On a fairly high trafficked website (10-20 million page views per month), we're looking to add a large amount of data to build data-driven pages. Think of adding 1000s of restaurants to create restaurant profile pages. Obviously we could go the custom post type route with a few different types of post types such as (cities, restuarants, etc.) but my concern is dumping all of this data into the posts and post meta database tables? I've read about custom tables, but I'm also a bit hesitant to go outside the standard wordpress procedures. What is the correct approach here if we're assuming tens of thousands of data objects added to a high traffic website which already publishes 300 blog posts per month or so?


![Removing default image size list in Media Box](http://i.stack.imgur.com/8xYfy.gif) I trying to remove unused image size (Thumbnail, Medium, Large) in MediaBox Any function can i use in functions.php ? or some trick ? PS : I know i can use jQuery trick but any better function to use ?


post_content is empty

I'm trying to make some plugin. This plugin is some kind of auto posting.               function new_post($title,$content)     {     $post = get_post($id);     $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );     $title = $post->post_title;     $content = $post->post_content;     echo $title;     echo $content;     }     add_action( 'publish_post', 'new_post' );      I can see only `$title`, `$content` is empty. I've checked mysql in draft status, I can see `post_title` fields has data but `post_content` has no data. `post_content` has data when I click publish or auto save. I think this plugin run faster than wordpress insert data process. This plugin have to run after publish or make different way. How can I fix this code... I hope wordpress developer's can help.


How to reply to Buddypress notifications?

Currently, when I receive notifications from Buddypress, I have to log in the site to post a comment on an event, or a reply to a message. Is there a way to reply directly in the MUA ? My idea was to generate a UUID that would be used as a reply-to field ,e.g. msg.59326d09-821e-4d32-b77c-096ac7507a02@reply.domain.com , find the related event when the message is received using postfix content filter, parse the email body to extract the reply, and to insert the comment into the database. Is this secure? Can it be done without having high privileges on the server ?


blank page with no code or errors on blog

I'm encountering some trouble moving a Wordpress installation from a development to a production server. The development server works just fine, but when moving to production the blog page suddenly stops working. Homepage: http://www.elireview.com Blog: http://www.elireview.com/blog/ The homepage and the sub-pages of the site work fine, but when in Settings > Reading I set posts to display on the homepage, it them stops working and /blog/ works like expected. The page produces absolutely no HTML or error messages, and nothing is recorded to the server logs, so I am working blind here. I've tried just about every recommendation for "blank page" on the web, but I can't find any solution that works. Any assistance is greatly appreciated.


Edit format of Paginate_Links()

I'm using paginate_links to paginate the results of a loop. I want to style the pagination using dots instead of numbers, but I'm not sure how to go about doing this. I could try to play around with the css but I would prefer a clean method.               example.          <-                 o o o                ->          currently.          <-                 1 2 3                ->      This is currently how I am outputting my links.               <?php          $big = 999999999;          $paginate_links = paginate_links( array(         'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),         'format' => '?paged=%#%',         'current' => max( 1, get_query_var('paged') ),         'total' => $the_query->max_num_pages,         'prev_text'    => __('

'),         'next_text'    => __('

'),         'type' => 'array',         'n_display' => 'test'     ) );          foreach ( $paginate_links as $pgl ) {         echo "$pgl";     }          ?>      Looking at the core paginate_links() function in Wordpress is there anyway I can modify the output of $n_display before or after.


Undefined index: at_nonce in custom post metabox

I'm getting this error with my custom post metabox. The custom post and metabox works fine, but if i have debug on and when i try to save any other page or post, i will get an error: > Notice: Undefined index: at_nonce in /Users/jay/site/wp- > content/themes/mytheme/dogs-post-type.php on line 53 > > Notice: Undefined index: at_nonce in /Users/jay/site/wp- > content/themes/mytheme/dogs-post-type.php on line 53 > > Warning: Cannot modify header information - headers already sent by (output > started at /Users/jay/site/wp-content/themes/mytheme/dogs-post-type.php:53) > in /Users/jay/site/wp-includes/pluggable.php on line 876 My code:                <?php                // Add new custom post for dogs           function example_dogs_custom_init() {               $args = array(                  'label' => 'Dogs',                 'public' => true,                 'capability_type' => 'post',                 'hierarchical' => true,                 'has_archive' => true,                 'menu_position' => 5,                 'supports' => array('title', 'editor'),                 'rewrite' => array('slug' => 'pets/dogs', 'with_front' => false)               );               register_post_type( 'dogs', $args );           }           add_action( 'init', 'example_dogs_custom_init' );                     // METABOX breed           add_action("add_meta_boxes", 'test_add_post_meta_boxes_breed');                function test_add_post_meta_boxes_breed() {             add_meta_box(             'breed-meta',      // Unique ID             'Breed',   // Title             'breed_cb',   // Callback function             'dogs',         // Admin page (or post type)             'side',         // Context             'default'         // Priority             );           }                function breed_cb() {             global $post;             $breed_input = get_post_meta($post->ID, 'breed_field', true);                  // unique identifier, name of hidden field             wp_nonce_field(__FILE__, 'at_nonce');             ?>             Breed:             <input type="text" name="breed_field" id="breed_field" value="<?php echo $breed_input; ?>" />
<?php           }                add_action('save_post', function() {             global $post;             if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;             // security check - nonce                  // verify this came from the our screen and with proper authorizarion,             // because save_post can be triggered at other times             if ( $_POST && !wp_verify_nonce($_POST['at_nonce'], __FILE__) ) {                 return;             }                  if ( isset($_POST['breed_field']) ) {                   update_post_meta($post->ID, 'breed_field', $_POST['breed_field']);             }                });              ?>      There is something wrong with the nonce field but i cant figure out what. If it helps, the code structure is from Jeffrey Ways The Magic of WordPress Custom Post Types course.


How to build a multi-taxonomy, multi-term query based on user input

Thanks to Otto's excellent post on advanced taxonomy queries, I (mostly) understand how to create multi-taxonomy and multi-term queries. However, what I don't know is how to build those dynamically based on user input. I'd really like to end up with something like Amazon.com has on their site, with check boxes next to the various terms for a taxonomy in the sidebar (and multiple lists of terms, each with a taxonomy heading). Something like this: ![Taxonomy with list of terms and check boxes to select those terms](http://i.stack.imgur.com/PkYVW.png) How should I go about building something like this? Displaying the content dynamically (content changes when a box is checked) would be great, but I'd certainly settle for having a "submit" button.


Disable Individual Plugins (specifically in Custom Post Types) on a per-post basis?

The title pretty much says what I'm trying to accomplish, but more specifically I have a plugin that I made and it creates a custom post type, lets call them `newpages`. On these pages I have used `template_redirect` to take over the design of the pages, but some plugins appear, but I don't want to remove all of the plugins from loading, just a couple. So I was wondering if it's possible to use something like custom fields to disable certain plugins on a per-post basis. Can anybody point me in the right direction? Thanks!


How to get any tag ID

I want to exclude a certain tag from my home page not a category only post that hold the tag for example "olive"; I found a function for that which is like this                   function exclude_tag($query) {     if ( $query->is_home) {         $query-> set('tag__not_in',array(x));         }     return $query;     }     add_filter('pre_get_posts','exclude_tag');      Whereas X is the ID of the tag I want to exclude. How can I find that ID?


Change background color with a dominant from picture

Im looking for a smart way to change the background color for a page, but taking the #xxxxxx value from the dominant color of the headline picture. In twenty eleven theme, I can set a random image for each page loaded, I would change the background color to match the picture. I know that's possible but I don't know how to modify the CSS or the template to take the value from a specific function (I found this that seems promising: http://stackoverflow.com/questions/2541481/get-average-color-of-image-via- javascript Is that too complicated? thanks alot


working with term_relationships table

I have this little code to insert posts via custom form:                $post = array(          'post_author' => 1,          'post_title' => 'my title,          'post_content' => 'my content',          'post_category' => array(3),          'post_type' => 'post',       );          if ( $post_id = wp_insert_post( $post ) ){         echo 'post added!';      }      but now I need to insert the last $post_id to `term_relationships` table, basic scheme of term_relationships:               object_id | term_taxnomy_id | term_order     -----------------------------------------      Wordpress have a function to update that table?, or I need to build a custom query?


Changing Login Logo

After modifying the code in my functions.php file to display a different logo on my login page, I'm getting a blank square instead. I've added a custom .png image (326x67) to my (child) theme's image folder, and the code I've added to `functions.php` is as follows:               function custom_loginlogo() {         echo '<style type="text/css">         h1 a {background-image: url('.get_bloginfo('template_directory').'/images/login_logo.png) !important; }         </style>';     }     add_action('login_head', 'custom_loginlogo');      Could it be a permissions problem (like an `.htaccess` file blocking the image)?


How can I echo out the user id in user meta?

I need to generate a unique ID number for each new member. I was going to use WP_query, but am not getting anything but an array.


WP E-Commerce Custom Meta > Serialized array

I have an issue where I am adding custom meta to my products. Everything works fine until I update my product. This is before: ![enter image description here](http://i.stack.imgur.com/LIoY9.png) This is after update: ![enter image description here](http://i.stack.imgur.com/37S75.png) I am thinking it has something to with how it is pulling the data from the database. Anyone else have this problem before? Thanks in advance for your help.


WordPress plugin for scheduling appointments

I have searched and found a few plugins which help me offer appointment scheduler for the site owner. Is there something in existence which can offer the same functionality to all the users of the site instead of just the site owner? Like a visitor can schedule an appointment with any user of the site? Do you know of such a plugin? If such a plugin doesn't exist, any options which can fill my cup up? Or I will have to write something of my own probably using code of some existing one but which one (any suggestions?)


How can I show different menu for different pages?

I have a website that has a main menu(Top-Horizontal) like this:               Main menu      - Home      - About Us      - contact us      On Home page I have a link to "Company" page like this www.xyz.com/company. When I am on this company page I want my website to chnage my menu items and use this:               Different menu      - Home (same Home page link that will take user to www.xyz.com)      - promoters      - Gallery      - Maps      I think i can do this using wordpress Conditional_Tags, but really dont know how should I start.


How to upload images manually to wordpress?

I would like to know if it is possible to manually upload images to WordPress (ftp/scp) and make it recognize them and add them to the media browser. This also has to work with Wordpress running in multi-site mode (network).


Fix warning: Missing argument

i want to submit a theme to the wordpress.org. when i put the `define('WP_DEBUG', true);` in my `wp-config.php`. my theme showed some errors.but i don't know how to correct theme. Q1:`Warning: Missing argument 2 for cutstr() in ....htdocs\wordpress\wp- content\themes\warm-home\functions.php on line 156`. the following is my function.               function cutstr($string, $length) {              $string =strip_tags($string);             preg_match_all("/[x01-x7f]|[xc2-xdf][x80-xbf]|xe0[xa0-xbf][x80-xbf]|     [xe1-xef][x80-xbf][x80-xbf]|xf0[x90-xbf][x80-xbf][x80-xbf]|[xf1-xf7][x80-xbf][x80-xbf][x80-xbf]/", $string, $info);                for($i=0; $i<count($info[0]); $i++) {                     $wordscut= '';                     $wordscut .= $info[0][$i];                     $j='';                     $j = ord($info[0][$i]) > 127 ? $j + 2 : $j + 1;                      if ($j > $length - 3) {                              return $wordscut." ...";                      }              }              return join('', $info[0]);     }     add_action('after_setup_theme','cutstr');      invoked the function line is: `<p><?php echo cutstr($post->post_content,150) ?></p>`.there is no Missing argument 2 . why shows the above error? how correct it?


wordpress sql posts query won't display the latest post in a specific category

Hi I tried to display 5 posts titles from a specific category also show the date, but it won't display the most recent one that just published, I had to change the recent post date 2 months so it'd show up .. I used in_category to filter the post does in_category work with sql query ?? Thanks !
          <?php     $max_loop=0;      $month = array('','January', 'Febuary', 'March', 'April', 'May', 'June', 'July',          'August', 'September', 'October', 'November', 'December');          $work_items = $wpdb->get_results("SELECT YEAR( post_date ) AS year, MONTH( post_date )         as month, post_title as title, ID as post_id, COUNT( id ) as post_count FROM $wpdb-      >posts WHERE post_status = 'publish' and post_type = 'post' GROUP BY year ORDER BY      post_date DESC");          foreach($work_items as $work_item) {          if(in_category("photography",$work_item->post_id)){     echo "
";     echo "title).")'>";     echo $work_item->title;     echo "".$work_item->year." / ".$month[$work_item-         >month]."";     echo "";     echo "
";     $max_loop++;     if($max_loop==4){break;}     }      }     ?>


How to enlarge thumbnail on mouseover?

I am currently using NextGen Gallery and I want to view full images when I hover over the thumbnail, it is much better than waiting the user to click. Currently I obtain this functionality in Chrome by using the extension Hover Zoom but I want to enable this functionality to all my visitiors. I suppose that this should be a generic solution, not something special for NextGen.


Pulling Featured Images in to a WordPress Menu

I've got a simple static list marked up like this that I'd like to turn in to a WordPress Menu:

      I'd like each list item to link to a specific post, and pull in the Featured Image rather than the title. If I setup a default WordPress Menu it would output like this:

Blog Post 1

Blog Post 2

Blog Post 3

Blog Post 4

      How would I instead output it like this:

      So essentially I'd just like to return the Featured Image of each post I specify in a WordPress Custom Menu rather than the post title.


Plugin: Events manager - Next and previous event

I'm trying to get a navigation in the events of event manager the next/previous post links work but they are ordered by creation date instead of event date. How could it be possible to change this?


Problem with permissions in wp-content/plugins

I have a WP installation on my local machine and trying to get my hands dirty with plugins. I wish to clone a project from github which has this plugin code. However, i dont have the permissions inside plugins to do this as a normal user without su priveleges. (of course i can become root and do this but i dont think thats the way it should be). Then by default the folders in a WP installation have group set to "tape", which appears strange to me. What exactly should be the right permissions for the internal folders on a local WP installation?


Read more link for blog listing page

I have a blog page setup to list posts. The "Read More" link is added by                <?php       global $more;       $more = 0;             the_content('Read More'); ?>      How do i add the_permalink in where the "#" is without breaking the php?


When Front page and Posts page are specified is it possible to just have front-page.php as the home page?

Right now I have a Front page and a Posts page specified in dashboard. The Front page is a page called "home" using a page-home.php template. However I don't want to have to create a WP page for the home page, I just want WP to use my front-page.php or home.php template. And at the same time I still want it to have a specific page for posts. How to do that, is it even possible?


Custom taxonomy admin page

If you want a custom admin page for a taxonomy, you can set `'show_ui' => false` when you register it to suppress the default admin page and then create a new admin page to replace it. However `edit-tags.php?taxonomy=taxonomy-slug` still takes you to the 'hidden' default admin page. Is there way of directing it instead to the custom admin page. Or otherwise is there another method than circumvents this issue?


Find the post an attachment is attached to

I have a list of attachment IDs which are built using this array:               $all_images = get_posts( array(     'post_type' => 'attachment',     'numberposts' => -1,     ) );      Is it possible to take the image ID from this list and find the Title and permalink of the POST the image is attached to? I know it's feasible because the Media Library shows it, but I can't find the right way to do this with the codex. I have tried this code, however it returns the title and permalink to the attachment itself, not the post it's attached to:               $parent = get_post_field( 'post_parent', $imgID);     $link = get_permalink($parent);


Remove post from new menu in top bar

I have removed the post menu from the admin side bar like so:               add_action('admin_menu','remove_default_post_type');          function remove_default_post_type() {         remove_menu_page('edit.php');     }       How can I now remove it from the top bar 'new' menu as well?


Import JSON feed to Wordpress

We have received a URL which is a JSON file apparently:               http://www.domain.com/tools/export-json/?destination=hawaii      I am completely clueless when it comes to JSON and Wordpress. Anybody know where to start? We will need to create individual posts from this JSON file I presume..


Custom page with variables in url. Nice url with add_rewrite_rule

Using WP3.1 I Have a custom page with a WP_Query and the query gets dynamic variables from the url. And i want safe variables and clean urls. Example: > carpage/?carmodel=honda&location=finland TO > carpage/honda/finland/ I made add_rewrite_rule in to functions.php and it works, but iam not sure it's safe to use this. Functions.php                 function fcars() {            add_rewrite_rule('carpage/[/]?([a-zA-Z-]*)[/]?([a-zA-Z-]*)$', 'index.php?pagename=carpage&var1=$matches[1]&var2=$matches[2]');            add_rewrite_tag('%var1%', '[a-zA-Z]+');       add_rewrite_tag('%var2%', '[a-zA-Z]+');     }          add_action('init', 'fcars');      And in Custom template i get the vars Could someone please help me with this. How can i make this safe to use and is this the right way in WP3.1 What is the right way to make add_rewrite_rule in this case: > carpage/honda/finland/ (just hyphens and small letters in url) carpage is the static template page.


What's the sql for this condition?

I want to delete all records from `wp_usermeta` with user_id whose meta_value is "tonetone" which is spam accounts. As you know already, there are many records with one user_id in wp_usermeta. I tried like this but doesn't work. Thanks to anyone who can show me the way.               delete from wp_usermeta where user_id = (select user_id from wp_usermeta where meta_value = "tonetone")


Somebody guide me to implement tag subscription plugin.

I would like to implement tag subscription and follow/nofollow for registered users. I mean when the user goto tag page, left side widget should show subscribe/unsubscribe button. And when the user goto author page, left side widget should show follow/nofollow button. Front page posts should have two other tabs called "subscribed" and "following". When the user click `subscribed tab` it should show the posts which contains user subscribed tags. Likewise `following tab` should only show user following author posts. Is there any readymade plugin available??? If not can i use existing plugins like subscriber2 to implement this feature. What are the steps? I should store the tag and author id in the database right? PS: I don't want you to code my plugin. This is my first wordpress plugin which requires database related work. So i just wanna understand how the database works. I just want to know whether i should create a new table or can i use existing meta tables to implement this feature.   If i can use existing table which table i should use to store tag id and author id.


get listed category's id?

ok - so i'm listing categories and their sub-categories. How can i get the ID of the category that's being shown with a function? ( i know what it is in the admin ) ie /category/events/women-in-art/ women-in-art-ID = ? any help appreciated! Dan.


Incorrect Blog Root

I have a blog at http://leghumped.com which I moved from a subdirectory to the site root a few months back. The problem is, the root still seems to resolve to /blog/. Eg: Instead of seeing http://leghumped.com/ when I use bloginfo('template_url'), I instead see http://leghumped.com/blog/ I've checked in the control panel in Settings->General, the WP-Config.php file and wp-settings.php. I have nowhere else to look. Is there anywhere else this could conceivably be defined?


Wordpress pagination with wp_query_columns

I'm using the code from here to split my loop up in to columns. The columns work. I have 7 posts in the databese and showposts set to 6. I cannot get nextpage link to show? I have a $paged variable in my $args array I have set number of posts per page to 5 in admin/reading. Full loop below. Many thanks in advance.               <?php      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array(     'showposts' => 6,     '&paged=' => $paged,     'tax_query' => array(         array( 'taxonomy' => 'post_format',             'field' => 'slug',             'terms' => array('post-format-audio')                  )         )     );     $the_query = new WP_Query($args);?>     <?php foreach(new WP_Query_Columns($the_query, 3) as $column_count) : ?>
             <?php while ($column_count--) : $the_query->the_post(); ?>

<a href="<?php echo get_post_meta($post->ID, '_format_audio_embed' , true); ?>">

                  <?php echo get_the_date(); ?>                  <a class="spch-bub-inside" href="<?php comments_link(); ?>">                                            <?php comments_number('0', '1', '%'); ?>                                                                 <?php the_tags(' '); ?>                                                       <a href="http://twitter.com/share" class="twitter-share-button"                   data-url="<?php the_permalink(); ?>"                   data-via="jillowen"                   data-text="<?php the_title(); ?>"                   data-count="horizontal">Tweet

                       <?php endwhile; ?>
                    <?php endforeach; ?>

<?php previous_posts_link('« Previous Entries') ?>

<?php next_posts_link('« Older Entries') ?>


How can I add an options page for my class based plugin?

I'm trying to use the new Settings API with a class based plugin to add a settings page. This is the code I have so far:               class simple_sample_plugin{         function simple_sample_plugin()         {             add_action('init', array(&$this, 'init'));         }         function init()         {             add_action('admin_menu', array(&$this, 'admin_menu'));             add_action('admin_init', array(&$this, 'admin_init'));         }         function admin_init()         {             register_setting(                 'sample'  // A settings group name. Must exist prior to the register_setting call.                 ,'sample_options' //  The name of an option to sanitize and save.                 ,array($this, 'set_options') //  A callback function that sanitizes the option's value.             );             // Register our settings field group             add_settings_section(                 'sample_section1', // String for use in the 'id' attribute of tags.                 'Section 1', //  Title of the section.                 '__return_false', // Function that fills the section with the desired content. The function should echo its output.                 'sample' //  The type of settings page on which to show the section (general, reading, writing, media etc.)             );             // Register our individual settings fields             add_settings_field(                 'color_scheme'  // String for use in the 'id' attribute of tags.                 ,'Color Scheme' // Title of the field.                 ,array($this, 'color_scheme') // Function that fills the field with the desired inputs as part of the larger form. Passed a single argument, the $args array. Name and id of the input should match the $id given to this function. The function should echo its output.                 ,'sample' //  The type of settings page on which to show the field (general, reading, writing, ...).                 ,'sample_section1' // The section of the settings page in which to show the box (default or a section you added with add_settings_section, look at the page in the source to see what the existing ones are.)                 ,array() // $args - Additional arguments that are passed to the $callback function. The 'label_for' key can be used to give the field a label different from $title.             );         }         function set_options()         {              }       function color_scheme()         {           echo "<textarea type='text' rows='2' cols='80' name='sample_options[color_scheme]'>";           echo time();           echo "</textarea>";       }         function admin_menu()         {             add_options_page(                 __('sample') //page title                 ,__('sample') //menu title                 ,'edit_posts' //capability                 ,'sample' //menu-slug                 ,array(&$this, 'settings_page') //function callback             );              }         function settings_page()         { ?>

sample Options
         <form class="myform" method="post" action="options.php">          <?php                  settings_fields('sample');             do_settings_sections('sample_section1');                   ?>                  <input type="submit" value="Save" />         </form>
         <?php         }     }     global $simple_sample_plugin;     $simple_sample_plugin = new simple_sample_plugin();      I've tried to keep that as clean and simple as possible, and I've tried to do it according to a lot of tutorials and documentation. I also have a jQuery line in there to show hidden fields. The only problem though is that this does not work. That is to say it adds a sample options page, but the field values are not there. Screenshot: ![screenshot-with- shadow.png](http://img600.imageshack.us/img600/4526/screenshotwithshadow.png) Help! What am I doing wrong? I've been trying this for 24 hours now.


How to redirect a link to a new link?

I am about to change the slug for my page's permalink. Since I dont want to loose the traffic, i would like to redirect the visitors to the new more SEo friendly link. Can I achieve this with the mod_rewrite? (I use Apache on Ubuntu) Or any other easier alternative? (I prefer not using any plugin if possible) Many Thanks,


Set Default Category to Username

I installed a plugin called "Symbiosis" which creates categories automatically copying a user's username upon them signing up. Whenever any user creates a post on the site, I am trying to figure out how to assign that category that was already created with the new post. I want to set WP Default Category to the authors username so that when anyone creates a post it automatically posts under their name. (my users do not have access to default wp-panels) I know about the dropdown in the settings > writing panel but that's not what I'm looking for as I cannot customize the slug to a users username. Is this possible via plugin or programatically somewhere else? The categories are all already created. I can pull the loggedin users username and echo it but I'm not sure where to put it:               <?php global $current_user; if ( isset($current_user) ) {echo $current_user->user_login;}?>


scheduled event not getting executed

class checkPost{       function __construct()       {         if ( !wp_next_scheduled('my_task_hook') ) {           wp_schedule_event( time(), 'hourly', 'my_task_hook' ); // hourly, daily and twicedaily         }         add_action('my_task_hook', array(&$this,'my_task_function'));       }       function my_task_function()        {         add_action('wp_head', array(&$this,'wp_head'));       }       function wp_head()       {         echo '<!--This is a test!-->';       }     }      That's the stripped code of my plugin, but it's somehow not working. Why is it not?


Custom post type with file upload - need to "set as field" instead of "send to editor"

I've created a custom post type. It requires a file to be uploaded. I found the following tutorial which I've successfully adapted to do what I need with one exception: http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in- your-plugin-or-theme/ The tutorial provides JavaScript code to override the "send to editor" button, however that's not what I want to do. I want to set the filename as a meta value of the post so I can pull it out in my display template. Ideally I want to display another custom link in the file upload thickbox, similar to "set as post thumbnail", which will do this. My custom JavaScript file contains this (the first function has been customised to my post type, the second hasn't):               jQuery(document).ready(function() {          jQuery('#upload_resource_button').click(function() {      formfield = jQuery('#upload_resource').attr('name');      tb_show('', 'media-upload.php?type=file&TB_iframe=true');      return false;     });          window.send_to_editor = function(html) {      imgurl = jQuery('img',html).attr('src');      jQuery('#upload_image').val(imgurl);      tb_remove();     }          });      If I need an additional hidden field to assign the filename back to, I can probably work that out - really what I need to know is what hook to use to add a new link to the thickbox to use instead of "Send To Editor". I hope that makes sense - I'm not sure of all the correct terminology. Thanks!


How to call a plugin function in footer.php

I want to call this http://wordpress.org/plugins/easy-media-gallery/   easy media gallery plugin in footer.php or recommend me any image gallery plugin like its in the footer of this website http://ssmrudrapur.org/


Facebook share post dialog not showing post information

I recently created a new blog in Wordpress.com and wanted to share my post with my Facebook friends. When I tried to post using the Facebook share from my post, the "Share on Facebook" page opens with the message `http://myblog.wordpress.com is marked private by its owner. If you were invited to view this site, please log in below. Read more about privacy settings.` I checked the blog's settings in **Dashboard -> Settings -> Reading**. `Site visibility` option is set as `Allow search engines to index this site`. Am I missing some configuration? Here is a screenshot of the Facebook dialog I am getting. ![enter image description here](http://i.stack.imgur.com/qwBgV.png)


Personalized images in widget MU site

I am using the module image-widget and is it possible to create personalized images for Multi user sites ? I want to make header, footer and right sidebar in image-widget. That is admin uploaded pre-designed images for these three sections and users only need to select from uploaded images. The upload option is to be removed. Please share your thoughts here, its very helpful for me. I am using WP 3.6 Is the way I can implement the idea ?


Open Source Forum for wordpress similar to stackexchange or stackoverflow

I have to add forum feature in my wordpress blog.I see bbpress but would like to add forum similar to stackexchange or stackoverflow. Please let me know.


How to code schedule / cron job

I am using `wp_schedule_event` to hourly insert items from an rss news feed into my client's blog. Here is how I am setting it up in my functions.php:               add_action('init', function(){          $timescheduled = wp_next_scheduled('update_feed');          wp_unschedule_event($timescheduled, 'update_feed');              if (!wp_next_scheduled('update_feed'))         wp_schedule_event(time(), 'hourly', 'update_feed');     });          add_action('update_feed', 'update_fashion_news');          /* rest of the code for updaring feed goes here */      So first I unschedule it and then schedule the event. Now this seems to work some days and other times it doesn't. Is the unscheduling part necessary? Am I doing this right? What I want to know is:   1. Am I using my function calls in the right order?   2. Are the schedule and unschedule calls cancelling each other out? Here is the full code in a gist if you want to see it: https://gist.github.com/3984658


How to add new tab to admin list of posts and handle result list

## ![Admin links](http://i.stack.imgur.com/65m51.jpg) The goal is to show posts with special values of custom field (post meta) in separate tab. I know how to add new tab, here is a code:               add_action( 'views_edit-post', 'remove_edit_post_views' );     function remove_edit_post_views( $views ) {             $views['pre'] = 'Name of Sort';             return $views;     }      but I have no idea how and where I can filter posts. Any ideas?


Why is the $old_instance needed for the widget update function?

In the PHPdoc of the function `WP_Widget::update()` located under `wp- includes/widgets.php` it says the following:               /**      * ...      * This function should check that $new_instance is set correctly.      * The newly calculated value of $instance should be returned.      * If "false" is returned, the instance won't be saved/updated.      * ...      */      It is unclear to me why the `$old_instance` is needed when updating the values and how can it be used to validate that the `$new_instance` is set correctly.


posts and cms and posts again

I'm setting up a WP site as a CMS that will sell CDs. I have set up the individual titles as posts on a page I call recordings, and have a number of categories that make up the collection of discs. I'm not sure if this is the best way to setup the site as a CMS, though. Additionally, I want to set up another page for a blog under the "about us" section of the site. Is this possible, since I've already allocated the recordings page as the posts page? Or can I just make a blog entry on the Posts page w/the category of Blog and call only those posts? Is there a better way to make a 'recordings' database besides using the posts approach?


Limit image upload to one and disable audio, video and other document file types to upload

Somebody knows some trick in Add new Post to:   1. Disable the upload of audio, video and other filetypes.   2. Only accept the upload of an image (jpg, png, gif).   3. Limit the upload of each Post to only One image (no more than one). Thanks in advance.


Custom taxonomy list page?

I've been searching Google for this to no avail. I'm working on a restaurant site, and I have a custom post type for dishes, like so:               $args = array(         'labels'=> $labels,         'public'=> true,         'publicly_queryable'=>true,         'show_ui'=>true,         'show_in_nav_menus'=>true,         'query_var'=>'dish',         'rewrite'=>true,         'capability_type'=>'post',         'hierarchicial'=>false,         'menu_position'=>5,         'supports'=>array(             'title',             'editor',             'thumbnail',             'excerpt',             'custom-fields',             'revisions'         )        );            register_post_type('dish', $args);      An example of one of the custom taxonomies I want to use is this:               register_taxonomy('Main Ingredient', array('dish'), array(         'hierarchical' => true,         'label' => 'Main Ingredient',         'singular_label' => 'Main Ingredient',         'query_var'=>true,         'rewrite' => true)     );      The custom taxonomies are working fine in the admin, and I can go to myurl.com/main-ingredient/pork and see a list of all dishes with pork in them. What I'm wanting to do is be able to hit myurl.com/main-ingredient and get a list of all the various main-ingredient values. I found this reference, which is exactly what I'm trying to do: Custom taxonomy listing page when no term set (all terms) But the solution is not working for me - I'm still getting a 404 when going to myurl.com/main-ingredient Any suggestions on how best to do this?


Proper implementation/use of code/syntax highlighting

I've already read what I can on a couple of sites and installed this plug-in: http://en.support.wordpress.com/code/posting-source-code/ http://alexgorbatchev.com/SyntaxHighlighter/ I'm missing how to make it work. Question 1: Do I have to type in the Visual window or the HTML window? Question 2: Does TinyMCE mess with this? I've seen my code disappear in the HTML window. I currently have typed in my code in Visual Window like this:               [sourcecode language="php"]     <?     Header( "HTTP/1.1 301 Moved Permanently" );     Header( "Location: http://CMSTrainingVideos.com" );     if ($_GET["page_id"] == 1)        Header( "Location: http://CMSTrainingVideos.com/?p=35");     if ($_GET["page_id"] == 2)        Header( "Location: http://CMSTrainingVideos.com/?p=43");     ?>     [/sourcecode]      I also tried `<pre language="php">` with the "Geshi" syntax highligher, and no luck there either. But nothing is happening, i.e. no syntax highlighting: http://cmstrainingvideos.com/?p=53


Error passing post_content to function

The purpose of this function is to simply wrap the first occurrence of the keyword in bold tags. I'm getting an error on the line marked below. Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: error parsing attribute name in Entity, line: 4 in C:\xampplite\htdocs\testsite\wp- content\plugins\mylugin\test.php on line 40 Is this the correct way to pass the post_content object?               add_filter('wp_insert_post_data', 'my_bold_keyword' );     function my_bold_keyword($content){       $myKeyword = "test 123";       $d = new DOMDocument();       $d->loadHTML($content['post_content']); //ERROR OCCURS HERE       $x = new DOMXpath($d);       $Matches = $x->query("//text()[contains(.,$myKeyword) and not(ancestor::h1) and not(ancestor::h2) and not(ancestor::h3) and not(ancestor::h4) and not(ancestor::h5) and not(ancestor::h6)]");       if($Matches && $Matches->length > 0){         $myText = $Matches->item(0);         // need to wrap #myText in <b> wrapper       }       return $content;     }


Get posts after today (upcoming events)

I'm using PHP Exec to build a widget to show a list of upcoming events:               <?php     function filter_whene($whene = '') {         $whene .= " AND post_date >= '" . date('Y-m-d') . "' ";     return $whene;       }     add_filter('posts_whene', 'filter_whene');     query_posts('cat=10&showposts=3&');     if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_date(); ?> <a href="<?php the_permalink(); ?>">       <?php the_title(); ?>
     <?php endwhile;     else: ?>
Não há eventos agendados.
     <?php endif; ?>     <?php remove_filter('posts_whene', 'filter_whene'); ?>     <?php wp_reset_query(); ?>      It seems to work on the front end but I get: Fatal error: Cannot redeclare filter_whene() (previously declared in /home/content/a/c/a/acamorg/html/cea2/wp-content/plugins/exec- php/includes/runtime.php(42) : eval()'d code:3) in /home/content/a/c/a/acamorg/html/cea2/wp-content/plugins/exec- php/includes/runtime.php(42) : eval()'d code on line 6 on the widget backend. Any suggestions? Thank you.


Wordpress blog post cloned and stolen?

I'm not sure if this is the right place to ask this but last night i made a post on my wordpress powered blog here: http://blog.twostepmedia.co.uk/css3-still-novelty-or-usable-in-everyday-web- development/ then this morning i see this: http://buzzgamesnews.blogspot.com/2011/01/css3-still-novelty-or-usable-in.html Is this right? Can someone completely clone a post of mine or am i overreacting?


$wpdb->insert is changing a value

I'm writing a plugin called 'Featured Releases' for a client. The user fills out a short form in the admin area which inserts some text and an image id into the wordpress database via $wpdb->insert. On my development machine it works fine, but on the production server (which has over 500 posts of all sorts, mostly images), the value of the image id is being changed to 127 no matter what I do. 127 is the id of a post, but its not an image and certainly not the id that was passed from the form. The image is uploaded via the native wordpress media uploader. The image's post id (from the wp_posts table) is passed to a hidden input in the form. On submit, this function handles the $_POST data:               function fr_add_album() {         global $wpdb;              if ( isset($_POST) && (count($_POST) > 0) ) {                  check_admin_referer('featured-releases-add_album');                  $table_name = $wpdb->prefix . 'featured_releases';                  $desired_keys = array('fr_band', 'fr_album', 'fr_album_description', 'fr_image_id', 'fr_shop_url');                  $data = array();             foreach( $desired_keys as $key ) {                      // Define and sanatize data                 if ( isset($_POST["$key"]) ) {                     $accepted_html = array('a' => array('href' => array(),                                             'title' => array()));                      $data["$key"] = wp_kses($_POST["$key"], $accepted_html);                          unset($_POST["$key"]);                 } else {                     $data["$key"] = '';                 }             }                  // Sanitize the shop url             if ( isset($data['fr_shop_url']) ) {                 $data['fr_shop_url'] = esc_url($data['fr_shop_url']);             }                  $data['fr_modified'] = date('Y-m-d h:i:sa');                  error_log($data['fr_image_id']); // This returns the correct value!                  $wpdb->insert($table_name, $data, array('%s','%s', '%s', '%d', '%s'));                  // After the insert, the fr_image_id column always reads "127"              }     }      The insane thing is that there _are a few images which do post correctly_. These were the first images I uploaded when I created the wordpress install. Every other image from any other date, including any new image I upload is saved as 127 in the database. All the images have the same owners and same permissions. I also can't see any difference in wp_posts between the new images and the old. Any ideas? I'm dyin' here. Thanks for your help!


Can Wordpress realistically handle a site with 500 'pages'?

I'm building it from scratch and probably a 100 or so of those pages will be ecommerce. I would like to create meaningful, normal looking permalinks for aesthetics and SEO. I would really love to use Wordpress for this but I'm concerned about performance issues with this volume of pages.


Query between two meta values?

How do I limit the query by two custom meta fields, a start date and an end date? This is what my data looks like:               meta_key   | meta_value |     ------------------------|     start_date | 20100131   | //Jan 15, 2010     end_date   | 20100206   | //Feb 6, 2010     ------------------------'          $today = date(YYYYMMDD);      The post will show if `start_date = $today` and it will expires when `end_date = $today`. > > update Here is the structure on my single.php First Query I use here your answer               <?php     query_posts( $query_string );     if (have_posts()) : while (have_posts()) : the_post();         ?><a href="<?php the_permalink() ?>"><?php the_title() ?>
<?php     endwhile; endif;     wp_reset_query();     ?>      and Second Query with regular wordpress function but this second query doesnt work properly               <?php     query_posts('showposts=5&meta_key=start_date&meta_compare=>&meta_value='.date("Ymd"));     if (have_posts()) : while (have_posts()) : the_post();         ?><a href="<?php the_permalink() ?>"><?php the_title() ?>
<?php     endwhile; endif;     wp_reset_query();     ?>


ex-style bulk post editing

I imported my twitter stream into WP: http://wordpress.barrycarter.info/index.php/category/twitter/ but all the entries now have "barrycarter:" at the beginning. I realize I could just re-import w/ different settings, but I want a more general solution. Is there a plugin/etc that lets me do "s/barrycarter://isg" on selected (or all) posts? In other words, mass-edit, but not by hand. I realize I could use the API for something like this, but would prefer an existing plugin/etc if there is one.


How to protect wp-admin from third party access?

How can the wordpress administration panel and the login page wp-login.php be hidden such that only the website administrator can access it? Can the URL be rewritten through some mod_rewrite rule without worrying about breaking anything (leaving aside all the plugins)? Preferably the solution should not be IP address based which will mean the administrator can access the website from only one or a set of computers.


Warn me about 'uncategorized' posts

I always want new posts to have a category, but sometimes I forget. How can I make Wordpress warn me when I'm about something 'uncategorized'?


wp_insert_post does not insert string with apostrophes correctly

I'm using wp_insert_post (for several reasons) in a script I'm writing and it's causing any string that has an apostrophe in it to be truncated up to that character (including the character). Here's the code I've got to test it:               $question = "If you’re in need, this is who you call";          echo $question."<br />";          $post = array(         'post_title'     => $question,         'post_status'    => 'publish',         'post_type'      => 'question'     );            echo $post['post_title'];          $the_post_id = wp_insert_post($post);      It's weird because when I echo out both the strings, the echo the correct thing on both ends so I've isolated it down to the wp_insert_post function that's causing the issue. When I view it in WordPress, the title is just 'If you' and then ends. I found a similar problem here:               http://premium.wpmudev.org/forums/topic/q-wp_insert_post-truncates-post-content-on-quotes-is-there-a-proper-way-to-escape-these-things      But there doesn't seem to be any solution to it on that page. Any ideas on what's going on here and how to solve it? No idea why it's causing it. I'm looking into it to see if has something to do with something else in my code but it seems like it shouldn't because the array element seems formatting just fine when it's echoed out before the wp_insert_post() function. Thanks for your help! ## EDIT I should have specified that these are having to be called from an array where I'm grabbing data from a different source so I won't necessarily have access to the strings directly. I tried mysql_real_escape_string() which should do that job automatically as well and that didn't seem to work...


How to change category translation in Polylang afterwards

If I translate Tag or Category with Polylang-plugin (http://wordpress.org/plugins/polylang/ ) in Wordpress, how can I change the translation afterwards or remove the translation without removing current tags? There seems to be no way to do it on admin side. With posts and pages you can manually change the id of translation on posts pr pages edit view.


Customizing Responsive Themes Menu

I use the popular theme: https://wordpress.org/themes/responsive I would like to change the color of one of the menu items and if possible also have a jquery popup from one of the menu items. How can I accomplish this? Thanks


Server Side Includes not working in text widget

I'm trying to add Server Side Include code to a WordPress text widget, but the content is not being displayed. I've added SSI before on my non-WP site, but for some reason its not working with my WP text widget. Do I need to do something different where this is within WP? Note my WP installation is in a subfolder of my domain. I've tried adding the following to my text widget:               <!--#include virtual="http://www.mydomain.com/mycontenturl.html"-->      and also tried               <?php include ('http://www.mydomain.com/mycontenturl.html'); ?>


Proper way to pass credentials in a custom login form to avoid "headers already sent"

I'm working on a custom login page plugin. I'm trying to figure out how to log the user in without creating "headers already sent" errors. I was calling `wp_signon` directly after the user clicked "login," but quickly found that this approach yields "headers already sent" errors. I've switched to using hooks:               private function attemptLogin() {         add_action( 'after_setup_theme', array( $this->Cms, 'authenticateUser' ), 10, 2 );         do_action( 'after_setup_theme', $_POST['username'], $_POST['password'] );     }      But, as you've probably guessed, this yields the same errors since I'm still, in essence, executing the login immediately. How can I leave the hook to run on its own schedule to avoid errors, while still making the user's credentials available to it? I've searched both Google and this site for the answer to no avail. The closest to an answer I've found is this, but I'm still unsure how to implement the advice while still passing the user's credentials.


File upload from front-end form (as attachment) not working

I have a front-end form that is supposed to allow the user to upload a CV which is then sent along with the rest of the form as an attachment. To do so I have used `wp_handle_upload()` like so:               if ($_FILES) {          if ( ! function_exists( 'wp_handle_upload' ) ) require_once( ABSPATH . 'wp-admin/includes/file.php' );     $uploadedfile = $_FILES['file'];     $upload_overrides = array( 'test_form' => false );     $movefile = wp_handle_upload( $uploadedfile, $upload_overrides );         if ( $movefile ) {             echo "File is valid, and was successfully uploaded.\n";             var_dump( $movefile);         } else {             echo "Possible file upload attack!\n";         }      }      The form is then sent with wp_mail after checking for errors: (`$receiver_email, $subject, $body, $headers` are all fine and can be seen here               $attachments = $uploadedfile;          if (wp_mail($receiver_email, $subject, $body, $headers, $attachments)) {              $jobs_email_sent = true;          } else {         $jobs_email_sent_error = true;     }      However I am getting the following from `var_dump($movefile)` when I submit the form.               File is valid, and was successfully uploaded.     array(1) {      ["error"]=>      string(212) "File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini."     }      And natually no attachment with the email. I checked php.ini and file_uploads is indeed on and upload_max_filesize is 128M. I have tried to add a pdf and a jpg file which are both quite small. I would greatly appreciate any insight as to what I'm doing wrong here. UPDATE just read that for `wp_mail()` the file path has to be fully specified as in `$attachments = array(WP_CONTENT_DIR . '/uploads/file_to_attach.zip');` which should be returned in `wp_handle_upload();` as file. When I var_dump($_FILES) I get:               array(1) {       ["upload_file"]=>       array(5) {         ["name"]=>         string(5) "3.jpg"         ["type"]=>         string(10) "image/jpeg"         ["tmp_name"]=>         string(14) "/tmp/php3aeSzD"         ["error"]=>         int(0)         ["size"]=>         int(53262)       }      }      My file is named 3.jpg.


Send value to RSS feed to create custom feed

So, i've got a bunch of code calculating a few things resulting into a simple echo               echo $confirmation;      There is just one thing I want to do; I want to send the $confirmation to an RSS feed. Any ideas?


Advanced meta query help

I want to get posts according to the following logic: "If post status = publish or pending then get all records which have a meta value of less than todays date. If the post is in trash, get it regardless of meta query" So I have the following args but these bring in only the trash posts that have meta value of less than todays date and I want to get all trash posts.               $args = array(         'posts_per_page' => -1,         'post_type' => 'jobs',         'post_status' => 'pending, publish, trash',         'author' => $current_user->ID,         'meta_key' => 'JOBS_ad_end',         'meta_query' => array(             array(                 'key' => 'JOBS_ad_end',                 'value' => date("Y-m-d"),                 'compare' => '<=',                 'type' => 'NUMERIC,'             )          )     );     $posts = get_posts($args);      I'm guessing this probably isn't even possible and will need a custom query, but thought I'd check if anyone knows a way to do it.


Remove Rewrite Rule

after adding a rule:               add_action( 'init', 'wpse26388_rewrites_init' );     function wpse26388_rewrites_init(){     add_rewrite_rule(         'usuario/([0-9]+)/?$',         'index.php?pagename=usuario&property_id=$matches[1]',         'top' );     }          add_filter( 'query_vars', 'wpse26388_query_vars' );     function wpse26388_query_vars( $query_vars ){     $query_vars[] = 'property_id';     return $query_vars;      }      My xampp went to space. I can't access my localhost/phpmyadmin, it gives me 403 error and everything I put on url, as localhost/test it's redirects to my wordpress. How can I disable this? Thanks


How to modify the query in taxonomy-custom.php to sort term archives by a custom meta field?

I am trying to create theme pages for custom taxonomy terms in which the archives are ordered by a custom meta field. I can do this with a new wp_query as follows:                       <?php $directory_archive_query = new WP_Query(                  array(                      'post_type' => 'directory',                     'posts_per_page' => 200,                     'meta_key' => 'surname',                     'orderby' => 'meta_value',                     'order' => 'ASC' ) ); ?>                          <?php while($directory_archive_query->have_posts()) : $directory_archive_query->the_post(); ?>      However, I need this to work on the taxonomy-custom.php page so that each individual taxonomy term's archive page is listed according to the custom meat field (called 'surname'). If I use the wp_query, then of course that doesn't work, because it no longer shows results for each specific term. I have also tried to do this using pre_get_posts, but can't make that work either. What I am expecting to happen is that all posts listed on the term archive page will be listed in ascending order by the surname meta key. That is not happening. Instead, they are just listing in the same order as if there were no pre_get_posts there. The code I have used is as follows:               <?php               function customize_customtaxonomy_archive_display ( $query ) {             if (($query->is_main_query()) && (is_tax('services')))                  $query->set( 'post_type', 'directory' );                              $query->set( 'posts_per_page', '200' );             $query->set( 'meta_key', 'surname' );                        $query->set( 'orderby', 'meta_value' );             $query->set( 'order', 'ASC' );         }               add_action( 'pre_get_posts', 'customize_customtaxonomy_archive_display' );          ?>      Really hoping that someone can help. Thanks for your time. Andrew.


Hosting WordPress on AWS EC2 using CloudFront Dynamic Content Origins for page content

Is it possible to **completely** host WordPress on AWS with EC2, S3 and CloudFront Dynamic Content Origins, in the way that WordPress is currently built / architected? **Further Details:** I would like to install my WordPress on an EC2 instance. Store all my assets: images, videos and download etc on S3 And use CloudFront Dynamic Content Origins serve the pages and posts from the WordPress website. Therefore making is very quick for page load and only needing a very small EC2 instance, because all content is cached in CloudFront. Read more   * Amazon CloudFront Now Supports Dynamic Content   * CloudFront Concepts **N.B. CloudFront does not support POST HTTP method** **Notes**   * Please do not suggest plugins that only stores assets on S3    * Please do not suggest that I rewriting WordPress to make this work


is_page not working when loading javascript with add_action in functions.php

This code is working in my functions.php and it's loaded properly:               add_action('wp_enqueue_scripts', 'js_custom', 50);     function js_custom() {         wp_register_script( 'js_custom', get_template_directory_uri() . '/js/custom.js', false, null);         wp_enqueue_script( 'js_custom' );     }      However, this is not working and not loaded:               if ( is_page(273) ) {         add_action('wp_enqueue_scripts', 'js_custom', 50);         function js_custom() {             wp_register_script( 'js_custom', get_template_directory_uri() . '/js/custom.js', false, null);             wp_enqueue_script( 'js_custom' );         }     }      Why it's not loaded? I am on the page with the id equal to 273.