How to delete post attachments when jQuery is used with a click event on the delete link

I think I'm on the right track with what I need to do, at least for doing one of the ways it could be done. I'm not really sure though, I could be way off for all I know. This is part of the code I needed help with last night for resizing the uploaded image files, but now I am trying to figure out how to use the wp_delete_attachment($id) function to delete images attached to the posts. So, I have this jQuery script that adds/ removes extra fields, for uploading more images to attach. For every added image there is a link to remove them. Clicking remove has only ever just remove the div which the link clicked was contained by, and when saving the post the attached file would show up as still attached. In my click event handler for the remove link, I need to first run function that will call the wp_delete_attachment(), to permanently delete the file/attachment, THEN I can use jQuery to remove the div of that attachment from the page. That way when saving the post it will have been deleted and not show up again still. Here's my functions I've been trying to work with:               // a function that returns the delete attachment php function,      // and a message saying Deleted that fades in and out.         jQuery(function() {             function delete_att( attID ) {                 var div = jQuery('#img_uploads'),                     msg = $('div').html('Attachment Deleted!').fadeIn().delay(200).fadeOut().appendTo('div');                 return '<?php wp_delete_attachment( ' + attID + ', true ); ?>', msg;             }      And the click handler which calls this function and then removes the containing div element from the page is:                   jQuery('.remImage').live('click', function() {              if( size > 1 ) {                 var postID = jQuery('#attID').val()                 delete_att( postID );                      //jQuery(this).parents('.attchmt').find('#attID');                 jQuery(this).parents('.attchmt').detach();                 size--;             }              return false;          });     });      The code to add extra fields is between these two parts but these are the key pieces for what I need help with. Currently, the way I have it coded here I am getting this error message. idk wtf this means exactly though lol.               Error: uncaught exception: [Exception... "Node cannot be inserted at the specified point in the hierarchy"  code: "3" nsresult: "0x80530003 (NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)"  location: "http://code.jquery.com/jquery-1.4.4.min.js Line: 113"]      So here is the full code which I am using, exactly. https://gist.github.com/802465 Just trying to pass info to/from jQuery and Php and that's always a pain in the ass, (for me).


Echo current custom post type

I have a all my custom post types list together in blog format. What I'm trying to do is echo the post type name on each post. I tried this:               get_post_type_object('post');     echo $obj->labels->singular_name;      But it just displayed "Post" for everything instead of the custom post type name


Add "external" link to admin menu in the backend

Trying to add a link to my admin menu (dashboard/backend) that leads to the frontend of wordpress, so I basically want a link in the menu that takes me to the blog. I've found a couple of ways to add new stuff to the admin menu, but I haven't been able to link to the home_url, it seems like the admin menu only is designed to let you link to stuff within the wp-admin. Anyone that have succeeded with this? Edit:   Tried with this: https://gist.github.com/792b7aa5b695d1092520               add_admin_menu_item('Overview',array(            'title' => 'View Site',           'slug' => get_bloginfo('url')       ));      Which gives me the link hxxp://myurl.com/myurl.com   With this plugin (hxxp://wordpress.org/extend/plugins/admin-menu-editor/), I get:   hxxp://myurl.com/wp-admin/www.test.com


Problem with context in multisite - getting main site data in every blog (get_pages())

I'm working on a multisite, everything is configured and works fine from dashboard. Now I'm trying to write a plugin with a PHP file that displays the list of pages created in a site - to be displayed to the admin of the site who logs in. Here is the code (simplified)               <?php     require('../../../wp-load.php');     ?>     (some HTML)     <?php             $pages = get_pages();                                                foreach ( $pages as $page ) {             echo $page->post_title . '<br>'     ?>      My plugin PHP file uses `login_redirect` filter to redirect user after login to that PHP file where I am trying to display the list of pages the user created:               function my_login_redirect( $redirect_to, $request ) {          return '/wp-content/plugins/my-admin-plugin/my-admin-view-all-pages.php';      }      THE PROBLEM - no matter which site I'm in, I get the list of pages created in the "main" site. How do I pass the context of the existing site to the functions?


How to keep a record of changes to a custom field?

I have a custom post type that hold real estate listings and I need to figure out a way to keep a record of the price of the property is listed for. For example a user lists a property for sale and then the user edits the property listing and changes the price. I need to show the price before and the new price and the date the price was changed. The price value is stored in a custom field. Doe anyone have any idea of how I can begin to tackle this issue. I basically need to keep a record of a posts custom field and the date it was changed. If i can get an idea of how to code this I can post the code here for anyone who might find this useful. Thanks


Send POST request to Wordpress to make a new post

I want to make new posts on my Wordpress blog using HTTP POST sent to `post.php`. I was searching for the parameters I should pass but i didn't find any useful information yet. Can anyone give me a reference to the parameters I should send?


Need to hide an element depending on date and post category

I've been racking my brains for a few days trying to figure this out. I'm using WP Voting on my site. I need to create a script in single.php that will remove the div that contains the voting widget depending on the date and the post category. For instance: If the month is September and the category IS NOT 13, remove div Else If the month is October and the category IS NOT 14, remove div. I tried this first with JavaScript which worked with the date, but not category, and then php, but I can't seem to get it right. Can anyone help? Please? Thanks Ettan


Limit one submission from each user using Contact Form 7?

I am using Contact Form 7 along with the add-on Contact Form 7 Dynamic Text Extension to pre-populate usernames and emails. I know this may be sort of a strange request but I want to be able to limit the number of submissions to one for each user only for one of my forms. Basically, it's a submission form for a contest and I don't want users to be able to submit over and over again. Is something like this possible with this plugin?


Define multisite is not working

I put the define( 'WP_ALLOW_MULTISITE',true ); in the wp-config but the network tab never shows up. I read some comments on the internet, and tried only MULTISITE, true, even WP_ENABLE_MULTISITE, but nothing works The network tab never shows up. running wordpress 3.9.2 Please help


List all Wordpress key words

I have a page               http://bhaa.ie/realex-ipn.php      that returns normally when called with GET but is throwing a 404 when it is called via a POST request               curl -i -X POST http://bhaa.ie/realex-ipn.php      I'm trying to understand what is causing the issue. I've disabled the various plugins i have installed and the issue is still there. I know that using key works as http parameter names can causes issues and that the list of wordpress reserved keywords is here. I think it might be the case that one of my plugins has registered its own keyword and this is causing this 404 issue. Is there a way to list all the keywords that wordpress and the installed plugins have registered?


Problems with custom post_type and custom taxonomy

I'm trying to make a simple plugin that let's me create blogposts from a custom post_type (tutorials), with it's own custom taxonomies. I got this working. There are 2 problems though. 1: I also created a widget which works almost the same as the category widget provided by WordPress. It displays the categories from my custom taxonomy (tutorials). It also shows the post count per category. Just like the default category widget for regular posts. But, when I click on one of the categories, I get a 'Not Found' page, instead of an overview of my tutorials within that category. The url of this page is 'example.com/tutorials/category'. I already tried to make a custom template called 'taxonomy-tutorials.php', which is a copy of the 'archive.php', but this didn't work. 2: The tutorials (custom post_type) should have the url 'example.com/tutorials/category/blogpost'. But I have no idea how to set this correctly. Right now the url is 'example.com/tutorials/blogpost'. The permalink structure is set to '/%category%/%postname%'. Regular blogposts for example are 'example.com/category/blogpost'. And my custom blogposts should be 'example.com/tutorials/category/blogpost'. Here is the PHP code that registers the custom post_type, the custom taxonomy, and the widget.               /* Function to register the custom post type */     function create_tutorials_posttype() {         register_post_type( 'tutorials', array(                 'labels' => array(                     'name' => __( 'Tutorials' ),                     'singular_name' => __( 'Tutorials' )                 ),                 'public' => true,                 'has_archive' => true,                 'rewrite' => array( 'slug' => 'tutorials' )             )         );     }          /* Function to register the custom taxonomy */     function create_tutorials_taxonomy() {         register_taxonomy( 'tutorials', 'tutorials', array(             'hierarchical' => true,             'public' => true,             'show_ui' => true,             'show_admin_column' => true,             'rewrite' => array( 'slug' => 'tutorials' )         ) );     }          /* Widget (within a widget class ofcourse) */     public function widget( $args, $instance ) {         // outputs the content of the widget         $title = apply_filters( 'widget_title', $instance['title'] );              echo $args['before_widget'];         if ( ! empty( $title ) ) {             echo $args['before_title'] . $title . $args['after_title'];         }              $terms = get_terms( 'tutorials', 'orderby=name&hide_empty=1' );         echo '
';         foreach ($terms as $term) {             $link = get_term_link( $term, 'tutorials' );             echo '
'.$term->name.' ('.$term->count.')
';         }         echo '
';         echo $args['after_widget'];     }      I hope someone can help me with this. It's getting a little frustrating


get_terms() doesn't return empty terms even though hide_empty is false

I can't manage to make `get_terms()` to return the empty terms and I've tried it in a number of ways. Here's the code:               $terms = get_terms('device',array('hide_empty' => 0));     foreach($terms as $term) {             if($term->parent == 0) {                 if($i++ != 0) echo '</optgroup>'; echo '<optgroup label="'.$term->name.'">';                 $id = $term->term_id;                 $args = array("child_of"=>$id);                 $this_term = get_terms('device',$args);                 foreach($this_term as $the_term) {                      $term_name = str_replace($term->name,'',$the_term->name);                     echo '<option value="'.$the_term->term_id.'">'.$the_term->name.'</option>';                 }             }         }      I've tried all the possible ways:               $terms = get_terms('device',array('hide_empty' => false))     $terms = get_terms('device',array('hide_empty' => 0))     $terms = get_terms('device',array('hide_empty=false'))     $terms = get_terms('device',array('hide_empty=0'))      Also tried the last two ways without `array`. Nothing seems to be working. It returns all the terms that have posts, but no empty one.


How to check for empty and not a failure

I'm querying the postmeta table to see if a url has already been entered, using this statement (where $thisLink is the url I'm checking)                 $mypostids = $wpdb->get_results("select * from $wpdb->postmeta where meta_key = 'rssmi_source_link' and meta_value like '%".$thisLink."%'");      The problem is that on some servers it appears it's not finding urls that already exist in the database, and I'm becoming convinced that this may be due to the server failing on the query or something like that. Anyway, I'm not sure how to check for both the url already exist (thus don't process anymore) or there was some sort of failure in completing the query). right now, I just use:               if (empty( $mypostids )){ do stuff}      is there a way I could make the condition like if empty AND if not a failure then do stuff?


