title: Wordpress custom field being lost on wp_update_post, with a twist

text: I'm using wp_update_post to programmatically add a title and tags to posts from the front end. I'm running into a hair-tearing issue with custom fields in the process: one of the two custom fields that are created and populated when the post is initially created has its value deleted, while the other is perfectly fine. This is the part of the code I use to create the post in the first place:               // Set the post ID so that we know the post was created successfully     $post_id = wp_insert_post(         array(             'comment_status'=>  'closed',             'ping_status'   =>  'closed',             'post_author'   =>  $author_id,             'post_name'     =>  $slug,             'post_status'   =>  'publish',             'post_type'     =>  'custom'         )     );          // If the post was created properly     if($post_id) {              // Add meta/custom field data to post         add_post_meta($post_id, 'custom_random_id', $randomId);         add_post_meta($post_id, 'viewcount', '1');      Then, this is the code I use to update the title and tags:               // Continue if untampered     if($new_hashed_value == $_POST['hash']) {              $updatePost = array();         $updatePost['ID'] = $post_id;         $updatePost['post_title'] = $title;         $updatePost['tags_input'] = $tags;              if(wp_update_post($updatePost)) {                  totallyUnrelatedStuff();         }      I understand from other posts that wp_update_post may delete values - but in this case, the custom field ' **custom_random_id** ' is always intact, and ' **viewcount** ' always has its value deleted. I've tried altering it so that it goes:               if(wp_update_post($updatePost)) {                  update_post_meta($post_id, 'viewcount', '1');         }      or even:               if(wp_update_post($updatePost)) {             delete_post_meta($post_id, 'viewcount');                                                 add_post_meta($post_id, 'viewcount', '1');         }      But the **viewcount** field's value continues to be erased. Furthermore, just to throw another wrench at me,               if(wp_update_post($updatePost)) {             delete_post_meta($post_id, 'viewcount');                                                 add_post_meta($post_id, 'new_field', 'new_value');         }      works perfectly. Would anyone know what's going on? Thanks!


title: Override WordPress Widget CSS Classes?

text: I'm attempting to style lists in the sidebar (you know, `<ul><li>`) and I'm curious how to also make widgets adopt this class. Each widget seems to have its own class assigned to it by WordPress' defaults - is there a way to override this?


title: permalink structure for single-{post-type}.php in wordpress

text: I have tried many ways to display my custom post type as `single-{post-type}` and finally it works nicely once i used:               'rewrite'=> false,      before that, i used               'rewrite' => array( 'slug' => 'custom-post-type' )      but never works for me. Don't know where i made mistake. Right now i should feel happy cos its working without any error. But have a small confusion for the permalink because its display:   1. `localhost/myblog/?news=breaking-news`   2. _**instead of:_** `localhost/myblog/news/breaking-news` anyone please provide me some idea how to get link like: `localhost/myblog/news/breaking-news` my permalink structure selected: > http//myblog/sample-post/ and its working for other post types.


title: Custom comments list, right depth

text:
I created a custom comments_list() function, it works fine, the only problem is to show child comments inside the parent div. It works well with first and second depth levels but not for others. This is my code:               /* -----------------------------------------------------------------------------      * Comments custom functions      * -------------------------------------------------------------------------- */     //Custom comments lst     function t_one_comments_list( $comment, $args, $depth ) {         $GLOBALS['comment'] = $comment;         switch( $comment->comment_type ) :             case 'pingback' :             case 'trackback' : ?>             <li <?php comment_class(); ?> id="comment<?php comment_ID(); ?>">
<?php comment_author_link(); ?>
         <?php                 break;             default :         ?>
     <?php if ($depth == 1) {?>        <div <?php comment_class('media'); ?> id="comment-<?php comment_ID(); ?>">             <?php if ($comment->comment_approved == '0') : ?>
<?php _e('Your comment is awaiting moderation.', 't_one') ?>
             <?php endif; ?>
                     <?php echo get_avatar( $comment, 100 ); ?>

                             <?php comment_author(); ?>  <?php printf( __('%1$s', 't_one'), get_comment_date()) ?>                             <?php edit_comment_link(__(' Edit', 't_one'), ' ', '' ); ?>                             <?php comment_reply_link( array_merge( $args, array(                                      'reply_text' => __( 'Reply', 't_one' ),                                     'depth' => $depth,                                     'max_depth' => $args['max_depth']                                      ) ) ); ?>

<?php comment_text() ?>

                 <?php if ( $depth + 1) { ?>                 <div <?php comment_class('media'); ?> id="comment-<?php comment_ID(); ?>">             <?php if ($comment->comment_approved == '0') : ?>
<?php _e('Your comment is awaiting moderation.', 't_one') ?>
             <?php endif; ?>
                     <?php echo get_avatar( $comment, 100 ); ?>

                             <?php comment_author(); ?>  <?php printf( __('%1$s', 't_one'), get_comment_date()) ?>                             <?php edit_comment_link(__(' Edit', 't_one'), ' ', '' ); ?>                             <?php comment_reply_link( array_merge( $args, array(                                      'reply_text' => __( 'Reply', 't_one' ),                                     'depth' => $depth,                                     'max_depth' => $args['max_depth']                                      ) ) ); ?>

<?php comment_text() ?>

                      <?php } ?>
              <?php } ?>         <?php // End the default styling of comment             break;         endswitch;     }      What is the correct way to use $depth? Thanks in advance!


title: How to change post date only 1 time a day?

text: I have this code               is_admin() or add_action( 'the_post', function( $post ) {          if ( ! is_singular() or ! is_main_query() )         return;          $post->post_date     = current_time( 'mysql' );     $post->post_date_gmt = '';          wp_update_post( $post );      }); When refreshing the page, it will update to current time. But this will slow down my site. So how to update date time of page to current time **only 1 time per day** ? Example: I write a post on 5pm, June 6, 2013. And now, when I refresh page, it will change from 5pm, June 6 to 7pm, June 9. And in June 9, if I refresh the page, it will not change anything. Sorry for my poor English ! Thank you very much !


title: Conditional For get_the_author_meta

text:
In post loop I'd like to setup a condition for get_the_author_meta. So if the author meta field is empty, then nothing is displayed. Below is what I have but it's not working.               <?php if(get_the_author_meta('twitter') ): ?>     <a href="https://www.twitter.com/<?php get_the_author_meta('twitter'); ?>" target="_blank">Twitter
     <?php else: ?>     No website     <?php endif; ?>


title: How to support special characters in text field?

text: When i put special characters in text field on wordpress themes option then it's gonna add some slash characters Like if I put               It's        then its show               It\'s.       How i solve that?


title: Error: Call to a member function get_error_code() on a non-object

text: I am getting the following error when with the code that I wrote for my plugin: Error: Fatal error: Call to a member function get_error_code() on a non-object in .../wp-login.php on line 335 I've tried to do a var_dump($errors) inside wp-login.php and it returns NULL. My Plugin: (Adds registered users to an external db)                function add_user_to_SF($errors, $sanitized_user_login, $user_email ) {           global $SF_USERNAME;      global $SF_PASSWORD;      global $errors;           try {        $mySforceConnection = new SforceEnterpriseClient();        $mySoapClient = $mySforceConnection->createConnection(CD_PLUGIN_PATH . 'Toolkit/soapclient/enterprise.wsdl.xml');        $mySFlogin = $mySforceConnection->login($SF_USERNAME, $SF_PASSWORD);          $sObject = new stdclass();     $sObject->FirstName = $_POST['user_login'];     $sObject->LastName = $_POST['user_login'];     $sObject->Email = $_POST['user_email'];          $createResponse = $mySforceConnection->create(array($sObject), 'Contact');          $ids = array();         foreach ($createResponse as $createResult) {             array_push($ids, $createResult->id);         }              } catch (Exception $e) {                $errors->add( 'demo_error', __('ERROR: There is a Salesforce problem.','mydomain') );           return $errors;          }           }           add_filter( 'registration_errors', 'add_user_to_SF', 10, 3 );      Additionally, when I test the process with this function, everything works smoothly.                 function myplugin_registration_errors ($errors, $sanitized_user_login, $user_email) {         if ( empty( $_POST['first_name'] ) )             $errors->add( 'first_name_error', __('ERROR: You must include a first name.','mydomain') );              return $errors;     }      add_filter( 'registration_errors', 'myplugin_registration_errors', 10, 3 );


title: How to remove the Template drop down, but keep Parent and Order

text: I am about to turn a custom Wordpress site over to a client and do not want them to be able to choose/edit Templates, but need to allow them to sort the pages with Order and choose a Parent page. Is there a way to only remove the Template drop down from the Page Attributes option, but keep the Parent and Order options?


title: How can I add text to a single nav menu item?

text: I'm working on a theme that requires the end-user to specify the current performance season using a custom admin panel I've created, ie. "2013/2014", "2014/2015" etc., which I can retrieve using `get_option('current_season');` On my custom nav menu I have a page titled "Season" that needs the aforementioned field inserted into it so it reads "2013/2014 Season" rather than just "Season". The walker tutorials I have looked at only seem to show examples of adding a class to menu items but I need to add specific text to one menu item. How can I achieve this?


title: Unit testing for plugin development

text: I need to apply unit testing for one of my plugins. I recently re designed it into classes, so unit testing should be easier to apply now. What are some effective strategies to unit test my plugin? I need a way to use WordPress' functions used in the plugin, but I shouldn't need a running WordPress site (just test data on the DB AFAIK), right? I have a hard time figuring out how to just unit test the plugin and not the plugin in the site's context. I could use Selenium for this, but right now I just want to focus on unit testing the plugin classes functionality, so that I don't break them with each update.


title: Twenty Twelve Author not displaying

text: I have a WordPress blog. On which I want to display author name with each post.   I have tried various plugins but these don't work for me. This is the address of blog: http://altuslift.com/blog/ I want to show the name of author with date. Please help!


title: Temporary redirect prevents getting $_POST array

