redirect old pages by .htaccess

i want to redirect pages from **sitename/sitename/pagename.html** and **sitemap/sitename/** to               sitemap/sitename/pagename       how i can do that by using . **haccess** file i tried this code RewriteEngine On RewriteBase / RewriteRule . /sitename/index.php [L] RedirectMatch 301 (.*).html$ sitename/$1 and i tired also to add                Redirect 301 sitename/sitename/      but it is not working but i think both not working because it still gives me an error when i open www.sitename.com/pagename.html


wordpress remove views from action links in a custom post

I have created a custom post type, but I want to remove the View link from actions, in the listing of the custom post. I have tried this snippet                  add_filter( 'post_row_actions',array(&$this, 'remove_row_actions', 10, 1));        public function remove_row_actions($action){            unset($action['view']);            return $action;        }      But it throws > `call_user_func_array() expects parameter 1 to be a valid callback, array > must have exactly two members in D:\wamp\www\wordpress\wp- > includes\plugin.php on line 173`


need help looping add_action in wp

i would like to know the proper way to do this               $dynValue=5;//loop this many times     //start of my loop     for ($num=1; $num <= $dynValue; $num++){          //note the incremented number ($num) in the call back     add_action('add_meta_boxes', 'mpc_meta_box_'.$num.');          //below is where im having the problem     // i am trying to increment this function name so i will not get the error that "function name has already been declared". i cannot add '.$num.' in the func name below cause its not valid php.     function mpc_meta_box_'.$num.'(){     //some content     }          }//end of my loop      i can do this with eval() but i know its not recommeneded


Looking for a way to take readers to random post when clicking a link

I did some reasearch but couldn't find a way to do it. Just to be clear I don't want to show a widget list of random posts on the sidebar. I want the ability for reader to click on a link that says "Random Post" and it will take them to a random post from my archive. How would I do it? I am php noob, so working code snippet would be much appreciated.


Same posts from my homepage are on all of my different page

I see that you solved the problem of a WordPress user memo-maritime two years ago "Same posts from my homepage is on all of my different pages".The same problem i have.What should I do?I installed Pagenavi but not working.Theme by default(default.php) is something like this:               <?php endwhile; ?>

<a href="<?php echo get_option('woo_archives'); ?>" class="more"><?php _e('SEE MORE ARTICLES IN THE ARCHIVE',woothemes); ?>

      Now I installed pagenavi and I modified it in blog.php:               <?php endwhile; ?>

          <?php wp_pagenavi(); ?>      and in default.php I left as I mentioned above, nothing happens anyway, I tried.Contrary send me the exactly same page that is repeated on all 3 pages.I tried to fixed many times, but nothing happens,the same..I do not know exactly where would be this issue, maybe it is not there.If I change the theme,works!So the problem is the current theme..this function is repeated somewhere Many Thanks in advance


Using a page as home, how do I prevent nav from setting both home and page links active?

Let's say we have a site with four items in a managed menu, corresponding to pages: > Home | Foo | Bar | Baz The "Home" item is a custom link pointing at "/".   And we want the "Bar" content shown on the home page, so in Settings, we specify that for the front page. When visiting the homepage, both "Home" and "Bar" get active classes, resulting in styling(`.current-menu-item / .current_page_item`) like: > **Home** | Foo | **Bar** | Baz …when it seems reasonable to expect that only Home be highlighted. Did I do something wrong here, or is this actually buggy(or at least sub- optimal) behavior? And is there a relatively painless way to correct it in templating? I can undo the styling pretty easily with a bit of page-targeted CSS, but it's a workaround to the actual problem and I'm curious if there's something I'm missing in the theming.


How to find the page the front page is using?

I use WordPress theme Shiny. I had someone else do my site and now I am trying to figure out how to edit the homepage. The theme version is version 1.0.2. How can I edit my homepage?


How to add an excerpt and read more link to a page?

I've a custom/static "homepage.php" in my templates directory at my WordPress. Now I need to show differents "page excerpts" in my homepage, but I don't know what should be do it. At this moment I've in my "functions.php" de following function:               function excerpt_page() {       add_post_type_support( 'page', 'excerpt' );     }     add_action('init', 'excerpt_page');      With this function, I've in my Page editor a new field available where I can put an summary of the page. Somebody has any idea?


Permalinks not working (404) for the 'item' post type

I have searched various forums and blogs, however I could not find the isuse so far, neither a way to fix it. `item` does not seem to be a wordpress-reserved word. My custom post type registers just fine. I can work with it from admin, edit, delete, preview, assign terms, publish... . However any time I try to visit the permalink (e.g. `http://www.example.com/item/test-item-77/`) it goes to the 404 page! Had someone tried this out with the latest version of WP?


Sorting By Custom Posts With Attachments

I think I've got this figured out and I'd like to make sure I'm not missing anything obvious. My goal is to prioritize a list of results by custom posts with attachments. So, I have a query returning say 60 results and, of those 60, 40 have attachments. I'd like those to show first, then continue with the posts that don't have any attachments. Given the limitations of the "orderby" parameter my method of attack is as follows:   1. Create a custom field ("has_attachment") that is updated "true" if the post has any attachments. Tie the update into an action (e.g. "attachment_fields_to_save").   2. Run a query to set the value to true on posts that already have attachments. I would _like_ to make this bulletproof and go so far as to empty the field in the event that all attachments to the post are deleted. That's not necessary in my use-case, though, as the likelihood is slim. Anyway, I'd like to see if any of you have suggestions for improving my method or ideas for a different way to approach this. Otherwise, I'll get to work!


How to remove custom post type name from base url?

How can I remove custom post type slug from my base url ? for eg : mywebsiteurl.com/custom-post-slug/postname I would like to make it mywebsiteurl.com/postname instead .


How to get post id of last approved comment?

Can you help me with something simple? How can I get the post id of the last approved comment? I want to assign it to a variable. Thanks so much in advance!


Loop not displaying comments_popup_link

I cannot get the `comments_popup_link` to display with the posts retrieved by the foreach loop. Only the title and permalink are displayed. Any idea why the comment link is left out?               <?php       if(count($ids)){         echo '
News

';         foreach($ids as $id){            echo '
'.get_the_title( $id ).'';            if ( comments_open() ) :            echo '
';            comments_popup_link( '', '1 comment', '% comments', '');            echo '
';            endif;         }         echo '

';        }


gallery PHP & CSS

I am creating my own theme, and in order to display a gallery I want to add the PHP to call the gallery, and then use CSS to style it. I am using the plugin from the following site and when i follow the process in the page below I get errors. could someone shed some light on the PHP required to display a gallery within a div so that i can theme it. added to plugin                   <?php         remove_shortcode('gallery');         add_shortcode('gallery', 'parse_gallery_shortcode');          ?>      added to `function.php`                            <?php                  function parse_gallery_shortcode($atts) {                       global $post;                       if ( ! empty( $atts['ids'] ) ) {             // 'ids' is explicitly ordered, unless you specify otherwise.             if ( empty( $atts['orderby'] ) )                 $atts['orderby'] = 'post__in';             $atts['include'] = $atts['ids'];                  }                  extract(shortcode_atts(array(             'orderby' => 'menu_order ASC, ID ASC',             'include' => '',             'id' => $post->ID,             'itemtag' => 'dl',             'icontag' => 'dt',             'captiontag' => 'dd',             'columns' => 3,             'size' => 'medium',             'link' => 'file'         ), $atts));                   $args = array(             'post_type' => 'attachment',             'post_status' => 'inherit',             'post_mime_type' => 'image',             'orderby' => $orderby         );              if ( !empty($include) )             $args['include'] = $include;         else {             $args['post_parent'] = $id;             $args['numberposts'] = -1;         }              $images = get_posts($args);              foreach ( $images as $image ) {                 $caption = $image->post_excerpt;                  $description = $image->post_content;             if($description == '') $description = $image->post_title;                  $image_alt = get_post_meta($image->ID,'_wp_attachment_image_alt', true);                  // render your gallery here             echo wp_get_attachment_image($image->ID, $size);                }     }


Authors Page : A page of authors

I'm looking for a way to create a parent authors page and then use the `author.php` for the individual author pages. I've been out of the loop (no pun) for a couple months and am wondering the best way to do it.


"add from media library" tab is super slow

The add from media tab for wordpress is _super slow_ on my local. It takes at least a full minute for the modal box to load content when I click that tab. I am guessing it is because I have 65 pages of images and WP is loading all 65 pages. Is there a good plug-in or a hack out there to help speed up content loading when adding feature images to posts from the medial library? Thanks.


The Events Calendar Plugin - List View Background Colour Issue

I'm trying to look for some help, I've got a WordPress website that I'm working on. I'm using this plugin called **The Events Calendar** , but in List View, the background keeps showing in transparency... Would somebody be able to help me trigger and find where in the code I can change the background color instead of having it in transparency? Here is the link: http://bit.ly/1cJlC8e


Help on conditional statement to accompany wp_insert_post function please?

I'm trying to programatically insert posts from an external MySQL database as posts on my wordpress blog, I've got something that works, but there is no way of wordpress checking to see if the post already exists before it inserts a new post at the moment, so I'm getting lots of duplicate entries. I'm sure for anyone who knows how, we're talking about some simple conditional if, else statements here, but I can't get my head around what to check for to make sure that the post hasn't already been added to the wordpress database? I've figured its something of a distinction between wp_insert_post and wp_update_post, I just can't figure out what to check against and how I get wordpress to check each entry? Do I need to add some custom_meta data? Or can the conditional statement check against the title or date for example? Really appreciate any help of advice anyone can suggest? Thanks a lot! My code is as follows:                                   if( ) {                              // Create post object                         $post = array();                         $post['post_title'] = $user ." said " . $text;                         $post['post_content'] = "
" . $user . " " . $date .":
" . $text . "

\n";                         $post['post_status'] = 'publish';                         $post['post_date'] = date("jS F Y, G:i.s", $date);                         //$post['post_type'] => 'post';                              // Insert the post into the database                         wp_insert_post( $post );                           }                      else {                         // Update post object                         $post = array();                         $post['post_title'] = $user ." said " . $text;                         $post['post_content'] = "
" . $user . " " . $date .":
" . $text . "

\n";                         $post['post_status'] = 'publish';                         $post['post_date'] = date("jS F Y, G:i.s", $date);                         //$post['post_type'] => 'post';                                   // Insert the post into the database                         wp_update_post( $post );                  }


Is it possible to sort posts by vote using the GD Star Rating plugin?

Anyone has experience using the GD Star Rating plugin? and make a loop that sorts posts by vote/stars?


post_row_actions for custom post type

I'm using this code to have a duplicate post function in WordPress Admin. However, when I add the filter for a custom post type, like this:               add_filter( 'directory_row_actions', 'rd_duplicate_post_link', 10, 2 );      (The Custom Post Type has a registered name of `directory`) - it doesn't add it to the action row underneath the entry title. When I do it for the posts or pages, like this:               add_filter( 'post_row_actions', 'rd_duplicate_post_link', 10, 2 );      it works perfectly. I've been reading that `post_row_actions` has been deprecated but I can't find anywhere that says it's replacement. Does anyone know how to get this working for my Custom Post Type?


Hide page visual editor if certain template is selected?

How do I hide the page editor (WYSIWYG editor) if the current page is set to a certain template. I have the following code already to add in custom meta boxes when certain templates are chosen:               add_action('admin_init','my_meta_init');     function my_meta_init()     {         $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];         $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);              $savemeta = true;              if ($template_file == 'template-page-2quotes.php') {             add_meta_box('main_quote_meta-meta', 'Top Quote', 'main_quote_meta', 'page', 'side', 'low');             add_meta_box('sub_quote_meta-meta', 'Right Hand Side Quote', 'sub_quote_meta', 'page', 'normal', 'low');         } elseif ($template_file == 'template-page-1quote.php') {             add_meta_box('sub_quote_meta-meta', 'Right Hand Side Quote', 'sub_quote_meta', 'page', 'normal', 'low');         } elseif ($template_file == 'template-page-factsnfigures.php') {             add_meta_box('facts_n_figures-meta', 'Amount Raised', 'facts_n_figures', 'page', 'normal', 'low');         } elseif ($template_file == 'template-page-fundraising.php') {             add_meta_box('fundraising_ideas-meta', 'Fundraising Ideas', 'fundraising_ideas', 'page', 'side', 'low');         } else {             $savemeta = false;           }         if($savemeta == true) {             add_action('save_post','my_meta_save');         }     }      What I would like for example is that the editor is removed if `$template_file == 'template-page-2quotes.php'` Edit (Working Code):               add_action('admin_init','my_meta_init');     function my_meta_init()     {         $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];         $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);              $savemeta = true;         $hideeditor = false;              if ($template_file == 'template-page-2quotes.php') {             add_meta_box('main_quote_meta-meta', 'Top Quote', 'main_quote_meta', 'page', 'side', 'low');             add_meta_box('sub_quote_meta-meta', 'Right Hand Side Quote', 'sub_quote_meta', 'page', 'normal', 'low');         } elseif ($template_file == 'template-page-1quote.php') {             add_meta_box('sub_quote_meta-meta', 'Right Hand Side Quote', 'sub_quote_meta', 'page', 'normal', 'low');         } elseif ($template_file == 'template-page-factsnfigures.php') {             add_meta_box('facts_n_figures-meta', 'Amount Raised', 'facts_n_figures', 'page', 'normal', 'low');         } elseif ($template_file == 'template-page-fundraising.php') {             add_meta_box('fundraising_ideas-meta', 'Fundraising Ideas', 'fundraising_ideas', 'page', 'side', 'low');         } elseif($template_file == 'template-page-news.php') {             $hideeditor = true;             $savemeta = false;         } else {             $savemeta = false;           }         if($savemeta == true) {             add_action('save_post','my_meta_save');         }         if($hideeditor == true) {             add_action('admin_print_styles', 'admin_no_editor_style');         }     }     function admin_no_editor_style() {         echo "<style>#postdivrich{display:none;}</style>";     }


Delete associated thumbnails when calling wp_delete_attachment

I have a somewhat straightforward script that allows users to upload their own avatar from the front-end. Another script allows them to delete their avatar, before uploading another. The image/attachment ID for each avatar is stored as user meta. When the user chooses to delete their avatar, I call wp_delete_attachment() like so                   //DELETE AVATAR         if( $_POST['explorer_delete_avatar'] == 'on' ) {             $attachmentID = get_field('explorer_profile_custom_avatar', 'user_'.$userID);             if( wp_delete_attachment($attachmentID, true) !== false ) {                 $user_meta['explorer_profile_custom_avatar'] = '';             }             else {                 $errors[] = 'Could not delete your profile portrait.';             }         }      This properly deletes the original file that was uploaded, but not any of the thumbnails that were generated. I'm seeking the most efficient way to also delete the thumbnails. A few searches didn't reveal anything in the Codex or readily apparent on Google. Something tells me this should be fairly straight-forward. Any suggestions for a fellow hacker? **Here's a bit more on my script's workflow**               <?php     //FORM NOT SUBMITTED, ALLOW UPLOAD     if( !$_POST ) {         echo '<form action="'.get_permalink($post->ID).'" method="post" enctype="multipart/form-data" id="explorerAvatarUpload">';         echo 'Please choose a file for your portrait.';         echo '<input type="file" name="explorer_avatar_src" />';         echo '<input type="submit" name="explorer_portrait_upload_submit" value="Upload Portrait" />';         echo '</form>';     }          if( $_POST['explorer_portrait_upload_submit'] ) {     //UPLOAD SUBMITTED, ADD AS ATTACHMENT     //HANDLE THE UPLOAD         require_once(ABSPATH . 'wp-admin/includes/image.php');         require_once(ABSPATH . 'wp-admin/includes/file.php');         require_once(ABSPATH . 'wp-admin/includes/media.php');         $imgID = media_handle_upload('explorer_avatar_src', 0); //Passed to the crop form as a hidden field              //SHOW THE CROPPER         // Basic implementation of jCrop, ManifestCrop class handles showing the appropriate JS and hidden form fields         echo '
Crop your profile portrait
';         echo 'Drag and drop over the large image to crop.';         $crop = new ManifestCrop($imgID, 110, 110);         $crop->showCropper();     }          //The crop has been designated and dimensions are available     if( $_POST['crop_submit'] ) {         $src_path = get_attached_file($_POST['imgID']);              //Instantiate WP_Image_Editor class for cropping         $img = wp_get_image_editor($src_path);         $img->crop($_POST['crop_x'], $_POST['crop_y'], $_POST['crop_w'], $_POST['crop_h'], 110, 110);         $saved = $img->save($src_path); //We've saved a new image, but it's unattached              //Delete the original upload (uncropped source image)         wp_delete_attachment($_POST['imgID'], true);              //Attach the new image (cropped down to 110x110)         $args = array(         'guid' => $saved['path'],         'post_mime_type' => $saved['mime-type'],         'post_title' => basename($filename),         'post_content' => '',         'post_status' => 'inherit'         );         $imgID = wp_insert_attachment($args, $saved['path'], 0);              //Regenerate the attachment's metadata (for the cropped image)         require_once( ABSPATH . 'wp-admin/includes/image.php' );         $attachment_metadata = wp_generate_attachment_metadata($imgID, $saved['path']);         wp_update_attachment_metadata($imgID, $attachment_metadata);              //UPDATE THE USER META         $prev_avatar = get_user_meta($userID, 'explorer_profile_custom_avatar', true);         $prev_avatar = $prev_avatar ? $prev_avatar : '';         update_field('explorer_profile_custom_avatar', $_POST['imgID'], 'user_'.$userID);     }     ?>


What is the best way to store a few fields?

I'm researching what it would take to develop a custom Wordpress plugin. The plugin is a pretty small one. We just need to persist 2 fields of integer information. It's a pretty basic progress bar with current progress (int) and goal (int). Is there a simple way of storing that amount of information in Wordpress? Is there a simple API for storing things like this in the db? Or, should I just persist by writing to a basic xml or json file on disk? Thanks for any help.


How to: Update live sites theme from version control repo via plugin or library?

Maybe someone knows how i could update my live sites theme from a version control*) project repository. Point is that it's really time consuming if you got your theme hosted with version control _(as an open source project)_ , have a live site that uses the theme and maybe also make it available else where. Normally that means half an hour until you got everything running after you wrote an update/commited something. I've seen it once that a server got a "live" update via a git project, but so far couldn't find out how this would be done. Nice would be if there's a plugin out there that does this already. Libraries or similar are also ok. *) The Q is about Github, Bitbucket, etc. and it also doesn't matter if the solution is git or svn based. Thank you!


Comment reporting for Multisite

I'm trying out the 2 comment reporting plugins that I know about in a multisite installation.   * AJAX Report Comments   * Safe Report Comments Both don't work - various javascript errors and (I assume) not taking into account the differences between single and multisite WP. Does anyone know of a working comment reporting plugin for Multisite, or has anyone run into issues with the above plugins before? [Update] Using Ajax Report Comments   * Clicking on the "Report comment" link correctly opens a textbox.   * Clicking on the "Report comment" button (which should fire off the report) raises the following error in chrome's javascript console              Uncaught SyntaxError: Unexpected token       mysack.onCompletion       runAJAX.xmlhttp.onreadystatechange      The inserted javascript is as follows:


Can a user find a child page?

When editing a page, instead of the expected content, all the user sees is this:               [child-pages depth="1" sort_column="post_title"]      How can the user find that page in order to edit it?


wp_nav_menu remove class and id from li

I'm new to wordpress and trying to learn my way through from making a theme. Right now I am using wp_nav_menu to generate my menu My menu consists of pages and categories However, the default generation of the menu looks like

      I want to remove all the class and id from li and ul. I have been googling for awhile now. Tried different methods and no luck. Any help would be much appreciated. I'm currently using Wordpress 3.1 Thank you in advance!


Widget redirecting to home page

Am trying to create a widget that searches for names. The searching and all that is fine, but when I hit submit, I get returned to the front page. I tried messing with the action="", but no matter what I change it to, the widget still redirects to the home page. Am sure it's simple, I just can't figure out what am doing wrong. Any help is appreciated!                   <?php         require_once('include/functions.php');              if( !defined( 'ABSPATH' ) ) { exit;}             class HNDomainSearchWidget extends WP_Widget         {     function HNDomainSearchWidget()      {         $widget_ops = array(             'classname' => 'HNDomainSearchWidget',             'description' => 'Search for domains on your site.'         );         $this->WP_Widget('HNDomainSearchWidget', 'HobiNom Domain Search', $widget_ops);     }          // admin form, in the widget page     function form($instance)     {         global $wpdb;         (isset($wpdb->base_prefix) ? $_prefix = $wpdb->base_prefix : $_prefix = $wpdb->prefix);           $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );     $title = $instance['title'];         // allow for updating the widget name         ?>
             <label for="<?php echo $this->get_field_id('title'); ?>">Title:              <input class="wide" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" />
         <?php         }          function widget($args, $instance)      {          global $wpdb;         global $post;              $referrer = $_SERVER['HTTP_REFERER'];              // widget sidebar output         extract( $args );         // these are the widget options         $title = apply_filters('widget_title', $instance['title']);         $text = $instance['text'];         echo $before_widget;              // Display the widget         echo '
';              // Check if title is set         if ( $title ) { echo $before_title . $title . $after_title;}              // the actual search get_permalink( $post->ID );          $pid = (isset($post->ID)) ? get_permalink($post->ID) : '';         //echo '<form role="search" method="get" id="domainsearch" action="' . esc_url( home_url( '/' ) ) . '?search_for_domain" >';         echo '<form role="search" method="get" id="domainsearch" action="'. $pid .'" >';         echo '<input type="text" name="domain" value="Domain.com" onfocus="this.value = \'\';" />';         echo '<input type="submit" value="' . __( 'Search' ) . '" name="search_domain" />
';         echo '
</form>';              $this->search_for_domain($_GET['domain'], get_permalink( $post->ID ));              echo $after_widget;     }          // update widget options     function update($new_instance, $old_instance)      {         $instance = $old_instance;         // Fields         $instance['title'] = strip_tags($new_instance['title']);         return $instance;     }          function deactivate()     {          delete_option('HNDomainSearchWidget');         }               // process the widget input and search for domain using     function search_for_domain($search_domain, $permalink)     {         $referrer = $_SERVER['HTTP_REFERER'];              if(isset($search_domain))         {             // get details to access             $hobinom = new hobinom_db();                   $current_user_id = get_current_user_id();             $details = $hobinom->get_details($current_user_id);                  $username = $details['username'];               $password = $details['password'];                   // separate the data from domain and tld             // explode makes each subsequent . a new array, so domain.co.uk is [0],[1],[2] while domain.co is [0][1]             $root_domain = explode(".", $search_domain);             $domain = $root_domain[0];              $tld = substr($search_domain, strrpos($search_domain, ".")+1);                  // access enom api             $url =  '/interface.asp?command=check&sld='.$domain.'&tld='.$tld.                     '&responsetype=xml&uid='.$username.'&w='.$password;                  // Load the API results into a SimpleXML object             $xml = simplexml_load_file($url);                  if(isset($xml->errors))              {                 // print all errors                 function recursive_print($item, $key)                 {                     echo '
'.$item.'

';                 }                 array_walk_recursive($xml->errors, 'recursive_print');             }             else             {                 // Read the results                 $rrpCode = $xml->RRPCode;                 $rrpText = $xml->RRPText;                      // Perform actions based on results                 switch ($rrpCode)                  {                     case 210:                         echo '
'. $xml->DomainName.' is available
';                         break;                     case 211:                         echo '
'.$xml->DomainName.' is not available
';                         break;                     default:                         echo '
Code: '. $rrpCode . ' ' . $rrpText . '
';                         break;                 }             }                    //$this->hobinom_redirect($referrer);         }     }          function hobinom_redirect($permalink)      {         wp_redirect($permalink);     }         }           add_action('widgets_init', array($HNDomainSearchWidget, 'hobinom_redirect'));     ?>


Undefined function error when creating Custom Meta Box

Following this tutorial, I am trying to create a custom Meta Box on my theme by adding following codes to the `function.php` file:               enter code here     add_meta_box( 'my-meta-box-id', 'My First Meta Box', 'cd_meta_box_cb', 'post', 'normal', 'high' );     add_action( 'add_meta_boxes', 'cd_meta_box_add' );          function cd_meta_box_add()     {       add_meta_box( 'my-meta-box-id', 'My First Meta Box', 'cd_meta_box_cb', 'post', 'normal', 'high' );     }          function cd_meta_box_cb()       {         echo 'What you put here, show\'s up in the meta box';          }        but I am getting following error : ![fatal error](http://i.stack.imgur.com/OSagi.png)               ( ! ) Fatal error: Call to undefined function add_meta_box() in C:\wamp\www\TMPress\wp-content\themes\twentytwelve\cpt.php on line 94     Call Stack     #   Time    Memory  Function    Location     1   0.0012  865440  {main}( )   ..\edit.php:0     2   0.0018  982824  require_once( 'C:\wamp\www\TMPress\wp-admin\admin.php' )    ..\edit.php:10     3   0.0021  1008744 require_once( 'C:\wamp\www\TMPress\wp-load.php' )   ..\admin.php:30     4   0.0023  1026872 require_once( 'C:\wamp\www\TMPress\wp-config.php' ) ..\wp-load.php:29     5   0.0029  1158248 require_once( 'C:\wamp\www\TMPress\wp-settings.php' )   ..\wp-config.php:90     6   0.3251  32951888    include( 'C:\wamp\www\TMPress\wp-content\themes\twentytwelve\functions.php' )   ..\wp-settings.php:291     7   0.3255  32979176    include_once( 'C:\wamp\www\TMPress\wp-content\themes\twentytwelve\cpt.php' )    ..\functions.php:2      Can you please let me know why this is happening? is there any better way to add a meta box containing a field and dropdown select box? I know there are some plugins out there for doing this but I really like to learn it on my own.


Taxonomy term archive default loop returns 1 record instead of 8

I have a Custom Post Type called "book" and a custom taxonomy for this CPT called "books". One term's slug of this taxonomy is "accepting-yourself". Here's the code of the "accepting-yourself" archive page (URL: my_site/books/accepting-yourself/):               if ( have_posts() ) :          while ( have_posts() ) : the_post();          echo get_the_title();         endwhile;     endif;      This should return all the "book" posts in custom taxonomy "books", that's 8 posts. Instead it returns only one. Just in case here's the code defining my custom post type and custon taxonomy:               /*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------      CUSTOM POST TYPE : BOOK     -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/          function my_custom_post_book() {         $labels = array(             'name'               => _x( 'Books', 'post type general name' ),             'singular_name'      => _x( 'Book', 'post type singular name' ),             'add_new'            => _x( 'Add New', 'book' ),             'add_new_item'       => __( 'Add New Book' ),             'edit_item'          => __( 'Edit Book' ),             'new_item'           => __( 'New Book' ),             'all_items'          => __( 'All Book' ),             'view_item'          => __( 'View Book' ),             'search_items'       => __( 'Search Book' ),             'not_found'          => __( 'No books found' ),             'not_found_in_trash' => __( 'No books found in the Trash' ),              'parent_item_colon'  => '',             'menu_name'          => 'Books'         );         $args = array(             'labels'        => $labels,             'description'   => 'Holds our books specific data',             'public'        => true,             'menu_position' => 4,             'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'custom-fields'),             'has_archive'   => true,         );         register_post_type( 'book', $args );         }     add_action( 'init', 'my_custom_post_book' );          function my_updated_messages_book( $messages ) {         global $post, $post_ID;         $messages['book'] = array(             0 => '',              1 => sprintf( __('Book updated. View book'), esc_url( get_permalink($post_ID) ) ),             2 => __('Custom field updated.'),             3 => __('Custom field deleted.'),             4 => __('Book updated.'),             5 => isset($_GET['revision']) ? sprintf( __('Book restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,             6 => sprintf( __('Book published. View book'), esc_url( get_permalink($post_ID) ) ),             7 => __('Book saved.'),             8 => sprintf( __('Book submitted. Preview book'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),             9 => sprintf( __('Book scheduled for: %1$s. Preview book'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),             10 => sprintf( __('Book draft updated. Preview book'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),         );         return $messages;     }     add_filter( 'post_updated_messages', 'my_updated_messages_book' );               /*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------      CUSTOM BOOK TAXONOMY     -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/          $labels = array(         'name'                          => 'Books',         'singular_name'                 => 'Book',         'search_items'                  => 'Search Books',         'popular_items'                 => 'Popular Books',         'all_items'                     => 'All Books',         'parent_item'                   => 'Parent Book',         'edit_item'                     => 'Edit Book',         'update_item'                   => 'Update Book',         'add_new_item'                  => 'Add New Book',         'new_item_name'                 => 'New Book',         'separate_items_with_commas'    => 'Separate Books with commas',         'add_or_remove_items'           => 'Add or remove Books',         'choose_from_most_used'         => 'Choose from most used Books'         );          $args = array(         'label'                         => 'Books',         'labels'                        => $labels,         'public'                        => true,         'hierarchical'                  => true,         'show_ui'                       => true,         'show_in_nav_menus'             => true,         'args'                          => array( 'orderby' => 'term_order' ),         'rewrite'                       => array( 'slug' => 'books', 'with_front' => false ),         'query_var'                     => true     );          register_taxonomy( 'books', 'book', $args );


Custom Meta Data is not being saved

I have created a custom meta box using following link in wordpress 3.0:   http://farinspace.com/how-to-create-custom-wordpress-meta-box/ I am using same code and custom meta data is not being saved. I get blank textbox in custom meta box each time. Please let me know what to do.


I can't modify the 'Continue reading...' link of the_excerpt

I just placed this in my `functions.php` (I'm using Wordpress 3.0.4):               function new_excerpt_more($more) {            global $post;         return 'ID) . '">Read the Rest...';     }     add_filter('excerpt_more', 'new_excerpt_more');      But my post is still displaying `… Continue reading` Any suggestions?


Page Templates automatically showing index page contents?

So I'm taking my first foray into creating a wordpress page template. I created a .php file with the following contents:               <?php     /*     Template Name: Download Page Template     */     ?>      Then I created a page in the page editor and assigned it to use the "download page template". However, when I preview this page, all I see is the home/index page ... I tried a few of the samples from the codex, but all that happened is that my content from the wp editor showed up at the very bottom of the index page. Am I missing something obvious?