Removing Unnecessary Text from Admin Menu without CSS

I am looking for a way to remove all the unessesary text from default worpdress metaboxes. Preferably I would like to ensure that the content is not just hidden through CSS but actually removed from the HTML so it does not even show up in the source. The areas I am interested in removing include:   1. The HELP button on the top right and associating DIV/HTML/text when you click on it   2. On the Dashboard in the Right Now Metabox I want to remove the text related to which theme is being used and the version of wordpress as well as the change theme button.   3. On the "Page Attributes" metabox on the bottom it has the text "Need help? Use the Help tab in the upper right of your screen." I would like for this text to be removed   4. Under the "Excerpt Metabox" there is text which I would like to remove   5. Any other text which you might also know how to remove to cleanup wordpress.


Save an array from drop-down in custom meta box

I have successfully pulled a custom post type through into a drop-down that is in a custom meta box. However, when displaying it on the front end I would like to also provide a link to the actual post, not just the name of the post. So I am guessing I need to save this as an array? Is this possible through a drop-down? Confused on how I should approach this. Any help is greatly appreciated. Here is what I have so far:               // Add Meta Box To Select Overseeing Pastor     add_action('admin_init', 'ministry_select_add_meta');     function ministry_select_add_meta(){         add_meta_box('ministry_select_post', __('Overseeing Pastor'), 'ministry_select_meta', 'ministry', 'side');     }          function ministry_select_meta( $post ) {         $values = get_post_custom( $post->ID );         $selected = isset( $values['pastor_select'] ) ? esc_attr( $values['pastor_select'][0] ) : '';         wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );         ?>             <select name="pastor_select">                 <?php                 $args = array(                     'post_type' => 'employee',                     'position' => 'pastor'                 );                 $pastorList = new WP_Query($args); while ($pastorList->have_posts()) : $pastorList->the_post();                     $is_selected = (get_the_title() == $selected) ? 'selected="selected"' : '';                     echo '<option value="'.get_the_title().'" '.$is_selected.'>'.get_the_title().'</option>';                 endwhile; wp_reset_postdata();                 ?>             </select>         <?php        }          add_action( 'save_post', 'ministry_select_save' );     function ministry_select_save( $post_id )     {         // Stop If Autosaving         if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;              // Stop If Nonce Can't Be Verified         if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;              // Stop If Unauthorized User         if( !current_user_can( 'edit_post' ) ) return;              // Make Sure Data Is Set Then Save               if( isset( $_POST['pastor_select'] ) )             update_post_meta( $post_id, 'pastor_select', esc_attr( $_POST['pastor_select'] ) );     }


List Wordpress.org Blog on Wordpress.com

I have a self-hosted blog at `www.MyPersonalSite.com/blog` that runs on the Wordpress.org platform. My buddy has a blog at `www.HisName.wordpress.com`. He seems to get a lot more traffic to his blog. My inclination is that when he makes a post, it submits it to some central Wordpress blogroll. Is this right? **Question:** Is there a way for me to list my blog such that it gets more exposure and people can search for it through Wordpress.com and subscribe to my posts?


Editing registration page labels through .mo and .po files

I'm attempting to change the wording of Buddypress's registration page (see below) so that the "Username" heading is displayed as something else. ![registration page](http://i.stack.imgur.com/rpn1v.png) I found this documented here on Buddypress's website, in which I am directed to   1. Create a copy of the .po language file in `/plugins/buddypress/bp-languages`   2. edit the wording in that copy   3. Use the edited version to create a .mo   4. Move both the .mo and edited .po to the `wp-content/languages/` directory (which I had to create). I followed the above steps but no change was made to the page. Can anyone see a step that I might be leaving out? Or might this process be obsolete? Thanks for any thoughts!


Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy

I've (I think) an interesting problem here. What I want to do is create a global archive page, with everything on it. Dates, authors, categories etc all on one page. I have a child theme, with TwentyTwelve as the parent. Inside TwentyTwelve there exists archive.php, category.php, tag.php, author.php etc., basically all faceted archive templates split up individually. In my child theme what I want to do is to create an archive.php template, and have that overwrite all of the parents templates. I understand creating archive.php in the child will overwrite the parents archive.php, but before it checks for archive.php it will check for category.php, and use that template from TwentyTwelve before hitting archive.php in my child theme. Same for all other templates as per the template hierarchy. I know of at least 2 ways to fix this:   1. Delete category.php, tag.php etc from TwentyTwelve. (Not the best, as any update will restore those files)   2. Re-create tag.php, category.php, etc in my child theme and copy/paste my layout for each one into each template file. (Better, but lots of template files just makes for a messy directory.) I'm wondering if there is something I could drop in functions.php to overwrite the hierarchy, and force WP to use my child archive.php for all archive pages. Ideas? Regards, Dave


How to make blog posts have their own urls?

When I post a blog post, the blog post doesn't appear with a separate url -- it just appears under http://richardclunan.com/blog and there's no button to edit the url when I'm on the Edit Post page. How do i make blog posts have their own urls?


W3 total cach and theme changes

i have read that i have to weight with w3 total cache until my blog design is complete. But to be honest, it will never be finished. I'm constantly developing new stuff. How will this affect my site if i chose to use w3 total cache? Can i reset the cache every time i make changes to the theme? and how does this plug in deal with comments? Hope some one have a simple answer for me :)


How Do I Order Posts by Modified Date?

I've read the codex article about `WP_Query`'s `orderby` parameters and I understood that it is possible to order by Modified date. But I couldn't find where should I edit. How WordPress post order by modified date including home page as well as categories page and tag pages?


How to translate get_intermediate_image_sizes?

I use the following code to get image sizes:               public function getImageSizes(){             global $_wp_additional_image_sizes;             $sizes = array();             foreach(get_intermediate_image_sizes() as $s){                 $sizes[$s] = array(0, 0);                 if( in_array( $s, array( 'thumbnail', 'medium', 'large' ) ) ){                     $sizes[$s][0] = get_option( $s . '_size_w' );                     $sizes[$s][1] = get_option( $s . '_size_h' );                 } else {                     if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $s ] ) )                         $sizes[$s] = array( $_wp_additional_image_sizes[$s]['width'], $_wp_additional_image_sizes[$s]['height'] );                 }             }             return $sizes;         }      The result is a select with image sizes, something like this:               <option value="thumbnail">Thumbnail</option>     <option value="medium">Medium</option>     <option value="large">Large</option>     <option value="tribe_image_widget_custom" selected='selected'>Custom</option>      The question is how to translate sizes (Thumbnail, Medium, Large and Custom)? By default the sizes are in English, I need them to be another language (I use CodeStyling Localization plugin for it). Thank you! P.S.: to biuld a select I use this code:               <select class="widefat" id="<?php echo $this->get_field_id('size'); ?>" name="<?php echo $this->get_field_name('size'); ?>">         <?php foreach ($this->getImageSizes() as $name => $atts): ?>             <option value="<?php echo $name ?>"<?php echo ($name==$size?' selected':'') ?>><?php echo ucwords($name) . ' ('. implode( 'x', $atts ). ')' ?></option>         <?php endforeach ?>     </select>


What's the correct way to include files in Wordpress TwentyTen theme with it's own jquery scripts and css?

I want to include a slider in the default Wordpress theme on the home page. I did manage to get the page to show using `<?php if ( is_home() ) { include ('slider.php'); } ?>` but it doesn't look like it's loading the jquery script it needs or the style sheet. I know there's a conflict with scripts and Wordpress, I just don't know how to get it to work. Sample page is at http://axiomwest.com/ How do you feed in a page with it's own style sheet and scripts?


How to dynamically build a multiple taxonomy query loop within a post type's single loop?

This question is a little different then the others floating around here. The most similar one is "How to get the parent's taxonomy ?". I have a music cms setup that utilizes two post types: _album_ and _album media_ and a few taxonomies: _genre_ , _year_ , and _artist_. In the footer of every _single-album.php_ post I want to display the corresponding _album media_ template and do this dynamically. There is only one _album media_ post for every one _album_. Both post types are associated with the three taxonomies. How can I write a loop inside another loop that automatically/dynamically obtains the associated taxonomies of it's parent post type? For example: An _album_ called "Dark Side of the Moon" is associated with taxonomies rock, 1973, and Pink Floyd. The _album media_ "Dark Side of the Moon" is associated with the same taxonomies. Within the main loop in _single-album.php_ is another loop that looks for what three taxonomies the _album_ is associated with and constructs a loop for "album-media". The contents of this loop could also be displayed as _single- albummedia.php_. Can this be done? I have the feeling that I am over-thinking this :) Things this question involves:   * multiple taxonomy query   * loop within a loop   * custom taxonomies and post types


wordpress query - orderby child post date

I have support ticket system which i have built using wordpress. The basic functionality is that when a "ticket" is created, it creates a post. When an admin replies, it then add a child post to the original post. My question is how can i order my posts by the child post_date is ASC order? My query args at the moment are:               $args = array(       'post_type' => 'support_tickets',       'numberposts' => -1,       'post_parent' => 0,       'orderby' => 'date',       'order' => 'DESC'  );      This only obviously orders the parent post's in ASC by date. Is what i require achievable?


custom fields for attachments?

is it possible to add extra fields via the functions.php script for attachments in wordpress? Tried loads of examples but none seem to work. Worried an existing plugin might be affecting my attempts but its not clear if its even possible. best, dan.


Get Next / Prev 3 Posts in Relation to Current Post

I have 7 posts, like this: 1   2   3   4 - this is the current post   5   6   7   As noted, number four is the current post being displayed. I need to create a query that will allow me to display the previous 3 posts (by publication date) and also the three posts after. This can be done with two separate queries. I've been able to display the immediately previous or next post, just not the ones further down / up. Any ideas?


