How to stop filter from running on the index.php page?

I'm trying to make a Wordpress function and currently I have this in my functions.php file:                function find_my_image($content) {          if(is_single()) {              if (preg_match('#()#', $content, $result)){                  $content .= '
Image has been found
';              }         else{                  $content .= '
Sorry, no image here!
';              }          return $content;           }      }          add_filter('the_content', 'find_my_image');      The function works perfectly on a single post page, but my index.php is now blank (only the titles of the posts are displayed, but no post content). I tried removing:               add_filter('the_content', 'find_my_image');      from function.php, but that's stops the function from executing on my single.php. Also I tried using this (I don't know if it's correct):                if(is_single()) {               add_filter('the_content', 'find_my_image');          }      But that's just cancels the function on single.php. My guess is that add_filter('the_content', 'find_my_image'); is the problem here, but I can't figure it out, so can anyone help me out a bit?


How to correctly limit the content and strip HTML?

I have been using this code for a long time :               $temp_arr_content = explode(         " ",         substr(             strip_tags(                 get_the_content()             ),             0,             720         )     );     $temp_arr_content[count( $temp_arr_content ) - 1] = "";     $display_arr_content = implode( " ", $temp_arr_content );     echo $display_arr_content;     if( strlen( strip_tags( get_the_content() ) ) > 0 )         echo "...";      To limit my content to 720 characters and strip html from it   However, today I used it again in my new theme but I noticed that it also outputs the HTML codes (the HTML code is not working, but shows up in the content) .   I have also used this code in my theme :               $excerpt = get_the_excerpt();     echo string_limit_words( $excerpt, 55 );      and this code on my Function.php :               function string_limit_words( $string, $word_limit ) {         $words = explode( ' ', $string, ( $word_limit + 1 ) );         if( count( $words ) > $word_limit )             array_pop( $words );         return implode( ' ', $words );     }      to limit words and strip HTML , however, when I change 55 to 150 the code does not work and it still shows 55 words.   can someone please help me resolve this issue ? thanks


Google calendar in wordpress showing events

How can I have the google calendar in wordpress showing my events?


How to remove duplicate link from add_menu_page