WP 3.0.5 - Custom posts matching 2 taxonomies

I'm running a WP 3.0.5 website and here is my problem: I define a custom post type with 2 custom taxonomies and I've got to develop a search engine based upon these taxonomies. Until there, no problem :               $args = array(              'my_post_type' => 'post_type_name',              'my_taxo_1' => 'taxo-1-slug',              'my_taxo_2' => 'taxo-2-slug'     );          query_posts( $args );      Working like a charm! But... What I want is to retrieve only custom posts matching both taxonomies whereas here, only 1 is sufficient. I saw WP 3.1 is introducing a new way dealing with taxonomies (http://codex.wordpress.org/Function_Reference/query_posts#Taxonomy_Parameters) which will absolutely solve my problem but WP 3.1 is still in beta and I can't take risk for my customer. Thanks for your help !


the_excerpt is not limiting my post page to 55 words?

Wordpress states the following: > An excerpt is a condensed description of your blog post and refers to the > summary entered in the Excerpt field of the Administration > Posts > Add New > SubPanel. The excerpt is used to describe your post in RSS feeds and is > typically used in displaying search results. The excerpt is sometimes used > in displaying the Archives and Category views of your posts. Use the > Template Tag the_excerpt() to display the contents of this field. Note that > if you do not enter information into the Excerpt field when writing a post, > and you use the_excerpt() in your theme template files, WordPress will > automatically display the first 55 words of the post's content. I wrote a post of 164 words. And placed this into my posts page:
                 <?php // Create custom loop                 $custom_posts = get_posts('post_type=page_content&page_sections=Content (Front Page)'); ?>                 <?php foreach( $custom_posts as $post ) : setup_postdata( $post ); ?>

<?php the_title(); ?>
                         <?php the_excerpt(); ?>
                 <?php endforeach; ?>                 <?php wp_reset_query(); ?>
      I'm still seeing 164 words in that post. EDIT: This is what I've written in the post:               Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.          Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.          Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.          Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat      . I tried exceeding 55 words in other post and it is the same story. Any suggestions?


How to debug | Some times the "Save Draft" button seems to spin but does not actually save

I am using wordpress 3.5.1 and lately there seems to be a recurring problem with the save draft function where it seems like the draft was saved (i.e the wheel finishes spinning without an error message) but alas, all edits are lost. This happens both in the regular editor as well as in the distraction free wring space (where it is extremely frustrating, as all edits are lost when returning to the regular editing mode). I couldn't find a discussion about this problem in the other forums or any instructions on how to debug this or find the source of the problem. Any help will be much appreciated.


How to establish site-wide fields with my theme?

I have been searching high and low and cannot seem to find a plugin/implementation for wordpress which allows for site wide values to be set and used (in places such as header/footer). Any help much appreciated **EDIT** Sorry I might not have been clear enough. What I am wanting to do is have fields which can be set in the backend and displayed site wide such as a phone number in the footer. Thanks


Forum-esque Post Count User Ranks (Without Buddypress)

My client is looking for a ranking system similar to a forum. As your post count goes up, your "title" changes. I think Buddypress offers something along these lines but we're at the end stage and he doesn't want to take the extra time to let me convert it to a buddypress system. Are there other plugins that can do this? Or maybe someone can suggest some code to use with User Role Editor? Thanks


Permalinks not working using wordPress Networking with custom post types

Hay All, I've setup a WordPress network and have a couple of websites. Within these 'sub-websites' have a created a new custom post type called 'courses'. When i create a new 'course' a sample permalink would be www.mysite.com/site1/course/my-course-name However, this doesn't link to the article in the question. Is this a normal error with wordpress? How, can i fix this? I think there's an issue with the .htaccess file WP generated for me.


Debugging WP routing

For some posts, I see 404 page, even though posts exist, where is the place in WP where using permalink is decided what object needs to rendered? Thanks!


Plugin for custom sort order for categories?

I'd like to employ a sort order option in my theme to allow categories to be sorted similar to pages. Can anyone recommend a plugin that does this?


And/Or Category Query

I'm having a lot of trouble using php query_posts(array('category__and'=>array(1,3))) - it seems to be pulling anything that's in category 1 regardless of whether it's also in category 3 and I only want the posts if they exist in both categories. And ultimately, I need a bunch of OR statements anyway, so is there a better way than query_posts to do this? I want a page of posts that exist in a variety of multiple categories -- i.e: categories 1 AND 3 OR categories 1 AND 5 OR categories 1 AND 6 But not categories 1 AND 4 Any help would be greatly appreciated. Thanks.


wp_redirect and current_user_can issues

Put simply, I'm trying to redirect the user after clicking a 'Save Changes' button. The plugin uses custom capabilities, and so I want to check the current user has the correct capabilities before progressing with the save and redirect afterwards. However, bit of a dilemma. I have tried loading the function that carries out what is mentioned above using 'admin_init' and 'admin_menu'. Using 'admin_init', throws an undefined function error for the 'current_user_can' function, which makes sense since it hasn't been loaded yet (and is well documented in other help topics). The redirect works fine (using wp_safe_redirect). On the other hand, using 'admin_menu' allows the 'current_user_can' function to work, but the redirect doesn't. This is because the headers have already been sent. Is there a way to have both functions working in either actions 'admin_init' or 'admin_menu'? Thanks in advance.


Pagination: Keep prev and next link even on the first/ last page

On my `index.php` I'm using 'paginate links'. I want to make a pagination where you have a button for previous, than the page numbers and then a button for next, like:               < PREVIOUS  1  2  3  4  [5]  6  7  8  9  NEXT >      When the user is on the first page the button for 'previous' must be unclickable and must have another background color than normal. The problem here is that, when I'm on the first page the whole 'previous' button disappears(same on the next page), so that makes it impossible for me to look if it has a different class so I can give it a different styling... So what I'm wondering is:   1. How to make the Previous and Next button appear on every page (even on the first and last page)?   2. If they appear, how do I remove the link from the previous button when I'm on the first page (and from the next button on the last page of course) My pagination code is:               <?php echo paginate_links( array(         'base' => str_replace( 999, '%#%', get_pagenum_link( 999 ) ),         'format' => '?paged=%#%',         'current' => max( 1, get_query_var('paged') ),         'total' => $wp_query->max_num_pages,         'prev_text'    => __('
vorige
'),         'next_text'    => __('
volgende
')     ) );     ?>


Custom Post Type Archive Page: Set Posts Per Page, Paginate

I have a custom post type called `video`. Would like to paginate its archive page, showing **only 3 posts** on each page. There is also a custom loop on the archive page that outputs **all** the video posts (for a thumbnail gallery). This is the `archive-video.php`:               <?php while( have_posts() ) : the_post(); ?>         MAIN LOOP...     <?php endwhile; wp_reset_query(); ?>          <?php next_posts_link(); previous_posts_link(); >          <?php $custom_loop = new WP_Query( array('post_type' => 'video', 'posts_per_page' => '-1' ) );     <?php while ( $custom_loop->have_posts() ) : $custom_loop->the_post(); ?>         CUSTOM LOOP...     <?php endwhile; ?>      I've tried to set the `posts_per_page` to 3 using `pre_get_posts` (code here). The pagination would work perfectly, but the custom loop now outputs only 3 posts and not all the posts! Anyone with a hard-coded/non-plugin solution? Have been googling to no avail... Any advice/help would be most appreciated!!!


How do you categorize pages?

I am an experienced Drupal developer who is just getting stuck into Wordpress. For a selected number of pages on a new wordpress build, I need to add them into a category, then add this category block to a page that shows the different categories (selecting them will act as a filter). In drupal this would involve create a custom content type, a taxonomy and a views block etc. How can the same be achieved in wordpress? I know that I can create a sidebar and drop a widget into it. But I am struggling to workout how to create the block to drop into there and categorize these pages.


WordPress function that makes HTML safe to be sent via AJAX request

What is correct way to send HTML back to an AJAX request in WordPress? I currently have this:               add_action( 'wp_ajax_nopriv_get-location-info', 'sc_locations_get_location_info' );     add_action( 'wp_ajax_get-location-info', 'sc_locations_get_location_info' );     function sc_locations_get_location_info() {         $nonce = $_POST['nonce'];         if ( ! wp_verify_nonce( $nonce, 'get-location-info-nonce' ) ) {             $response = json_encode( array( 'success' => false, 'error' => "Failed nonce check" ) );         } else {             $response = json_encode( array( 'success' => true, 'HTML' => '...LOTS OF WONDERFUL HTML...' ) );         }         header( "Content-Type: application/json" );         echo $response;         exit;     }      Now I'm currently just using `json_encode()` but should I be doing anything else to the HTML? The HTML generated can be trusted so no stripping would need to take place.


wp E-commerce featured product plugin with muliple option?

I'm Using E-commerce featured product plugin.in this plugin we have a options to select a single product from product list but not able to select multiple options at same time. * * * so any suggest to improve this plugin?


How to loop through each user id?

The functions that I am aware of:               WP_User      and               wp_get_current_user      seem to only get the user object of the current user. As an administrator, if I want to display certain profile information in a table from each user, how can I loop through the ids? Can this be done with WP template tags or should I resort to SQL? Thanks in advance


2nd button row from WP Super Edit or TinyMCE Advanced doesn't show to 2nd admin

I'm currently using WP Super Edit. But the same problem persists with TinyMCE Advanced. This is how it is configured: http://i.imgur.com/4PyXi.png http://i.imgur.com/YniBi.png http://i.imgur.com/7MytG.png This is how I (admin) see it: http://i.imgur.com/OAdnF.png This is how my friend (2nd admin) sees it: http://i.imgur.com/mfUMq.png I'm getting desperate figuring out why the hell the 2nd button bar doesn't show.


Conditionally Loading JavaScript/CSS for Shortcodes

I released a plugin that creates a shortcode and requires a JavaScript file and a CSS file to load on any page that contains that shortcode. I could just make the script/style load on all pages, but that's not the best practice. I only want to load the files on pages that call the shortcode. I've found two methods of doing this, but both have problems. Method 1 sets a flag to true inside the shortcode handler function, and then checks that value inside a `wp_footer` callback. If it's true, it uses `wp_print_scripts()` to load the JavaScript. The problem with this is that it only works for JavaScript and not CSS, because CSS should be declared inside `<head>`, which you can only do during an early hook like `init` or `wp_head`. Method 2 fires early and "peeks ahead" to see if the shortcode exists in the current page content. I like this method much better than the first, but the problem with it it won't detect if the template calls `do_shortcode()`. So, I'm leaning towards using the second method and then trying to detect if a template is assigned, and if so, parse it for the shortcode. Before I do that, though, I wanted to check if anyone knows of a better method. **Update:** I've integrated the solution into my plugin. If anyone is curious to see it fleshed out in a live environment you can download it or browse it. **Update 2:** As of WordPress 3.3, it's now possible to call `wp_enqueue_script()` directly inside a shortcode callback, and the JavaScript file will be called within the document's footer. That's technically possible for CSS files as well, but should be considered a bad practice because outputting CSS outside the `<head>` tag violates W3C specs, can case FOUC, and may force the browser to re-render the page.


Complex widget form UI - examples and best practices

I'm contemplating a widget with quite a number of options, which will make for a lengthy widget form. To improve the user experience with this form, I'd like to divide it into sections. I don't feel like re-inventing the wheel, so what are some examples of widgets that have fairly complex forms (especially those which are divided into multiple sections) **all the while remaining usable and easy to parse visually**? I should add that I'm looking for examples that could be considered "best practices", _not messy kitchen sink forms that are difficult to use_. I realize this is probably subjective. Thanks for your input!


Customizing the wordpress tag-cloud output

I'm using a little function below to list out the post_terms. The function is outputting very specific markup for the grouping, filter, and href attributes (this is a term selector for the jQuery isotope plugin).               $terms = get_terms("post_tag");     $count = count($terms);      if($count > 0){         echo '
';         echo '
Post Tags
';         echo '
';         echo '
any';         foreach ($terms as $term) {             echo '
slug.'" data-group="tag" data-filter=".tag-'.$term->slug.'">'.$term->name.'';                 }         echo '
';         echo '
';      }      Question: Given the requirements above where each term has it's own custom href, data- group, data-filter, how would I go about changing this list format into a tag cloud with my requirements? (an ordered list of terms is way to long for use within a sidebar, hence a tag cloud would work much better when using terms as a selector) I did look through the codex, but didn't see any examples on how to modify the output of the tag cloud. thanks


Conditonal statement for iPad

I need to hide the branding section of my blog, but only when someone is viewing it from the iPad. I am not sure how to attack this. EDIT: the function `remove_access` currently works in my template, but I need to add the iPad function. So would this look correct for trying to hide the area:               <?php      function remove_access() {      if(is_page(array(63, 386, 391, 405, 'forums'))) {         remove_action('thematic_header','thematic_blogtitle',3);         remove_action('thematic_header', 'thematic_blogdescription',5);         remove_action('thematic_header', 'thematic_brandingclosing',7);         remove_action('thematic_header','thematic_access',9);         remove_action('thematic_footer','thematic_siteinfoopen',20);         remove_action('thematic_footer','thematic_siteinfo',30);       }     }     if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT']) ){         add_action('template_redirect', 'remove_access');     }      EDIT-3: the complete function changed the condition to: if (it's an iPad AND page is blog) OR (if it's one of the pages in array), then remove items.               <?php     function remove_access() {         if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT']) && is_page('blog') || is_page(array(63, 386, 391, 405, 'forums')) ){             remove_action('thematic_header','thematic_blogtitle',3);             remove_action('thematic_header', 'thematic_blogdescription',5);             remove_action('thematic_header', 'thematic_brandingclosing',7);             remove_action('thematic_header','thematic_access',9);             remove_action('thematic_footer','thematic_siteinfoopen',20);             remove_action('thematic_footer','thematic_siteinfo',30);         }     }          add_action('template_redirect', 'remove_access');      EDIT-4: Add a function to remove from child pages as well. I tried this, but it doesn't seem to work:               function remove_access() {     if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT']) && is_page('blog') && ($post->post_parent == 'blog') || is_page(array(63, 386, 391, 405, 'forums')) && ($post->post_parent == (63, 386, 391, 405, 'forums')) ){         remove_action('thematic_header','thematic_blogtitle',3);         remove_action('thematic_header', 'thematic_blogdescription',5);         remove_action('thematic_header', 'thematic_brandingclosing',7);         remove_action('thematic_header','thematic_access',9);         remove_action('thematic_footer','thematic_siteinfoopen',20);         remove_action('thematic_footer','thematic_siteinfo',30);       }     }          add_action('template_redirect', 'remove_access');


