title: Hierarchical Custom Posts - Highlighting Current Post in Sub-Menu

text:
I have created a hierarchical custom post type called events and have used wp_list_pages to list the sub-posts for each event post (See below). This navigation works great, but I cannot figure out how to highlight the menu items based on the post being viewed. I normally use .current_menu_item, but this class is not generated for CPT. Is there any way I can add this class to the link for the current post? Thank you for your help!               //If the post has a parent, get the parent id     if($post->post_parent) {         $args = array(           'title_li'  => '',           'child_of'  => $post->post_parent,           'post_type' => 'events',           'echo'      => 0         );         //Create a variable for the parent post id          $top_page = $post->post_parent;     }     //If the post is a parent, get the post id     else {         $args = array(           'title_li'  => '',           'child_of'  => $post->ID,           'post_type' => 'events',           'echo'      => 0         );         //Create a variable for the post id         $top_page = $post->ID;       }     //List child pages     $post_children = wp_list_pages( $args );     //Get the title of the the parent page     $top_title = get_the_title($top_page);      //Get the of permalink the parent page     $top_link = get_permalink($top_page);              //If there are children, list them in a side nav         if ( $post_children ) {         ?>
             <a href="<?php echo $top_link; ?>">
<?php echo $top_title; ?>

                 <?php echo $post_children ?>


title: How to optimize 'select found_rows()' query? Several 'high load average' alerts daily

text: I have 5,000 regular posts, 6,000 posts in one post type and 2,000 posts in another post type. Needless to say, that has made the wp_posts table quite large. Not to mention, I have custom taxonomies set up to mimic the post types so for every Company A entered into Company post type, there is Company A, I manually entered Company A into Company taxonomy. That way, when I do a regular post about Company A, I can effectively 'tag' Company A into the post and then that post appears on Company A's custom post type page. Specs: Running WP Super Cache w/ Cloudflare as CDN. Theme is Wordpress TwentyEleven but heavily customized. Server: 2048 RAM, 80gb Raid, 8+CPU 4x priority, 5000GB Bandwidth. Traffic is 750k views/month & 200k uniques. I'm starting to see performance issues increase pretty rapidly with two instances in the last week where I got an 'error connecting to database' message on the site and had to restart mysql service. Not to mention, high load average emails several times a day. Ran Debug queries. Ran it with WP Super Cache. Uninstalled WP Super Cache & tried W3 Total Cache w/ most of the options enabled. In both trials, I saw the longest load time caused by these two queries (but only on the first load! Almost 0 on subsequent loads):               Time: 7.79628753662E-5     Query: SELECT FOUND_ROWS()     Call from: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/child-theme/index.php'), WP_Query->__construct, WP_Query->query, WP_Query->get_posts, WP_Query->set_found_posts, W3_Db->query, W3_DbCache->query, W3_DbCallUnderlying->query, W3_Db->query, W3_DbProcessor->query, W3_Db->default_query          Time: 6.29425048828E-5     Query: SET SESSION query_cache_type = 0;     Call from: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/child-theme/index.php'), get_footer, locate_template, load_template, require_once('/themes/child-theme/footer.php'), wp_footer, do_action('wp_footer'), call_user_func_array, Debug_Queries->the_queries, Debug_Queries->get_queries, W3_Db->query, W3_DbCache->query, W3_DbCallUnderlying->query, W3_Db->query, W3_DbProcessor->query, W3_Db->default_query      I did remove an array which made it so that we looked for posts types in addition to regular posts but that didn't seem to make a difference. Full example query output: http://pastebin.com/L0mSXe9q Also, here is the template code for the main index:                   <?php if ( have_posts() ) : ?>                  <?php /* Start the Loop */ ?>                      <?php while ( have_posts() ) : the_post(); ?>                      <?php if ( 'status' == get_post_format() ) {                          get_template_part( 'content-status', get_post_format() );                      } else get_template_part( 'excerpt', get_post_format() );                  ?>                  <?php endwhile; ?>      Really not sure where to proceed from here.


title: Facebook user login integration with WordPress

text:
I am trying to use Facebook login to register users on my blog, but after users are logged into their Facebook account, their account is still not created in WordPress. I would like to have the users registered by taking their Facebook email and creating a random password. After the user is registered, they should be automatically logged in and sent to the profile page where they can update their name, add some custom user meta data and a short bio. The code for the Facebook login integration with WordPress I'm using is below: 1- // This is the login button that goes in my index/page               Rejoignez-nous sur facebook      2- // This goes in my functions.php               //create facebook href button     function FbC_head(){         if( is_user_logged_in() ) return;         ?>

                  <?php     }     add_action( 'wp_head', 'FbC_head' );//end          //load jquery if needed     function FbC_enqueue_scripts(){         wp_enqueue_script( 'jquery' );     }     //add_action( 'wp_enqueue_scripts', 'FbC_enqueue_scripts');//end          //event handler in footer     function FbC_footer(){         ?>                  <?php     }     add_action( 'wp_footer', 'FbC_footer' );//end      3- // Finally this is the function to do the registration and named according to 1- (checkFB.php)               //don't worry I don't wanna show this on http://wordpress.stackexchange.com/!     require_once('/this_is_the_path_to_my_server_/wp-load.php');     require_once('/this_is_the_path_to_my_server_/wp-config.php');          /*     $_REQUEST is sent with 2 arrays. We will retrieve the ID and then start checking.     */     $login = $_REQUEST['userResp']['id'];          //Check if the username exists already     $id = username_exists($login);     $errors = array();          //Case 1 : When the ID doesn't exist.     if(!$id) {         $email = $_REQUEST['userResp']['email'];         $existingID = email_exists($email);         //Case 1 confirmed : If the email also does not exist, we can proceed with registration.         if(!$existingID) {             $pass = wp_generate_password( $length=12, $include_standard_special_chars=false );             $userData = array();             $userData['user_login'] = $login;             $userData['user_email'] = $email;             $userData['user_password'] = $pass;             $userData['user_nicename'] = $_REQUEST['userResp']['first_name'] .' '. $_REQUEST['userResp']['last_name'];             $userData['first_name'] = $_REQUEST['userResp']['first_name'];             $userData['last_name'] = $_REQUEST['userResp']['last_name'];             $insertStatus = wp_insert_user($userData);             if(is_wp_error($insertStatus)) {                 $errors = array_merge($errors, $insertStatus->getErrorMessages());             }             else {                 wp_set_auth_cookie($insertStatus, true);             }                }         //Case 2 : When the email ID the user has attached to his FB account is also registered here.         else {             $userFB = get_user_meta($existingID, 'fbid', true);             //if a user is already attached to the email.             if(!empty($userFB)) {                 //Case 2a : Here we match the Facebook ID of the user to the facebook ID of the email ID.                 if($userFB == $login)                     wp_set_auth_cookie($existingID, true);                 else {                     array_push($errors, __("Another Facebook ID seems to be attached to your account. Please check."));                 }             }             //Create the link between the user's email ID and the facebook ID for the first time, and log him in.             else {                 if(!add_user_meta($existingID, 'fbid', $login, true)) {                     array_push($errors, __("Sorry! We were unable to link your FB account."));                 }                 else {                     wp_set_auth_cookie($existingID, true);                 }             }         }     }            //Case 3 : When the user is already registered     else {         wp_set_auth_cookie($id, true);     }          $resp = array();     if(!count($errors)) {         $resp['status'] = "Success";         $resp['loggedIn'] = true;         $resp['errors'] = $errors;     }     else {         $resp['status'] = "Failure";         $resp['loggedIn'] = false;         $resp['errors'] = $errors;     }     echo "reply(".json_encode($resp).")";


title: Does WordPress Development Mode Exist (with not minified JS)?

text: A lot of WP JS is minified and therefore it's hard to be analyzed in the Console. Is there any way to have all scripts uncompressed?


title: Make "sidebar template" the default template for new pages

text: On **_Twenty Eleven_** or on its child themes the default template for new pages is a template with **no sidebar**. I don't know why this is like this; it seems to me that the designers of Wordpress are still not thinking about CMS functionality in some places. For example the most obvious place to put a menu in a CMS is the sidebar. But with Twenty Eleven the only way to show a menu in all pages is to explicitly set all the pages to **_"sidebar template"_**. I would think it's a design bug, as the only solution so far is to tell everyone to _"don't forget to set the new pages to "sidebar template""_. I'm sure there must be a single line in `functions.php` which changes the default action but I don't know what that line is. Could you tell me what should I write in `functions.php` to set all new pages to **_"sidebar template"_** when using Twenty Eleven? _I'm sure that it has been asked before but I really couldn't find it anywhere using the search function._


title: What does wordpress search, search?

text: I just realized in testing, it appears worpress search is not matching my search term "php" with any post's tagged with "php" or in a category of "php" unless php is in the title or body, is that all the search searches for?


title: How can I remove the new stats message?

text: I've recently (latest update) been welcomed to my stats page with this annoying message: ![enter image description here](http://i.stack.imgur.com/VlATz.png) Can anyone tell me how to remove that offensive red "did you know" message? **Edit:** Looks like adding:               .gotonewdash {display: none;}      to wp-admin/css/wp-admin.min.css did the trick of hiding it, but according To Tom J Nowell, this is a big no-no. Does anyone have recommendation for doing this properly?


title: GUID URL Question

text: I had a website that needed to be re-done, so I hosted a new dev site (not locally) with a temporary domain. The dev/new site was completed and I then moved the domain from the old site to the dev/new site. All seemed to work perfectly after the domain switch, except that the images/posts for the blog are taking forever to load and I could see in the browser when loading a post it was looking for the temporary domain and not the new domain. I checked the GUID column on the database and I see all the post_type and content etc. are still using the temporary domain URL. Will it be safe to use a plugin like Blue Velvet or an SQL querie to replace the temporary domain with the original domain without breaking the site? I'm just a wee bit nervous to pull the trigger based on reading so many warnings to not touch the "GUID" column.