In the theme admin menu below, the "MyTheme Menu Label" is being duplicated twice on the sidebar menu, once for the main menu link and again for the first submenu link. How can I remove the 2nd instance of the link               add_menu_page(         "MyTheme",          "MyTheme Menu Label", //THIS IS REPEATED TWICE IN THE MENU         "edit_themes",          "functions.php",          'theme_admin',          get_bloginfo('template_directory') .'/img/favicon.png',31     );          add_submenu_page(         'functions.php',          "SEO Options",         "SEO",         'edit_themes',          'my-seo-options',          'theme_admin'     );          add_submenu_page(         'functions.php',          "Misc Options",         "Misc",         'edit_themes',          'my-misc-options',          'theme_admin'     );           //etc...


how to set context in Wordpress for unit testing

I have created a wordpress plugin which converts shortcodes to content based on the entry saved on the dataase:                   global $wpdb;              $post_id = get_the_ID();         $post_content = get_the_content();              $pattern = '/\[zam_tweets page=([0-9])\]/';         preg_match($pattern, $post_content, $matches);              if(!empty($matches)){                  $tweets_table = $wpdb->prefix . 'zam_tweets';             $result = $wpdb->get_var("SELECT tweet FROM $tweets_table WHERE post_id = '$post_id'");             $content = $result;         }              return $content;      My problem is how do I set the context to be that of a specific post so that I will get an actual post id when using the `get_the_ID()` method. Is this how I'm supposed to go with this or do I just have to specify them as arguments?


How to display php source code inside a post using visual editor?

**NOTE** I don't want the php code to be executed, only displayed. I want to display this php code `<?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?>` inside a post. I cannot make it work. If I go to text type of editor and type `<pre class="lang:php nums:false"> <?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?> </pre>` there and save. I can see what I want to. But when I switch to visual editor the php text is not there. There is box for it but the text is not there. If I save the post now html comments are added to the source code and it looks like `<pre class="lang:php nums:false"> <!--?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?--></pre>`. So when I then refresh the post page I got `!--` characters there, something that shouldn't be there. Any idea how to display php code with syntax highlight?


update_post_meta not saving when value is zero

I have a problem with the `update_post_meta` function.   I have a user submitted value, which I pass via `$_POST` and then saving to post meta. All is working fine, but when the value is `'0'` the post meta is not updated. My code:               $id = absint($_POST['ex_id']);     $key = (string) $_POST['id'];     $value = (string) $_POST['value'];          echo update_post_meta($id, 'wpptabs_' . $key, $value);      Does anyone have any idea what might be wrong?


Best practice way to delete user meta data during plugin uninstall?

If a plugin stores data in the usermeta tables what is the best practice method to delete these entries for all users in uninstall.php? I could access the database directly but is there another way?


WP_query parameters for date range

I'm using the events manager plugin to create custom posts for events. I do not have a need for a blog, so I modified my theme's `index.php` file (using a child theme) for its query to retrieve the "event" post type on the home page. `new WP_Query ( array( 'paged' => $paged, 'post_type' => 'event', 'posts_per_page' => 4 )` (I have only included the 'event' post type). So far, so good. But it displays current, past and future events on the home page. I want it to only display current and future events (that is, **I want events that haven't started yet to be shown on the home page too. I only want to prevent past events from being shown** ). I have taken a look at the codex page for WP_Query and used the following code excerpt:               // Create a new filtering function that will add our where clause to the query     function filter_where( $where = '' ) {         // posts for March 1 to March 15, 2010         $where .= " AND post_date <  CURDATE() ";         return $where;     }          add_filter( 'posts_where', 'filter_where' );     $query = new WP_Query( $query_string );     remove_filter( 'posts_where', 'filter_where' )      It doesn't produce the desired result because the event date isn't stored on `post_date` on the DB. However I suppose there's some easy way to reference the events' dates, because the date automatically displayed on the home page isn't the posts publication date, _but rather the event start date, without any modification being made_.


Problem in creating table through plugin code

I'm using the following code to create the database table using plugin. However, the table is neither getting created nor I'm getting any error message. The code is as follows:                   global $wpdb;         $table_name = "tbllb_club";              $sql = "create table $table_name (         club_id int(11) NOT NULL auto_increment,         project_name varchar(500) NOT NULL,         first_name varchar(100) NOT NULL,         school_status varchar(50) NOT NULL,         school_name varchar(200) NOT NULL,         school_city varchar(50) NOT NULL,         school_state varchar(50) NOT NULL,         year_in_school varchar(50) NOT NULL,         age int(2) NOT NULL,         email varchar(200) NOT NULL,         mobile varchar(15) NOT NULL,         chat_id  varchar(50) NOT NULL,         facebook_page_link varchar(200) NOT NULL,         mailing_address_street varchar(50) NOT NULL,         mailing_address_city varchar(50) NOT NULL,         mailing_address_state varchar(50) NOT NULL,         mailing_address_zip char(6) NOT NULL,         social_networking varchar(50) NOT NULL,         organization_involvement varchar(2000) NOT NULL,         yesclub_heard varchar(50) NOT NULL,         volunteer_experience varchar(2000) NOT NULL,         volunteer_reason varchar(2000) NOT NULL,         skills varchar(2000) NOT NULL,         creative_ideas varchar(5000) NOT NULL,         other_information varchar(2000) NOT NULL,         face_photo_url varchar(200),         school_image_url varchar(200),         video_clip_url varchar(200),         PRIMARY KEY  (club_id)         );";              require_once(ABSPATH . 'wp-admin/includes/upgrade.php');         dbDelta($sql);      I have followed the rules as mentioned the Wordpress Codex. Please help!! Thanks in advance.


Display Images from Array with wp_get_attachment_image()

I'd like the client to be able to type any image ID (number) from any gallery / attachment and then displaying it with wp_get_attachment_image(). Here is my code:               if ( $images ) {         foreach ( $images as $image ) {            echo '<li>';            echo wp_get_attachment_image( $images, 'thumbnail' ); // notice this part            echo '</li>';           }      When I do print_r $images, I get this array: Array ( [0] => 318 [1] => 304 [2] => 301 [3] => 299 [4] => 297 ) and it works if I hardcoding the array, like               echo wp_get_attachment_image( 304, 'thumbnail' );,       but of course I'd like it to appear dynamically. How to do that? Thanks in advance.


Set start page depending on screen width

I'm building a responsive theme and would like to have different start pages depending on screen width. In this case, the start page is set in WP admin and contains an image map built on a cunstom page template. On mobilde devices this image map doesn't work so well, so I'd like set one of the other pages as start page. I guess I can merge front-template with standard-template and somehow achieve this with media queries, but would prefer a javascrip/jQuery solution. Thanks


Trying to add taxonomy to get_categories() but it's not working. How to fix this?

I have this template I purchased and I'm trying to customize. I added a new taxonomy category called location and I'm trying to replace the default categories being loaded in the theme with my new taxonomy categories. here's the current code and where it loads the categories:                $cats_array = get_categories('hide_empty=0');      $pages_array = get_pages('hide_empty=0');      $site_pages = array();      $site_cats = array();           foreach ($pages_array as $pagg) {     $site_pages[$pagg->ID] = htmlspecialchars($pagg->post_title);     $pages_ids[] = $pagg->ID;      }           foreach ($cats_array as $categs) {     $site_cats[$categs->cat_ID] = $categs->cat_name;     $cats_ids[] = $categs->cat_ID;      }                   array( "name" => "Featured Category",                "id" => $shortname."_feat_cat",                "type" => "select",                "options" => $site_cats,                "desc" => "description"),      Ideally, this change should work:               $cats_array = get_categories('hide_empty=0&taxonomy=location');      but it doesn't! I'm obviously missing something and don't know how to fix this. Any help is appreciated. Here's the register taxonomy part:                   // Register custom taxonomy         register_taxonomy(  "location",                              array(  "woo_estate"    ),                              array ( "hierarchical"      => true,                                      "label"             => "Locations",                                      'labels'            => array(   'name'              => __('Locations'),                                                                     'singular_name'     => __('Location'),                                                                     'search_items'      => __('Search Real Estate'),                                                                     'popular_items'     => __('Popular Locations'),                                                                     'all_items'         => __('All Locations'),                                                                     'parent_item'       => __('Parent Location'),                                                                     'parent_item_colon' => __('Parent Location:'),                                                                     'edit_item'         => __('Edit Location'),                                                                     'update_item'       => __('Update Location'),                                                                     'add_new_item'      => __('Add New Location'),                                                                     'new_item_name'     => __('New Location Name')  ),                                      'public'            => true,                                     'show_ui'           => true,                                         "rewrite"           => true )                             );      The pages codes can also be found at: http://codepad.viper-7.com/4Wkgg3 http://codepad.viper-7.com/n2hZRI I wasn't able to fix the issue in the end, but instead of using the theme options file to dynamically select the category I want, I used an override code to directly (statically) select the category I wanted and it worked.


How to make “Upload files”selected by default in Insert Media?

I am frustrated having to click on the "Upload Files" constantly instead of the first choice being Upload Files in posts editor....How can i make “Upload files” selected by default instead of "Media library"? ![](http://i.stack.imgur.com/nIcMv.jpg)


Noob Question - Buddypress Dynamic content on static page

Sorry for posting such a noob question but I am totally stuck and don't know what I am looking for. So basically I have a buddypress website with a static homepage. On the homepage I need to add a dynamic area where the admins can add a news story, this story will change maybe once a month. I just need to know what I am looking for, is it widgets or sidebars or something else? Once again sorry for the noob question, I am new to all the WP/BP stuff. Its the latest version of WP/BP. Kyle


How to stop wordpress from showing the selected category on top of others in the category selection?

By default in the category chooser at the edit post screen wordpress displays the selected categories on top of the others, i find that extremely annoying and i would like to disable the feature even if i need a hack for this.


Which WordPress books should I recommend to a beginning web designer?

I have a friend who has a background in graphic design. She has taken a particular interest to web design. I am a software developer/system administrator, not a web developer, and I'm certainly not a designer; I couldn't design a good-looking site to save my life. However, I am aware of the technologies involved and the skills that she would need to acquire. For the first book, I have recommended Head First HTML with CSS & XHTML for it's non-threatening, yet practical approach to teaching. This book introduces the reader to the modern technologies which are used by the browser to display web pages, and explains how to use them. As most of you know, that is only the tip of the iceberg. Most sites today rely on some sort of back-end (CMS, et cetra). So, any web designer should be able to work with at least one kind of CMS. I think WordPress would be a great place to start (and who knows, maybe even specialise in) because it is highly scalable, yet easy to use for developers, designers, server administrators, and end users alike. It is used by individuals, small businesses, and enterprise. At the same time, it is simple enough to design for that I don't think it would scare her off with too much programming. Disclaimer: I use WordPress for most of my personal sites, so I am more than a tad bias. However, I'm not sure which book/tutorial to recommend to her for WordPress design. Below is a list of books which I have found, and my thoughts on them: Head First WordPress: A Brain-Friendly Guide to Creating Your Own Custom WordPress Blog - It explains in plains in plain English what WordpPess is, how it works, and how to use it. I love the format for this purpose, but it has a very short theme chapter. It may be good for supplementary reading. Smashing WordPress: Beyond the Blog (Smashing Magazine Book Series) - It is well laid out, and up to date. It has an entire section on WordPress theme development. But, I would prefer a book which specialises in theme development. WordPress 2.8 Theme Design - This book is written to be a step-by-step guide to designing, building, and tweeking a WordPress theme. But, it's a bit out of date. Could this be a problem? Build Your Own Wicked Wordpress Themes - I have mixed feelings about this book. Is moderen, design orientated, and nice to look at. However, it bases much of of the work on the Automattic theme framework. On one hand, this minimises hand-coding, making it easy to learn and use, especially for someone without a background in programming. On the other hand, I'm concerned that such an approach might not prepare one for the "real world" of theme development, if one ends up applying for work at a design company, rather than doing freelance work. Is this a valid concern? How widely are frameworks used? As I said, web design/development is not my field, so I don't know much about the industry. Any help is appreciated.


AJAX search on post pages by custom post type

I'm having an issue creating an ajax search on my single post pages. I need to limit the search results to the custom post types "fod_videos" and "post" and category 12. My issue is the search is returning all the posts under those filters and not taking the search value. I'm guessing I'm missing something obvious but I can' figure it out. Here's my setup.

Search Videos

        <form role="search" method="get" id="searchform" action="http://myurl.com/" >         <input type="text" value="" name="s" id="s" />         <input type="submit" id="searchsubmit" value="Search" />        </form>

          add_action('wp_ajax_wpa5000_search', 'wpa5000_search');     add_action('wp_ajax_nopriv_wpa5000_search', 'wpa5000_search');     function wpa5000_search(){       global $wp_query;       $search = $_POST['search_val'];       $args = array(         's' => $search,         'posts_per_page' => 10,         'cat' => 12,          'post_type' => array( 'post','fod_videos'  )       );       $wp_query = new WP_Query( $args );            get_template_part( 'video-search-results' );            exit;     }          add_action( 'wp_enqueue_scripts', 'wpa56343_scripts', 100 );     function wpa56343_scripts() {      wp_enqueue_script(         'wpa56343_script',         get_template_directory_uri() . '/libs/search.js?ver=1.0',         array( 'jquery' ),         null,         false      );      wp_localize_script(         'wpa56343_script',         'WPaAjax',         array(             'ajaxurl' => admin_url( 'admin-ajax.php' )         )      );     }      // search.php               $(document).ready(function($){      $('#searchsubmit').click(function(e){         var $panel = $(this).closest(".panel");         $panel.empty();         e.preventDefault();         var search_val=$("#s").val();         $.post(             WPaAjax.ajaxurl,             {                 action : 'wpa5000_search',                 search_val : search_val             },             function( response ) {                 $panel.append( response );             }         );      });     });      //video-search-results.php               <?php      while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>        //STUFF     <?php endwhile; ?>


query attachments of parent page if attachments of current page are smaller than …

I'm using `WPQuery` and `get_children($query_images_args)` to query attachments from the current page. If the current page has no attachments assigned I'm querying the images of the parent page. This works the way I want but there is one little extra I'm aiming for. I already asked a similar question (with the same code sample) here in the forum. only get attachments that are associated with a gallery? However in this question I ask for a different approach to address the same problem.               $query_images_args = array(             'post_type' => 'attachment',             'post_mime_type' =>'image',             'post_status' => 'inherit',             'posts_per_page' => -1,             'post_parent' => $post->ID         );              $attachments = get_children($query_images_args);              if ( empty($attachments) ) {             $query_images_args = array(                 'post_type' => 'attachment',                 'post_mime_type' =>'image',                 'post_status' => 'inherit',                 'posts_per_page' => -1,                 'post_parent' => $post->post_parent             );         }              $query_images = new WP_Query( $query_images_args );         $images = array();         foreach ( $query_images->posts as $image) {             $images[] = wp_get_attachment_image_src( $image->ID, 'large');         }      I'm querying the attachment images of the current page and if there are no images assigned to the current page I query the images of the parent page. Moreover I'm doing an additional filter-thingy for only large images. However I wonder if it is possible to query the images of the parent page if the current page has only "small" images. So in essence, I'd like to get only "large" images of the current post if it has images and get only "large" images of the parent page if the current post has no images. Any ideas on how to do that!


Use <?php echo $_GET['ref']; ?> to track referrals

I am setting up my wp site and i have it setup like this www.mydomain.com/?ref=AFFILIATEID thats alright if they land on the page they are directed to but if they go off page onto another one, how do i get the affiliate id to track through the site so that anywhere i put the link www.affiliatelink.com/ it will show who the referer is. Also is there a way to set a default referer so that if someone came to the site www.mydomain.com it would have a defulat affiliate id set through out the site. Im using the latest wordpress, self hosted and using the optimizepress theme Thanks James


Limits, not all post are showen when querying for posts by view count

I'm having some difficulty getting a loop that gives me post by most viewed. I started by following this tutorial http://www.wpbeginner.com/wp-tutorials/how-to-track-popular-posts-by-views-in- wordpress-without-a-plugin/ This worked fine. How ever I have some 700 posts that where added with php script and json from a different site. In the JSON I had some extra information that I added as meta tags (custom fields). One of the information I got from the JSON where the current view count. I then have a work around that calculates new views along with the views from the other website(it's stored on both sites for a while, long story) Adding the view count to the posts is no a problem and works fine. But when I finally get to querying the posts I get a bug. The query only shows me posts with view count under thousand, all post with view count over 1000 are not included. There are over 100 posts with view count over 1000. My query is so:               $popularpost = new WP_Query( array( 'posts_per_page' => 20, 'meta_key' => 'viewCount', 'orderby' => 'viewCount', 'order' => 'DESC'  ) );     while ( $popularpost->have_posts() ) : $popularpost->the_post();          include('content-markup.php');          endwhile;       I might point out that it is being done in a custom template page, and the included php file is includes the markup I use to style the post. If I remove the included file and use the_title(); instead it make no different, I just get the titles for the same posts. The first post has 999 views, the next after it has 1012 views. For some reason something is limiting the query so that it can only show post with the meta value under 1000. I'm not sure what else I can inform you off, I hope that someone out there can help me out (and someone else can correct my grammar) :D


Problems updating wordpress

When I try to update wordpress from 3.2.1 to the latest one it stalls and does nothing. It used to ask for my ftp details, which I looked up online and added this to the wp-config:               /** Setup FTP Details **/     define("FTP_HOST", "localhost");     define("FTP_USER", "your-ftp-username");     define("FTP_PASS", "your-ftp-password");      This seems to have stopped it asking for ftp details, but it gets to a page and just does nothing, below is a screen shot of what I see. Any ideas of whats going wrong? ![enter image description here](http://i.stack.imgur.com/p7YC4.png)


When switching from html to visual editor the <iframe> tag gets corrupted

I'm trying to embed an iFrame, and because I set up some CSS using responsive design, I wish to NOT have `width=""` and `height=""` attributes whatsoever. When I type this into the HTML editor field..                     And then I switch to visual mode and come back, it immediately removes the `class="scale-with-grid"` and changes it to `width="320" height="240"`                     How do I avoid this? I used this "Raw HTML" plugin but it didn't apply to this iframe situation whatsoever.


Restrict access of admin uploads to certain logged-in users?

This is a very open-ended, speculative question with lots of possible angles: has anyone worked with ways to restrict the access of certain uploads to a logged in user? I.e., how can the site admin upload files and assign permissions to each one for certain logged-in users? Could this entail an uploads directory called /this_user/ in wp- content/uploads/? And restrict access to that with .htaccess and is_logged_in? Or some kind of meta or custom field that assigns permissions and users for uploads? Other answers here on WPAnswers deal with hotlinking protection, which is a different situation; I need to restrict to logged in users, all on the same domain. Any ideas? Thanks


Show category post order ASC

Below is my category.php page code. I want to order by `ASC`. How can I achieve this?
       <?php if ( have_posts() ) : ?>
    <?php single_cat_title('',true); ?>

     <?php while ( have_posts() ) : the_post();              ?>
 <a href="<?php          $url = get_post_meta($post->ID, 'productURL', true);               if ($url) {             echo "$url";         }     ?>" target="_blank">           <?php  the_post_thumbnail() ?>
<?php the_title(); ?>
           <?php endwhile;                  ?>
            <?php else : ?>       <?php endif; ?>


Custom SQL Query passing array to WHERE p.id

I need to pass an array of post ID's to a custom SQL query I am running on a certain page. The query looks like this:               $querystr3 = "SELECT *,          events_startdate.meta_value AS the_start,         events_enddate.meta_value AS the_end         FROM $wpdb->posts p         LEFT JOIN $wpdb->term_relationships              ON ( p.ID = $wpdb->term_relationships.object_id )         LEFT JOIN $wpdb->term_taxonomy              ON ( $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id )         LEFT JOIN $wpdb->postmeta AS events_startdate              ON (                  p.ID = events_startdate.post_id                  AND events_startdate.meta_key = 'events_startdate'              )         LEFT JOIN $wpdb->postmeta AS events_enddate              ON(                 p.ID = events_enddate.post_id                  AND events_enddate.meta_key = 'events_enddate'          )          WHERE ($wpdb->term_taxonomy.term_id = 11             AND $wpdb->term_taxonomy.taxonomy = 'status'             AND p.ID != array(1433, 1344) <--- trying to pass array here             AND p.post_type = 'pmg_events'             AND p.post_status = 'publish'             AND events_startdate.meta_value != ''             AND events_enddate.meta_value != ''             AND events_enddate.meta_value >= CURDATE()         )         ORDER BY events_enddate.meta_value ASC     ";           $theresults3 = $wpdb->get_results($querystr3 );      As you can see, I am trying to pass 2 post ID's to exclude from a custom SQL query I am running. If I pass in one number ie: p.ID != 1433 it works, but passing in multiple post ID's does not. I've tried using `implode(',',$ids);` but still to no avail. Is it not possible to pass in an array like this. I don't want to re-write this to use `$wp_query`.


orphaned taxonomy terms remove by sql query

I have 3 custom post types each of these CPT's have posts that are set to auto delete via a given time scale by cron jobs, thing is when they are deleted it leaves behind orphaned taxonomy terms in dropdowns etc, needless to say when these are clicked it goes to a "quack quack oops 404 error", i can find sql queries to run for orphaned tags, but there seems to be very little (infact i have found nothing at all) that pertains to taxonomy terms, anubody have any ideas on this? **More Info**   All my terms are pre-assigned to the taxonomies and are listed in wp_terms table, the reason they are pre-assigned is that authors choose them from option menus when creating a new post, so all un-attached (un-used terms) still need to stay in the wp_terms table for later inclusion, the tables i need to be getting info from to run the delete query are wp_terms_taxonomy, wp_terms_relationships and wp_posts to look for a match of a NULL post id and thats the part what stumps me. I am showing the terms for selection via **Scribus Query Multiple Taxonomies** plugin. **UPDATE:** From **theDeadMedics** answer below im deducing that i can do something on the lines of:               <?php      require_once 'wp-load.php';          global $wpdb;           $expireds = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'sales' AND HOUR(TIMEDIFF(NOW(),  post_date_gmt)) >=4321     ");          foreach ($expireds as $expired) {     wp_delete_post( $post->ID, true );     }     ?>        **LAST UPDATE**   i see a couple of folks have set this as a favourite, below is a full working query that will delete time expired posts (and all meta associated with that post) set to a "n"th number of hours after post_date_gmt. In the code below `>=2` denotes delete posts 1 hour old, the number of hours you wish to set for delete should always be plus 1.               <?php      require_once 'wp-load.php';          global $wpdb;           $expireds = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'sales' AND HOUR(TIMEDIFF(NOW(),  post_date_gmt)) >=1");          foreach ($expireds as $post) {     wp_delete_post( $post->ID, false );     }     ?>      Regards


Comparing formidable pro and gravity forms

Has anyone come across any good reviews/comparisons of gravity forms and formidable pro? I am trying to find more information on both. I have a couple of sites that need several forms for adding items to our physical collections, leave requests and reserving specific rooms and resources and the like. I need something that will email form submissions as well as store entries in a database and which I can use to generate reports. Any information or personal experience with either of these or other options would be much appreciated.


Jetpack email sharing button to include image on email sent

I am changing the message for the email sent by modifying the `sharedaddy.php` file and have now spent hours trying to include the image attached to the post on the email. I tried adding the following two codes within the function below and had no luck displaying the images from the post in the email sent:               $content .=  wp_get_attachment_url($post->ID);       and               $content .=  wp_get_attachment_image( $post->ID, 'medium' );      into:               function sharing_email_send_post( $data ) {         $content  = sprintf( __( 'Someone you know visited my website Living Healthy With Chocolate, http://livinghealthywithchocolate.com and thinks you may be interested in the following recipe:'."\n\n", 'jetpack' ), $data['name'], $data['source'] );         $content .= $data['post']->post_title."\n";         $content .= get_permalink( $data['post']->ID )."\n";         wp_mail( $data['target'], ' '.$data['post']->post_title, $content );     }


How to retrieve the slug of current page?

I am trying to retrieve the slug of the current wordpress page outside the loop. The title of the page returns with `wp_title ()` but how can I get the slug?
<?php wp_title("",true); ?>


How can I add an option to the Page Template list from a Plugin?

I've been looking around for the past couple hours for a way to create a custom page template from within a plugin but haven't had any luck yet. What I am specifically trying to do is add an option to the list of available page templates when editing a page, and **not** using some other method like `if( is_page( 'page-slug' ) ) { /* etc */ }` Is there a global variable I can modify to do this? **Edit:** I'm using this code currently, based on the link @m0r7if3r gave me in a comment, the problem is it will run this function when viewing the page, but not when editing the page (to populate the dropdown list with the page templates):               class JW_SiteGrader {              private static $instance;              private function __construct() {                       add_action( 'template_redirect', array( &$this, 'sitegrader_template_redirect' ), 20 );              }              public static function getInstance() {                  // Return the class data in a Singleton fashion             if (self::$instance == null)                 self::$instance = new JW_SiteGrader();             return self::$instance;              }              public function sitegrader_template_redirect() {                  add_filter( 'page_template', array( &$this, 'sitegrader_page_template' ), 10, 1 );              }              public function locate_plugin_template( $template_names, $load = false, $require_once = true ) {                  if ( !is_array( $template_names ) )                 return '';                  $located = '';                  $this_plugin_dir = WP_PLUGIN_DIR . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) );                  foreach ( $template_names as $template_name ) {                      if ( !$template_name )                     continue;                      if ( file_exists( STYLESHEETPATH . '/' . $template_name ) ) {                          $located = STYLESHEETPATH . '/' . $template_name;                     break;                      } else if ( file_exists( TEMPLATEPATH . '/' . $template_name ) ) {                          $located = TEMPLATEPATH . '/' . $template_name;                     break;                      } else if ( file_exists( $this_plugin_dir .  $template_name ) ) {                          $located =  $this_plugin_dir . $template_name;                     break;                      }                  }                  if ( $load && '' != $located )                 load_template( $located, $require_once );                  return $located;         }              public function sitegrader_page_template( $template ) {                  $object = get_queried_object();                  if ( 'page' == $object->post_type ) {                      // New                  $templates[] = "page-sitegrader.php";                 // Like in core                 $templates[] = "page-{$object->post_type}.php";                 $templates[] = "page.php";                      return locate_template( $templates );                    }                  // return apply_filters('page_template', $template);             return $template;         }          }      **Edit 2:** It seems that this functionality will be released in a future update, I read quite a few trac tickets about this and there has been some discussion but no real answer (hoping for 3.4). Will list trac tickets URLs here in a bit. **Edit 3:** The code above works, BUT, the only issue I'm having at this point is there's no template being added to the dropdown list when editing/adding a new page. I'm trying a few things and will update my question soon.


Object Oriented Plugin not working

I'm trying to develop my WordPress skills a little. I've previously moved some of my functions.php that I use time and time again into a must-use plugin. I'm now trying to make that Object Oriented - with limited success. The code below is an excerpt of my overall code. The first section works perfectly, reducing the excerpt length, but the dashboard tidy doesn't. Both previously worked as procedural code. Any help in solving this would really be appreciated. Also, I'm struggling to understand why it is recommended to use the init rather than putting my actions and filters into the constructor. Can anyone explain this for me?               class OOtest     {         public function __construct()         {             add_action( 'wp', array( $this, 'init' ) );         }              public function init()         {             //Tidy up the dashboard             add_action('wp_dashboard_setup', array( $this, 'tidy_dashboard') );                  //Edit excerpt length             add_filter('excerpt_length', array( $this,  'custom_excerpt_length') );         }              public function tidy_dashboard()         {             global $wp_meta_boxes, $current_user;                  // remove incoming links info for authors or editors             if(in_array('author', $current_user->roles) || in_array('editor', $current_user->roles))             {                 unset($wp_meta_boxes['dashboard']['normal ']['core']['dashboard_incoming_links']);             }                  // remove the plugins info and news feeds for everyone             //Wordpress Development Blog Feed             unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);             //Other WordPress News Feed             unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);             //Quick Press Form             unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);             //Plugins - Popular, New and Recently updated WordPress Plugins             unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);         }              // Add custom excerpt length         public function custom_excerpt_length($length)         { return 55; }     }     $foo = new OOtest;     ?>


Pagination not working properly

I have a list of posts from a category as seen here in this example. The problem is, if you scroll down to the bottom and click older, you'll see that the posts on the page have not changed at all, how ever the url has changed. Can some one tell me whats wrong with the following code that generate this?               function category_query($query){         if(is_admin || !$query->is_main_query()){             return;         }              if(is_category()){             $cat_id = get_cat_ID( single_cat_title(null, false) );             $query->set("cat=$cat_id&posts_per_page=10" );             return;         }     }          add_action('pre_get_posts','category_query');          $attr = array(         'align' => 'left',         'class' => 'thumbnail imageRight',         'width' => 350,         'height' => 350     );     if(have_posts()){         while(have_posts()): the_post();         ?>
<?php             the_post_thumbnail('medium', $attr); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

<?php the_excerpt(); ?>

             <?php         endwhile;              ?>

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

             <?php previous_posts_link('Newer Entries »'); ?>

<?php      }


Conditionals if tags exist?

I have the following code to display tagged articles with the same name as the page title, but I only want the to appear if the tag exists, otherwise it just says 'Related Articles' with no content. I have tried using some conditionals with no luck. Is there a way to do this? I have found no examples or questions here that relate specifically to this.
Related Articles
     <?php query_posts( 'tag=' . get_the_title() . '' );     while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?>
     <?php endwhile;?>     <?php wp_reset_query();?>      Thank you for any help


Change the name of the 'Default Template'

I am working on a client's site and they need to select a Template whenever they are adding a new page; the "Default Template" is not a valid choice. I would like to rename "Default Template" to something like "-- Select Template --". Searching the WordPress codebase I found references to "Default Template" are hard-coded, in wp-admin/includes/meta-boxes.php (line 588) and wp- admin/includes/class-wp-posts-list-table.php (line 882). Does this mean there is currently no way to change this, without altering the core code (something I want to avoid)?


wp_nav_menu: indicate by id page grandparents

I have an web site with top-header menu and sidebar menu. Situation, like: header menu: books **music** movies (if we are now under music) sidemenu: blues **jazz** dance (if we are now under "Jazz") sidemenu submenu (under jazz): 60's **90's** 40's (if we are now at 90's) I would like to know how can I highlight MUSIC item from top menu (for example by id or class), because wp_nav_menu does't mark this grandparent item in any way... Please, help!! )


Force authors to Preview a post before publishing

I'm looking to find a way to force authors (including admin & editors) to preview their post before publishing. Is this possible, if so does anyone know the easiest way to achieve this? I'm running WP3.5.1. Thanks


How to hide a post from archives

I want to hide the WordPress post from archives page using the 'private' option. I only want the post to be hidden from archives but visible to public. How to I do it?


Display post excerpt instead of content, if available

I'm planning to display the post excerpt instead of the content if available and auto generate excerpt from the content if not available with the function below:               <?php the_content( __( 'Continue reading →', 'blabla' ) ); ?>      in `functions.php` I'm adding:               # Function to trim the excerpt     if (!function_exists('narga_excerpts')) :         function narga_excerpts($content = false) {             # If is the home page, an archive, or search results                 global $post;                 $excerpt_length = 40;             # If an excerpt is set in the Optional Excerpt box             if ( $post->post_excerpt ) {             $content = the_excerpt();             function custom_excerpt_length( $length ) {                 return 20;             }             add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );             function excerpt_readmore($more) {             return '... ID) . '" class="more-link">  ' . __( 'Read more »', 'narga' ) . ' ';             }                 add_filter('excerpt_more', 'excerpt_readmore');             }             # If no excerpt is set             else {                 $content = $post->post_content;                 $words = explode(' ', $content, $excerpt_length + 1);                 if(count($words) > $excerpt_length) {                     array_pop($words);                     $content = implode(' ', $words);                 }             }             $content = '
' . $content . '
';             # Make sure to return the content             return $content;         }     # Replace content with excerpt     add_filter('the_content', 'narga_excerpts');     endif;      But it does not work.


Show custom post along with default post

I've created a custom post type named "image". Now my theme shows posts on homepage in three parameters- Fresh, Featured, Random(i'm feeling lucky). How can i add custom posts in there. here is the front-page file - front-page.php