What are the differences between custom post type and custom page templates?

What is the difference between custom taxonomies and page templates and custom post types? I think I understand that taxonomy is used to organize data. CPTs are used to give your data a different design. but can't a template be used instead of CPT? or are they used in combination? and can't categories be used instead of creating additional taxonomies? i guess are CPT's and custom taxonomies just tools to make life easier or do they serve a purpose that could not be achieved without them? I have been creating new templates for any page the needs a different look or any page that uses a specific category. have i been doing this wrong or poorly? instead of having 7 templates should i have 7 CPT's or something like that?


What is the most secure way to store post meta data in WP?

Sony's recent security "holes" showed how unsafe it can be to store data unencrypted. As some of you may know, I 'm working on re-releasing the free CRM theme Driftwood. What is the most secure way to store sensitive (ie non-public information) post meta in the database?


Using <!--more--> tag to output text in Genesis?

here's what i'm trying to achieve! HTML:               some text          some text      when post is loaded:               some text     MY TEXT WHICH WAS ADDED TO THE MORE TAG     some text      on my old WP site, i used this to have a banner displayed on posts exactly where the tag was inserted. unfortunately, i can't get this to work in Genesis. here's the code which was added to functions.php on my old website:               function adsense_added_at_more_tag($text) {     if( is_single() ) :     $ads_text = 'BANNER GOES HERE';     $pos1 = strpos($text, '<span id="more-');     $pos2 = strpos($text, '', $pos1);     $text1 = substr($text, 0, $pos2);     $text2 = substr($text, $pos2);     $text = $text1 . $ads_text . $text2;     endif;     return $text;     }      any ideas on how to get this to work in Genesis? i got some great tips from Brad who suggested the following code:               add_filter( 'the_content_more_link', 'read_more_link' );     function read_more_link() {     if ( is_single() ) {     echo '
Add Your Banner HTML Here
';         }     }      i've tried adding this to functions.php in Genesis, but nothing happens. the "Add Your Banner HTML Here" text doesn't appear in the post. i've explored various code examples online and tried tweaking the code pasted above with my (it's safe to say) non-existant PHP skills without success. can anyone figure out how to modify the code to show text in a single post in Genesis?


Retrieve the template directory URI via global or get_template_directory_uri() every time?

One Wordpress function I happen to use frequently is `get_template_directory_uri()`. While I tried to minimize or avoid its use where I can, I still happen to have more than one call to this function in certain pages across my theme. Most of the time in a series of href or inside other functions (for which I normally put the URI resulting from `get_template_directory_uri()` in a `$variable` - however I still find that I might have to store again that variable in a different php file). I wonder, would it be best if I store the returning value (my theme URI) in a global and use echo the global when I need it in different parts of my theme php files? I'm still learning my way to best practices and uses of variables and globals. Thank you


Filter Shortcodes when using get_page

I'm using the following line to show content from one page on another. This line outputs the content's raw text of a shortcode:               <?php $id=3934; $post = get_page($id); $content = apply_filters('the_content', $post->post_content); echo $content;  ?>      How can I add to or filter this snippet to allow the shortcodes from said page to fully display, rather than outputting raw [/tab] text?


Formatting error while publishing theblog from Microsoft Word

I am trying to publish a blog post into wordpress based website from Microsoft Word. Here is the sample text that I added in Microsoft which I published as well. > " Temporary Blog Post > > I am adding a temporary blog post here Let’s see how it goes > > Thanks" However, when I published the post, this is how it looked > /pI am adding a temporary blog post here > > /ppLet’s see how it goes > > /ppThanks Any idea the reason behind the formatting error. I thought, when you publish from Microsofot word or Microsoft Live Writer, I was thinking, when published it looks the same as in the Microsoft Word. Thanks Kiran


Installing jQuery plugin to wordpress theme (Incredible)

Ok so here is the plugin in question  I'm trying to integrate it on the homepage of my wordpress theme (incredible bought from themeforest) After reading up on wordpress enqueue script and all that stuff i want to do it the right way from the start. **functions.php snippet:** i just added 2 lines here, one to register my script "contenthover" the other to enqueue. Also i tried adding `array('jquery'));` to make sure its dependent on jquery but that only produced a parse/syntax php error               if (!function_exists('pp_scripts')) {         function pp_scripts() {                  wp_register_script('flexslider', get_template_directory_uri() . '/js/flexslider.js');             wp_register_script('isotope', get_template_directory_uri() . '/js/jquery.isotope.min.js');             wp_register_script('ender', get_template_directory_uri() . '/js/ender.min.js');             wp_register_script('carousel', get_template_directory_uri() . '/js/carousel.js');             wp_register_script('tooltip', get_template_directory_uri() . '/js/tooltip.js');             wp_register_script('popover', get_template_directory_uri() . '/js/popover.js');             wp_register_script('effects', get_template_directory_uri() . '/js/effects.js');             wp_register_script('twitter', get_template_directory_uri() . '/js/twitter.js');             wp_register_script('imagebox', get_template_directory_uri() . '/js/imagebox.min.js');             wp_register_script('contenthover', get_template_directory_uri() . '/js/jquery.contenthover.js');             wp_register_script('custom', get_template_directory_uri() . '/js/custom.js');                  wp_enqueue_script('flexslider');             wp_enqueue_script('custom');             wp_enqueue_script('isotope');             wp_enqueue_script('ender');             wp_enqueue_script('imagebox');             wp_enqueue_script('carousel');             wp_enqueue_script('twitter');             wp_enqueue_script('tooltip');             wp_enqueue_script('popover');             wp_enqueue_script('effects');             wp_enqueue_script('contenthover');              }         add_action('wp_enqueue_scripts', 'pp_scripts');     }      Next is the initialization code where i experimented with to make work, it didn't work when inserted in the _header.php_ or _footer.php_ or _template- homepage-xxx.php_ . Although as far as i know, it should work if its included in any of those files, its just not the "best practice" way of doing things to keep things clean. The theme already has a custom.js file loaded so i thought the best way would be to initialize it from there **so here is the custom.js snippet:** it already contains many small snippets of code for carousels/effects..etc.etc. I've tried using the standard $(), as well as jQuery()               var $j = jQuery.noConflict();     $j(document).ready(function () {     $j('.d1').contenthover({         effect:'slide',         slide_speed:300,         overlay_background:'#000',         overlay_opacity:0.8     });     });      **Errors and outputs:**   1. With $() i get is undefined error in firebug console.   2. With jQuery() and $j()i get Error: Permission denied to access property 'toString' on firebug console. not sure if thats related.   3. Ive experimented with the sequence of scripts hoping that maybe its an issue related to the scripts being loaded in the wrong sequence, but no luck there.    4. My last consideration would have to be lookin into the jquery.contenthover.js file it self to see if there are any conflicts that could arise with wordpress? would that be a wise thing to try and wrestle with?   5. I'm sure this effect can be done vanilla and maybe with some clever CSS3 but i'm new to wordpress and want to figure the ins and outs so i can install custom scripts later on.  So thanks in advance, if there is anything thats unclear, or scripts you'd like to see. or perhaps a live example, just let me know. I would appreciate anything just a push in the right direction. Thanks all for your time.


Any disadvandages if I style the wordpress align classes without img and .wp-caption prefix

In various WordPress themes the margins are only applied to elements when they are images or captions               /* Images */     .alignleft {         float: left;     }          .alignright {         float: right;     }          .aligncenter {         display: block;         margin-left: auto;         margin-right: auto;     }          img.alignleft {         margin: 5px 20px 5px 0;     }          .wp-caption.alignleft {         margin: 5px 10px 5px 0;     }          img.alignright {         margin: 5px 0 5px 20px;     }          .wp-caption.alignright {         margin: 5px 0 5px 10px;     }          img.aligncenter {         margin: 5px auto;     }          img.alignnone {         margin: 5px 0;     }      This is taken from the 2013 Theme. I coded a plugin and used this align classes to float the content. Now It looks ugly because the margins are only applied to images and wp-captions. So I have to add my own margins. My question is now why they to it this way. Why do they not give the bases classes some base margins? What elements do they want to float without margins? I am asking for theme purposes, I use bootstrap which comes with `.pull-left` and `.pull-right` already that do nothing but float. So I not really need this classes for floating without margins. But maybe there is a good reason I should do it the way they do? I mean base margins could still be overwritten if needed so why?


How can i list current author's categories?

My Code getting authors written post categories but just 2 ID has author lists category.. I replace `$current_user->ID` but it is not worked.               <?php         $categories = $wpdb->get_results("             SELECT DISTINCT(terms.term_id) as ID, terms.name, terms.slug             FROM $wpdb->posts as posts             LEFT JOIN $wpdb->term_relationships as relationships ON posts.ID = relationships.object_ID             LEFT JOIN $wpdb->term_taxonomy as tax ON relationships.term_taxonomy_id = tax.term_taxonomy_id             LEFT JOIN $wpdb->terms as terms ON tax.term_id = terms.term_id             WHERE 1=1 AND (                 posts.post_status = 'publish' AND                 posts.post_author = '2' AND                 tax.taxonomy = 'category' )             ORDER BY terms.name ASC         ");         ?>
             <?php foreach($categories as $category) : ?>
                 <a href="<?php echo get_category_link( $category->ID ); ?>" title="<?php echo $category->name ?>"><?php echo $category->name ?>
             <?php endforeach; ?>


Cloudflare's Rocket Loader + Wordpress -> Ignore scripts?

I'm trying to make Cloudflare's Rocket Loader work on my WP site. Everything works fine except for the WP Visual Editor. I followed the advice here but it doesn't work: How do I add custom attributes to javascript tags in Wordpress? Cloudflare says that in order to make Rocket Loader ignore a javascript file I need to add the data-cfasync="false" tag before my script:               <script data-cfasync="false" src="/javascript.js"></script>          https://support.cloudflare.com/entries/22063443--How-can-I-have-Rocket-Loader- ignore-my-script-s-in-Automatic-Mode- Rocket loader doesn't ignore my JS files. Here's my code:               function rocket_loader_attributes( $url )     {     $ignore = array (          'http://www.mysite.com/wp-includes/js/tinymce/tiny_mce.js?ver=349-21274',     'http://www.mysite.com/wp-admin/js/editor.js?ver=3.4.2'          );     if ( in_array( $url, $ignore ) )     { // this will be ignored     return "$url' data-cfasync='false";     }          return $url;     }     add_filter( 'clean_url', 'rocket_loader_attributes', 11, 1 );      What is wrong with my code? I'm currently using Rocket Loader on Automatic mode. Can anyone help? @toscho if you see this maybe you can point me in the right direction. Thank you.


Disable Link to Post from Showing Up in Post's Comments?

When I link to a another post in one of mine, is there a way for it not to show up in that entry's comments? Very small, new blog at the moment... I honestly just don't want all the exposure from being in a big blog's comments


how to display page title only for child category pages

I apologize if this is a dumb question, but I am just learning PHP and Wordpress. It's probably very simple. I have a site where the top-level nav is all parent categories, with the child categories as dropdowns. The pages are all pulling from category.php. On the child category pages, I would like to display the current child category page title (single_cat_title, I think) for styling, but I want to exclude this feature on the parent category pages. I've been trying to write this very simply using get_the_category() as per this example in the codex: `$category = get_the_category(); echo $category[0]->cat_name;` Any help is greatly appreciated.


Open Source replacement for WPML?

Since WPML is not free anymore and still one of the most used Wordpress Translation Plugins, is there an open source project that keeps development going? Or something similar that replaces it? I know there are other alternatives out there, but most have different approaches or features. I for example like the fact, that every translation is in it's own post.


Template plugin for blog posts?

can someone recommend a plugin to do the following? My wordpress CMS has two types of users: administrator and editor, both of whom are not technologically savvy, so they need things to be super simple. The administrator wants to be able to create a re-useable template in the CMS that editors can use for their posts. As an example, an administrator can create a template along the lines of               Welcome to the ________.     We are hosting our event at __________.     Buy your tickets for ______ dollars.      The editor can then login to the CMS, create a new blog post and import the template above and fill out the 3 underlined areas. We want things to be a little more complex by giving the administrator the ability to add images, styling, and fields to record form registrations (form submissions get recorded to wordpress database). What wordpress plugin comes closes to achieving the above results?


Editing the loop for Author pages

I was wondering if anyone can help me out. I am looking to remove the_content part of the loop on **my author pages only**. So basically, I just want a list of the author posts with only the title and meta instead of the full post. When I went to the author.php file, I found this, which I believe is the code that is generating the posts on the Author Pages.               /* Run the loop for the author archive page to output the authors posts      * If you want to overload this in a child theme then include a file      * called loop-author.php and that will be used instead.      */          get_template_part( 'loop', 'author' );      I'm pretty new at this, so please bare with me. My question is, how I do I remove the content from the loop for only the Author pages. I wouldn't think that I should remove the function that generates the content from the loop.php file because that would remove it from all posts on my site. The comments above say, If I want to overload this in a child theme, the include a file called loop-author.php. Can I simply copy all the code from the loop.php file into a new loop-author file, remove the function that generates content from there? Would i have to change any of the parameters in the get_template_part() function? Again, really new at doing this, so any advice would be greatly appreciated. Thanks a lot.


Morris.js for Wordpress?

I found Morris.js to be a delightfully implemented charting script, and wanted to include it in my Wordpress installation. But I have never included a js file with my blog before, and would appreciate if someone can guide me on this:   1. How do I include the javascript file?   2. Where do I upload it on the server?   3. Anything else I need to know to use it? Thanks.


stop the_permalink printing and save as variable?

Is there a way i can get the_permalink as a variable? I need to build an info window with it but it wont appear in the $infoWindow variable...               <?         $link = the_permalink($post->ID); // prints out into html         $infoWindow = '

'.$post->post_title.'

';     ?>              best, Dc


Custom folder structure and problem with 3rd party services

First off, I've customised my WordPress folder structure a bit: ![enter image description here](http://i.stack.imgur.com/Zcnul.png) wordpress/ contains all the files a fresh WordPress install does (wp-admin, wp-includes, etc) The problem I'm facing is that a couple of third-party services can't seem to "interact" with WordPress this way (for example: editorially.com, ifttt.com). They either fail to authorise or give the following error:               Someone may be trying to trick you into giving them access to your site.      Or it could be you just encountered a bug :). Either way, please close this window.      I've tried symlinking wp-admin.php and wp-admin/ to my web root but that doesn't fix it. Any advice on how this could be solved or how I could further troubleshoot this? ----- EDIT ---- My wp-config was modified as below:               define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/wordpress');     define('WP_HOME',    'http://' . $_SERVER['SERVER_NAME']);          define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content');     define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/wp-content');      And my index.php file looks like this:               define('WP_USE_THEMES', true);          /** Loads the WordPress Environment and Template */     require('./wordpress/wp-blog-header.php');      Both of these services (ifttt and editorially) has the option to create new posts in your WordPress install, I've tested both with a standard WordPress install and there they work flawlessly. My apache access log show the following error:               54.235.21.109 - - [02/Nov/2013:22:00:02 +0100] "POST /xmlrpc.php HTTP/1.1" 404 15092      Symlinking that file to the root of my site solves the problem with ifttt.com, but not with editorially, which is still giving me the "Someone may be trying to trick you into giving them access to your site" error as mentioned above. Editorially asks you to log in with your wordpress.com account and required the WordPress Jetpack plugin to be installed. That is the case here and it is linked to my wordpress.com account.


Show custom taxonomies in admin panel under custom post type

I have added a custom post type called "product" to my theme. I have also created a custom taxonomy for this post type called "product_category". In the admin panel, the custom taxonomy shows up under the custom post type (product) like so: ![Screenshot of current custom post type](http://i.stack.imgur.com/RJzjH.png)   If the user adds terms to my custom taxonomy (eg: 'kitchenware' & 'Painting'), I would like the terms to show up in the admin where 'Product Categories' currently shows. I have photoshopped an example to show what I need to achieve. ![What I need to Achieve](http://i.stack.imgur.com/t3Z4A.png) When the users clicks on these terms, they are brought to edit.php where they are shown only products with the term they clicked. Is this possible with Wordpress? It seems like something that should be part of wordpress functionality.


Display Shipping information in the products Meta

I'm looking to simply display a products shipping class / information in the products meta where the SKU and category reside but every snippet i try seems to do nothing. I'm no php guy so i cant work this out :S can anyone help me with this . it seems like something that should be fairly easy to achieve


Display my plugins content based on a pages post_id

I have created a plugin that has the frontend content in a file named showmap.php, I currently have a shortcode that includes the contents of showmap.php on the page the shortcode is placed. I addition to the shortcode, I have created an option to allow the user to choose a page to include the content on. The reason is that I have a search widget that needs to post to that page so I had to have a way of detecting it.               $db_showmap_options = get_option( 'db_showmap_options' );     $chosen_page = $db_showmap_options['page_id'];      How do I detect the chosen page and include showmap.php? Do I have to take permalinks into account. I'm afraid I'm really lost on this one. Thanks in advance for any help.


Ajax, filters and shortcodes

could you figure out why I'm unable to get shortcode filters applied in ajax inclusion of posts? Let me explain better: I've managed to include a post from within another post, through **admin-ajax.php** , as recommended in the famous 5 tips. Obviously I don't want to display the shortcode tags, nor I'd like to strip them, so I'm echoing `do_shortcode($post->post_content)` At this point, the post gallery gets rendered but _unfiltered_ , even though I'm running the "Cleaner Gallery" plugin, which starts with `add_filter( 'post_gallery', 'cleaner_gallery', 10, 2 );` and succesfully works in normal (non-ajax) posts. I've been trying to debug this issue by replacing               $output = apply_filters('post_gallery', '', $attr);         if ( $output != '' )             return $output;      with               $output = apply_filters('post_gallery', '', $attr);     echo 'FILTERED OUTPUT = '.$output.' !';         if ( $output != '' )             return $output;      inside the **function gallery_shortcode($attr)** located in _wp- includes/media.php_. It seems that it runs twice, but in ajax inclusions the output is empty at first time and then it's not filtered. Well, in all effect it happens that also the "2nd round" echoed output I mentioned remains empty when setting again **add_filter** before **do_shortcode** ; otherwise it's shown (but, as I said, unfiltered). I've also tried to track it with               echo has_filter('post_gallery');     echo current_filter();      and I've discovered that **_has_** returns always **_1_** , while **_current_** first returns ' ** _post-gallery_** ' as expected, and then it gets overwritten by the ' ***wp_ajax_nopriv_etc*** ' hook, which is required to handle requests with _admin-ajax.php_ but it's actually an **action** and **not** a **filter**. (?!?) I've also tried without success to hack the cleaner gallery plugin, in order to make it directly run the shortcode without filtering the default function, removed the originary shortcode and added that new one. It works like a charm for normal posts, but it seems there is no way to implement the plugin in ajax requests. I'm getting more and more confused. Please help me! (also posted on the WP.org forums)


How to send data to sidebar?

I have a sql database of historical events, I would like it to post data into the sidebar area of a wordpress site. As I am very new to it I do not have any idea how to proceed. I would be thankful if anyone could help me out. Thanks in advance


Display the first tag assigned to a post

This is what I'm trying to achieve: Originally I was trying to include the _first_ tag of a post above the post on the homepage, using the following:               $tags_i = 0;     $tags = get_the_tags();     if ($tags) {       foreach ($tags as $tag) {         $tags_i++;         if ($tags_i == 1) { ?>
<a href="<?php echo get_tag_link($tag->term_id); ?>"><?php echo $tag->name; ?>
         <?php         }       }     }      The issue is that this actually grabs the first tag in _alphabetical_ order (it seems at least). I was originally hoping to grab the first tag assigned to that post. **I was wondering if** I would be able to use **custom tag** to achieve this. I've never used custom tag types, and I can't really find much information on how they work, so any additional info would be helpful. Or, if you can suggest a solution to my problem, that would also be very appreciated.


