Improving a Stackoverflow "inspired" badge system to display badges in author page

I've been modifying a long abandoned plugin project that provides a Stackoverflow inspired badge system for Wordpress. I have upgraded some of its code so it functions with the new Wordpress version. Please view the plugin code here: http://pastebin.com/kCWWLPL2 The problem is that the original code did not provide a way to echo the badges the user have been awarded. Currently, there is a way of displaying the badges: `<?php rhb_list_badges() ?>` this function will list every single badge in the system. I want to modify the code so that by adding a function to the author.php page of Wordpress, **it will list the user's awarded badges**. However, my knowledge of PHP is very limited and I have hit a wall. I was told that this might work:               <?php     $user_id = get_current_user_id();     if ($user_id != 0) {       rhb_list_badges(array('user_ID' => $user_id));     }     ?>      But all it did was to list the all the badges and not _just_ the awarded ones for the user. Maybe something is missing in the above code? I am certain that there must be a way to accomplish this. Do you know how? **Update:** If we look in the original code, we can see that there is a filter already in place:               function rhb_get_badges( $filter = '' ) {                  global $wpdb;                  if ( empty($filter ) ) { $filter = array(); }                  // Select all rows by default             $sql = 'SELECT badge_id, name, description, type FROM ' . $wpdb->prefix . 'rh_badges b WHERE 1=1 ';                  // If a user ID was entered.             if ( array_key_exists('user_ID', $filter) ) {                          $user_ID = $filter['user_ID'];                          // Join the rh_user_badges table.                     $sql = 'SELECT b.badge_id, b.name, b.description, b.type                                     FROM ' . $wpdb->prefix . 'rh_badges b,                                             ' . $wpdb->prefix . 'rh_user_badges ub                                     WHERE b.badge_id = ub.badge_id                                     AND ub.user_id = ' . $user_ID;                  }                  // If a badge ID was entered.             if ( array_key_exists('badge_ID', $filter) ) {                          $badge_ID = $filter['badge_ID'];                          // Append a WHERE clause to the SQL.                     $sql .= " AND b.badge_id = $badge_ID";             }                  $badges = $wpdb->get_results( $sql );                  return $badges;     }          function rhb_list_badges( $filter = '' ) {                       if ( empty($filter ) ) { $filter = array(); }                  print '';                                  foreach (rhb_get_badges( $filter ) as $badge) {                                  print '

type )                                                     echo 'bgold';                                             elseif ( 'silver' == $badge->type )                                                     echo 'bsilver';                                             elseif ( 'bronze' == $badge->type )                                                     echo 'bbronze';                                                  print '">
                                                     ' . $badge->name . '
';                             }                             ;     }      How would I go about to use it?


Unset color set in Theme Customizer

I'm building a theme using the Theme Customizer and have a few options with color pickers. It seems as though once you set a color using the color picker, there's no way to clear/remove/ unset it, is that right? If you haven't saved your settings yet, you can hit the cancel button (though you'd lose all your other unsaved settings) -- but once it's saved, it's set in stone? Or am I missing something?


Delete custom fields when deleting posts

When I delete a bunch of posts their custom fields remain in the database, is there a way to remove them as well on deletion?


Sorting posts by custom field value

I am trying to sort posts by their custom field value, which is a date in this format: 9 August 2012, 7:18 am                       'orderby'  => 'meta_value',              'meta_key' => 'wprss_item_date',             'order' => 'DESC'      Do I need to do some conversion before that can work?


posts_nav_link() not displaying anything

I'm having difficulty getting posts_nav_link() to display anything. Below is my index.php template file, I'm using permalinks (`index.php/2011/08/26/sample-post/` format) and I've currently got my `Blog pages show at most` set to `-1`. Does anyone know why the links aren't working? **index.php**               <?php         get_header();         $args = array('posts_per_page' => 4,'paged' => get_query_var('page'));         $myquery = new WP_Query( $args );     ?>              <?php while ( $myquery->have_posts() ) : $myquery->the_post(); ?>
<?php the_title(); ?>
                  <?php the_content()?>              <?php endwhile ?>              <?php posts_nav_link() ?>              <?php wp_reset_postdata(); ?>          <?php get_footer(); ?>


Checkboxed term search

Anyone know if I can make a checkbox-list with all terms from a taxonomy, and search for the posts belonging to the checked terms? Listing categories in the checkboxes also would be a bonus!


How can I secure a WordPress blog using OpenID from a single provider?

We're about to launch an internal blog for the company I work at. Much of the blog will be available to the public, but certain posts will be for employees only. Our intranet/extranet has an OpenID endpoint which we would like to use to secure the private blog posts. There are many benefits to this – not least that people won't have to sign in with yet another username and password. Additionally, when someone new to the blog signs in with their OpenID, we don't want to have to require them to set up a local WordPress user account – we'd like that to be handled automatically. If a user doesn't exist with the OpenID specified, one should be created automatically. Incidentally, we've taken this route with other third party software that we've used in-house. In most cases, we've taken the OpenID consumer plugin that came with the software (a DotNetNuke-based learning system) and modified the login form so that, instead of presenting users with a URL input field for their OpenID, we present them with a button that simply says "Login with [Your Intranet]". So, in short, we'd like to:   * Allow the vast majority of users to use OpenID to sign in to WordPress   * Not require that those users already have a local WordPress user account   * Restrict the OpenIDs accepted to those from a single domain, either by hardcoding the endpoint used or by configuring a list of approved endpoint domains I've looked at the plugins available on WordPress.org and can't see any that offer this level of functionality 'out of the box', but would love to hear from people who could suggest anything, especially from anyone who's done this. Additionally, an idea of which plugin to use to base a new plugin on if we need to write this full functionality ourselves, would be great. Thanks. **Update: 4/2/13:** We've installed the WordPress OpenID plugin and will probably use this as our base. I'll continue evaluating.


How to set different settings for a mobile theme?

My desktop version of wordpress theme requires using a 'static' page as the start page as it has custom shortcodes etc. While this is good, when it comes to my mobile theme, sadly the 'static' page is being displayed and because its a different theme, the shortcodes are not being executed. Is there a way to tell a mobile theme to display 'blog posts' as the default page and not use a 'static page' as a starting page for the theme?


Archive template limiting to 4 entries?

I have a category called "javascript" and it's limiting my list to only 4 entries?               <?php get_header(); ?>

Javascript
         <?php if (have_posts()) : ?>         <?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
                    <?php endwhile; ?>                    <?php endif; ?>

          <?php get_footer(); ?>      The link to this page is:
<a href="<?php bloginfo('wpurl'); ?>/category/javascript">Javascript


Display grandchildren on child and grandchild pages using wp_list_pages

On hierarchal pages 3 levels deep, I would like to display the grandchildren on child and grandchild pages (but not on the parent page). What I have so far displays the grandchildren on the child page but I'm confused on how to keep them displayed on the grandchildren pages. How can I do this?                        <?php                 //display children's child pages                 $childrens_children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');                      if ( is_page() && $post->post_parent > 0 ) {                  ?>                 <aside id="child-child-pages" class="widget widget_child_child_pages">                     <ul>                          <?php echo $childrens_children; ?>                     </ul>                 </aside>             <?php } ?>       **The idea** Parent : show nothing Child : show grandchildren of parent Grandchild : show grandchildren of parent


WordPress Frontend Post Form (Bootstrap Modal) Not Creating Post

I have a form in a separate PHP file in the theme directory and it's being included in the sidebar of the main page template. The form is inside a Boostrap modal. I've been trying to use this code to be able to allow the users to submit new posts using the form but this code doesn't insert anything:               <?php      if ( isset( $_POST['submitted'] ) && isset( $_POST['post_nonce_field'] ) && wp_verify_nonce( $_POST['post_nonce_field'], 'post_nonce' ) ) {          $subjectError = '';          if ( trim($_POST['subject'] ) === '' ) {       $subjectError = "Please enter the subject.";       $error = true;     }          $post_information = array(       'post_title' => wp_strip_all_tags( $_POST['subject'] ),       'post_content' => $_POST['postContent'],       'post_type' => 'post',       'post_status' => 'pending'     );          $post_id = wp_insert_post( $post_information );     if ( $post_id ) {       wp_redirect("/home");       exit;     }       }     ?>

Submit content

       <form class="form" id="submit-content-form" method="POST" action="<?php the_permalink(); ?>">         <?php if ( $subjectError != '' ) { ?>             <?php echo $subjectError; ?>

         <?php } ?>
             Subject
                 <input type="text" name="subject" id="subject" class="required" value="<?php if ( isset( $_POST['subject'] ) ) echo $_POST['subject']; ?>" />

             Content
                 <textarea name="postContent" id="postContent" cols="30" rows="10" class="required">               <?php if ( isset( $_POST['postContent'] ) ) { if ( function_exists( 'stripslashes' ) ) { echo stripslashes( $_POST['postContent'] ); } else { echo $_POST['postContent']; } } ?>                </textarea>

             Upload file
                 <input type="file" value="Choose file">

       </form>

       <input type="hidden" name="submitted" id="submitted" value="true" />       <?php wp_nonce_field( 'post_nonce', 'post_nonce_field' ); ?>       Submit
      Kindly help! I'm completely lost here. I've been searching everywhere on the web but can't find a solution for this. What am I doing wrong here? Thanks! **EDIT:** Here is the working code. It now creates the post but validation doesn't work which allowed empty posts to be created until I added one more check to make sure the subject field is not empty when the form is being submitted. Now post is being created and the extra check prevents blank posts from being added. Validation works only if I add an elseif block to separately check which field is still empty upon form submission.               <?php     if ( isset( $_POST['submitted'] ) && !empty ( $_POST['subject'] ) && isset( $_POST['post_nonce_field'] ) && wp_verify_nonce( $_POST['post_nonce_field'], 'post_nonce' ) ) {          $subjectError = '';          if ( trim($_POST['subject'] ) === '' ) {       $subjectError = "Please enter the subject.";       $error = true;     }          $post_information = array(       'post_title' => wp_strip_all_tags( $_POST['subject'] ),       'post_content' => $_POST['postContent'],       'post_type' => 'post',       'post_status' => 'pending'     );          $post_id = wp_insert_post( $post_information );     if ( $post_id ) {       wp_redirect("/home");       exit;     }     } elseif ( isset( $_POST['submitted'] ) && empty ( $_POST['subject'] ) ) {     $subjectError = "Please enter the subject.";     $error = true;     }     ?>