Create html from function

I have a simple html structure like this.
              <a href="<?php echo get_permalink($post->ID); ?>">
                 <?php                          $attachments = get_children(array(                         'post_type' => 'attachment',                         'post_mime_type' => 'image',                         'post_parent' => $post->ID                     ));                          if(count($attachments) > 0) {                         echo '';                     }                      ?>

<?php echo the_title(); ?>

by
                  <?php echo the_excerpt(); ?>
      I'm using this on a number of pages so I want to add it to functions.php and call the function on the page. How do I add this as a function to generate this structure. I tried this.               function ideas(id){       echo '
';       echo '';          echo '
';            $attachments = get_children(array(         'post_type' => 'attachment',         'post_mime_type' => 'image',         'post_parent' => $post->ID       ));            if(count($attachments) > 0) {         echo '';       }            echo '
';       echo '
'.the_title(); .'
';            echo '
by
';            echo the_excerpt();            echo '';       echo '
';          }      and in the page               if(function_exists('idea')){       idea();     }


Changing interface language without multisite

I want to change the Theme's interface language without making multisite by passing langauage parameter into the URL.               <a href="<?php echo home_url('/')?lang=bn ?>">Bengali      My thought is to use the following code:               get_query_var('bn') {              /**          * CHANGE THE 'WPLANG' IN wp-config.php TO bn_BD ON THEME SWITCHING          * Thanks: toscho          * Source: http://wordpress.stackexchange.com/a/121136/22728          * -------------------------------------------------- */              add_filter( 'locale', 'toscho_change_language' );              function toscho_change_language( $locale ) {             return 'bn_BD';         }          }      With checking `isset()` of the parameter in URL, loading of this code block. And using the theme's language file `bn_BD`. But I'm actually curious about the logical proceedings:   * Is this concept Ok?   * Will it load the theme's language file successfully?


posting twice from an array?

I dynamically create iterations of a form field with jquery, but they all carry the name extrakosten[] for the first variable and the other variable vergoeding[]. The php:               $postTitle = ''; // save post title          if(isset(   $_POST['submit']    )){             // if submit button is present              for ($i=0; $i < count($_POST['vergoeding']); $i++) {                  $new_post = array(                 'post_title'    =>  $postTitle,                 'post_content'  =>  ' ',                        // can not be empty                 'post_status'   =>  'publish',                           'post_type'     =>  'landschapselement'         // custom post type             );             $pid = wp_insert_post($new_post);                   // insert the post                  wp_set_post_terms( $pid, $_POST['extrakosten'],'kostenpost',false);             wp_set_post_terms( $pid, $_POST['vergoeding'],'vergoedingaanleg',false);          } // close for loop          }      What happens now, is that when I click the submit button, a new post under custom post type 'landschapspakket' is made. The values under vergoeding and kostenpost are being posted in the custom taxonomy 'vergoedingaanleg' and 'kostenpost'. What it does now, is create ONE post with TWO values for 'kostenpost' and 'vergoeding'. What I try to achieve is to create TWO posts, each with ONE value for both 'kostenpost' and 'vergoeding'. I think something might be wrong with the array. I'm new to arrays. Any suggestions? Thanks for the help


wp_mail is sending two emails when used after retrieving session data

I'm using the wp_mail function to send emails in WordPress. Before I run the function, I retrieve a heap of data from a session and some others from a form that was just submitted. For example:               $first_name = $_SESSION['first_name'];     $last_name = $_SESSION['last_name'];     $phone_number = $_POST['phone_number'];     $message = $first_name . $last_name . $phone_number;     wp_mail($myemail,"Email sent",$message);      I'm using the plugin called WP-MAIL SMTP to send via Gmail's SMTP servers. When I disable this, no emails are sent at all. For some reason, I receive two emails. One has the POST AND SESSION information and the other only has the SESSION information. Any help would be greatly appreciated! Thanks in advance, Jamie I'm using WordPress 3.3


Comment Pagination

I am hoping someone can help me with comments pagination. I have the pagination working and the links point to the next page etc, but when clicking the page just refreshes. Here is my code so far and hoping someone can help me.               $pid = $post->ID;        $comment_query = "SELECT * FROM `wp_comments` WHERE comment_post_ID = ".$pid. " AND comment_approved = '1'";     $comments_array = $wpdb->get_results($comment_query, OBJECT);          if ($comments_array):                                                      $cpp = 10; // Comments per page                                                      $wp_query->comments = count($comments_array);                                                      //echo $wp_query->found_posts;                                                      $wp_query->max_num_pages = ceil($wp_query->comments / $cpp);                                                      $on_page = intval(get_query_var('paged'));                                                      if($on_page == 0){ $on_page = 1; }                                                       $offset = ($on_page-1) * $cpp;                                                      $wp_query->request = "                                                     SELECT * FROM `wp_comments` WHERE comment_post_ID = ".$pid. " AND comment_approved = '1'                                                                                LIMIT $cpp                                                     OFFSET $offset                                                         ";                                                     $newcomments = $wpdb->get_results($wp_query->request, OBJECT);     ?>
         <?php if ($newcomments) : ?>
<?php _(comments_number('No Comments','1 Comment','% Comments')); ?>

                 <?php                           foreach ($newcomments as $comment) :      full code: http://pastebin.com/md3zdpbd Thanks


Overriding the currently selected menu item

I have a WP 3.x site that I'm using mainly as a CMS. The menu links to the various WordPress pages. One of the pages, "News", is the "posts" page. However, when clicking on one of the posts on the News page, the "News" item in the menu loses highlighting because the post isn't treated as a child of "news". Is there an easy way to override the currently highlighted item in the menu? Ideally by forcing a page ID upon it.


Incorporating a meta query into a mysql query in wordpress