Can I use wp_editor() to create a second instance of the editor in my post page?

Looking at the codex and the code they provide, it doesn't seem like I can add a second editor. This looks like something more for front-end use rather than for use in the admin. If I am wrong, can someone help me figure this out? Thanks.


Check role in database

I'm developing a script outside of Wordpress that needs to work with the Wordpress database and our website. I just need to check if the role of a user is our custom role (already defined) of ntnw_member and if so, echo out "Enabled" if it is anything other than that (like subscirber) I need to echo out "disabled". Because we are using this with our application I cannot use the wp user class so I just need a simple query to check if the role is ntnw_member. I am using a simple get request in the url to get the users email and look their info up from that. Here is what I have so far:                if(isset($_GET["email"])) {                  //clean our requests             $userEmail = mysqli_real_escape_string($connect, $_GET["email"]);                  //check email against database             $checkEmail = mysqli_query($connect, "select * from wp_usermeta WHERE meta_value = '$userEmail'") or die('Error: ' . mysqli_error($connect));                  if(mysqli_num_rows($checkEmail)>0){                   while ($row = mysqli_fetch_array($checkEmail, MYSQL_ASSOC)) {                      //get the user_id from database                 $userID = $row[user_id];                      $subscriber = Array(                     'subscriber' => 1                 );                      $ntnwMember = Array(                     'ntnw_member' => 1                 );                      $checkRole = mysqli_query($connect, "select * from wp_usermeta WHERE user_id = '$userID' AND meta_value = '$ntnwMember'") or die('Error: ' . mysqli_error($connect));                      if ($checkRole){                   echo 'Enabled';                 } else {                   echo 'Disabled';                 }                  } //end while $row         } else {             //if email address does not match anything on file, kill this script             die('Failed: Your email address does not match our records');         } //end if if(mysqli_num_rows($checkEmail)>0){}              } //endif isset       So in the code above it is really this section I seem to be stuck on, as it doesnt fully work.               $subscriber = Array(                         'subscriber' => 1                     );                          $ntnwMember = Array(                         'ntnw_member' => 1                     );                          $checkRole = mysqli_query($connect, "select * from wp_usermeta WHERE user_id = '$userID' AND meta_value = '$ntnwMember'") or die('Error: ' . mysqli_error($connect));                          if ($checkRole){                       echo 'Enabled';                     } else {                       echo 'Disabled';                     }