title: How to dispaly comment form error messages in the same page

text: I want to display comment form validation errors (as well as captcha error) on the comment form itself and not on a different page. How can I do that ?


title: Could the WP script/style loader be used to concatenate and gzip scripts and styles in the front-end?

text: WP has a nice javascript loader included in wp-admin: http://core.trac.wordpress.org/browser/tags/3.0.4/wp-admin/load-scripts.php and a CSS loader: http://core.trac.wordpress.org/browser/tags/3.0.4/wp- admin/load-styles.php I was wondering if it's possible to use them in the front-end too, not just admin, because they can concatenate all enqueued scripts, and serve them as a single gzipped file


title: Displaying comment counts in WP Gallery thumbnail view

text: Wordpress founder, Matt Mullenweg, has a great feature in his photo galleries. In thumbnail view, any photo that has a comment attached displays the comment count under the thumbnail. Look here (scroll down and you'll see some thumbnails with comment counts): http://ma.tt/2010/11/luxembourg/ He appears to be using the built-in gallery function, but I have been scouring the internet and cannot find any way to do this. Any help would be appreciated. Thanks! EDIT: It should also be noted that in this particular case I actually don't need the standard captions to show at all. Instead of adding the comment-count to the caption, I would be happy with a way to replace the standard caption with the comment count. I'm not sure if this make things any easier. Thanks!


title: Modifying the following code to displaying the title and the content of static page Posts page?

text:
I read a tutorial about how to Display the contents of static page Posts page. Basically I had to place this code right before the Loop:               <?php //This is the code from the tutorial     if ( 'page' == get_option('show_on_front') && get_option('page_for_posts') && is_home() ) : the_post();      $page_for_posts_id = get_option('page_for_posts');      setup_postdata(get_page($page_for_posts_id));     ?>      <div id="post-<?php the_ID(); ?>" class="page">
        <?php the_content(); ?>        <?php edit_post_link('Edit', '', '', $page_for_posts_id); ?>

     <?php      rewind_posts();     endif;     ?>      I wanted to also include `the_content`, but instead the `the_title` of the first post (blog) entry was shown:
            <?php the_title(); ?>            <?php the_content(); ?>            <?php edit_post_link('Edit', '', '', $page_for_posts_id); ?>
      picture: ![enter image description here](http://i.stack.imgur.com/nEdKz.png) **Code:** **loop.php**               <?php     if ( 'page' == get_option('show_on_front') && get_option('page_for_posts') && is_home() ) : the_post();         $page_for_posts_id = get_option('page_for_posts');         setup_postdata(get_page($page_for_posts_id));     ?>

<?php the_title(); ?>

<?php the_content(); ?>
             <?php edit_post_link('Edit', '', '', $page_for_posts_id); ?>

                     <?php                         rewind_posts();                     endif;                     ?>
          <?php         /* Start the Loop.          *          * In Twenty Ten we use the same loop in multiple contexts.          * It is broken into three main parts: when we're displaying          * posts that are in the gallery category, when we're displaying          * posts in the asides category, and finally all other posts.          *          * Additionally, we sometimes check for whether we are on an          * archive page, a search page, etc., allowing for small differences          * in the loop on each template without actually duplicating          * the rest of the loop that is shared.          *          * Without further ado, the loop:          */ ?>     <?php while ( have_posts() ) : the_post(); ?>       (...) **blog.php:**               <?php     /**      * Template Name: Blog      * @package WordPress      * @subpackage Prominent      * @since Prominent 1.0      */     get_header(); ?>             <?php // Start the Main Loop             if ( have_posts() ) : ?>                 <?php while ( have_posts() ) : the_post(); ?>

<?php the_content(); ?>

                 <?php endwhile; ?>             <?php endif; ?>             <?php get_sidebar(); ?>

     <?php get_footer(); ?>      Any suggestions? **EDIT:** Right now I'm using the following code. It retrieves the page's specific **the_content** but when retrieving the_title, it still retrieving the first blog post.               <?php     /**      * Template Name: Blog      * @package WordPress      * @subpackage Prominent      * @since Prominent 1.0      */     get_header(); ?>

             <?php /* Display the contents of static page Posts page */             if ( 'page' == get_option('show_on_front') && get_option('page_for_posts') && is_home() ) : the_post();                 $page_for_posts_id = get_option('page_for_posts');                 setup_postdata(get_page($page_for_posts_id));             ?>                 <div id="post-<?php the_ID(); ?>" class="page">

<?php the_content(); ?>
                         <?php edit_post_link('Edit', '', '', $page_for_posts_id); ?>

             <?php                 rewind_posts();             endif;             ?>

                  <?php // find all content that has the type of video and then to loop through them. ?>                  <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>                                  <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                                 <?php if ( is_front_page() ) { ?>
<?php the_title(); ?>
                                 <?php } else { ?>
<?php the_title(); ?>
                                 <?php } ?>
                                     <?php the_content(); ?>                                     <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'twentyten' ), 'after' => '
' ) ); ?>                                     <?php edit_post_link( __( 'Edit', 'twentyten' ), '', '' ); ?>

                                  <?php comments_template( '', true ); ?>                  <?php endwhile; ?>
             <?php get_sidebar(); ?>

     <?php get_footer(); ?>


title: database optimization and server errors

text: I've a self hosted wordpress blog. The server showing internal (500) server error and usually the system admins ask me to optimize my database. The database is relatively small in size and fits in few MBs. The error usually displaying is Fast CGI process. The usual reply from admins are as below > As we have checked and found that you are using Mysql database and fetching > database through php code from database server which is at remote location > and in this process when queries are being more then PHP fast cgi > application get hanged and that's why you are getting this issue, For this > you should check code or database optimization How can I optimize my database? I've installed a wordpress plugin to optimize my tables. Or is it a server problem?


title: WP Multisite Static Frontpage

text: I created a multisite and my question is as followed: Im trying to display a default static page for each new site. So when they create a new site, they automatically get a default page I made. This is the only page they need and have controle over. This page has only widgetized area's in it so that the site-admin can add content by adding widgets into the widget area's. They dont have access to create a post or page themselves. By adding a piece of code into wp-admin/includes/upgrade.php the page will be automatically made by WP whenever a new site is made. However, the page isnt connected to the template with the html/php code in it to display the widgets they add. Normally in WP you can create a page and on the right side you can select a template. Is it clear this far? (even I get confused lol) So what Im asking is.. is there a way to create a static frontpage for all newly created sites (like test.example.com and test2.example.com) with a template connected to it? Thanks in advance!!! It would make my day!


title: Remove action from shortcode

text: There is add_action() function inside function which is callback for add_shortcode(). Any idea how to remove this action with the help of custom plugin? Should I hook to any action which is called later then add_shortcode() function? I do not want to removing and re-adding shortcode, because there is huge function beyond it. Simple example:               function test_shortcode() {       ... other code ...       add_action( 'some_hook', 'custom_function');       ... other code ...     }          add_action( 'wp_head', 'setup_theme' );     function setup_theme() {       ... other code...       add_shortcode( 'test', 'test_shortcode' );       ... other code ...     }      I need to remove custom_function() from this shortcode. Thank you for your help...


title: Managing Backups: Space Issues

text: I recently reached 95% full storage on my GMail. Approximately 60% of this was, in fact, email backups from Wordpress' "WP-DB-Backup" plugin on 10+ sites that I manage. (I get a scheduled daily backup of the whole database.) There must be a better way to manage my backups. Ideally, if I can somehow automatically delete all but the most recent backup (whatever the solution is), that would be best. Sure, I can manually do this in GMail, but it's tedious and error-prone. Is there a better way to do this, or a better way to manage WP backups without worrying about HD space? GMail doesn't look like it's a good solution.


title: How to Append to the_excerpt() Function

text:
I have the following snippet of code:               <?php>$more = '.....';?>
<?php the_excerpt(); ?>
      What I am trying to do is append the value of $more to the_excerpt() function but unsure how to do. I have tried:
<?php the_excerpt() . $more; ?>
      but no go. Any help would be appreciated. Thanks.   sp.


title: How do I direct my domain name straight to my WordPress page?

text: I've sifted through a lot of similar questions on Google but haven't found anything that works. I changed my Document Root section in the apache2 sites- enabled 000-default file to `/var/www/wordpress` but when I do that and go to my domain name, it just says Apache can't find the file.


title: Posting code inside the post instead of in the template file using shortcode

text: I am using two plugins one of which is Thumbs Rating which have have a shortcode like this for example in order to display the thumbs rating option: The code bellow is to be used in the templates files but I would like to have the option of using functions like the bellow and related ones inside posts using a shortcode if possible.               <?=function_exists('thumbs_rating_getlink') ? thumbs_rating_getlink() : ''?>      I add this into my post but it doesnt show instead gets parsed as normal text. Is there a way to convert the code above into a shortcode something like [thumbsrating] which I can use in my posts. ( I want to paste the shortcode at a specific spot inside my post this is the reason for doing this ) Edit: Here is the code I had created with shortcode API but it didnt work:                   function rating_function() {       return '=function_exists('thumbs_rating_getlink') ? thumbs_rating_getlink() : ''';     }     add_shortcode('rating', 'rating_function');      The result I got by adding the shortcode [rating] in my post was the return as text and not executed as PHP. Any suggestions? Thanks


title: How to convert hits from Top 10 plugin to WordPress Popular Posts?

text: How can I import/convert hits from the plugin top 10 to wordpress popular posts plugin?


title: Using pre_get_posts to filter out posts, pagination problem