I'm trying to find a way of inserting a meta condition into this bit of SQL below...               $query = "SELECT COUNT( ID ) as num_events " .                  "FROM $wpdb->posts " .                  "WHERE post_type = '" . AI1EC_POST_TYPE . "' AND " .                  "post_status = 'publish'";      I know this first bit works but I wanted to add to it the condition that the **meta_key** called **private** isn't **true** which is stored as `a:1:{i:0;s:4:"true";}` thanks to Advanced Custom Fields I haven't written any MySQL myself so my first attempt came out like this:                           $query = "SELECT COUNT( ID ) as num_events " .                  "FROM $wpdb->posts " .                  "WHERE post_type = '" . AI1EC_POST_TYPE . "' AND " .                  "post_status = 'publish' " .                  "AND WHERE meta.meta_key ='private' " .                  "AND meta.meta_value != 'a:1:{i:0;s:4:"true";}'";      But then I get a `PHP Parse error: syntax error, unexpected 'true' (T_STRING)` because of the "true" in the longtext value of the meta. Then changing to `"AND meta.meta_value != 'a:1:{i:0;s:4:\"true\";}'";` on the last line means that no results are omitted - is it because it's searching for `\"true\"` now instead?? Have also tried with `"AND meta.meta_value IS NULL "` \- as would achieve roughly the same. No Joy I am not hugely familiar with SQL queries so I could be doing something completely wrong - if anyone can spot anything I would be hugely appreciative.


Comments not enabled for custom post types

I don't get this at all. I've looked online and I think I did everything I was supposed to, but my custom post type does not display a comments form. In functions.php. where I define the post type I have: `'supports' => array('title','editor','thumbnail', 'excerpt', 'comments'),` ( **note:** the 'comments' string wasn't there when the posts where made, I added it just now trying to fix this) In the `single-mytype.php` I added `<?php comments_template('comments.php'); ?>` to the loop. note: before I added the filename, I got nothing but now I get a "comments are closed" slug. If I edit the post, I see "enable comments" and "enable trackbacks" are unchecked, but if I check them they won't stay checked. If I check "enable comments" and add a comment to the admin form, that comment _will_ be displayed... but no form for other comments. What am I missing here?


2 wordpress site same database

I have twoo websites on worpdress platform:   * http://fian.ro/   * http://nuovafattoria.ro/ On the server there are 2 different folders with same files, same config but one of them has:               define('WP_HOME',    'http://nuovafattoria.ro/');     define('WP_SITEURL', 'http://nuovafattoria.ro/');      so is the same database but different url. I wanna made some changes on one of them, different logo, background so I need a second options table but the others to remain same for both websites. How can I have different logo, background and settings on the second website?


Custom Post Type order Title ASC

I´d like to display all car manufacturer in order by title (e.g. "Merecedes") and order from lowest to highest values (e.g. "A-Class") "ASC", too. It should looks like a glossary. ### Page: Cars A ... BMW:   1er   2er   3er   ... Mercedes:   A-Class   B-Class   C-Class   ... Z This is my `custom-port-type-cars.php`
Mercedes
         <?php $args = array( 'post_type' => 'cars', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC',               // ============================= Mercedes ==============================             'tax_query' => array(                 array(                     'taxonomy' => 'manufacturer',                     'field' => 'slug',                     'terms' => array('mercedes')                 )             )         );              // ============================= OUTPUT ==============================         $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();             the_title('
', '
');             the_content();         endwhile; ?>
BMW
          <?php $args = array( 'post_type' => 'cars', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC',               // ============================= BMW ==============================             'tax_query' => array(                 array(                     'taxonomy' => 'manufacturer',                     'field' => 'slug',                     'terms' => array('bmw')                 )             )         );                   // ============================= OUTPUT ==============================         $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();             the_title('
', '
');             the_content();         endwhile; ?>      This doesn´t work for me. I can´t order title an terms at the same time. Thanks for your help   Ogni


How to add new custom page or post blocks?

I would like to add custom contents to post, such as price, options and some others, I dont like to use the custom fields, because always i have to select from a drop down menu, I want these options to be in a separate area such as title, editor, thumbnail... I think its possible, I have seen this in WP Ecommerce plugin. Can anyone tell how t do it?


My Calendar Plugin - add output directly in template file

I am using the latest version of the My Calendar plugin by Joe Dolson with the latest version of WP. I want to output an events list in a particular place in my code, but I can't seem to find any way to do this. The only thing I've found regarding output is by using shortcodes in the post/page. I guess theoretically I could add a new sidebar widget and then add the templates that way. Then put the sidebar where I want in the code, but this poses two problems: 1\. It's a hassle 2\. I don't want my clients to be able to move or change this. I'd like to have it set and stay that way. I'm having some trouble finding the answers to this question. It seems like it would be possible, because most plugins I've used have an option to add output directly in the template code, but I can't seem to find the answer. Thanks in advance!


Problem with get_posts, tax_query and counting the number of posts

I want to count the number of posts that has simoultaneously 3 different taxonomies. THe code i'm using is this:               $products = get_posts(array(         'post_type' => 'products',         'posts_per_page' => -1,         'post_status' => 'publish',         'tax_query' => array(             'relation' => 'AND',             array(                 'taxonomy' => 'collection',                 'field' => 'slug',                 'terms' => array($current_collection),                 'operator' => 'IN'             ),             array(                 'taxonomy' => 'type',                 'field' => 'slug',                 'terms' => array($current_type),                 'operator' => 'IN'             ),             array(                 'taxonomy' => 'color',                 'field' => 'slug',                 'terms' => array($current_type),                 'operator' => 'IN'             )         )        ));     $countpost = count($products);      The problem occours when the **colors** and **type** taxonomy term I'm looking for do not exists...   * if the **collection** does not exists, the count is 0   * if the **type** does not exists, it returns posts with the specified collection and color   * it the **color** does not exists, it returns posts with the specified collection and type what I was expenting, since the relation is AND, was that if one of the terms does not exists, the count should be always 0, instead of basically ignoring that term and considering only tho other two... am I doing something wrong? how can I fix it? thanks a lot!


Let user subscribe to specific categories

How could I let each user subscribe to a specific categories of his choice? I want to do something like reddit subscribe to categories? Is there any tutorial helps doing this?


get_query_var vs global query variables?

I have query vars defined in functions.php using:               add_filter('init', 'add_query_vars');          function add_query_vars() {         global $wp;         $wp->add_query_var('profession');     }      Until now, to retrieve the query var in page templates, I have been using `$profession = get_query_var('profession');`. A similar example `$paged = get_query_var('paged');` is also shown for the `$paged` variable on Codex page for `get_query_var()`. However, today I learnt that the query variables are accessible as global variables. All I have to do is declare `global $profession;` and I can start using the value of the variable anywhere within the template. This to me appears to be a much better way of accessing the query vars without the overheads of nested functions of `get_query_var()`. Is there a good reason to use `get_query_var()` to fetch the query vars instead of accessing them as global variables? If not, then why does `get_query_var()` even exists?


I want to display the all the posts that are inside a certain subcategory in a specific order that I decide (this is because the category contains a list of tutorials and I want to decide how to list them). How can I do that? Is there any plugin that I can use? I just want to be able to set the order when displaying that category. Thanks.


GD Star Rating Rating In Latest Comment

I want To Show latest comment with rating.. Iam Using The code below.. But Its don't Shown Any Rating.               <?php $comments = get_comments('status=approve&number=3');     foreach($comments as $comment) : ?>         <?php $my_id = $comment->comment_post_ID ; $post_id_comms = get_post($my_id); $title = $post_id_comms->post_title; ?>          Who: <?php echo($comment->comment_author);?>
         Rating: <?php wp_gdsr_comment_integrate_standard_result(get_comment_ID(), '', 16); ?>         About: <a href="<?php get_permalink($comment->ID)?>#comment-<?php echo $comment->comment_post_ID?>" title="on <?php echo $title ?>"><?php echo $title ?>
         What they said: <?php echo($comment->comment_content);?>
         When they said it: <?php echo($comment->comment_date);?>
     <?php endforeach;?>


How to use Link Manager

I'm working on a plugin and want to use WordPress's 'link manager' (see following image). ![Link Manager](http://i.stack.imgur.com/00CfV.png) How can I use it? I used Google to find an answer but I couldn't. I also figured out that this option was disabled with Wordpress 3.5?! And this plugin should help me out. I installed it but I can't figure out how it works or what I have to do with it.


WordPress get posts by date without query_posts

I'm want to get posts from the last 30days in a sidebar but I don't want to use query_posts, is there a way to achieve this with the get posts function?


Shortcode doesn't work if I directly paste its function in a template file?

This is a shortcode to add a question form in the Question and Answer Forum plugin for Wordpress:               [question_form width=\'x\' bordercolor=\'x\' style=\'x\']question form title[/question_form]      This short code calls this:               //allow short codes  [question_form]     function question_form($atts,$content = "")     {         global $questionformid;         include "askquestionform.php";         return $html;     }     add_shortcode('question_form','question_form');      and this is askquestionform.php:               <?php     load_plugin_textdomain( 'qna-forum', false, 'question-and-answer-forum/languages' );     if(get_option('q_loginrequired_ask')=="TRUE" && !is_user_logged_in())     {         $html = "
".__("Please login to ask a question",'qna-forum')."
";         $html .= q_loginform(get_permalink());         return $html;     }                                                  //STYLING INFORMATION=============     $formstyle = "";     $introstyle = "";     if(isset($atts['width']))     {         $formstyle .= "width:" . $atts['width'] . ";";     }     if(isset($atts['style']))     {         $formstyle .= $atts['style'];     }     if(isset($atts['bordercolor']))     {         $formstyle .= "border: 2px solid " . $atts['bordercolor'] . ";";         $introstyle .= "background-color:" . $atts['bordercolor'] . ";";     }          if(!isset($_POST['title']) || $_POST['title'] == null)     {         $qtitle = __("Enter Question Title",'qna-forum');     }     else{         $qtitle = $_POST['title'];     }     if(!isset($_POST['question']) || $_POST['question'] == null)     {         $Qtext = __("Enter Your Question Here",'qna-forum');     }     else{         $Qtext = $_POST['question'];     }          $html = '<form class="questionform" name="questionform-'. $questionformid . '" id="questionform-' . $questionformid. '" style=\'' . $formstyle. '\'>
';     if($content != "")     {         $html = $html . $content;     }     else     {         $html = $html . __("Use the form below to ask a question",'qna-forum');     }     $html = $html . '
';     include_once (ABSPATH . 'wp-content/plugins/question-and-answer-forum/coreform.php');     $html = $html . '</form>';          $questionformid = $questionformid + 1;      I created a template file called, **question-form-page.php** , I pasted the whole code of **askquestionform.php** but nothing is displayed (blank). I also tried placing the following in **question-form-page.php** :               question_form($atts,$content = "")      and               global $questionformid;     include "askquestionform.php";     return $html;      But I get the same result. Any suggestions?


Allow shortcode in the author bio textarea

Is it possible to make shortcodes available in the Author bio textarea?


Filter Category Loop Dynamically

I'm trying to display a custom loop with a dynamic category filter. As a setup I have categories of all usernames which are created once a user creates an account. So I am trying to echo the user's username as a category filter. It works when I echo is elsewhere on the page, but it doesn't work when I try to embed it like so:               <?php query_posts('category_name=<?php global $current_user; if ( isset($current_user) ) {echo $current_user->user_login;}?> &posts_per_page=6'); ?>          <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>          <a href="<?php the_permalink() ?>"><?php the_title(); ?>       <?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?>          <?php endwhile; else: ?>          NO Posts Present           <?php endif; ?>      Any help would be greatly appreciated, thanks.


Log in / Log Out Custom Button

On our website we have a "Join" button in the top right corner and a log in / log out link using `<?php wp_loginout(); ?>` . Instead of having the log in / log out link we would like to have it display in a button. It should ready "Login" when something like `if ( is_user_logged_in() )` is false and "Log Out" when it's true. The Code for the Join Button is:               Join      so the code for the Log in / log out button should have the same `.join- button` class. Style for `.join-button`:               .join-button {     -moz-box-shadow:inset 0px 1px 0px 0px #f5840c;     -webkit-box-shadow:inset 0px 1px 0px 0px #f5840c;     box-shadow:inset 0px 1px 0px 0px #f5840c;     background-color:#f5840c;     -moz-border-radius:6px;     -webkit-border-radius:6px;     border-radius:6px;     border:1px solid #f5840c;     display:inline-block;     color:#ffffff;     font-family:Arial;     font-size:14px;     font-weight:bold;     padding: 1px 4px;     text-decoration:none;     text-shadow:1px 1px 0px #f5840c;     }      Could someone please help me write the code to achieve this task?


Get images attached to a specific page

Is there a way to fetch the URLs and captions of all images attached to page _x_?


Use Featured Image for backstretch.js

I'm using backstretch.js for full-width header images on my pages. I'm able to grab the Featured Image url like this:               <?php $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full', false, ''); echo $src[0]; ?>      Does anyone know of a way to pass this url to my main.js file?               $(".cover").backstretch("FEATURED_IMG_URL_WOULD_GO_HERE"); // backstretch.js      Thanks in advance. Any help is appreciated! UPDATE: Thinking it might be possible to store the PHP in a variable, though I'm not so sure. Something like this, perhaps?               var cover-image = <?php $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full', false, ''); echo $src[0]; ?>;          $(".cover").backstretch(cover-image); // backstretch.js


Rewrites with hierarchical taxonomies in permalink

I am attempting to create a hierarchical list of products in WordPress 3.5.1. For example if the custom post type product was in the custom taxonomy `Outdoor > Garden Tools > Hoses`, these would be the desired permalinks: `/outdoor/garden-tools/hoses/mega-hose/` (loads the single.php template) `/outdoor/garden-tools/hoses/` (loads the archive.php template) What is the best practice approach to achieving this? I have generated the permalinks with all multiple levels of parent categories successfully for the posts and terms using the `post_type_link` and `term_link` filters respectively. There appears to be a problem with the URL rewriting though as the permalinks return 404 responses, I can't seem to figure out how these requests are functioning (where "xx" can be any string): `/xx/mega-hose/` (returns mega hose page) `/xx/xx/mega-hose/` (redirects to /outdoor/garden-tools/hoses/mega-hose/ and returns a 404) Any help would be much appreciated!


Order by Custom Field date not recognized

Ok, so I have this custom field `wpcf-evento-data-inicio1` generated with the (great) Types plugin.   This is how it stores on db:   `1372896000`   OK, so I want to order by this value. I'm doing it by url args, and i can't spot what is wrong... I'm currently doing like this:               mysyte.com/?post_type=evento&order=desc&orderby=meta_value_num&meta_key=wpcf-evento-data-inicio1      I have also tried with meta_value instead of meta_value_num               mysyte.com/?post_type=evento&order=desc&orderby=meta_value&meta_key=wpcf-evento-data-inicio1      it outputs like this order:   1. 1372896000   2. 1371600000   3. 1372204800 I just cannot see what is wrong, any ideas? Thank you so much. _(edit: Pls note that this is a archive template (archive-evento.php)_


How to add the time of a post to the list of posts on the administration page?

This seems like a simple thing to do, but I haven't been able to figure it out. What I'd like to do is add the time a post is scheduled to the date stamp on the list of posts. I know this means modifying the columns, and there's a way to do it that seems fairly simple. Has anyone done this, and can you suggest some code?


Query multiple custom post types in single loop

I'm aware there are several other posts that cover similar ground to what I'm about to ask. I have three custom post types running, in addition to 'posts'. I want to run a loop that pulls all posts categorised under a particular category                <?php               $args = array(         'post_type' => 'testimonial',         'posts_per_page' => 1,         'tax_query' => array(             array (                      'taxonomy' => 'testimonial_category',                     'field' => 'slug',                     'terms' => 'home'         )     )     );     $query = new WP_Query( $args );                     $postcount = 0;                 ?>                 <?php if ($query->have_posts()) : ?>                     <?php while ($query->have_posts()) : $query->the_post(); ?>                         <?php $postcount++; ?>     //loop here     <?php wp_reset_query(); ?>         This is the code I have at the moment, not sure how I condense this into pulling in multiply post types from one category.


How to display product category's individual product list in shop page?

I want to display each product category's sub products list in the shop page. Actually now in my shop page was displaying the whole list of products. But when ever i click on the list of sub category menu the control was automatically goes to the home page of that site. And i can understand that there is no code error. When i add 2 categories followed by the 4 pre_category in the admin part this problem is occur. So may be its WP-ADMIN settings problem.               I done this site by using woocommerce plugin.          Can u pls help me whats the problem...


WordPress keeps asking for connection information in localhost

I tried to find and answer but even though the problem is common I haven't been able to fix it, WP keeps asking me for the FTP info on my local LAMP environment when trying to install, delete or update themes and plugins. I have set my local `www` folder permissions like this:               drwxrwsr-x  3 root www-data 4096 Oct 28 07:43 www/      So the users in the `www-data` group have full access to the folder, I also ran `chmod -R 775` on my site root folder to make sure the owner and group had full permissions as well. I can upload files using the media upload just fine and I can delete them as well, I can also change the `.htaccess` file on the permalink menu so the permissions are at least partially working. If I change the owner of the site folder to the `www-data` user recursively it works fine but since the files and their parent folders group is `www-data` and they have full group permissions I shouldn't need to do this, is this correct?


Help with a query not working with custom taxonomy

The query below is always returning the latest "news" post, not the latest "news" post with the taxonomy "sotm". I have verified the details of my custom taxonomy, name is "postCat" attached to post type "news", and there is a term "sotm" applied to the post I want to display. Can anyone point out what might be wrong?                   <?php             $sotmArticle_query = new WP_Query(array(                 'post_type' => 'news',                 'postCat' => 'sotm',                 'orderby' => 'date',                 'order' => 'DESC',                 'posts_per_page' => 1             ));             if($sotmArticle_query->have_posts()){                 while($sotmArticle_query->have_posts()){ $sotmArticle_query->the_post();         ?>


Additional Option on Custom Header admin

I would like to extend the Custom Header class to include an animation feature for the header graphics. Essentially, I'd like to add another possible value for the radio button for randomization. The existing code reads:               if ( 1 < count( $headers ) ) {             echo '
';             echo '<input name="default-header" type="radio" value="random-' . $type . '-image"' . checked( is_random_header_image( $type ), true, false ) . ' />';             echo __( 'Random: Show a different image on each page.' );             echo '';             echo '
';         }      I would like to do something like this so you can toggle between random and animated. Default output would look something like this:

     <input name="behavior-header" type="radio" value="none" checked />     None: No randomization or animation.

     <input name="behavior-header" type="radio" value="random" />     Random: Show a different image on each page load.

     <input name="behavior-header" type="radio" value="animate" />     Animate: Display headers as slideshow.

      I have had no luck hooking into the custom_header_options (it just places any code into the end of the page, which does not allow for an either/or selection of none/random/animation). Anyone had any experience with extending the custom header class? Is there a simpler way to do this without extending the class? I'm all ears :)


WooCommerce - Adding notice above products on Shop Home

I am trying to add a block of text above the products section on the base Shop page, but for some reason I am getting other titles above it, and I can't work out where to put it. The block that I want to add is a simple div with some padding and some text. I want to place it so that it appears underneath the main page title, which is Online Shop. This is the page I'm talking about this. However, you'll notice that it's going underneath the Products title, which doesn't make sense. I have tried to find the WooCommerce template file that creates that Product title, but I can't find it anywhere... At the moment, that DIV block of text is in the woocommerce-template.php file, in the root of the Woocommerce plugin folder. (I'll move it to it's own folder within my theme when I've finished this, as I'm aware that it'll get overwritten with updates if I don't). Can anyone point me to the right WooCommerce template file?


multisite on subdomains but all admins on main domain subdirectory

I need to have subdomain multisite install but with no wp-login and wp-admin on subdomains but only on maindomain.com/site/(wp-login/wp-admin). What are the tweaks i need to do to get this working? edit: so far i tried this but it did not changed anything:               $uri = $_SERVER["REQUEST_URI"];       $uri_array = split("/",$uri);     $uri_first = $uri_array[2];      if (  $uri_first == 'wp-admin' )     {     define('SUBDOMAIN_INSTALL', false);         }     else     {     define('SUBDOMAIN_INSTALL', true);     }


Adding posts of custom type into the main feed

I'm having some trouble with a subject that seems to be pretty basic, so I'm starting to feel (a little, only a little) dumb :-) Here's the thing: I want my main feed to include the posts and other content (custom post types) as well. I followed two pointers so far:   1. First I followed this tip at WPmu.org. It works when I use only one custom type, but fails to include more than one custom type (adding them to the array).   2. Later I followed the answer provided in this previous SE thread. This ended in an Error 500, so I went back to the first approach. Here it is the code I'm including right now, I don't see my error, but clearly something is not OK.               function two_customtype_in_home_loop( $query ) {      if ( is_home() && $query->is_main_query() )      $query->set( 'post_type', array( 'post', 'custom1', 'custom2') );      return $query;      }      add_filter( 'pre_get_posts', 'two_customtype_in_home_loop' );      Edited to add: I forgot to add the code provided in a previous StackExchange thread (marked as "worked perfectly" and approved reply). The code is:               // ADDS POST TYPES TO RSS FEED     function myfeed_request($qv) {         if (isset($qv['feed']) && !isset($qv['post_type']))             $qv['post_type'] = array('ve_products', 'post');         return $qv;     }     add_filter('request', 'myfeed_request');      I adapted the line:                       $qv['post_type'] = array('ve_products', 'post');      and added my two custom types:                       $qv['post_type'] = array('custom1', 'custom2', 'post');      This solution is breaking my site, and I can't find out why. Any ideas? Thanks :)


Members Only site with Feed Keys

I've had good luck for several years (6 years!) running WordPress with Members Only and Feed Keys. This provided a completely members only blog (no external view at all) as well as private RSS feeds for those members who want it. It looks like a recent update has caused some piece of functionality to stop working, and new feed key urls now return:               <rss version="2.0">     <channel>     <title>Blog Name</title>     <link>http://example.com</link>     <item>     <title>No Feed Key Found</title>     <link>http://example.com</link>     <description>     You need to use a Feed Key to access feeds on this site. Please login to obtain yours.     </description>     <pubDate>July 31, 2012 14:27:41 UTC</pubDate>     </item>     </channel>     </rss>      So my questions, given these plugins have not been updated in some time:   1. What might be causing this issue? Are there issues with older plugins and newer WordPress that seem likely culprits?   2. Are there now better solutions for members only with feed key blogs? I see WordPress Access Control, and tried it, but it has feed keys on a development roadmap, not in the current release.   3. Any other ideas?


\-- I've just done a fresh install of Wordpress 3.4 \-- I've downloaded and uploaded this new free eCommerce wordpress theme suggested by smashing magazine. { http://www.smashingmagazine.com/2011/10/19/free-e-commerce-wordpress-theme- balita/ } \-- And I get this giant error on the homepage:               Fatal error: Call to undefined function wpsc_cart_item_count() in /home/content/97/8209697/html/websitename/wp/wp-content/themes/balita/header.php on line 78      Line 78 reads:
<?php printf( _n('%d item', '%d items', wpsc_cart_item_count(), 'tokokoo'), wpsc_cart_item_count() ); ?>
      _Live Site at (http://tinyurl.com/cdva5aw)_ **Any pointers?**


How to make the home screen of my blog not show full posts?

I recently set up my blog and on the home screen, the full blog posts are shown. Is there a way to cut off the blog posts at some point in the text? As it is now, my home screen is extremely long with a bunch of full blog posts.


Wordpress NavXT plugin localization

My situation is as follows: 1) I am using wordpress 3.6.1, and I have the Breadcrumb NavXT plugin installed. 2) I have a custom theme, and the localization file is on the following path: theme_folder/languages/ar_AR.mo file I want the path in breadcrumbs to be localized (i.e. let "mywebsite > My Account" appear in local language instead of English). 1) I changed wp-config.php to be: define('WPLANG', 'ar_AR'); 2) I added the labels that appear in the breadcrumbs (i.e. My Account) to the PO file, and generated a new MO file (using POEdit), and uploaded the new MO file to the path: theme_folder/languages/ar_AR.mo file After doing the steps above, NOT all of the labels in the breadcrumbs path are translated in the webpage (some of them are successfully translated), although they are translated in PO file. So the questions is: What should I do in order to translate the breadcrumbs path?


Encrypt Email Addresses at Rest

Some enterprise clients require that all email addresses be encrypted at rest (i.e., the actual values stored in the database must be encrypted). I've put together something that seems to do the trick, based on quick testing. But I want to know if anything looks glaringly missing or wrong? One thing I'm reasonably sure of: there are no filters or hooks in the WP_User class that allow you to control what it returns. So any plugins that use that class directly will probably break. But is there anything in core that'll break because of this? Am I taking the wrong approach altogether here? (For the sake if simplicity, I'm just base64encoding values in this example. I realize this is not encryption :))               <?php              /*         Plugin Name: Email Encryption at rest.         Version: 1.0         Description: Testing encryption at rest for email addresses         */              /**          * Intercept user queries, and fix 'em if necessary          */         function wpsx_pre_user_query( $obj_query ) {                  // Trim off the *s. These seem to be added automatically to the query.             $search = isset( $obj_query->query_vars['search'] ) ? trim( $obj_query->query_vars['search'], '*' ) : '';                  // Figure out if the search term is an email address. If so, encrypt it.             // This precludes partial matches on emails address searches             if( is_email( $search ) )                 $obj_query->query_where = str_replace( $search, wpsx_encrypt_email( $search ), $obj_query->query_where);              }         add_action( 'pre_user_query', 'wpsx_pre_user_query' );              /**          * Custom version of the get_user_by() function,          * which is used by a lot of things to get user data.          */         if ( !function_exists('get_user_by') ) {                  function get_user_by( $field, $value ) {                      // If we're checking against an email address, be sure we're checking the encrypted version                 if( 'email' == $field )                     $value = wpsx_encrypt_email( $value );                      $userdata = WP_User::get_data_by( $field, $value );                      if ( !$userdata )                     return false;                      $user = new WP_User;                 $user->init( $userdata );                      // If we pulled an email out of the DB that looks encrypted, decrypt it                 if( isset( $user->user_email ) && !is_email( $user->user_email ) )                     $user->user_email = wpsx_decrypt_email( $user->user_email );                      return $user;             }              }              /**          * When the current user is set, make sure we decrypt any email the obj contains          */         function wpsx_set_current_user( $user ) {                  global $current_user;                  if( ( $current_user instanceof WP_User ) && isset( $current_user->data->user_email ) && !is_email( $current_user->data->user_email ) )                 $current_user->data->user_email = wpsx_decrypt_email( $current_user->data->user_email );              }         add_action( 'set_current_user', 'wpsx_set_current_user' );              /**          * Encrypt the given email address, if necessary          */         function wpsx_encrypt_email( $email ) {                  if( !is_email( $email ) )                 return $email;                  return base64_encode( $email );              }         add_filter( 'pre_comment_author_email', 'wpsx_encrypt_email' );         add_filter( 'pre_user_email', 'wpsx_encrypt_email' );              /**          * Decrypt the given email address, if necessary          */         function wpsx_decrypt_email( $email ) {                  if( is_email( $email ) )                 return $email;                  return base64_decode( $email );              }         add_filter( 'the_author_email', 'wpsx_decrypt_email' );         add_filter( 'comment_author_email', 'wpsx_decrypt_email' );         add_filter( 'user_email', 'wpsx_decrypt_email', 1 );          ?>


How to get or know the slug of home.php

I found this code from Different Main Navigation per category:               <?php       if(is_category('first-category') || in_category('first-category)) {      wp_nav_menu( array('menu' => 'First Category Nav' ));      } else {       wp_nav_menu( array('menu' => 'Default Nav' ));     }     ?>      and want to re-use this to display different main nav in my `home.php` and the rest of the page. I came up with this:               <?php     if(is_page('???') || in_page('???')) {        wp_nav_menu( array(        'menu' => 'Main Nav Menu',        'container' => ''       ));      } else {       wp_nav_menu( array(         'menu' => 'Nav Menu',         'container' => ''       ));     }     ?>      but I don't know where to find this home.php slug, I tried 'home' as slug but i turned out an error page:               Fatal error: Call to undefined function in_page() in D:\xampp\htdocs\wp-xxx\wp-content\themes\BLANK-Theme\header.php on line 62


How can I output the custom fields wrapping with HTML

I am trying to publish custom fields created using the plugin "Advanced Custom fields". I am able to display them on posts and custom post types as raw output. But I want to wrap html around the output. Ex: Field-1(field name is 'the_one'): I want to publish any content like Text or Date with the format I want.               <?php if( get_field('the_one') != '' ) : ?>             <a href="<?php echo get_field('the_one'); ?>"><?php _e( 'Content', $post_id ); ?>      Field-2 (field name is 'the_link'): I want the URLs for website urls be published converting to links               <?php if( get_field('the_link') != '' ) : ?>         <a href="<?php echo get_field('the_one'); ?>"><?php _e( 'Special Category', $post_id ); ?>     <?php endif; ?>      Could any one help me with this? Thanks! Update: I have no success creating custom fields by own. So tried to use ACF again. Here is the loop.php code- http://pastebin.com/7UE2izdg. Custom fields are in the lines 58 and 59.


Include WooCommerce 2's prettyphoto scripts on all site pages

So when WooCommerce updated to version 2 they replaced the fancybox lightbox scripts with prettyphoto. I would like to use this on all my wordpress site's pages, not just the product pages, but the scripts are only loaded on a product page. I have a jQuery script to add the relevant css class to my image links but I need a filter/hook to make sure the actual scripts are loaded. Can anyone help?


Posts made to category don't show up (do show up on frontpage)

Added a subcategory to WordPress. Wrote a blog post and attached it to this subcategory. Now for some reason when I check it on my site, it give me the below error:               Sorry, you are looking for something that isn't here.      The weird thing is that I can still access the post from the front page, and it shows me the correct URL:               subdomain.domain.com/category/subcategory/postname        But when i remove "postname", it says it can't find it. Any ideas?


Need to remove 'Featured', 'Date' and 'Comments' from WordPress Sticky Post?

I need to remove the 'Featured', 'Date' and 'Comments' from my Twenty Eleven child theme sticky post that I have on my landing page. I am finding it hard to find any information that show what functions I will need to override and what files they reside in. Does anyone know what I need to override and help point me in the right direction. I have amended the 'loop' in index.php adding which only shows the posts that are not sticky. I now need to remove the comments etc from sticky post, any idea as to what function(s) I will need to override? Thanks in advance code for index.php               <?php if ( have_posts() ) : ?>                 <?php twentyeleven_content_nav( 'nav-above' ); ?>                      <?php /* Start the Loop */ ?>                 <?php while ( have_posts() ) : the_post(); ?>                         <?php if( !is_sticky() || !is_home() ) :?>                          <?php get_template_part( 'content', get_post_format() ); ?>                     <?php endif;?>                 <?php endwhile; ?>                      <?php twentyeleven_content_nav( 'nav-below' ); ?>


Wordpress not taking password and username

I am in a strange situation, I installed wordpress on my godaddy hosting everything was fine and i developed my theme in nice way, But now i cant login in wp-login.php, i try to reset my password but when password is resetting it taking me to the subscribers dashboard not on admin dasboard. i can resgister on my site as subscriber is there a way so i can change subscriber to admin from phpmyadmin ?


Get categories for a specific post - Custom post type

I'm trying to retrieve all the categories which are related to a specific post, using the `wp_get_post_categories()` function. The problem is that it is a custom post type, so I tried sending it in the $args array :               wp_get_post_categories($id,array('post_type'=>'product'));      but that returned an empty array as well. What is the correct way of doing it?


Can i show items based on the day with php?

I have a code on my site that displays different headers for different post types using the `if ( get_post_type() == 'post type here' ) {` code but is there a way i can do this for days of the week? I want to create a calendar since i can't find an actual good calendar that works to my fits. I want to create a list of shows and showtimes based on the day of the week and place it in the sidebar. * _I'm trying to create a list of items to display in the sidebar using a php code....for example when it's monday only the list for monday will show and etc......by using th`echo ''` term i want to be able to place `<div>` and or `<tabel>` inside the echo code *_


Preview page/post revisions without overwriting current content

Is it possible to add or update a Post/Page without it overwriting the current content that it on there? I need to make some edits to a page, but I need to have someone review it before I can publish it and I don't want to overwrite the current content that is up there.   Any suggestions?


I want use these code to load src of images that attachs in wordpress's post:               $recent = new WP_Query("showposts=30"); while($recent->have_posts()) : $recent->the_post();                  $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array(80,80) );             echo $thumb[0];          endwhile;      but my code don't work, and give me nothing. please help me


"After file loaded" action

I have a plug-in that allows for repeatable fields. There will be an image and the image description. The description allows for tinyMCE editing. There are obviously problems with this, but I think I have found a solution. What I am trying to do is save the metadata after the user closes the thickbox and the image filed is populated. I'm wondering if there is an 'add_action' hook that I can use to accomplish this. Any ideas?


Making Wordpress Local Again?

I've been working on a Wordpress site for a while and have gone to make it live this afternoon. After following this tutorial video (http://www.youtube.com/watch?feature=player_embedded&v=cM9Z8aQTCvQ), I went into settings on my localhost installation and changed them to my live site, therefore my local Wordpress installation no longer works. Is there an easy way to access that page and point Wordpress locally again? The upload didn't work out so I decided to just do a manual re-install.


How to delete post revisions?

I haven't set a limit to the number of revisions, which makes some of my post have more than 20 revisions, so how to delete these revisions? By the way, I am using WPMU and have many blogs, so how to delete WordPress revisions for all my blogs?


List all images from a single post meta value

I have created a custom post type with an image gallery upload. Now I am trying to display the gallery on the front end. This is what I have so far that works to display 1 image, but if multiple images are uploaded all the URLs get stuck in the `src` tag. So I'm guessing I should loop through that array and spit out each one separately? Would that be the route to go and if so how can I accomplish this?               <?php if (have_posts()) :  while (have_posts()) : the_post(); ?>          <?php     echo 'ID, 'gallery-upload', true).'">';         ?>          <?php endwhile; else: ?>
<?php _e('No posts were found. Sorry!'); ?>
     <?php endif; ?>      EDIT: This is what I ended up with that works...               <?php     foreach(get_post_meta($post->ID, 'gallery-upload') as $meta) {      foreach(explode(',', $meta) as $src) {       echo '';      }     }     ?>


Add number of members to “Right Now” dashboard widget

## Problem I have this code in functions.php but it does not output the total number of members (something is wrong with it it breaks the site) in my "Right Now" dashboard. Is there a way to fix it?               function dashboard_wps_user_count() {     global $wpdb;     $users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");     ?>

           <? echo $users; ?>	           Members

     <?}     add_action( 'right_now_content_table_end', 'dashboard_wps_user_count');      ## Additional feature Also is there a way to show how many authors are registered and how many subscribers are registered also in the "Right now " dashboard?


Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]

I am currently trying to perform a custom query on the authors page (author.php). I have two custom fields for posts that I want to query against (post_photographer and post_videographer). What I am trying to do for the author's profile is get all the posts for the current user profile where the user is:   * the author of the post   * **OR** the post photographer   * **OR** the post videographer  So each person's profile **MAY** have posts that they didn't author (they were the photographer or videographer instead). The following code is close to what I want, but the problem is that it retrieves posts where the current user is the author **AND** is either a post photographer **OR** post videographer. It needs to be where the current user is the author **OR** post photographer **OR** post videographer.               $args = array(     'author' => $posts[0]->post_author,     'meta_query' => array(         'relation' => 'OR',         array(             'key' => 'post_photographer',             'value' => $posts[0]->post_author,             'type' => 'numeric'         ),         array(             'key' => 'post_videographer',             'value' => $posts[0]->post_author,             'type' => 'numeric'         )       )     );     query_posts( $args );      Is this possible via WordPress queries (query_posts or WP_Query), or do I need to write custom SQL? Any help is greatly appreciated! If you need clarification please ask.


Use regular category with custom post types

I'm using WooCommerce that uses a custum post type (`product`) with its own product category taxonomy (`product_cat`). Now I'm using an other plugin (minimu) that selects posts to display based on the normal WordPress category. Seeing as my custom post types don't belong to a regular category it displays nothing... Now I want to make it so that I can assign a product category as well as a normal category to each post. How would I have to modify this? I guess adding something to the custom post declaration of WooCommerce? But no idea how and what? **EDIT** Found this code, that makes it able to assign regular categories to custom post types but now my importer doesn't assign them, but I think I'll be able to fix this.               add_action( 'init', 'wpse6098_init', 100 ); // 100 so the post type has been registered     function wpse6098_init()     {         register_taxonomy_for_object_type( 'category', 'product' );     }      This post may be deleted, tried to do it myself


Bidding site plugin

I have to make the bidding site like odesk, freelancer type. Is there any helpful plugin for job, contractor, user, project and payment management in wordpress as these are the main tasks of this project? Secondly, building it in wordpress will be good or in a custom way?


changing theme folder name breaks menus - twentyeleven

I needed to change the twentyeleven theme folder name, so I activated the default theme, changed the twentyeleven folder name to X, then reactivated it. Everything worked except the menus were all in the wrong places. I figured out they needed to be redefined in Menus>Theme Locations. But now, there's an extra sitemap listing in the footer.. I didn't put it there and can't figure out how to get rid of it. It's listing out the sitemap in ul tags, twice. Any suggesions?


Simple Facebook Connect token errors

I'm using this plugin to try and integrate a facebook page to my WP site. I'm not sure why i'm getting the following errors and wondered if anyone could help? No User or Access Token found. Try re-saving this page. Application Access Token found! Fan Page Access Token not found. Try re-saving this page. I'm not sure what the user or access token relates too - i'm the manager of the fb fan page too. Any help would be great thanks


Make a Shortcode load after Post/Page Content?

I created a shortcode for `time.ly`'s "all in one event calendar app" that makes a paginated list of upcoming events with out all the java script and user options. I posted about it here. _(Its still a work in progress)_ As it is now it loads before all the content, I'm guessing because the file returned at the end includes `echo`'s. I'd prefer if it always loaded after the posted content regardless of where it is typed on the page. Is it possible to force a short code to load after page content?


wpdb Cannot Access Associative Array Data in a Count Query

I have two records in my custom table. I am trying to use `SELECT COUNT(*) AS total FROM tableA` but I am not getting the results I am expecting. The code below will echo `Array ( [0] => Array ( [total] => 2 ) )`:               // Count the amount of records in the table     $total = $wpdb->get_results( "SELECT COUNT( * ) AS total FROM tableA", 'ARRAY_A' );          echo "Total Records:" . print_r( $total );      The code below echos nothing:               // Count the amount of records in the table     $total = $wpdb->get_results( "SELECT COUNT( * ) AS total FROM tableA", 'ARRAY_A' );          echo "Total Records:" . $total[0]['total'];      How can I simplify this? What am I doing wrong? I'm racking my brain over this and I just can't get it to work.


how to create a static front page for my blog in wordpress

I need php code to create a static front page for my blog.how do it by php in wordpress.anybody can help me.


How to display a posts 1 year ago with custom WP_Query loop?

I have a custom WP_Query loop that I use for the main archive page. How can I filter the custom query to diplay posts from within 2 days +/- of one year ago from todays date? My current query:               $posts_args = array(          'post_type' => 'album',         'post_status' => 'published',         'paged' => $paged,         'order' => strtoupper($album_sort),         'orderby' => 'date'     );      I know that the codex lists this time parameter for WP_Query but I've never used a loop filter and am a little confused on the implementation.               // Create a new filtering function that will add our where clause to the query     function filter_where( $where = '' ) {         // posts  30 to 60 days old         $where .= " AND post_date >= '" . date('Y-m-d', strtotime('-60 days')) . "'" . " AND post_date <= '" . date('Y-m-d', strtotime('-30 days')) . "'";         return $where;     }          add_filter( 'posts_where', 'filter_where' );     $query = new WP_Query( $query_string );     remove_filter( 'posts_where', 'filter_where' );      Any assistance is appreciated.


Leader board for game on homepage

I've built a simple game which is housed on my homepage. I'd like to create a leader board (a small results table) which displays the top three 3 scores. How would i insert/retrieve the score data into and from my DB? The games been coded using JS, is there wordpress php functions that would help me GET / POST this data. thanks in advance, Cam


register_nav_menus and wp_nav_menu issue, not displaying independent menus

My problem is that wordpress isn't showing the two menu's as separate menus, it just outputs on menu to both positions. URL: http://www.msc-media.co.uk Check the header and footer for the links - I know the footer is ugly, need to sort out the css later. I've created two menus in the functions.php with this code.               <?php         register_nav_menus( array(             'topmenu' => 'Top Menu',             'footermenu' => 'Footer Menu',         ) );          ?>      I've then called these menu's in my footer.php and header.php with this code:               <?php wp_nav_menu(array('menu' => 'footermenu')); ?>     <?php wp_nav_menu(array('menu' => 'topmenu')); ?>      This is my back-end config with wordpress, getting the top menu to show 4 links, and the footer to display two. With the positions correctly appointed. ![enter image description here](http://i.stack.imgur.com/vSmQo.png) Can anyone explain what is wrong with this? - I'm stumped and I've searched the WP codex/forums for hours now.


Using thumbnail functions inside a shortcode

I'm trying to figure out why WP doesn't seem to recognize functions like get_the_post_thumbnail() inside a shortcode loop. For example, tried adding it to a fresh theme / plugin-less installation. Here's my functions.php:               <?php     add_theme_support( 'post-thumbnails' );           function scRecentPhoto() {     global $post;          $photoargs = array(     'post_type' => 'photos',     'posts_per_page' => 1,      );     $photoloop = new WP_Query($photoargs);          while ( $photoloop->have_posts() ) : $photoloop->the_post();      $output = get_the_post_thumbnail(array(280,130));     $output .= '
' . get_the_title() . '
';     $output .= '
' . get_the_excerpt() . '
';     endwhile;          return $output;     }     add_shortcode('recentphoto', 'scRecentPhoto');     ?>      And I always get a PHP error such as: Fatal error: Call to undefined function get_the_post_thumbnail() in ... Any ideas? Thanks. EDIT = Photo CPT example code:               register_post_type( 'photos',         array(             'labels' => array(                 'name' => __( 'Photos' ),                 'singular_name' => __( 'Photo' )             ),             'public' => true,             'supports' => array(                 'title',                 'editor',                 'author',                 'thumbnail',                 'excerpt',                 'comments'             ),             'capability_type' => 'post',             'rewrite' => array('slug'=> $slug)         )     );      EDIT 2 = Did some more testing, and it turns out that the shortcode works if I place it directly in a post / widget / etc. it just wouldn't work where I need it, which is inside a theme options page. Which I'm calling as such:               $homeoptions = get_option('home_options');     $row1box1 = do_shortcode($homeoptions['row1box1']);          if ($row1box1) :     echo '
' . $row1box1 . '
';     endif;       I'm not entirely sure why it won't work inside the option page though, as other basic shortcodes I've had created work just fine. But hopefully this maybe narrows down the problem a bit?


How to order by blog ID in this multisite 'List Blogs' custom function

I found this really cool function to list all the blogs on a multisite network install. Because the original multisite list blogs function was depreciated :/    So I am using this function below which is great because it is so flexible. But the only thing I can't seem to work out is how to re-order the get_results query. Can any one please help me understand how to re-order this query by blog id, instead of the current outputted alphabetical order.                  function projects_menu($link_self = true)     {         global $wpdb;         echo '
';              $blogs = $wpdb->get_results("             SELECT blog_id             FROM {$wpdb->blogs}             WHERE site_id = '{$wpdb->siteid}'             AND spam = '0'             AND deleted = '0'             AND archived = '0'             AND blog_id != 1         ");         $sites = array();         foreach ($blogs as $blog) {             $sites[$blog->blog_id] = get_blog_option($blog->blog_id, 'blogname');         }         natsort($sites);         foreach ($sites as $blog_id => $blog_title) {             projects_menu_entry($blog_id, $blog_title, $link_self);         }              echo '
';     }         Source of this functions https://gist.github.com/davejamesmiller/1966341    Thanks in advance. * * * See this should work but does not...               $blogs = $wpdb->get_results("             SELECT blog_id             FROM {$wpdb->blogs}             WHERE site_id = '{$wpdb->siteid}'             AND spam = '0'             AND deleted = '0'             AND archived = '0'             AND blog_id != 1             ORDER BY blog_id         ");      * * *               // EVENTS SITEMAP     function projects_menu_entry($id, $title, $link_self)     {         global $blog_id;         if ($link_self || $id != $blog_id) {             if ($id == $blog_id) {                 echo '
';             } else {                 echo '
';             }             $url = get_home_url($id);             if (substr($url, -1) != '/') {                 // Note: I added a "/" to the end of the URL because WordPress                 // wasn't doing that automatically in v3.0.4. YMMV.                 $url .= '/';             }             echo ' ' . $title . '';             echo '
';         }     }     function projects_menu($link_self = true)     {         global $wpdb;         echo '
';         echo '
Admin sitemap
';              $query = "         SELECT blog_id         FROM $wpdb->blogs         WHERE site_id = %d            AND public   = '1'            AND archived = '0'            AND mature   = '0'            AND spam     = '0'            AND deleted  = '0'            AND blog_id != '1'         ORDER BY blog_id ASC";         $blogs = $wpdb->get_col( $wpdb->prepare( $query, $wpdb->siteid ) );              $sites = array();         foreach ($blogs as $blog) {             $sites[$blog->blog_id] = get_blog_option($blog->blog_id, 'blogname');         }              foreach ($sites as $blog_id => $blog_title) {             projects_menu_entry($blog_id, $blog_title, $link_self);         }              projects_menu_entry(1, 'Home', $link_self);              echo '
';          }      Please see above my function 'trying' to list all blogs in on my network site and show which is currently being viewed by having a active class. But the above code is only returning one site. And the home link.


Create wordpress dashboard metabox which spans all columns

Is it possible to create a wordpress dashboard plugin that will span all the columns that the user has chosen to display? I know how to force the user to only display one column but I would rather leave them that freedom and span the number of columns that they have selected. Be it one, two, three or four. Thanks.


Including a post title in a twitter link

Im trying to make a Twitter button on each article of my blog. This is the code I use on single.php               <a href="http://twitter.com/home?status=<?php echo urlencode(get_the_title()); ?>">     Tweet this!     </a>      The problem is that I have a blog post with this title: > Give format to “bodytext” and when I tweet it, the quotes appear as > Give format to “bodytext” What should I do?


Assign a custom post to a custom taxonomy based on custom field value

This answer does exactly what I needed to do, but the only thing is I need it to select more than just one category. So I have changed the code to work based on salary so salary gets entered into a custom field, then it automatically selects the salary banding category which works fine, but now I have a _salary from_ and a _salary to_ custom field so I have a value of salary to, so how can I get the code to add the post to mulitiple categories based on both values if that makes any sense? Below is my code that works for the category selection based on the value of salaryband, so I need it to also select the category based on salaryband2 (custom field)               function add_my_taxonomy($post_ID) {         $salary = array(     '1015' => '10 - 15 ph',     '100140' => '100K - 140K',     '101120' => '101K - 120K pa',     '121150' => '121K – 150K pa',     '151170' => '151K – 170K pa',     '171200' => '171K – 200K pa',     '2025' => '20 – 25 ph',     '2025k' => '20K – 25K pa',     '2630' => '26 – 30 ph',     '2630k' => '26K – 30K pa',     '3040' => '30 – 40 ph',     '3140k' => '31K – 40K pa',     '4150' => '41K – 50K pa',     '5160' => '51K – 60K pa',     '6170' => '61K – 70K pa',     '7180' => '71K – 80K pa',     '8190' => '81K – 90K pa',     '91100' => '91K – 100K pa'         );         $zip = array(     '1015' => '10, 11, 12, 13, 14, 15,',     '100140' => '101000, 102000, 103000, 104000, 105000, 106000, 107000, 108000, 109000, 110000, 111000, 112000, 113000, 114000, 115000, 116000, 117000, 118000, 119000, 120000, 121000, 122000, 123000, 124000, 125000, 126000, 127000, 128000, 129000, 130000, 131000, 132000, 133000, 134000, 135000, 136000, 137000, 138000, 139000, 140000,',     '101120' => '101000, 102000, 103000, 104000, 105000, 106000, 107000, 108000, 109000, 110000, 111000, 112000, 113000, 114000, 115000, 116000, 117000, 118000, 119000, 120000,',     '121150' => '121000, 122000, 123000, 124000, 125000, 126000, 127000, 128000, 129000, 130000, 131000, 132000, 133000, 134000, 135000, 136000, 137000, 138000, 139000, 140000, 141000, 142000, 143000, 144000, 145000, 146000, 147000, 148000, 149000, 150000,',     '151170' => '151000, 152000, 153000, 154000, 155000, 156000, 157000, 158000, 159000, 160000, 161000, 162000, 163000, 164000, 165000, 166000, 167000, 168000, 169000, 170000,',     '171200' => '171000, 172000, 173000, 174000, 175000, 176000, 177000, 178000, 179000, 180000, 181000, 182000, 183000, 184000, 185000, 186000, 187000, 188000, 189000, 190000, 191000, 192000, 193000, 194000, 195000, 196000, 197000, 198000, 199000, 200000,',     '2025' => '20, 21, 22, 23, 24, 25,',     '2630' => '26, 27, 28, 29, 30,',     '2025k' => '20000, 21000, 22000, 23000, 24000, 25000,',     '2630k' => '26000, 27000, 28000, 29000, 30000,',     '3040' => '31, 32, 33, 34, 35, 36, 37, 38, 39, 40,',     '2630k' => '26000, 27000, 28000, 29000, 30000,',     '3140k' => '31000, 32000, 33000, 34000, 35000, 36000, 37000, 38000, 39000, 40000,',     '4150' => '41000, 42000, 43000, 44000, 45000, 46000, 47000, 48000, 49000, 50000,',     '5160' => '51000, 52000, 53000, 54000, 55000, 56000, 57000, 58000, 59000, 60000,',     '6170' => '61000, 62000, 63000, 64000, 65000, 66000, 67000, 68000, 69000, 70000,',     '7180' => '71000, 72000, 73000, 74000, 75000, 76000, 77000, 78000, 79000, 80000,',     '8190' => '81000, 82000, 83000, 84000, 85000, 86000, 87000, 88000, 89000, 90000,',     '91100' => '91000, 92000, 93000, 94000, 95000, 96000, 97000, 98000, 99000, 100000,'         );         foreach ($zip as $code => $salaryband){             $salaryband = explode(',', $salaryband);             $customField = get_post_meta($post_ID,'salaryband',true);             if (in_array($customField,$salaryband)){                 wp_set_object_terms( $post_ID, $salary[$code], 'salary' );             }         }


How to display page title+link of page created by user

I want to check if user is logged in and if have created a page. If so, option 1 is shown. This all works fine. But **how to display page title+link of page created by that user** between {page title with link to page} See the code below I tested it with no results. As used in the code below, nothing special is showing, only option 1 text (which is good for the user have a page created and is logged in).                   <?php             if ( is_user_logged_in() ) {                 global $wpdb;             $user = wp_get_current_user();             $where = get_posts_by_author_sql( 'page', true, $user->ID );             $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );                      if ( $count >= 1 ) {                       // this part is added to display page title+link created by current user                 foreach ( $results as $result )                     printf( '%2$s
',                      get_permalink( $result->ID ),                         esc_html( $result-post_title )                     ); ?>          //option 1
Hey <?php echo $current_user->display_name ?>, check your page here: {page title with link to page}
              <?php } else { ?>         //option 2
Welcome <?php echo $current_user->display_name ?>, etc.. text with tags etc.
              <?php } } else { ?>         //option 3
text with tags etc.
              <?php } ?>      Any suggetions?


how to force caching of wordpress admin

Because of using slow connection these days, I would like to force WordPress's Admin section to be cached in browser (FF,IE) so that it it takes less time to load admin pages (because in fact, most of items never change.). Is there any way to do that?


WordPress Paginate $wpdb->get_results

Due to a complex multisite config, I have a query which combines the posts from two blogs and I would like to **paginate the results**. I am grateful for any help. I have posted my query.                           $latestposts = $wpdb->get_results(                      "                 (SELECT * FROM net_5_posts                 INNER JOIN net_5_term_relationships ON net_5_posts.ID=net_5_term_relationships.object_id                   WHERE post_type = 'post'                  AND post_status = 'publish'                  AND term_taxonomy_id = '151'                  )                      UNION ALL                      (SELECT * FROM net_7_posts                 INNER JOIN net_7_term_relationships ON net_7_posts.ID=net_7_term_relationships.object_id                   WHERE post_type = 'post'                  AND post_status = 'publish'                  AND term_taxonomy_id = '20'                  )                      ORDER BY post_date                 DESC LIMIT 5",'ARRAY_A');                      foreach ($latestposts as $latestpost) {                      $da_id = $latestpost['ID'];                 $da_title = $latestpost['post_title'];                 $da_content = strip_tags($latestpost['post_content']);                 $da_content = limit_words($da_content,55);                 $da_link = $latestpost['guid'];                 $da_date = $latestpost['post_date'];                 $da_date = date('F j, Y', strtotime($da_date));                      echo '

'.$da_title.'
                 '.$da_date.'                 '.$da_content.'…
                 Continue Reading
                 ';                      }


What is the "with_front" rewrite key?

I have the following line in a register_post_type function:               'rewrite' => array('slug' => 'Newsletters', 'with_front' => false),      I understand what the line does in general (adds "newsletters" to the slug) but I don't specifically understand what the 'with_front' part does. I have to admit, I don't really have a problem that needs solving, but I'm suddenly curious....


Get names of authors who have edited a post

How can I call the usernames of people that have edited a post? I know I can use `get_the_modified_time` to display the time the post was last modified, is the same possible with the list of users that edited it?