Merge multiple posts comments

**Edit:** I now have a combined object by adapting this code to work with my comment objects, I can also pass this new object to wp_list_comments to display a combined list. I dont know how to override the current posts comment list so I can access get_comment_pages_count, previous_comments_link etc. **Original Question:** I want to merge the comments from several posts into one list so they can all be listed and keep the standard pagination etc. I am looking for if there is a 'Wordpress' way to do this. Reason: I am using polylang to make a multi language site, If I have two posts, an english and Japanese one I want to show both of their comments. For example if the Japanese post has five comments and the English one has 10 then viewing either post will show fifteen comments. What I have: I have got the posts for each language split up, I can get each languages individual comments so I could rebuild my own paginated list from this but I want to know if there is an easier way to do this before I try to recreate the wheel. NOTE: I have the polylang tag as it affects my situation but this is (I think) a general comment display question. my current loop has this structure:               for each language         if there is a post             get its comments                 // create an object:                 $commentsByLang[$value['slug']] = array(                     'comments'=> $langComments,                     'language'=> $value['name'],                     'lang'=> $value['slug'],      This gives me an object like:               array     'en' =>          array         'comments' =>              array             // comments for this language         'language' => string 'English' (length=7)         'lang' => string 'en' (length=2)         'is_current_lang' => boolean true         'post_id' => int 31         'post_url' => string '.../en/english-test-post-no-1/' (length=49)     'ja' =>          array         'comments' =>              array             // Comments for this language         'language' => string '日本語' (length=9)         'lang' => string 'ja' (length=2)         'is_current_lang' => boolean false         'post_id' => int 21         'post_url' => string '.../ja/日本語テストポスト/' (length=135)