Submit content

               <form class="form" id="submit-content-form" method="POST" action="">
                     Subject
                         <input type="text" name="subject" id="subject" class="required" value="<?php if ( isset( $_POST['subject'] ) ) echo $_POST['subject']; ?>" />

                     Content                     <?php if ( $subjectError != '' ) { ?>                     <?php echo $subjectError; ?>

                     <?php } ?>
                         <textarea name="postContent" id="postContent" cols="30" rows="10" class="required">                       <?php if ( isset( $_POST['postContent'] ) ) { if ( function_exists( 'stripslashes' ) ) { echo stripslashes( $_POST['postContent'] ); } else { echo $_POST['postContent']; } } ?>                        </textarea>

                     Upload file
                         <input type="file" value="Choose file">                     <input type="hidden" name="submitted" id="submitted" value="submitted" />                     <?php wp_nonce_field( 'post_nonce', 'post_nonce_field' ); ?>

               </form>

               Submit


Adapting CSS Star Rater for Wordpress post voting

I am trying to adapt the code from Rogie's CSS Star Rater code to save the result into a Wordpress post. Most importantly, and the reason I'm not using a plugin, is that I only want to save scores from users and not show the results to anyone as it's for a competition website. Where would I start to create a function to handle this? I was looking at this post that was for a simple like option, but on its own the code didn't work for me. This post, which is a bit outdated, also seems helpful, but I wasn't sure how it would work in conjunction with the idea I want, which is to save ratings to a custom field in each Wordpress post. I'll update as I work through this, but hoping for some pointers along the way. CSS Star Rating HTML:                                                <input type="radio" name="rating" value="1">                   <input type="radio" name="rating" value="2">                   <input type="radio" name="rating" value="3">                   <input type="radio" name="rating" value="4">                   <input type="radio" name="rating" value="5">                       CSS Star Rating JS:                   $(':radio').change(       function(){         $('.choice').text( this.value + ' stars' );       }      )      **UPDATE:** I had some help from a friend and we're much closer, but it's still not quite working. The meta values aren't even being added to the post. Here's the code we've added to the functions:               add_action('wp_ajax_nopriv_post-like', 'post_like');     add_action('wp_ajax_post-like', 'post_like');          wp_enqueue_script('like_post', get_template_directory_uri().'/js/rating.js', array('jquery'), '1.0', true );     wp_localize_script('like_post', 'ajax_var', array(         'url' => admin_url('admin-ajax.php'),         'nonce' => wp_create_nonce('ajax-nonce')     ));          function post_like()     {         // Check for nonce security         $nonce = $_POST['nonce'];              if ( ! wp_verify_nonce( $nonce, 'ajax-nonce' ) )             die ( 'Busted!');              if(isset($_POST['post_like']))         {             // Retrieve user IP address             $ip = $_SERVER['REMOTE_ADDR'];             // $ip = long2ip(rand(0, "4294967295"));             $post_id = $_POST['post_id'];             $rating = $_POST['rating'];                  // Get voters'IPs for the current post             $meta_IP = get_post_meta($post_id, "voted_IP");             $voted_IP = $meta_IP[0];             if(!is_array($voted_IP)){                 $voted_IP = array();             }                  // Get votes count for the current post             $meta_count = get_post_meta($post_id, "votes_count", true);             $meta_rating = get_post_meta($post_id, "votes_rating", true);                  // Use has already voted ?             if(!hasAlreadyVoted($post_id)){                 $voted_IP[$ip] = time();                      // Save IP and increase votes count                 update_post_meta($post_id, "voted_IP", $voted_IP);                 update_post_meta($post_id, "votes_count", ++$meta_count);                 update_post_meta($post_id, "votes_rating", $meta_rating+$rating);                      // Display rating (ie jQuery return value)                 echo $meta_rating;             }else{                 echo "already";             }         }         exit;     }          function hasAlreadyVoted($post_id){         global $timebeforerevote;              // Retrieve post votes IPs         $meta_IP = get_post_meta($post_id, "voted_IP");         $voted_IP = $meta_IP[0];              if(!is_array($voted_IP))             $voted_IP = array();              // Retrieve current user IP         $ip = $_SERVER['REMOTE_ADDR'];         // $ip = long2ip(rand(0, "4294967295"));              // If user has already voted         if(in_array($ip, array_keys($voted_IP)))         {             $time = $voted_IP[$ip];             $now = time();                  // Compare between current time and vote time             if(round(($now - $time) / 20160) > $timebeforerevote)                 return false;                  return true;         }              return false;     }          function getPostRatingLink($post_id) {               $output = '
';              if (hasAlreadyVoted($post_id)) {             $output .= ' Your vote has been recorded.';         }else{             $output .= '                                   <input type="radio" name="rating" value="1">                                   <input type="radio" name="rating" value="2">                                   <input type="radio" name="rating" value="3">                                   <input type="radio" name="rating" value="4">                                   <input type="radio" name="rating" value="5">                                   <input type="hidden" name="post_id" value="'.$post_id.'" id="post_id" data-post_id="'.$post_id.'">                                 ';             $output .= '
';         }              return $output;     }               /*************************************************************************/          add_filter('manage_edit-post_columns', 'add_new_columns');          /**      * Add new columns to the post table      *      * @param Array $columns - Current columns on the list post      */     function add_new_columns( $columns ) {         $column_meta = array('meta' => 'Total Rating' );         $columns = array_slice( $columns, 0, 2, true ) + $column_meta + array_slice( $columns, 2, NULL, true );         return $columns;     }          // Add action to the manage post column to display the data     add_action( 'manage_posts_custom_column' , 'custom_columns' );          // Register the column as sortable     function register_sortable_columns( $columns ) {         $columns['meta'] = 'Custom Column';              return $columns;     }     add_filter( 'manage_edit-post_sortable_columns', 'register_sortable_columns' );          /**      * Display data in new columns      *      * @param  $column Current column      *      * @return Data for the column      */     function custom_columns( $column ) {         global $post;              switch ( $column ) {             case 'meta':                 $metaData = get_post_meta( $post->ID, 'votes_rating', true );                 echo ($metaData == null) ? 0 : $metaData ;             break;         }     }      And here's the JS:               $(document).ready(function() {              $('.star-rating input').click(function(){                    // Retrieve post ID from data attribute             var post_id = $(this).siblings('input[type="hidden"]').data('post_id');             var rating = $(this).val();                  // Ajax call             $.ajax({                 type: "post",                 url: ajax_var.url,                 data: "action=post-like&nonce="+ajax_var.nonce+"&post_like=&rating="+rating+"&post_id="+post_id,                 success: function(totalRating){                     // If vote successful                     if(totalRating != "already")                     {                         $('.rating .voted').removeClass('dn').find('b').text(rating);                         $('.star-rating').addClass('dn');                         // $(this).siblings('.count').text('Votes: '+count);                     }                 }             });                  return false;         })     })


How to Mass Delete Images from Media Library

I need your help. I am trying to mass delete attachments from a custom post type ('book') using a sql query. I found this snippet on the wordpress form: Wordpress.org I tested it on my local computer, and it removes all of the attachments from my media library. Now, I would like to have your help in setting the query so that it will only target attachments(featured image and thumbnail) from my custom post type 'book'. Thanks


Dynamic logo/banner depending on affiliate link

i am building an affiliate site using woo commerce and wp affiliates. There will be a network of 20-30 affiliate sites linking back to main site. I need to display the logo/banner of the referring site on the main site. So if a user is referred from Widget Maker 1 website to the main site i need to display Widget Maker 1 logo or banner at the top. Same for Widget Maker 2, if a different user is referred from widget maker 2 website to the main site i need to display widget maker 2 logo or banner. Since using query strings in the url for affiliate links this seems like it would be pretty trivial to do but i am at a lose of where to start. Anyone have any experience doing this sort of thing?


Changing attachment page Permalink

How can i change the attachment page permalinks to               http://domain.com/photos/%attachment_id%/%postname%/%attachmentname%      currently my permalinks set to Custom Structure http://domain.com/%custom_taxonomy%/%post_id%/%postname%/ Created a Custom Taxonomy and Translated Custom Taxonomy Tag using this method               add_filter('post_link', 'sections_permalink', 10, 3);     add_filter('post_type_link', 'sections_permalink', 10, 3);          function sections_permalink($permalink, $post_id, $leavename) {         if (strpos($permalink, '%sections%') === FALSE) return $permalink;              // Get post         $post = get_post($post_id);         if (!$post) return $permalink;              // Get taxonomy terms         $terms = wp_get_object_terms($post->ID, 'sections');            if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;         else $taxonomy_slug = 'projects';              return str_replace('%sections%', $taxonomy_slug, $permalink);     }        is this this right way to do? and my attachment page is               http://domain.com/%custom_taxonomy%/%post_id%/%postname%/%attachmentname%


Magic Fields gives error File ___ doesn't exist?

I'm using WordPress 3.4 with plugin Magic Fields 2.0. I've created a write panel with an image field called 'icon' as a (media upload) type, and icon is not inside a group. However, whenever I try to call the `get_image()` functions front end functions, this fails to pull up the images. Here's my code:                <?php echo get_image( 'icon', 1, 1, 0, $page->ID ); ?>      `$page` is a page object that I've retrieved outside the loop. Here's the output:               File “http://domain.com/wp-content/uploads/2012/07/tommy-icon1.jpg” doesn’t exist?       When I check the server, that file does exist! I copy the address into my address bar, and the image loads in the browser. I'm developing this on my local xampp host, using a dns record that's only in my hosts file. So, I'm wondering if that is causing the issue? Perhaps, since that file doesn't exist at that url remotely, that is causing a file_exists check to fail somewhere in Magic Fields. Any advice to access this image would be greatly appreciated!


How can I add Expire headers to images?

I'm trying to speed up my site a bit. How can I add Expire headers to images I upload? Must this be done with Apache configuration, or is there a setting or plugin to do the job?


404 Page not found

I have created a new template page and added to the theme's directory where the other pages, archive, comment, author and the rest of the pages are. When trying to go to it via the browser http://mysite.com/newpage.php, I get a 404 page not found error. What is the proper way to add this page so it is visible and as part of the theme instead of adding it to the root?


How to remove the 'Archives' title and list and the 'Meta' title

How can I remove the 'Archives widget' and the 'Meta widget' from the pages on my blog -- for example, on this page: http://richardclunan.com/ ? And how can I remove those from every page but keep them on the blog ?


changing function wp_register

how can i change function in general-template.php without affecting this core file on this:               if ( ! is_user_logged_in() ) {         if ( get_option('users_can_register') )             $link = $before . '' . __('Register') . '' . $after;      to this:               if ( ! is_user_logged_in() ) {         if ( get_option('users_can_register') )             $link = $before . '' . __('Profile Page') . '' . $after;


Check if home.php and set home.php as page_on_front

I want to include a custom inline js on home page only. I havent set home page from reading section. I am using home.php file.               function print_my_inline_script() {            if (is_home() && wp_script_is( 'jquery', 'done' ) ) {           ?>           <script type="text/javascript">             jQuery(document).ready(function($){                  $('.carousel').carousel();                 $('.item').hover(function(e){                     $(this).find('.summary').stop().fadeTo('fast',1);                  },function(){                     $(this).find('.summary').stop().fadeOut('fast');                  });             });           </script>           <?php       }     }     add_action( 'wp_footer', 'print_my_inline_script' );       This doesnt work. `is_front_page()` doesnt work either. I have already done `<?php wp_reset_query(); ?>` after loop. I have one more question. I know home.page overrides `index.php` and works as home page. But I dont want my users to get confused when they change options in `reading` section. I have found this,               update_option( 'page_on_front', $post->ID );     update_option( 'show_on_front', 'page' );      but it needs an ID and I dont have any page, so I dont have any id. So, I need a way to set check if user is in `home.php` (home page) and since using home.php overrides the reading section options, any workarounds for that ?


How do I create a widget to embed the code for a sign up form, so that the sign up form appears on every page?

I'm going to follow the instructions here: http://kb.mailchimp.com/article/how-can-i-add-my-signup-form-on-my-website to create a sign up form on my website. I think I need to embed the code that I generate when I follow those instructions in to a widget. How do I create a widget to embed the code in to? And once I've created a widget and added the code for the sign up form, will the sign up form appear on every page on my site? Including blog posts? If not, how can I make it appear on every page? And how do I make it also appear on every blog post? I'm using a modified Twenty Eleven Child theme on this site: http://richardclunan.com/


How do I make the category template display full posts instead of partial posts?

I'm using Wordpress 3.0.1 with the Twenty Ten theme. I'm trying to change the way the posts in the Category view are displayed (i.e. by going to a url like mywebsite.com/category/mycategory). Currently the posts in the Category view just show the first part of a post, but I'd like to change that so it shows the whole thing. In the Category Template (category.php) file, there are a few lines of code that look like they are responsible for generating the category data:               /* Run the loop for the category page to output the posts.      * If you want to overload this in a child theme then include a file      * called loop-category.php and that will be used instead.      */     get_template_part( 'loop', 'category' );     ?>      Since the comments mention setting up a child theme, I went ahead and followed these instructions (via this answer) to set up a child theme so I could add my custom functionality. I see from the comments that I'm supposed to create a file called loop- category.php with my custom implementation, but I don't know what code I need to put in that file. What do I need to add to loop-category.php to get Category views to show up with full blog posts? _NOTE: While I've been using Wordpress for quite a while, this is my first dive into theme customization. Any help would be much appreciated._


Custom Blog Post Page

I found this example here of creating a custom blog post page: http://www.wpbeginner.com/wp-themes/how-to-create-a-custom-homepage-in- wordpress/ 1) I created a blog page under Pages > Add New 2) Under Template, I select "Blog" 3) Note that I created a blog.php file in my custom theme that has this content:               <?php     /*     Template Name: Blog     */     ?>     <?php         echo "Hello World";         $temp = $wp_query;         $wp_query= null;         $wp_query = new WP_Query();         $wp_query->query('posts_per_page=5'.'&paged='.$paged);         while ($wp_query->have_posts()) : $wp_query->the_post();     ?>      4) In settings > reading, under "Front page displays", I set "Posts page:" to "Blog" Now I view my blog page in browser, it just renders all my posts. But it doesnt echo the "Hello World" and if I remove the code from blog.php, it has no effect! It still just renders all the posts. And then I try to add a custom query:               <?php     /*     Template Name: Blog     */     ?>     <?php         global $wpdb;         $content = $wpdb->get_row(             $wpdb->prepare(                 "SELECT * FROM $wpdb->posts                  WHERE post_type = %s                  LIMIT 1                 ",                 'header_post'             )         );         echo $content->post_content;      ?>      And again it ignores this and just renders all the posts with post_type of post and a post_status of publish. Obviously, the code in my blog.php is being ignored. Why? This is what it currently looks like too (post date is missing, comment is missing): http://i49.tinypic.com/2caq0g.jpg I made changes to the index.php in my theme:               <?php     $temp = $wp_query;     $wp_query= null;     $wp_query = new WP_Query();     $wp_query->query('posts_per_page=1'.'&paged='.$paged);     while ($wp_query->have_posts()) : $wp_query->the_post();     ?>      and still no effect


Bypassing a Form Options

here is the situation. I am using a plugin and although it is (half) works, I can't access the setting page. The plugin is to fetch thumbnail from Youtube and other video sites, but the problem is, I have to embed the video using a specific "Featured" box, for aesthetic reason. It works well if I just put the video inside the post, the "usual way". I've done some research and apparently the plugin accept custom field value (which can solve my problem) but I have to put the custom fields name in its setting page. For some reason, I can't access it and only get a blank page. I think it may be a plugin conflict but I've tried activate and deactivate the others and still no luck. I look at the code and found this part:               Custom Field (Optional: If your video is stored in a custom field, enter the name of that field here. Otherwise, leave this field blank.)	          <fieldset><legend class="screen-reader-text">Custom Field (Optional: If your video is stored in a custom field, enter the name of that field here. Otherwise, leave this field blank.)</legend>          <input name="video_thumbnails_custom_field" type="text" id="video_thumbnails_custom_field" value="<?php echo get_option( 'video_thumbnails_custom_field' ); ?>" />      and I believe this is where it uses the input from the form:               // Get the post or custom field to search             if ( $video_key = get_option( 'video_thumbnails_custom_field' ) ) {                 $markup = get_post_meta( $post_id, $video_key, true );             } else {                 $post_array = get_post( $post_id );                 $markup = $post_array->post_content;                 $markup = apply_filters( 'the_content', $markup );             }             $new_thumbnail = null;      My question is, how do I bypass and just hardcoded my custom field name? I've tried assigning the value directly to $video_key (so it is $video_key = $skyali_video >> the theme's video featured's value) and variations of putting the custom field's name ("skyali_video") but still no luck. Thanks in advance.


metaboxes disappear on saved pages

Ok I have a wierd issue with custom meta boxes that I am at a loss for. I am using this class               <?php     class ARIXWP_Meta {              private $meta     = null;         public $postid    = null;         private $template = null;              function __construct() {             add_action('save_post',array(&$this, 'save_meta_data'));         }              function __destruct() {             $this->meta     = null;             $this->postid   = null;             $this->template = null;         }              public function init_meta() {             add_action('admin_init',array(&$this, 'add_meta'));         }              public function add_meta() {             if ($this->meta['template'] == $this->template) {                 add_meta_box($this->meta['id'], $this->meta['title'], array(&$this, 'format_meta'), $this->meta['post_type'], $this->meta['context'], $this->meta['priority']);                 }         }              public function format_meta() {             global $post;                  if (!isset($post)) return false;                  if ($this->meta['post_type'] != $post->post_type) return false;                  $this->set_postid($post->ID);                  // Use nonce for verification             echo '<input type="hidden" name="' . $this->meta['nonce_name'] . '" value="', wp_create_nonce(basename(__FILE__)), '" />';                  foreach ($this->meta['fields'] as $field) {                 // get current post meta data                 $meta = get_post_meta($post->ID, $field['id'], true);                      if (isset($field['before']) && $field['before'] != "") {                   echo '
' . $field['before'] . '
';                 }                      echo ''. $field['name']. '
';                      if (isset($field['desc']) && $field['desc'] != "") {                   echo '
' . $field['desc'] . '
';                 }                      if ( $field['type'] == 'radio' )                     echo '
';                      switch ($field['type']) {                     case 'text':                         echo '<input type="text" name="'. $field['id']. '" id="'. $field['id'] .'" value="'. ($meta ? $meta : $field['default']) . '" class="arixwp_admin_input" />'. '
';                         break;                     case 'textarea':                         echo '<textarea name="'. $field['id']. '" id="'. $field['id']. '" cols="60" rows="4" class="arixwp_admin_input">'. ($meta ? $meta : $field['default']) . '</textarea>'. '
';                         break;                     case 'select':                         echo '<select name="'. $field['id'] . '" id="'. $field['id'] . '" class="arixwp_admin_select">';                         foreach ($field['options'] as $option) {                             echo '<option '. ( $meta == $option ? ' selected="selected"' : '' ) . '>'. $option . '</option>';                         }                         echo '</select>';                         break;                     case 'radio':                         foreach ($field['options'] as $option) {                            // echo '<input type="radio" name="' . $field['id'] . '" value="' . $option['value'] . '"' . ( $meta == $option['value'] ? ' checked="checked"' : '' ) . ' />' . $option['name'] . '
';                             echo '<input type="radio" id="' . $field[ 'id' ] . $option['value'] . '" name="' . $field[ 'id' ] . '" value="' . $option['value'] . '"' . ( $meta == $option[ 'value' ] ? ' checked="checked"' : '' ) . ' />' . $option[ 'name' ] . '';                          }                         break;                     case 'checkbox':                         echo '<input type="checkbox" name="' . $field['id'] . '" id="' . $field['id'] . '"' . ( $meta ? ' checked="checked"' : '' ) . ' />';                         break;                 }                      if ( $field['type'] == 'radio' )                     echo '
';                     // echo     '
';             }         }              public function save_meta_data($post_id) {             global $post;                  if (!isset($post->ID)) {                 $post = get_post($post_id);             }                  $this->set_postid($post->ID);             $this->meta = $this->get_meta();                  if ($this->meta['post_type'] != $post->post_type) return $post_id;                  $_POST[$this->meta['nonce_name']] = isset($_POST[$this->meta['nonce_name']]) ? $_POST[$this->meta['nonce_name']] : "";                  //Verify nonce             if (!wp_verify_nonce($_POST[$this->meta['nonce_name']], basename(__FILE__))) {                 return $post_id;             }                  //Check autosave             if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {                 return $post_id;             }                  //Check permissions             if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) {                 if (!current_user_can('edit_page', $post_id)) {                     return $post_id;                 }             } elseif (!current_user_can('edit_post', $post_id)) {                 return $post_id;             }                  foreach ($this->meta['fields'] as $field) {                      $old = get_post_meta($post_id, $field['id'], true);                 $new = isset($_POST[$field['id']]) ? $_POST[$field['id']] : '';                      if ($new && $new != $old) {                     update_post_meta($post_id, $field['id'], $new);                 } elseif ('' == $new && $old) {                     delete_post_meta($post_id, $field['id'], $old);                 }             }         }              public function set_postid($axPostId = 0) {             $postID  = null;             $postID2 = null;                  if ($axPostId > 0) {                 $this->postid = $axPostId;             } else {                      if ( isset( $_GET['post'] ) ) {                          $postID  = filter_var( $_GET['post'], FILTER_VALIDATE_INT );                          if ( isset( $_POST['post_ID'] ) ) {                         $postID2 = filter_var( $_POST['post_ID'], FILTER_VALIDATE_INT );                     } else {                         $postID2 = '';                     }                          $this->postid = $postID ? $postID : $postID2 ;                       }             }         }              public function get_postid() {             return $this->postid;         }              public function set_template() {             $this->template = get_post_meta($this->postid,'_wp_page_template',TRUE);         }              public function get_template() {             return $this->template;         }              public function set_meta($axMeta) {             update_post_meta($this->postid, '_arixwp_field_meta', serialize($axMeta));             $this->meta = $axMeta;         }              public function get_meta() {             if (is_null(($this->meta))) {                 $this->meta = unserialize(get_post_meta($this->postid,'_arixwp_field_meta',TRUE));             }             return $this->meta;         }     }       and this is the php to call the class               <?php              $meta_template = '';         $meta_posttype = 'page';         $meta_title    = 'Page Options';         $meta_context  = 'normal';         $meta_priority = 'high';         $meta_id       = 'page-meta';         $meta_nonce    = $meta_id . '-nonce';         $arixwp_meta       = new ARIXWP_Meta();              $arixwp_meta->set_postId();         $arixwp_meta->set_template();         $arixwp_template  = $arixwp_meta->get_template();              if ($arixwp_template == $meta_template) {             $arixwp_meta->set_meta(array(                      //This is the id applied to the meta box                 'id'         => $meta_id,                      //This is the post type the meta is for                 'post_type'  => $meta_posttype,                      //This is the template to show the meta for                 'template'   => $meta_template,                      //This is the nonce for this meta                 'nonce_name' => $meta_nonce,                      //This is the title that appears on the meta box container                 'title'      => $meta_title,                      //This defines the part of the page where the edit screen section should be shown                 'context'    => $meta_context,                          //This sets the priority within the context where the boxes should show                 'priority'   => $meta_priority,                      //Here we define all the fields we want in the meta box                 'fields' => array(                        // Show or hide featured posts                          array(                         'before'    => '',                         'after'     => '',                         'name'      => __( 'Show Featured Posts', THEMENAME ),                         'desc'      => __( 'This allows you to show or hide the featured posts banner on this page. ( Note: this will override the setting in the themes control panel. )', THEMENAME ),                         'id'        => '_arixwp_featured_show_page',                         'type'      => 'radio', // text,textarea,select,radio,checkbox                         'default'   => 'home',                         'options'   => array(                             array('name' => __( ' Yes', THEMENAME ), 'value' => 'yes'),                             array('name' => __( ' No', THEMENAME ), 'value' => 'no')                         )                                                    ),                        // Featured Posts Display Method                          array(                         'before'    => '',                         'after'     => '',                         'name'      => __( 'Featured Post Display', THEMENAME ),                         'desc'      => __( 'This controls how your featured posts are displayed. You can show one main feature and 3 normal features, one main feature only, three normal features only, or a jQuery slider that slides through the latest 4 posts in the featured category. ', THEMENAME ),                         'id'        => '_arixwp_featured_display_page',                         'type'      => 'radio', // text,textarea,select,radio,checkbox                         'default'   => 'four',                         'options'   => array(                             array('name' => __( ' Main Feature & 3 Normal Features', THEMENAME ), 'value' => 'four', 'class' => 'wparix_feature_four' ),                             array('name' => __( ' Main Feature Only', THEMENAME ), 'value' => 'one', 'class' => 'wparix_feature_one' ),                             array('name' => __( ' 3 Normal Features Only', THEMENAME ), 'value' => 'three', 'class' => 'wparix_feature_three' ),                             array('name' => __( ' Slidertron Slider', THEMENAME ), 'value' => 'slide', 'class' => 'wparix_feature_slide' )                         )                                                    ),                      // Sidebar Location                          array (                         'before'    => '',                         'after'     => '',                         'name'      => __( 'Sidebar Location', THEMENAME ),                         'desc'      => __( 'This allows you to override the default sidebar settings.', THEMENAME ),                         'id'        => '_arixwp_sidebar_page',                         'type'      => 'radio', // text,textarea,select,radio,checkbox                         'default'   => 'left',                         'options'   => array(                             array('name' => ' Left', 'value' => 'left'),                             array('name' => ' Right', 'value' => 'right'),                             array('name' => ' None', 'value' => 'none')                         )                                                    ),                                                        )             ));                  $arixwp_meta->init_meta();         }              $arixwp_meta = null;      I am using several instances of this for posts and custom page templates and it works fine. But when just trying to apply it to a generic page. The Meta boxes show when you choose to add a new page. But as soon as you save or publish they dissappear.


Use Ajax To filter posts?

Right now I'm submitting a drop-down form to it's own page (action="") to filter posts displayed. I'd like to not have to refresh the page, which resets the forms. Is there a way to query posts/filter them using ajax?


Is it a bad practice to go directly to the mysql database while developing a plugin?

This is a sample of the Vote it Up plugin:               //Run this to create an entry for a post in the voting system. Will check if the post exists. If it doesn't, it will create an entry.     function SetPost($post_ID) {         global $wpdb;              //prevents SQL injection         $p_ID = $wpdb->escape($post_ID);              //Check if entry exists         $id_raw = $wpdb->get_var("SELECT ID FROM ".$wpdb->prefix."votes WHERE post='".$p_ID."'");         if ($id_raw != '') {             //entry exists, do nothing         } else {             //entry does not exist             $wpdb->query("INSERT INTO ".$wpdb->prefix."votes (post, votes, guests, usersinks, guestsinks) VALUES(".$p_ID.", '', '', '', '') ") or die(mysql_error());         }     }          //Run this to create an entry for a user in the voting system. Will check if the user exists. If it doesn't, it will create an entry.     function SetUser($user_ID) {         global $wpdb;              //prevents SQL injection         $u_ID = $wpdb->escape($user_ID);              //Check if entry exists         $id_raw = $wpdb->get_var("SELECT ID FROM ".$wpdb->prefix."votes_users WHERE user='".$u_ID."'");         if ($id_raw != '') {             //entry exists, do nothing         } else {             //entry does not exist             $wpdb->query("INSERT INTO ".$wpdb->prefix."votes_users (user, votes, sinks) VALUES(".$u_ID.", '', '') ") or die(mysql_error());         }     }          //Returns the vote count     function GetVotes($post_ID, $percent = false) {         global $wpdb;              //prevents SQL injection         $p_ID = $wpdb->escape($post_ID);              //Create entries if not existant         SetPost($p_ID);              //Gets the votes         $votes_raw = $wpdb->get_var("SELECT votes FROM  ".$wpdb->prefix."votes WHERE post='".$p_ID."'");         $sinks_raw = $wpdb->get_var("SELECT usersinks FROM  ".$wpdb->prefix."votes WHERE post='".$p_ID."'");         $guestvotes_raw = $wpdb->get_var("SELECT guests FROM  ".$wpdb->prefix."votes WHERE post='".$p_ID."'");         $guestsinks_raw = $wpdb->get_var("SELECT guestsinks FROM  ".$wpdb->prefix."votes WHERE post='".$p_ID."'");     /* Deprecated         $uservotes_raw = $wpdb->get_var("SELECT votes FROM ".$wpdb->prefix."votes_users WHERE user='".$u_ID."'");         $usersinks_raw = $wpdb->get_var("SELECT sinks FROM ".$wpdb->prefix."votes_users WHERE user='".$u_ID."'");     */              //Put it in array form         $votes = explode(",", $votes_raw);         $sinks = explode(",", $sinks_raw);         $guestvotes = explode(",", $guestvotes_raw);         $guestsinks = explode(",", $guestsinks_raw);     /* Deprecated         $uservotes = explode(",", $uservotes_raw);         $usersinks = explode(",", $usersinks_raw);     */         $uservotes = 0;         $usersinks = 0;              $initial = 0; //Initial no. of votes [will be placed at -1 when all posts receive votes]      (and so on...) I've heard from many people that it is a bad practice to go directly to the mysql database. That the code can break up in future versions of Wordpress. Or it is necessary in some plugins like Vote it Up?


Using WP Rewrite to rewrite custom urls in this scenario

I have build a plugin where I can output special php pages on a page using shortcode. The plugin directory consists of the following php pages.               product_info.php     index.php     account.php     login.php     checkout.php     core.php      The shortcode function which is on `core.php` is as follows,               function output_store(){     if(!isset($_REQUEST['slug']))         include(WP_PLUGIN_DIR.'/'.basename(dirname(__FILE__)).'/index.php');            if($_REQUEST['slug'])         include(WP_PLUGIN_DIR.'/'.basename(dirname(__FILE__)).'/'.$_REQUEST['slug']);        }     function filter($content = '') {         if ( '' == $content || !strstr($content, '[WP_online_store]') ) { return $content; }         return preg_replace('|(<p>)?(\n)*[(\[)WP_online_store(\])](\n)*(</p>)?|', do_shortcode( '[WP_online_store]' ), $content);     }     add_shortcode('output_store', 'output_store');     add_filter('the_content', 'filter');      `[output_store]` will be placed on any page for example on `store` page so when I visit the `store` page the default content of that page will display the `index.php` file from the plugin directory. In the `index.php` file I have links for accessing `login.php, product_info.php, account.php and checkout.php` each has url of:               login.php => http://website.com/store/?slug=login.php     product_info.php => http://website.com/store/?slug=product.info.php     account.php => http://website.com/store/?slug=account.php     checkout.php => http://website.com/store/?slug=checkout.php      Also on `index.php` I have products there pulled from mysql database in which accessible by links like `http://website.com/store/?slug=product_info.php&products_id=38` and so on. Now I wanted to rewrite these urls to be search engine friendly. I wanted:               http://website.com/store/?slug=login.php to become http://website.com/store/login     http://website.com/store/?slug=account.php to become http://website.com/store/account     http://website.com/store/?slug=checkout.php to become http://website.com/store/checkout      and all product urls:                   like http://website.com/store/?slug=product_info.php&products_id=38          to become http://website.com/store/product-info/38      How can I accomplish that using wordpress's WP Rewrite? I tried this for the product info pages:               // Define permalinks     function add_query_vars($aVars) {     $aVars[] = "products_id";     return $aVars;     }               function add_rewrite_rules($aRules) {     $aNewRules = array('product-info/([^/]+)/?$' => 'index.php?slug=product_info.php&products_id=$matches[1]');     $aRules = $aNewRules + $aRules;     return $aRules;     }          add_filter('query_vars', 'add_query_vars');     add_filter('rewrite_rules_array', 'add_rewrite_rules');          function isset_productinfo() {       if(isset($wp_query->query_vars['products_id'])) {        $sMsdsCat = urldecode($wp_query->query_vars['products_id']);       }     }     add_action('init','isset_productinfo');          // End Special Permalinks      Flushed my permalinks and its not working.. When I access `http://website.com/store/product-info/38` and goes on `http://website.com/store/` instead of displaying the product page. How can I fix this? or do you have any other solutions? Please help..


WordPress project under Mercurial, what's an appropriate .hgignore file?

For those of you who are controlling their project with Mercurial, I'm curious as to what you have listed in your .hgignore file? I'm at a bit of a loss as to what I should include in it. I'm thinking just exclude cache and file data, but anything else? Thanks. EDIT: For some reason I titled .hgrc instead of .hgignore, my bad. However, it looks like the responder(s) below knew what I meant :) Sorry.


How do you Query posts with nothing in common?

We can get multiple posts manually in a page, but that's generated in a template, AFTER the default query returned something else (page/post, etc) How do you query multiple posts in a public query, which share no taxonomy or anything else? e.g. by ID:               http://example.com/?p=23,18,2,199,6,8      I got it working already parsing a variable in a page-name.php template, but once it gets the template it's too late to generate e.g. canonicals. I guess this would be something similar to a search, except the search is a 1-to-multiple-posts relation and this requires a multiple-queries-to-unique- post (each). Thanks.


what is the cache directory for in my theme? (version control it?)

I was wondering what processes exactly use the `cache` directory inside my theme's directory. More specifically, I am wondering if I should add any of those files to my git repo.


How can I append blog_id to ... echo [functions-defined-constant]?

I use 'constants' a lot. I set them in functions.php like `define('mytheme_town', 'Orlando');` and then call them into the theme `<?php echo mytheme_town ; ?>`. It's simple and easy. But I need them to be site-specific (for multisite) so I thought it might be possible to append the current blog_id to the theme call and declare constants for each MultiSite in functions.php? I don't know how to code that, but what I'm trying to achieve in the theme file this ... `<?php echo [current_blog]_mytheme_town ; ?>` ..... For example **In functions.php** // set constants for all multisites that use this theme // awebsite.org : site_id=1   define('1_mytheme_town', 'Orlando');   define('1_mytheme_subject', 'food');   define('1_mytheme_p1', 'This is the first paragraph text'); // adifferentsite.com: site_id=2   define('2_mytheme_town', 'New York');   define('2_mytheme_subject', 'wine');   define('2_mytheme_p1', 'This is the first paragraph text'); // anothersite.net : site_id=3 define('3_mytheme_town', 'LA');   define('3_mytheme_subject', 'Donuts');   define('3_mytheme_p1', 'This is the first paragraph text'); **In theme files** Call the constants using the current blog_id like so ... `<?php echo [current_blog]_mytheme_town ; ?>`   `<?php echo [current_blog]_mytheme_subject ; ?>`   `<?php echo [current_blog]_mytheme_p1 ; ?>` I have been trying all day, but I'm just guessing and I don't really know what I am doing. Everything I have tried works, but it simply echos out text of the code > 1_mytheme_town and not the constant that is defined in functions.php. Hope you understand what I'm trying to explain.


Add the sidebar/widget editor to the post edit screen?

There are (among others) two common ways of customizing the sidebar on an individual post:   1. **Create a new sidebar for the post,** using code or plugins like Custom sidebars, WP Custom Sidebar, Per Page Sidebars, or similar.   2. **Create conditional display rules on individual widgets** , using plugins like Widget Logic or Conditional Widgets.  Option 1 can lead to a proliferation of sidebars on your Widgets page if you have more than a few posts you want to customize. Option 2 can quickly lead to long, complicated, and difficult-to-manage sidebars in the backend. And with both 1 and 2, the user has to manage things on a separate page than the page she wants to customize. ## So: Are there any plugins—or related attempts—to add a sidebar/widget editor, (like in **Appearance » Widgets** ) to the post edit screen? The idea would be to give the user the option to override the default sidebar on a given page in a convenient and intuitive way. It might work something like this:   * Add a metabox containing a checkbox to override default sidebar on that post or page.   * If checked, display interface to select widgets. (this could be the full widget 'bank', but, more economically, it could just be a dropdown with names of widgets).   * For the interface and saving, recycle code from Appearance » Widgets   * For front of site, include filter to replace the default sidebar if `_override_sidebar` meta field says so. I'm surprised I can't seem to find a plugin for this. Do you have suggestions—plugins, pitfalls, related code? ![enter image description here](http://i.stack.imgur.com/TH3LZ.png)


Page reload occurs before request finishes

I wrote a plugin to send an invitation to a friend and am submitting a form using AJAX and used the tips talked about in 5 tips for using AJAX in wordpress and another article referenced in the AJAX in plugins wordpress codex page. I have now got the relevant code executing and sending an email as expected however the page reloads before the AJAX call finishes. The relevant PHP code is here:               <?php     define( 'SEND_INVITATION_MIN_WORDPRESS_VERSION', '3.1.1' );     define( 'SEND_INVITATION_PLUGIN_URL', plugins_url( '', __FILE__ ) );          // Tie into WordPress Hooks and any functions that should run on load.     //     add_action( 'init', array( 'NC_SendInvitation', 'send_invitation_init' ) );          class NC_SendInvitation {         protected $nonce_name = 'send_invitation';         protected $post_url = '';              public static function send_invitation_init() {             new self;         }              public function __construct() {             $this->send_invitation_head();             $this->send_invitation_check_wordpress_version();             add_action( 'show_invitation_form', array( $this, 'send_invitation_get_form' ), 10, 1 );                  // Add AJAX actions             // Serves logged in users             add_action( 'wp_ajax_form_action', array( $this, 'send_invitation_handle_submit' ) );                  // Serves non-logged in users             add_action( 'wp_ajax_nopriv_form_action', array( $this, 'send_invitation_handle_submit' ) );         }              public function send_invitation_head() {              // Add script that for handling AJAX POST request to the head             wp_enqueue_script( 'send-invitation-ajax-handle',                 plugins_url( 'js/ajax.js', __FILE__ ),                 array( 'jquery' ) );                  // Localise script find out what this does             wp_localize_script( 'send-invitation-ajax-handle',                 'send_invitation_ajax_script',                 array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );                  // Add the script for showing and hiding the form to the head             wp_enqueue_script( 'send-invitation-js',                 plugins_url( 'js/send-invitation.js', __FILE__ ),             array( 'jquery' ) );                  // Add the CSS that styles the form to the head             wp_enqueue_style( 'send-invitation',                 plugins_url( 'css/send-invitation.css', __FILE__ ) );         }              public function send_invitation_check_wordpress_version() {             global $wp_version;                $exit_msg = 'Send Invitation requires version '         . SEND_INVITATION_MIN_WORDPRESS_VERSION         . 'or newer Please     update!';              if ( version_compare( $wp_version, SEND_INVITATION_MIN_WORDPRESS_VERSION, '<') )         {             exit( $exit_msg );         }     }              public function send_invitation_get_form($post_url) {         // TODO Try moving this into another file and include here using method above         $send_invitation_form ='
Send Invitation
         <form id="invitation-form" action="" method="post">
                 Your Email Address
                 <input type="text" name="your_email" />

                 Email Address of Recipient
                 <input type="text" name="friends_email" />

                 Subject
                 <input type="text" name="subject" />

                 Message
                 <textarea rows="10" cols="20" name="message">' . $post_url . '</textarea>
             <input type="hidden" name="nonce" value="send_invitation" />             <input type="hidden" name="action" value="form_action" />
<input id="submit-button" type="submit" value="Send" onclick="send_invitation();" />
         </form>

';              echo $send_invitation_form;     }              public function send_invitation_handle_submit() {         $success = __('OK');         $error = __('NOT OK');         if (!empty($_POST)) {             try {                 error_log('Inside if', 0);                 $to = $_POST['friends_email'];                 $subject = $_POST['subject'];                 $message = $_POST['message'];                      // TODO Suppress error message with @                 $send_result = wp_mail($to, $subject, $message);                 $feedback = $send_result ? $success : $error;             }             catch( Exception $e ) {                 $feedback = "Catch: " . $e->getMessage();             }         } else {             $feedback = "Error: " . $error;         }         echo $feedback;         exit;         // Do not forget to exit     }     ?>      The relevant javascript code is here:               function send_invitation() {         alert("got here");         jQuery.post(send_invitation_ajax_script.ajaxurl,             jQuery('#invitation-form').serialize(),             function(response) {                 alert('Response: ' + response);                 jQuery('.response-area .success').html(response);             }         );     }      Another problem I am seeing is that the POST request to the ajaxurl shows up red in firebug but it disappears quickly and I cannot see what is happening but the correct PHP functions are executing but no response comes back and all I get is page reload once the request is sent. I am not sure why this is the case but I have tried debugging this for a while and could not find a solution. Thanks in advance. nav


How do I add open graph tags?

I'm using the Wordpress CMS. I don't have access to the theme's code etc.. So how do I update the opeh graph tags? I'm mainly looking to add an image to go along with it, as it's using the default WordPress image when I share on Facebook. Thanks!


Reblog from Tumblr to Wordpress

If you have a Tumblr blog, you can 'reblog' from other Tumblr blogs, much like a trackback. I follow a couple of Tumblr blogs and sometimes want to quote from those websites. And, on these Tumblr sites, there is a 'notes' section for each post listing each 'reblog'. So my question is: is there some WordPress plugin (or some workaround not requiring a plugin) that will allow me to 'reblog' from a Tumblr site to my WordPress one and have it show up in the 'notes' section of the Tumblr blog? My site is a wordpress.org blog, if that makes a difference. And I am running WordPress 3.0.1. Thanks in advance!


Creating new page with pre-defined parent page

I have a blog with a very complex page structure (like, 4 levels of hierarchy). When creating new pages, it is very cumbersome to pick the parent page from the drop-down list, as it is constantly growing. For that reason, I would like to add a button to the frontend admin bar that points to `post-new.php`, but with a "parent page ID" parameter. Effectively, the button would allow you to navigate to the desired parent page on the front page, and then click a "add new page here" link there that takes you to the back-end with the parent page preselected. However, it seems to be impossible to add parameters to `post-new.php` and a related feature request has been closed in the WordPress trac. Does anybody know a solution that does not require hacking the core? One idea I had was hooking up to a hook that gets triggered before a new item is created, pulling the parent page from a GET parameter there, and setting it in the item-to-be. If that is a viable way, I would be grateful for a simple pointer which hook to use.


How can we select attachements based on Caption?

I am trying to select some attachements based on an attachement caption. I need to do this for a seperate download page. On the download page i want to display all attachment which caption equals "downloads". So this way i can be selective of post attachments which can and can't be downloaded At the moment i have this code to select all the attached pdf's as downloable files, but i like to select some attached images and deselect some pdf's.                   $args = array('post_parent' => $atts['product_id'],         'post_status' => 'inherit', 'post_type' => 'attachment',         'post_mime_type' => 'application/pdf', 'order' => $order, 'orderby' => $orderby);     $attachments = get_posts($args);         //print_r($attachments);             $i = 1;             foreach ($attachments as $attachment) {     ...     $attachment->guid      i am also able to select images based on there given thumbnail name with               wp_get_attachment_image($attachment->ID,'product-slider-thumbnail')      but how to select based on caption?? regards


wp_insert_post and title not utf8 inserts with empty title?

I'm using `wp_insert_post` I loop over a text file one row at a time and for each row I create a post. The text is set as the `post_title', for text that is not utf8 the post inserts but with an empty title. Why does that happen, if I'm able to create a post in the backend admin using non utf8 chars it looks like WordPress converts the encoding in the backend. How can I bypass this with `wp_insert_post` and have it insert the post title with non utf8 chars? Thanks


Pull post meta with post_query?

I'm building a custom index loop that just uses query_posts at the moment. The issue is that inside The Loop, I have to then query for the post meta data (with get_post_meta), which I believe has to query the DB each time it's called. Is there any way I can pull the meta data with the query_posts? I'd need most if not all of the meta data stored for each post. Thanks,   Max


Wordpress redirection to get url friendly

I want to get url friendly for pass data to page from other page. I explain : I have on i classic wordpress page, url like it : ( example.com/agent/name_agent ) it's url build dynamically. ( get_permalink($id_page_agent) . $name_agent ) In my loop-agent.php , i can manage $_GET['agent_name'] to make a filter. I need to build redirection example.com/agent/name_agent > example.com/agent/?agent_name=name_agent I don't know if you understand ?


Search/Replace for editor in HTML-mode

Is there a way to do a Search and Replace for the editor in HTML-mode?   Plugins I found are for the visual editor, we are working **only** in HTML- mode, therefore -not- appropriate for what we do.   I would appreciate to find a code snippet or plugin for HTML-mode (did I miss the one you found?)   Thanks in advance for time and effort.


query_posts doesn't order by title

It seems like stupid bug, but how can i order by title? It anyways orders by date! I'm using:               query_posts( array(          'post_type'      => 'page',         'posts_per_page' => -1,         'orderby'        => 'title',         'order'          => 'ASC'     ) );      I want to use this in function as SHORTCODE. What i'm trying to achieve is to create site map / index of all entries in alphabetic order. Also i'm using newest WP.


What is the easiest way to implement cascading database upgrade for my plugin?

**Lets assume following situation:** I develop a plugin. The plugin requires custom database table to store some kind of information. From month to month I release new versions of my plugin. Different versions could have their own sets of changes of the table structure and table's data. For instance:   * _version 1.0.0_ has initial setup for table structure   * _version 1.1.0_ has changes to one column type and requires to perform update operation over data of this column   * _version 2.0.0_ requires creation of two new columns, splitting data from old column to new columns and removal of old/deprecated column **The problem:** Lets consider two use cases:   1. An user downloaded version 1.0.0, skipped update to version 1.1.0 and decided to update the plugin when the version 2.0.0 was released. How to organize database upgrade process, which will handle upgrade from version 1.0.0 to version 2.0.0 including changes from version 1.1.0?   2. An user downloaded version 2.0.0 and installed it on a blank instance of WordPress. How to perform the latest version of database installation, which will include all changes from all versions compliance with DRY principles?


How to make website with many template that active

I want to make a website with wordpress engine but with some features. One website has 3 template and every template is active because I want to make 1 website that has 3 sub categories such us blog, portfolio, and photo gallery but with different templates and fitur in every sub-category. Anyone knows how to do that, please ? Thank you very much in advance.


Wp-Admin FTPS Connection Error unlike Filezilla

My wordpress website is just moved FTP to FTPS protocol. When I tried to make a connection with FileZilla, the connection is successful. There is nothing wrong with my FTPS connection. ![enter image description here](http://i.stack.imgur.com/Y4emW.png)               Status: Connecting to 88.247.100.147:16666...     Response:   fzSftp started     Command:    open "sonergonul@88.247.100.147" 16666     Command:    Trust new Hostkey: Yes     Command:    Pass: **************     Status: Connected to 88.247.100.147     Status: Retrieving directory listing...     Command:    pwd     Response:   Current directory is: "/home/sonergonul"     Command:    ls     Status: Listing directory /home/sonergonul     Status: Calculating timezone offset of server...     Command:    mtime "sonergonul_net"     Response:   1326036705     Status: Timezone offsets: Server: 7200 seconds. Local: 10800 seconds. Difference: 3600 seconds.     Status: Directory listing successful      But in my wp-admin, when I tried to update my wordpress version auto, these informations are not accepted. ![enter image description here](http://i.stack.imgur.com/fZUxO.jpg) Error code means: > There was a problem connecting to the server, please check the connection > settings. My all files under the `88.247.100.147:16666/home/sonergonul/sonergonul_net`. All tried to connect all the possibilities in my Server name (88.247.100.147, 88.247.100.147:16666, sonergonul.net) but no one was accepted. I think I miss some point but couldn't find it. Doesn anyone have an idea for this situation?


Why is the server response time slowing my site down?

My site is www.phoenixwave.com When I use Pingdom speed test and Google's speed test both give me the conclusion that my server response time is ridiculously slow...I'm using a Rackspace server. I'm just trying to get a general direction where I need to start troubleshooting. Should I look into different hosting? Am I having a server problem or a DNS problem? Thanks for any and all help provided from the community. See the result picture from Pingdom below: ![Pingdom Test of Phoenixwave.com](http://i.stack.imgur.com/oJry6.jpg)


Adding custom fields to images

I want to show sources under my every images. So basicly I want to add a simple custom field. I added this code to my function.php               add_filter('attachment_fields_to_edit', 'edit_media_custom_field', 11, 2 );     add_filter('attachment_fields_to_save', 'save_media_custom_field', 11, 2 );     function edit_media_custom_field( $form_fields, $post ) {         $form_fields['custom_field'] = array( 'label' => 'Custom Field', 'input' => 'text', 'value' => get_post_meta( $post->ID, '_custom_field', true ) );         return $form_fields;     }     function save_media_custom_field( $post, $attachment ) {         update_post_meta( $post['ID'], '_custom_field', $attachment['custom_field'] );         return $post;     }      It is ok so far.But then things getting messy. Now my problem is where I can add this second calling code, I meant which .php               get_post_meta( get_the_ID(), '_custom_field', true ) );


Wordress debug log is not working

I have tried all recommendations from here but none solves my issue. I have a couple of wordpress installations on a local machine running Win 7 and wamp 2.4 and none of them writes in the debug.log file or even display the errors in the page. I have set the following in the wp-config.php:               define('WP_DEBUG', true);     define('WP_DEBUG_LOG', true);     define('WP_DEBUG_DISPLAY', false);      I have manually created an empty file named debug.log in the wp-content directory with full permissions for everyone. My php.ini settings are:               error_reporting = E_ALL     display_errors = On     display_startup_errors = On     log_errors = on     log_errors_max_len = 1024     ignore_repeated_errors = Off     track_errors = On     html_errors = On     error_log = "C:/wamp/logs/php_error.log"      The only way to debug is to use one of the available plugins but they are useless when I'm getting the white screen.


Custom post type page for authors

I've got 30+ users and several custom post types.   * Classes   * Downloads   * Parties   * Events   * etc At the moment, I'm using `author.php` to display all these custom posts for **that** user, each post type in a loop, each hidden in a tab format. `http://www.websites.com/members/steve` I've been asked if there's a way of having each post type on it's on URL `http://www.websites.com/members/steve/classes` `http://www.websites.com/members/jean/parties` `http://www.websites.com/members/peter/events` Can this be done?


Registering Class methods as hook callbacks

I'm not sure if I have done this correctly. As I understand it: if I have a class foo and a static method bar I can register that as the callback by passing the array `array("foo","bar")` as the function name. If I have an instance of a class in $foo and want to call the method bar I pass the array `array($foo,'bar')`. If I need to register an action inside the class itself would it work with `array($this,'bar')`?


Dynamically Create Terms in Taxonomy when Custom Post Type is Published. Almost There!

I'm trying to automatically create terms in a certain taxonomy when a certain custom post type is published. The newly created term must be the name of the post that was published. Example: I have a custom post type "country" and a custom taxonomy "country_taxo". When I publish a country say "Kenya" I want a the term "Kenya" to be automatically created under the "country_taxo" taxonomy. I have accomplished this using the "publish_(custom_post_type) action hook", but i can only get it to work statically. Example:               // This snippet adds the term "Kenya" to "country_taxo" taxonomy whenever      // a country custom post type is published.          add_action('publish_country', 'add_country_term');     function add_country_term() {         wp_insert_term( 'Keyna', 'country_taxo');     }      Like I mentioned above I need this to dynamically add the post title as the term. I tried this, but it doesn't work:               add_action('publish_country', 'add_country_term');     function add_country_term($post_ID) {         global $wpdb;         $country_post_name = $post->post_name;         wp_insert_term( $country_post_name, 'country_taxo');     }      Does anyone know how I would go about doing this? Any help is greatly appreciated.


How can I query for all values of a custom taxonomies?

Suppose I have a Custom Taxonomy "Fruits". I want to query for all the values available eg. Oranges, Apples, Mangos etc. How can I do that?


Custom Loop, Match Category with Page: How to display post featured image?

I found this answer. It saved my day, but could you tell me how to display featured image of the post with the following code? When I'm using               <?php echo $cpost->post_thumbnail('thumbnail', array('class' => 'alignleft')); ?>      An image does not show up... Code below:               <?php if(is_page()) : // check we are a page ?>         <?php global $post; $cposts = get_posts("numberposts=-1&category_name={$post->post_name}"); if($cposts) : ?>                      <?php foreach($cposts as $cpost) : ?>

<?php echo $cpost->post_title; ?>

<?php echo $cpost->post_content; ?>
                          <?php echo $cpost->post_thumbnail('thumbnail', array('class' => 'alignleft')); ?>
                   <?php endforeach; ?>                               <?php endif; ?>             <?php endif; ?>      Could you tell me how the correct code should work?


Custom taxonomy for Media Library

I am trying to create a custom taxonomy for the Media Library called "Reference Type" When I add the following content to functions.php               function wptp_add_reference_type_taxonomy() {         $labels = array(             'name'              => 'Add Reference Type',             'singular_name'     => 'Reference Type',             'search_items'      => 'Search Reference Type',             'all_items'         => 'All Reference Type',             'parent_item'       => 'Parent Reference Type',             'parent_item_colon' => 'Parent Reference Type:',             'edit_item'         => 'Edit Reference Type',             'update_item'       => 'Update Reference Type',             'add_new_item'      => 'Add New Reference Type',             'new_item_name'     => 'New Reference Type',             'menu_name'         => 'Reference Type',         );              $args = array(             'labels' => $labels,             'hierarchical' => true,             'query_var' => true,             'rewrite' => true,             'public' => true,             'show_in_nav_menus' => true,             'show_ui' => true,             'show_admin_column' => true         );              register_taxonomy( 'reference_type', 'attachment', $args );     }     add_action( 'init', 'wptp_add_reference_type_taxonomy' );      Options to add and modify items in that taxonomy show in the admin panel. However, when I got a page like http://sitehere.com/reference_type/sample-item I get redirected to a Page Not Found in index.php and not the custom page I have set up for this taxonomy in taxonomy.php In addition, when I add a reference type "sample item" to a media item it will show up in the Library tab, but in the Reference Type tab, it will say there are 0 items under "sample item". In general, when i try to print a list of items in this taxonomy it does not show up (I am using code suggested in the WP codex). **SOLUTION** Adding `'rewrite' => array('slug' => 'reference_type', 'with_front' => false)` fixed my issue of not being able to view individual item pages. Adding `'update_count_callback' => '_update_generic_term_count'` fixes my issue with the count not updating


Changing permalink name redirects to another template?

I'm creating a template with a few templates with names `page-contact.php`, `page-portfolio.php` and `page-blog.php`. The problem is that when I select a **Defaul Template** for a page (I expect it to open `page.php`) and rename the page permalink to **sitename.com/contact** the page starts using the `page-contact.php`.. Why is that, why is the URL telling WordPress what template to use if a Default one i chosen? Is this intended behavior?


Sorting search results

I am trying to develop a better way of searching my website. I want:   * Results to be displayed by relevance   * Pages to be listed first, posts should be listed after pages   * Searched terms to be highlited in post excerpts. This is a list of requirements from the most important to the least important. I am not sure how I can modify my code to fulfil those requirements Could you please help me with at least first two of them? Here is a piece of code which performs the searching:
                 <?php                      $s = get_search_query();                     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                          // CHECK IF FILTERS ARE APPLIED                     if (isset($_GET['filter'])) {                         $filter = $_GET['filter'];                         if($filter == 'pages')                             $searcharray = array( 'page' );                         elseif ($filter == 'posts')                             $searcharray = array( 'post' );                         else                             $searcharray = array( 'post', 'page' );                     } else {                         $searcharray = array( 'post', 'page' );                     }                          echo '
Filters:
                         Display posts                         Display pages                         Display posts and pages                     ';                                            $newsposts = new WP_Query(                     array(                         'post_type' => /*array( 'post', 'page')*/  $searcharray,                         'posts_per_page' => 10,                         'paged' => $paged,                         's'=>$s));                     if ($newsposts->have_posts()) : while ($newsposts->have_posts()) : $newsposts->the_post();                  ?>

<a href="<?php echo get_permalink(); ?>"><?php the_title(); ?>
                                  <?php $category = get_the_category();                                       ?>                             <a href="<?php echo get_category_link( $category[0]->term_id ) ?>"><?php echo $category[0]->name; ?>
                                 <?php the_excerpt(); /* the excerpt is loaded to help avoid duplicate content issues */ ?>                                 <?php echo ''.$langOptions['more'][ ICL_LANGUAGE_CODE ].'';?>


jquery not working correctly in plugin options page?

I have created my own plugin which has a custom script attached to it. I have added this in the correct manor like this:               add_action('admin_enqueue_scripts', 'add_search_script');     function add_search_script() {         wp_register_script('search', plugins_url('search.js', __FILE__) );         wp_enqueue_script('search');         }      If i add an alert to the top of the .js file, and then refresh the plugin page the alert appears. Simple alert like this:               alert ('test');      However if i try and hide something with js, noting happens? I target a class like this:               $(".simple").hide();      Which has no effect? I have also tried:               jQuery(".simple").hide();      Which again has no effect? Any ideas on what could be the problem?


Wordpress page content outside Wordpress

I have a strange request. Is it possible to load the content of a Wordpress page in a normal PHP page? For example I want to display the content of the wordpress page 4 in a PHP page that is on the same domain but is not a part of the wordpress installation? How? Thank you in advance


List Taxonomy terms along with their posts

I am trying to make a list of all my posts in a custom post type by the taxonomy term e.g. Term name 1 - post 1 - post 2 - post 3 Term name 2 - post 1 - post 2 - post 3 Term name 3 - post 1 - post 2 - post 3 I have found the function which lists the terms (get_terms) but can't work out a way to list the terms but also list the posts. Any help is appreciated


Debugging upload problem: What part of WP does actual image-resizing?

I have a problem when uploading large images: images larger then (approx) 2000x2000 aren't generating thumbnails. The file is uploaded fine, but no resized version are generated. No errors are shown. If I upload a smaller one, everything works fine and smaller sizes are generated (ex: `test-100x100.jpg`) I've contacted my hosting support because I thought this would be a `php-gd` problem, but support said everything was fine. Here what we have ruled out:   * Permission problems   * Out of disk space   * Out of memory (works fine on a server with half the amount of memory)   * Max upload limit (in WP and on server) We even tried another server with the exact same setup, and everything works fine here.   * I use a clean copy of the latest version WP. no plugins activated   * I've tried plugins which regenerates thumbnails, but even here all processes end successfully without errors, but no resizing was done. So I'm no trying to manually debug WP, and I'm having trouble finding the exact file where uploaded files are handled and resized. If found some classes in `/wp-includes`:   * `class-wp-image-editor.php`   * `class-wp-image-editor-gd.php` But it seems none of them are used during an upload. ( I've put `die()` in various functions)


Duplicate use of Wordpress plugin

I am stuck in a website and searching for someone to help me. I am using "Awesome Filterable Portfolio" plugin. I have to use it for different pages like Logo Design, Website, Print Graphics etc and other each page there will be some categories. So How I can use the plugin more than once? I have tried to change the name and everything, but when I install it shows one single menu in Dashboard with two plugins menu. Please help me: How i can use a plugin more than one time?.


How to prevent people from seeing certain articles in menus?

I found several plugins that prevent people from seeing certain widgets and posts. However, the posts I restrict still show up in all the places where you can see posts. They show up in search menus as well. I'd like to have several groups, as is native to WordPress, who can only see articles for them. For example, general consumption posts such as 'how to set up email' can be seen by everyone who has an account, but have other posts such as 'how to use a unix terminal' accessible to a certain level of account holder. Right now, people in the first group cannot read articles from the second group, but the title shows up on the posts page, so the first group knows they're being blocked, and they have a lot of titles that clutter their interface which they can't access. How can I prevent certain groups of users (say "readers") from even knowing that certain posts exist? I was thinking about copying widgets and pages and making a unique one for each group, but I was wondering if there was a better way.


How to change the image size in new Media Uploader (ie use medium vs thumbnail)

Is it possible to change the image size of the thumbnails in the new media uploader? For example images are currently displayed using the "thumbnail" image crop size and I would like them to be the "medium" image crop size.


How to prevent Wordpress from loading the jQuery library at the top of the page

I am developing a site that must be HTTPS secure and Wordpress is loading `<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>` at the very top of my page, before `<html>` and giving me an insecure error. I cannot find where this is being loaded from to prevent it from loading. Unfortunately I cannot show the site as it's a federal credit union site and it would be against our contract agreement for me to present this site publicly before it is complete. Here's a screenshot of the issue via Chrome web dev tools. http://oi50.tinypic.com/wjtchi.jpg


How to output taxonomy term (incl. link to archive) on author.php?

I have used the excellent tutorial of Justin Tadlock on Custom user taxonomies in WordPress to add a Blog custom taxonomy to both my Posts post_type as well as the user object_type. In his tutorial Justin then outputs a list of users that share the same (profession) taxonomy. I on the other hand would like to output the specific term of my Blog taxonomy on the `author.php` archive, together with some other user_meta-fields I already have added to the User Profile. How would I be able to accomplish this? Ideally it not only outputs the taxonomy term, but also a link to the term archive.


Custom Rewrite Rules

I am developing a plugin, the goal of which is to allow for a bookmark-able, pretty permalink search engine on a single page. To do so, I am using WP's rewrite rules to allow for the searching/permalinks. I need a structure as follows: http://example.com/courses/nc/charlotte Where /nc/ (or whatever is inputted/sent) would be accessible as a state variable later on, and the same for /charlotte/ as a city. My code so far is as follows: http://pastebin.com/PNHudKg5 (updated to include suggested code from below, which did not stop the query vars from being stripped). Currently, the `echo '<h2>'.$course->post_title.'</h2>';` works as it is outputted before the rest of WP loads. However, if I move the code from the query parse function to a shortcode, the query params /nc/charlotte disappear off of the url and are inaccessible by my shortcode. Am I missing some function that will keep the query parameters so I can use them on page? It seems like when the page loads, it strips the url, but before the page loads, they are still accessible. Or maybe I'm doing it wrong altogether? I've found so many different ways of using WP's rewrite rules that my head is spinning. WP provides documentation on the functions, but not how to hook them all together to build something with them. Also, I'm using Jan Fabry's Rewrite Analyzer plugin. When I type in http://example.com/courses/nc/charlotte, I get the correct match in the window below. So I know I've got _something_ right. **Updated info:** the shortcode was just a temporary means of executing code on the page. I actually need the page to utilize it's normal query in that it pulls the regular page content. The search results are supposed to be appended after the page content (hence the shortcode, or probably later - a page template). Therefore, I cannot REPLACE the query, I am building a new one, and adding the matched posts to the page in the area designated (again, currently a shortcode in the content; later will be a page template). My setup works awesome currently as I have it setup to use typical GET requests - like example.com/courses/?state=nc&city=charlotte The above url gets posts with meta where custom fields (in this case, state and city) match the city and state in the GET request. My goal is to move this functionality to WP Rewrite rules, like I mentioned above. Hope that makes it more clear.


How to "Global Ignore" / "Hell Ban" someone, restrict post visibility to the author only?

I'm looking for a way to deal with trolls by making any post they make invisible to everyone except them. This is known as a number of names "Global Ignore", "Hell Ban", "Troll Hack", "Tachy Goes to Coventry". How can I do that?


Rewrite vs Redirect from ?p={ID}

WordPress does a 301 from `http://example.com/?p=100` to `http://example.com/post-title/`, but I thought a URL rewrite was different from a redirect and therefore this wouldn't result in a 301. Can anyone clarify?


How to include DW Question & Answer plugin in front page template?

I tried using a shortlink code, but only the link is displaying and it isn't working either.               <?php the_shortlink('http://abc.com/?p=52'); ?>      I am using **DW Question & Answer** plugin and want to show question answer page in my blog. How to do it?


Get Taxonomy Term Title by it's URL

I have a URL - `http://localhost/products/product-name/` and I want to use this URL to retrieve the title `Product Name` This is out of loop, so the URL provided is all I have to work from. `Product Name` is obviously the name of the term, which has the URL `http://localhost/products/product-name/` I just need it so I can print it out on a particular place on the website. The url above denotes the taxonomy as `products` but this is a rewrite of `product_type` - I'm not sure if this'll affect the solution.


How to display only an excerpt of the content with custom post types?

<?php     /*     Template Name: second     */     ?>               <?php get_header(); ?>               <?php query_posts(array('post_type'=>'event')); ?>         <?php if(have_posts()) while(have_posts()) : the_post(); ?>         <div id="post-<?php the_ID(); ?>" class="entry">
<?php the_post_thumbnail('full'); ?>

<?php the_title(); ?>

                 <?php the_content(); ?>                 <?php wp_link_pages(array('before' => '
'.__('Pages', 'cpotheme').':', 'after' => '
')); ?>

         <?php endwhile; ?>               <?php get_sidebar(); ?>     <?php get_footer(); ?>      The page acts like an index.php What should I amend in order to make the title as the link to the full page and make display only an excerpt of the content?


How to Save Different Settings Options Using Settings API and/or the Theme Optimizer

I would like to allow users to save different versions in the options panel using the Settings API and/or the Theme Optimzer. For instance, imagine that I have styled my site using via an admin panel or the theme optimizer. I like how it looks, but I want to experiment with a different look. The problem is that I don't want to lose the work that I have done. What I would like to be able to do is to name and save these styles and be able to reload them later on and use or edit them. Is that possible vis-a-vis the Settings API and/or the Theme Optimizer - and, if so, how could I do that?


Matrix problem with MathJax plugin

My code LaTex matrix is as follows: [latex]\begin{matrix} জাহাঙ্গীর খান\\ কালা জাহাঙ্গীর\\ ৩২\\ বাদল খান\\ নোয়াপুর \end{matrix}[/latex] But the output says: > >     Formula does not parse. >   Even following code is not working. [latex]\begin{matrix} নোয়াপুর \end{matrix}[/latex] I have used Unicode Bangla here as matrix elements.


Wordpress site not redirecting properly

We have developed a wordpress site recently, if i just type http://example.com in browser i will get the site, but if i type www.example.com it is not displaying anything, what happened to it, is there any problem to my htaccess? My site url and homeurl is http://example.com, i have tried with different options in my htaccess badluck, i just want to redirect the www.example.com to http://example.com.