text: I'm trying to figure out how to fix my pagination problem while filtering out posts on the fly. I have a dropdown box just above the category archive that allows a user to sort or filter out posts based on custom fields. The posts, filter just fine on the first page. My problem shows up the minute I filter posts from within 2'nd or deeper page because filtering them out also reduces the number of existing pages. This returns a 404 error for me. I was wondering how to modify this to also **check if the page exists** , if not... return to first page. `$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;` Updated the code as requested:               // ADD SORT QUERY VAR     add_action( 'init', 'sort_rewrite_rules' );     function sort_rewrite_rules() {         // SORT QUERY VAR         add_rewrite_tag( '%sort%', '([^/]+)' );     }          add_action( 'pre_get_posts', 'filter_pre_get_posts',11 );     function filter_pre_get_posts( $query ) {         // DON'T AFFECT WP-ADMIN SCREENS         if ( is_admin() )             return;     // SORT ADS FROM THE MAIN QUERY     $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;     $sort = get_query_var( 'sort' );     if ( $query->is_main_query() && $sort ) {                   //EXCLUDE EXPIRED POSTS         if ( 'expired' == $sort ) {             $today = date('Y-m-d H:i:s');             $metaquery = array(                             array(                                  'key' => 'expire_date',                                  'value' => $today,                                  'type' => 'DATETIME',                                  'compare' => '>'                         )                 );             $query->set( 'meta_query', $metaquery );             $query->set( 'paged', $paged );         }          }     }               <div id="sort">         <form action="" method="GET">             <select name="sort" id="sort-dropdown">          <option value="expired" <?php selected( get_query_var( 'sort' ), 'expired' ); ?>><?php _e( 'Exclude Expired Posts', 'txt' ); ?></option>             </select>             <button type="submit" id="sort-submit">Sort</button>         </form>         </div>


title: Display one post on category.php: Wrong featured image

text: **What I want** When a user opens a category link, there should be automatically displayed the first queried post. My query looks like this:                   <?php global $query_string;                 $posts = query_posts($query_string.'&posts_per_page=1&order=ASC'); ?>                  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>             <?php get_template_part( 'content', get_post_format() ); ?>             <?php endwhile; endif; ?>                  <?php wp_reset_query(); ?>      **The problem** The category URL displays the first queried content, but the wrong featured image, which is taken from the last queried post, meaning `order=DESC` is used. Any idea how to solve this? **Maybe important** The featured images are set as full screen background images via backstretch.js by using               wp_enqueue_script( 'backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/jquery.backstretch.min.js', array( 'jquery' ), '1.0.0' );     wp_enqueue_script( 'backstretch-set', get_bloginfo('stylesheet_directory').'/js/backstretch-set.js' , array( 'jquery', 'backstretch' ), '1.0.0' );          wp_localize_script( 'backstretch-set', 'BackStretchImg', array( 'src' => wp_get_attachment_url( get_post_thumbnail_id() ) ) );


title: How to hook into wordpress admin upload iframe?

text: I have written a plugin which lets the user upload file attachments for using wordpress as a download site.   So I have added a meta box which shows the user the files he has uploaded for every post. Every thing is working fine until I wanted to make it so that if a user uploads file using the built-in upload manager and then closes the ThickBox a function of mine is invoked to update that meta box for new files. In simple words, I want to be able to listen on the ThickBox close event. That's it.


title: next_post_link / previous_post_link not working with WP_Query

text:
I am trying to add next and previous page buttons to my template, but when I try to use either `next_post_link` or `previous_post_link`, it just does not work. Could it be because I am using `WP_Query`? Here is my code thus far,               <?php get_header(); ?>                      <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>                 <?php $args = array(                     "post_type" => "page",                      "page_id" => $post->ID,                      ); ?>                      <?php $query = new WP_Query($args); ?>                      <?php if ($query->have_posts()) : ?>                          <?php while ($query->have_posts()) : $query->the_post(); ?>                                              <?php endwhile; ?>

<?php previous_post_link(); ?>

<?php next_post_link(); ?>

                      <?php else: ?>                                                      <?php endif; ?>          <?php get_footer(); ?>      Am I maybe missing essential parameters? From what I can see in the codex, it should work fine as I am using it now?


title: admin_notices after register_uninstall / deactivate_hook