i want to display one comment at a time then after sometime next should be displayed in same place

<?php     /*      Plugin Name: My 1st Widget      Plugin URI: http://example.com      Description: Add my widget to theme      Version: 1.0      Author: example      license: none      */          class my_1st_widget extends WP_Widget{         function __construct(){             parent::__construct(false, $name = __('My 1st Widget'));         }         function form(){              }         function update(){              }         function widget($args, $instance){             ?>

Comments
                      <?php                 $args = array('user_id' => '',                     'number' => 2                      );                      $comments_query = new WP_Comment_Query;                 $comments = $comments_query->query($args);                   if ( $comments ) {                           foreach ( $comments as $comment ) {                                echo $comment->comment_content."
";
";                         }                 } else {                         echo 'No Comments!!!';                 }             ?>
     <?php         }         }     add_action('widgets_init', function(){     register_widget('my_1st_widget');})     ?>


WordPress doesn't respect the template hierarchy?

My theme has a custom taxonomy template (" **taxonomy-authors.php** ") but WordPress _only_ serves this template file when a term associated with this taxonomy is called. e.g. example.com/cpt/authors/john-doe When loading example.com/cpt/authors/ it will return a 404. What I want it to do is to list all terms associated with the taxonomy "authors" when example.com/cpt/authors/ is requested. Here's part of my **taxonomy-authors.php** file:               <?php         if (have_posts()) :     ?>
List of Authors
          <?php             $terms = get_terms('authors');                  foreach ($terms as $term) {                 echo $term->name;             }              endif;     ?>      Any pointers on how to fix this?


WP insert post Redirect after function has executed

After using a function to submit custom fields the standard redirection is not longer working. What we would like is that after the post has been insetered for the user to be redirected the standard wp_redirect is not at the moment working. I theorise this is because of the custom fields submission function. The code               if ( is_user_logged_in() ) {     $my_post = array(         'post_title' => $_SESSION['booking-form-title'],         'post_date' => $_SESSION['cal_startdate'],         'post_content' => 'This is my post.',         'post_status' => 'publish',         'post_type' => 'booking',         'post_author' => $user_ID,     );      $the_post_id = wp_insert_post( $my_post );          __update_post_meta( $the_post_id, 'duration', $_SESSION['booking-form-actual-duration'] );     __update_post_meta( $the_post_id, 'picture', $_SESSION['booking-form-picture'] );     __update_post_meta( $the_post_id, 'totalprice', $_SESSION['booking-form-total-price'] );     __update_post_meta( $the_post_id, 'activityduration', $_SESSION['booking-form-total-duration'] );     __update_post_meta( $the_post_id, 'totaldives', $_SESSION['booking-form-total-dives'] );          query_posts('post_type=services'); while (have_posts()) : the_post();     __update_post_meta( $the_post_id, 'producttitle'.get_the_ID(), $_SESSION['products-form-title'.get_the_ID()]);      __update_post_meta( $the_post_id, 'productprice'.get_the_ID(), $_SESSION['products-form-price'.get_the_ID()]);      __update_post_meta( $the_post_id, 'productduration'.get_the_ID(), $_SESSION['products-form-duration'.get_the_ID()]);     __update_post_meta( $the_post_id, 'productdives'.get_the_ID(), $_SESSION['products-form-dives'.get_the_ID()]);       __update_post_meta( $the_post_id, 'productquantity'.get_the_ID(), $_SESSION['products-form-quantity'.get_the_ID()]);            endwhile;       $linkit = get_permalink($the_post_id);     wp_redirect($linkit);     }     else {;}      the wp_redirect is producing the following error `Warning: Cannot modify header information - headers already sent by (output started at /home/divethe1/public_html/update/wp-content/themes/master/type- booking.php:18) in /home/divethe1/public_html/update/wp-includes/pluggable.php on line 890` Just so we are on the same page to change $the_post_id to $post_id negated the function and still does not perform the redirect. The function and procedure to make it can be found at WP insert post PHP function and Custom Fields The objective is therefore to redirect the user to the page created by the wp_insert_post. If anyone can see where I have gone wrong, many thanks, Marvellous


Adding featured image via PHP

Currently I'm working on a project where site is driven by user articles, how it works:   1. Any user goes to compose post page and writes post along with few details, has upload file option for image and then submits   2. Post is uploaded in wordpress and the image attached is set as featured image   3. Admin approves the post and it gets published. Here user is not required to have an account. I am using `wp_insert_post` to create a new post but not able to figure out how to add featured image via PHP.


Disable update notification for individual plugins

Is there a way to disable update notifications for specific plugins? As a plugin developer, I have some plugins installed on my personal site using the svn trunk version for testing, but the same plugins are available from the plugin site. In these cases WP considers the latest version to be the _most recently published_ version and constantly tries to warn me that updates are available. I still want to see notifications for updates on other plugins, but it's anoying to constantly ignore the `Updates (2)` notice in the header!


How to display meta box data using "Meta boxes as needed"

I have been following this post exactly: http://wordpress.stackexchange.com/a/19852/14957 and have everything working in the backend but when I try to use `echo get_post_meta($post->ID, 'songs', true);` in my template all that is shown is `Array`. Any ideas? I would appreciate it.


Distribute post content through several divs

I would like to distribute the content in a post through several divs. Much like a word processor distributes content through pages. Any ideas?


Is there a way to set the order of wp_footer hooked functions?

I was wondering if we can set the order of a function hooked to wp_footer(), I created a function that echos:               <script> ajsfunction(); </script>      and I also enqueued the js file of this function and printed it in the footer but the above is being printed before linking to the js file so it's not working, I'm doing this because this script is not run on all pages only on specific ones. if we can't do this with wp_footer is there a way to output this script tag after the enqueued js file ? thanks in advance.


wp_localize_script escaping my url - fix or alternative

Here is my wp_enqueue_script and wp_localize_script - which i am using to run an Ajax call.               wp_enqueue_script( 'function', plugin_dir_url( __FILE__ ) . 'function.js', array( 'jquery', 'json2' ) );     wp_localize_script( 'function', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );      While debugging this problem arose:               <script type='text/javascript'>     /* <![CDATA[ */         var MyAjax = {"ajaxurl":"http:\/\/mydomain.com\/wp-admin\/admin-ajax.php"};         /* ]]> */         </script>      As you can see my url is been escaped out and i have no idea why... is there a possible fix or alternative method for what i am trying to do? Thanks in advance


PHP $_session is not work in wordpress

why PHP $_session is not working in wordpress my php code is               session_start();     session_register('lang_opt');       $_SESSION['lang_opt'] = $_POST['lang_opt'];     $mylang = $_SESSION['lang_opt'];      echo $mylang;


Is it possible to use get_post_meta() to control HTML?

I want to hide or show an HTML widget I built depending on whether someone adds custom fields to a page via WP Admin. Is this possible? I'd like to do this in my HTML widget template (tips.php): check if there is a value for each of the custom fields in this template. If there isn't, hide this html from view. Otherwise, if there is custom field text, show the widget. Here's my code:

<?php echo get_post_meta(get_the_id(), 'header', true); ?>
          <img src="<?php bloginfo('template_url'); ?>/images/pencil_Tip.gif" alt="">

 <?php echo get_post_meta(get_the_id(), 'content', true); ?>
      Thanks in advance for any help.


TinyMCE editor turns white on Biographical info

I tried out the solution found here: How to use tinyMCE for user “biographical info” without messing with any core file? and added it to my plugin code. The problem is, it turns the editor white (see this picture--> http://i.imgur.com/HKp0A.png) How do I make it show up? Regards, John


How do I customize my WordPress shortlink structure in link-template.php without a plugin?

Right now my shortlink structure looks something like this: example.com/?p=451 I would prefer it to look more like this: example.com/abc123 Any ideas how I can alter the code to do just this?