WP_Query, How to identify if the offset reached the max posts count

I'm doing a custom `WP_query` to populate my post list via `AJAX` with some filters. I load additional posts once the user click the 'Load More' button, this fires the `$.ajax` and on success adds the new set.               $args = array(         'category_name' => 'properties',         'post_type' => 'post',         'posts_per_page' => 10,         'offset'     =>  $offset,         'meta_key' => 'category',         'meta_value' => $category     );          $the_query = new WP_Query($args);           if ( $the_query->have_posts() ) :         while ( $the_query->have_posts() ) : $the_query->the_post();         //do stuff;         endwhile;     else :         //NOTHING FOUND     endif;      It's working fine for me but now the problem is I don't know if I have already loaded all the posts on the category option that I selected. Let's say I have 30 post overall, and 20 of these are in category 'wordpress'. So what should happen is I load the first 10, then when I click 'load more' it will load the other 10, and then I should hide the 'load more' button since I've loaded all 20 post from this category. But in reality I don't know how many post are in each category so I cannot just simply do the math. Update: At the moment, my solution is to do a separate query just to get the number posts under certain category. Is there an easy way around this? I wish there's a callback that returns the stats like '12/20'.


Create CSV for import from File directories?

Lets say I have posts sorted in individual folders with a word document & jpg inside. What would be the best way to sort that into a csv for import. I assume some excel script or such. Any suggestions would be helpful Thanks


