title: Filter Hook Returning Blank When Used Twice

text:
This is a pretty lengthy question, so bare with me. In a plugin I've written that allows users to easily create new meta boxes, I have a function that uses a switch() to return the appropriate HTML for the kind of meta field being added. The function looks like this:               // displays the requested field type     function ecpt_render_field($field, $meta) {              global $wp_version, $post, $ecpt_options;              switch($field['type']) :                  case 'text' :                 $field_html = '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . stripslashes($meta) . '" size="30" style="width:97%" />
' . __(stripslashes($field['desc']));                 break;                      /*****************************************************************                 * lots of case statements here have been removed for this example                 ******************************************************************/              case 'checkbox' :             $field_html = '<input type="checkbox" name="' . $field['id'] . '" id="' . $field['id'] . '" ' . checked(!empty($meta), true, false) .'/>
' . __(stripslashes($field['desc'])) . '
';             break;                    endswitch;                if(has_filter('ecpt_fields_html')) {             // this adds any addon fields (from plugins) to the array             $field_html = apply_filters('ecpt_fields_html', $field, $field_html, $meta);         }                 // return the final field         return $field_html;     }      $field is an array that contains all of the information for the field (id, type, class, etc). $meta is the value stored in the post meta. At the end of the function there is a check for the existence of the "ecpt_fields_html" filter. This is a filter I've setup to allow additional meta field types to be registered via other plugins. An example function that registers additional field types (successfully), looks like this:               // generates the HTML for the additional fields     function ecpt_bonus_fields_html($field, $field_html, $meta) {              switch($field['type']) :                  case 'taxonomy' :                 // returns the options html for select fields                 $field_options = ecpt_get_field_options($field, $meta);                 $field_html =  '<select name="' . $field['id'] . '" id="' . $field['id'] . '">' . $field_options . '</select>
' . $field['desc'];                 break;                  case 'separator' :                 $field_html = '
';                 break;                            case 'colorpicker' :                 if (empty($meta)) $meta = '#';                 $field_html = "<input class='ecpt-color' type='text' name='" . $field['id'] . "' id='" . $field['id'] . "' value='" . $meta . "' size='8' />                         " . __('Select a color') . "                         " . __('Hide Picker') . "

";                 break;                  default :                 $field_html = $field_html;              endswitch;              return $field_html;     }     add_filter('ecpt_fields_html', 'ecpt_bonus_fields_html', 10, 3);      This function to register extra field types works exactly like the first one. Now, let's say that I have the the function above activated in an add-on plugin (everything works fine), and then I setup a second plugin that has a second function that registers more field types (this new second function is structured exactly like the filter function above). If I do this, both of the filter functions that register new field types fail completely. They don't throw any errors, but the "return $field_html;" statement simply returns nothing at all. The second filter function looks like this:               // generates the HTML for the additional fields     function ecpt_sample_fields_html($field, $field_html, $meta) {              switch($field['type']) :                  case 'textblock' :                 $field_html = 'this should be shown in the metabox, but is not';             break;                        endswitch;              return $field_html;     }     add_filter('ecpt_fields_html', 'ecpt_sample_fields_html', 10, 3);      Both filter functions work perfectly when the other is not active, but if both are active, then the *$field_html = apply_filters('ecpt_fields_html', $field, $field_html, $meta);* in the very first function results in nothing, just blank. Alright, now is where it gets a little stranger. I have an almost identical set of functions / filters setup that display the labels for the field types in the meta box. They work perfectly fine. In the core plugin, the function that setups the label for each field looks like this:               // run the label through a filter. This allows us to modify/remove the label for any field type     function ecpt_field_label($field) {         $label = '' . __(stripslashes($field['name'])) . '';         // the ecpt_field_label_filter allows the field label output to be altered for any field type         if(has_filter('ecpt_field_label_filter')) {             $label = apply_filters('ecpt_field_label_filter', $label, $field);         }         return $label;     }      And the filter function that allows the label HTML to be changed for fields registered with other plugins looks like this:               // modify the labels for the bonus fields (if needed)     function ecpt_bonus_fields_labels($label, $field) {              if($field['type'] == 'separator') {             // removes the label for the separator field             return;         }         if($field['type'] == 'header') {             return '
' . $label . '
';         }         return $label;     }     add_filter('ecpt_field_label_filter', 'ecpt_bonus_fields_labels', 10, 2);      This works perfectly fine, even when I setup a _second_ label filter function (remember, setting up the second function for the field types is what caused it to break). So my second filter function for the labels looks like this:               // modify the labels for the bonus fields (if needed)     function ecpt_sample_field_labels($label, $field) {              if($field['type'] == 'textblock') {             return '' . $label . '';         }         return $label;     }     add_filter('ecpt_field_label_filter', 'ecpt_sample_field_labels', 10, 2);      The _only_ difference (aside from using switch() and i() statements) is that the filter types filter has 3 parameters and the field labels filter has 2. At least that is the only difference I can find. Below are screenshots that illustrates the issue. ![Only the first filter function is active, used to register the Color field](http://i.stack.imgur.com/VJvri.jpg) ![Both filter functions are active. The field labels work, but not the input fields](http://i.stack.imgur.com/VYZlW.jpg)


title: querying on custom meta fields and sorting them by custom meta

