Run a plugin just 'once' per page reload

I'm making a plugin that counts the number of times a visitor visits my site. I want to run the code in the plugin once per page load. What's a good action hook I can use ?


When using wp_enqueue_script(); in a theme why don't we use add_action?

When using `wp_enqueue_script` in a plugin, I have always been told to use an `add_action` :               function add_my_css_and_my_js_files(){         wp_enqueue_script('jquery-validate-min', plugins_url('jquery_validate_min.js', __FILE__ )          }     add_action('wp_enqueue_scripts', "add_my_css_and_my_js_files");        How come this is **not** required if you put wp_enqueue_script in the theme:                wp_enqueue_script('jquery-validate-min', plugins_url('jquery_validate_min.js',


Search by the title in WP_Query?

From the wordpress offical document website , there are a search parameter which is `&s={keywords}` However, I wonder is this search is based on everything of the Post? that means if I provide `&s=book` , then if a Post has a name = "abc" which is a category of "book", it still include in the search result. Are there any way to specific the search to title_plain only?


Sending a search query form a Flash search box to Wordpress search.php?

it does not look like to many people would try this, maybe not possible?? I have an old Flash page that contains a search for using command "Get" and goes to a cgi search script. I need to modernize the whole thing and use WordPress for my Arts Directory in the future - but, this little tricky thing keeps bugging me, i want to use my Flash interface as front page and the search box /search query should end up at WordPress `search.php` (or `searchform.php` which my Theme has in addition to `search.php`. Is there any way to do this in Flash, what PHP string would i need to replace the existing               On (Release)           If (query ne "")                 Get URL ("cgi-bin/linksaroo/search.pl", window="_self", vars=GET)           End If     End On      in Flash??


Help with implementing qTip2, with html map in wordpress

I am trying to create an HTML map with qTip2 in my WordPress page, but can't get it work- so I'd really appreciate your help. My aim is to have something very similar to this StackOverflow thread. but in my WordPress custom page. I have added the same HTML and CSS as in the example (as a test) and placed the jQuery in a separate file called `qtipcall.js`, I have then followed a tutorial How to implement the qTip to WordPress. I have followed it step by step, did everything few times and it doesn't work! As it says in the guide I have inserted, this, just above the `wp_head()`:               wp_enqueue_script('qtip', 'your/path/to/jquery.qtip.min.js', array('jquery'), false, true);     wp_enqueue_script('qtipCall', 'your/path/to/qtipcall.js', array('jquery', 'qtip'), false, true);      I then updated the paths to match my site, like this:               wp_enqueue_script('qtip', get_template_directory_uri() . '/js/jquery.qtip.min.js', array('jquery'), false, true);     wp_enqueue_script('qtipCall', get_template_directory_uri() . '/js/qtipcall.js', array('jquery', 'qtip'), false, true);      But the files seem not to be loading up with the site. I have checked the page source and the call for the two `js` files (`jquery.qtip.min.js` and `qtipcall.js`) aren't in the code. This is my site. Would appreciate any suggestions and tips on what I am doing wrong and how to fix this.


database columns: post_title vs post_name

I changed post_title, post_contents, and post_name to allow for utf by changing collating sequence to: utf8_general_ci Then using add new post, I type for the title three Hebrew ALEFs.   The post_title is in Hebrew in the database, but the post_name has this value: %d7%90%d7%90%d7%90 According to Charmap, ALEF has a hex value of 05D0.   So what does the d790 represent? Some other encoding? I'm looking to write a program to mass upload a bunch of posts, so I need to know what to put in the post_name field, and what it is used for.


How can I set up a category "overview" page?

I know I can use the Template Hierarchy to set up custom theme pages for terms inside a category, like these:               mysite.com/category/tech/              // category-tech.php     mysite.com/category/blog/              // category-blog.php     mysite.com/category/featured/          // category-featured.php      `category.php` does not seem to work for the overview page, but it would work for a page like `mysite.com/category/tech/` if a more specific template file (`category-tech.php`) was not available. I want to create a "category overview" page (`mysite.com/category/`) which would show all the terms of the `category` taxonomy. Similarly, I would also like to be able to do this with a custom taxonomy, such as `mysite.com/books/` in this case:               mysite.com/books/fiction/     mysite.com/books/non-fiction/     mysite.com/books/science/      I do want this done dynamically, i.e. I don't want to create a page called 'category' with a permalink `category` and then add the items to that page. I think it would work but that seems like a hack.


How to implement separate sub-menus?

I want to implement two menus that work like this:                 Cars      *Animals   <-selected       Recipes     --       Bear      *Dog   <-selected       Cat      So the top menu in the main menu, the the menu below is the sub-menu. Not all main menu items have sub-menus. Is there an elegant way to implement this? Preferably, selecting the top menu item would select the first sub-menu. wordpress version 3.03


How to give a CPT (custom post type) a date based url

I have events that have an event-date custom field. I want to create a date based page to display all events for a given day, and my hope was to use the url to help with that. I have a 7 day calendar working, and it shows a "featured" event for a given day. Then I want to link to a page that shows all the events for that day. Not sure if this is at all possible but I figured the geniuses in this Stack would know.


Show recent posts in menu?

I'm building a menu which contains categories. Is there a way to make each menu option show a list of recent posts in that category when you hover over it?


What happened to my Inactive Widgets?

I have purchased the DynamiX theme, and I'm trying to use it for the first time. I was looking at the widgets, and I saw some neat customized (Dynamic maybe?) widgets in the Inactive Widgets section. I was going to drag one to my Sidebar, but accidentally dropped it, and now it is gone. Is there any way to retrieve those? I don't even know exactly what it was, I just know that it was part of my theme. I'm pretty new to Wordpress, so please bear with me. Thanks in advance!


Filter search by terms

I want to implement advanced search by filters. The user should have the option to select some "tags" or "terms" or "category" and then all the posts containing those tags to be displayed. Expected results as: side bar widget that user should have to select category, subcategory,and child of subcategory with prices,locations and then all the posts containing those tags be displayed.


wordpress custom walker for thumbnails with custom menu

I'm still very novice at PHP so any help is greatly appreciated. Typically I have found the codex to be very helpful but it appears custom walkers may be outside its scope. I'd like to have thumbnails show in a custom nav menu which I have in a theme. From what I understand I need to create a custom walker to accomplish this. I've placed this               wp_nav_menu( array( 'container_class' => 'menu-stamp', 'theme_location' =>'stamp-menu' , 'walker' => new Thumbnail_Walker) );       in my theme menu location and inserted the 3 thumbnail lines below the item output section below               /*      * Create HTML list of nav menu items.      * Replacement for the native Walker, using the description.      *      * @see    http://wordpress.stackexchange.com/q/14037/      * @author toscho, http://toscho.de      */     class Thumbnail_Walker extends Walker_Nav_Menu     {     /**      * Start the element output.      *      * @param  string $output Passed by reference. Used to append additional content.      * @param  object $item   Menu item data object.      * @param  int $depth     Depth of menu item. May be used for padding.      * @param  array $args    Additional strings.      * @return void      */      function start_el(&$output, $item, $depth, $args)      {         $classes     = empty ( $item->classes ) ? array () : (array) $item->classes;              $class_names = join(             ' '         ,   apply_filters(                 'nav_menu_css_class'             ,   array_filter( $classes ), $item             )         );              ! empty ( $class_names )             and $class_names = ' class="'. esc_attr( $class_names ) . '"';              $output .= "
ID' $class_names>";              $attributes  = '';              ! empty( $item->attr_title )             and $attributes .= ' title="'  . esc_attr( $item->attr_title ) .'"';         ! empty( $item->target )             and $attributes .= ' target="' . esc_attr( $item->target     ) .'"';         ! empty( $item->xfn )             and $attributes .= ' rel="'    . esc_attr( $item->xfn        ) .'"';         ! empty( $item->url )             and $attributes .= ' href="'   . esc_attr( $item->url        ) .'"';              // insert thumbnail         // you may change this         $thumbnail = '';         if( $id = has_post_thumbnail( (int)$item->object_id ) ) {             $thumbnail = get_the_post_thumbnail( $id );         }              $title = apply_filters( 'the_title', $item->title, $item->ID );              $item_output = $args->before             . ""             . $args->link_before             . $title             . ' '             . $args->link_after             . $thumbnail             . $args->after;              // Since $output is called by reference we don't need to return anything.         $output .= apply_filters(             'walker_nav_menu_start_el'         ,   $item_output         ,   $item         ,   $depth         ,   $args         );        }     }      I get an error for unexpected } at the end of the thumbnail code so its wrong but I'm not sure why.


archive as a page, so that it can be added in the wp_menu_nav

`http://localhost/lyrics/don't-turn-me-away/` is a custom post type. my question is how to display `http://localhost/lyrics/` as a page and not an archive? my goal really is just for it be added to `wp_nav_menu`. I have created a page named `lyrics` but it won't direct me there. Instead it brings me to `archive.php`. With that, the `lyrics` in menu, don't have the `current-menu-item` class.


Remove duplicated values from meta box values

I use the code to get all the meta boxes values in a custom type               <?php     $args = array('post_type' => 'posttype');     $emptyvalue = "";     $optionname = "optionname";     $the_query = new WP_Query($args);          $output ="<select name='".$optionname."'> <option value='".$emptyvalue."'>Location</option>'";          while ( $the_query->have_posts() ) : $the_query->next_post();              $id= $the_query->post->ID;              $location = get_post_meta($id, 'institution_location', true);              $get_location = $_GET['institution-location'];              $selected = ($get_location == $location) ? 'selected=selected' : '';              $output .="<option $selected name='".$location."' value='".$location."'>".$location."</option>";          endwhile;     $output .="</select>";          echo $output;          ?>      But if there are two custom post have the same values it returns the two values, so I want to just return one value of them. Thanks


How to remove comment link title attribute?

When I hover over any post's comment link, I see the title: "Comment on Post Title". How can I remove it? I could not find this text in the theme. Edit: Here's the source which generates the comments link:               <?php comments_popup_link( __('0', 'domain'), __( '1', 'domain'), __('%', 'domain')); ?>


Get posts based on meta key/value

I have a custom post type "custom_author" which is selected when making a new post using a metabox dropdown with field key "chosen_author". This is what my wp_postmeta looks like: ![enter image description here](http://i.stack.imgur.com/ImnXv.png) Where 13088 is the blog post that has "author" 13112 assigned to it. I am trying to get all posts by a particular author using the following:               $args = array(             'post_type'     => 'post',             'post_status'   => 'publish',             'meta_query' => array(                 array(                     'key' => 'chosen_author',                     'value' => '13112' (tried with and without quotes)                 )             )         );              $getPosts = new WP_Query($args);      But it just returns ALL my posts. I did some debugging:               $getPosts = new WP_Query($args);     echo $GLOBALS['wp_query']->request;      and that output               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (wp_posts.post_author != 0) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 10      Completely ignoring the meta_query array! If it matters this being used outside the loop


How to test custom rewrite rules /permalinks?

After much research, I think I can wrap my brain around WP's rewrite system. I would like to know, though, how to properly test rewrite rules to see if the right rule/tags is being used and the right query vars are being passed. Is there a way to create a temporary template that supersedes everything in a theme whose sole purpose is to spit out current query_vars?


update_option in javascript

So there's function in wordpress to update a named option/value pair to the options database table: `<?php update_option( $option, $new_value ); ?>`. And what I'm trying to do implement this function in javascript so when you hit the bottom of the page an option would update. I am using this script to check when you hit bottom of the page:               $(window).scroll(function () {        if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {           /***update options***/        }     });      So my question is how to implement update_option function into javascript.


Form to post new post with custom taxonomies

![enter image description here](http://i.stack.imgur.com/EAeWl.png) I have displayed the custom taxonomies in the drop down as you see in the red box i want to ask that how can i submit them with the post .I can't figure it out.`               // Do some minor form validation to make sure there is content     if (isset ($_POST['title'])) {         $title =  $_POST['title'];     } else {         echo 'Please enter the wine name';     }          // ADD THE FORM INPUT TO $new_post ARRAY     $new_post = array(     'post_title'    =>  $title,     'tax_input' => array(         'industries' =>  $_REQUEST['taxonomy_id'] ),     'post_status'   =>  'publish',           // Choose: publish, preview, future, draft, etc.     'post_type' =>  'websites'  //'post',page' or use a custom post type if you want to     );          //SAVE THE POST     $pid = wp_insert_post($new_post);          //SET OUR TAGS UP PROPERLY          //REDIRECT TO THE NEW POST ON SAVE     $link = get_permalink( $pid );     wp_redirect( $link );          } // END THE IF STATEMENT THAT STARTED THE WHOLE FORM          //POST THE POST YO     do_action('wp_insert_post', 'wp_insert_post');?>`          the form          enter code here


Custom Capability - show plugin menu to these users and admins only

I have created a plugin which has custom menu pages. The plugin creates two roles upon activation (let's say role 1 and role 2). role 1 is used for some coding and works fine, WordPress users are assigned this role and the code works correctly. Where I am struggling is that I would the plugin menu's to only be displayed to Administrators and users who have role 2 assigned to them. I am running the following from a function called by my activation hook...               add_role( 'role 1', 'Role 1', array( 'read' => true, 'level_0' => true ) );     add_role( 'role 2', 'role 2', array( 'read' => true, 'level_0' => true ) );     add_action( 'admin_init', 'f_mdjm_caps');      the function f_mdjm_caps contains the following               function f_mdjm_caps()  { /* Capabilities */     $role = get_role( 'role 2' );     $role->add_cap( 'manage_myplugin' );     }      I tried adjusting my menu code to be               add_menu_page( 'My Menu', 'My Menu', 'manage_myplugin', 'mdjm-dashboard',  f_mdjm_admin_dashboard' );      but the menu disappears. Any help appreciated Thanks


user contributed content as custom post types

We are looking into creating a solution that allows user to contribute media files by filling out a form (without access to the admin) and have it ןד created as a custom post type. The files will be either YouTube Movies, PowerPoint Files etc. Is that possible at all? Do you know any example of something similar?


Truncate Widget Title

I'm using a function: `function widget_new_title($title) { echo word_limiter($title,20); } add_filter('widget_title','widget_new_title');` to limit the characters for widget title but my problem is that if I do this, the title is not wrapped in before_title and after_title as well as before_widget and after_widget. Any help? Thanks, Cip


Creating entries with image attachements within posts and managing them in a list

I need help with choosing a suitable meta box or other means for listing, adding and sorting entries, relevant to the containing post. For each entry it should be possible to attach a set of images, for example by using an WP "Add Media" button. The images should be attached to the entries and not to the containing post. It should also be possible to edit and delete entries. I've thought of having these entries as regular posts of some type/category and I think that could work, but they're actually only relevant to the containing post and my thinking is that it could be sensible to avoid it. What do you think? So, in other words I have two problems:   1. How to create a kind of "mini post" with image attachments.   2. How to create an interface to manage them inside the containing post admin page. Does anyone have suggestions on how this could be approached or on any plugin that could be useful for this?


Any harm in pointing my dev Wordpress installation to my production database?

I have a dev instance of a public website that I maintain, and while they are very similar, there are differences between the site structure of the development instance and the production website. They are both using the custom theme we developed for the site, and when we update production from dev, that's all we update, not any of the rest of the Wordpress install. My question is, can I point my dev Wordpress instance to our production database? The dev instance would presumably be missing some files from some of the plugins that the production instance has, but really all I'm trying to do here is get it working well enough to view and debug any html/css changes to the theme. Is this just a dodgy approach? My ultimate reason for doing this is I want to be able to have the dev instance use Git and have it work on multiple machines, which doesn't play so well when you're using a local database. Any help would be most appreciated.


Self-Hosted Blog on Google Search

I have a self-hosted blog, (Code Repo - Code Snippets) but for some reason when I search for it on google, it doesn't come up in the results. I posted an entry about 4 days ago, and by now I would have expected it come up in the results. When I search for things on my normal site (same domain), they do come up, its just things inside the blog that don't seem to be included. In the past, I have only had blogs hosted on wordpress.com and they have always automatically come up. What can I do to fix this? Thank you!


Need advice on theme customizer and child themes

I have been working on a theme, initially it only had one design and I made almost all of the front page elements customizable through the theme customizer. Now I would like to offer a few variations of my theme and I am not sure what I should do. The way I setup my theme is that is that when my theme is installed it looks like the demo, since I made the default values of the theme settings match the design. So the defaults are all setup for the one style. Now since I want to offer a few variations of my theme it makes sense to use child themes that the users can switch to. Although I have no idea how that would work, since most of the elements get there values from the theme settings and not the CSS file so they can be easily customized. Would I not be able to use child themes? Would it make more sense for me to add a setting for which style is chosen and have my customizer choose different default values depending on that setting? (Have three sets of defaults values in a function, and use logic to choose which defaults are used depending on theme chosen?) I want to be able to have a demo bar to show the theme variations. So would it be possible to have a child theme that overrides the customizer aswell? So I could switch to a child theme easily in the demo bar? Any advice would be appreciated.


Trouble using antispambot()

I have a custom field in a theme that contains an email address and was pleased to find `antispambot()`
<a href="mailto:<?php antispambot(the_field('queries_e-mail')); ?>"> <?php echo antispambot(the_field('queries_e-mail'));?>
      It looks fine and works as intended (ie. it opens a compose mail window) but when I view the code source it doesn't appear to be encoded.
 john.doe@mysite.com
      According to the Codex the default usage is :               <?php echo antispambot("john.doe@mysite.com"); ?>      which should output:               john.doe@mysite.com      However the encoding doesn't appear to be working in my case.


Modify main WordPress loop with a parse_query filter

I am trying to modify the main WordPress loop on my category pages like so:               add_filter('parse_query', 'my_modified_query');          function my_modified_query( $q ) {            if (!is_admin() && is_category()) {                   $q->set( 'orderby', 'meta_value' );                   $q->set( 'meta_key', 'my_key' );            }                 return $q;     }      but it does not seem to work. However modifying anything else like :                $q->set( 'order','title' );      $q->set( 'orderby', 'DESC');      works perfectly. Just not               $q->set( 'orderby', 'meta_value' );     $q->set( 'meta_key', 'my_key' );      any idea why that is?


How do I get the parent category if I know the child category?

So Ive got this function here that creates a drop-down menu from only the child categories, it works great. The problem is that I need to get the parent categories name and assign it as the value of the option class for the child category menus. I can't seem to get it to work, all I get is either '/' or '/child_Category_name/' Thanks!               function child_dropdown($dropID, $taxonomy, $exclude) {          $args = array(     'orderby'                  => 'name',     'order'                    => 'ASC',     'hide_empty'               => 0,     'hierarchical'             => 1,     'exclude'                  => $exclude,     'taxonomy'                 => $taxonomy,     'pad_counts'               => false );                         $categories = get_categories( $args );          $menu = '<select name="'.$dropID.'" id="'.$dropID.'" class="postform">';     $menu .='<option value="">--</option>';          foreach($categories as $category)     {         if($category->parent != 0 ) {                  $menu .= '<option class="'.get_category_parents().'" value="'.$category->name.'">'.$category->name.'</option>';         }     }        $menu .= '</select>';     echo $menu;      }


Putting the title attribute in image tag — Snapshot Theme from Woothemes

Does anybody know, how to insert the title used in the field "screenshot" and "large-image", in Snapshot Theme from Woothemes? I´ve tried using 'the_title();', but I get the post title, not what I wrote in the "Title" field, in the additional fields "Snapshot Custom Settings". Does anyone have used yet this theme? Does anyone know how to get that title? The Theme website: http://www.woothemes.com/products/snapshot/ My Customization: http://kevingstongramado.p.ht/catalogo/ Thanks.


Page will only display first 6 videos

I'm creating a page in WordPress using a custom theme. I have a page that I need to put 8 (maybe more) videos on. With 6 video players on the page it loads in less than a second, but as soon as I put any more videos on, it just loads the first 6 videos then the page continues to load for ages. In the bottom left corner of Chrome it says "Processing Request". I don't understand why 1 or 2 more videos would prevent the page from loading properly. This page contains videos that will introduce you to the different IT & business systems that we use in the company. This includes Google Apps, Dropbox, WorkflowMax, Skype and TeamGantt.

Gmail
     [video mp4="http://intranet.yourgroupuk.com/wp-content/uploads/2014/08/Using-Gmail.mp4"][/video]

Google Calendar
     [video mp4="http://intranet.yourgroupuk.com/wp-content/uploads/2014/08/Google-Calendar.mp4"][/video]

Dropbox
     [video mp4="http://intranet.yourgroupuk.com/wp-content/uploads/2014/08/Using-Dropbox.mp4"][/video]

Team Gantt
     [video mp4="http://intranet.yourgroupuk.com/wp-content/uploads/2014/08/Team-Gantt.mp4"][/video]

Skype
     [video mp4="http://intranet.yourgroupuk.com/wp-content/uploads/2014/08/Using-Skype.mp4"][/video]

WorkflowMax Introduction
     [video mp4="http://intranet.yourgroupuk.com/wp-content/uploads/2014/08/WFM-Introduction.mp4"][/video]

WorkflowMax - Purchase Orders
     [video mp4="http://intranet.yourgroupuk.com/wp-content/uploads/2014/08/WFM-Purchase-Orders.mp4"][/video]

WorkflowMax - Timesheets and logging time
     [video mp4="http://intranet.yourgroupuk.com/wp-content/uploads/2014/08/WFM-Time-Sheets.mp4"][/video]


Update post status from "publish" to "trash" for half of posts

I want to update half of all posts with status from `published` to `trashed`. Example:   * if I have 10000 posts, 5000 post to trash   * If I have 6000 posts, 3000 posts to trash   * If I have 7000 posts, 3500 posts to trash


Modify image while uploading

I have a plugin which uploads image using `wp_upload_handler` here is a function:               //handles upload, a modified version of bp_core_avatar_handle_upload(from bp-core/bp-core-avatars.php)     function handle_upload( ) {         global $bp;              //include core files         require_once( ABSPATH . '/wp-admin/includes/file.php' );             $max_upload_size=$this->get_max_upload_size();             $max_upload_size=$max_upload_size*1024;//convert kb to bytes         $file=$_FILES;                  //I am not changing the domain of erro messages as these are same as bp, so you should have a translation for this             $uploadErrors = array(             0 => __('There is no error, the file uploaded with success', 'buddypress'),             1 => __('Your image was bigger than the maximum allowed file size of: ', 'buddypress') . size_format($max_upload_size),             2 => __('Your image was bigger than the maximum allowed file size of: ', 'buddypress') . size_format($max_upload_size),             3 => __('The uploaded file was only partially uploaded', 'buddypress'),             4 => __('No file was uploaded', 'buddypress'),             6 => __('Missing a temporary folder', 'buddypress')         );              if ( $file['error'] ) {             bp_core_add_message( sprintf( __( 'Your upload failed, please try again. Error was: %s', 'buddypress' ), $uploadErrors[$file['file']['error']] ), 'error' );             return false;         }              if ( ! ($file['file']['size']<$max_upload_size) ) {             bp_core_add_message( sprintf( __( 'The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format($max_upload_size) ), 'error' );             return false;         }              if ( ( !empty( $file['file']['type'] ) && !preg_match('/(jpe?g|gif|png)$/i', $file['file']['type'] ) ) || !preg_match( '/(jpe?g|gif|png)$/i', $file['file']['name'] ) )          {             bp_core_add_message( __( 'Please upload only JPG, GIF or PNG photos.', 'buddypress' ), 'error' );             return false;         }                   $uploaded_file = wp_handle_upload( $file['file'], array( 'action'=> 'bp_upload_profile_bg' ) );              //if file was not uploaded correctly             if ( !empty($uploaded_file['error'] ) ) {             bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $uploaded_file['error'] ), 'error' );             return false;         }                  //assume that the file uploaded succesfully             //delete any previous uploaded image             self::delete_bg_for_user();             //save in usermeta             update_user_meta(bp_loggedin_user_id(),'profile_bg',$uploaded_file['url']);             update_user_meta(bp_loggedin_user_id(),'profile_bg_file_path',$uploaded_file['file']);             update_user_meta(bp_loggedin_user_id(),'profile_bg_pos',0);                  do_action('bppg_background_uploaded',$uploaded_file['url']);//allow to do some other actions when a new background is uploaded         return true;     }      before uploading I want to modify this file. Generally I want to add "blur" effect to image. is it possible with such structure?


wp_delete_post() not working with BBpress replies

I'm trying to auto-delete all BBpress replies of a user when someone's account is banned, but the wp_delete_post is not working with replies. wp_delete_posts() returns a post object if it runs successfully, and it does do this with the reply, but the reply is not deleted from its respective topic!               $args = array (             'numberposts' => -1,             'post_type' => array('topic','reply'),             'author' => $user_id     );     $user_posts = new WP_Query($args);     while ( $user_posts->have_posts() ) : $user_posts->the_post();         wp_delete_post(get_the_ID(), true);         endwhile;


Pull & display new comments without refreshing the page

I've just managed to implement ajax on comment submission and now members don't have to leave the page when they comment but still have to go one extra mile when they want to see new comments. I've looked around the web before asking this question and I didnt find any real info about doing this. Anyone has any ideas or maybe already did it? Right.. I need something like this :                    $numComments = wp_count_comments('comments');           $numComments = $numComments->publish;              // Posts per page         $per_page = 50;              // Determine total amount of pages         $total_comments = ceil($numComments / $per_page);              // Get current page         $paged      = (get_query_var( 'page' )) ? get_query_var( 'page' ) : 1;              // Above your loop         $ignores = array();              // If we have sent ignore ID's         if ( $_GET['ignore] )        {            $get_ignores = trim($_GET['ignore'], ',');            $get_ignores = explode(',', $get_ignores);        }             // If we have ignore ID's         if ( !empty($get_ignores) )         {             foreach ($get_ignores AS $k => $v)             {                 $ignores[] = $v;             }         }              $count = 1;              $my_args = array(             'per_page' => '50'             'paged'  => get_query_var( 'page' ),             'comment__not_in'   => $ignores,             'comment_status'    => 'publish'         );                                                $my_query   = new wp_list_comments($my_args);              if ( $paged <= $total_pages):             $paged = $paged + 1;                       while ( $my_query->have_posts() ): $my_query->the_post();                 // At the start of the loop populate the used post ID's                 $ignores[] = $comments->ID;     ?>     <?php $count++; endwhile; endif; ?>     <?php              if ( $ignores AND is_array($ignores) )         {             // Create a comma separated string of ignore ID's             foreach ( $ignores AS $k => $v ) {                 $ignore_str .= $v.',';             }                  // Trim the ignore string of any rogue commas             $ignore_str = ltrim($ignore_str, ',');             $ignore_str = rtrim($ignore_str, ',');                  $ignore = site_url('page/'.$paged.'/?ignore='.$ignore_str.'');         }          ?>           <a href="#" rel="<?php echo $ignore; ?>" id="load-more">Load New Comments           <?php if ( !$my_query->have_posts() ) : ?>           <?php endif; ?>                   This is just something Im trying to modify to suit my own needs.


Would like to be able to take list of pages, and place them into an array

Well...title says it, but here are the details. I would like to take a list of all of the active wordpress pages on my site, and place them into a list. This list is generated by an array (it uses Options Framework Multi-check-boxes The way that the option code looks when I create it:               $options[] = array(     'name' => __('What Pages to Include?'),     'class' => 'inner_section_header',     'id' => 'select_pages_to_display',     'options' => array('option1' , 'option2' , 'option3'),     'std' => '',     'type' => 'multicheck');      * * *               'options' => array(),       That is where I am attempting to put the list of pages, so that it will generate a list of checkboxes with each active page. I have tried both `get_pages();` and `wp_listpages();` but both have left me pulling my hair out -- Roughly 4 hours of it last night with no luck. Would anyone be able to guide me in the right direction as to how I would solve this? How the attempt went with wp_list_pages() I attempted to store the output of wp_list_pages() in a variable. I thought that the following would do so               $pages_list = wp_list_pages($args);      Unfortunately all this did was output the list of pages at the beginning of my page, even though it or the variable was never echo'd. so I moved onto get_pages() How the attempt went with "get_pages" I attempted to store them in a variable as before, this time with better luck.                   $pages = get_pages($args);          foreach ( $pages as $page ) {             $option = "'";             $option .= $page->post_title;             $option .="' ," ;             $page_list .= $option;              }         $options[] = array(                 'name' => __('What Pages to Include?'),             'class' => 'inner_section_header',             'id' => 'select_pages_to_display',             'options' => array($page_list),             'std' => '',             'type' => 'multicheck');      At this point I thought I almost had it because this outputted a single checkbox with the option: 'Contact' ,'Home' ,'Portfolio' ,'Services' , Was almost there...just need those to be displaying as separate checkboxes instead of one checkbox. After that, I began trying different formatting combinations (using substr to remove that last comma to see if it was a formatting issue...but I got it to the point where it looked exactly as it would if I were to manually type out each option which I thought would have made the array act like the equivalent of this:               'options' => array('Contact', 'Home', 'Portfolio', 'Services'),      but apparently I am missing something. If anyone needs more details, I'll be happy to provide. Thanks in advance * * * ## EDIT: it has been solved (leaving the details above, and posting the answer below, in case it solves someone else's problem in the future) Wordpress.org support forums yielded the solution!               $pages = get_pages();          if ( $pages ) {         $prop = 'post_title';         $pages = wp_list_pluck( $pages, $prop );              $options[] = array(             'name'    => __( 'What Pages to Include?' ),             'class'   => 'inner_section_header',             'id'      => 'select_pages_to_display',             'options' => $pages,             'std'     => '',             'type'    => 'multicheck' );     }     If you need the post slugs use:     $prop = 'post_name';     Post IDs:     $prop = 'ID';      Tested it out, and it worked perfectly. **Credit goes to Mod keesiemeijer** @Wordpress.org


Is the '/category/post-name-date/' permalink structure okay?

> **Wordpress Codex says:** Make sure to end your structure with either > `%post_id%` or `%postname%` (e.g. `/%year%/%monthnum%/%day%/%postname%/`) so > that each permalink points to an individual post. But I would like to set my website's permalink structure (to suite the Google News URL guidelines) like this: `/%category%/%postname%-%year%%monthnum%%day%/` So, an example URL would look like this:   _http://example.com/internet/hello-world-20120322/_ But this permalink structure appears to be against the quote from WP codex. Do you see any problems with my custom permalink structure? Please advise.


Rewrite-Rules not working on a vhost, everything goes to index.php

after setting up the wordpress htaccess rules in my vhost, i was unable to enter the wp-admin area. I was always redirected to the frontpage of my wordpress instance. The rewriting itself worked on the mainpage. All links worked so far, but the admin area remains without any access. Rewrite rules used:               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]      Personally i dont know where to start looking, im even unable to find that problem over google, which is kinda rare - maybe someone over here knows where the problem is to be located.


How to get current menu item "CSS Classes" value?

While on any given link that has a CSS Classes value, I'd like to do something like this:               $css_classes = get_current_menu_item_css_classes();         if ( $css_classes == 'mycustomclass' ) : // do something      Thanks ![enter image description here](http://i.stack.imgur.com/D45LE.png)


Drop Down menu expanded by default (on front page)

For this site users seem to have difficulty finding the site's content that is accessible through the 'Data' drop down menu on the top left. To improve this I would like to have this drop down menu expanded by default – but only on the front page. By this older (not WordPress related) StackExchange question (that is including a JSFiddle) and some other comments I have learned that I should use jQuery. I tried my best but I have not been able to get it working at all on my site. What are the CSS elements on my site that I have to address in the JQuery code? And where should I put this code? Would somebody be able to help me? **Edit:** Thank you very much user49916! This works! The problem that I encountered was that the second level children were also expanded by default. To hide them and then only show them on hover I added this:               /*Make the drop down menu expanded by default – on the front page*/         .home ul#menu-all-descendants-as-submenus li ul {             left: 0;         }              /*Make the drop down menu expanded by default and hide the sub-children – on the front page*/             .home ul#menu-all-descendants-as-submenus.menu li ul ul {                 left: -999em;             }         /*Make the drop down menu expanded by default and show the sub-children on hover of menu – on the front page*/                  .home ul#menu-all-descendants-as-submenus.menu li ul li:hover>ul {                 left: 0;             }


Using global $post; to get featured image for custom post via WP_Query

I'm using a site-wide function to add css to the `<head>` of the page pull in featured images of various as a responsive page background. It works great across the rest of my site but fails on a page where I'm calling posts from a custom post type using `WP_Query`. I think this is because `WP_Query` doesn't use the standard loop, and my function uses `global $post;`. Is there a way to adapt the `WP_Query` loop to work with the function? I need the featured image function to also work on the rest of my site, which uses the standard WP loop. \-- Here's how I'm calling the custom posts:               <?php $port_query = new WP_Query( array(         'post_type' => 'portfolio',         'posts_per_page' => 1,         'orderby' => 'rand'     ) );      if ( $port_query->have_posts() ): while ( $port_query->have_posts() ) : $port_query->the_post(); ?>         <div class="page-bkg responsive-bkg">             // page content here         </div>     <?php endwhile; wp_reset_postdata(); endif;      And the function to call responsive featured images, from functions.php:               function bkg_featured_image() {          // call the global post variable     global $post;          if ( has_post_thumbnail( $post->ID ) ) : // checks whether the post has the featured image set          // get the post thumbnail ID for the page or post     $post_thumbnail_id = get_post_thumbnail_id( $post->ID );          // store the image sizes in an array. You can also add your own image sizes with the add_image_size function     $img_sizes = array( 'thumbnail', 'medium', 'large', 'full', 'thumb480', 'thumb768', 'thumb1280', 'thumb1680', 'thumb2048' );          // grab the URL for each image size and store in a variable     foreach ( $img_sizes as $img_size ) {         ${ 'img_src_' . $img_size } = wp_get_attachment_image_src( $post_thumbnail_id, $img_size );     }          echo '<style type="text/css">               .responsive-bkg {             background-image: url(' . esc_url( $img_src_thumb768[0] ) . ');         }              @media screen and ( min-width: 768px ) {             .responsive-bkg {                 background-image: url(' . esc_url( $img_src_thumb1280[0] ) . ');             }         }              @media screen and ( min-width: 1281px ) {             .responsive-bkg {                 background-image: url(' . esc_url( $img_src_thumb2048[0] ) . ');             }         }          </style>';             endif; // end if the featured image is set          } // end function my_featured_image          add_action( 'wp_head', 'bkg_featured_image' );          // (this function borrowed from http://s2webpress.com/responsive-featured-image-function-in-wordpress-themes/)


Remove WPML's home_url filter

The WPML plugin filter's `home_url` in order to provide a link to the home page specific to the language you are viewing. (So if you are reading a Spanish page home_url() will point you to `http://example.com/es`). I need to disable for a site that will not have language-specific homepages. So I went digging into the WPML plugin, which is essentially launched in a typical way:               global $sitepress;     $sitepress = new SitePress();      Then in the class's constructor the offending filter is added:               add_filter( 'home_url', array( $this, 'home_url' ), 1, 4 );      With the class's callback method being (for reference):               // filter for WP home_url function     function home_url( $url, $path, $orig_scheme, $blog_id )     {         // exception for get_page_num_link and language_negotiation_type = 3         if ( $this->settings[ 'language_negotiation_type' ] == 3 ) {             $debug_backtrace = debug_backtrace();             if ( !empty( $debug_backtrace[ 6 ] ) && $debug_backtrace[ 6 ][ 'function' ] == 'get_pagenum_link' )                 return $url;         }              remove_filter( 'home_url', array( $this, 'home_url' ), 1 );         // only apply this for home url - not for posts or page permalinks since this filter is called there too         if ( ( did_action( 'template_redirect' ) && rtrim( $url, '/' ) == rtrim( get_home_url(), '/' ) ) || $path == '/' ) {             $url = $this->convert_url( $url );         }         add_filter( 'home_url', array( $this, 'home_url' ), 1, 4 );              return $url;     }      This seems like it should be a straight-forward case of `remove_filter`. However adding the following to functions.php (admittedly it should maybe be in a site-specific plugin) does not seem to remove the filter and the main logo (which uses the `home_url()` function is still pointing to the language- specific homepage).               function rar_remove_wpml_home_filter(){         global $sitepress;         remove_filter( 'home_url', array( $sitepress, 'home_url' ), 1, 4 );     }     add_action( 'plugins_loaded', 'rar_remove_wpml_home_filter' );      I've also tried running this on the `init` hook. It seems I must me missing something obvious.


Ajax returning correct data BUT at wrong place

I'm trying how to figure out how to use AJAX correctly with Wordpress: (I've used it on other sites, but not in WP) I have this code in functions.php of a theme:               function jquery_stuff() {         wp_enqueue_script('jquery');         wp_enqueue_script('scriptname', get_bloginfo('template_url') . '/wibergsweb.js');     }     add_action( 'init', 'jquery_stuff');          //AJAX     add_action('wp_ajax_locationContent', 'locationContent');          function locationContent() {         echo 'batman returns';         die();     }      and this is what the jQuery looks like:               function loadLocationInfo(clickedOn) {                var locationId = clickedOn.next().attr('id');                       var locationContent = $.ajax({                             type: 'POST',                 data:{                     action: 'locationContent',                     location_id: locationId                 },                 url: "/wp-admin/admin-ajax.php",                 dataType: 'json'             });                  locationContent.done(function(data) {                   alert('DONE');                 });                                          locationContent.fail(function(ts) {                            alert('ERROR');                 clickedOn.next('.location-info').html(ts.responseText);                 $('body').css('cursor', 'pointer');                 clickedOn.css('cursor', 'pointer');            });         }               $(document).on('click', 'h3', function(e) {             var tClicked = $(this);             loadLocationInfo(tClicked);         });      Why is the actual response returned in the `fail`-function? (Yes, the data is correctly returned. That's the weird part of it). This is what happens:               1. ERROR is shown in alert-dialog.      2. The .location-info div is set to 'batman returns'      If I don't have die() in the php like this:               function locationContent() {         echo 'batman returns';         }      Then a **0** is returned **BUT** that 0 is returned in the `done()`-function (incorrect data returned at expected place) Why is the actual response returned in the **fail-function** and how do I solve this issue? (I can't figure out what's going on here)


Query custom post type only if it contains another custom post type

I currently have a custom post type named "blog". On registration, every user gets automatically a post "blog" linked with their user ID. This custom post type queries another post type named "articles". Those articles are written by the user and then showed in their "blog" custom post type. Now, I would like to show a list of X most recent "blog" custom post type but only if they have at least one "article" in it but I can not find any way to do it... Thank you in advance for your help and have a good day.


Adding capabilities to super admins

I'm developing a plugin that uses custom capabilities. Some of those capabilities need to be added to all users who are super admins. Currently, I'm using this code:               $supers = get_super_admins();     foreach ( $supers as $admin ) {         $user = new WP_User( 0, $admin );         $user->add_cap( 'my_cap' );         $user->add_cap( 'my_second_cap' );     }      However, I'm concerned that this code is just adding the capabilities to the individual users, as opposed to the role as I usually would. If a new super admin is created, they will not have these capabilities as this function only runs on plugin activation. Is there a better way of adding custom capabilities to super admins?


Order posts by month - in custom taxonomy template

I'm trying to show all posts posted under the month, so 2012 ## December post 1   post 2 ## November post 1   post 2 The posts are to appear under my custom taxonomy template, so taxonomy- pubyear.php and I'm able to retrive all the posts for that term using the basic loop. If I add get_the_year('F') in the loop then the same month will be displayed repeatedly but I need it displayed once and have all the corresponding posts show up under it, any help with this would be appreciated. Note: If I have post published under the same day, month and year then the above get_the_year('F') will show the month and display those posts below it, i want that functionality but without having to use the same published date.


How do I get the comments section to show up?

My theme does not seem to be showing me the comments section, this is the PHP code I have in my `index.php` file inside the template folder                    <?php get_header(); ?>          <?php get_footer(); ?>     <?php get_sidebar(); ?>     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                             <?php if ( in_category('3') ) { ?>
      <?php } else { ?>
      <?php } ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
                 <?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?>
        <?php the_content(); ?>

Posted in <?php the_category(', '); ?>

                  <?php endwhile; else: ?>
Sorry, no posts matched your criteria.
                 <?php endif; ?>


How can I store an image in the database with Transients API?

I'm trying to store an image generated with `imagecreatefrompng()` using the Transients API, but it just stores an empty string (`string(0) ""`). Also, I notice if I set the transient before `imagedestroy( $im )`, the image is broken and doesn't display at all (broken image thumbnail). What _can_ I store in the database with the Transients API? How would I store an image like described above?


Get URL of a specific file

I have a file that can either be included in a plugin, or in a theme. What's the best way to get the URL of the file's folder (from within the file)? Edit: I'm now using this for now               home_url( '/' . str_replace( ABSPATH, "", dirname( __FILE__ ) ) );      Let me know if there's any problem with this / there's a better way.


Prevent access to single post types

Say that I want to make a post type called 'press' and it is mostly concerned with linking a title with a PDF document of a press clipping. I want to show all of these as an archive... so something like site.com/press but i don't want any single post template pages. so no site.com/press/article1 or site.com/press/article2. other than not including a link in my archive template (which just obscures it but doesn't negate their existence or prevent access to the single posts) how can i prevent a visitor from inadvertently accessing the single posts. how could i re-direct them back to the /press archive?


3 Level Deep Navigation Menu Not Showing All Levels

I have a 3 level deep navigation menu which will show beside all pages on the site except the homepage. The issue is only 2 of my 3 levels are showing in the menu when displaying it using the wp_nav_menu. I've tried specifying the depth parameter and without it to no avail. I am using the Roots theme if that helps. See below for an image as to how the menu is in the Appearance > Menus section. ![enter image description here](http://i.stack.imgur.com/Nd16D.png) The problem as can be seen from above is that "Production Solutions" and "Avalanche" are showing, but the children items underneath Avalanche aren't showing. And it's not a styling thing either the 3rd levels just aren't being output at all. I'm not using any custom walkers or anything either, this is via stock register and display nav menu functions. **This is the code that registers all of my nav menus:**               register_nav_menus(array(         'accordion_navigation' => __('Page Accordion Navigation', 'roots'),         'footer_navigation_left' => __('Footer Navigation Left', 'roots'),         'footer_navigation_solutions' => __('Footer Product Solutions', 'roots'),         'footer_navigation_news' => __('Footer News & Events', 'roots'),         'footer_navigation_about' => __('Footer About', 'roots')     ));      **In my page template I have this code for displaying the menu:**               wp_nav_menu(array('theme_location' => 'accordion_navigation'));      Am I missing something here?


Display posts differently depending on which author wrote it

I've got a multi-author site running on Wordpress 3.1.3 . I'm trying to place an extra header above the title for a specific author. So if "John" posts on the blog, it would have an above the post on the home page that says "John's Perpective", or something of that nature. The idea is that we want one of the many author's posts to be highlighted for users. My issue is that I cannot figure out how to check for which user wrote the post within the loop. I am doing it on various other areas of the site via WP_Query. I'm imagining I need something like this (pseudo code):               if ( author == 2 ) {         echo '
John's Perspective
'     }      Should be an easy fix, but I'm stumped. Thanks in advance!


How to substitute old wordpress menu by wp 3 menu the right way?

I have a wp theme with this menu in header:

<a href="<?php echo get_option('home'); ?>/" class="on">Home
                  <?php wp_list_pages('title_li='); ?>

      I followed the tut here http://www.wpbeginner.com/wp-themes/how-to-add-custom- navigation-menus-in-wordpress-3-0-themes/ and replace it with               <?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-header' ) ); ?>      but it doesn't style at all like previously. So is it really the right way ?


Changes to permalink structure results in 404 error for all pages other than home

When changing the permalink structure on my site, I get a 404 error for every page except the home page. I've see other questions that mention resetting the permalink structure to get it work, but this doesn't work for me (using the default of ?p=123 does show the posts, but changing back to month and name 2012/03/sample-post/ causes the 404). With the permalink structure set to month and name, the htaccess file is:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /wordpress/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /wordpress/index.php [L]     </IfModule>          # END WordPress      The htaccess file that wordpress updates is in the /etc/wordpress directory and the details are:               -rw-r--r-- 1 www-data root      934 2012-03-10 19:13 htaccess      The index.php file is in the /var/www directory:               <?php     /**      * Front to the WordPress application. This file doesn't do anything, but loads      * wp-blog-header.php which does and tells WordPress to load the theme.      *      * @package WordPress      */          /**      * Tells WordPress to load the WordPress theme and output it.      *      * @var bool      */     define('WP_USE_THEMES', true);          /** Loads the WordPress Environment and Template */     require('./wordpress/wp-blog-header.php');     ?>      Are there other changes I need to make to allow for a change to the permalinks? **Update** This is running on a Linux box I have root access to. I did enable mod_rewrite, but get the same results - the default permalinks work, but changing the structure doesn't. I also have /wordpress in each URL, like wordpress/?page_id=31 and updating the URL in the Wordpress settings doesn't help. That most likely is a separate issue - I'll ask separately, but wanted to provide the info in case it's relevant.


reusing code in function and running it with loop

In variable.php , the page use to display any attributes related to a product. I want some changes in code but not for all pages, so i think only point it to create a function of variable.php, and call it within custom loop. My question is how do i make a function out of variable.php, put all variable.php in               function{      code from [variable][1].php     }      After making a function, how do i insert it in a loop, so it prints with every product?                   $args = array(         'post_type' => 'product',         'posts_per_page' => 4,     );     $featured_query = new WP_Query($args);          if ($featured_query->have_posts()) {         while ($featured_query->have_posts()) {             $featured_query->the_post();             ?>

<?php the_title(); ?>

<a href="<?php echo get_permalink(); ?>"><?php echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail'); ?>

                  <?php              }         wp_resetpostdata();     }


set_post_thumbnail_size not cropping featured images, but reducing proportionally

In my function file, I set the following:               if ( function_exists( 'add_theme_support' ) ) {         add_theme_support( 'post-thumbnails' );         set_post_thumbnail_size( 150, 50, true );        }      And in the loop:               <?php the_post_thumbnail();  ?>      But the images are resized proportionally, using the smallest value. The crop is not working. **UPDATE** I change the function:               function resize_thumb () {        add_theme_support( 'post-thumbnails' );        set_post_thumbnail_size( 280, 80, true );     }          add_action ( 'after_setup_theme', 'resize_thumb' );      But the desire crop not happens. **SOLVED** In functions.php, I add just this line:               add_image_size( 'thumbnail-news', '190', '40', true );      And in the loop I add this line               <?php the_post_thumbnail( 'thumbnail-news' ); ?>      To resize old images, I use Regenerate Thumbnails plugin. Note: I'm using roots theme.


Wordpress white screen with word 'error'

I am getting a white screen that just says 'error' on it. I have removed all plugins, re-installed the theme and also re-installed wordpress. The website will work fine when going to the homepage, but as soon as I click on another page or category it returns this white screen. Has anyone else seen this?


I can't access wordpress functions from an ajax php call

I've seen a few questions similar to this but I can't find a solution to the issue I have.               <?php     add_action('wp_ajax_nopriv_LogHit_callback', 'LogHit_callback');     add_action('wp_ajax_LogHit_callback', 'LogHit_callback');     function HitCount() {       ?>       <script type="text/javascript" >       jQuery(document).ready(function($) {         var data = {             action: 'LogHit_callback',             PostId:'<?php echo get_the_ID() ?>'         };              jQuery.post('http://www.test.com/wp-admin/admin-ajax.php', data);      });      </script>     <?php          function LogHit_callback() {       global $wpdb; // this is how you get access to the database            $postId = $_POST['PostId'];       $hits = get_post_meta((int)$postId, 'hit-counter', true);       $hits = $hits + 1;       update_post_meta((int)$postId, 'hit-counter', (int)$hits);       exit; // this is required to return a proper result     }      When I call the HitCount function in my page it renders the following               <script type="text/javascript" >      jQuery(document).ready(function($) {     var data = {         action: 'LogHit_callback',         PostId:'86476'     };     jQuery.post('http://www.test.com/wp-admin/admin-ajax.php', data);       });     </script>      The direct link to the admin-ajax.php file works in a browser but the callback function is never called?


Posts are being redirected to xampp home page

I have a wordpress site, I downloaded it from live and configured it on local using xampp. When i click on any post, it redirects me to `localhost/xampp` instead of post page my .htaccess is like               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     # BEGIN W3TC Browser Cache     <IfModule mod_deflate.c>     <IfModule mod_setenvif.c>     BrowserMatch ^Mozilla/4 gzip-only-text/html     BrowserMatch ^Mozilla/4\.0[678] no-gzip     BrowserMatch \bMSIE !no-gzip !gzip-only-text/html     BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html     </IfModule>     <IfModule mod_headers.c>     Header append Vary User-Agent env=!dont-vary     </IfModule>     <IfModule mod_filter.c>     AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon     </IfModule>     </IfModule>     <FilesMatch "\.(css|js|htc|CSS|JS|HTC)$">     FileETag None     <IfModule mod_headers.c>     Header set X-Powered-By "W3 Total Cache/0.9.2.4"     </IfModule>     </FilesMatch>     <FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">     FileETag None     <IfModule mod_headers.c>     Header set X-Powered-By "W3 Total Cache/0.9.2.4"     </IfModule>     </FilesMatch>     <FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">     FileETag None     <IfModule mod_headers.c>     Header set X-Powered-By "W3 Total Cache/0.9.2.4"     </IfModule>     </FilesMatch>     # END W3TC Browser Cache     # BEGIN W3TC Page Cache core     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^(.*\/)?w3tc_rewrite_test$ $1?w3tc_rewrite_test=1 [L]     RewriteCond %{HTTP:Accept-Encoding} gzip     RewriteRule .* - [E=W3TC_ENC:_gzip]     RewriteCond %{REQUEST_METHOD} !=POST     RewriteCond %{QUERY_STRING} =""     RewriteCond %{HTTP_HOST} =highimpactdataindex.com     RewriteCond %{REQUEST_URI} \/$ [OR]     RewriteCond %{REQUEST_URI} (sitemap(_index)?\.xml(\.gz)?|[a-z0-9_\-]+-sitemap([0-9]+)?\.xml(\.gz)?) [NC]     RewriteCond %{REQUEST_URI} !(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|\/feed\/|wp-.*\.php|index\.php) [NC,OR]     RewriteCond %{REQUEST_URI} (wp\-comments\-popup\.php|wp\-links\-opml\.php|wp\-locations\.php) [NC]     RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|wordpress_\[a\-f0\-9\]\+|wordpress_logged_in) [NC]     RewriteCond %{HTTP_USER_AGENT} !(W3\ Total\ Cache/0\.9\.2\.4) [NC]     RewriteCond "%{DOCUMENT_ROOT}/wp-content/w3tc/pgcache/%{REQUEST_URI}/_index%{ENV:W3TC_UA}%{ENV:W3TC_REF}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" -f     RewriteRule .* "/wp-content/w3tc/pgcache/%{REQUEST_URI}/_index%{ENV:W3TC_UA}%{ENV:W3TC_REF}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" [L]     </IfModule>     # END W3TC Page Cache core     # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress


Adding wp_list_categories to a specific div that was appended using jQuery

Due to the way my projects menu is coded/styled I'm having some difficulty figuring this out. I have appended a div to my menu using jQuery, and I want to be able to include an external php file that simply contains a wp_list_categories(); function wrapped in an unordered list. What would be the best way to go about doing this so that wordpress recognises the wp_list_categories functions and works as I've intended? or is there a better/easier solution.


Wordpress not reflecting changed of the database

my problems started when I moved my website to another folder (from /dev/ to /). I have gone through the whole database in order to change all the hardcoded /dev/ into / but I still notice that wordpress, somehow, still uses the old values. Basically the website uses information that are not there anymore. I checked my own and the server cache and they all seem to be clean (the server doesn't even seem to have that feature on). So, I am pretty much lost... **FIXED:** The problem was related to the revision number of every information. Having changed some values directly from the DB but not the revision number, wordpress would reject the change and show nothing (as there were no previous versions). I just entered all the missing information by hand and it worked. Basically, don't mess with the DB. Wordpress doesn't forgive!


Create custom taxonomy and Display in metabox dropdown

I'm looking to create a dropdown in the post edit screen which contains 3 already existing tags. What's the easiest way of doing this? Basically all I'm looking for is a simple drop down which adds one of the following tags to the post itself; 'beef-stew', 'pea-soup' & 'chili'. I'd also like 'beef-stew' to be the default. Thank you in advance EDIT: As I don't want the user to be able to display more than 1 of these 3 categories at any time, and have to option to easily change which one as they please, tags might not be the best solution? Would I be better off creating a custom taxonomy ('food')? They will basically be used to change the way a post is displayed on the front page of the website.


Share Bar over laps left column

on my posts page i have a share thing in the side bar, however the side bar over laps the main content even though there is plenty of room on the right, i have tried changing single right column and single left column but nothing makes any difference, any advice would be appreciated.               http://79.170.40.241/shaddersafrica.com/?p=119      Thanks Lee


Is there something like has_no_term

I have a custom post type named 'Projecten' with a taxonomy called 'fases_projecten', in there i have 'concept', 'inontwikkeling' and 'gerealiseerd'. In my template I'm using the following code for displaying changes between the sevral fases/terms.               `<?php  if( has_term( 'concept', 'fases_projecten' ) ) { ?><div class="status sActiveConcept"><?php } ?>`      For each fase I have a diffrent openingdiv class, but maybe it will happen that the users of the website forget to choose a fase, witch mess up the site completely because the openingtag of the div is missing. So I was wondering if there exsists something like has no term. What I already tried is               <?php   if( has_term( '', 'fases_projecten' ) ) { ?>
<?php } ?>      Also when I make do it like this:               <?php   if( has_term( 'concept', 'fases_projecten' ) ) { ?>
<?php } ?>     <?php   elseif( has_term( 'inontwikkeling', 'fases_projecten' ) ) { ?>
<?php } ?>     <?php   elseif( has_term( 'gerealiseerd', 'fases_projecten' ) ) { ?>
<?php } ?>     <?php   else( has_term( '', 'fases_projecten' ) ) { ?>
<?php } ?>      It will not work, I get a servererror. I hope I explained clear enough, my english is not so good though


How to add rel nofollow to this?

How can i add rel="nofollow" to this?               echo " "."(...)"."";


Does WP "out-of-the-box" allow user profile photos?

How does a user upload a photo to their profile? Do you need a plug-in to do that? Right now the user has a gray box with a white silhouette headshot.


Custom Template for more than 1 Tag

Wordpress let me create custom tag templates, i have lots of tags, and i want to display the post tagged with some tags with a template, and the post tagged with other tags with another template. ![enter image description here](http://i.stack.imgur.com/C7kUo.png) As this image shows the template hierarchy let me create the tag template easily, giving to the page the name or the id of the tag. But i want to create 1 template tag for a great number of tags (instead of making 1 template for every different tag), and another template tag for the remaining one.


Login using the password from protected pages

Does anyone know the logic on how to do the following: I have a login section with a password field only on the index, so the user enter the password and submit. Upon submission, I was hoping if the password entered can match with the passwords of the existing protected pages. Once there's a single match, the user will be redirected to that password protected page as login successful. Do u think it's possible..? I need some hope here, thanks!


custom taxonomies on permalink

> is it possible to bring custom taxonomies to permalink? > > currently my permalink is looking something like this > `/%postname%/%category%` > > but i also want to add custom taxonomies to my permalink so it should look > something like this > > `/%postname%/%category%/%location%/%mba_courses%` > > is this possible? the solution to this answer i found, i googled and i found this code, which works perfetc for me               add_filter('post_link', 'mba_courses_permalink', 10, 3);     add_filter('post_type_link', 'mba_courses_permalink', 10, 3);          function mba_courses_permalink($permalink, $post_id, $leavename) {         if (strpos($permalink, '%mba_courses%') === FALSE) return $permalink;                  // Get post             $post = get_post($post_id);             if (!$post) return $permalink;                  // Get taxonomy terms             $terms = wp_get_object_terms($post->ID, 'mba_courses');              if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;             else $taxonomy_slug = 'mba_courses';              return str_replace('%mba_courses%', $taxonomy_slug, $permalink);     }      but now i have one more problem, when i google my website i get the old url structure link, when i click on that i get 404 error, where as the post is still inside the website, just the url has changed, so how can i make the old url to direct it to new url i mean if clicking on the old url and instead of redirecting to 404 page, can it redirect to the actual post where i have the new url? is this possible?


Why is my 'list_terms_exclusions' filter function timing out?

Why is my function timing out? When the issue was first noticed I added `wp_defer_term_counting('true')` to delay that process but to no avail.               /* Filter category from get_categories and wp_list_categories */          add_filter('list_terms_exclusions', 'my_list_terms_exclusions', 10, 2);          function my_list_terms_exclusions($exclusions, $args) {              global $my_sc_id;              // Defer term counting as its a heavy operation and may time out the server         wp_defer_term_counting('true');              if (!is_admin() && $my_sc_id) {                  //Get the secret category and all its descendents             $list_terms_exclusions = my_sc_return_secret_cats($elbone_sc_id); // Returns an array                  // Implode array             $list_terms_exclusions_string = implode(',', $list_terms_exclusions); // Returns a string                  // Filter             $list_terms_exclusions_clean = wp_parse_id_list($list_terms_exclusions_string);                  // Add to SQL query             foreach ($list_terms_exclusions_clean as $ex) {                      if (empty($exclusions))                     $exclusions = ' AND ( t.term_id <> '.intval($ex).' ';                 else                     $exclusions .= ' AND t.term_id <> '.intval($ex).' ';                  }                  // Closing bracket             if (!empty($exclusions))                 $exclusions .= ')';                  // Modify query             return $exclusions;                   }              // Enable term counting         wp_update_term_count();               }      **EDIT:** The contents of the `elbone_sc_return_secret_cats` function.               /* Return child categories as array */          function elbone_sc_return_secret_cats($elbone_sc_id) {              // Add the child cats to the array           $sc_children = get_terms('category', 'child_of='.$elbone_sc_id);              foreach ($sc_children as $sc_child) {                  $sc_child_ids[] = $sc_child->term_id;              }              // Add the parent category         $sc_child_ids[] = $elbone_sc_id;              // Return results         return (array)$sc_child_ids;          }


Show selected images on top in Media Manager

I've searched numerous StackOverflow and Wordpress Awnsers questions, but I couldn't find any solution that matches my situation or even remotely points me in the right direction. I have a custom media frame in my plugin where I have pre-selected certain images out of a media library of about 3000 images. However, these pre- selected images aren't sorted on top of the list by default, which results in you browsing the list for hours to find your selected images. In short I want these to be on top of the list. I have their ID's. I found that in media-models.js where the code goes:               Query = media.model.Query = Attachments.extend({ ...      it handles the querying / sorting of the attachments that are displayed in the media manager. I've tried extending it like this in my main plugin javascript file               wp.media.model.Query = wp.media.model.Attachments.extend({ ...      which gave me no result and numerous other suggestions in question that looked similar to my situation. Now I'm at the point where I'm out of idea's of how to tackle this. Could someone point me in the right direction? * * * **EDIT:** Well I have been able to influence the queries made by my media frame. In my main.js in my plugin I do this now:               file_frame = wp.media.frames.file_frame = wp.media({         id: 'multi_image',         title: 'Select images',         button: {             text: 'Use selected images'         },         library: {             type: 'image', post__in:[3322,3323,3324,3325,3326,3327,3328]         },         multiple: true,     });       This way I can show the media frame only displaying the image attachments with certain id's. However I also want to display the rest of the attachments, only with my selected images on top. So I would need to either combine the results of this query by making a new query with post__not_in instead of post__in or by custom ordering the attacments giving the attachments with those id's priority. I don't know how to do that. The arguments I can pass to the library seem limited to me.


How do I write an inventory list plugin that creates dynamic details pages?

I am working on a plugin that creates an inventory list page using an XML data file. For the sake of this example, let us say the inventory items are antique motorcycles or contemporary area rugs. User activates my plugin and adds a short code to a page in order to display the inventory on a page called "Inventory." I want to introduce a details page so when the end user wants to enlarge the thumbnail picture or read more details about a specific motorcycle, he can click from site.com/Inventory to site.com/Inventory/somethingelse/ to find that information on another page. What is the right way to code this? Some things I have considered are...   * Create another page and another short code and then hide the page from the menus   * Add rewrite rules to send these requests to a .php file in my plugin directory What do you think? Thanks for reading.


Permalink structure with $_SESSION variables

I have a project that has content being filtered throughout the site (many custom WP_QUERY calls). Originally there was no URL needs, just filtering by **$_SESSION** variable. Works perfectly, but NOW client wants each specialty to be loaded with a custom URL (much like categories do already). I need to to first know: > **Is it possible to make a permalink structure with the $_SESSION > variable?** If so: > **How can I create a URL structure like this?** **Archive Page:**               http://domain.com/session-var/      **Single Page:**               http://domain.com/session-var/post-name


How can I reverse engineer a Permalink to Find the Page?

I am new to WordPress, and I need to make some quick changes. How can I find the Page that is referenced by a permalink: e.g. for www.example.com/mypermalink how can I locate the actual WP Page so I can find it either in the file system or in the WP Pages list?


Are term_taxonomy_id and term_id the same?

I have a custom query where I need a JOIN because I want to COUNT all the posts **of a specific category**. So I checked the tables and I found out that table `wp_term_relationships` contains a reference to the `wp_term_taxonomy` table. The **`term_taxonomy_id`**. However when I looked into the `wp_term_taxonomy` table again I found out that **`term_taxonomy_id`** and **`term_id`** are having the exact same values. So are they always the same? Can I filter the results by category with only joining `wp_term_relationships` and using **`term_taxonomy_id`**?


Connect Wordpress comment moderation with bbPress Moderation plugin

Is it possible to connect the bbPress Moderation plugin with WordPress's first comment moderation so a Wordpress comment moderation would also approve people for the forum, and a moderated first topic/reply on the forum would approve someone for wordpress comments...? To keep people from having to be moderated twice...


Images with excerpt function

I got this great excerpt function that keeps my paragraphs in tact. Works great btw.                function pietergoosen_custom_wp_trim_excerpt($text) {     global $post;     $raw_excerpt = $text;     if ( '' == $text ) {         $text = get_the_content('');              $text = strip_shortcodes( $text );              $text = apply_filters('the_content', $text);         $text = str_replace(']]>', ']]>', $text);              //Add the allowed HTML tags separated by a comma.         $allowed_tags = '
,,,';           $text = strip_tags($text, $allowed_tags);              //Change the excerpt word count.         $excerpt_word_count = 105;          $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count);               //Change the excerpt ending.         $excerpt_end = ' ' . '…' . __( 'Read more about this article →', 'pietergoosen' ) . '';          $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end);              $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);         if ( count($words) > $excerpt_length ) {             array_pop($words);             $text = implode(' ', $words);             $text = $text . $excerpt_more;         } else {             $text = implode(' ', $words);         }     }     return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);     }     remove_filter('get_the_excerpt', 'wp_trim_excerpt');     add_filter('get_the_excerpt', 'pietergoosen_custom_wp_trim_excerpt');      To show the first image with the excerpt, I use the old function                   function pietergoosen_get_first_image() {         global $post, $posts;     $first_img = '';     if(preg_match_all('//i', $post->post_content, $matches)){     $first_img = $matches [1] [0];     }          return $first_img;     }      This also works great. The question now is (I'm not a coder at all), is there a way and how to change the excerpt code I supplied to automatically display the first image without needing more functions. Any code will be highly appreciated


WP-Cron tasks scheduled but not running

I'm working on a particularly large WordPress multisite network, and have been struggling with WP-Cron. It seems that WP-Cron tasks are being scheduled, but not run. The WP-Cron tasks are not being run on either our staging or production environments, but locally, they run fine. The instances are all identical—multisite, with the same set of sites, the same theme, and the same plugins activated (and same versions of plugins). There are slight differences in the version of PHP on the server and in my local sandbox, but the WP versions are the same (a little behind the current – 3.5.2) I've tried clearing the queue, and hitting the cron script directly (/wp- cron.php?doing_wp_cron), but without success. I even tried scheduling a call to that script in an actual cronjob, but with the same result—nothing. I double-checked that `DISABLE_WP_CRON` is not present in the wp-config file, and even played with defining that constant to `false`. Any insight into why it might not be running, or how to force it to run, would be very helpful.


Plugins to generate CSS Sprites?

I see that w3 total cache can't offer CSS sprite generation. Is there another plugin that can complement this feature? Thanks. update: I didn't mean that w3 total cache doesn't allow CSS sprites to be used, but that it doesn't generate them automatically as a way to improve sites performance. My question is what plugins DO offer that capability.


Get permalink and title by post name?

In the theme there is a custom post type called `faq` I just want to get certain post by its name (NOT by id cause no id exist).               <?php query_posts('post_type=faq') ?>      how to get `the_tile()` and `the_permalink()` by its name?


Querying Multiple Custom Taxonomy Terms

I created a new taxonomy called 'country' and have two terms items inside it: 'USA' and 'Canada'. How do I go about querying this info? I have a filter page with two checkboxes:               <input type="checkbox" name="usa" value="USA" /> USA     <input type="checkbox" name="canada" value="Canada" /> Canada      How do I make the query show multiple results in case I have both boxes checked? I tried an array, but it didn't work.               <?php query_posts( array('country' => array($_POST['usa'], $_POST['canada'])) ); ?>


Timthumb.php image gallery not working on Multisite Wordpress

What I am trying to do is get a gallery working on a multisite wordpress installation . . It works on the home site because that is where wordpress is actually installed but not on the sub domain sites. Timthumb.php is a script that basically resizes images into a thumbnail. So on main domain it works but not on any subdomains, it doesn't show the thumb, only the main image once the thumb is clicked. The creator of timthumb.php wrote a fix at http://www.binarymoon.co.uk/2009/10/timthumb-wordpress-mu/ but I cannot work out the application for my case. Any tips?


Is it possible to query_posts using post__in and then Loop through them in the ordered they were queried?

query_posts( array ( 'post__in' => array( 5, 76, 21, 56, 3 ) ) );      I'd like to query the Loop using `post__in` and a set Wordpress IDs. I'd then like to run through the Loop in the exact order of the query. Does anyone know if that is possible?


Adding Sticky functionality to Custom Post Type Archives

In WordPress, Custom Post Types do not have Sticky functionality as a core feature. It is possible, I'm sure, to create it in certain cases—and I'm working on a project that requires it for `archive-{customposttype}.php` templates. I have downloaded and installed a plugin, called Sticky Custom Post Types, which I read in this article could be used along with a little bit of PHP to get_option( 'sticky_posts' ) and reconfigure the array of the query currently being executed. I know that the plugin works because using `if (!is_sticky()) {et cetera}` within the loop allows me to alter the output of the sticky (custom post type) posts. I haven't been able to successfully implement the code from the article—the order doesn't seem to change at all when I place it at the top of my `archive-{customposttype}.php` template, nor have I been able to make it work through several other attempts. This is probably because I'm not very adept at PHP. Another thing I tried is creating a new query, specifying that I want only sticky posts (which worked at showing me only sticky posts); trying to store that query in a variable, then calling `wp_reset_query()`, then creating another query specifying that I **don't** want sticky posts, trying to store that in a variable, calling `wp_reset_query()` again; and then merging the two query arrays with `array_merge()`. Unfortunately my various implementations of this either broke the page, or succeeded at doing absolutely nothing, or only showed the second query's output... and I deleted them out of scorn. I don't know if I'm going about this in the right way at all, really; and I'm sure plenty of people have confronted and overcome this issue. If anyone has any advice or code snippets to help me implement this feature, it'd be greatly appreciated. To reiterate for the sake of clarity, I'm attempting to show sticky posts at the top of my archive pages for custom post types.


How do I force Wordpress to show most recent version of images in the media library?

My workflow is sometimes the following:   1. Delete many images from the media library at once (named for example, `01.jpg`, `02.jpg`, `03.jpg`...).   2. Re-upload a series of images with the same file names (`01.jpg`, `02.jpg`, `03.jpg`...). The media library retains and display shows the old images as thumbnails and previews, even though they are deleted. Obviously this problem is avoidable by adding images with distinct file names, but I wondered if there were some better way that works regardless of naming convention. Or something else that I'm completely missing? Thanks.


Update fields with post object and custom tax with wp_insert_post

**Updated Post**   ' **update_field** ' Function is **Acf** Plugin               $supplier_one = 'my supplier';     $supplier_two = 'my supplier TWO';     $post_id_one = 555;     $post_id_two = 556;          update_field('suppliers', $supplier_one, $post_id_one)     update_field('suppliers', $supplier_two, $post_id_two)      This code works for post object?   My other question is how to send posts to custom taxonomies with wp_insert_post      My Code for Wp_insert_post                 $insert_post = array(         'post_status' => 'publish',         'post_type' => 'products',         'post_title' => 'my post title',         'tax_input' => array( 'category-products' => array( 'several' ) ) /// Category for post_type products     );     wp_insert_post($insert_post);


Wordpress custom posttype meta values doesnot save

I am developing a wp plugin which supports custom post type in that i have create a metabox everything goes well.When i enter the values in my metabox field it will not display in admin panel where as it will store in database(wp_postmeta table ).Can any one suggest me what is going wrong with my code.               //Create Meta box      function astest_add_metabox(){      add_meta_box("astestimonial_metaboxes", "AS-Testimonial Client Information", "astestimonial_meta_box", "astestimonial", "side", "low");      }     add_action('add_meta_boxes','astest_add_metabox');          //html code     function astestimonial_meta_box($post_id){     wp_nonce_field('astest_meta_box','astest_meta_box_nonce');     $clientname = get_post_meta($post->ID,'clientname_value','true');     echo'<label for="client_name_val">';     _e('Name: ', 'astestimonial_textdomain');     echo'</label>';     echo'<input type="text" id="clientname_value" name="clientname_value"   value="'.esc_attr($clientname).'" />';          //save post     function as_testi_save_data($post_id){     global $post;     if(isset($_POST['post_type']) && ($_POST['post_type'] == "astestimonial"))     {         $cli_name_data = $_POST['clientname_value'];          update_post_meta($post_id, 'clientname_value', $cli_name_data);      }     }          add_action("save_post", "as_testi_save_data");      Can anyone find what is wrong with this.. Thanks


Get admin menu link

Is there any way I can get the menu link for admins? http://codex.wordpress.org/Function_Reference/edit_post_link Similarly to the `edit_post_link()` that returns the edit link for loggedin Admins I would like to do something similar for the `edit menu` if there is anything like that?


Why does WordPress need my private ssh key to update?

Configuring WordPress to update within the application (i.e. WordPress) is ideal for me because of its convenience. Nonetheless, I'm troubled by the requirements. The requested fields that show up after installing ssh2 for php ask not just my public key, but my private key as well. I would think that, at the most, only the public key would be required. Does WordPress actually give my private key to a server so that the server can upload the correct software package to my server? I'm familiar with how SSH private/public keys work, which is why I'm confused why WordPress needs this. If anything, I would think that the mechanism for updating wouldn't even need this protocol; it would just use http or ftp to the package server and then download/install/activate from there. **Why does WordPress need my ssh keys? Are there security concerns here?**


Only show featured image on exerpt and exclude images in post

I have below code which displays the featured image from the post. But when I add an image to the post it also shows up with the featured image. What I need to do is just show the featured image and some content from the post with a read more link, after someone clicks the read more link the other images should appear with the full post.                  <? query_posts('post_type=front&p=47');              while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
             <?   if ( has_post_thumbnail() ) {           the_post_thumbnail( 'front-thumb' );         }                  the_content('Read more');              endwhile; ?>


Include category name in page template

The theme I am using inserts and styles the page title using this code. I would like to display the category name depending on whatever it is for that category. I have tried a number of methods but none of them work inside this code. I can make the static title 'Blog Category' appear for each category but not a dynamic category title. Any suggestions would be most welcomed !!                 <!-- Page Heading -->             <h1 class="fl">             <?php if ( is_front_page() ) {                  echo(__('Let\'s talk about respect and equity', 'layeru'));             } else if ( is_category() ) {                           echo(__('Blog Category', 'layeru'));                      } else if ( is_404() ) {                 echo(__('Page Not Found', 'layeru'));             } else if ( is_search() ) {                 echo(__('Search', 'layeru'));             } else if ( function_exists('bp_is_active') && bp_is_group_single() ) {                 echo(__('Discussion Groups', 'layeru'));             } else if ( function_exists('bp_is_active') && bp_is_member() ) {                 echo(__('My Activity', 'layeru'));             } else {                                 global $wp_query;                 $page_title = $wp_query->post->post_title;                 echo $page_title;             }             ?>             </h1>


wp_remote_post tp paypal nvp api timeout, while curl with the same parameters work

I'm using wordpress **Http Api** to call this worked perfectly for over two years and just recently broke down. This is the code:               $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature&$nvpStr_";//                   // posting to paypal server with wp built in function              $httpResponse = wp_remote_post($API_Endpoint,array(             'sslverify'=>false,             'timeout' => 20, // just to make sure this isn't the problem             'body'=>$nvpreq             )         );      RETURNS:`connect() timed out` error. WHile this works perfectly from curl (when I echo the request from wordpress and just copy paste to curl). Any ideas? I'm thinking maybe a server change in our side started to block a outgoing port that the `wp_remote_post` function uses, but I'm not sure this is the problem and I don't know what port does the Http Api use behind the scenes. I'm also suspecting some change in the Http Api in a wordpress version update that broke something, But I couldn't find any clues to this kind of change in the docs.


Custom Taxonomy Filter Issues

I have a custom post type with a few custom taxonomies and I am using a piece of code to filter the posts based on the taxonomy on the main edit page using drop-down menus, which works great, but I have found that when I click onto a taxonomy's main page, and click on the number of posts that contains a specific term, it says 'trying to get property of non-object' and does not filter them. This is the code that is causing me issues:               function taxonomy_filter_post_type_request( $query ) {       global $pagenow, $typenow;            if ( 'edit.php' == $pagenow ) {         $filters = get_object_taxonomies( $typenow );           foreach ( $filters as $tax_slug ) {             $var = &$query->query_vars[$tax_slug];               if ( isset( $var ) ) {                $term = get_term_by( 'id', $var, $tax_slug );                 if($var){                  $var = $term->slug;                }             }          }       }     }          add_filter( 'parse_query', 'taxonomy_filter_post_type_request' );      The line that reads $var = $term->slug; seems to be causing the problem, But if i replace:               if($var){       $var = $term->slug;     }      to:               if(is_array($var)){       $var = $term->slug;     }      Then it works when I click on the number of posts that contain a certain term, but the drop-down menu filters fail to work. By looking at this, is it possible to make them both work?


Fatal error with jigoshop and woocommerce

I am using woocommerce on my site. Is jigoshop necessary for the functionality of woocommerce? I deleted the plugin jigoshop from the admin and then some links and pages disappeared (like the shop archive and other pages). So I tried to reinstall jigoshop and now I’m getting this: > Fatal error: Cannot redeclare is_shop() (previously declared in > /home/blaa/public_html/blaaa.com/wp-content/plugins/woocommerce/woocommerce- > core-functions.php:442) in /home/blaah/public_html/blaa.com/wp- > content/plugins/jigoshop/jigoshop.php on line 646


QA/Staging envirnoment for wordpress sites

I have different wordpress environments as Local, Staging, Live. I start writing contents with Local, then push to Staging and once Tested on staging need to push to live server   1. I know that I can use export/import pages/posts. what is the best practice to do this without loosing any internal resources like images/js files/css etc   2. If I am customising the themes, do I need to make the same customizations in different environmets or export and import themes ?


Add an Outside Wrapper to my Header and Make it Full Width

I did reposition the `<header>` outside the 'wrap class' class by adding this function in my function.php               /** Reposition header outside main wrap */     remove_action( 'genesis_header', 'genesis_header_markup_open', 5 );     remove_action( 'genesis_header', 'genesis_do_header' );     remove_action( 'genesis_header', 'genesis_header_markup_close', 15 ) ;          add_action( 'genesis_before', 'genesis_header_markup_open', 5 );     add_action( 'genesis_before', 'genesis_do_header' );     add_action( 'genesis_before', 'genesis_header_markup_close', 15 );          /** Reposition header outside main wrap */     remove_action('genesis_after_header','genesis_do_nav');     add_action('genesis_before','genesis_do_nav');      I have my 'header' 980px width with `margin:0 auto;`               #header {         border-bottom: 2px solid #1e1e1e;         min-height: 120px;         overflow: hidden;         width: 980px;         margin:0 auto;         padding: 0 0 10px 0;     }      When i check inspect element i see this.                      Some text here            What i want is to add a wrapper to the header with full width
Some text here
                .hwrapper { width: 100% ; background-color:#000;}      Is there a Hook or a Function that will do that?????


Multsite - changing the default /blog/ to be /gb/blog/

We're in the process of converting a single wordpress blog into a multisite one. As it stands at the moment, wordpress is installed in a `/blog/` directory, with each of the new blogs we're going to create existing as a virtual subdirectory, - only problem is, we need the multisite URLs to look like this:   * `/gb/blog/`   * `/us/blog/`   * `/ae/blog/`   * etc... (I've tried to argue my case against doing it this way around, and would much prefer to have /blog/gb/, etc.. - but I've been out voted.) So - other than just installing multiple copies of the blog in physical folders, is there any way in which we can achieve this? Thank you.


How to show gallery description with nextgen 2.0.33

I have a gallery that contain description of gallery. I want to show it in my page but i don't know how to get description for showing my page. What should i do? _**Edit_** I found old answer in -> http://stackoverflow.com/questions/9674669/plugin-wordpress-nextgen-gallery- how-to-show-the-gallery-description-in-nextg but the answer is use old version of nextgen