text:
I've successfully added admin notices to display on `register_activation_hook`, and when the plugin updates, but I'm not seeing any way to display `admin_notices` after the uninstall or deactivation hooks. Is this at all possible? ~~Alternatively can use javascript at this stage?~~ (yes sort of). * * * **EDIT:** To answer @G. M. I've already read the docs and @kaiser I've already seen your great writeup on these hooks, but unless I've been sloppy and missed something these two hooks seem to operate differently then the activation hook. Here is what I've tested: This does **not** display a notice on the admin page, on deactivation or uninstall (though with _deactivation only_ , you _will_ see the message displayed briefly on a white screen after the hook runs, but just before the plugin admin page reloads):               register_deactivation_hook(__FILE__, "gfahp_deactivate");     function gfahp_deactivate(){         $notices = sprintf('%sSome notice%s', '

', '

');     echo $notices;      }      This also does not work (on either):               register_deactivation_hook(__FILE__, "gfahp_deactivate");          function gfahp_deactivate(){           add_action( 'admin_notices', 'gfahp_checks', 0 );      }     function gfahp_checks(){         $notices = sprintf('%sSome notice%s', '

', '

');         echo = $notices; // return does not work either      }      Javascript DOES work on deactivation but NOT uninstall:               register_deactivation_hook(__FILE__, "gfahp_deactivate");     function gfahp_deactivate(){         $notices = 'Some notice';         echo "";      }


title: Override private status - Enable users to read private posts

text: **Hidden private posts for not logged in users** The private posts are by default only visible when logged in. **Override, show private posts for everyone** Is there a clever way to override this? Make it visible to everyone? **404 page** I know about using it in queries but the big problem is the 404 page that is shown. Instead of 404 template it should use single.php template.


title: (Wordpress) How to get custom taxonomy parent name?

text:
I'm using **custom taxonomies** and **custom post type** in my blog and everything is running fine so far. The problem is, I've made a small query to list all my child categories, but now I can't get the name of each parent because of the condition on line 10. Here's my code:               <?php     $args = array(             'orderby' => 'id',             'order' => 'ASC',             'taxonomy' => 'album'     );                       $categories=get_categories($args);     foreach($categories as $category) {     if($category->parent!=0) {     ?>

             <a href="<? bloginfo('url'); ?>/album/<?php echo $category->category_nicename; ?>" rel="nofollow">                             <img src="<?php bloginfo('url'); ?>/covers/<?php echo $category->category_nicename; ?>.jpg" alt="">
                     <a href="<? bloginfo('url'); ?>/album/<? echo $category->category_nicename; ?>">                             <? echo $category->parent . ' - ' . $category->name; ?>

         <?         }     }         ?>      Any workaround?


title: Custom post type's slug gets wrong when adding a custom meta box

text: I'm trying for hours now to find the error moving back and forth. I have a custom post type. Everything works fine until I add my custom meta box. Now suddenly the slug gets the title of one of `$post->ID == '21'` child pages instead its own title when creating a new custom post. It always is the title from the page with the lowest `$post->ID`. But when I remove my custom meta box again. Everything works fine. I may have tracked it down to the `foreach` but I can't see what's wrong there. Besides this `%postname%` error everything's fine. The custom field gets saved correctly. I even can edit the slug manually. But that's not how it is supposed to be. Please help! * * * Tried it without the `<form>` tags now. Problem still persists. Calling `wp_reset_postdata()` didn't work as well. But I realized the slug always gets created right after I fill the title text input. Also when I edit the custom post later and change some content the slug gets wrong again.               add_action( 'init', 'cpt_init_cases' );     function cpt_init_cases() {       register_post_type( 'case', array(         'labels' => array(           'name' => __( 'Cases' ),           'singular_name' => __( 'Case' )),         'description' => 'Create cases to be displayed on single customer child pages',         'public' => true,         'menu_position' => 6,         'rewrite' => array('slug' => 'case'),         'supports' => array('title', 'editor', 'thumbnail', 'custom-fields')       ));     }          /*** when I delete everything below this line slugging works as expected ***/     add_action('admin_init', 'admin_init');     function admin_init(){         add_meta_box('refInfo-meta', 'Reference', 'reference_meta_callback', 'case', 'side', 'high');     }            function reference_meta_callback( $post ){            global $post;            $custom = get_post_custom($post->ID);       if( isset($custom['reference_id'][0]) ) {         $reference_id = $custom['reference_id'][0];       } else {         $reference_id = '0';       }            wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );            ?>         <form action="<?php bloginfo('url'); ?>" method="get">           <select name="ref_id" id="ref_id">             <option value="0" <?php selected($reference_id, '0'); ?>>- choose client -</option>                <?php           $args = array( 'numberposts' => -1, 'post_type' => 'page', 'post_parent' => 21);           $posts = get_posts( $args );           foreach( $posts as $post ) : setup_postdata( $post ); ?>             <option value="<?php echo $post->ID; ?>" <?php selected($reference_id, $post->ID); ?>><?php the_title(); ?></option>           <?php endforeach; ?>                </select>         </form>       <?php     }            add_action( 'save_post', 'save_reference_id' );       function save_reference_id( $post_id ) {            global $post;            if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;            if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;            if( isset($_POST['ref_id']) ) {         update_post_meta($post->ID, 'reference_id', $_POST['ref_id']);       }     }


title: wp uses index.php instead taxonomy.php

text: I have created taxonomy AUTO with terms and rewrite rules -               add_rewrite_rule("^auto/?$", "index.php?taxonomy=auto", "top")     add_rewrite_rule("auto/([^/]+/?)$", 'index.php?taxonomy=auto&term=$matches[1]', "top")      **The problem:** `site/auto/audi uses taxonomy.php` as WP must do, BUT `site/auto` uses `index.php`, while in both cases `$wp->query['query']['taxonomy'] = auto`.


title: Wordpress loop only displaying one post

text:
I don't know enough PHP perhaps to recognize immediately why the loop in my wordpress theme is only displaying one post and so I humbly ask for assistance.

                          <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                              <?php                                get_template_part( 'content', get_post_format() );                      ?>                            <?php endwhile; ?>                      <?php web2feel_content_nav( 'nav-below' ); ?>                  <?php else : ?>                      <?php get_template_part( 'no-results', 'index' ); ?>                  <?php endif; ?>

     <?php get_footer(); ?>      I believe that it then references the content.php file which is as follows               <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                                              <?php if ( 'post' == get_post_type() ) : ?>
                             <?php web2feel_posted_on(); ?>
                         <?php endif; ?>
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?>
                                                    <?php                         $thumb = get_post_thumbnail_id();                         $img_url = wp_get_attachment_url( $thumb,'full' ); //get full URL to image (use "large" or "medium" if the images too big)                         $image = aq_resize( $img_url, 780, 400, true ); //resize & crop the image                     ?>                          <?php if($image) : ?>                     <img class="img-responsive" src="<?php echo $image ?>"/>                     <?php endif; ?>
                         <?php the_excerpt(); ?>
                                                   <?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>                             <?php                                 /* translators: used between list items, there is a space after the comma */                                 $categories_list = get_the_category_list( __( ', ', 'web2feel' ) );                                 if ( $categories_list && web2feel_categorized_blog() ) :                             ?>                                                              <?php printf( __( 'Posted in %1$s', 'web2feel' ), $categories_list ); ?>                                                          <?php endif; // End if categories ?>                                  <?php                                 /* translators: used between list items, there is a space after the comma */                                 $tags_list = get_the_tag_list( '', __( ', ', 'web2feel' ) );                                 if ( $tags_list ) :                             ?>                                                              <?php printf( __( 'Tagged %1$s', 'web2feel' ), $tags_list ); ?>                                                          <?php endif; // End if $tags_list ?>                         <?php endif; // End if 'post' == get_post_type() ?>                              <?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>                         <?php comments_popup_link( __( 'Leave a comment', 'web2feel' ), __( '1 Comment', 'web2feel' ), __( '% Comments', 'web2feel' ) ); ?>                         <?php endif; ?>                              <?php edit_post_link( __( 'Edit', 'web2feel' ), '', '' ); ?>
      Any help would be appreciated. Thank you. Also this has nothing to do with the wordpress backend settings. They are indeed set to show 5 posts on the blog page.


title: pre_get_posts returns non property object when using posts__not_in

text: I'm displaying posts from a category and want to show all but the first one using posts__not_in. The code below is returning a property of non object error.               function modify_onthisday_cat( $query ) {              if ($query->is_category(7) && $query->is_main_query() ) {                  global $post, $wp_query;                  set_query_var( 'day', date('d') );             set_query_var( 'post__not_in', array($post->ID) );                  return;         }     }     add_action( 'pre_get_posts', 'modify_onthisday_cat');      If I replace $post->ID with a specific post id, it will work, but I need it to be dynamic. From what I understand this action is ran before the query so getting that id dynamically is going to take some more work. I'm just not sure how to get there. Edit (clarification): Currently, I have a category page served up with the category.php template. I have a featured post displayed above and the remaining posts displayed below. The featured post is called from a custom function and the remaining posts are called from the default wordpress loop. My goal is to show the posts below while not showing the first post and preserving pagination.


title: Fetching data from other website in wordpress

text: I am developing a website in which I want that on clicking a push button named "Get date" the client get's to know the date. The data will be fetched from supremecourt of India's website...the data required for fetching the date will be filled in my website..Is it possible to do so??


title: 3.1 update erases customized function page?

text: I recently performed the 3.1.1 update on a localhost install, but first performed a backup of my entire wamp directory. Once the install was complete, it seems all the edits to my functions page are now gone. This was my custom post types & taxonomies. I have my backups, so I guess I can just copy and paste. but will I have to do this every time there's an update? Did I perform the update wrong? Don


title: Wordpress | Sub-domain switching

text: I'm finding a way to redirect to a sub-domain. Sub-domains contain instances of multiple languages, say for an example -: `http://mysite/?p=7694` This is the English site and I want it to redirect to (when user selects particular language)               http://chinese.mysite/?p=7694      Is there a simple way of doing this want to know if there are any plugins to do so. This the requirement of my client, and they wont to do it in that way. Thanks.


title: How to keep track of new plugins published on wordpress.org?

text: Is there any RSS feed to keep track of the Newest Plugins published on wordpress.org?


title: Missing current_page_item in custom menu

text: I'm using the new custom menus in my side navigation and it only creates a class sub-menu in the `UL's` but does not use the `current_page_item` like when you use `wp_list_pages()`. I have 3 levels and only want to show the sub menus of the page you are on, easily done using `wp_list_pages()` but I can't do it with the custom menus? Can someone please help? Thanks


title: How to put Stack Exchange Flair as widget?

text: I want to put my flair in as a widget in the top of my sidebar in my blog. There was a similar question asked here but the only answer links to the flair page and suggests copying and pasting the html into the theme. I don't want to edit my theme, I want to be able to add is as a widget. Is this possible?


title: Where sales manager of WP-Commerce plugin?

text: This is screenshot after when i installed wp-commerce plugin ![enter image description here](http://i.stack.imgur.com/cx7tZ.png) This is manager screenshot on ecommerce plugin website http://getshopped.org/wp-content/uploads/2010/01/screenshot-install-06.jpg i can't to find out sales manager like as on ecommerce website.


title: Display post titles that match string in post content

text:
I'm trying to search through the content of the current post and look for any strings in the content that match the title of any 'term' custom post types. The idea is that any terms we have that are in the post description are right there for a user to view if they need clarification. This script works perfectly when I put in any string for the variable $content_search, but stops working properly when I set               $content_search = get_the_content();      It spits out the matching terms, but also a few seemingly random ones as well. I've been staring at this block of code for quite some time and I just can't figure out what's wrong. Any help would be awesome!                                   <?php                                  // search for matching glossary terms that are in the description                                  $content_search = get_the_content();                             $content_search = strtolower($content_search);                                  $args_terms = array(                                 'post_type' => 'term',                                 'orderby'   => 'title',                                 'posts_per_page' => -1                                 );                                  $glossary_terms = new WP_Query($args_terms);                                  echo '
Terms Used in this Lesson:
';                                  while ($glossary_terms->have_posts()){                                 $glossary_terms->the_post();                                 $tt_title = strtolower(get_the_title());                                      if (strpos($content_search, $tt_title) !== false){                                          $tt_title = ucwords($tt_title);                                     $tt_content = strip_tags(get_the_content());                                     echo do_shortcode('[tooltip tooltip_title="' . $tt_content . '"]' . $tt_title . '[/tooltip]');                                     echo ' | ';                                     }                                 }                                      wp_reset_postdata();                             ?>


title: Display all categories as plain text

text:
Within my loop i'm currently outputting one category that a post is assigned to as plain text. Its being used as a class name within my markup (not visible to users) but if a post is assigned multiple categories, my code below only outputs one category, how do I get ALL categories (that the post has assigned to it) to appear as class names instead?               <?php //begin new query                     $project_query = new WP_Query('cat=14,15,16,17,18,19');?>                          <?php while ($project_query->have_posts()) : $project_query->the_post(); $do_not_duplicate = $post->ID; ?>                                                                          <div class="element <?php $category = get_the_category(); echo $category[0]->category_nicename; ?> sports">
                                 <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">                                          <img src="<?php the_field('leading_image') ?>" />
<?php the_title(); ?>

                          <?php endwhile; wp_reset_query(); ?>


title: Is there a limit on the number of attachments?

text: It seems there's a limit on the number of attachments of a post? I have 265 images uploaded for one of the posts (yes, I know it's quite a few), and when I want to put them into order. The result: only 125 of them gets number, the others a left without one and also I only see 140 images. The tabs says "gallery (265)", and it is ok, but I only see 140 images when I open the gallery tab.


title: Query posts alphabetically within this function

text:
I've been given some code to tidy up and edit a bit and the client wants to organize a custom post type named "plans" alphabetically. It's not a straight forward query and I've never come across anything like this before, any ideas?               <?php $planIDs = get_post_meta($post->ID, '_lm_comm_plans', false); ?>     <?php foreach ($planIDs as $planID) : ?>         <?php $pdfID = get_post_meta($planID, '_lm_plan_pdf', true); ?>             <?php $pdfURL = wp_get_attachment_url($pdfID); ?>                 <?php $planTitle = get_the_title($planID); ?>

     <?php endforeach; ?>


title: my blog crashes ie7?

text: hey guys, weird problem. My blog theme works fine in ie8, ie9 and all other major browsers... however ie7 doesn't even render it? in ie7 it seems like my blog even has serverside problems? ![enter image description here](http://i.stack.imgur.com/MEh09.png) any idea what could cause that? In my programming history i've encountered ie7 styling issues and stuff but never something like this that the webpage doesn't even get rendered? Sometimes the page is kind of loaded in ie7, however the browser does crash anyway. any idea what could cause that? If sometimes the page gets loaded in ie7 the bar at the bottom says: "loaded but with errors" ... I do not have a single error if I validate the page!


title: Open a wordpress single post in a lightbox without the header and footer

text:
I am developing a plugin which requires to open a single wordpress post inside of a lightbox. Here are a few details :   * Currently,I am using colorbox for lightbox. The lightbox is triggered to open an external .php file which received the post id as $GET variable.   * Only the Title, Meta information, Content and comments part should open in the lightbox and not the theme header and footers.   * All the shortcodes , embedded youtube links etc should work in the opened post.   * It would be great if there is a way to pick up the current theme's single.php file, strip the header , sidebar and footer from it and display only the formatted content. But i believe that depends on themes and is not a generic solution Here is the current plugin link :http://test.anshulsharma.in/ The current code for the external php file is :               if(!function_exists('get_post'))     {     require_once("../../../../wp-load.php");     }     $thepost = get_post($_GET["ID"]);     $thecontent = $thepost->post_content;     $thetitle = $thepost->post_title;     $thelink = get_permalink($_GET["ID"]);     ?>         <div id="cg-post-container" style="width:<?php echo get_cg_option('lightbox_width'); ?>px;">
         <a href="<?php echo $thelink; ?>"><?php echo $thetitle; ?>

                   <?php echo $thecontent; ?>

      In the current version of the plugin, only the posts content shows up. Shortcodes dont work and embeded links dont show up. Also there is no way to view or add comments. I am willing to write a custom single.php file for this and add my own styling . But i just want to know the BEST way to do it and also how to communicate the post id (from the $GET variable to the single.php) to the lightbox.


title: Closest post to a date

text: So I've got a wordpress blog I've been posting to once a week for a couple of years - I'd like to be able to press a button, or use a bookmarklet, or edit the url in such a way that I see that I see the post from a year ago. For example if the date is 31 December 2012. I'd like to be able to retrive the post that was made closest to 31 December 2011. Any ideas?


title: Problem with WordPress output text ('esc_html' & 'wp_richedit_pre')

text: I have a problem with output text. When I editing text in the WordPress control panel everything looks normal: http://i.stack.imgur.com/GaIut.png but when I output it to the html:               <?php esc_html( wp_richedit_pre( $_product->details ) ); ?>      It looks like this: http://i.stack.imgur.com/r81xE.png What could be wrong? Please for help.


title: can I 'combine' categories as a menu item?

text: I have custom post type and I want to have a menu where I combine category or categories from default Wordpress post type and from my custom post type. Let's say I have these categories   * sport, books, movies, any in default post type   * sport, books, school, any in my custom post type can I have a menu link where I would display   * **sport** posts from both post types?   * **sport, books** posts from default post type and **any** from my custom post type?


title: Where do I start from

text: I'm student web developer and I'd like to know the things I should know before venturing into WordPress. Where do I start?


title: Proper procedure for wp_insert_post?

text: I just found the magnificent wp_insert_post function and have a few basic question about it. *For reference I used this on a multisite install for a number of blogs running theme_x. I simply wanted to add a page to each blog (without having to do it through WP Admin). This seems to have mostly-worked though I'm not sure I'm using it for its intended purpose?   1. **What happens if the specified page title already exists on several blogs?** Does it a) terminate the function b)rename in typical WP fashion to "page-name-2" format, or c) something else?   2. **Should I remove the code from the theme template now that I have done what I needed to?** I'd like to leave it in just incase more blogs are added which use this theme but I'm wondering if it creates unnecessary database overload (does it get run every page load)?   3. **The page doesn't appear anywhere in WP admin?** Though all blogs using this theme do indeed resolve to the newly-added page like so ... URL/newly-added-page. This is fine for me in this instance, but it makes me think I'm not using the function "properly" (I kinda expected a new page in WP Admin also)


title: Save Theme Options (options.php) From The Frontend

text: I try to save an option from the frontend but i can't find yet how to do it.   So, the idea is to give the blog owner a simple form with a dropdown that can select a different stylesheet.css. I have build it for the wp-admin area and it works fine, but i want to do the same in the frontend, i have tried to include the wp-admin/options.php in the header but nothing, just errors,   i post the form to "wp-admin/options.php" but it redirect me in the wp- admin/options page. here is the frontend form:               <form id="save-theme" name="save-theme" action="/wp-admin/options.php" method="post">     <select>         <option>Select Theme</option>         <option>Red</option>         <option>Dark</option>         <option>White</option>     </select>     <button name="update-options" type="submit">Save</button>     <?php wp_nonce_field('update-options'); ?>     </form>      thanks a lot!


title: How to list users that have written custom post types and hide the ones that have not?

text:
I'm trying to build an author list that would show all authors that have written a Custom Post Type post, and hide authors that have no posts. With `wp_list_authors` it would be easy to show users that have written Posts (not CPT). This does not show the users that have published Custom Post Types, it affects only to Posts.               wp_list_authors('hide_empty=1');      I looked in to the `get_users` function but managed to only build a list with it (more control over the list but not what I was aiming for).                $blog_url = get_bloginfo('home');      $blogusers = get_users('orderby=display_name&role=editor');      foreach ($blogusers as $user) {         echo '
user_login . '">' . $user->display_name . '
';       }      I found this really nice post dealing with how to show the post counts in the backend. It defines a function `_yoursite_get_author_post_type_counts()` that could possibly maybe be some help in this... Any idea how to do this? Thanks! :)


title: Display a post map on a blank/new page

text:
On my single.php file I am displaying the_title(), the_content() and a link to a Google Map (Javascript v3). Lat/Lng coordinates for each location map are held in two separate meta fields attached to each post. How can I structure my single.php file to grab the Lat/Lng values and display only the map when the map link is clicked? I think I need to append the lat/lng values to my permalink somehow and then when single.php notices these values present it strips out everything except:

      I am using jQuery Mobile as the presentation layer for this project and have pretty permalinks enabled. My single.php file looks like:               <?php get_header(); ?>     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                    <?php the_title(); ?>          <?php the_content(); ?>          <a rel="external" href="<?php echo get_permalink(); ?>">Map

          <?php endwhile; ?>     <?php endif; ?>     <?php get_footer(); ?>      While in the head of my template I call a simple JS file as below:                     Thank you.


title: remove empty paragraphs from the_content?

text:
Hey guys, I simply want to prevent the creation of empty paragraphs in my wordpress post. That happens quite often when trying to manually space content. I don't know why this doesn't take effect?               /*Remove empty paragraph tags from the_content*/     function removeEmptyParagraphs($content) {              /*$pattern = "/
]*><\\/p[^>]*>/";            $content = preg_replace($pattern, '', $content);*/         $content = str_replace("

","",$content);         return $content;     }          add_filter('the_content', 'removeEmptyParagraphs');      edit/update: seems like the problem is this:               function qanda($content) {              // filters for [q=some question] and [a=some answer]         // wraps it inside of

         $content = preg_replace('/\[q=(.+?)].+?\[a=(.+?)]/is', '

$1

$2

', $content);              return $content;     }          add_filter('the_content', 'qanda');      i did this function myself to filter for a kind of shortcode pattern in my posts and pages. Even though in my backend the post is completely done without paragraphs and unnecessary spacings the outcome looks like this:

...

...

...

      any idea where this empty p's come from?


title: Easy way to update a single translation entry without having to translate

text: I'm using the "Featured Image" meta box which allows you to attach a secondary thumbail to a post. The title for this box is defined in the Wordpress codebase like so:               __('Featured Image')      Which looks to be a wrapper for the translate methods. I'm wondering how to change this text without having to do any translation files. Is it as simple as an action or filter hook?


title: Custom post type pagination error

text:
Another one of these paging errors you see here so often. I searched high and low for a fix but have come up with nada so far. I am paging CPT results using my archive-{$post_type}.php template and getting an incomplete return of posts. I have set posts_per_page to 8, and am return 3 pages to get 24 results. There are 27 posts, so I am missing 3 (ie. paging falls short of showing last 3 posts). Here's my template file (HTML stripped for clarity):               <?php   /* SET UP */                  wp_reset_query();                  // Selected team member             $team_member_id = $_GET['member'];                  // Top post by menu order             $top_post = get_posts('post_type=team&numberposts=1&orderby=menu_order&order=ASC');             $top_post_id = $top_post[0]->ID;                       // Set $current_team_member_id             if ($team_member_id) {                 $current_team_member_id = $team_member_id;             } else {                 $current_team_member_id = $top_post_id;             }          ?>               <?php   /* MENU */                  // Paging             $page = (get_query_var('paged')) ? get_query_var('paged') : 1;                  // Args             $args = array(                 'post_type'=> 'team',                 'posts_per_page' => '8',                 'paged' => $page,                 'orderby' => 'menu_order',                 'order' => 'ASC',             );                       // New instance of WP_Query             $loop = new WP_Query($args);                       if ($loop->have_posts()) :          ?>               <?php next_posts_link('Next' ); ?>     <?php previous_posts_link('Back' ); ?>               <?php while ($loop->have_posts()) : $loop->the_post(); ?>          <?php   $post_id = get_the_ID();             $postclass =  '';                  if( $current_team_member_id == $post_id ) {                      $postclass = 'current';                   } elseif ( $top_post_id == $post_id && $current_team_member_id == NULL) {                      $postclass = 'current';                   } else {                      $postclass =  'post';                   }                   $url = get_bloginfo('url').'?post_type=team&member='.$post_id.'&paged='.$page;           ?>          <a id="team-member-<?php print $post_id; ?>" href="<?php print $url; ?>" class="<?php print $postclass; ?> <?php print $top_post_id; ?>"><?php the_title() ;?>
     <?php echo get_post_meta( $post->ID, '_exit_member_metabox_pos', true ); ?>          <?php endwhile; ?>               <?php   /* MEMBER PROFILE */                  $current_team_member_post = get_post($current_team_member_id );              setup_postdata($current_team_member_post);          ?>          <?php echo $current_team_member_post->post_title; ?>     <?php echo get_post_meta( $current_team_member_id , '_exit_member_metabox_pos', true ); ?>     <?php the_content(); ?>     <?php echo get_the_post_thumbnail($current_team_member_id, 'pic-third'); ?>                    <?php else: ?>
Sorry, but this content is not available.
          <?php endif; ?>      What am I doing wrong? What's missing?


title: Adding Widget form fields dynamically

text:
I am trying to add form field to a WordPress widget dynamically. So if the user want to add another date to an event they can click a button to get more fields. The question is: **How do save newly created input fields to my database?** Do i need to write a custom update function? Any tips? This is how the widget looks: ![enter image description here](http://i.stack.imgur.com/sn2kO.png) This is my php code for the widget (so far):                   class Spillelister extends WP_Widget {              public function Spillelister() {                  $widget_options = array (                 'classname' => 'spillelister-widget',                 'description' => 'Widget for å illustrere spillelister.');                  parent::WP_Widget('spillelister_widget', 'Spilleplan', $widget_options);         }              // The actual widget user interface         public function widget($args, $instance) {                  extract( $args, EXTR_SKIP);             $title = ( $instance['title'] ) ? $instance['title'] : 'Spilleplan';             $body = ( $instance['body'] ) ? $instance['body'] : 'Ingen flere forestillinger';                  ?>                      <?php echo $before_widget; ?>                 <?php echo $before_title . $title . $after_title; ?>
<?php echo $body; ?>
                  <?php         }              public function update() {              }              public function form() {         ?>

                 Dato <input type="text" class="datepicker">
                 Tid <input type="text">                 Remove

                 Add fields
              <?php          }               }          function spillelister_init() {         register_widget('Spillelister');         }     add_action('widgets_init', 'Spillelister_init');      Any tips, hints or answers are appreciated. :)


title: Post revisions don't save or show up only for custom post types

text: My website makes use of a number of custom post types as well as the traditional "posts" and "pages" types. For all "posts" and "pages" revisions show up as they should, with a history of edits visible, the option to compare posts, and so on. For all custom post types, I have no revision history at all. I've enabled revisions when defining each of these post types in functions.php, so on each of these post types I get a blank tab that says "Revisions" but does not display or collect any revisions data. I'm at a loss for how to fix this and any help would be appreciated! Thanks in advance for any assistance.


title: How can I create podcast posts automatically from the contents of a particular directory?

text: All of the Wordpress Podcasting plugins I have seen allow you to easily insert a podcast into a post. Is there any way to automate the creation of the post (and the podcast feed) by simply uploading the podcast into a specific directory? For example I could upload 10 podcasts into the `/media/` directory and then it would automatically create a post for each of the 10 files I uploaded. Ideally it would take the information from the ID3 tags. The key factor here is not having to do anything in wordpress after the initial setup.


title: How to allow visitors to enter custom post type?

text: I wanted to use a custom post type to create a "share your story" type of feature. People would fill in the text boxes and "share their story". This would then be automatically posted on to a stories page. But I can't figure out how to have the data entry page be a decent looking page instead of one of the admin pages, i.e. I want the data input screen to be on the front end instead of the back end. Does anyone have any examples/tutorials on how to do this?


title: $wp_query->current_post restarts from zero on paged pages

text: I know how to keep track on the 'index' of the current post when running the loop using               $wp_query->current_post      Bu this restarts the count from zero on subsequent paged pages. So if I have 20 posts, and show 5 posts per page, then on page 2 the posts are again numbered 0-4 instead of 5-9. My question is: Is there a build in way to get the absolute index when running the loop on a paged page, or do I have to calculate the offset myself, using information about page number and posts per page?


title: Help with WP Business Directory Manager Plugin?

text: I'm using the WP Business Directory Manager plugin and I'm having some problems. The developer hasn't been supporting the plugin lately, so here I am.   * I need to change the field order. Currently the option is there, but it doesn't work.   * I need to target the field for CSS purposes, with custom classes/ids   * And I need to be able to query the post from certain categories from its directory. I would want to post different list on throughout the site and Im not sure how to do that. The plugin is very useful, I just need some help with these issues...PLEASE. Thanks for any help that can be provided.


title: How to use widget in a widget-less WordPress theme?

text: I have a widget-less WordPress theme to which I want to add Subscribe by Email functionality. Unfortunatly the plugin only comes in the form of a widget. How can I use the widget functionality without widget support.


title: Removal of all posts content in bulk, keeping the posts itself

text: How to, using PHP scripting or WordPress overwrite all of the posts (permamently, so it takes effect on database) with some static text such as "Content removed."?


title: Run functions only in the admin area?

text: I'd like this code to only run inside the admin area as it is resorting the items on the public side admin bar too.                 /* Reorder Admin Menu to put "Pages" at the top */       function menu_order_filter($menu) {       $content_menu = array('edit.php?post_type=page');       array_splice($menu, 2, 0, $content_menu);       return array_unique($menu);       }       add_filter('custom_menu_order', create_function('', 'return true;'));       add_filter('menu_order', 'menu_order_filter');


title: Pick out specific menu item from code

text:
I'm using this bit of code to generate a menu:
       <?php $args = array(         'depth'        => 1,         'show_date'    => '',         'date_format'  => get_option('date_format'),         'child_of'     => 0,         'exclude'      => '426, 508',         'include'      => '',         'title_li'     => __(''),         'echo'         => 1,         'authors'      => '',         'sort_column'  => 'menu_order, post_title',         'link_before'  => '',         'link_after'   => '',         'walker' => '' ); ?>

<?php wp_list_pages( $args, 'sort_column=menu_order' ); ?>

      It's generating the menu fine but one of the links I need it to goto another page. Is it possible to pick out that page by ID and tell it to goto a different address? If so, how can I do it?


title: URLs ending with number higher than 2147483647 redirects to to domain.com/2147483647

text: I've got a javascript implented on my Wordpress site with the purpose to the substring of the URL and if it matches some criteria, it'll load a specific piece of content. So, if you input this URL for example `http://domain.com/subpage/84708495222` it should catch `84708495222` and find the content associated with this number. This works as intended. BUT, the problem is that Wordpress for some reason redirects `http://domain.com/subpage/84708495222` into `http://domain/subpage/2147483647`. I guess it's due to some sort of rewriting mechanism in Wordpress. Is there some way to avoid this? `84708495222` in this example is not generated by me, and cannot be changed to a lower number..


title: How to get rid of the username of registration form in theme my login wp plugin?

text: I have tried disabling the username in the functions.php through                if(!is_admin()){       remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );       add_action( 'personal_options', 'prefix_hide_personal_options' );     }     function prefix_hide_personal_options() {     ?>     <script type="text/javascript">       jQuery(document).ready(function( $ ){     $("#registerform #user_login, #your-profile #user_login, #your-profile #nickname, #your-profile #display_name, #your-profile #url,  #your-profile #description").parents("div.form-group").hide();       });     </script>     <?php     }      I have added this id name #registerform #user_login to be hidden but nothing happens in the registration form page, still username is showing up. Any idea that could help me point out the problem and what to do. I am newbie in wp, don't have yet solid understanding in plugins.