text: I have event posts with multiple custom date and time fields. To pull all the events happening this week, I am querying on the different date fields. Here is my code:               $today=date("Y-m-d");     $nextweek= date("Y-m-d", strtotime("+7 days"));          $args2 = array(          'post_type' => 'post',     'meta_query' => array(     'relation' => 'OR',          array(     'key' => 'date2',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN'     ),     array(     'key' => 'date3',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN'     ),     array(     'key' => 'date1',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN'          )     )     );     $query2 = new WP_Query( $args2 ); ?>      When I put var_dump($query2->request) after this, I get the following string:               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID      FROM wp_posts      INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)      INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)      INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id)      WHERE 1=1 AND wp_posts.post_type = 'post'      AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')      AND (        (wp_postmeta.meta_key = 'date2' AND CAST(wp_postmeta.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')        OR (mt1.meta_key = 'date3' AND CAST(mt1.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')        OR (mt2.meta_key = 'date1' AND CAST(mt2.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')      )      GROUP BY wp_posts.ID      ORDER BY wp_posts.post_date DESC LIMIT 0, 10      This is pulling the correct posts, but now I want to sort the results on the date1 field. I tried this and it isn't working. I end up with all of the events posted, and not sorted either. I've also tried the 'meta_value' for orderby without luck. The values in the date1 field are in date format YYYY- MM-DD Any help would be appreciated.               $args2 = array(     'order' => 'ASC',     'meta_key' => 'date1',     'orderby' => 'meta_value_num',     'post_type' => 'post',     'meta_query' => array(     'relation' => 'OR',          array(     'key' => 'date2',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN'     ),     array(     'key' => 'date3',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN'     ),     array(     'key' => 'date1',     'value' => array( $today, $nextweek ),     'compare' => 'BETWEEN',          )     )          );          $query2 = new WP_Query( $args2 ); ?>      When I put var_dump($query2->request) after this I get:               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID      FROM wp_posts      INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id      INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)      INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id)      INNER JOIN wp_postmeta AS mt3 ON (wp_posts.ID = mt3.post_id)      WHERE 1=1      AND wp_posts.post_type = 'post'      AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')      AND (wp_postmeta.meta_key = 'date1'        OR (mt1.meta_key = 'date2' AND CAST(mt1.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')        OR (mt2.meta_key = 'date3' AND CAST(mt2.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')        OR (mt3.meta_key = 'date1' AND CAST(mt3.meta_value AS CHAR) BETWEEN '2013-05-21' AND '2013-05-28')      )      GROUP BY wp_posts.ID      ORDER BY wp_postmeta.meta_value+0 ASC LIMIT 0, 10


title: Wordpress won't let me use a page slug of 'feed'

text: I want to make a custom feed page* with the slug of 'feed', but when I try to save, Wordpress changes it to 'feed-2'. Is there a way I can force Wordpress to let me use a slug of feed—or, if it's better practice, to hook my custom feed template* into the default Wordpress RSS feed generator? If the latter, what code do I need to substitute my own feed template for the default? * The custom feed template I'm using is based on the useful code here: http://digwp.com/2011/08/custom-feeds/


title: Best way to categorize/populate a magazine style layout

text: I'm taking the reigns of an existing Wordpress site that has a magazine-style home page with sections for featured articles, upcoming events, different categories of articles, etc. Currently, these fields are populated with a hodgepodge of different taxonomy - the page uses categories, tags, **and** sticky posts to correctly populate the content. Using all three seems a big excessive. What's the best method of categorizing and populating a magazine style layout. Just being driven by the category of the article, etc? Or are their plugins/methods for the editors to directly choose specifically which article appears where.


title: How to load previous or next attachment with jquery ?

text: When i am on the single.php page, i show the first image attachment. then i would like to load the next (and previous) image attachments without reloading the page. so in single.php i started with this to retrieve an array with the images html:               <?php $args = array('post_type' => 'attachment', 'post_mime_type' => 'image', 'order'=> 'ASC', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );            $attachments = get_posts($args);       if ($attachments) {                 foreach ( $attachments as $attachment ) {                      $my_image = wp_get_attachment_image($attachment->ID, large) );              $attachments_list[] = $my_image;         }       }       reset($attachments_list);       $first_image = current($attachments_list);       echo $first_image;      ?>      and then in the script.js file i would like to get the value of my php array $attachments_list to do something like this :               $(document).ready(function(){         var count = attachments_list.lenght();         var init = 0;         var current = init;              if (count > 1) {             $('#next-img').click(function() {                 if (current+1 < count) {                     current++                 } else if (current+1 === count) {                     current = init;                 }                 $('#image-container').html(attachments_list[current]);             });             $('#previous-img').click(function() {                 if (current > init) {                     current--                 } else if (current === init) {                     current = count-1;                 }                 $('#image-container').html(attachments_list[current]);             });         }     });      how can i retrieve the value of the php $attachments_list array to attachments_list inside the script.js file ? Json maybe ? thanks for your attention


title: Ajax form filter post by custom fields

text: I'm currently working on a site where users can search for apartments. I have a custom post type for the apartment posts, which contain several custom fields. I have a page where i list all of the apartments. What i want to do is have a form, containing check boxes, drop-downs and radio button, where the user can filter apartment posts by custom fields. For example by price or size. So when the users clicks on an check-box for example i want the result field to be refreshed. Much like this one product-sort. I know this can be done via the query, but i would like an AJAX function to filter the post without reloading the entire page. I have tried Ultimate WP Query Search Filter plugin but it didn't work that well. I have done a lot of searching to find a solution, but i'm not a ajax/javascript master. So can you point in some direction, maybe with some code to help me out?


title: Single Page View for Paginated Posts

text: Okay, so you know how you can break up a wordpress post by inserting the next- page/page break quicktag. Then, using the wp link pages function in your template, wordpress will generate page 1, 2, 3, etc. links for your now paginated post. Great. But is there any way to put the post back together again? Think about all the online magazines and newspapers that break their articles into pages and then offer some variation on a "single page view." Can you do that with Wordpress? I spent the whole weekend trying to google a solution and came up with exactly nothing.


title: Is there a way to prevent a function/method from being called outside a specific hook?

text: I would like to make function only callable by a specific action, in this case the `register_activation_hook()` function. How can I do this?


title: Is there a Image Gallery which will load all my posted Images like twitter's image grid?

text: Many of my wordpress posts have images in them for my personal blog. I have been searching for a good way to display all of the images from all of the posts in a grid layout on a page. Similar to the twitter grid layout seen here. I have seen Next Gen Gallery, and was wondering if there is a way not just images from the current post, but ALL of the images from all posts into a collecting on one page. Thanks


title: split searchresults into different topics?

text: How could I split the searchresults into topics. I have e.g. three Topics - cars | computers | culture all are "custom post types" . Now a user searches for term "speed" in the searchbox and the resultpage would be something like this:               cars ---           2 Posts with "speed" in Cars.     searchresults          computers ---          10 posts with "speed" in Computers     searchresults          culture ---          0 nothing found for "speed" in Cutlure.     searchresults      any way to make this work? Need different loops I guess? thank yoU! AD


title: How to get cropped thumbnail source for custom post type

text: I need thumbnail image url with size 148*148px. I using custom post type for testimonials. I need just the image source like http://example.com/demoimage.jpg. It is possible to get cropped image source. 'add_image_size' doesn't solve my problem. I have some classes and some data attribute in my <img> tag. Please help Thank You


title: Replacing global wp_query

text: I have a site that uses a custom query to search for posts by country. The search results come back fine, but the pagination at the bottom reflects the total number of posts in the site, instead of the total number of posts in the search results. The plug in that manages this uses global $wp_query to determine the number of posts, instead of the custom query. By default, it works like this:               function wp_page_numbers($start = "", $end = "")     {         global $wp_query;         global $max_page;         global $paged;         if ( !$max_page ) { $max_page = $wp_query->max_num_pages; }         if ( !$paged ) { $paged = 1; }              $settings = get_option('wp_page_numbers_array');         $page_of_page = $settings["page_of_page"];         $page_of_page_text = $settings["page_of_page_text"];         $page_of_of = $settings["page_of_of"];              $next_prev_text = $settings["next_prev_text"];         $show_start_end_numbers = $settings["show_start_end_numbers"];         $show_page_numbers = $settings["show_page_numbers"];              $limit_pages = $settings["limit_pages"];         $nextpage = $settings["nextpage"];         $prevpage = $settings["prevpage"];         $startspace = $settings["startspace"];         $endspace = $settings["endspace"];              if( $nextpage == "" ) { $nextpage = ">"; }         if( $prevpage == "" ) { $prevpage = "<"; }         if( $startspace == "" ) { $startspace = "..."; }         if( $endspace == "" ) { $endspace = "..."; }              if($limit_pages == "") { $limit_pages = "10"; }         elseif ( $limit_pages == "0" ) { $limit_pages = $max_page; }      I tried modifying it to this:               if ($gallery_query){ $page_query=$gallery_query; }else {$page_query=$wp_query;}         global $max_page;         global $paged;         if ( !$max_page ) { $max_page = $page_query->max_num_pages; }         if ( !$paged ) { $paged = 1; }      But that returns no pages. Ideally, I should replace the $wp_query value with the $gallery_query value, but I don't know how. The obvious `$wp_query = $gallery_query` doesn't work. Any suggestions? Thanks! ty


title: Page title in post query

text: How do i add the current post/page title in a post query? I've tried this, doesn't work:               query_posts( 'posts_per_page=10category_name=&' . $post->post_title); if (have_posts()) : while (have_posts()) : the_post();


title: wp_rewrite not working on third level url

text: I have the following code :               global $wp;             $wp->add_query_var('akey');             $wp->add_query_var('sort');             $wp->add_query_var('paged');             add_rewrite_rule('^activate/([^/]*)/?','index.php?pagename=activate&akey=$matches[1]','top');             add_rewrite_rule('^users/$','index.php?pagename=users','top');             add_rewrite_rule('^users/most-active/?','index.php?pagename=users&sort=mostactive','top');             add_rewrite_rule('^users/most-active/paged/([^/]*)/$','index.php?pagename=users&sort=mostactive&paged=$matches[1]','top');             add_rewrite_rule('^users/recent/?','index.php?pagename=users&sort=recent','top');             add_rewrite_rule('^users/recent/paged/([^/]*)/$','index.php?pagename=users&sort=recent&paged=$matches[1]','top');             add_rewrite_rule('^users/oldest/?','index.php?pagename=users&sort=oldest','top');             add_rewrite_rule('^users/oldest/paged/([^/]*)/$','index.php?pagename=users&sort=oldest&paged=$matches[1]','top');             add_rewrite_rule('^users/by-username/?','index.php?pagename=users&sort=byusername','top');             add_rewrite_rule('^users/by-username/paged/([^/]*)/$','index.php?pagename=users&sort=byusername&paged=$matches[1]','top');      the problem is the following users/recent/ works while users/recent/paged/number/ does not work Any ideas ? Thanks


title: Theme my Login plugin, how to update fields

text: I'm using the Theme my Login plugin for a client project and I'm having trouble updating profile fields once a user has been registered; I followed the instructions here but they didn't seem to have any effect. If anyone could shed some light on it that would be great. This is my current code; `register-form.php`               <p>         <input           type="text"           name="phone_number"            id="phone_number<?php $template->the_instance(); ?>"            class="input"            value="<?php $template->the_posted_value( 'phone_number' ); ?>"            size="20"            tabindex="20"            placeholder="Phone Number"         />     </p>      `profile-form.php`               <p>         <input            type="text"            name="phone_number"            id="phone_number"            value="<?php echo esc_attr( $profileuser->phone_number ); ?>"            class="regular-text"            placeholder="Phone Number"         />     </p>      `theme-my-login-custom.php`               function tml_user_register( $user_id ) {             // Phone Number             if ( !empty( $_POST['phone_number'] ) )                 update_user_meta( $user_id, 'phone_number', $_POST['phone_number'] );     }     add_action( 'user_register', 'tml_user_register' );


title: Advanced Custom Fields: how do I check to see if a value is set in an field?

text: How do I check and see if a value is set in an Advanced Custom Field?


title: WooCommerce plugin appearance and look

text: Is it possible to customize WooCommerce plugin the same as my own theme? Im about to finish the theme development, and I was wondering if it's possible to style the WooCommerce Checkout system that it looks the same as the theme Im creating? Thanks


title: What the mean about 'child theme'?

text: I have read on codewordpress about this issue. In the article "A WordPress child theme is a theme that inherits the functionality of another theme". And then on stylesheet use import style from parent style `@import url("../twentythirteen/style.css");` Lets take example with twenty thirteen. So I have current conclusion that is good system for fast & simple development. We no need build from scratch and no need update in future because parent update->child also updated. But yesterday, I found that this theme claim is child from twenty thirteen. I check it, but I don't see any import style to twenty thirteen and all php file is all there (I create child theme and just php file from twenty thirteen that have in my theme as example function.php, header, footer, and content-_*). Any wrong with my conclusion about child theme? One other part of my question and for help me for mistake in future. If we use child theme and override some function and style on twenty thirteen. Does in future (when parent theme updated) the function and style still used?? For example: `#article {code override}` Is this id/class will be still used? `function foo(){all code}` Is this function (example) in functions.php will be still used? I hope anyone can explained more to me so It confused will be done. Thanks


title: calling an additional css and js links for a custom page template

text: I am building a custom page for portfolio. It will require additional css and jss file for the navigation slider... Since that part is contained in the header.php I decided to take the part I need and hoped it would accept my tags for the external files. Though the link can be seen in the page's head tag, they are not being called. I have looked extensively and all the suggestions points to using wp_enqueue_script() and wp_enqueue_style() which is an overkill. Even trying them does not help and I would like to call the external links only if someone visits the portfolio page and not burden the rest of the site. I will appreciate some insight. www.gransar.net/portfolio


title: Get cat parameter from admin-ajax

text: I have a plugin that restricts the categories users can view/edit in the admin. All works fine in WordPress 3.0.1, but as I started testing 3.1 I noticed that the category filter, which is AJAX, allows you to bypass the restrictions. I'm able to filter this out in 3.0.1 because it's submitted via URL parameters. My trouble is being able to $_GET the 'cat' parameter from the new AJAX request. I have tried testing for $_SERVER['HTTP_X_REQUESTED_WITH'], but it doesn't register. I've asked this question on the wp-hackers mailing list, but no one can give me actual code that helps with my predicament.


title: Basic gallery plugin suggestion

text: I'm developing a custom wp theme which needs a gallery function. I looked over a few popular gallery plugins, but all of them seem "bloated" with a lot of unnecessary stuff. Do you have any recommendations of a light gallery plugin that allows the admin to upload photos and group them into galleries?


title: Links from the_tag not working

text: I am using Wordpress to output different content types here: http://www.africanhealthleadership.org/resources/articles/ Each type of content is tagged accordingly. Users should be able to click on these tags & see all items marked with that tag e.g. clicking the word "Article" above the article name would take someone to a full list of articles. However, the tag links are not working: clicking does nothing. This is the code I used to output the tag and article name. ` ## ### ` When I check the page with Firebug, I see a link such as Is the rel preventing the links from working? Or is it my goofy little brain? Thanks for any ideas, Jeff


title: Display WordPress commenter nice name

text: I'm working on a custom plugin that needs to display specifically the commenter's nice name. The codex shows how to do this for the logged in user but not someone else. Can this easily be done?


title:
How to determine, from plugin script, if active theme has
The Post Title

text: My plugin needs to know if the currently active theme places the post title in H1 heading tags? I'm looking for suggestions on approaches to create script that could discern this. UPDATE: The plugin evaluates the SEO profile of the post content to help the user make improvements for search rankings. Second only to the post title, the h1 tag is one of the most important tags for SEO. However, I don't want to ask the user to include their primary keyword in an h1 heading tag in the post content if the theme already does that (as many do).


title: Prevent user from editing others posts

text: I have declared a new post type and it is visible on the admin menu: function create_post_type() {                   register_post_type( 'employer_fm',           array(             'labels' => array(           'name' => _x('Employer', 'Employers'),           'singular_name' => _x('Employer ', 'domain'),         ),             'public' => true,              'capability_type'    => array('employer','employers','adminstrator'),                  'supports' => array('title','author','thumbnail','page-attributes'),             'capabilities' => array(                   'read_post' => 'read_employer',                   'publish_posts' => 'publish_employer',                   'edit_posts' => 'edit_employers',                   'edit_others_posts' => 'edit_others_employer',                   'delete_posts' => 'delete_employer',                   'delete_others_posts' => 'delete_others_employer',                   'edit_others_pages' => 'edit_others_employer_page',                   'read_private_posts' => 'read_private_employer',                   'edit_post' => 'edit_employer',                   'delete_post' => 'delete_employer',                  ),           )         );       }      I have also declared roles:               $result = add_role(             'employer',             __( 'Employer' ),             array(                  'edit_employer'   => true,                 'edit_employers' => true,                 'publish_employer' => true,                 'read_employer' => true,                 'delete_employer'=> true,                 'edit_others_employer' => false,                 'delete_others_employer' => false,                 'edit_others_employer_page' => false             )         );           $role = get_role( 'administrator' );          $role->add_cap( 'edit_employer' );           $role->add_cap( 'read_employer' );           $role->add_cap( 'delete_employer' );           $role->add_cap( 'edit_employers' );           $role->add_cap( 'publish_employer' );       if `'map_meta_cap' => true,` Users can only view and publish posts (including admin) and if it it not set all users can edit all employer type posts. How can I prevent `employer` user types from editing others posts?


title: Frontend posting - everything saves other than checkboxes?

text: I have a form on the frontend of Wordpress which is saving all fields except a checkbox array. It displays and saves the correct values if I tick the boxes in the backend post editor, and the ticks show correctly on the front. However ticking a box on the frontend doesnt save! All other fields save correctly from font and back.I have spent a long time trying to figure it out however it doesn't seem to work, any help would be **greatly** appreciated. Here's the code:               $query = new WP_Query( array( 'post_type' => 'property', 'posts_per_page' => '-1' ) );           if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();           if(isset( $_GET['post'] ) ) {         if ( $_GET['post'] == $post->ID ) {             $current_post = $post->ID;             $options = $custom_meta_fields[7]['options'];             $checkboxes = get_post_meta($current_post, 'custom_cgtest', true);     }     }     endwhile; endif;      wp_reset_query();     global $current_post;          if(isset($_POST['submitted']) && isset($_POST['post_nonce_field']) && wp_verify_nonce($_POST['post_nonce_field'], 'post_nonce')) {     $post_information = array(     'ID' => $current_post,     'post_title' => ($_POST['post_title']),     'post_content' => esc_attr(strip_tags($_POST['postContent'])),     'post-type' => 'property',     'post_status' => 'publish',     );              $post_id = wp_update_post($post_information);     if($post_id) {      update_post_meta($post_id, 'custom_cgtest', ($_POST['cbn']));     }     }      In the page:               foreach ($options as $option) {           echo '<input type="checkbox" name="cbn[]" id="'.$option['value'].'"',$checkboxes && in_array($option['value'], $checkboxes) ? ' checked="checked"' : '',' /> ';         echo $option['value'];         }      In functions.php:               array (       'label' => 'Checkbox Group',       'desc'  => 'A description for the field.',       'id'    => $prefix.'cgtest',       'type'  => 'cgtest',       'options' => array (           'one' => array (               'label' => 'Option One',               'value' => 'one'           ),           'two' => array (               'label' => 'Option Two',               'value' => 'two'           ),           'three' => array (               'label' => 'Option Three',               'value' => 'three'           )       )       )      If you require any more code please let me know.


title: Server-side sorting of posts

text: I have seen on some websites that you can sort posts server-side by passing in some queries like so: `domain.com/?sort=date` or `domain.com/?sort=name` How would I do this with WordPress posts on a page?


title: Redirect homepage ( www.sitename.com ) to the latest post

text: I'm just wondering how I would go about redirecting to the latest post when you go to the web site? Similar to http://gregorywood.co.uk/ Many thanks :) Suleiman


title: Give a unique ID while saving

text: I have in my theme custom post types (products) with some meta-boxes. My client asked me, to automaticly give a unique SKU (meta-box) while saving that product. My thought: > Give a random ID => have to check if that ID somewhere else exists OR > > Give the Post-ID => that is just possible after saving once, cuz WP assign > that ID while saving. **@Milo** "additionally, a new post already has an ID before the user saves the post" How can I get the ID before I save the post and put it into that meta box and save it with a new post at once? Thanks


title: How to use checkbox and radio button in options page?

text: Call me stupid but I coudn't figure out how to do it. For text input I would just:               <input type="text" name="option_name"  value="<?php echo get_option( 'option_name' ); ?>" />      and then hook it into workdpress using `register_setting()`. I could then get its value thru `get_option('option_name')`. How should I do that with checkboxes and radio buttons?


title: How do I migrate custom post type data to a new format?

text: I am renovating an old site that has a messy custom post type. Over the years, it has accumulated redundant fields and taxonomies. I have replaced it with a new CPT that reflects the client's current business logic, and now I need to migrate the old data to the new format. This is the process I have in mind for migrating the post metadata:   1. Add both old and new CPT and related taxonomy definitions to a blank theme.   2. Output meta data and taxonomy terms for a sample of the old posts, and for an example of a new post. Look for patterns, and build up a `$migrationMap` array, where each element is `Relation` object: ### Relation     * `$oldKey`     * `$newKey`     * `function translate( $oldVal ) -> $newVal`     * (optional) `function verify( $oldVal, $newVal ) -> $ok`   3. Dry run: Loop over the old CPT and make sure that all `verify` funtions pass. `var_dump` the output, a translated version, of each post, and make sure it looks good.   4. Do it again, but this time run the outputs through `wp_insert_post` to complete the migration of the CPT data. And then, repeat the process for taxonomies. Has anyones else done this? Does anyone know if there is a simpler / easier way?


title: unable to access network admin of a blog

text: I am unable to see it network admin link in a multisite blog. Can anyone tell me how to activate it again? I am logged in as super user. For the main blog I could see, I used to see the network admin link previously for any other blogs too if am logged in as super user but now I am unable to see. check the below images, Before, I can see network for all sites if am logged in as super user ![enter image description here](http://i.stack.imgur.com/IxwEm.png) Now, I cannot see network admin link for any blogs ![enter image description here](http://i.stack.imgur.com/bUGVZ.png)


title: Where to place landing pages or files inside wordpress?

text: We have some content that it's outside the wordpress instalation like landing pages, or forms which sometimes must be embedded. I'm wondering where to place them so I don't loose it if I update the wordpress installation or change the theme. I thought about placing it on the wp-content folder, is it a good idea? If not where should I place them?


title: enqueue and localize script in footer

text: I have a script which must run in my footer, after some variables are declared. It works if I just put the code directly in my footer file, but I think best practices dictate I should do this via functions.php and wp_localize_script. Unfortunately that doesn't work; the script is always output in the header. Any ideas on where I'm going wrong? Thanks in advance for your help!               add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_front_page_scripts' );          function mytheme_enqueue_front_page_scripts() {          wp_register_script('flowplayer_object',                                 get_bloginfo('stylesheet_directory') . '/_/js/flowplayer/flowplayer-object-creator.js' );               // last 'true' in wp_enqueue_script should force this into footer, right?          wp_enqueue_script( 'flowplayer_object','','',true, true );               $data = array( 'my_stylesheet_path' => __( get_bloginfo('stylesheet_directory') ) );          wp_localize_script( 'flowplayer_object', 'my_data', $data );     }


title: Show different category galleries without page refresh using Galleriffic and Wordpress

text: I'm using Galleriffic in a WordPress site to display a gallery of images. The images belong in several different categories, and I want users to be able to filter by category via a submenu without the page refreshing. My basic idea is to use a conditional statement within the wp_query call for each category and link each condition to a different button/link in the category menu. It would default to showing all of the images, but if one of the category buttons was selected, only images of that category would show in the gallery. My Javascript/JQuery/Ajax skills are a bit sub-par, however, and I haven't been able to figure out a good way to implement the menu. I imagine this technique has been used for things other than galleries. Has anyone done something similar?


title: Is the new WordPress 3.1 admin bar pluggable and how can I extend it?

text: ## How can I extend the functions of the WordPress 3.1 admin bar in my plugins? I am looking for specific hooks and filters to use in adding links or other features to the admin bar. A good example of what has already been done is the Yoast WordPress SEO (Wordpress Plugin). ![alt text](http://i.stack.imgur.com/ZapRm.png) Currently there is no documentation available on extending the admin bar. According to The Codex there are two filters to turn it off or not show it: `no_admin_bar()` & `show_admin_bar()`


title: Get page link from slug?

text: Is is possible to get a page's permalink from the slug alone? I'm aware that you can get the page's permalink from the ID using `get_page_link()`:               <a href="<?php echo get_page_link(40); ?>">Map      I'm curious if there is any way to do the same with the slug of a page:               <a href="<?php echo get_page_link('map'); ?>">Map


title: What is the use case for the "Class" parameter in register_sidebar?

text:
I registered a new sidebar and filled in the `class` parameter (see code), I then dropped in an Archive widget and went hunting for my "testing" class. **Not there**. So what is the class parameter used for. Can I see an example?               register_sidebar(         array(             'name'  => __('Footer Widget One', 'wpbs-framework'),             'id'    => 'footer-01',             'class' => 'testing',             'description'   => __('The first footer area', 'wpbs-framework'),             'before_widget' => '
',             'after_widget'  => '
 ',             'before_title'  => '
',             'after_title'  => '
'         )     );


title: Making extra parameters optional

text: I've setup a very specific function and it works well but I'd like to make the parameters optional but I can't get a handle on the regex bit:               add_rewrite_rule('whats-on/([^/]+)/([^/]+)/([^/]+)/?$', 'index.php?page_id=71&event_year=$matches[1]&event_month=$matches[2]&event_day=$matches[3]','top');      `/whats-on/2012/01/25` I'll show all events on this date. `/whats-on/2012/01` goes to 404 but I'd like the parameter to be optional so I can show all January dates and the same for `/whats-on/2012` all dates in year 2012 Any help will gratefully received - thanks


title: running queries of multiple post types

text: I am trying to figure out the query I need to build for my project. I've got a little idea but i am getting confused by all the different query methods and I'm not sure which one to use. I have two post types that I need to pull meta data from. First post type is pods_product_grps (PG). This is the post type that will display information for both this post type and the second post type which is product_variants I need to create a sub loop that pulls all the meta data from the product_variants (PV) based on its relationship to the PG. The way the two connect is through a common variable PG:group_id => PV:grp_id So at first I was going to get the current group_id with:               $group_id= get_post_meta(get_the_ID(),'group_id','single');      If the data was in its own table I would run a select * from Pv where grp_id = $group_id but its not. The data is in the meta table with different meta values on each line. So, I am guessing I need to first figure out the post_id associated with the result, then use that in the get_post_meta functions? I'm thinking there is a more direct method of doing this, but I'm not sure what it is. I will need to pull data from 4 meta fields in the PG and 5 from the PV. Each product group has multiple variations, so a Foreach loop will be established, so I need to set this up to make as few database request as possible. If anyone can assist me, I would appreciate it. Thanks I also found this code that I thought could be useful, but I'm not sure what to do with it. I can use this to get the post_id or other data for the subsequent queries maybe?               $meta_query_args = array('key' => 'grp_id',     'value' =>$group_id,     'compate' => 'LIKE')


title: Ascending order of yearly archives

text:
### Hey there, I stumbled upon this question but I can't seem to contact the author, because I'm still too new here. I'm using this snippet on my `archives.php` page to display my posts sorted by years. It works great, now I want to know how to sort the posts in **descending** order, so that the newest posts are displayed on top.               // get years that have posts     $years = $wpdb->get_results( "SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year DESC" );          foreach ( $years as $year ) {     // get posts for each year         $posts_this_year = $wpdb->get_results( "SELECT post_title FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' AND YEAR(post_date) = '" . $year->year . "'" );              echo '
' . $year->year . '

';         foreach ( $posts_this_year as $post ) {             echo '
' . $post->post_title . '
';         }         echo '
';     }      This is what it looks like at the moment: ![image](http://abload.de/img/bildschirmfoto2014-096aoop.png) Every help is very much appreciated. Thank you from Berlin.


title: Filter Posts By Tag

text: I'm trying to filter my posts by category, then further by city. The only way I can think of filter by city is if the admin adds the city to the listed tags and then filtering from there via switch statement. How can I filter posts by a certain tag? Is there a better way to do what I'm doing? My PHP knowledge is intermediate and my Wordpress knowledge is pretty basic. Thanks in advance!


title: using $wpdb to insert a form into a post

text:
I am wanting to take the following form, and use $wpdb to insert it into a post. I have tried reading the class reference page INSERT rows, but I don't really know what should be referenced. I am not sure how to tell the form to insert the data into a post using $wpdb?               <?php     if (isset($_POST['pickup-form']))     {         // Clean POST data         $demo_input = (isset($_POST['demo-input'])) ? trim((string) $_POST['demo-input']) : '';              // Validate POST data         if ('' === $demo_input)         {             $errors['demo_input'] = __('Demo field is required');         }              // No errors         if (empty($errors))         {             // Save POST data to database, send some e-mails, etc.             $success = TRUE;         }     }     ?>          <?php if ( ! empty($success)) { ?>
Thank you!
          <?php } else { ?>              <?php if ( ! empty($errors)) { ?>             <?php print_r($errors) ?>         <?php } ?>              <form method="post" action="">             <input type="hidden" name="pickup-form">             <input type="text" name="demo-input" value="<?php if (isset($demo_input)) { echo esc_attr($demo_input); } ?>">             <input type="submit">         </form>          <?php } ?>


title: Load more button

text:
I am trying to make a button that loads more posts with AJAX each time you click it. When I click the button the first time, it'll load 3 new posts, but if I click on it a 2nd or 3rd time it will show the same 3 posts. What am I doing wrong?               //js file          $(document).ready(function() {     $('#load-more').on('click', function() {         var $this = $(this);              $.ajax({             url: '?page_id=90',             type: 'POST',             data: {                 posts_per_page: 3             },             beforeSend: function() {                 $this.text('Loading...');             },             success: function(data) {                 if (data) {                     $('#post-container').append(data);                     $this.text('Load more');                 } else {                     $this.text('No more');                 }             },             fail: function() {                 console.log('error');             }         })       });     });          //php file     <?php     /*     Template Name: AJAX     */     ?>          <?php     $not_in = array();          $pages = get_posts(array(         'post_status' => 'publish'     ));          foreach($pages as $p){         array_push($not_in, $p->ID);         //echo $p->ID.' ';     }          query_posts(array(         'post_type' => 'post',         'posts_per_page' => $_POST['posts_per_page'],         'post__not_in' =>  $not_in     ));          if (have_posts()) {       while (have_posts()) {         the_post();     ?>

             <?=the_post_thumbnail()?>

 <?=the_title()?>

                     <?=the_content()?>

     <?php         }     }      wp_reset_query();     ?>


title: display menu with out list tags

text: Is there a way I can display a menu in my theme that isn't formatted in a list? i just want to display the `<a>` tags without the `<li>` tags. is this possible? theme file:               <?php wp_nav_menu( array( 'theme_location' => 'navigation' ) ); ?>      functions.php:               function register_my_menus() {         register_nav_menus(array('navigation' => __( 'Main Nav' )));     }          add_action( 'init', 'register_my_menus' );      **Edit:** see my answer below, found on Stack Overflow


title: Inserting data into MagicFields using mysql queries

text: PART 01: INTRO Hey Stackexchange Greetings from the Snowy alps of Norway I have now tried for two full consecutive days to reverse engineer Magic Fields. Why? Because I am a simple man, and want to import data to my wordpress from an exotic database using CSV (and not programming a php routine, which I don't know nor understand). This has worked for all vanilla Wordpress fields, i.e. post-data, categories and so on. (I used LibreOffice Calc to fine-tune the CSV data, Quest Toad for MySQL import and to create MySQL queries). My designer has designed this entire thing extensively using the Magic Fields plugin. Therefore I have to deal with Magic Fields for the rest of the data that I need to have imported. It's a movie database, so it's the typical meta- data for movies like "productionyear" "producer" "imdblink" "youtubetrailerlink" and so on. My question is that I am hoping to get some insights/ideas/support on how to import these data into the magic fields. I have tried and given up the "magic fields importer", it is not documented and does not give any error messages when I try to import various csv formats. PART 02: Understanding Magic Fields My question is how can I populate(insert) a magic field with data using a mysql query? I have tried to understand what it is Magic Fields is doing when I put some data into a magic field and press save, in the admin-edit-post- frontend. It does a lot of things that I can't seem to re-create. For one it is not enough to insert data into the two places where the data is referenced. wp_postmeta and wp_mf_post_meta. This example post is not sufficient to get the data to "work" i.e. display themselves in wordpress neither in the admin-post-editor nor the front-end for the user:               INSERT INTO `wp_postmeta` (`post_id`,`meta_key`,`meta_value`) VALUES ('474','originaltitle','Die Hard 3');          INSERT INTO wp_mf_post_meta ( meta_id, field_name, field_count, group_count, post_id )  VALUES ( 1100083, 'originaltitle' , 1,1 ,474 );      Also with that meta_id number, Magic Fields creates a number series of 10 for each post, like 7000-7010 and then 8000-8010. I don't understand where it takes those numbers from, and whether they have to be sequential/consecutive. I have found that once entered by the admin-post-editor frontend, I can change the meta-id's in wp_postmeta and wp_mf_post_meta and it still works. But again when I try to create them myself with a SQL query, "it just doesn't work (TM)". After enabling MySQL querylogging and examining the logfile from the MySQL db engine gives and then trying to insert the queries manually (that I can make out from the logs), I still can't make Wordpress "find" the data and display them properly on the page. I can modify the data with mysql queries after I have populated them using the frontend with no problems. Also using the query logs, I found that after I push "SAVE" in the Wordpress frontend-post-editor it does no less than ~780 mysql query lines (regardless if I populate 1 or 10 of my magic fields)! The other thing I have tried is to take a snapshot of the database before and after I have done the post of the magic fields, and then used a diff-tool (various, WinMerge and Notepad++ mainly). I can't understand what it's doing but I THINK it is doing some hidden trickery in wp_term_taxonomy. This is just speculation. Part 03: Conclusion I don't know programming so any practical solution, would be deeply apprechiated. the full query I want to do per post (I have about 800 of these) is here: http://pastebin.com/5cZT3AjA The FULL list of queries that Magic Fields is doing after I push save in the admin-front-end is listed here (which I call the 'robot-at-work'). http://pastebin.com/c2c6qUQt To be sure I have checked three times that it wasn't something extraordinary that it is doing ~780 lines after I push save. I guess if I could find a way to bulk-edit all of my posts, and then have the "robot" i.e. admin-post-edit frontend do the work to create all these lines in the database. I could then change the fields afterwards... But the bulk-editor doesn't show the magic-field editor either. I have twisted my head around this problem 10 times now, and can't twist anymore!


title: Custom taxonomy permalinks and custom post types

text: I have set up a custom post type called "Portfolio". I have asigned this custom post type 2 taxonomies, "Clients" & "Service". The portfolio homepage URL is as follows: **www.domain.co.uk/portfolio/** The portfolio single page is as follows: **www.domain.co.uk/portfolio/project-name/** The clients and services though are as follows (client eg): **www.domain.co.uk/client/client-name/** I would like this URL to be as this if possible: **www.domain.co.uk/portfolio/client-name/** When I change the slug for this it completely ruins all my other links. Has anyone any ideas on how to make my custom taxonomy permalinks look like this?


title: more than one upload directory?

text: Is it possible to have 2 separate upload directories? One in which the resized images are created/stored and another to where full size original images are uploaded. This would let you use the path to the resized images in your templates thus keeping the path to original full size images hidden from public view (but in a location such that they could still be used to regenerate thumbnails/new image sizes etc).


title: Redirect non-members to about/intro page

text: I´m making a small wordpress/buddypress community site where I want all content except an about page to be for members only. I need to do a redirect to the about-page for all non-logged in users. When users log in (from the sidebar) they should end up on the blog/frontpage. How can I achive this? I tried some different members-plugins for buddypress and wordpress but none of them did exactly what I wanted, or didn´t work with other important plugins (like WP-FB-autoconnect). I´m guessing this is pretty easy to do with custom code in the header or functions file. But I´m not really a coder so I would like som help!


title: Archive Widget - Show selected Category Post title. Sorted by Year

text: I need to add a widget to the sidebar that shows post titles sorted by year ie: 2011 POST TITLE 1 POST TITLE 2 POST TITLE 3 2010 POST TITLE 1 POST TITLE 2 POST TITLE 3 I was thinking of using the Archive widget to do this, but I dont know how to add the display post title bit and then have the YEAR display as a type of heading for all the posts under that year. This might not be the best way to go... Any thoughts or feedback would be greatly appreciated


title: Custom role conflict with NextGen-Gallery

text: * * * EDIT: I've discovered that on a clean install of Wordpress and a reset database, the NextGen plugin appears to return this error with any standard Wordpress role except Administrator. Perhaps I shouldn't have assumed that their code was less likely to have errors than mine. Have contacted their customer support to notify them. If it is confirmed that the error is on their part, I will close/remove this question. * * * I am adding a custom post type to an existing theme where certain users will be able to log in and draft (but not publish) posts to only the custom post type and not interact with anything else on the admin side of the site. I created a custom post type and custom role to go with it. Tested it with both admin and custom role users - so far so good. However, I am having a consistent problem with logging in to the custom role user if NextGen-Gallery is activated.               PHP Notice: Undefined index: nextgen-gallery in [directory_path]\wp-content\plugins\nextgen-gallery\products\photocrati_nextgen\modules\nextgen_admin\class.page_manager.php on line 110      I did the custom role in functions.php like so:               add_role( 'guest_author', 'Guest Author', array( 'post_blog' ) );     function add_theme_caps() {         $role = get_role( 'guest_author');         $role->add_cap('delete_blogs');         $role->add_cap('edit_blogs');         $role->add_cap('delete_blog');         $role->add_cap('edit_blog');         $role->add_cap('upload_files');         $role->remove_cap('publish_blogs');         $role->add_cap('read');         $role->add_cap( 'read_blog' );           }     add_action( 'admin_init', 'add_theme_caps');               /*access for administrator*/          function add_caps_to_roles() {         $role = get_role('administrator');         $role->add_cap('publish_blogs');         $role->add_cap('manage_blogs');          $role->add_cap('publish_private_blogs');         $role->add_cap('publish_blog');         $role->add_cap('upload_files');         $role->add_cap('delete_blogs');         $role->add_cap('delete_published_blogs');         $role->add_cap('delete_blog');         $role->add_cap('delete_published_blog');         $role->add_cap('delete_others_blogs');         $role->add_cap( 'edit_blog' );         $role->add_cap('edit_blogs');         $role->add_cap('edit_private_blogs');         $role->add_cap('edit_published_blogs');         $role->add_cap('edit_others_blogs');         $role->add_cap('read');         $role->add_cap( 'read_blog' );          $role->add_cap( 'read_private_blogs' );          }         add_action( 'admin_init', 'add_caps_to_roles');      The code referred to in the php error (and surrounding lines) are:               107  if ($properties['before']) {     108 global $submenu;     109                      110 $parent = $submenu[$properties['parent']];     111 $item_index = -1;     112 $before_index = -1;      It seems unlikely that such a popular plugin can't work with custom roles, so I assume I am doing something incorrectly. I would be deeply grateful to anyone who can shed light in this issue or maybe point me in a helpful direction. I've driven myself to distraction with it.


title: Custom Database Table and foreach

text: I have just created a custom database table and would now like to output every inserted row from it into a predefined format using a foreach statement. Some guidance in this matter would be great. Thanks, Ashley


title: Checking if a Page has an Associated Term?

text: I am looking for a way to do some conditional logic on terms associated with a post. Essentially I created my own custom taxonomy for "age groups" and have created three terms for them. Kids, Teens, Adults... In the admin area I want to check the terms which apply to a specific post and on the frontend of the site within my page template I want to show a specific image if the term was associated with the post or a different one if the term was not associated. Does anyone have a solution for this... I thought the following code example would work but it does not. (BTW - what I am doing here is changing the image based off css).               <li id="kids-<?php if ( is_term( 'Kids' , 'age_groups' ) ) {        echo 'on';     } else {echo 'off';} ?>">Kids Programs


title: What is the http://go2.wordpress.com/ redirect?

text: Hi I see a wordpress.com blog and on the latest post there is a redirect for the external links via "http://go2.wordpress.com/" redirect. This redirect is obfuscated - on hovering the link it displays a "http://google.com/url?..." redirect instead. What is this and why is it suddenly on this post and not others? Also, I see the redirect type is a 302 - surely this is harmful in terms of SEO for the destination links?


title: Coding Challenge - JavaScript Easter Egg

text: As some of you know, there's an Easter Egg hidden in the WordPress post revision system that will display a message from the movie _The Matrix_ if you perform a specific action (if you don't know, I won't spoil the surprise ... poke around with post revisions and see if you can find it). I love Easter Eggs, and this one was a thrilling find when I stumbled upon it. Some people, it seems, aren't really fans, though. I had a client recently discover this Easter Egg go into a panic attack because they thought someone had hacked their blog. They freaked out, flooded my inbox with panicked messages, and maxed out my voice mail quota with "please help!" messages. This leads me to believe that some Easter Eggs should be turned off when WordPress is deployed in certain situations - i.e. for high-maintenance clients. Enter my idea for the first ever WordPress Answers code challenge. ### The winner of this challenge will be awarded an extra 150 reputation points!!! Let's see how skilled you all are at coding ... what would you recommend as the simplest way to remove this Easter Egg from WordPress without hacking core? In other words, using only action hooks, filters, and custom enqueued JavaScript, how would _you_ remove the Matrix Easter Egg? I'll select the "best" answer on October 31st based on:   * The completeness of the answer (a description of the code + example code + screenshots if applicable)   * The simplicity of the code (but remember, shorter isn't always better)   * Full descriptions of how you would install the code on a client site BTW, anyone who merely copy-pastes the solution I already posted on the WP- Hackers mailing list will be automatically disqualified. Let the games begin!


title: Adding Properties to User Profile and Displaying in List

text: I have a site that I am migrating to WordPress, and I have a need to add properties that each of the users can edit (e.g., Address, City, State, Business Name, etc), along with some properties that Administrators can edit (IsActive, CanEmail) that wouldn't be displayed to the user. In addition, I need to be able to display the properties in a table (similar to how the plugin, "Members List", displays, but with the custom fields displaying as well. Given these requirements, I had attempted to use a combination of "Cimy User Extra Fields" and "Members List", but the members list grid did not have an option to display the extra fields created by the other plugin. How would you recommend I approach this? EDIT: So I guess the crux of my question is, what is the preferred method to add properties to the User?


title: Serialize data for wp options

text: I am creating my first ever plugin, its purpose is to show a notice when some conditions are met, I created the function in jQuery and initially I had to manually edit the file everytime I wanted to change the notice message, so I decided to create a settings page so that the user could edit the message from the front end. Thanks to another member on stackxchange I was able to use wp localize to show the custom message saved in the wp options instead. however, I now find my self having to structure the message being shown such as;               Title          Message          Image      I don't want to create many options so I thought I could try and serialize the data but I dont know how to. In the settings page I have a single textbox for the user to enter the message.               <textarea name="msg_data" id="msg_data" cols="40" rows="10" />     <?php echo get_option('notice_data'); ?>     </textarea>      Here is the localize               $custom_notice = get_option('notice_data', 'default_value');       wp_localize_script( 'lu_ban', 'custom_notice', $custom_notice);      My goal is to create three different inputs, one for title, one for body message and one for image path, can anyone help me out please. THanks


title: Rename upload images during upload

text: I want to insert newpost on Front-end of wordpress.   And i want to rename images name during upload **for my code below**   Result like: "MemberUpload_ _dd/mm/yy_ _random_number_[width]x[height].jpg"   (For all size: thumbnail, medium, large, full and custom size) My code upload i'm using for my theme..   Thanks friends verymuch! ;)               // Upload      if (!function_exists('wp_generate_attachment_metadata')){                         require_once(ABSPATH . "wp-admin" . '/includes/image.php');                         require_once(ABSPATH . "wp-admin" . '/includes/file.php');                         require_once(ABSPATH . "wp-admin" . '/includes/media.php');                     }                      if ($_FILES) {                         foreach ($_FILES as $file => $array) {                             if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {                                 return "Upload Err: " . $_FILES[$file]['error'];                             }                             $attach_id = media_handle_upload( $file, $newPost );                         }                        }                     if ($attach_id > 0){                         //and if you want to set that image as Post  then use:                         update_post_meta($newPost,'Uploaded_img_id',$attach_id);                     }     // END upload


title: Search url wp-rewrite after redirect?

text: I started using this functions for my "search results"-page.               #SearchRewrite     add_action('generate_rewrite_rules', 'my_rewrite_rules');     function my_rewrite_rules( $wp_rewrite )     {         //RewriteRule ^icerik/(.+)?$ /index.php?s=$1 [QSA,L]         $new_rules = array(         'icerik/(.+).html' => 'index.php?s=' .         $wp_rewrite->preg_index(1) );         $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;     }      Also I added this line to my `.htaccess`-file               RewriteRule ^icerik/(.+)?$ /index.php?s=$1 [QSA,L]      But, whenever I search for something in my search-field the URL doesnt redirect to new URL—even though the new links actually works, I now have two links. Example: This is the rewritten URL: http://www.fatihtoprak.com/icerik/linux.html This is the regular URL: http://www.fatihtoprak.com/?s=linux My question is then: how do I make the rewritten URL display, when a user uses the search-field on my website? **\---UPDATED---** It solved with this Plugin & Class here.. Also i have another question about this. Its like ; when i type a word with Turkish character (İ,Ü,ü,Ö,ö,ğ,Ğ,ş,Ş) it gost 404 Error page :( Do you _have any idea for this ?_ Please type and search **Atatürk ve Cumhuriyet**. Also the query results hook doesn't care with spaces too (:


title: Wordpress show posts from children terms of a taxonomy term

text: I was a little hard for me to explain what I'm trying to achieve in the title so I will explain my setup much more detailed here. I tried to find an answer searching here and other sites but couldn't find anything that fits what I'm trying to do. I have a a custom taxonomy called "products_cat" this custom taxonomy has different terms as parent categories: "Electronics", "Computer", "Home Appliances", etc. And then under each of those terms I have more subcategories like under Electronics for example I have "TV", "Audio", "Home Theaters", "MP3",etc. So the thing I'm trying to do is to have within the taxonomy-product_cat.php a code that display the current chosen Taxonomy (suppose Electronics) and then have the titles of all children and the products under each one of those. Thanks.


title: Declaring an instance of class included in parent theme from child theme functions.php

text: **Please note this is all "working" - the question is about the best practice and to try and work out why I need to include the PHP file which contains the class in two places for it to work correctly.** I'm working on a simple parent theme to speed up my own development cycle - and have got to the point of testing a simple child theme. I understand that the `functions.php` file for the child is called up before the parent `functions.php` \- which includes all the PHP functions and a class for adding CPT's. I would like to build the CPT from the child theme - I want the parent to contain all the reusable and update-able functionality - but not to pre-build added features into each WP install it's used on. To the code question: I tried to include the class (which is in a separate PHP file) in the child `functions.php` and then instantiate an instance - for example:               require_once TEMPLATEPATH."/library/cpt/cpt.php"; // CPT class ##     $cpt_tree = new Custom_Post_Type( "tree" ); // New CPT - "tree" ##      Reloading the page gives an error:               Fatal error: Class 'Custom_Post_Type' not found in C:\xampp\htdocs\site\wordpress\wp-content\themes\child\functions.php on line 14      So, then I included the same PHP file in the parent `functions.php` file - and it all works - as an experiment I removed the class from the child theme - and it gives the same error. I know this question is lacking lots of code examples - I'm hoping it will ring a bell with someone - or someone who understands more about using Classes will be able to give me some pointers - seems silly to require this file in two places and I'll like to keep the `functions.php` file as clean as possible.


title: Set up dataTables row delete rather than php and page refresh

text:
I am using the dataTables jQuery plugin to display a table in a wordpress site with data from a custom table and it works well. I have added select check boxes and once a row or rows have been selected and the Delete button is clicked the form calls an external non-wordpress file to delete the rows corresponding to the IDs in the GET (for me to see the data being passed). I know dataTables can do this for me instead but I am not good enough at JS to implement it can anyone help? Also I know I should be using the correct Wordpress $wpdb delete but just found this easier as I am used to doing things outside of wordpress. Here are the pertinent parts of the files I am using.               <form action="<?php echo plugins_url('process/process-form-delete.php',__FILE__) ; ?>" method="get">

                         Select	                         Part Image	                         Part Name	                         Vehicle	                         Seller Type	                         Location	                         Price	                         Date	                         View

                    <?php                         foreach ($rows as $row) {                                 $part_details = pl_get_part_details($row->pl_part_ID);                             ?>                             <tr id="<?php echo $row->my_part_ID; ?>">                             <input name="selector[]" type="checkbox"  value="<?php echo $row->my_part_ID; ?>"  />	                              Stuff Here 	                              Stuff Here 	                              Stuff Here 	                              Stuff Here 	                              Stuff Here 	                              Stuff Here 	                              Stuff Here 	                              Stuff Here
                               <?php                         } ?>

                       <button class="btn btn-primary"  name="submit_mult" type="submit">Delete</button>                       </form>      Process-form-delete.php               <?php     require_once ('../config/dbwpconfig.php');     $number = $_GET['my-parts_length'];     $i=0;     while ($i < $number) {      $data = $_GET['selector'];     if (isset($data[$i])) {         $sql = "DELETE FROM wp_pl_my_parts WHERE my_part_ID =  :partID";         $stmt = $dbh->prepare($sql);         $stmt->bindParam(':partID', $data[$i], PDO::PARAM_INT);           $stmt->execute();               }     $i++;     }     header('Location: ' . $_SERVER['HTTP_REFERER']);     ?>      jQuery to get table to become a datatables table               jQuery(document).ready( function() {       jQuery('#my-parts').dataTable( {         "aaSorting": [[2,'asc']],         "aoColumnDefs": [           { "bSortable": false, "aTargets": [ 0,8 ] }         ]              } );          } );


title: Remove 'More..' link from RSS feed

text: I believe this can probably be done with a filter, but haven't been able to find any info so far about it. We are pulling the description node from our RSS feed into some external properties. The problem is that wordpress is adding a Read More link to the feed. We need it to disappear. Here is what a description node currently looks like:               <description>     <![CDATA[     This is the article text......[.....]           Read More …     ]]>     </description>      And what we want it to look like               <description>     <![CDATA[     This is the article text............]     ]]>     </description>      Is this possible to achieve?


title: How to exclude specific category from the get_the_category(); array

text: In my loop I've added:               <?php     $categories = get_the_category();     $separator = ' ';     $output = '';     if($categories){         foreach($categories as $category) {             $output .= 'term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.''.$separator;         }     echo trim($output, $separator);     }     ?>      to display all the categories attached to the post here. There is a specific category "Featured" that I want to prevent from displaying. I've tried :               <?php     $categories = get_the_category();     $separator = ' ';     $output = '';     if($categories){         foreach($categories as $category) {     if($category !== 'Featured'){             $output .= 'term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.''.$separator;}         }     echo trim($output, $separator);     }     ?>      But I guess it's a wrong approach since it's not working :) Can anyone please help to achieve my task or at least point me in the right direction? :)


title: Exporting Custom Taxonomy in plugin

text: I am writing a plugin which requires exporting custom taxonomies in csv on submit button click. I am using get_terms() to export taxonomies terms. I have written a class file which handle this operation and this file is included on the top of plugin main file. I have searched about it and found out that get_terms() doesn't work until theme function.php is not loaded. So I want to know where should I include the class file. I have checked various hooks also but problem is that if I include it on admin_menu or admin_init hooks then it also outputs some other text of wordpress in exported csv file. So please let me know how should I include the class file.


title: How do add_action and WP_Query

text: I am new to WP, semi-new to PHP and new to OOP. 1) How can the WP function `add_action` receive another function as its argument? I know this by itself is not possible. I deliberately broke some code and found that there is actually a native php function `call_user_fun_array`, but how did they make it so that their own function can have a function as its argument? 2) I am doing some plugin tutorial and working with WP_Query, and I just passed an argument directly to WP_Query, as if it was a method and not a class.               I did the following:           $loop = new WP_Query(             array(                 'posts_per_page' => 3             )     );      I would understand if I first instantiated the class and THEN used its method, something like:               $loop = new WP_Query();         $loop->someMethod(                 array(                 'posts_per_page' => 3,                 'category__in' => $cats,                 'orderby' => 'rand',                 'post__not_in' => array($id)             )     );      but how is this possible, that instantiating a class can act as a method as well? (this is more of a general OOP question I guess).