Registered widget is showing up collapsed in the dashboard

I have registered two widgets in my `functions.php` file; however, the second one (#footer-ad) isn't showing up in the dashboard.               function mobile_mix_widgets_init() {         register_sidebar( array(             'name'          => __( 'Featured Videos', 'mobile-mix' ),             'id'            => 'featured-videos',             'description'   => '',             'before_widget' => '',             'after_widget'  => '',             'before_title'  => '',             'after_title'   => '',         ) );              register_sidebar( array(             'name'          => __( 'Footer Ad (468x60)', 'mobile-mix' ),             'id'            => 'footer-ad',             'description'   => '',             'before_widget' => '',             'after_widget'  => '',             'before_title'  => '',             'after_title'   => '',         ) );     }     add_action( 'widgets_init', 'mobile_mix_widgets_init' );      Here is what it looks like in the dashboard. In the area where the widget should appear, instead there is a grey horizontal line. I looked in the source and it looks like the widget has been registered since all of the data is showing up. However, for some reason, it's not showing up. Where did I go wrong? ![enter image description here](http://i.stack.imgur.com/IoTE0.jpg)


How extend shortcode default values for a plugin?

I recognize this would be better suited for the plugin's official support thread, but the developer doesn't appear to read the forums. I'm using the Standout CSS3 Buttons plugin to add buttons via shortcode around my site. There's an optional parameter in the shortcode, `cssclass`, which allows you to specify a custom class for the button. Since my site is built on the Gantry framework, which already has rules for the `.button` class, I'd really like to simply declare `cssclass="button"` in the shortcode and let Gantry's CSS cover it. Unfortunately, when I do that, the plugin doesn't appear to recognize it, and when the page loads, the button does not have the `.button` class. If, instead of `cssclass="button"`, I specify a class defined by the plugin, such as `"button-pinterest"` or `"button-rss"`, the button updates just fine, reflecting that class and the appropriate styles. It seems as though the plugin is stripping out any custom class--which seems to defeat the very purpose of offering custom CSS classes. You can see a button generated by the plugin on a page here, in the sidebar. Right now, it's using the `.button-pinterest` class, and I'd like to give it the `.button` class instead. I don't have the PHP chops to look at the plugin and figure out how to make it add the class I specify in the shortcode. Is there anyone who could kindly take a look at it and help me add my custom classes?


Set template based on query in URL

I want to be able to force WordPress to load an page/post based on a query in the URL. `www.mywordpresssite.com/posts/myarticle?template=custom` This URL should load the _myarticle_ post using template `custom.php` I don't even know where to start with this one. Is there a hook I can use to change the template in my theme before it loads? Any help is appreciated.


short_ping what does it do

Sinds wp 3.6 you can do short_ping on comments as you can see on http://codex.wordpress.org/Function_Reference/wp_list_comments i want use it for my new website ZorgWijzer.nl. But i am not realy sure if thise is good or bad for SEO. Can someone tell me where i can find more information?


Add Paypal Button programmatically

I've setup a post type-Product with custom fields containing price and other attributes. I'm reading Paypal Documentation right now,   What i've read till now is "HTML-Buttons" can be pasted from Paypal, but i can't tell my client to copy and paste the "Add to Cart" button from Paypal every time he creates a new product. Even the plugins tagged with "Paypal" seem manual. I wanted something that would take price and other attributes _programmatically_ from custom fields.   I don't want my client to do any thing regarding Paypal. **So my question:** Should i ditch my almost-complete theme and build everything from ground up with Woocommerce? Or is there still a way to integrate Paypal into this theme. Thankyou for your time and thoughts.


How to use nonce with front end submission form?

Thanks to a variety of posts on here I've managed to put together a front end submission form. After about 24 hours of tweaking I've finally got everything working including a redirect to a 'success' page after submission, but I have no idea what to do with the nonce. Here is the form page: http://pastebin.com/YWyXL3jY And here is the success page: http://pastebin.com/3Usu0Pt6 They are both custom page templates (I know the formatting is a bit all over the place at the moment as different parts came from different sources, and I don't think I'm going to use the file upload feature as I'd rather use a plugin for better security). Does the nonce need to be processed before the user is redirected to the success page? I have no experience at all with nonce's and am a 'copy and paste' php coder so please be gentle! Huge thanks for any advice you can give :)


Wordpress Multisite Sites show in Dropdown but not in Sites menu

So, I've been having some issues getting a Wordpress Multisite network going. I think I'm finally on the right track, having made changes to the primary database for all the different sites according to this guide http://interconnectit.com/840/wordpress-3-0-multisite-with-multiple-domains- setup/ But now, the sites show up in the Network Admin dropdown, but not when you click the Sites button. Only the primary site shows up in the Sites screen. I'm sure this is probably a symptom of a larger problem, but I'm a bit lost. The documentation for Multisite Wordpress is iffy at best. Has anyone else had similar issues or knows what is wrong with my setup?


Semi complicated custom taxonomy question

Given the following the following products: product 1   * Naam   * part of taxonomy "brand" value "Joolz"   * part of taxonomy "Categorie" value "Chair" product 2   * Naam   * part of taxonomy "brand" value "Joolz"   * part of taxonomy "Categorie" value "Car" product 3   * Naam   * part of taxonomy "brand" value "Costa"   * part of taxonomy "Categorie" value "Bike" How could I want to retrieve all the categorie value that has products related to them with a given Brand, So I give value "Costa" I get bike, if i give value "Joolz" i get "chair" and "car"


How to Create Export/Import Functionality for Plugin

I am following the tutorial here http://wp.tutsplus.com/tutorials/creative- coding/creating-a-simple-backuprestore-settings-feature/ The script shows how to export all options into JSON. Since my plugin creates a custom post type, I would also like to export and import all posts of this custom post type. How can I do that?


How indicate when a functions was upgraded in relationship to the entire program

for inline documentation there are those @somethings for some php documenter, when there is the common @since @version and so on. I have a lot of functions that are all part of a big package. But what if i want to indicate when i last updated a function and show on what version of the mayor package it was done? should i just use @version and give the function the version of the entire package? In case i cause confusion: lets say i have a function with @since 0.1 in my program 1.0. then the program itself gets developed up to 2.9 and for the 3.0 version the function would have a change. So actually the functions version would be 0.2 now but i want to show on what version of my entire programm it was updated. So should i just jump and say @version 3.0 at this function? i just used a @updated but thats not existing right? nothing like this documented here Is there anything for my purpose?


ACF - get fields from group

i have been using this code to get all fields from a specific group:               <?php     $GroupOrPostSlug = 'acf_specialgroup';     //or insert the ID of your fields Group.     $groupID='';                    global $wpdb;     if (empty($groupID))     {$groupID = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name =  '$GroupOrPostSlug' ");}     if (empty($groupID))     {$groupID = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title =  '$GroupOrPostSlug' ");}          $custom_field_keys = get_post_custom_keys($groupID);     foreach ( $custom_field_keys as $key => $fieldkey )     {         if (stristr($fieldkey,'field_'))         {             //echo $key . " => " . $fieldkey . "
";             //echo $field['label'] . ': ' . $field['value'];             //echo $fieldkey . "
";             $field = get_field_object($fieldkey, $groupID);             echo $field['label'];              }     }     ?>      but it displays only fields' names. doesnt there exist a simple hook/function, something like this: `get_all_fields_from_group($id)`


TinyMCE Plugin Parameter

Can anyone tell me if there is anywhere I can find out what each of these TinyMCE plugins are for?               $in['plugins']='inlinepopups,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs,wpfullscreen';      I'm wondering because if I remove the `wordpress` one that the editor will stop stripping out my `<p>` tags, but I also lose all my spacing in the `html` view of the editor as well.


Why are there two diffrent full screen editors?

In the WP editor there is a full screen button. It has shortcut `ALT+SHIFT+G`.   When the button is pressed it shows a different full screen editor then when the shortcut is used. I tried this on multiple 3.4.1 installations, one of them had no plugins to interfere. Why is this? **EDIT** its a bug: http://core.trac.wordpress.org/ticket/21197


Custom Query Not Paginating

I have a site that uses a custom query to filter posts:               <?php //Search Region table to retrieve array of country names     $regionresult = mysql_query("SELECT * FROM gallery_regions WHERE region='$region'") or die(mysql_error());     $num_rows = mysql_num_rows($regionresult);          // Process search reults and format array contents for WP Query     $country_search_array = array();         while($row = mysql_fetch_array($regionresult)){         $country_search_array[] = $row['country'];              }          //Build WP query     $args = array(          'posts_per_page' => '48',          'cat' => '4',          'meta_query' => array(              array(                 'key' => 'Country',                 'value' => $country_search_array,                 'compare' => 'IN'             )         )     );     $gallery_query = new WP_Query( $args );?>      supplemented by a custom function that paginates the results, using the WP Page Numbers plugin (http://www.jenst.se/2008/03/29/wp-page-numbers):               function wp_page_numbers_custom( $wp_query, $start = '', $end = '' )     {         $_backup = array(             'wp_query' => @ $GLOBALS['wp_query'],             'max_page' => @ $GLOBALS['max_page'],                'paged' => @ $GLOBALS['paged'],           );              $GLOBALS['wp_query'] = $wp_query;         $GLOBALS['max_page'] = $wp_query->max_num_pages;            $GLOBALS['paged'] = max( $wp_query->get( 'paged' ), 1 );              wp_page_numbers( $start, $end );              foreach ( $_backup as $var => $val )             $GLOBALS[ $var ] = $val;     }          //usage: wp_page_numbers_custom( $gallery_query );      While the number of pages returned is accurate, the navigation isn't working. If you click on page 2 of X, you still wind up on page 1, despite the change in the URL. The site in question can be found here. Any help is appreciated. Thanks, ty


Changing title to lowercase

Lets say i have 100 posts. And i would like to lowercase the title. but only 70 of it. I cant use text-transform or mb_strtolower. Is there anyway to download posts and lowercase the title with microsoft word and reupload it?


How can I make my blog urls have words of the title in them?

I just started a new blog and all the urls look like this:               sitename.com/?p=1      But how do people make the url have the title of the blog Thanks!


Resizing the width of the WISIWYG editor

Just a simple question here but though my googling and searching efforts haven't found the answer to it. I'm wanting to re-size the width of my wordpress WYSIWYG editor to be 650px. What do I have to type into functions.php to get this effect? I found this but it didn't do anything               add_action('admin_print_styles-edit.php','increase_textarea_css');     add_action('admin_print_styles-post-new.php','increase_textarea_css');          function increase_textarea_css() {         ?>         <style type="text/css">         textarea#content { width:650px!important; }         </style>         <?php     }


Create/Edit posts and auto-redirect back to listing page

Is there any way to possibly force a redirection to the post (type's) listing page (`edit.php?post_type=<post-type>`)? ~~**EDIT:** Since I got a LMGTFY link, let me clarify before I downvote it.~~ **Is there anyway to redirect the user forcibly to the post type's listing page AFTER they've already submitted the form to either edit the post or create a new post?**


Post formats template

I would like to know what template wordpress uses to display post formats archive pages? What is parent template file that is used when there is no specified template file and what is specified template file that covers all post formats templates? Also is there a way to know if loaded page is post formats archive page?


How to Include HTML in Excerpts?

I use the Leaf theme and I can't seem to format the home page excerpts. I tried plugins and fiddling around with the theme-functions.php file but to no avail. I don't need a lot of fancy stuff in the excerpts just a bit of formatting, nothing more. That should be possible, right?


Security threats if wp-config got exposed to the outsiders?

Usually, people setup so that the username/password can only access db from localhost. In case of php interpreter malfunction and the configuration wp-config got exposed to visitors, what harms could they possibly do? UPDATED: The other question (Is moving wp-config outside the web root really beneficial?) is not exactly what I was looking for. I was looking for what can the outsiders do once they grabbed the username and password of the db.


Configuration File Safety

I'm new to PHP and WordPress and I've a few questions to ask about database and configuration file security. I hope you answer them.   1. When I try to reach some wp sites config file by typing "example.com/wp-config.php" it redirects me to a 404 page. How this happens?   2. My database informations and other information (which are extremely important) are in the wp-config.php file. Can anybody download this php file? With some kind of downloader softwares? **EDIT: I don't think especially this part is duplicate**   1. Let's say I'll do a website with php and mysql. Where should I keep my config file? How to prevent people to download and/or see this file?   2. Again, let's say I'm coding php, where should I keep my queries and/or connection strings?   3. Can anybody download and look into my php files? (They didn't reach my panel, they didn't had my ftp accounts. Can they download and see some other way?)


Determine Registered Admin Menus

Is it possible to obtain a list of which Top Level Admin Menus have been registered via some plugin? I'm talking about menus registered with: `add_menu_page();`


Is there a better way to check for a new comment?

I have some code that runs on the client that checks every 30 seconds or so for new comments, and if a new comment is found the user is alerted. The check count the comments on a page, and returns the count. The code that checks for comments is:               check_for_new_comments() {     $sitewide = get_option( 'sitewide_mode', 0 );        $postID = $_POST['postID'];     $postID = ( $sitewide ) ? '' : $postID ;          $comments_number = get_comments( array( 'post_id' => $postID, 'status' => 'approve', 'type' => 'comment', 'count' => true ) );          $response = array( 'count' => $comments_number );wp_send_json( $response );          }      On the client, if the counter is greater than last time we checked then I call a function to get the comments missing using the following in jscript.               function( commentCheck ) {          if ( commentOld === null ) {             commentOld = commentResponse;     }          if ( commentOld.count < commentResponse.count ) {              commentGrab();         commentOld = commentResponse;          }          }      I know the count can be cached, but on dynamic sites with lots of comments (At busy ties I can get 1000 comments per post and around 100 visitors per minute putting a lot of strain on my server CPU). I think counting the comments might not be efficient and wonder if it would be more efficient to compare the tiestamp of the most recent comment. Is "counting the number of comments and then comparing the count" quicker than "comparing the date of the most recent comment"? Can you please advise me on what is the more efficient approach and if it is to compared dates, how do I code this? Many thanks


My function doesn't work into WordPress but outside, it works - what am I missing?

I used a functions into my page I created for WordPress, it's working, but the functions 're not working, doesn't showing any result. For example:               <?php     function tester()     {          global $pol;          $pol="ok all fine and working";     }          tester();          echo $pol;     ?>      This function works perfectly if I use it outside WordPress, but problem is when I tried using it into the file I created, it won't work. I don´t know what the difference I need to assure to work it in WordPress other than any other PHP file.


WordPress (3.9.1) MultiSite Permissions. Is chown the answer?

**The situation:** I'm working on a WordPress MultiSite for a charity. They have a Dedicated Apache Server running multiple Domain Names (Accounts). I preparation for Development & Production, which will occur on the same Domain Name within that Dedicated Server, I made a few test installations on a separate Shared Hosting Environment using different Domain Names. No problems whatsoever during these tests on Shared Hosting. I understand the reason why I'm getting the following errors, and I am happy, during Development (which is Password Protected) to switch _CHMOD_ File Permissions of /uploads/ & uploads/site/2 to 0777 in order to be able to Upload from within WordPress, but obviously I'd prefer not to use 0777 for the Production Release. **A question of Hosting Support Time** The charity I work for have a fixed and pre-agreed support contract, which doesn't, at the moment, include Server Support for WordPress. So I want to make sure I approach the Hosting Provider (a Web Design Agency / Hosting Reseller) with a set of definite instruction on how to solve the Server Side issue. Basically, I don't want to run the risk of a seemingly simple Server Support request turning into a lengthy discussion on solutions - I would prefer to provide them with a definitive guide to solving the Server Side / Permissions issue, which is what they'd also prefer, actually. What specific instructions should I give to the Hosting Provider in order to solve the Errors that I've outlined below? **The Problem:**   1. Error: > The uploaded file could not be moved to wp-content/uploads. And for the 2nd Site..., > The uploaded file could not be moved to wp-content/uploads/sites/2. And for Plugins installation..., > Download failed. Destination directory for file streaming does not exist or > is not writable. **My Technical Predicament:** From what I've researched, possible solution:   * **chown?** > you need to chown your installation to the php user too. i.e. if your user > is www-data and they're a member of www-data you'd do $chown -R www- > data:www-data /var/www/wp-content/uploads/sites/ - Source   * **_WP_TEMP_DIR_?** > I'd try adding the following to your wp-config.php file to force it to use > the wp-content directory _define('WP_TEMP_DIR', ABSPATH . 'wp-content/');_ - > Source **Point #1** - I have no experience of dealing with chown, so I'm not sure if this would be the correct guidance I should provide to the Hosting Provider. **Point #2** - from what I've read, it is NOT a good idea to define Constants for /temp/ Directories in this way. And, actually - I would prefer not to extend the wp-config.php as a fix. I'd appreciate your input.


can't edit widgets after moving from subfolder to root

I had some issues with migration: childtheme that was ranamed and working was automatically renamed back + a lot of wrong absolute apps from even older version on site... Now, after I fixed everithing and changed site url to root, front end is working fine but backend has some UI issues; dropmenues/submenues not working and widget ares are not expanding so widgets can't be edited. Any suggestions? EDIT: It seams like only widgets are affected... AJAX?


wpdb updating record in wordpress with json adds extra array elements

This is killing me - I keep getting magical array elements added to my updated array in WP. For example if my query is (var_dumped below):               string(70) "UPDATE wp_mytable SET already_played = '[9]' WHERE user_id = '1'      the already_played cell shows: [9,7] what the hell is going on? Like i say, I var_dump the query and I'm positive its only running once... am I missing something very obvious here? Its set as MEDIUMTEXT. EDIT here is the code:               $allPlays=array('5','6');     $allPlays=implode(',',$allPlays);     global $wpdb;     $my_table = $wpdb->get_blog_prefix() . "mytable";        $newQuery = "UPDATE " . $my_table . " SET already_played = '$allPlays' WHERE user_id = '$userID'";     $someResult = $wpdb->query($newQuery);          //RESULT is not just 5 and 6, but 5,6,and other randoms!!


Display just child pages of a certain page in search results

StackExchangers! I have searched the internet left right and center and still cannot find a way to alter the search results that are displayed. Basically I would like no posts and only child pages of this parent page to be displayed in the search results of my WP Site: http://universitycompare.com/university-guide/ Otherwise, if none of these pages are displayed it would display null results. Any help/direction is appreciated, I did try and gather as much information from here, forums and asking webdev friends - But I am completely stuck so I have resorted to asking StackExchange. Hopefully this isn't too broad and you understand what I have been trying to figure out for days, otherwise if not, please ask for what you need and I can provide.


How can my plugin display a populated new post window

I've written a plugin that creates a feed reader like google reader in wordpress. ![An old screenshot of Orbital Feed Reader](http://i.stack.imgur.com/fg3pg.png) Currently I let folks reblog feed items by using the built in WP PressThis plugin url. I pass in parameters and WP formats a post for my users. I'd like to get more granular control - let my users specify a post format etc. I want to control the title, the body, and maybe even things like tags or format, but I want my users to have a chance to edit it all right before they hit publish to add in their wise thoughts. What's the WP way to do this in my plugin?


Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working

EDIT: So I added the full code. What I'm trying to attempt is to get the post id into the metabox values for a publish immediate and scheduled post. It appears that I'm having trouble passing the id onto get_post_meta. Some of the stack exchange answers have helped to get me here (I believe I can now do an immediate publish via prfx_meta_usa/get_post_meta. But it seems something is stopping the scheduled/future posts from firing. I've been reading a lot of the stack exchange topics on get_post_meta() but it appears that none of them have helped me. I've attempted multiple solutions here and none have really helped and I'm wondering if I'm just not getting it. first its a new install of wordpress and it has twentyfourteen and this plugin as the only active ones. I can echo $post->ID I can echo get_the_ID() When I attempt to use get_post_meta using either of those methods- I come up empty. If I click refresh (my page errors to white screen where I've var_dumped the variables and so I can hit refresh) it then populates with what I need it to do. (I've check the input field on the wordpress page, the database and it seems fine). When I hardcode a previous post into get_post_meta it works like a charm.                $meta_value = get_post_meta( $post->ID, 'meta-text', true );          // Checks and displays the retrieved value     if( !empty( $meta_value ) ) {         echo $meta_value;          } else {         echo "no meta value for meta-text";         var_dump(get_post_meta($id ) );         echo "
 end of var_dump of meta post " ;         $meta = get_post_meta($id );         echo $meta['meta-text'][0]; //this is line 292         echo "
 This is something else ";         echo $thePostID;          }      This outputs               silly test no meta value for meta-textarray(2) { ["_edit_last"]=> array(1) { [0]=>     string(1) "1" } ["_edit_lock"]=> array(1) { [0]=> string(12) "1400387873:1" } }      end of var_dump of meta post      Notice: Undefined index: meta-text in /var/www/wp-   content/plugins/remoteLinkedin/remotelinkedin.php on line 292          This is something else 705      When I click on refresh (and it asks me to resubmit the info) then the get_post_meta output looks like this               silly test     weeee we have lift off!     Wow     array(4) { ["_edit_last"]=> array(1) { [0]=> string(1) "1" } ["_edit_lock"]=> array(1) { [0]=> string(12) "1400387886:1" } ["meta-text"]=> array(1) { [0]=> string(3) "Wow" } ["theta-test"]=> array(1) { [0]=> string(3) "Now" } }       Wow and Now are apart of the get_meta_post($post->ID) var_dump. I'm frustrated as I spent most of my free time the last few days trying to figure out what was going on originally and I suspect somehow I'm messing up in a very silly and stupid way. This is all being down in something that is attached as               add_action( 'transition_post_status', 'linkedin_intercept_all_status_changes', 10 , 3 );      I've tried wp_query, the_ID, get_the_ID so on               echo "
 the post-> " . $post->ID;         print "
 the get id " . get_the_ID();      outputs               the post-> 705     the get id 705      It should be noted they are both on simultaneously and so I was under the impression that if you are in the loop you could get one and not the other??? I'm guessing that I'm not having get_post_meta jumping in at the right moment considering that it decides to work aftera resubmit...is the metapost data saving or something later than the post id...or is something stopping the post id from showing up with get_post_meta?? I apologize for a bit of rambling, I'm not an expert on wordpress and know beginning to intermediate PHP. Side notes: I used http://themefoundation.com/wordpress-meta-boxes-guide/ as the basis for my metabox. I was using advance custom fields but I was getting the same issues. EDIT: I think this is what is saving it?               /**      * Saves the custom meta input      */     function prfx_meta_save( $post_id ) {          // Checks save status     $is_autosave = wp_is_post_autosave( $post_id );     $is_revision = wp_is_post_revision( $post_id );     $is_valid_nonce = ( isset( $_POST[ 'prfx_nonce' ] ) && wp_verify_nonce( $_POST[ 'prfx_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';          // Exits script depending on save status     if ( $is_autosave || $is_revision || !$is_valid_nonce ) {         return;     }          // Checks for input and sanitizes/saves if needed     if( isset( $_POST[ 'meta-text' ] ) ) {         update_post_meta( $post_id, 'meta-text', sanitize_text_field( $_POST[ 'meta-text' ] ) );     }          }     add_action( 'save_post', 'prfx_meta_save' );      EDIT: This is the full code               /**      * Adds a meta box to the post editing screen      */     function prfx_custom_meta() {     add_meta_box( 'prfx_meta', __( 'Meta Box Title', 'prfx-textdomain' ), 'prfx_meta_callback', 'post' );     }     add_action( 'add_meta_boxes', 'prfx_custom_meta' );          /**      * Outputs the content of the meta box      */     function prfx_meta_callback( $post ) {     wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );     $prfx_stored_meta = get_post_meta( $post->ID );     ?>
         <?php _e( 'Example Text Input', 'prfx-textdomain' )?>         <input type="text" name="meta-text" id="meta-text" value="<?php if ( isset ( $prfx_stored_meta['meta-text'] ) ) echo $prfx_stored_meta['meta-text'][0]; ?>" />
          <?php     }          /**      * Saves the custom meta input      */function prfx_meta_save( $post_id ) {          // Checks save status     $is_autosave = wp_is_post_autosave( $post_id );     $is_revision = wp_is_post_revision( $post_id );     $is_valid_nonce = ( isset( $_POST[ 'prfx_nonce' ] ) && wp_verify_nonce( $_POST[ 'prfx_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';          // Exits script depending on save status     if ( $is_autosave || $is_revision || !$is_valid_nonce ) {         return;     }          // Checks for input and sanitizes/saves if needed     if( isset( $_POST[ 'meta-text' ] ) ) {         update_post_meta( $post_id, 'meta-text', sanitize_text_field( $_POST[ 'meta-text' ] ) );     }          }     add_action( 'save_post', 'prfx_meta_save' );          function prfx_meta_use (){           // Retrieves the stored value from the database     $meta_value = get_post_meta( get_the_ID(), 'meta-text', true );          // Checks and displays the retrieved value     if( !empty( $meta_value ) ) {         echo $meta_value;     }     }                                             //****************************************************     //**************************************************************************                /**      * Adds a meta box to the post editing screen      */      function srfx_custom_meta() {     add_meta_box( 'srfx_meta', __( 'Meta Box Title', 'srfx-textdomain' ), 'srfx_meta_callback', 'post' );     }      add_action( 'add_meta_boxes', 'srfx_custom_meta' );          /**      * Outputs the content of the meta box      */     function srfx_meta_callback( $post ) {     wp_nonce_field( basename( __FILE__ ), 'srfx_nonce' );     $srfx_stored_meta = get_post_meta( $post->ID );     ?>
         <?php _e( 'Example Text Input', 'srfx-textdomain' )?>         <input type="text" name="theta-test" id="theta-test" value="<?php if ( isset ( $srfx_stored_meta['theta-test'] ) ) echo $srfx_stored_meta['theta-test'][0]; ?>" />
          <?php      }           /**       * Saves the custom meta input       */     function srfx_meta_save( $post_id ) {          // Checks save status     $is_autosave = wp_is_post_autosave( $post_id );     $is_revision = wp_is_post_revision( $post_id );     $is_valid_nonce = ( isset( $_POST[ 'srfx_nonce' ] ) && wp_verify_nonce( $_POST[ 'srfx_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';          // Exits script depending on save status     if ( $is_autosave || $is_revision || !$is_valid_nonce ) {         return;     }          // Checks for input and sanitizes/saves if needed     if( isset( $_POST[ 'theta-test' ] ) ) {         update_post_meta( $post_id, 'theta-test', sanitize_text_field( $_POST[ 'theta-test' ] ) );     }          }      add_action( 'save_post', 'srfx_meta_save' );          function srfx_meta_use (){           // Retrieves the stored value from the database     $meta_value = get_post_meta( get_the_ID(), 'theta-test', true );          // Checks and displays the retrieved value     if( !empty( $meta_value ) ) {         echo $meta_value;         }      }      Then creating the custom post               function my_custom_post_Linkedin() {     $labels = array(         'name'               => _x( 'Linkedins', 'post type general name' ),         'singular_name'      => _x( 'Linkedin', 'post type singular name' ),         'add_new'            => _x( 'Add New', 'Linkedin' ),         'add_new_item'       => __( 'Add New Linkedin' ),         'edit_item'          => __( 'Edit Linkedin' ),         'new_item'           => __( 'New Linkedin' ),         'all_items'          => __( 'All Linkedins' ),         'view_item'          => __( 'View Linkedin' ),         'search_items'       => __( 'Search Linkedins' ),         'not_found'          => __( 'No Linkedins found' ),         'not_found_in_trash' => __( 'No Linkedins found in the Trash' ),          'parent_item_colon'  => '',         'menu_name'          => 'Linkedins'     );     $args = array(         'labels'        => $labels,         'description'   => 'Holds our Linkedins and Linkedin specific data',         'public'        => true,         'menu_position' => 3,         'supports'      => array( 'title', 'editor', 'thumbnail' ),         'has_archive'   => true,     );     register_post_type( 'Linkedin', $args );         }     add_action( 'init', 'my_custom_post_Linkedin' );      This is my post transition function               function linkedin_intercept_all_status_changes( $new_status, $old_status, $post) {          //globals          global $post;     global $meta;     global $classes;          //$id = get_the_ID();     //$video_value = get_post_meta($id, '_post_video', true);              // Retrieves the stored value from the database        // $meta_value = get_post_meta( $id, 'meta-text', true );          // $linkedin_id = post->id;      if ( ( $new_status == 'publish' ) &&  (get_post_type( $post ) == 'post')) {                                    // Post status changed               require_once('db.php');     require_once('linkedin_3.2.0.class.php');          //http://stackoverflow.com/questions/11370356/having-trouble-with-the-oauth-verifier-for-offline-use-in-simple-linkedin-php     //http://wordpress.stackexchange.com/questions/135422/get-post-meta-doesnt-work     //http://codex.wordpress.org/Post_Status_Transitions     //http://themefoundation.com/wordpress-meta-boxes-guide/     //http://wordpress.stackexchange.com/questions/115852/why-is-my-get-post-meta-always-empty?rq=1     // ^ update_post_meta($post_id,'ch_event_date', 'Chris figured it out');     //          //*************************************     //     //*************************************          //beginning of the formal document     // I know * is not good but until I get it to work we'll leave it like this     $select = "SELECT * FROM wp_twitter WHERE oauth_provider='linkedin' AND wpid='1'";     $result = mysql_query($select);          if (mysql_num_rows($result)===0){           echo "not connected";          }else{          $result = mysql_fetch_assoc($result);          //database variables             $linkedin_oauth_provider = $result['oauth_provider'];             $linkedin_oauth_token = $result['oauth_token'];             $linkedin_oauth_token_secret = $result['oauth_secret'];             $linkedin_uid =  $result['oauth_uid'];             $linkedin_username = $result['username'];             $linkedin_wpid = $result['wpid'];             $user_ID = $result['wpid'];          }               // display constants       $API_CONFIG = array(     'appKey'       => '*****',       'appSecret'    => '*****',       'callbackUrl'  => NULL        );                    $linkedin = new LinkedIn($API_CONFIG);     $linkedin->setToken(array(       'oauth_token' => $linkedin_oauth_token,        'oauth_token_secret' => $linkedin_oauth_token_secret     ));                    $id = print_r(get_the_ID(), TRUE);          //update_post_meta(get_the_ID() , 'meta-text', 'Chris figured it out');     //update_post_meta(get_the_ID() , 'theta-text', 'Chris figured it out');          $post_id = $post->ID;          prfx_meta_save( $post_id );     srfx_meta_save( $post_id );          prfx_meta_use ();     srfx_meta_use ();          $meta_value = prfx_meta_use (); //get_post_meta( $post->ID, 'meta-text', true );     $theta_value = srfx_meta_use ();//get_post_meta( $post->ID, 'theta-text', true );                    $id = get_queried_object_ID();                    $thePostID = get_the_ID(); //print_r ($_POST['ID'], true);            $content = array();             $content['comment'] =  $meta_value; //$thePostID; //get_field('comments_linkedin',$thePostID);//$comment;// get_field('linkedin_comments');              $content['title'] = $post->post_title;//$_POST['stitle'];             $content['submitted-url'] =  $theta_value; //$post_class; //get_field('submit_url_linkedin',get_the_ID());//get_the_ID(); //get_field('submit_url_linkedin',$thePostID); //$urllinkedin;//get_field("linkedin_description");//$_POST['surl'];             $content['submitted-image-url'] = "rockitup";// $meta_value; // $post_class1; //get_field('image_url_linkedin',$thePostID);  //$image_url_linkedin;//get_field("image_url");//'hey'; //get_field('linkedin_image_url');//$_POST['simgurl'];              $content['description'] = $post->post_content;//$_POST['sdescription'];              $private = true;                 // share content       $response = $linkedin->share('new', $content, $private);       if($response['success'] === TRUE) {         // status has been updated        // header('Location: ' . $_SERVER['PHP_SELF']);                           } else {          global $post;                  // an error occured         echo "Error sharing content:

RESPONSE:

" . print_r($response, TRUE) . "

LINKEDIN OBJ:

" . print_r($linkedin, TRUE) . "
";           echo "
 This is the array  ";           print_r($content);           echo "
 printing the post";           print_r($post);           echo "
";                        echo "
 the post-> " . $post->ID;         print "
 the get id " . get_the_ID();                echo "
 var dumping post ";          var_dump($post);//test values in $post                     echo "

" ;          //wp_reset_query();               // function of crazy          $id = print_r($post->ID, TRUE);     print $id;     echo "
 silly test ";           $meta_value = get_post_meta( $post->ID, 'meta-text', true );          // Checks and displays the retrieved value     if( !empty( $meta_value ) ) {         echo "weeee we have lift off!";          echo $meta_value;         var_dump(get_post_meta($post->ID ) );     } else {         echo "no meta value for meta-text";         var_dump(get_post_meta($post->ID ) );         echo "
 end of var_dump of meta post " ;         $meta = get_post_meta(get_the_ID());         echo $meta['meta-text'][0];         echo "
 This is something else ";         echo $thePostID;          }                 }             }     }       add_action( 'transition_post_status', 'linkedin_intercept_all_status_changes', 10 , 3 );      This is the output (not including the linkedin print_r's as that's not the issue)                   This is the array Array ( [comment] => gasfg [title] => asdf [submitted-url] => [submitted-image-url] => rockitup [description] => asd )      printing the post          WP_Post Object (       [ID] => 770 [post_author] => 1       [post_date] => 2014-05-18 15:56:38       [post_date_gmt] => 0000-00-00 00:00:00       [post_content] => asd       [post_title] => asdf       [post_excerpt] =>       [post_status] => draft       [comment_status] => open       [ping_status] => open       [post_password] =>       [post_name] =>       [to_ping] =>       [pinged] =>       [post_modified] => 2014-05-18 15:56:38       [post_modified_gmt] => 2014-05-18 15:56:38      [post_content_filtered] =>       [post_parent] => 0       [guid] => http://www.rivallist.com/?p=770       [menu_order] => 0       [post_type] => post       [post_mime_type] =>       [comment_count] => 0       [filter] => raw )           the post-> 770     the get id 770     var dumping post object     (WP_Post)#265 (24) {       ["ID"]=> int(770)       ["post_author"]=> string(1) "1"       ["post_date"]=> string(19) "2014-05-18 15:56:38"       ["post_date_gmt"]=> string(19) "0000-00-00 00:00:00"       ["post_content"]=> string(3) "asd"       ["post_title"]=> string(4) "asdf"       ["post_excerpt"]=> string(0) ""       ["post_status"]=> string(5) "draft"       ["comment_status"]=> string(4) "open"      ["ping_status"]=> string(4) "open"       ["post_password"]=> string(0) ""       ["post_name"]=> string(0) ""       ["to_ping"]=> string(0) ""       ["pinged"]=> string(0) ""       ["post_modified"]=> string(19) "2014-05-18 15:56:38"       ["post_modified_gmt"]=> string(19) "2014-05-18 15:56:38"       ["post_content_filtered"]=> string(0) ""       ["post_parent"]=> int(0)       ["guid"]=> string(31) "http://www.rivallist.com/?p=770"      ["menu_order"]=> int(0)       ["post_type"]=> string(4) "post"      ["post_mime_type"]=> string(0) ""       ["comment_count"]=> string(1) "0"       ["filter"]=> string(3) "raw" }           770      silly test weeee we have lift off!gasfg          array(4) {      ["_edit_last"]=> array(1) { [0]=> string(1) "1" }      ["_edit_lock"]=> array(1) { [0]=> string(12) "1400428598:1" }      ["meta-text"]=> array(1) { [0]=> string(5) "gasfg" }      ["theta-test"]=> array(1) { [0]=> string(3) "sdf" } }            Warning: Cannot modify header information - headers already sent by (output started at /var/www/wp-content/plugins/remoteLinkedin/metabox.php:71) in /var/www/wp-admin/post.php on line 233          Warning: Cannot modify header information - headers already sent by (output started at /var/www/wp-content/plugins/remoteLinkedin/metabox.php:71) in /var/www/wp-includes/pluggable.php on line 896


qTranslate: Hide untranslated content

I know qTranslate has the option to hide untranslated content, but that doesn't seem to work. I.e: I have a website with three languages: Dutch, French and English. There is one particular page that has some subpages that are only available in Dutch. I want them to show up on the Dutch website, but hide them completely from the French and English site. Like so:   * MenuItem1   * MenuItem2      * MenuItem2.1     * MenuItem2.2   * MenuItem3 So MenuItem2 and it's subpages are only available in Dutch. I want them hidden on the English/French website. Is this possible with qTranslate, or another plugin? Or is there a piece of code that will allow this? Thanks.


get id custom tables on current page

i will get id on current page.               <?php          $hasil = $wpdb->get_results("SELECT id,bab,tema FROM $tabel ORDER BY bab ASC");         foreach ($hasil as $bab) :         ?>
                 <?php  echo $bab->bab;?>	                 <?php  echo $bab->tema;?>	                 <a href="<?php echo get_permalink(get_page_by_path('lks')).'?id='.$bab->id;?>">Kerjakan
         <?php endforeach; ?>      then urls showing :               localhost/wordpress/lks?id=2      and works on after page if i call $_GET['id']. but i will urls showing :               localhost/wordpress/lks/2      and i change permalink               <?php echo get_permalink(get_page_by_path('lks')).'/'.$bab->id;?>      Dont work on after page if i call $_GET['id']. How can i get id 2 the url on after page? or there are other ideas that I can get the id with the url? Thanks.


Wp-query causing problems with the_content();

I'm using some code provided in an answer on here to calculate "post X of Y" and display pagination icons on single.php. It works beautifully but it's causing problems displaying `the_content();` On my local MAMP server it displays the content from the first post on every post, and on my web server it doesn't display the content at all. * * * My full code is below:
              <?php              // save current id to match later         $current_project_id = $post->ID;              $args = array(             'post_type' => 'portfolio',             'posts_per_page' => -1         );         $all_projects = new WP_Query( $args );              ?>
              <?php              while( $all_projects->have_posts() ) : $all_projects->the_post();                  // simple 'if' test to find the current post in the loop             // note that current_post starts at zero, which is why we add 1 to it.             // you can also output the_title, the_permalink, thumbnails, etc..                  $permalink = get_permalink();             $projectnum = $all_projects->current_post+1;                  if( $post->ID == $current_project_id ){                 echo "

";             }else {                 echo "

";             }              endwhile;              ?>

      Any help would be appreciated! Thank you


How do I get the avatar URL instead of an HTML IMG tag when using get_avatar?

I'm using a plugin called Simple Local Avatars which lets me upload author images which are stored on my server locally (no Gravatar). The plugin works fine and `get_avatar` returns the local avatar. However, I need to use that avatar in different ways and different places and for that I need the local avatar image URL instead of the entire HTML tag. I could write a wrapper function for `get_avatar` that uses RegEx or SimpleXML to pick out and return only the URL, but I was wondering if there's any existing way to do this.


Front End Plugin for User Management

Is there a free plugin that I can use for a membership site which includes user login, registration and profile management all from WordPress front end? Thanks


How do I output a list of categories from a tag?

I want to show a list of categories associated to a tag. So say now I have two posts:   1. Brown Sneakers which is in the Category GOLF child of SPORT and tagged USA and    2. Pink shorts which is in the Category LADIES child of CLOTHING and also tagged USA  When viewing the USA tag page I would like to see as a list, CLOTHING and SPORT (with its sub cats of course). There are going to be many countries sharing categories like sport and clothing for example so I don't want to add the countries as parents and have long lists of duplicated child categories. I have set up a custom post type with a custom hierarchical taxonomy called Product Categories and another custom non-hierarchical taxonomy (tags) called Countries. I then created a new archive template that displays all the tagged posts. At the moment it displays all the tagged posts but what I am trying to get it to display is a list of categories in a tag instead... if that is at all possible. This is something I am playing around with but it isn't working:                <?php $terms = get_the_terms( $post->ID , 'countries' );?>      <?php      $args = array(      'tag_id' => $terms,      );     get_the_category_list($args);     ?>      Can somebody please steer me in the right direction?


How do I alter the comment form 'allowed tags' text in a plugin?

I'm using the PHP Markdown plugin, and I'd like to modify it so that it adds some text to the bottom of the comment form indicating that Markdown is supported in comments. I've been modifying my theme to do this, but the theme is updated quite frequently and I don't want to create a custom version of it for a single line of text to be preserved. In my `comments.php` file (Theme is ZBench) I have the following:               $comment_notes='
' . __('NOTE - You can use these ','zbench') . sprintf(('HTML '.__('tags and attributes:','zbench').'
%s' ), ' ' . allowed_tags() . '' ) . '
';      I simply want to add to that indicating Markdown is active, and presumably the ideal way to do that is to alter the output of `allowed_tags()`. Is this possible to do with `add_filter()`, or am I looking at the wrong function? I want to modify the plugin itself, so that the extra line is added only if the plugin is active.


Is it possible to build social networking website using WordPress?

Can one WordPress install handle at least 100,000 user profile pages (5m visitors a month), 20-100 pictures per profile, taging, facebook-like wall, private messaging system etc.? What's the limit with WordPress? When thigs will get really slow? The biggest sites I've seen so far are Envato's marketplaces like ThemeForest but content there is added by editors, mostly. Do you have any examples of such sites?


Creating Featured Content Boxes

I know there are plenty of plugins to do sliders out there but I'm looking for something slightly different and I've come up with no luck for a solution. Basically, what I am trying to accomplish is to have a set of images (thinking of around 4) that sits statically above my content. Preferably it would pull the featured image and the title from posts with a specific tag or category and list them up there. Basically, a slider that doesn't slide I suppose. I've included a screenshot of what I mean. Does anyone know of a plugin that would achieve this or a good tutorial on creating something like this? ![Example](http://i.stack.imgur.com/eMkJu.jpg)


Make multiple pages and set template/content on theme activation?

I am wanting to make about 6 pages or so on theme activation, and I have found two ways to do it on this site. One will make as many pages needed and that is all, the second one will make only one page but allows me to pick a page template and content. I am looking for a kind of mash up of the both, but have not been able to get it to work. I would like to make as many pages as needed and for each page set a template and content if needed. Here is the code I have that will make more than one page.               function create_initial_pages() {         $pages = array(             'page1' => 'Page 1',             'page2' => 'Page 2',             'page3' => 'Page 3',             'page4' => 'Page 4'         );         foreach($pages as $page_url => $page_title) {             $id = get_page_by_title($page_title);             $page = array(                 'post_type'   => 'page',                 'post_name'   => $page_url,                 'post_title'  => $page_title,                 'post_status' => 'publish',                 'post_author' => 1,                 'post_parent' => ''             );             if (!isset($id)) wp_insert_post($page);         };     }      And here is code that will make one page but set content and a page template               if (isset($_GET['activated']) && is_admin()){         $new_page_title = 'Sitemap';         $new_page_content = ' ';         $new_page_template = 'sitemap.php'; //ex. template-custom.php. Leave blank if you don't want a custom page template.         //don't change the code bellow, unless you know what you're doing         $page_check = get_page_by_title($new_page_title);         $new_page = array(                 'post_type' => 'page',                 'post_title' => $new_page_title,                 'post_content' => $new_page_content,                 'post_status' => 'publish',                 'post_author' => 1,         );         if(!isset($page_check->ID)){                 $new_page_id = wp_insert_post($new_page);                 if(!empty($new_page_template)){                         update_post_meta($new_page_id, '_wp_page_template', $new_page_template);                 }         }     }      ## Does anyone know a way to get this done? Edit: If able, I could also see having use for creating a child page as well but not that needed.


What is the Timeline for the Active Version Pie Chart in the Repository?

When going through your own plugin details and checking the active version downloads. It's helpful to see which version that webmasters prefer, but I see no details on the subject on WordPress (and on here, yet). I recently had an unexpected change in stats, and I can't find anything as to what the time frame is. What few that I have found are either closed with little or no response, and/or indirectly related. The active version pie chart can be found on any plugin under **Stats**.               http://wordpress.org/extend/plugins/[PLUGIN-NAME]/stats/      Most of the time, new versions don't even show up until about a day or so, but is the timeline based on days, weeks, or months? This says that it is based on the current active users. Which is interesting. Daily Tip: New Usage Graphs on WordPress.org Plugin Repository Any additional information on how the chart actually works is helpful.