title: Custom Search Form WP_Meta_Query - Filtering Custom Fields

text:
I'm trying to build a search form that will filter users based on their custom fields. These custom fields are things like 'company_name' 'user_country' etc. I have some code and I am having a small amount of success with things so far. I can search for cities for example, but I am not sure if these cities are actually relating to the city names I have created. I think it's better if I show a code example:               <?php     function aio_search_meta_data($atts, $content = null) {     global $wpdb;          extract(shortcode_atts(array(         "role" => '',         "number" => 3,         ), $atts));          // Search general terms      $search_term = (isset($_GET['aio_keyword_search'])) ? sanitize_text_field($_GET['aio_keyword_search']) : false;          $number = sanitize_text_field($number);     $page = (get_query_var('paged')) ? get_query_var('paged') : 1;     $offset = ($page - 1) * $number;     // Set up the Query     if($search_term) {     $meta_query_args = array(         'meta_query' => array(             'relation' => 'OR',             array(                 'key' => 'user_city',                 'value' => $search_term,             ),             array(                 'key' => 'user_country',                 'value' => $search_term,             ),             array(                 'key' => 'user_company',                 'value' => $search_term,             ),         ));     // Instantiate a new object      $meta_query = new WP_Meta_Query($meta_query_args);     // Retrieve SQL     $mq_sql = $meta_query->get_sql(         'user',         $wpdb->users,         'ID',         null     );           } else {     $meta_query_args = new WP_User_Query(         array(             'role' => '',             'offset' => $offset,             'number' => $number,             'meta_query' => array(                 'key' => 'user_country',                 'value' => ''             ),             'meta_key' => 'company_name',             'orderby' => 'meta_value',             'order' => 'ASC'         ));      } ?>               <form class="member-directory-listings" method="get" action="<?php the_permalink(); ?>" role="form">

                 <input type="text" name="aio_keyword_search" id="aio_keyword_search" class="form-control" placeholder="Enter Keywords">                 Search for network partners by country, city, or company name

                 <select class="form-control" name="aio_countries">                     <option value="">Value</option>                 </select>

                 <select class="form-control" name="aio_countries">                     <option value="">Value</option>                 </select>

                 <select class="form-control" name="aio_countries">                     <option value="">Value</option>                 </select>

     <input type="submit" class="grey-btn" value="Search">     </form>               <?php      if(!empty($mq_sql)) { ?>

                 Logo	                 Company Name	                 City	                 Country

          <?php     foreach($mq_sql as $mq) {         $args = array(             'role' => '',         );         $author_info = new WP_User_Query($args);          $author_details = get_userdata($mq->ID);?>
                              <img class="member-profile-img small-image-bg" src="<?php echo $author_details->image; ?>" alt="User image" />             	                          <a href="<?php echo get_author_posts_url($mq->ID); ?>"><?php echo $author_details->company_name; ?>             	                              <?php echo $author_details->user_city; ?>             	                              <?php echo $author_details->user_country; ?>             	             <?php }  ?>

      I have to complete this project by Friday. Can anyone help me to put this form together? I need to be able to create drop downs too with predefined information.


title: Return a custom value in a function added to an action hook

text: I looked into the difference between action and filter hooks, and as far as I understand, it is not possible to have a function, which is added to an **action** hook, **return a (custom) value**. My scenario:   * Upon saving a post, I **try** to save another post. Therefore I use `add_action( 'save_post', 'create_another_post');`   * Depending on some conditions, saving this additional post takes place (for that case I'd like to return `true`) or it doesn't (return `false`) How would I go about implementing this `true/false` scenario? I appreciate your help and ideas.


title: Why doesn't my simple the_title filter get applied?

text: I have added the code below to an active plugin, but it's having no effect on my posts.               add_filter( ‘the_title’, ‘myfunction’);          function myfunction($title) {      return "Why won't this work?" . $title;     }      What am I missing here? The post templates are definitely using the_title(), and the theme is normal (wp_head(), etc), and there are no conditionals surrounding the function in the plugin that would make it not run. I have also tried adding different priority in the add_filter function, from -9999 to 9999, to no effect.


title: Is that possible show user's post after user login

text: I have website, Administrator setup one post for each register user, only this user can see it when he/she login.(the author of the post is the user's name). I think when user login just search user name equal to author name will be fine. The question is how to do it, I don't know too much about PHP, Hard to make it work. He is some code, maybe useful.                 <?php     if ( is_user_logged_in() ) {     echo 'Welcome, registered user!';     } else {     echo 'Welcome, visitor!';     }     ?>


title: One taxonomy template for all categories?

text: I'm looking at the Codex about template hierarchy. However, I have a custom post type with many categories from a custom taxonomy I created also. This post type allows users to add new categories to their posts. I read in the codex that I can create a `taxonomy-{taxonomy-name}.php` template file for each of my taxonomies. What I am wondering is if I can create one template file to "catch" all of the CPT's categories.


title: change menu item names from front

text: how do i change current menu item names? I have a form that gets the new names the user chose from front. I can not find anywhere a function that handles it. this function:                wp_nav_menu_update_menu_items()      returns an error that says there is no such function. Should I change the information directly in the database? Or is there a simpler way to do this?


title: Cannot get Jquery to work with wordpress

text: I can't figure out why Jquery isn't working on my Wordpress site. Am I setting it up right? Any help or suggestions is appreciated! Thanks. Here is what I have in my function.php                function my_scripts_method() {          wp_deregister_script( 'jquery' );          wp_register_script( 'jquery', 'ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js');      wp_enqueue_script( 'jquery' );     }              add_action('wp_enqueue_scripts', 'my_scripts_method');      and on my header.php               <!DOCTYPE html>     <html>     <head>         <meta charset="<?php bloginfo('charset'); ?>">                 <title>          <?php             wp_title('-', true, 'right');             bloginfo( 'name');         ?>         </title>         <?php wp_head(); ?>         <script type="text/javascript" src="js/script.js"></script>         <meta name="viewport" content="width=device-width, initial-scale = 1.0">           <!--[if lt IE 9]!>      <script src="dist/html5shiv.js"></script>      <![endif]-->     </head>


title: How to check homepage contain blog post?

text: I try to add some content on the post excerpt in wordpress. For a category page excerpt condition working perfect. but i am not sure how to check in home page i tried is_home and is_front_page like that                   function addtoexcerpt($excerpt) {         ob_start();              $values = ob_get_clean();         return $values.$excerpt;              }     if(is_single()||is_category()||is_front_page()) {         add_filter('the_excerpt','addtoexcerpt');     }      But for homepage itself is not come's up, i a homepage there is 3more columns with these one of the column as blog post how to check the homepage blogpost in order to append the content I am using expound theme template. Thanks vicky


title: Wordpress with broken paging page 3

text:
I am working with a blog page that uses the following query:               <?php         $paged = (get_query_var("paged")) ? get_query_var("paged") : 1;         query_posts("category_name=blog&posts_per_page=2&paged=".$paged);     ?>      and my pagination looks like:               <?php         $next = get_next_posts_link("Next >>");         $prev = get_previous_posts_link("<< Prev");         if ($prev || $next) { ?>
         <?php } ?>         <?php if ($next) { ?>
                 <?php echo $next; ?>
         <?php } ?>         <?php if ($prev) { ?>
                 <?php echo $prev; ?>
         <?php } ?>         <?php if ($prev || $next) { ?>

         <?php } ?>         <?php if ($prev || $next) { ?>
         <?php }      ?>      The pagination is working to a certain extent...I see the previous and next links and can click next until I get to page 3, instead of arriving at page 3 I get a 404, which is weird because I know there is more content WordPress just doesn't display it for some reason. Anyone know what could be causing this issue, the weird thing is I am using the exact code on another website without error :-( The permlinks are set to the default and I am not using a custom post type. Thanks,   Josh


title: Self-hosted blog Admin Panel Forwarding to WP.com

text: I was goofing with the settings (first problem) in the "General" tab of my wp- admin panel on my self-hosted blog. There are two settings: Wordpress.com URL and Blog URL (or something). They were both originally set to my self-hosted `www.domain.com/blog`. I thought if I changed the Wordpress.com URL to an empty blog that I set up on Wordpress `www.myblog.wordpress.com` that it would simply connect the two blogs so that my site went into the Wordpress.com directory. **This did not happen.** Now, if I visit MY self-hosted URL, I see my blog, but it's clearly missing a stylesheet. And now I can't access the admin panel of my own blog. I don't know what happened. Can I remedy this? Is there a file on my server where I can just edit the line that I changed and switch it back to what it should be?


title: Wordpress query fire inner join in one table 5 times?

text: Dear friends this is my arguments for WP_Query.               $args = array('post_type' => 'job_listing',     'relation' => 'OR',         'meta_query' => array(             'relation' => 'OR',             array(                 'key' => 'app_trailer-type',                 'value' => $job_tailor,                 'compare' => 'LIKE'             ),             array(                 'key' => 'app_pay-type',                 'value' => $app_pay_type,                 'compare' => 'LIKE'             ),             array(                 'key' => 'geo_address',                 'value' => $geo_address,                 'compare' => 'LIKE'             ),             array(                 'key' => 'geo_country',                 'value' => $geo_country,                 'compare' => 'LIKE'             ),             array(                 'key' => 'geo_short_address',                 'value' => $geo_short_address,                 'compare' => 'LIKE'             ),         ),     );      WordPress Returns query like.               SELECT SQL_CALC_FOUND_ROWS wp_posts.id     FROM   wp_posts            INNER JOIN wp_postmeta                    ON ( wp_posts.id = wp_postmeta.post_id )            INNER JOIN wp_postmeta AS mt1                    ON ( wp_posts.id = mt1.post_id )            INNER JOIN wp_postmeta AS mt2                    ON ( wp_posts.id = mt2.post_id )            INNER JOIN wp_postmeta AS mt3                    ON ( wp_posts.id = mt3.post_id )            INNER JOIN wp_postmeta AS mt4                    ON ( wp_posts.id = mt4.post_id )     WHERE  1 = 1            AND wp_posts.post_type = 'job_listing'            AND ( wp_posts.post_status = 'publish'                   OR wp_posts.post_status = 'expired'                   OR wp_posts.post_status = 'tr_pending'                   OR wp_posts.post_status = 'tr_failed'                   OR wp_posts.post_status = 'tr_completed'                   OR wp_posts.post_status = 'tr_activated'                   OR wp_posts.post_status = 'private' )            AND ( ( wp_postmeta.meta_key = 'app_trailer-type'                    AND Cast(wp_postmeta.meta_value AS CHAR) LIKE '%Flatbed%' )                   OR ( mt1.meta_key = 'app_pay-type'                        AND Cast(mt1.meta_value AS CHAR) LIKE '%Per Week%' )                   OR ( mt2.meta_key = 'geo_address'                        AND Cast(mt2.meta_value AS CHAR) LIKE '%Davenport%' )                   OR ( mt3.meta_key = 'geo_country'                        AND Cast(mt3.meta_value AS CHAR) LIKE '%United States%' )                   OR ( mt4.meta_key = 'geo_short_address'                        AND Cast(mt4.meta_value AS CHAR) LIKE '%Davenport%' ) )     GROUP  BY wp_posts.id     ORDER  BY wp_posts.post_date DESC     LIMIT  0, 10        please help, i can't understand why it creates inner join 5 times on one table.


title: Update woo-commerce cart content on post update

text: I am using the woo-commerce plugin for a payment gate-way when I did add to cart first time that time I am inserting the product to cart it's working good.Just having the issue with how to update cart if I added cart before in same session.I tried lots of but not getting any idea how to do it.               <?php         add_action('init', 'customcart');                    function customcart() {              // simple form for testing                      if (isset($_POST["addcustomcarts"])) {               echo"mypostif";             global $woocommerce;           if(empty($_SESSION['update_post'])){                 echo"mypostif2";             $my_post = array(               'post_title'    => 'My post',               'post_content'  => 'This is my post.',               'post_status'   => 'publish',               'post_author'   => 1,               'post_type'     =>'product'             );             // Insert the post into the database             $product_ID = wp_insert_post( $my_post );             $postupdate=1;              $_SESSION['update_post']=$postupdate;              if ( $product_ID ){               add_post_meta($product_ID, '_regular_price', 100 );               add_post_meta($product_ID, '_price', 100 );               add_post_meta($product_ID, '_stock_status', 'instock' );               //Getting error on this line.               $woocommerce->cart->add_to_cart( $product_ID, $quantity=1 );               exit( wp_redirect( get_permalink( woocommerce_get_page_id( 'cart' ) ) ) );               echo"mypost1";             }           }         else             {                 $my_post = array(               'ID'=> 426,               'post_title'    => 'My post222222',               'post_content' => 'This is the updated 55545content.'           );         // Update the post into the database           wp_update_post( $my_post );             echo"mypost2";             exit( wp_redirect( get_permalink( woocommerce_get_page_id( 'cart' ) ) ) );         }           }           }         ?>


title: Load a template for add menu page

text: How to load a template from twentytwelve theme for add menu page function.               add_action( 'admin_menu', 'register_my_custom_menu_page' );          function register_my_custom_menu_page(){     add_menu_page( 'custom menu title', 'custom menu', 'manage_options',   'custompage', 'my_custom_menu_page', plugins_url( 'myplugin/images/icon.png' ),   6 );      }          function my_custom_menu_page(){     echo "Admin Page Test";       }          In the function my_custom_menu_page, i need to load a template or show a web page instead of echo something.How can i do this.      Please help.


title: add_action second argument missing

text: I don't know what is missing here. I have a **do_action()** and **add_action()**. Only the first argument passed, to the function:               function testing($a, $b) {         echo $a . $b; // Here is just get A, and an error for missing $b     }          $a = 'A';     $b = 'B';     do_action('test', $a, $b);          add_action('test', 'testing');


title: Making Wordpress-built website mobile friendly

text: I have a website that is built with `WordPress` but hosted on GoDaddy. I need to make it more mobile-friendly. I installed `WPTouch` and the `WordPress- Mobile Pack` to do so. However, I find that even after installing the plugins and re-installing the website on `GoDaddy`, the site remains mobile- unfriendly. Writing to GoDaddy support did not help much either since I was redirected to WordPress support. My question(s):   1. How do I make a WordPress website that is hosted by GoDaddy mobile compatible?    2. How do I activate plugins like WPTouch on GoDaddy?


title: Assign tags records that have a keyword

text: I have a lot of records without labels, I want to assign a specific tag such records. If the name of the record found a certain word, then it is assigned a specific tag. I think it can be done through SQL-query, but how to realize it is not possible, because the tags and records are in different tables. I would be very grateful for your help. Sorry for my bad English!


title: What is the precendence of item types within WordPress

text: I recently stumbled across an issue on a site that uses the following URL structure;               /%postname%/%post_id%/      An old blog entry had the URL www.mysite.com/my-blog-post/1918/ Since that entry was made there was some media added to the site with the name My Blog Post, meaning the slug for it was also my-blog-post. Since the addition of the media anyone going to www.thesite.com/my-blog- post/1918/ would be shown the media page instead of the blog page. I can't see this happening too often, I have corrected the error and informed the guys in charge of content to be mindful of it but it got me thinking about the precedence of different item types. I would have thought off the bat that Media types would be lower down the list, but apparently not. **What I would like to know is how I go about finding what the precendence of WordPress items is and if there is any way of changing it.**


title: load wp_menu dynamically with enquire.js

text:
I'm trying to dynamically load the wp_menu with enquire.js but it just doesn't work. If the screen is < 1080px the wp_menu(mobile) should be loaded, otherwise the wp_menu(desktop). In my homepage-template.php I regularly call the header and then I use enquire.js as per instructions.                     Enquire works, but Wordpress doesn't and kicks out this error message:               Fatal error: Call to undefined function wp_nav_menu() in /kunden/372333_10437/webseiten/dev.andreapuiatti.com/dev4/wp-content/themes/spk/templates/headernav-computer.php on line 20      Any Idea on how to dynamically load that menu? follows the content of headernav-computer.php:               <?php wp_nav_menu( array('link_after' => '

', 'menu' => 'primary', 'container_class' => 'menu') ); ?>


title: How to remove a tab in Media Upload page in wordpress

text: I use wp_enqueue_script('media-upload') show upload box,but i don't want show "Media Library" I use upload for frontend and don't want remove it on backend. Can you help me modify it Thanks I fixed this problem               if(current_user_can('subscriber')){         function remove_media_library_tab($tabs) {                 unset($tabs['library']);             //    unset($tabs['type_url']);                  return $tabs;         }         add_filter('media_upload_tabs', 'remove_media_library_tab');     }


title: How to get pretty URLs with add_query_arg in permalinks

text: With `add_query_arg()` it is nice to add additional parameters to an URL and it is also easy to create a rewrite rule. So far so good. But the problem is the URL replacement done by wordpress. When I have an URL, like:               www.mysite.com/?page_id=1&myvar=test      and I type this URL into the address line of the browser with activated permalinks. This link will become to:               www.example.com/pagename/?myvar=test      **BUT** : what I would like to get is:               www.example.com/pagename/test      Finally, I would like to use code like:               <a href="<?php add_query_arg( 'myvar', 'test', get_permalink() ) ?>"> .... </a>      which would result in:               www.example.com/pagename/test      How can this be achieved? I have spent hours in reading documents and I couldn't found a solution.


title: Is there any record of installed plugins in the database?

text: I have my live install on one server and a development install on another. I've added a plugin to both but it only appears in the plugin list in `wp- admin` on one. For a plugin to appear in `wp-admin` does it need to appear in the database at all? Or is it that just by having the plugin file(s) in the `plugins` directory that it'll be detected? Cheers!


title: How do I add php to all links automatically?

text: I'm using the Qtranslate plugin for my site. It's a pretty cool plugin and works great to a degree. I'm having a problem though when users add links to internal content in the WYSIWYG editor in that the link will just be outputted in one language. I would like to insert some php automatically to all links to internal content created in the WYSIWYG editor of my site. I want `<?php echo qtrans_getLanguage(); ?>` to be added to every internal link. For example if the following is done in WP:               London      I want it to be outputted as this:               <a href="/<?php echo qtrans_getLanguage(); ?>/london/">London      This way any links inserted in content using the WYSIWYG editor will automatically forward to the right language. There's a further complication that means I don't want external links to have the php added. So if a link looks like this: `<a href="http://www.google.com/">Google</a>`I want it to stay like this. Any idea how this could be done? I couldn't find any other posts that were addressing such an issue.


title: how to edit attachments?

text: when attaching eg. files to a post, how can i edit/delete them afterwards? couldn't find anything in the post editor. thanks


title: Is function_exists() considered a good practice when using 3.0+ functions?

text: I Know it's not needed if we're using the latest wordpress but I'm just wondering if it's a good practice to always use it or just use new 3.0+ functions without it, and should we use it for commercial themes ? thanks in advance.


title: Adding a filter to related posts not working

text: I'm using the the filter below to filter related posts by author, I added an author ID to test but they are not filtering by author               add_filter( 'woocommerce_product_related_posts', 'woo_custom_attribute_filter' );     function woo_custom_attribute_filter( $q ) {                      array(                 'orderby'        => 'rand',                 'posts_per_page' => $limit,                 'post_type'      => 'product',                 'author'        => 2,                 'fields'         => 'ids',                 'meta_query'     => $meta_query,                 'tax_query'      => array(                     'relation'      => 'OR',                     array(                         'taxonomy'     => 'product_cat',                         'field'        => 'id',                         'terms'        => $cats_array                     ),                     array(                         'taxonomy'     => 'product_tag',                         'field'        => 'id',                         'terms'        => $tags_array                     )                 )             );         //print_r($q);         return $q;     }


title: Namespace spl_autoload problem in Wordpress admin

text: I am experimenting with PHP namespacing within Worpdress plugins. The plugin includes a loader file which sets up the spl_autoload functionality and then instantiates a different controller depending on whether the current page request 'is_admin()' or not. [WP_PLUGIN_DIR]/lhes_experiment/loader.php               use lhes\system\controllers as sys;          set_include_path('./wp-content/plugins/lhes_experiment/' . PATH_SEPARATOR .     get_include_path());     spl_autoload_extensions(".php"); // comma-separated list     spl_autoload_register( 'spl_autoload' );          $config = array( ... );          if( is_admin() ){        error_log( var_export( new sys\experiment( ), true ), 0 );     }else{        error_log( var_export( new sys\experiment( ), true ), 0 );     }      [WP_PLUGIN_DIR]/lhes_experiment/lhes/system/controllers/experiment.php               namespace lhes\system\controllers;        class experiment extends test{           public $property;           function __construct( ){              $this->property = 'owls';           }        }      [WP_PLUGIN_DIR]/lhes_experiment/lhes/system/controllers/test.php               namespace lhes\system\controllers;        class test{           public $test;           function __construct( ){              $this->test = 'hi';           }        }      When the request is **not** and admin page, the code runs as expected and the error log shows:               [23-Jan-2013 12:55:27 UTC] lhes\system\controllers\experiment::__set_state(array(        'property' => 'owls',        'test' => 'hi',     ))      However, when the request **is** to an admin page the exact same code does not work:               [23-Jan-2013 12:56:17 UTC] PHP Fatal error:  Class 'lhes\system\controllers\test' not found in C:\Program Files (x86)\Zend\Apache2\htdocs\wp-content\plugins\lhes_experiment\lhes\system\controllers\experiment.php on line 4      I've spent many an hour googling the problem but can't seem to find anything. If anyone has any ideas as to why this might be happening I would really appreciate some pointers.


title: issues with object cache (memcached as backend) and wpmu when flush_all is run

text: Im running a rather large wpmu setup bloggersdelight.dk - from time to time, we need to reset the object cache when doing changes on the site. When we do this, things mess up. Option values from sites gets mixed together and homeurls for blogs redirects to wrong blogs etc. This is the current object-cache.php im working with. http://pastebin.com/QgM5tR9n As you can se the flush function is created in a way that it does not allow to flush if multisite. This was the default for the plugin found on wordpress.org. In order to flush a blogs cache i need to do some "fun" created stuff like this:               switch_to_blog($blogid);          $pattern = "/^" . $blogid . ":/";          $memcache = new Memcache();     $memcache->connect( $server, $port );          $list = array();     $allSlabs = $memcache->getExtendedStats( 'slabs' );     $items = $memcache->getExtendedStats( 'items' );     foreach ( $allSlabs as $server => $slabs ) {     foreach( $slabs as $slabId => $slabMeta ) {     if ( !empty( $slabId ) ) {     $cdump = $memcache->getExtendedStats( 'cachedump', (int) $slabId );     foreach( $cdump as $keys => $arrVal ) {     if ( !is_array( $arrVal ) ) continue;     foreach( $arrVal as $k => $v ) {     if(preg_match($pattern, $k))     {     $list[] = $k;     # $memcache->delete($k);     $parts = explode(":",$k);     print_r($parts);          wp_cache_delete($parts[2],$parts[1]);          }     }     }     }     }     }     return $list;      This seems to work for a single blog, allthough some items do not get cleared. Anyways, the problems occour when i do this telnet localhost 11211 and then type flush_all then things get weird and option values get mixed between blogs. If i run the flush_all command multiplte times then the problem usually is reducd and less blogs gets wrong option values. Does anyone have any suggestion to how to solve this ? Do i need to create some kind of key SALT ?