title: is_singular just won't work

text: I'm working with wp 3.9.1 and plugin Custom Content Type Manager. I'm creating my own theme. I created a custom type called "aggregato". I also use custom taxonomies. I then created a WP_query for my front-page:               $query = new WP_Query( array(        'post_type' => array ('post', 'aggregato'),        'cat' => '-1',        'posts_per_page' => 12,     ));      The query works, it returns 12 items of both the "post" and "aggregato" post types. Problem is that I want to format them differently. So when I use:               if ( is_singular('aggregato') ) {         //my code     }      Nothing happens. It never enters, that condition is never return true. I don't know what to do anymore. I used `is_singular()`, `is_single()`, `$query->post- type`, `$post->post-type`. Nothing. It just does not work. Anybody has any idea? Any pointers? Please, help! EDIT: the point is that using the codex and looking for answetrs on the web I was always sent to that particular function. It got some time to understand that it was not my case. I think that the question I posted was very clear. I was just, very simply, wrong.


title: How to get alphabetic listing x other posts, based on first letter post?

text: Let's say I have a `post` called "Hello World" and I am on that page... Let's say I have different posts like "Haaaa" and "Hoooo".... What I want to do is showing Haaa and Hooo in a different place (let us say the `sidebar`) if this "Hello World" post is being watched... So in the sidebar we get this:               Heeee     Haaaaa     <div class="highlighted active"> Hello World </div>     Hoooooo     Hxxxxx     Hzzzzzz      Where do I start? I guess `<?php wp_get_archives('type=alpha'); ?>`, but how do I get what I want?


title: How to Create a Directory in a Plugin Folder?

text: I am creating a plugin in WordPress Version 3.4.2. When the administrator submits a form, a new folder is created inside my plugin directory and a file saved in this new folder. But it gives me the following error:               error : The file has not been created           $dir = plugins_url()."/folder-name/;       The above code returns the following path:               http://localhost/website/wp-content/plugins/abc/folder-name          mkdir($dir, 0777, true);


title: Possible to add a language file to a plugin without adding .po/.mo files to plugin directory?

text: I need to add a language file to an existing plugin. Not for translation reasons, but because I'd like to change all occurrences of a certain word to something else. While I could just drop another .po/.mo file set into the plugin's languages directory, I don't want to lose the language file when the plugin is updated. It appears if the plugin used `load_textdomain` to pull files from the `WP_LANG_DIR` in addition to `load_plugin_textdomain` then I could just drop in some .po files into `/wp-content/languages/` and it would work. BuddyPress does it this way, and has instructions for doing the exact sort of thing I'm trying to do: http://codex.buddypress.org/getting- started/customizing/customizing-labels-messages-and-urls/. I've changed every reference to "Group" to "Community". All I have to do is drop the correctly-named files into the `/wp- content/languages/` directory and the files are loaded. The plugin I'm trying to modify is: BuddyPress Group Email Subscription. It loads the languages using this function:               function activitysub_textdomain() {         load_plugin_textdomain( 'bp-ass', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );     }     add_action( 'init', 'activitysub_textdomain' );


title: Change Twentyeleven Search Form Text

text: Anyone know how to change the text inside the Twentyeleven search field from "Search" to another choice?


title: How to determine if it is legal to remove credit link from theme?

text: I have downloaded a theme and modified few things and customised it according to my needs. Now I want to remove the credits i.e. the back link to the designers site. I want to know if its legal for me to remove that. What are the terms and conditions? Theme is http://diovo.com/links/voidy/ Credits is a backlink: Theme by Niyaz Diovo (with link)


title: Trailing slash results in an error:

text: On my website, any trailing slash is resulting in an error. How do I fix this? Example:   * http://example.com/content \- no error   * http://example.com/content/ \- error


title: Previous & Next on Index Page broken

text:
So the Next/Previuos on my index page is broken. It goes to page 2 but doesn't refresh the posts. It will work on my categories and it will work on my posts but it just won't work on the from page. Here's my code:               <?php get_header();?>     <?php include('from.php'); ?>

             <?php if ($posts) {                     if (get_settings('mistylook_asideid') != "")                         $AsideId = get_settings('mistylook_asideid');                     function ml_hack($str)                     {                         return preg_replace('|
\s*
|', '', $str);                     }                     ob_start('ml_hack');                     foreach($posts as $post)                     {                         the_post();                     ?>                     <?php if ( in_category($AsideId) && !is_single() ) : ?>
                             <li id="p<?php the_ID(); ?>">                                 <?php echo wptexturize($post->post_content); ?>

<?php comments_popup_link('(0)', '(1)','(%)')?>  | <a href="<?php the_permalink(); ?>" title="<?php _e('Permalink:','ml');?> <?php echo wptexturize(strip_tags(stripslashes($post->post_title), '')); ?>" rel="bookmark"># <?php edit_post_link(__('(edit)','ml')); ?>

                     <?php else: // If it's a regular post or a permalink page ?>                     <div id="post-<?php the_ID(); ?>" <?php if (function_exists('post_class')){ post_class(); } else { echo 'class="post"' ;} ?>>

<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e('Permanent Link to','ml');?> <?php the_title(); ?>"><?php the_title(); ?>

                             <?php the_time(__('M jS, Y','ml')) ?> <?php _e('by','ml');?> <?php the_author_posts_link() ?> <?php edit_post_link(__('Edit','ml'), '', ' | '); ?>

                         <?php the_content(__('Continue Reading »','ml')); ?>                         <?php wp_link_pages(); ?>
<?php if (function_exists('the_tags')) the_tags(__('Tags: ','ml'), ', ', '
'); ?>

<?php _e('Posted in','ml');?> <?php the_category(', ') ?> | <?php comments_popup_link(__('No Comments »','ml'), __('1 Comment »','ml'), __('% Comments »','ml'),'',__('Comments Off','ml')); ?>
                     <?php comments_template(); ?>
                 <?php endif; // end if in category ?>                 <?php                     }                      ob_end_flush();                 }                 else include_once(TEMPLATEPATH.'/notfound.php');             ?>
<?php posts_nav_link(' · ', 'previous page', 'next page'); ?>

     <?php get_sidebar();?>     <?php get_footer();?>      I'm using a random theme called MistyLook. I've tried working with it but if I have to go to the core files then im stumped... Any suggestions?


title: Taxonomy or Custom Field

text: I'm creating a network that has profile pages for authors (custom post type) on the main site, where I've created a few non-hierarchical taxonomies to help users sort through the authors. These taxonomies are: title, genre, publisher and date published. I understand the first three. What I don't understand is how to appropriately keep track of date published. Should I use a taxonomy? But that presents certain problems (I think) when it comes to searching a range of dates, lets say between 1900-1917. Or if I wanted to create a tag cloud. I've always felt that taxonomies were to establish relationships between terms. Does a range qualify as a relationship, and more practically can it work? If I created a custom field for date, how would I have users search through results? Hope that makes sense. Just looking for some opinions, from more experienced people, on how that would be best represented.


title: Help With MySQL to WPDB Query Conversion

text: I have a problem. I've got a PHP script that tracks individual file downloads, and I'm looking for a way to display that number in individual posts. I've got a half-baked solution- a plain ol' MySQL manual connection script, but I'm trying to convert it to use as a Wordpress plugin (I want it to use WPDB). **I've tried to convert it, but I don't know what the Wordpress alternative to 'mysql_fetch_array.'** Anyways, I've included the original script below, as well as my progress on a Wordpress-friendly version. Plain Version:               function mb_download_count() {         global $post;         if (get_post_meta($post->ID, 'zipname', TRUE)) {             $namemeta = get_post_meta($post->ID, 'zipname', TRUE);                  require $_SERVER['DOCUMENT_ROOT'].'/downloader-connect.php';             $result = mysql_query("SELECT * FROM mb_download_manager                                         WHERE filename='".$namemeta.".zip'");                        // get the first (and hopefully only) entry from the result             $row = mysql_fetch_array( $result );                 // Print out the contents of each row into a table              if ($row['downloads'] == '') { echo ('0'); } else {             echo $row['downloads']; }             } else { }     }      Wordpress-friendly Version so far:               function mb_download_count() {         global $wpdb;         global $post;         if (get_post_meta($post->ID, 'zipname', TRUE)) {             $namemeta = get_post_meta($post->ID, 'zipname', TRUE);                  $result = $wpdb->query("SELECT * FROM mb_download_manager                                         WHERE filename='".$namemeta.".zip'");                    $row = mysql_fetch_array( $result );             if ($row['downloads'] == '') { echo ('0'); } else {             echo $row['downloads']; }             } else { }     }


title: Show different number of posts per page in tag archives

text: I am using the following code out of loop to show one post per page in tag archive.               <?php query_posts($query_string."&showposts=1") ?>      However, I want to show recent posts as 10 posts per page and older posts than a date (say 1 August) as 1 post per page. Is there any way I can do that.   Thanks.


title: Adding a new user from the front end

text: I have a front end form that creates a new post from users that are not required to login. However, I need to create a new user based on the information passed in the form. As it is right now I can successfully create a new user, but in the user admin in the backend there are no posts associated with this new user (thought the posts are successful themselves). Side note, if I delete the user and click to delete all associated posts, it will delete the post they created. I just can't figure out why it won't show their posts in the user admin... Code as follows in my custom template file:               $new_post = array(     'post_title'    =>   $title,     'post_content'  =>   $description,     'post_category' =>   array($_POST['cat']),  // Usable for custom taxonomies too     'tags_input'    =>   array($tags),     'post_author'    => $user_id,     'post_status'   =>   'publish',           // Choose: publish, preview, future, draft, etc.     'post_type' =>   'post'  //'post',page' or use a custom post type if you want to          );          // Insert a user          if ( ! is_user_logged_in() ) {             // create an account           $user_data = array(                 'ID' => '',                 'user_pass' => wp_generate_password(),                 'user_login' => $lastname,                 'display_name' => $lastname,                 'first_name' => $firstname,                 'last_name' => $lastname,                 'role' => get_option('default_role'), // Use default role or another role, e.g. 'editor'                 'user_email' => $email             );             $user_id = wp_insert_user( $user_data );         }     else {         $user_id = get_current_user_id();     }


title: One WordPress install serving multiple virtual hosts

text: I have a number of WordPress-enabled sites setup as virtual hosts under XAMPP on a Windows 7 development server.      An example virtual host is as follows:      <VirtualHost *:80>   ServerName siteA.localhost   DocumentRoot "C:/htdocs/siteA"   </VirtualHost> My goal is to have all the sites use the same WordPress install, which is located in it's own folder off the Document Root, ie: "C:/htdocs/wordpress".      The only WordPress files unique to each virtual host will then be the wp- config.php file and the /wp-content/ folder, which will be located off the root of each site.      Does anyone have any suggestions for how to achieve this? I've tried adding the WordPress folder as an Alias for each Virtual Host, and adding it as "php_value include_path" value for each Virtual Host as well, but neither of these have worked.      Ultimately I want to make it easy to upgrade all my WordPress-powered sites by having them share the same WordPress core.      Thanks.


title: How can I add in post's the text "No content"

text:
How can I add in a post the words "No content available" if nothing is ritten Example:   If there is no text added, i want to get "No content available" automated in my template. I want to get for a specific Post Type, `Seriale`. How can I make that? In the template i have this               <?php          if (is_search())              the_excerpt();          else              the_content(__('Read the rest of this entry »')); ?>     <?php          if (is_page() or is_single())              wp_link_pages(array(                 'before' => '
Pages: ',                  'after' => '
', 'next_or_number' => 'number'             ));      ?>


title: get_terms problem : related articles

text: I'm trying to use get_the_term_list to catch the name of the current taxonomy of the page, and then use it with get_terms and a foreach method, to show the result of all the "elements" from the same taxonomy, but i only got an empty result. (for example, this is to have the related articles of the page). Do you know why it doesn't work? The echo on get_the_term_list works ok, but then in the parameter of get_terms, the result of the "li"s is blank.               $my_tax = get_the_term_list( $post->ID, 'type');     //echo $my_tax;?> output works fine          $terms = get_terms($my_tax);     foreach ($terms as $term) {     echo "<li>".$term->name."</li>"; // empty     }      Could you help me?


title: Adding a user's ID behind the <a> tag ref link address

text:
Good day, everyone: I want to make wordpress to add the user's id number behind the ref's link string, so that, for example
      go this page
      above code will be turning in to a link if the user id is 113 who clicked it, the address will become:               go this page      Or, if you know an alternative to do so, please also let me know. Generally, the purpose will be that a user will be directed to a page that with unified address but there will be a number equal to his id attached behind. every time, someone click the same link, in same page, will have the same effect on each user. **When a user click it, will be the CURRENT USER, who is a registered user.** If anyone could tell me if I could create the page at the same time (if not exist), will be terrific! Thank You


title: Media Content disapeared after upgrade WP core to 3.5.1

text: my Media -->Library content disappeared from the dashboard, but I still can see it inside my actual site folder. Could anyone instruct me how to fix it? Thank You


title: Get multiple posts with some custom fields efficient

text: Is there an efficient way to get some posts with (some of) their custom fields in one go? I have a custom post with some custom fields and would like to create an overview page where I display all posts in their respective category. I need the custom fields because there is info about how to display the posts in this overview (icon location, alt text etc.) I don't want to just get a list of posts and then get the custom fields for every single one of them using a loop producing a ton of queries. I know I can cache the result until a post changes but it would be nice if it wasn't necessary at all. So is there a way to get posts with their custom fields or at least a way to get the custom fields of several posts at once or do I have to write my own query to achieve that?


title: Add 'last' class to second post in featured post loop

text:
Hi there I'm using the following query to pull in two featured posts onto the home page of a site I'm building. How do I add a last class to the second post it drops onto the page?
Case Studies
                 <?php $my_query = new WP_Query('post_type=casestudy&posts_per_page=2');                     while ($my_query->have_posts()) : $my_query->the_post();                     $do_not_duplicate = $post->ID; ?>
                         <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                         <?php the_excerpt(); ?>
                     <?php endwhile; ?>      Thanks John


title: Best Way to Grab Post ID from Plugin

text: I'm currently using loop_end to hook my plugin and get the post id from a page. This works great, except that it's also displaying my plugin in the recent posts widget which I don't want. Is there a better way to do this so that it ONLY displays on page content and not widgets?


title: Call do_action class's function

text: There is the following do_action               else     do_action( 'example', $this->nothing());      Where nothing() does exactly what it sounds like. This logic is in a public function testFunction in a class called Test. What I would like to do is hook into this function (I'm in a different plugin), and call a different function (looppages()) that is already in the same class as the above logic like this:               add_action( 'example', Test::looppages);      Can I do this?


title: How to check if commenter is the_author?

text: What's the best way of checking if my commenter is also the author of the post that he post comment on? I know there's a css way (`.byauthor`), but how about PHP? How to compare post author with comment author? I was trying with is_author(), the_author() and comment_author() but it just doesn't look right (what if somebody uses the same nickname as author?). Here's my code for now:               <?php if(get_the_author() == get_comment_author()) _e( 'Author', 'theme' ) ?>


title: How to execute WordPress as though it is in the root folder while it is installed in a subdirectory?

text: I have a folder and file structure already in place for a site to which I am inserting WordPress. My goal is to execute WP at the root level (/) when a visitor just visits the domain without a path, however I want WP to be installed within the `wordpress` subfolder folder. So far I've reviewed several hits on this, but every single one of them appear to have the negative side effect of pushing the user on over to http://mydomain.tld/wordpress rather than keeping the user on /. How can this be accomplished? I am guessing it is going to take some massaging of .htaccess in both the root folder and the other subfolders to which I want to grant access aside from WordPress, but I'd like to see this delineated properly. One thing I have tried is to follow the Codex suggestion "Pointing your home site's URL to a subdirectory". In this I have updated my `.htaccess` as per what is there, however the site is consistently redirected to `http://mydomain.tld/wordpress`. I obviously want it to just be `mydomain.tld` without the additional wordpress path. I have further attempted to do the following, with the `mydomain.tld` loading up the wordpress blog, but then seemingly when I go to any page, such as the default sample page that is installed with a fresh installation, it then adds the subfolder path again `mydomain.tld/wordpress/blah`: in `/index.php`:               <?php     /**      * Front to the WordPress application. This file doesn't do anything, but loads      * wp-blog-header.php which does and tells WordPress to load the theme.      *      * @package WordPress      */          /**      * Tells WordPress to load the WordPress theme and output it.      *      * @var bool      */     define('WP_USE_THEMES', true);          /** Loads the WordPress Environment and Template */     require('./wordpress/wp-blog-header.php');      and `/.htaccess`:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /wordpress     RewriteRule ^index\.php$ - [L]          # uploaded files     RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]     RewriteRule . index.php [L]          </IfModule>          # END WordPress      Also, the `wp_options` table siteurl has `http://mydomain.tld/wordpress` in it as well.


title: bbPress: How to set conditional for specific user -or- user role, to be displayed in user profile

text: I've been trying to set a conditional for specific users (e.g. http://www.mywebsite.org/forum/users/john/) to display a custom "Contributor" graphic within their user profiles. The graphic would be displayed directly underneath the specified profile pics using the template file (bbpress/templates/default/bbpress/user-details.php). I was also thinking that it might be easier to set the conditional based on their WordPress user role (e.g. Contributor), so that I wouldn't have to write each user in the condition manually. Here's what I've tried so far:               <?php if(current_user_can('contributor')) { ?>          <?php } ?>      I've also tried:               <?php if(bb_user_id('15')) { ?>          <?php } ?>      I'm very new to PHP, and I've been trying very hard to find the answer. If you can help me, I would appreciate it very much! Thanks.


title: Replacing link URL ending strings via MySQL

text: We are about to purchase a site that uses Amazon affiliate links. Naturally, they have their own affiliate ID, Amazon affiliate links look like this:               http://www.amazon.com/gp/product/productcode/?tag=affiliateID-20      What would be the best way to alter the ending string for these links' URL's in a Wordpress blog?


title: Display category description instead of "nothing found" page

text: I'm using Wordpress 3.8.1 with the theme twenty fourteen. Unfortunately , when you click on a category with no post assigned to it for now , it displays a _not found_ page. I've tried to create a plugins with a hook that replace that by a text (like the description of the category). If there are no posts is in the category, only the description is displayed, if the category have posts, description is displayed and posts founds after. For now I don't find any ways to affect the _nothing found_ page. Is it possible to do this without modifying the category.php file (with plugin by hooks) like this thread