text:
I'm sending a form from a woocommerce plugin. I've tweaked the `thankyou.php` page and added email sending functionality. However the $_POST array is empty. Inspecting with Chrome Dev Tools I found that there is temporary redirect from the posted page:![Chrome Dev Tools](http://i.stack.imgur.com/1b8Mu.png) The relevant form code: (in `/woocommerce/templates/checkout/form- checkout.php`)                 <form enctype="multipart/form-data" name="checkout" method="post"  id="checky" class="checky" action="http://pharma-job.shared6.lighthost.co.il/checkout/order-received">     <input type="hidden" name="admin_email" value="<?php echo get_option('admin_email'); ?>" />         <?php if ( sizeof( $woocommerce_checkout->checkout_fields ) > 0 ) : ?>                  <?php do_action( 'woocommerce_checkout_before_customer_details'); ?>

                          <?php do_action('woocommerce_checkout_billing'); ?>

                          <?php do_action('woocommerce_checkout_shipping'); ?>

             העלה קו"ח:        <input type="file" name="cv_file">              <?php do_action( 'woocommerce_checkout_after_customer_details'); ?>
<?php _e('Your order', 'woocommerce'); ?>
              <?php endif; ?>              <?php do_action('woocommerce_checkout_order_review'); ?>          </form>      I looked at the generated HTML and found what appears to be the smoking gun:               <input type="hidden" name="_wp_http_referer" value="/checkout/" />      But what is the mechanism behind this redirect? How do I bypass it?


title: Checking if Database Table exists

text: I read the wordpress codex and professional wordpress. It seems both use something like               if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {      to determine if the table exists. Is there any reason why `CREATE TABLE IF NOT EXISTS ( ... )` is not used? It will check and create the table in 1 query, won't it be better? Or am I missing something?


title: RSS Widget on theme

text: I want to display some external RSS Feeds in my theme - not on a sidebar - just before a homepage content that I'm building. Is there a core shortcut or method to display RSS on themes?


title: Has anyone experience w/ WordPress (MultiSite) hidden users (possibly hacked)?

text: I have 2 WordPress MultiSite installs (on different accounts, but under the same HostGator reseller a/c) and both seem to have been compromised. I say "compromised" because the user_logins have been modified (somehow) and "hidden users" are being shown via WP Admin. I attempted to login to the installs which are both up-to-date (3.1) MultiSites. I use 1PassWord (with 50 character alpha + numerical + symbolic passwords) so weak passwords are not the hole. My logins (which I use every day) were rejected so I knew there was trouble. I can access phpMyAdmin and sure enough the user_logins and user_email had been modified. And if I change them via phpMyAdmin, 5mins later they were re- edited (now it seems I can't even do this). * Interestingly, I don't think you can change a username in WP Admin (it is ghosted and uneditable). Does this mean they are hacking in external to WP Admin in order to change this? Also, in the User Dashboard, 3 users are displayed, but the count (up the top) indicates there are 5 users in total. Super Admin is a simular story - it shows the tally as "3 Super Admins" but only 1 is displayed. (I have checked the source code and used Web Dev tools to try and find hidden content in these admin pages, but no joy). I had hoped to add new Super Admin and delete old super admin (after porting posts to new user admin user). But I am unable to delete the original Super Admin user (ID=1) even after creating new Super Admin and removing Super Admin privileges from ID=1. When I click "delete" (on hover of User ID=1) nothing happens; the page simply refreshes. HostGator have been suprisingly helpless, arguably hopeless, and VERY slow to deal with this matter. Which is ongoing. Can anyone give me some advice or help in any way.


title: Can I attach a plugin via my add_filter callback contents?

text:
I'm trying to add my plugin interface to the Category Editor. I've easily attached it to the post and page editor using the add_meta_box() filter, but there does not appear to be an add_meta_box hook on the category editor. So, since I'm already adding some extra fields to the category edit screen using add_filter('edit_category_form', 'my_category_editor_function', 1) I'm wondering if I can just call my plugin script from within that function? Example:               add_filter('edit_category_form', 'my_category_editor_function', 1);     function my_category_editor_function($tag) {         $tag_extra_fields = get_option('my_category_editor_function');?>
         <?php              /*             load my widget here. May have to use some funky css to get it to float              to the right of the cat editor just like it does in the post editor             */         ?>

             Category Title	             <input name="_my-categoryTitle" id="_my-categoryTitle" type="text" size="40" aria-required="false" value="<?php echo $tag_extra_fields[$tag->term_id]['my_cat_title']; ?>" />
The title is optional but will be used in place of the name on the home page category index (when in list view) and on the category landing page.

             Keywords	             <input name="_my-categoryKeywords" id="_my-categoryKeywords" type="text" size="40" aria-required="false" value="<?php if(isset($tag_extra_fields[$tag->term_id]['my_cat_keywords']))echo $tag_extra_fields[$tag->term_id]['my_cat_keywords']; ?>" />
Optional: If you want to add a keywords metatag to the category landing page and keywords in the Category image's alt tag.

             Image Link	             <input name="_my-categoryImageLink" id="_my-categoryImageLink" type="text" size="40" aria-required="false" value="<?php if(isset($tag_extra_fields[$tag->term_id]['my_cat_imageLink']))echo $tag_extra_fields[$tag->term_id]['my_cat_imageLink']; ?>" />
Optional: If you want to link the category landing page image to an affiliate or CPA offer, place your link here.

             Hide Ads?	             <input name="_my-categoryAds" id="_my-categoryAds" type="checkbox" style="width:30px;float:left;"<?php if(isset($tag_extra_fields[$tag->term_id]['my_cat_ads'])) echo ' checked="checked"'; ?>" />
Check this to remove ads from this category's landing page. (Does not affect ads placed in widgets)


title: Filter list of rules based on a capability

text: I'm trying to get a list of roles and filter them by a specific capability (custom). I've ran across this post, but I'd like to filter the roles by whether they're capable to, say, `edit_post`. -Zack


title: Getting custom taxonomy posts on archive page

text: Hi I am not sure if the question is understandable or not but what I am trying to achieve I will explain. I have a custom post type called menu item and custom taxonomy called menu item type. CODE               function create_menu_post_type()      {         $labels = array(             'name' => __( 'Food Menu','framework'),             'singular_name' => __( 'Menu Item','framework' ),             'add_new' => __('Add New','framework'),             'add_new_item' => __('Add New Menu Item','framework'),             'edit_item' => __('Edit Menu Item','framework'),             'new_item' => __('New Menu Item','framework'),             'view_item' => __('View Menu Item','framework'),             'search_items' => __('Search Menu Items','framework'),             'not_found' =>  __('No Menu Item found','framework'),             'not_found_in_trash' => __('No Menu Item found in Trash','framework'),              'parent_item_colon' => ''           );                $args = array(             'labels' => $labels,             'public' => true,             'exclude_from_search' => false,             'publicly_queryable' => true,             'show_ui' => true,              'query_var' => true,             'menu_icon' => get_template_directory_uri() . '/images/menu.png',             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => 5,             'supports' => array('title','editor','thumbnail'),             'rewrite' => array( 'slug' => __('menu-item', 'framework') )           );                 register_post_type('menu-item',$args);     }     add_action( 'init', 'create_menu_post_type' );               function create_menu_item_type_taxonomy(){              $labels = array(             'name' => __( 'Menu Item Types', 'framework' ),             'singular_name' => __( 'Menu Item Type', 'framework' ),             'search_items' =>  __( 'Search Menu Item Types', 'framework' ),             'popular_items' => __( 'Popular Menu Item Types', 'framework' ),             'all_items' => __( 'All Menu Item Types', 'framework' ),             'parent_item' => __( 'Parent Menu Item Type', 'framework' ),             'parent_item_colon' => __( 'Parent Menu Item Type:', 'framework' ),             'edit_item' => __( 'Edit Menu Item Type', 'framework' ),              'update_item' => __( 'Update Menu Item Type', 'framework' ),             'add_new_item' => __( 'Add New Menu Item Type', 'framework' ),             'new_item_name' => __( 'New Menu Item Type Name', 'framework' ),             'separate_items_with_commas' => __( 'Separate Menu Item Types with commas', 'framework' ),             'add_or_remove_items' => __( 'Add or Remove Menu Item Types', 'framework' ),             'choose_from_most_used' => __( 'Choose from the most used Menu Item Types', 'framework' ),             'menu_name' => __( 'Menu Item Types', 'framework' )         );              register_taxonomy(             'menu-item-type',              array( 'menu-item' ),              array(                 'hierarchical' => true,                  'labels' => $labels,                 'show_ui' => true,                 'query_var' => true,                 'rewrite' => array('slug' => __('menu-item-type', 'framework'))             )         );      }          add_action( 'init', 'create_menu_item_type_taxonomy', 0 );      I have created a post named sushi under the term japenese. And then created post named chow mein under the term chinese.I want to populate archive posts by different terms. I have an archive page i.e archive.php where I am populating posts but my code populates all posts from all terms.               <?php $loop = new WP_Query( array( 'post_type' => 'menu-item', 'posts_per_page' => -1 ) ); ?>                 <?php while ( $loop->have_posts() ) : $loop->the_post();                     get_template_part( 'content', get_post_format() );                     endwhile; wp_reset_query();                 ?>                      <?php else : ?>                     <?php get_template_part( 'content', 'none' ); ?>                 <?php endif; ?>      I am navigating to the archive page via dynamic sidebar               <?php dynamic_sidebar( 'Archive' ); ?>      Please note that I have used the custom post type and the taxonomy code from a theme as a reference. Also if this is by any way a non-valid question feel free to comment and I will delete the question and try to find some other solution. Adding a clearer example               Custom post -> menu-item     menu-item -> 2 posts -> sushi, chow mein     taxonomy -> menu-item-type     menu-item-type -> japenese, chinese     sushi -> japenese     chowmein -> chinese


title: List post from current taxonomy children

text: I have a custom post type and a taxonomy with children, with a template file named taxonomy-productcategories.php. On this i want to list all children with their posts.   * Child taxonomy 1     * Child taxonomy 1 Post A     * Child taxonomy 1 Post B     * Child taxonomy 1 Post C   * Child taxonomy 2     * Child taxonomy 2 Post D     * Child taxonomy 2 Post E     * Child taxonomy 2 Post F And so on... I have an example for getting just the Child taxonomy, but i want to add the post from each taxonomy.               <?php     $term_slug = get_query_var( 'term' );     $taxonomyName = get_query_var( 'taxonomy' );     $current_term = get_term_by( 'slug', $term_slug, $taxonomyName );     $termchildren = get_term_children( $current_term->term_id, $taxonomyName );          foreach ($termchildren as $child) {         $term = get_term_by( 'id', $child, $taxonomyName );         echo "$term->name:<br />";           }     ?>


title: Custom widget breaking widget section in admin menu

text:
I am building a child theme at http://habitat.erniehigh.com for a client. I need to add custom widget that shows recent posts by category. I have built similar widgets elsewhere using basically the same code.                   class habitat_posts extends WP_Widget {       function habitat_posts(){     $widget_ops = array(     'description' => 'Allows you to display a list of recent posts within a particular category.');     $this->WP_Widget('fromcat-widget', 'Recent posts from a Category', $widget_ops);     }      function form($instance) {     //widgetform in backend     $name = $instance['title'];     $numberposts = $instance['numberposts'];     $catid = $instance['catid'];     $rss = $instance['rss'];     ?>      <?php   }  // end of the instance      function update( $new_instance, $old_instance ) {         $instance = $old_instance;         $instance['catid'] = $new_instance['catid'];         $instance['numberposts'] = $new_instance['numberposts'];         $instance['title'] = $new_instance['title'];         $instance['rss'] = $new_instance['rss'];         return $instance;         } // end the updated        function widget( $args, $instance ) {            extract($args, EXTR_SKIP);              $title = $instance['title'];              $catid = $instance['catid'];               $numberposts = $instance['numberposts'];                       $posts = get_posts('numberposts='.$numberposts.'&category='.$catid);                        $out = '
';                   foreach($posts as $post) {                   $out .= '
ID).'">'.$post->post_title.'
';                      }               $out .= '
';              echo $before_widget;              echo $before_title.$title.$after_title;               echo $out;               echo $after_widget;               } // end of widget function           }  // end the whole process ready to register              register_widget('habitat_posts');      When I try to use it on the child theme here everything goes OK except the Widget area in the backend is a jumbled up mess. The new widget is visible and the form fields for creating a new instance are visible and I can drag it to a sidebar but that is all. Thanks for any suggestions or help Ernie


title: is_wp_error() and handling errors

text: Im trying to build a function which grabs the feedburner "readers" using `wp_remote_get()`. I noticed that it frequently returned a value of `0`. I assumed at first that it was a WordPress error (handled by `is_wp_error()`) or a flaw with `wp_remote_get()`. Wrong of-course.. Feedburner just kept crashing, so I used a second transient to store a result (never `0`) with an expiration of 7 days. The part which i cant get my head around is handling errors with `is_wp_error()`. I need to force an error so i can handle it properly, before I put it up on production. Heres an illustration:               $result = wp_remote_get( 'http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=' . urlencode($username) );          if ( is_wp_error($result) )         return false;      Whats the best way to force an error? Should i use `new WP_error()`?


title: Adding header logo instead of text

text: I want to add Header logo instead of the text "physics for All " in the following site. I think , i have to add my logo to my site then , i will have to insert the image link to the `header.php` option . I am using spacious wordpress theme. Can you suggest me that which one will i need to remove and to add to set the logo.


title: Exclude User from Activity Stream in BuddyPress?

text: I'd like to exclude a specific user account from showing up in the activity stream. I found this code that's supposed to exclude the Admin. Any clue how to exclude a specific user? (this code goes in bp-custom.php)               <?php      add_action("plugins_loaded","bpdev_init_sm_mode");     function bpdev_init_sm_mode(){     if(is_site_admin())     remove_action("wp_head","bp_core_record_activity");//id SM is on, remove the record activity hook     }     ?>      Thank you.


title: Display recent posts from the same category as current post in sidebar

text: I'm using a modified version of Twenty Twelve and I'm trying to display recent posts from the same category as the current post (except the current post) in the sidebar. I started this way but something's not ok:                   $category = get_the_category($post->ID);          $current_cat = $category[0]->cat_name; //This will get me the first category assigned to the current post but since every post has only ONE cat. assigned to, it's good enough        //Next, in my sidebar widget I have this:         $my_query = new WP_Query('category_name='.$current_cat.'&showposts=10');         while ($my_query->have_posts()) : $my_query->the_post();         ...display my titles here ...         unset($current_cat); //I'm not sure I need to unset this variable?         endwhile;      I'm not really a programmer so I'm struggling with understanding the logic but I'd like to learn. Any suggestions/help much appreciated! Thank you, Alex


title: Add image to media library from URL in uploads directory

text: The plugin "Video Embed & Thumbnail Generator" does a great job of generating thumbnails from videos. It saves the thumbnail URL as metadata for the attachment. The thumbnail gets added to the uploads directory. Is there a way to take this image and add it to the media library so i can pass the image through the image_downsize function to create thumbnail of a different size? wp_insert_attachment looks like it needs a path to a file and not a URL, or am i mistaken? how can i add a URL to the media library? this is possibly a duplicate of How can I get an image from the uploads dir and enter it in the media library? but that never got any answers.


title: My Gallery Photos are showing in the post's excerpts

text: I just can't win with this project! All of a sudden, each post's gallery photos are showing up in the excerpt/preview of the post. Each post has a gallery of images that should only be visible on the actual post's page. Can anyone see what might be causing this? Here is my code:               if ( has_post_thumbnail() ) {          the_post_thumbnail();     }     else {          get_the_image( array('size' => 'thumbnail',                               'image_class' => 'wp-post-image'));        }      Then in my functions file:               // This theme displays custom size (page-single) featured image on the Post's  page          function InsertFeaturedImage($content) {              global $post;              $original_content = $content;              if ( current_theme_supports( 'post-thumbnails' ) ) {                  if ((is_page()) || (is_single())) {                      $content = get_the_image( array( 'size' => 'full' ) );                 $content .= $original_content;             }         }         return $content;     }          add_filter( 'the_content', 'InsertFeaturedImage' );      You can view the site in question here: http://dependablecarcompany.com You'll see the horribly broken site in question. There should only be the ONE excerpt representative thumbnail there, and not all the thumbs from the gallery too. Thank You!


title: Error with /wp-admin/install.php

text: I have installed Wordpress many times and never encountered an issue. However I just installed it on a folder (public_html) and after setting up the config.php file it doesn't work. Alledgedly all my information is correct since it doesn't return database error on /wp-admin but redirects to /wp- admin/install.php. However the install.php doesn't load at all. In chrome I get:               The website encountered an error while retrieving http://www.chirie-sanchez.com/wp-admin/install.php. It may be down for maintenance or configured incorrectly.          HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.      The problem seems to be around here, since I can write anything before but not after:               /** Load WordPress Bootstrap */     require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );          /** Load WordPress Administration Upgrade API */     require_once( dirname( __FILE__ ) . '/includes/upgrade.php' );          /** Load wpdb */     require_once(dirname(dirname(__FILE__)) . '/wp-includes/wp-db.php');      I tried changing those with relative URLs and still didn't work. I don't know what to do? What could be the issue?


title: Editing options pages?

text: I'm trying to find a way of adding a single checkbox to one of the existing options pages, most likely options-reading.php programmatically. Unfortunately, I haven't found any good references on this. Any thoughts from the community?


title: CPT Template Not Showing - Getting 404

text: I'm developing a Custom Post Type plugin, which works fine in dev. Now that I've moved it to production, I'm getting a 404 when I try to display the template for the CPT. So, two questions: 1- Is there some mechanism to determine the path WP took to get through the hierarchy? 2- Why wouldn't it just give me the single or index page? I've dumped $wp_query and a stacktrace at the end of the 404. Here's part of what I found:               [query] => Array         (             [page] =>              [pagename] => refletters/proximity         )          [request] => SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND (wp_posts.ID = '0') AND wp_posts.post_type = 'page'  ORDER BY wp_posts.post_date DESC      [posts] => Array         (         )          [queried_object] =>      [queried_object_id] => 0      And the stack trace:               2013-04-27 22:16:41 - 24.52.197.40 - TRACE - index.php - 404.php[39] -          wordpress/wp-content/themes/notoriousconsultant/404.php[39] - aaLog->logtrace         wordpress/wp-includes/template-loader.php[50] - include         wordpress/wp-blog-header.php[16] - require_once         wordpress/index.php[17] - require      Thanks for your help.


title: Roots: Custom Post Type 404 Not Found

text: So I'm trying to create a custom post type for my theme. I've written the function to register the post type and I can add a post from the admin panel, but when I try to view the new post's permalink, I get a 404 not found page. Here's my post type function:               add_action( 'init', 'create_press_coverage' );          function create_press_coverage() {         register_post_type( 'press_coverage',             array(                 'labels' => array(                     'name' => 'Press Coverages',                     'singular_name' => 'Press Coverage',                     'add_new' => 'Add New',                     'add_new_item' => 'Add New Press Coverage',                     'edit' => 'Edit',                     'edit_item' => 'Edit Press Coverage',                     'new_item' => 'New Press Coverage',                     'view' => 'View',                     'view_item' => 'View Press Coverage',                     'search_items' => 'Search Press Coverage',                     'not_found' => 'No Press Coverages found',                     'not_found_in_trash' => 'No Press Coverages found in Trash',                     'parent' => 'Parent Press Coverage'                 ),                      'public' => true,                 'menu_position' => 8,                 'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),                 'taxonomies' => array( '' ),                 'has_archive' => true             )         );     }      I'm using the roots starter theme. Is there some extra configuration I need to do to make custom post types work with it? Thanks.


title: I am creating custom post type now i am creating for this post type single page but getting page isn't found

text: I am creating custom post as per given code add_action( 'init', 'create_post_type' ); function create_post_type() {               register_post_type( 'slider',             array(                 'labels'        => array(                 'name'          => __( 'Slider' ),                 'singular_name' => __( 'Slider' )                 ),         'supports'    => array( 'title', 'editor', 'thumbnail'),             'public'      => true,         'has_archive' => true,         )     );      } also creating themesfolder/single-slider.php but data is not getting page redirect on page isn't found.


title: Archive of custom post type returns 404

text: I have created a custom post type "video" (see my functions.php below) and it should return an archive on mysite.com/video but instead I get a 404. **Functions.php**               // Video's     add_action( 'init', 'register_cpt_video' );          function register_cpt_video() {              $labels = array(              'name' => _x( 'Video\'s', 'video' ),             'singular_name' => _x( 'Video', 'video' ),             'add_new' => _x( 'Voeg nieuwe toe', 'video' ),             'add_new_item' => _x( 'Voeg nieuwe video toe', 'video' ),             'edit_item' => _x( 'Bewerk video', 'video' ),             'new_item' => _x( 'Nieuwe video', 'video' ),             'view_item' => _x( 'Bekijk video', 'video' ),             'search_items' => _x( 'Zoek video\'s', 'video' ),             'not_found' => _x( 'Geen video\'s gevonden', 'video' ),             'not_found_in_trash' => _x( 'Geen video\'s in de prullenbak gevonden', 'video' ),             'parent_item_colon' => _x( 'Parent Video:', 'video' ),             'menu_name' => _x( 'Video\'s', 'video' ),         );              $args = array(              'labels' => $labels,             'hierarchical' => true,             'description' => 'Gebruik dit posttype om video\'s te posten',             'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'page-attributes' ),             'taxonomies' => array( 'post_tag' ),             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'menu_position' => 11,                  'show_in_nav_menus' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'has_archive' => true,             'query_var' => true,             'can_export' => true,             'rewrite' => array(                  'slug' => 'videos',                 'with_front' => true,                 'feeds' => true,                 'pages' => true             ),             'capability_type' => 'page'         );              register_post_type( 'video', $args );     }      I am working with Buttercream as a parent theme. I have a similar cpt ("foto") and that one does work flawlessly. Very strange. If it helps, this is the site: http://www.denotenbalkers.be/fotos/ (As you can see, `/fotos` works, but the "Video's" link in the nav does not.) ## EDIT 1 (22-4-2013) I tried adding another cpt, but it gives the same problem: I can create a post with that type, but when I want to view it, I get a 404.               add_action( 'init', 'register_cpt_filmpje' );          function register_cpt_filmpje() {              $labels = array(              'name' => _x( 'Filmpjes', 'filmpje' ),             'singular_name' => _x( 'Filmpje', 'filmpje' ),             'add_new' => _x( 'Voeg nieuw toe', 'filmpje' ),             'add_new_item' => _x( 'Voeg nieuw filmpje toe', 'filmpje' ),             'edit_item' => _x( 'Bewerk filmpje', 'filmpje' ),             'new_item' => _x( 'Nieuw filmpje', 'filmpje' ),             'view_item' => _x( 'Bekijk filmpje', 'filmpje' ),             'search_items' => _x( 'Zoek filmpjes', 'filmpje' ),             'not_found' => _x( 'Geen filmpjes gevonden', 'filmpje' ),             'not_found_in_trash' => _x( 'Geen filmpjes in de prullenbak gevonden', 'filmpje' ),             'parent_item_colon' => _x( 'Parent Filmpje:', 'filmpje' ),             'menu_name' => _x( 'Filmpjes', 'filmpje' ),         );              $args = array(              'labels' => $labels,             'hierarchical' => true,             'description' => 'Gebruik dit posttype om filmpjes te posten',             'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'page-attributes' ),             'taxonomies' => array( 'post_tag' ),             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'menu_position' => 11,                  'show_in_nav_menus' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'has_archive' => true,             'query_var' => true,             'can_export' => true,             'rewrite' => array(                  'slug' => 'filmpjes',                 'with_front' => false,                 'feeds' => false,                 'pages' => true             ),             'capability_type' => 'page'         );              register_post_type( 'filmpje', $args );     }


title: Why do all my custom post types return a 404, even after resetting the permalink?

text: I have two custom post types setup like this:               add_action( 'init', 'create_post_type_News' );     function create_post_type_News() {         register_post_type( 'news',             array(                 'labels' => array(                     'name' => __( 'News' ),                     'singular_name' => __( 'News' )                 ),             'public' => true,             'has_archive' => true,             'supports' => array(                 'title',                  'editor',                  'author',                  'thumbnail'             )             )         );     }      when I try to view the page (`/%postname%/` is used as permalink) I get the standard 404 message "Not Found Apologies, but the page you requested could not be found. Perhaps searching will help." I've tried the standard fix:   * set permalink back to default and save   * set permalink back to desired style and save The page **will** show with permalinks as default but not customized.


title: Naming convention for taxonomies

text: I had a taxonomy called: `wossom`. And I was using `taxonomy-wossom.php` as the template file that will describe a term of this taxonomy. Now I need to change the name of the taxonomy to `wossom-balag`, so I changed the name of the template to `taxonomy-wossom-balag.php`. But the page is not working correctly. Is the cause of the problem the fact that I am not respecting naming convention for the hierarchy? Thank you very much


title: How to know when an user is loged in?

text: Hello i have this simple problem: when the user is logged an podcast player is shown, other case no. How verify when the user is logged? Im wordpress and php newbie. Thankx


title: Gravity Forms | Form Object is NULL

text: I am trying to customize some gravity forms behavior. Therefore I've tried to hook into gforms from my theme. Unfortunately the form object is always `NULL`. Why is that the case? Example code:               1)     add_action('gform_confirmation', 'myCustom_gform_confirmation');     function myCustom_gform_confirmation($confirmation, $form) {         var_dump($confirmation);         var_dump($form);         die();     }          2)     add_action('gform_after_submission', 'myCustom_gform_after_submission');     function myCustom_gform_after_submission($entry, $form) {         var_dump($entry);         var_dump($form);         die();     }


title: How to override a parent theme framework php file in child theme

text: I have a theme which is using a custom framework to create custom post types, I want to extend it in child theme so that I will use the same methods to create a new custom post type in child theme. I cannot write custom code I must use the original classes to extend the functionality in child theme. The problem is I am unable to override any of the parent theme framework files. The standard files can be overridden but framework files (in a folder like parenttheme/framework/php/anyfilehere.php) cannot be overridden. I have duplicated the same folder structure and tried to override the file by creating a same name file, but it does not work.


title: What's wrong with my wp database query?

text: $cats = $wpdb->get_results('SELECT term_id, term_taxonomy_id, taxonomy, parent      FROM wp_terms, wp_term_taxonomy      WHERE term_id = term_taxonomy_id      AND parent = 1     AND taxonomy = "category"', ARRAY_A);      I'm trying to get all the categories in my database that are children of the category of ID 1, but it's not working. What's wrong ?


title: Import images from self-hosted to WordPress.com

text: I'm trying to migrate my self-hosted WP blog to WordPress.com, images included. Originally images were hosted on various image-hosting websites, but I've used this plugin to cache and upload them to my self-hosted WP media library. Now posts have image tags in this format:               <img src="http://mywebsite.com/wp-content/uploads/2012/02/2033_l.jpg" alt="" />      I've exported my blog to XML, and used the import tool on WordPress.com. The blog is imported fine, and all images have been added to WordPress.com media library. However, image urls in each post still link to my self-hosted (old) blog. I've contacted their support regarding this issue, and they say I have to change each of the 650~ image urls manually. Is there an easy way of doing this? I can do a _search & replace_ on the exported XML file, but there must be some easier way of importing the urls correctly.


title: How to update post taxonomies (Creating a custom UI for Custom Taxonomy)

text: I have a taxonomy eg. authors. I want to create a custom UI for. I think integrating with a Meta Box together with other post meta will make things easier for the user. Also I think a jQuery UI AutoComplete (Multiple comma separated values) is more appropriate So I will need to know how I can "update_post_taxonomy". I suppose I will need to   * if taxonomy does not exists      * create it   * if post does not have the taxonomy term      * add it   * remove terms that are not specified by user I am sure there are functions for this?


title: How to sort categories by id in wordpress admin

text: I would like to know if it is possible in Wordpress admin to show categories in `post-new.php` and `edit-tags.php?taxonomy=category` sorted by id NOT by category name.


title: How do I call comments_template(); from a plugin file?

text:
I am trying to call `comments_template();` from a plugin file. Specifically, it's the `player.php` file from the plugin All Video Gallery. Below is the file itself.               <?php          require_once('ismobile.php');          /******************************************************************     /* Build Player     ******************************************************************/     class Player {              var $width, $height;              public function buildPlayer( $profileid = 1, $videoid = 1, $autodetect = 1 ) {             global $wpdb;                         $profile      = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_profiles WHERE id=".$profileid);                  $this->width  = $profile->width;             $this->height = $profile->height;                  if( isset($_GET['slg']) && $autodetect == 1 ) {                 $slug    = $_GET['slg'];                 $video   = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_videos WHERE slug='$slug'");                 $videoid = $video->id;             } else {                 $video   = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_videos WHERE  id=".$videoid);             }                     if($video->type == 'thirdparty') {                 $result    = '
width . 'px; height:' . $this->height . 'px;">';                 $result   .= $video->thirdparty;                 $result   .= '
';             } else {                 $arr_params = array();                   $custpage   = ( $profile->custom_page_url ) ? $profile->custom_page_url : $this->curPageURL();                 if( isset($_GET['catid']) ) {                     $arr_params['catid'] = $_GET['catid'];                 }                 if( isset($_GET['sort']) ) {                     $arr_params['sort'] = $_GET['sort'];                 }                        $flashvars = 'base='.get_option('siteurl').'&wp=1&vid='.$videoid.'&pid='.$profileid.'&page='.urlencode( @add_query_arg($arr_params, $custpage) );                 $detect    = new IsMobile();                             $result    = $detect->isMobile() ? $this->gethtmlplayer( $profile, $video ) : $this->getflashplayer( $profile, $flashvars );                 }                         $this->updatehits( $video->slug );                  $cust_class = ( $profile->custom_player_class ) ? $profile->custom_player_class : 'avs_player';                  $output  = '' . "\n";             $output .= '
width.'px;">' . "\n";             if($profile->title) {                 $output .= '
'.$video->title.'
' . "\n";             }             if($profile->category) {                 $output .= '
Category : '.$video->category.'
' . "\n";             }             if($profile->hits) {                 $output .= '
Hits : '.$video->hits.'
' . "\n";             }             $output .= '

' . "\n";             $output .= $result . "\n";             if($video->description) {                 $output .= '
'.$video->description.'
' . "\n";             }             $output .= '
' . "\n";                  return $output;         }              public function getflashplayer( $profile, $flashvars ) {             global $allvideogallery_plugin_dir;                  $siteurl = get_option('siteurl');             $src     = $siteurl . '/wp-content/plugins/' . $allvideogallery_plugin_dir . '/player.swf?random=' . rand();                  $result  = '<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="' . $this->width . '" height="' . $this->height . '">';             $result .= '<param name="movie" value="' . $src . '" />';             $result .= '<param name="wmode" value="opaque" />';             $result .= '<param name="allowfullscreen" value="true" />';             $result .= '<param name="allowscriptaccess" value="always" />';             $result .= '<param name="flashvars" value="' . $flashvars . '" />';             $result .= '<object type="application/x-shockwave-flash" data="' . $src . '" width="' . $this->width . '" height="' . $this->height . '">';             $result .= '<param name="movie" value="' . $src . '" />';             $result .= '<param name="wmode" value="opaque" />';             $result .= '<param name="allowfullscreen" value="true" />';             $result .= '<param name="allowscriptaccess" value="always" />';             $result .= '<param name="flashvars" value="' . $flashvars . '" />';             $result .= '</object>';             $result .= '</object>';                  return $result;         }              public function gethtmlplayer( $profile, $video ) {             if($video->type == 'youtube') {                 $url_string = parse_url($video->video, PHP_URL_QUERY);                 parse_str($url_string, $args);                 $result  = 'width.'" height="'.$this->height.'" ';                 $result .= 'src="http://www.youtube.com/embed/'.$args['v'].'" frameborder="0" allowfullscreen>';             } else {                 $preview = $video->preview ? 'poster="' . $video->preview . '"' : '';                 $result  = '<video onclick="this.play();" width="'.$this->width.'" height="'.$this->height.'" '.$preview.' controls>';                 $result .= '<source src="'.$video->video.'" />';                 $result .= '</video>';             }                  return $result;         }              function curPageURL() {             $pageURL = 'http';                   if (!empty($_SERVER['HTTPS'])) {if($_SERVER['HTTPS'] == 'on'){$pageURL .= "s";}}              $pageURL .= "://";              if ($_SERVER["SERVER_PORT"] != "80") {                  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];              } else {                  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];              }                   return $pageURL;         }              function updatehits( $slug ) {             global $wpdb;                  $table_name = $wpdb->prefix."allvideogallery_videos";             $video = $wpdb->get_row("SELECT * FROM $table_name WHERE slug='$slug'");                     $count = ($video) ? $video->hits + 1 : 1;             $video->hits = $count;                  $wpdb->update($table_name, array('hits' => $video->hits), array('id' => $video->id));         }          }          ?>      I've tried adding `comments_template();` right before the `?>` but nothing shows up. Is there another way to call that function when it's not a theme file?


title: Absolute path to stylesheet_dir/images/my_img.jpg does not work?

text: I am manipulating an img element in functions.php using jQuery by changing the src attr on hover. How do I make so the absolute path works? Currently, when I view the image directly in the browser it brings me to 404 page. Relative path doesn't work either.


title: The revisions table in my database is at 70% capacity and growing. What should I do?

text: I installed the Wordpress System Health Plugin and it says that the revisions table in my database is at 70% capacity with 994 rows. I don't fully understand what this means. I anticipate that my site will get much larger than it is today. Questions   * Am I going to run into trouble or is there some way I can increase that table's capacity?    * Is it a hosting issue?  One proactive thing I have done is set a max number of post revisions to 4. Any solution or an explanation to help me understand what's going on would be really appreciated. Thanks for your help.


title: How to show description under an inserted image?

text: I'm using wordpress' native media manager. I have a problem. I can show the title under the image. But I want also to show the description. Is it possible to do?


title: Custom Post Custom Taxonomy Data Not Saving in Edit Screen

text: I have a custom post type "projects" with a custom taxonomy "project_type." If I select a project type taxonomy within the post editor screen and hit update, the taxonomy isn't updated. Worse yet, it clears all taxonomy values associated with that project. Oddly, I added a column in the admin screen to display the custom taxonomy values and I am able to update the taxonomy values via WP's built-in quick edit feature. Here is the bulk of the custom post type and taxonomy code: http://pastebin.com/2TdmVEAE So, I'm thinking I need some function that will amend the save post function to include the custom taxonomy data. Right now the save_post function must not include custom taxonomies in a custom post type, and that is why it is clearing the data. (side: why does it work with quick post?) I just don't know how exactly to handle the data in the custom taxonomies to compare/write the selected taxonomies to the specific post. I've just discovered the codex on save_post... Here's what I have so far, built off another post that is similar:               add_action('save_post', 'dcg_taxonomy_save');          // Save data from meta box     function dcg_taxonomy_save($post_id) {     global $post;          // verify nonce     if (!wp_verify_nonce($_POST['project_type'], basename(__FILE__))) {         return $post_id;     }          // check autosave     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {         return $post_id;     }          // check permissions     if ('page' == $_POST['project']) {         if (!current_user_can('edit_page', $post_id)) {             return $post_id;         }     } elseif (!current_user_can('edit_post', $post_id)) {         return $post_id;     }          $old = wp_get_post_terms($post_id, 'project_type', array("fields" => "all") ); // grabs all terms for this post in the taxonomy     $new = $_POST[ ...?... ]; // <-- how do I grab the custom taxonomy values          // probably need to run a foreach through the array of taxonomy values, yea?     if ($new != $old) {         wp_set_post_terms($post_id, $new, 'project_type', false ) // sets new taxonomy terms     }     }


title: comment_post callback function: how to run it in the background.

text: I'm calling a custom function when someone submits comments using the following to plug into the comment_post action: add_action('comment_post', 'MY_FUNCTION'); The problem is that my function is extremely heavy, causing about a 5 second delay between the time when someone submits a comment to the time when the page refreshes and they view their comment. Is there any way that my custom function could run in the background, so that they could be redirected right away? Alternatively, would it be safe to redirect them directly at the top of my function, then run the rest of my function after they had already been redirected?


title: Wordpress doesn't load HTML

text:
All, I'm trying to have a side navigation menu that once you click on a link it basically pulls the content of that wordpress page and displays it. I've got the following code to do this:               $qry = "Select post_content from wp_jjfuap_posts where ID='$menu->object_id'";     $result = mysql_query($qry);     $resultset = mysql_fetch_array($result);     $output = apply_filters( 'the_content', $resultset['post_content'] );      The issue is that it doesn't translate any HTML. It simply just displays the HTML. For example, it will output the following:

Test

Another test

     Blah
Al
 Person
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lacinia justo quis neque da
      How can I get Wordpress to actually display the correct HTML using this method? Thanks!


title: Customize search page

text: When I just click search, wordpress takes me to the 404 page. I'd like to just have a search template (maybe a page) that does search. Can anyone help? **UPDATE:** I created a custom search page (link), and changed things around in my header file to reflect the custom search page, however now the search is broken. Can you check out the code and help me out?


title: Using CSS ID's and Classes with images in a Wordpress Horizontal Menu

text:
just found this marvelous website, so, I'm new in Wordpress. I have a HTML/CSS website developed from a PSD file. Everything was going OK, Header, Footer, but when I came across the WP menu, I'm just stocked. Here's a code menu example:

     etc etc

      And the CSS for one example:                a#menunews, a#menunews:link, a#menunews:visited, a#menunews:active {     background: transparent url(imagens/menu/menu_news.png) no-repeat left top;     display: block;     height: 55px;     width: 56px;      }      a#menunews:hover {background-position: left bottom;}      Then I found that WP menus accepts classes, and I turn some of these itens into:               .menunews {     background: url(images/menu/menu_news.png) no-repeat left top;     height: 55px;     width: 56px;     display:block;     }      and                   #navmenu li:hover {     background-position: left bottom;     }      My question is, can I build the menu using the first structure, with the ID's? I have no idea where the wp_menu list outputs are... And using the classes, inside the menu admin panel, it works, but the Page Title stays above the image and the link works only on it, not in the image itself, like a block, like the original CSS. For visual purposes, the menu should look like this website: http://www.realmofobscura.com/ it is by the way made with WP. tutorials, links, anything, will be highly appreciated =)


title: How to use wp_nav_menu to create a select menu dropdown?

text: I'm using the following inside the `wp_nav_menu` function to create a select dropdown menu where each menu item is an option in the select dropdown...               'items_wrap' => '<select>%3$s</select>'     'before'     => '<option value="">'     'after'      => '</option>'      How do I add the link value in the `'before'` declaration? Is there a better way to go about this? I know about `wp_dropdown_pages`, but that doesn't work because I want users to be able to control the menu from the "Menus" page.


title: Using wordpress post data as input for google visualisations

text: I'm trying to use wordpress post data (eg title, link, custom fields) as a data source for google visualisations. I want to be able to take the wordpress data for all posts and visualise using the "table" and "motion" charts. Related doc http://code.google.com/apis/chart/interactive/docs/gallery/table.html http://code.google.com/apis/chart/interactive/docs/gallery/motion.HTML How do I loop though all my posts to create an array that that will work as a data source? I want to get post titles, post urls and associated custom fields for graphing. Hope you can help!


title: Adding Alt Attributes Automatically when Uploading Images to Media Library

text: I have lots of images that has to be uploaded via media library. I want to know, is it possible to add file name to `alt` attribute field automatically when I am uploading them? At the moment I have to open each image and add the `alt` attribute manually.


title: How to create a category or tag available exclusively to the admins and not to the users?

text: I would like to create a category or tag name that is available only to the admin(s) and not to the authors. For example, I would like to create a category or tag called `Exclusive Content`. Now only admins should be able to add this category or tag to their posts. Other users should not be able to see it or use it. Is it possible?


title: Locale switching with a "language" taxonomy

text: I know that it's possible to switch the WP locale by using URL paramaters, as described here, but I'm trying to build a method that would entirely rely on a custom "Language" taxonomy. What I currently have is a simple plugin, that registers the language taxonomy and implements a locale switch if the taxonomy is present:               <?php     add_action( 'plugins_loaded', 'wpsx_register_taxonomies' );     function wpsx_register_taxonomies() {     register_taxonomy('wpsx_language', array (                       0 => 'post',                       1 => 'page',                     ), array(                          'hierarchical' => true,                          'label' => 'Languages',                         'singular_label' => 'Language',                         'show_ui' => true,                         'rewrite' => false,                         )                      );     }     function wpsx_redefine_locale($locale) {         global $post;           if ( taxonomy_exists( 'wpsx_language' )) {             $locale = 'de_DE'; // this does work !!             if ( has_term( 'fr', 'wpsx_language' )) {                 $locale = 'fr_FR'; // this does not work yet :(             }             }          return $locale;     }     add_filter('locale','wpsx_redefine_locale',10);     ?>      So the little part that isn't working is the `has_term()` test. My impression is that the locale filter is running at an early step in the loading sequence, when the post content isn't retrieved yet, and therefore conditional tests like `is_single()` or `has_term()` won't return anything. Can I force the post content to load earlier? Can I delay the locale filter? I'm unable to figure out a solution for this. On the wp-hackers mailing list, a suggestion was to run `global $post;` but this didn't help. * * * **Update:** following the suggestion by david.binda, I found a workaround, dropping the taxonomy, and using the post slug as a trigger:               function wpsx89972_redefine_locale($locale) {         $wpsx_url = $_SERVER['REQUEST_URI'];         $wpsx_url_lang = substr($wpsx_url, -4); // test for the last 4 chars:         if ( $wpsx_url_lang == "-fr/") {             $locale = 'fr_FR';         } else if ( $wpsx_url_lang == "-en/") {              $locale = 'en_US';         } else { // fallback to default             $locale = 'de_DE';          }         return $locale;     }     add_filter('locale','wpsx89972_redefine_locale',10);      This requires the user to rewrite the post slugs, such as "my-post-title-fr" for French, "my-post-title-en" for English, etc. A bit less user-friendly than using language tickboxes, but it keeps the code simple and just works. So now I have a functional multi-language plugin, in only 13 lines of code :) Still, I will leave this question open for a couple days, to see if anyone comes up with a solution that would make use of the taxonomy...


title: Check for the existence of custom field

text: I am using the Advanced Custom Fields plugin, and I want to do a query to show all posts where a "date" field is before today and where another custom field (a report) has a value. For now I have this, but I am always getting all past events.                      'post_type' => 'activiteit',        'meta_key' => 'activiteit_datum',        'post_status' => 'publish',        'orderby' => 'meta_value',        'order' => 'DESC',        'meta_query' => array(           'relation' => 'AND',           array( 'key' => 'activiteit_verslag','compare'=>'EXISTS'),           array( 'key' => 'activiteit_datum', 'compare' => '<', 'value' => $fullDate,'type' => 'DATE')             )     );          $pastActivities=query_posts($arg);


title: Is the object cached?

text: I have a function to instantiate a class to provide var access to other functions.               function my_data(){     global $post,$the_data;     $postid = get_the_ID();     $the_data = new MY_Class ( $postid );     return $the_data;     }      This function will be called by every post, and each post will call it many times whenever need a var from MY_Class. The data is saved in WordPress postmeta and retrived in My_Class. Does WP automatically cache the object, or should I find a way to cache it? How?


title: How to change the matches in add_rewrite_rule

text: One of the examples using `add_rewrite_rule` function in wordpress is               add_rewrite_rule('^nutrition/([^/]*)/([^/]*)/?','index.php?page_id=12&food=$matches[1]&variety=$matches[2]','top');      I can understand where matches[1] is and where matches[2] is, but is there any way to change these matches, something like:               add_rewrite_rule('^nutrition/([^/]*)/([^/]*)/?','index.php?page_id=12&food=' . f1($matches[1]) . '&variety=' . f2($matches[2]),'top');      Where `f1` is a function of `matches[1]` and `f2` is a function of `matches[2]` Thank you very much. Edit 1: This is a very general question with the objective to understand wordpress add_rewrite rule. One example of f1 and f2 function is               function f1($string) {     if (strpos($string, '/america/')) {$string .= '-1';}     esleif (strpos($string, '/england/')) {$string .= '-2';}     return $string;     }      f2 was a similar function to f1.


title: How can I customize the search results in Bones theme?

text: In a site that uses Bones theme, I am trying to localize the search results page and would like to replace the "read more" text with something else. I tried editing the search.php but it is useless as the search.php seems to have a bug (It calls the_excerpt function with parameters while the function does not take any). I also tried the filter hook as described in the function reference but could not make it work, perhaps because I could not call the new function as required. I am quite new to wordpress and php, yes, but I feel there should be an easier way to replace that text. Are there any suggestions?


title: Get wp_get_attachment_url outside of loop

text: I need to get the featured image outside the loop. This is so that I can have a different full-screen background image for each page, set by the featured image. After doing some research I was able to get the post ID outside the loop. This is what I've got:               $page_object = get_queried_object();     $page_id     = get_queried_object_id();     $bkgdImg = wp_get_attachment_url( $page_id );     if (!empty($bkgdImg)) {         $backgroundImg = $bkgdImg;     }     else {         $defaultbackground = . get_template_directory_uri() . "/images/default-background.jpg";         $backgroundImg = $defaultBackground;     }          echo $backgroundImg;      Thanks!


title: wordpress is_main_query() breaks

text: After upgrading to 3.9 the function `is_main_query()` breaks down and doesn't works the way we want The following code               add_filter( 'pre_get_posts', 'my_get_posts' );     function my_get_posts( $query ) {     echo 'is_main_query: ' . ($query->is_main_query() ? 'y' : 'n');      }      prints 'y' at the top of the page and then keeps on printing 'n' for reasons best known to them.. The actual code which doesnt works               function hwl_home_pagesize( $query ) {          if ( is_home() && $query->is_main_query() ) {              $query->set( 'posts_per_page', 5 );         return;     }                }      add_action( 'pre_get_posts', 'hwl_home_pagesize', 1 );      it also breaks the navigation menu of my site


title: saving/reading custom field value does not work - no value gets POSTed

text: I am trying to add a custom field to all my posts and of course saving/reading the value. As a starting point I took the example from the Wordpress Codex and stripped it down to bare bones. I know it know has serious security flaws, I am just trying to understand it. The problem I am facing at the moment is that nothing is saved. After looking at what is POSTed when the post is saved, I noticed that the input's key & value is not present in the `$_POST` array at all. The property exists in the database, but without value of course. I also noticed that the variable `$post` passed to the `add_input` is empty, but I don't why (I guess this is the problem?). This is the code from my functions.php:               function add_custom_field() {         add_meta_box( 'my_field', 'My Field', 'add_input', 'post' );     }     add_action( 'add_meta_boxes', 'add_custom_field' );          function add_input( $post ) {         $value = get_post_meta( $post->ID, 'my_key', true );         echo '<input type="text" value="' . $value . '" id="my_id">';     }          function save( $post_id ) {             $mydata = sanitize_text_field( $_POST['my_id'] );         update_post_meta( $post->ID, 'my_key', $mydata );     }     add_action( 'save_post', 'save' );      Do you see any errors in the code above? Do you have any comments to my info I gave you? Why is nothing POSTed to the server?


title: Uploading non-media files?

text: I want to add files on WordPress that are non images, embedded video and the like. However when I try this using the upload media feature I get the following error. > "File type does not meet security guidelines." Is there a way to do this using WordPress?


title: How to intigrate multiple image uploader in a custom post type

text: ![enter image description here](http://i.stack.imgur.com/AaaZP.jpg) How can i add this type of field in the custom post type


title: WordPress use innodb by default?

text: I just created a new WordPress site in my server. Normally, WordPress uses MyISAM as the database type. But this time, it created all InnoDB tables! Is this normal? Has WordPress switched to InnoDB in the latest versions?


title: Display one latest post from multiple categories

text:
This should be very easy, however for some reason I can't find a working snippet anywhere on the web.. I basically need to display one latest post from 6 categories (can be changed to 7,8, etc etc) using one loop. this should be the output: (just a demonstration)

name of category 1
       The title and the permalink of the latest one post from category 1

name of category 2
       The title and the permalink of the latest one post from category 2

name of category 3
       The title and the permalink of the latest one post from category 3
      For now I am using 6 loops using simple query:               <?php query_posts('showposts=1&cat=8'); ?>      <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>         //Title, links etc comes her....     <?php endwhile; ?>      But that makes me create 6 loops and I would like to do it easier using **one loop** and a possibility to control how many and which catefories I want to display. Thanks A lot


title: Excerpts that don't truncate words

text: I know I can control the length of excerpts using a filter, however it sets the length globally. In my case I have different lengths of excerpts on three different pages. This is what I have now. I'd like to improve it so it doesn't truncate words.               $content_to_excerpt = strip_tags( strip_shortcodes( get_the_content() ) );     $pos = strpos($content_to_excerpt, ' ', 160);     if ($pos !== false) {      echo  "<p>" . substr($content_to_excerpt, 0, $pos) . "...</p>";     }


title: How to know if I am on 1st page

text: How can I find out if I am on the 1st page of my home page. I have my page setup like below where I want to display the 1st 2 posts taking up full width. then the rest 1/2. But I want this behaviour on the 1st page only, how can I do that? What condition do I use?


title: Please Check this '.htaccess' File

text: I just found my '.htaccess' file has the same lines of code repeated twice as below, maybe some plugins changed it, is it incorrect? Should I remove the repeated one? Thanks!!               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>     # END WordPress


title: Change CSS on a wordpress post

text: I want to change the Right-Hand style on the post http://sherridon.bluefrogclients.com/2010/12/15/wellington. Please let me know how to achieve this. Thanks. Sunil.


title: Am I not understanding plugins?

text: So I am trying to make it so that you can load a class from a child theme, theme or plugin using the following:               class AisisCore_Loader_AutoLoader{              protected static $_instance;              protected static $_directories;              public function get_instance(){             if(null == self::$_instance){                 self::$_instance = new self();             }                  self::$_directories = array(                 get_template_directory(),                 get_stylesheet_directory(),                 plugin_dir_path(__FILE__),             );                  return self::$_instance;         }              public function reset_instance(){             self::$_instance = null;         }              public function register_auto_loader(){             spl_autoload_register(array($this, 'load_class'));         }              public function load_class($class){             $path = str_replace('_', '/', $class);             foreach(self::$_directories as $directories){                 if(file_exists($directories . '/' . $path . '.php')){                     require_once($directories . '/' . $path . '.php');                 }             }         }        }      But I don't think I am understanding how the `plugin_dir_path` function is working. the problem is that, once this class is instantiated, no class can be loaded in the plugin's directory. that is `/plugin/myplugin/` How ever if I have a theme using the framework I am developing, and the theme is activated, and I instantiate this class in the plugin's main php file via:               //require_once(plugin_dir_path(__FILE__) . 'AisisCore/Loader/AutoLoader.php');     require_once(get_template_directory() . '/AisisCore/Loader/AutoLoader.php');          // Setup the autoloader.     $auto_loader = AisisCore_Loader_AutoLoader::get_instance();     $auto_loader->register_auto_loader();          $obj = new AisisCore_Http_Http();      Then everything works, it sees the AisisCore_Http_http class and and so on, but if I do:               require_once(plugin_dir_path(__FILE__) . 'AisisCore/Loader/AutoLoader.php');     //require_once(get_template_directory() . '/AisisCore/Loader/AutoLoader.php');          // Setup the autoloader.     $auto_loader = AisisCore_Loader_AutoLoader::get_instance();     $auto_loader->register_auto_loader();          $obj = new AisisCore_Http_Http();      it freaks out and cannot find the class. Ideas?


title: Any way to change the actual filename of an image from media manager?

text: The default WP media manager does not appear to offer the ability to change an image's filename. Are there any plugins available that allow this functionality?


title: wp-admin dashboard redirects to homepage

text: When going to /wp-admin on the website I am working on, it simply goes to the homepage. I then tried going to /wp-login.php and the login screen shows up, but once I login, the url in the address bar says wp-admin, but it still directed me to the homepage. I have indeed gone through the database and changed the siteurl, and I've tried numerous fixes that I've found online, but to no avail. Something odd, though, is that I can access any pages within /wp-admin except for the index. I can go to /wp-admin/edit.php or to /wp-admin/options- general.php, etc... but the moment I click on Dashboard or Dashboard > Home, then I get kicked out of the dashboard and it goes to the homepage, but the url in the address bar still says /wp-admin/index.php ... so, I am at a loss here. Anyone know what the issue could be?


title: How to make featured image thumbnails on index page load smoother?

text: I'm using a theme called Hatch Pro, which is a gallery based theme and the index page displays the posts using the featured image. You can see it here. On slower browser environments, the images sort of load in a jumpy manner. In this situation, I'd like them to load with a smoother transition (see example) or preload, so they all are ensured to appear at the same time. The theme author mentioned Lazy Load, but I'm not sure how I would implement that and would welcome any direction. I don't necessarily need them all to load at the same time (as the list of posts will continue to grow), but at least the images being viewed on the screen at the time of loading. I'm comfortable with CSS, but very novice with PHP or other heavier coding.


title: How do I serve fully cached full HTML on cloudfront

text: I am using cloud front but want it to serve not just images and CSS but full static HTML pages that are cached locally. I am using wp super cache ... I assume it is caching the full HTML for posts and pages. But I am thinking it would be better to have as much of the site in Cloudfront. I am currently using origin pull, but again it looks like HTML pages as just cached locally. My site doesn't change much it is mostly interviews updated every couple of weeks.


title: Wordpress display image link in shortcode

text: I have a shortcode that display an image when you use the image url inside it.               function image_code($atts, $content = null) {         return '';     }     add_shortcode('img', 'image_code');      So when I use the code like this:               [img]https://www.google.com.br/images/srpr/logo3w.png[/img]      it display only the image like this:(in the css I have set the .user-imgs to max-width 600px)                     But I want to display a link to the full image, like this:                     How I can retrieve the image url used in shortcode and use it as a link in to the original image?


title: Twitter feed - Failed to open stream

text: This works, however I keep getting a failed to open stream every so many random refreshes/page views. I've also tried this code on two different hosts with the same results. I've also tried using cURL with the same results. It keeps showing an error on the file_get_contents. Is there a conflict with wordpress and file_get_contents?               function get_tweets($twitter_username, $tweet_count) {     if(($twitter_info = file_get_contents('https://api.twitter.com/1/users/show.json?screen_name=' . $twitter_username)) === FALSE) {         return false;     }     $twitter = array();//store all info in this array     if(($profile_info = @json_decode($twitter_info, true)) === FALSE) {         return false;     }     $twitter['name'] = $profile_info['name'];          $tweets = array();          if(($tweets_json = file_get_contents('https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name='.$twitter_username.'&count='.$tweet_count))) {         if(($all_tweets = @json_decode($tweets_json, true)) === FALSE) {             return false;         }         foreach($all_tweets as $tw) {             $tweets[] = array('tweet'=>make_clickable_urls($tw['text']), 'created_at'=> 'about '. time_since(strtotime($tw['created_at'])) . ' ago', 'profile_image_url'=>$twitter['profile_image_url']);         }     }     else {         return false;     }     $twitter['tweets'] = $tweets;     return $twitter;     }


title: Changing wp login url without .htaccess

text: How to change wordpress login url without using .htaccess, should be a manual process, so `example.com/login` will not redirect to `example.com/wp- login.php` so `example.com/login` will be the login page?


title: update image path with words starting uppercase to lowercase chars

text: I have to convert the image path to lowercase characters inside wp_posts table. Right now, I have inside my posts this:               <img class="alignleft" title="my image title" alt="my image alt" src="http://www.mydomain.com/wp-content/uploads/2012/09/My-Image-Lowercase-First-Char.jpg" width="75" height="75" />      And I need to update those uppercase chars in the image path to lowercase chars like this: **my-image-lowercase-first-char.jpg**. Is it possible to do it via mysql in phpmyadmin?


title: Buddypress + Memberpress

text: I am looking to build a wordpress site using both BuddyPress and MemberPress. I know that these plugins have some conflicting areas. Has anyone ever used these plugins together? If so do the two plugins synchronize well? If not what are the things that I have to modify to allow the two to work together?


title: Menu item not created on theme activation

text: On theme activation the following code doesn't create my menu with the 'New Page' item, the menu is created and the location is assigned to 'submenu' but no menu item of my newly created page? What am I missing?               <?php     if (isset($_GET['activated']) && is_admin()){         $new_page_title = 'New Page';         $new_page_slug = '/new-page/';         $new_page_content = 'This is the page content';         $new_page_template = 'page-job-list.php'; //ex. template-custom.php. Leave blank if you don't want a custom page template.         //don't change the code bellow, unless you know what you're doing         $page_check = get_page_by_title($new_page_title);         $new_page = array(                 'post_type' => 'page',                 'post_title' => $new_page_title,                 'post_content' => $new_page_content,             'post_status' => 'publish',             'post_author' => 1,     );     if(!isset($page_check->ID)){             $new_page_id = wp_insert_post($new_page);             if(!empty($new_page_template)){                     update_post_meta($new_page_id, '_wp_page_template', $new_page_template);             }     }          // Check if the menu exists     $menu_name = 'AnotherMenu';     $menu_exists = wp_get_nav_menu_object( $menu_name );          // If it doesn't exist, let's create it.     if( !$menu_exists){         $menu_id = wp_create_nav_menu($menu_name);              wp_update_nav_menu_item($menu_id, $new_page_id, array(             'menu-item-title' =>  __($new_page_title),             'menu-item-url' => home_url( $new_page_slug ),              'menu-item-status' => 'publish'));     }          $menulocation = 'submenu';          if(!has_nav_menu($menulocation) ){         $locations = get_theme_mod('nav_menu_locations');         $locations[$menulocation] = $menu_id;  //$foo is term_id of menu         set_theme_mod('nav_menu_locations', $locations);     }     }


title: Shortcode not working in custom post types

text: I have created a shortcode and placed it in my functions.php and registered it with:               add_shortcode('featured-attribution', 'gteh_author_shortcode');      It works fine on posts and pages. I created a custom post type, and when I use the shortcode in the content, it just displays the shortcode rather than the function. I am using `the_content()` to display the content so not sure why it is not working. In fact, the custom post type is just using `single.php` so not sure why it works on single posts, but not single custom post type pages... Does anyone have any suggestions?


title: query custom post type by date

text:
I created a custom post type envent. I d like to filter out post in the futere. I did use the advanced custom fields plugin to make a date picker. I used following code, but somehow id does not filter out the future post.               <?php $events = new WP_Query(                 array(         'post_not_in'    => array($donotrepeat),         'post_type'       => 'chuchi_event',         'meta_key'        => 'event_datum',         'orderby'        => 'meta_value',         'order'           => 'dsc',         'meta_query'  => array(                            'key'     => 'event_datum',                     'value'   => date("Ymd"),                     'compare' => '<=',                             'type'    => 'DATE'                          )          )); ?>              <?php while($events->have_posts()) : $events->the_post(); ?>                           <?php $date = date_create(''.get_field('event_datum').''); ?>
<?php echo date_format($date,'l d.m.Y'); ?>
                                 <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute();                                  ?>" >                     <?php endif; ?>


title: Incorrect url for sharing blog on linkedin

text: I have a self-hosted Wordpress blog with Jetpack installed. My Wordpress URL structure is > http://mydomain.com/archives/%postname%. Using the Jetpack's Publicize feature, I connected my blog to my LinkedIn profile. New posts now automatically appear on LinkedIn, however, the post's URL appearing on LinkedIn inherits the following structure: > http://mydomain.com/2013/06/24/%postname% which of course gives a 404 error. Any suggestions on how to correct this problem?


title: unregister a sidebar widget

text: The codex says it is depreciated. As a long time plugin user, I know how annoying it is when plugins don't clean up after themselves, is it's deprecation indication that it is necessary?


title: Create a page in a plugin , like woocommerce

text: I want create a plugin with custom posts. Which post will be shown in the single page from the plugin, just like woocommerce single products are shown. How can I do it. I saw it in many plugins as one template folder which override theme single page.


title: Sticky post for each category on category pages

text: I think the title is self explanitory. I would like to show category.php a post I set as sticky post for that category.   Do you know a good plugin or a code to do this?   Thanks,   Sarit


title: Carousel Hover Image

text:
I a using an image carousel to display some pictures on my website. The carousel I am using is called: Jcarousellite (http://www.gmarwaha.com/jquery/jcarousellite/). I have the carousel setup, styled, and configured...but am having trouble getting through the last little bit of the code to work. The code I am using to get the images:               <?php query_posts( 'category_name=photos&posts_per_page=-1' ); ?>         <?php if ( have_posts() ) { ?>             <button class="prev"></button>             <button class="next"></button>

                     <?php while ( have_posts() ) : the_post(); ?>
<?php the_post_thumbnail("carousel-thumbnails"); ?>
                     <?php endwhile; ?>

         <?php } else { ?>
<?php _e("Sorry, no pictures have been posted :("); ?>
         <?php } ?>     <?php wp_reset_query(); ?>      The javascript function:                     I have another image that I would like to show when a user hovers over the thumbnail:               <?php the_post_thumbnail("carousel-full"); ?>      Initially, I tried to add a span to the end of the link, to make it work...then I could use CSS to position the image where I want...but because the jquery puts a `overflow:hidden` property on the photo container my image gets cut off. As I was looking around, a suggestion was to make the hover appear outside your `overflow:hidden` div, but how do I do that? Thanks,   Josh


title: Google maps live search and data storage in wp

text: I am developing a website - sellers database. Every seller posts locations - shops he has visited in the past so the chance of another seller visiting the same shop is being eliminated. I have built a custom meta box where the user inputs the address so every location is being displayed with a google map inside each post. The problem here is that some users type the address incorrectly as a result google maps cannot locate and display them. Is there any method that I can use live search when typing an address in the meta box like search in google maps works?


title: AJAX doesn't pass variables to the php function in the plugin

text: I'm creating a plugin that at a certain point has to use AJAX to pass information to php depending on the events fired by front end user on the different page. The event itself is when the user clicks on one of the links. my ajax code is :                 $.ajax({                cache: false,              async:false,              timeout: 8000,              type: 'POST',              data: {action: 'getpostfilter', year : year, month: month, category: category},              url: ajax_object_1.ajaxurl,              success: function(data) {alert( "Handler for .click() called." + category+year+month );},              error: function() {}              });      I have created action hooks and the function that ajax calls:               function get_post_filter_by_date_and_category(){               global $wpdb, $information;               $information['category']= $_POST['category'];          $information['year']= $_POST['year'];          $information['month']= $_POST['month'];             print_r($information);              return $information;              die();     }              add_action('wp_ajax_getpostfilter','get_post_filter_by_date_and_category');         add_action( 'wp_ajax_nopriv_getpostfilter','get_post_filter_by_date_and_category');      Where `global $information` was created in the beginning of the plugin source code is used to store the variables that are passed on to the php. I call the function that supposed to get the post information on the separate page as follows:               get_post_filter_by_date_and_category();          if(isset($information)){                  echo('<h1> ELSE</h1>');                  print_r($information);      I didn't forget to properly enqueue the scripts and I also use wp_localize_script to pass `admin-ajax.php` as URL to ajax call. I have absolutely no clue what is going wrong. **I have checked the following using different print and alert functions** :   1. The jQuery I am using is correct and creates all the variables and passes them to AJAX as intended.   2. AJAX gets all the info ( checked through `alert()` ) and doesn't throw any errors   3. PHP code runs without any 'blunt' errors . `print_r()` is used to check the contents of `$information` and every time it returns this :Array ( [category] => [year] => [month] => ) I am pretty sure this is not because I am not doing the extra security measures (nonce and etc.) Please help.


title: Custom post admin filtering by post meta (the date)

text: I've created a custom post type for events that uses a custom field to retrieve the date for the event. It works ok and I'm able to filter the displayed results using `meta_compare` to compare the date value to the current date. So far so good. I can also filter the admin end to display either future or past events (or both, by removing the `meta compare`) via a `pre get posts` filter. What I want to do is to create an admin page that will display the past events. I've created the page (and menu item) with the following code:               add_action('admin_menu', 'add_concerts_page');     function add_concerts_page() {         add_submenu_page('edit.php?post_type=concerts', 'Concerts Archive', 'Concerts Archive', 'manage_options', 'concerts-archive', 'my_archive_function' );     }          function my_archive_function() {}      But I don't know how to write the function!! I can write a regular loop and filter the results, as I would do on the front-end, but all I need to do is to show the same information as the normal admin page, but showing events that have since passed. This is how I filter the custom posts edit screen to show only future events:               function concerts_pre_get_posts($query) {       if (is_admin()) {         if (isset($query->query_vars['post_type'])) {           if ($query->query_vars['post_type'] == 'concerts') {               $query->set('meta_key', 'date_value');               $query->set('orderby', 'meta_value');               $query->set('order', 'ASC');         $query->set('meta_compare', '>=');               $query->set('meta_value', time());                }         }       }     }     add_filter('pre_get_posts' , 'concerts_pre_get_posts');      I don't really need to create a separate archive page for past events, just a link to toggle the query from past to future events on this page would be groovy, but I haven't a clue how to go about doing this! All help greatly appreciated!


title: WordPress echoing content in seemingly random place

text:
I have been building a series of theme pages. On one page a users messages (post_type=messages) come in in a tab on the page. The content is displayed in place as is the title etc.... The content is shown again after the closing on the page. There is no that would let that happen in the theme. Furthermore the post_type=bookings that show up in another tab echo the content correctly. But within that loop is another loop that shows the post_type=items showing the configurations of each booking. It then echoes the last item as another booking. What the hell is going on. Any ideas? Marvellous \---- EDIT --- The error is due to loops within loops. So we need to use the get_posts function instead of query_posts. I have implemented it like this.               <?php $congigs = get_posts('post_type=items&author='.$current_user->ID.'&tag='.$bkpostid.'&numberposts=-1');                         foreach($congigs as $posts) :  setup_postdata($posts); ?>
<?php the_title(); ?>
     <?php endforeach; ?>      There should be 8 of these posts to get and it does get them, however `<? the title ?>` is showing 8 copies of the main title of the entire page, not the item post title. Any ideas. Thanks,


title: Get Permalink without domain (i.e. get relative permalink)

text: This is the code I am using:               <?php echo str_replace( home_url(), '', get_permalink($post->ID) ); ?>      What it does is output the permalink as a relative URL i.e. only the slug. For instance, if the permalink is `http://example.com/2012/01/post-title/`, the relative URL output by the code would look like `/2012/01/post-title/`. **Problem:** All Posts and Pages show the right permalink, which is great. But all other pages (including Home, Search and Archives) show the relative URL of the first post and not that of the respective pages. Any idea why? What am I doing wrong here? **Reference:** Get page permalink without wpurl * * * **EDIT:** Here's what else I've tried: **In functions.php**               function get_relative_permalink( $url ) {         $url = get_permalink();         return str_replace( home_url(), "", $url );     }      **In header.php**               <link rel="alternate" hreflang="en-IN" href="http://in.example.com/<?php echo get_relative_permalink(); ?>" />      Same problem with this as well. But this one shows a not-so-informative error too.


title: featured image problem with custom post type

text: I created a new custom post type based on the code provided by the wordpress codex. But when I try to set a featured image it returns and shows -1 in the featured image box instead of the images. I checked in the function that sets the featured image and it looks like it doesn't pass the check to see if I'm allowed to edit the post ( current_user_can('edit_post', $postID) ) However when I check somewhere in my plugin (I'm adding meta boxes in that particular page) with the same function it shows that I have the right to edit the page. Anyone an idea why it is causing a problem with the featured image?


title: WooCommerce Customize the archive-product page

text: How to modify the archive-product.php in Woocommerce to sho the results with a bigger thumb and in list view not in grid. There is a plugin for that but this is not working for me since I will use a shorcode after that which plug-in is not working with the shortcode.


title: Can't send mails using contact plugin

text: There are many contact form plugins available but none of them succeeds in sending mail even contact 7 form. Only the default contact form of Jetpack wordpress succeeds in sending the mail. But the problem is it only sends the mail when I use the email id which I used while signing for the wordpress, a gmail id. if i replace that gmail id with my website support email id in my user profile, even the jetpack coontact form fails. I want to use my website email id as it has auto-responder facility.