Pagination of custom mysql in wordpress

I'm a novice with php and mysql so please be kind. The problem is I'm calling a database which has various states open, closed, pending etc, all this works fine. The problem is when I click next on my paging links the page just reloads to the start page with all states visible and the first 6 rows visible. My code seems to work fine as the url of next, prev page as a different start number for the start of the database query eg (http:/wordpress/?page_id=1072?s=6&np=3). I was wondering if this could be to with wordpress? help much appreciated.               $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) ;     mysql_select_db (DB_NAME) ;          /*state control buttons */          echo "

<form method=\"post\" action=\"".htmlentities($_SERVER['REQUEST_URI'])."\"><INPUT TYPE=\"submit\" name=\"showopen\" VALUE=\"\" class=\"show_open\"></form>
	";     echo "
<form method=\"post\" action=\"".htmlentities($_SERVER['REQUEST_URI'])."\"><INPUT TYPE=\"submit\" name=\"showpending\" VALUE=\"\" class=\"show_pending\"></form>
	";     echo "
<form method=\"post\" action=\"".htmlentities($_SERVER['REQUEST_URI'])."\"><INPUT TYPE=\"submit\" name=\"showclosed\" VALUE=\"\" class=\"show_closed\"></form>
	";     echo "
<form method=\"post\" action=\"".htmlentities($_SERVER['REQUEST_URI'])."\"><INPUT TYPE=\"submit\" name=\"show_all\" VALUE=\"\" class=\"show_all\"></form>

";               $self = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ;     /* Status set code */          if (isset($_POST['close'])) {         $close_row = $_POST['close_row'];         $close = "UPDATE support_users SET status = 'Closed', date_altered = NOW() WHERE ticket_number=$close_row";         $closeresult = @mysql_query ($close);         $viewstate = $_POST['viewstate'];     }          if (isset($_POST['open'])) {         $close_row = $_POST['close_row'];         $close = "UPDATE support_users SET status = 'Open', date_altered = NOW() WHERE ticket_number=$close_row";         $closeresult = @mysql_query ($close);         $viewstate = $_POST['viewstate'];     }          if (isset($_POST['pending'])) {         $close_row = $_POST['close_row'];         $close = "UPDATE support_users SET status = 'Pending', date_altered = NOW() WHERE ticket_number=$close_row";         $closeresult = @mysql_query ($close);         $viewstate = $_POST['viewstate'];     }          if (isset($_POST['pending_ami'])) {         $close_row = $_POST['close_row'];         $close = "UPDATE support_users SET status = 'Pending AMI', date_altered = NOW() WHERE ticket_number=$close_row";         $closeresult = @mysql_query ($close);         $viewstate = $_POST['viewstate'];     }          if (isset($_POST['pending_arp'])) {         $close_row = $_POST['close_row'];         $close = "UPDATE support_users SET status = 'Pending ARP', date_altered = NOW() WHERE ticket_number=$close_row";         $closeresult = @mysql_query ($close);         $viewstate = $_POST['viewstate'];     }          /* View state set code */          if (isset($_POST['showopen'])) {         $viewstate='open';     }          if (isset($_POST['showpending'])) {         $viewstate='pending';     }               if (isset($_POST['showclosed'])) {         $viewstate='closed';     }          if (isset($_POST['show_all'])) {         $viewstate='all';     }               $display = 6;          if (isset($_GET['np'])) {         $num_pages = $_GET['np'];          } else {                  if ($viewstate=='open') {                $query = "SELECT ticket_number, first_name, surname, email, product, retailer, DATE_FORMAT(dop, '%d %M %Y') AS dop, message, address, DATE_FORMAT(created, '%d %M %Y %r') AS created, status FROM support_dev WHERE status='Open' ORDER BY ticket_number ASC";             $query_result = mysql_query ($query);              $num_records = @mysql_num_rows ($query_result);                  if ($num_records > $display) {         $num_pages = ceil ($num_records/$display);     } else {         $num_pages = 1;         }     }                   elseif ($viewstate=='pending') {             $query = "SELECT ticket_number, first_name, surname, email, product, retailer, DATE_FORMAT(dop, '%d %M %Y') AS dop, message, address, DATE_FORMAT(created, '%d %M %Y %r') AS created, status FROM support_dev WHERE status LIKE 'Pending%' ORDER BY ticket_number ASC";             $query_result = mysql_query ($query);              $num_records = @mysql_num_rows ($query_result);                  if ($num_records > $display) {         $num_pages = ceil ($num_records/$display);     } else {         $num_pages = 1;     }         }          elseif ($viewstate=='closed') {             $query = "SELECT ticket_number, first_name, surname, email, product, retailer, DATE_FORMAT(dop, '%d %M %Y') AS dop, message, address, DATE_FORMAT(created, '%d %M %Y %r') AS created, status FROM support_dev WHERE status='Closed' ORDER BY ticket_number ASC";             $query_result = mysql_query ($query);              $num_records = @mysql_num_rows ($query_result);                  if ($num_records > $display) {         $num_pages = ceil ($num_records/$display);     } else {         $num_pages = 1;         }          }     else {             $query = "SELECT ticket_number, first_name, surname, email, product, retailer, DATE_FORMAT(dop, '%d %M %Y') AS dop, message, address, DATE_FORMAT(created, '%d %M %Y %r') AS created, status FROM support_dev ORDER BY ticket_number ASC";             $query_result = mysql_query ($query);              $num_records = @mysql_num_rows ($query_result);                  if ($num_records > $display) {         $num_pages = ceil ($num_records/$display);     } else {         $num_pages = 1;         }     }     }               if (isset($_GET['s'])) {         $start = $_GET['s'];     } else {         $start = 0;     }              $query = "SELECT ticket_number, first_name, surname, email, product, retailer, DATE_FORMAT(dop, '%d %M %Y') AS dop, message, address, DATE_FORMAT(created, '%d %M %Y %r') AS created, status FROM support_dev ORDER BY ticket_number ASC LIMIT $start, $display";         if ($viewstate=='open') {                  $query = "SELECT ticket_number, first_name, surname, email, product, retailer, DATE_FORMAT(dop, '%d %M %Y') AS dop, message, address, DATE_FORMAT(created, '%d %M %Y %r') AS created, status FROM support_dev WHERE status='Open' ORDER BY ticket_number ASC LIMIT $start, $display";             }                 elseif ($viewstate=='pending') {             $query = "SELECT ticket_number, first_name, surname, email, product, retailer, DATE_FORMAT(dop, '%d %M %Y') AS dop, message, address, DATE_FORMAT(created, '%d %M %Y %r') AS created, status FROM support_dev WHERE status LIKE 'Pending%' ORDER BY ticket_number ASC LIMIT $start, $display";             }             elseif ($viewstate=='closed') {             $query = "SELECT ticket_number, first_name, surname, email, product, retailer, DATE_FORMAT(dop, '%d %M %Y') AS dop, message, address, DATE_FORMAT(created, '%d %M %Y %r') AS created, status FROM support_dev WHERE status='Closed' ORDER BY ticket_number ASC LIMIT $start, $display";}             $result = @mysql_query ($query);             $num = mysql_num_rows ($result);              if ($num > 0) {              if ($num_pages > 1) {             echo '
';             $current_page = ($start/$display) + 1;                  if ($current_page != 1) {                 echo 'Previous ';             }             for ($i = 1; $i <= $num_pages; $i++) {                 if ($i != $current_page) {                     echo '' .$i .' ';                 } else {                     echo $i . ' ';                 }             }             if ($current_page !=$num_pages) {                 echo 'Next ';             }             echo '

';               }                    if ($result) {              echo '

Ticket

First Name

Last Name

Email

Product

Retailer

D.O.P.

Message

Address

Date created

Status

         ';              while ($row = mysql_fetch_array($result, MYSQL_NUM)) {             echo "

$row[0]

$row[1]

$row[2]

$row[3]

$row[4]

$row[5]

$row[6]

$row[7]

$row[8]

$row[9]

$row[10]

<form method=\"post\" action=\"".htmlentities($_SERVER['REQUEST_URI'])."#a".$row[0]."\"><input type=\"hidden\" name=\"close_row\" value=\"".($row[0])."\" /><input type=\"hidden\" name=\"viewstate\" value=\"".$viewstate."\" /><INPUT TYPE=\"submit\" name=\"open\" VALUE=\"\" class=\"submit_open\">
<INPUT TYPE=\"submit\" name=\"pending\" VALUE=\"\" class=\"submit_pending\">
<INPUT TYPE=\"submit\" name=\"pending_ami\" VALUE=\"\" class=\"submit_pendingami\">
<INPUT TYPE=\"submit\" name=\"pending_arp\" VALUE=\"\" class=\"submit_pendingarp\">
<INPUT TYPE=\"submit\" name=\"close\" VALUE=\"\" class=\"submit_closed\"></form>

";         }          }         mysql_free_result ($result);               }                 if (is_null($viewstate)) {         $viewstate='all';     }                    ?>


How can I delete options with register_uninstall_hook?

Right now, I have this code:               function mr_np_activate(){         // hook uninstall         if ( function_exists('register_uninstall_hook') )             register_uninstall_hook(__FILE__,'mr_np_uninstall');             }     register_activation_hook(__FILE__,'mr_np_activate');               /**      * Delete options      *      **/                   function mr_np_uninstall() {         delete_option('my_plugins_options');      }      But when I remove my plugin, all my options are there. (I made another plugin just to show my options). How can I delete options when plugin is removed? []'s Homem Robô


updating meta_key from the frontend

I am wanting to update the meta_key in the database to reorder postmeta from the frontend. I'm using jQuery UI drag and drop to move items into an order, I can update the values but the meta_key is not so easy. My meta_key and values are like this:   * add_task_0_assigned => value   * add_task_0_complete => value   * add_task_1_assigned => value   * add_task_1_complete => value   * add_task_2_assigned => value   * add_task_2_complete => value   * add_task_3_assigned => value   * add_task_3_complete => value the values I can update from the frontend easily using super globals $_POST or $_GET but, is there a way to modify the meta_key to save and reorder in the database? Any help or guidance would be appreciated.


Performance-wise, is it better to enqueue a (small) script on every page or test to see if it's needed?

I'm using the FitVids.js script to make YouTube video embeds work with a responsive layout. The script is < 3kb, but only about half of my pages actually have YouTube embeds. In terms of total load-time for a page that doesn't contain a YouTube video, is it more costly to do a `strpos()` on the content or to include the script regardless? I imagine this has a lot to do with the end-user's connection speed vs. the server's resources, and honestly, it's a low-traffic site with undemanding users so it really doesn't matter... I'm mostly asking because I don't have a good grasp of performance optimization and I want to learn.


Text under post title on frontpage but don't want it in full post

On the frontpage of a blog I want a piece of text (like an excerpt) under the title but I don't want is showing up in the full post. Any ideas how I would go about this? EDIT: Wasn't precise enough in my question. The piece of text under the title will be different for every post and has to be able to be set in the backend by the end user, preferably when typing the post.


Video shortcode - autoplay all videos

How can I autoplay all videos added by video shortcode?   I can make only one of them autoplay if only one has autoplay attribute set to 1, and others to 0, otherwise all are stopped.


Undefined index: b in /path/file.php relating to querystring parameters

I am getting errors in the server log for cformsII plugin but don't understand why.               PHP Notice:  Undefined index: b in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 12     [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice:  Undefined index: f in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 15     [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice:  Undefined index: f1 in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 18     [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice:  Undefined index: f2 in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 19     [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice:  Undefined index: a1 in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 21     [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice:  Undefined index: a2 in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 22     [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice:  Undefined index: l in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 30      > The url to the captcha image is http://mysite/wp- > content/plugins/cforms/cforms- > captcha.php?ts=3&c1=4&c2=5&ac=abcdefghijkmnpqrstuvwxyz23456789&i=i&w=115&h=25&c=#A6BEA4&l=000066&f=font4.ttf&a1=-20&a2=11&f1=17&f2=19&b=12.gif&rnd=448710 As you can see the variables throwing errors are included in the querystring. The error is happening against this statement (prep being a function which strips slashes):               $im_bg_url      = 'captchabg/' . ( prep($_REQUEST['b'],'1.gif') );


Certain actions failing when run through cron

I am having a huge argument with Wordpress, and this is my last port of call before I throw the PC out of the window. I have a plugin here that exports an XML feed into Wordpress posts. The posts have an image which is saved locally, the HTML to display the image is then inserted at the beginning of the post content, before being inserted into Wordpress using wp_insert_post. I'm having a slight issue though. The script works fine when it is turned on manually. But as soon as it triggered by cron, the post will import fine, but the image will not save locally, and the HTML for the image is not present in the posts content. I really am at a loose end. I thought it was to do with permissions, and the fact that the posts were being imported with no author. I then changed it so they were marked as written by an admin, but that made no difference. What is the problem of running it via cron vs running it manually when logged in? If anyone can help solve this then I will be eternally grateful!


How to extract the variables out from “add_shortcode” function?

In Wordpress, lets say i have a custom Shortcode function, like:               function foobar_func( $atts ){         //whatever required processings here...         $foo = "the value is foo!";         $bar = "the value is bar!";     }     add_shortcode( 'myshortcode', 'foobar_func' );     //now .. echo the value of $foo here? <----------      As you can see, how can i get the processed value of a variable out from the function please? (as in the last line) OR How to pass the variable from this Function to the outside, please?


simplified explanation on child themes?

I'm trying to create child theme for theme i'm using on my site... I read lot's of articles about this, but can't find simple tutorial or simple explanation how to do it... As i understand so far, if i copy (for example) loop.php file to child theme, and change               if(is_home()) {        do something     }       from original loop file to               if(is_home()) {        do something else       and do another more thing     }      my function will be executed and original function will be ignored? Is this right? Thanks in advance


How to display multiple $meta_boxes into separate tables

i am writing a plugin inside a class and i have created my $meta_boxes, i am able to retrieve all fields but they are duplicated and in the same table. this is my code for add $meta_boxes               function ri_add_custom_box() {         global $prefix, $meta_box, $meta_boxes;               $prefix = '_ri_custom_meta_'; // a custom prefix to help us avoid pulling data from the wrong meta box     $meta_boxes = array();          $meta_boxes[] = array(       'id' => 'ri_meta_box_panel1', // the id of our meta box     'title' => 'Test1', // the title of the meta box     'page' => 'ri_my_page', // display this meta box on post editing screens     'context' => 'side',     'priority' => 'high', // keep it near the top         'fields' => array( // all of the options inside of our meta box             array(                 'name' => 'Test1:',                 'desc' => 'Test1',                 'id' => $prefix . 'Test1',                 'type' => 'text',                 'std' => ''             ),         )     );          $meta_boxes[] = array(       'id' => 'ri_meta_box_panel2', // the id of our meta box     'title' => 'Test2', // the title of the meta box     'page' => 'ri_my_page', // display this meta box on post editing screens     'context' => 'side',     'priority' => 'high', // keep it near the top         'fields' => array( // all of the options inside of our meta box             array(                 'name' => 'Test2:',                 'desc' => 'Test2',                 'id' => $prefix . 'Test2',                 'type' => 'text',                 'std' => ''             ),         )     );          foreach ($meta_boxes as $meta_box) {         new Ri($meta_box);         add_meta_box($meta_box['id'], $meta_box['title'], array(&$this, 'ri_display_metaboxes'), $meta_box['page'], $meta_box['context'], $meta_box['priority']);     }     }      and this is my code for display $meta_boxes               function ri_display_metaboxes() {         global $meta_box, $meta_boxes, $post;              echo '<input type="hidden" name="ri_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';         echo '
';                  foreach ($meta_boxes as $meta_box) {                 foreach ($meta_box['fields'] as $field) {                      $meta = get_post_meta($post->ID, $field['id'], true);              echo '
', // create a table row for each option                     '', $field['name'], '	',                     '';             switch ($field['type']) {                      case 'text': // the HTML to display for type=text options                     echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />', '     ', $field['desc'];                     break;                           case 'textarea': // the HTML to display for type=textarea options                     echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="8" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>', '     ', $field['desc'];                     break;                      case 'select': // the HTML to display for type=select options                     echo '<select name="', $field['id'], '" id="', $field['id'], '">';                     foreach ($field['options'] as $option) {                         echo '<option', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>';                     }                     echo '</select>';                     break;                      case 'radio': // the HTML to display for type=radio options                     foreach ($field['options'] as $option) {                         echo '<input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'];                     }                     break;                      case 'checkbox': // the HTML to display for type=checkbox options                     echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';                     break;                  }             echo     '',                 '
';                     }                 }             echo '
';     }      I want to display in the first metabox Test1 and in second metabox Test2 like this Metabox1 Test1 Metabox2 Test2 but now with this code i have Metabox1 Test1 Test2 Metabox2 Test1 Test2 Sorry for my bad english. Any help is appreciated!


action wp_set_comment_status never gets fired when i change the comment status

I want to run some code on comment status change so using the action `wp_set_comment_status` but it seem to never fired when comment status gets changed. I am using wordpress 3.3.1. **Here is a simple code which doesn't work for me:**               add_action('wp_set_comment_status ', 'update_business_rating_avg');          function update_business_rating_avg($comment_ID, $status){         update_option( 'business', 'checked' );     }      There was a same bug on the wp version `2.8.2` and it was fixed later on. Not sure if i am doing something wrong or not. http://core.trac.wordpress.org/ticket/8863 The codex says about the action: **wp_set_comment_status:** Runs when the status of a comment changes. Action function arguments: comment ID, status string indicating the new status ("delete", "approve", "spam", "hold").


External page integrated into WordPress returns a 404 error

I have a script that I'd like to call via AJAX from my WordPress theme, it relies upon some core WordPress functions so I am including WordPress blog header like so:               define( 'WP_USE_THEMES', false );     require( '../../../../wp-blog-header.php' );      Somewhere during the processing of `wp-blog-header.php` WordPress sets a 404 header which causes my AJAX request to fail, even though the script I am calling exists and is returning content. I have since added `status_header( 200 );` after that snippet which changes the status header back to 200 and solves the problem, however it feels very much like a hack, so I was just wondering if there is a _recommended_ solution to this problem?


How to order separated Custom Post Search results

I am using the technique described here Seperating Custom Post Search Results and here posts_groupby problem to seperate my search results and group them by post type. This means I have the following code. **In functions.php**               add_filter('posts_orderby', 'group_by_post_type', 10, 2);     function group_by_post_type($orderby, $query) {         global $wpdb;         if ($query->is_search) {             return $wpdb->posts . '.post_type DESC';         }         // provide a default fallback return if the above condition is not true         return $orderby;     }      **In search.php**               <?php $last_type="";     $typecount = 0;     while (have_posts()){         the_post();         if ($last_type != $post->post_type){             $typecount = $typecount + 1;             if ($typecount > 1){                 echo '
'; //close type container             }             // save the post type.             $last_type = $post->post_type;             //open type container             switch ($post->post_type) {                 case 'post':                     echo "
News Articles

";                     break;                 case 'page':                     echo "
Pages

";                     break;                 case 'work':                     echo "
Projects

";                     break;                 case 'bootlegs':                     echo "
Bootlegs

";                     break;                 case 'directors':                     echo "
Directors

";                     break;                 //add as many as you need.             }         } ?>      This works perfectly except I have no control over the order in which the Custom Post Types are displayed. I'm guessing they are being ordered by an internal ID number, but I need to have control over them. How can I achieve this? Thanks!


Author bio Social Links

I'm using simple code to show user social link in author bio. **in functions.php**               <?php     function add_remove_contactmethods( $contactmethods ) {         // Add Twitter         $contactmethods['twitter'] = 'Twitter';         //Add Facebook         $contactmethods['facebook'] = 'Facebook';      // Remove Contact Methods         unset($contactmethods['aim']);         unset($contactmethods['yim']);         unset($contactmethods['jabber']);              return $contactmethods;     }     add_filter('user_contactmethods','add_remove_contactmethods',10,1);     ?>      **in single.php**                  <a href="<?php the_author_meta('twitter'); ?>" title="Twitter" target="_blank" id="twitter">      so how can i hide social link in author bio when the field is empty in user profile. please help me...


Confusing about permalink

I'm nubie in WP and I have some problems but the annoying for me is the default permalink. When tried to visit my site from top of the dashboard link, it says "mydomain.com/home" instead mydomain.com. So it directs me to 'NOT FOUND' page. Please help FYI, it's still installed in my dev.domain.com site.


WordPress not creating "large" thumbnails

I moved my WordPress installation from my local dev environment (MAMP) to a shared hosting server. Since then I have trouble with image uploads not being processes as before, especially with the large size. The large media setting is being ignored as long as I don't set it to quite small sizes. I want it to be at               Max Width: 940  Max Height: 10000 (or 0, I tried both)       Once I go under 1000 with the max height, the large image is being created, if I go higher it skips that. I already added               define( 'WP_MEMORY_LIMIT', '256M' );      in the wp-config.php, and when I run phpinfo on the server is says               memory_limit    256M          Any ideas what to tweak? I searched but coulnd't find something related. Thanks for replies!


Breadcrumbs: Search result not displayed when static page is on top

Uhm, this is quite a weird problem and I'm trying to make sure that I explain it well enough so that you understand what I'm talking about. So, I'm using breadcrumbs in my header area. It all works fine. However, when you type in a search, it only SOMETIMES displays the actual search result in the breadcrumbs. It's supposed to look like that: Home » Blog » Search results for "lorem" View it live. However, if the first search result (the one that is being displayed on top of all others) is a static page instead of a blog post, the breadcrumbs display it this way: Home » Blog » Page View it live. It's still shown correctly in the tab of my browser. Only the breadcrumbs seem to get confused. This is the code snippet I use for the breadcrumbs:               function dimox_breadcrumbs() {            $delimiter = '»';       $home = 'Home'; // text for the 'Home' link       $before = ''; // tag before the current crumb       $after = ''; // tag after the current crumb            if ( !is_front_page() || is_paged() ) {              echo '
';          global $post;     $divider = $delimiter;     if (is_home()) $divider = '';     $homeLink = get_bloginfo('url');     echo '' . $home . ' ' . $delimiter . ' Blog ' . $divider . ' ';              if ( is_category() ) {           global $wp_query;           $cat_obj = $wp_query->get_queried_object();           $thisCat = $cat_obj->term_id;           $thisCat = get_category($thisCat);           $parentCat = get_category($thisCat->parent);           if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));           echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after;              } elseif ( is_day() ) {           echo '' . get_the_time('Y') . ' ' . $delimiter . ' ';           echo '' . get_the_time('F') . ' ' . $delimiter . ' ';           echo $before . get_the_time('d') . $after;              } elseif ( is_month() ) {           echo '' . get_the_time('Y') . ' ' . $delimiter . ' ';           echo $before . get_the_time('F') . $after;              } elseif ( is_year() ) {           echo $before . get_the_time('Y') . $after;              } elseif ( is_single() && !is_attachment() ) {           if ( get_post_type() != 'post' ) {             $post_type = get_post_type_object(get_post_type());             $slug = $post_type->rewrite;             echo '' . $post_type->labels->singular_name . ' ' . $delimiter . ' ';             echo $before . get_the_title() . $after;           } else {             $cat = get_the_category(); $cat = $cat[0];             echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');             echo $before . get_the_title() . $after;           }              } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {           $post_type = get_post_type_object(get_post_type());           echo $before . $post_type->labels->singular_name . $after;              } elseif ( is_attachment() ) {           $parent = get_post($post->post_parent);           $cat = get_the_category($parent->ID); $cat = $cat[0];           echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');           echo '' . $parent->post_title . ' ' . $delimiter . ' ';           echo $before . get_the_title() . $after;              } elseif ( is_page() && !$post->post_parent ) {           echo $before . get_the_title() . $after;              } elseif ( is_page() && $post->post_parent ) {           $parent_id  = $post->post_parent;           $breadcrumbs = array();           while ($parent_id) {             $page = get_page($parent_id);             $breadcrumbs[] = 'ID) . '">' . get_the_title($page->ID) . '';             $parent_id  = $page->post_parent;           }           $breadcrumbs = array_reverse($breadcrumbs);           foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';           echo $before . get_the_title() . $after;              } elseif ( is_search() ) {           echo $before . 'Search results for "' . get_search_query() . '"' . $after;              } elseif ( is_tag() ) {           echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;              } elseif ( is_author() ) {            global $author;           $userdata = get_userdata($author);           echo $before . 'Articles posted by ' . $userdata->display_name . $after;              } elseif ( is_404() ) {           echo $before . 'Error 404' . $after;         }              if ( get_query_var('paged') ) {     if (is_home()) echo ' ' . $delimiter . ' ';           if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';           echo __('Page') . ' ' . get_query_var('paged');           if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';         }              echo '
';            }     } // end dimox_breadcrumbs()      I already talked to the creator of the code, but he also has no clue why this is ocurring. I hope somebody has at least a clue so that I can work on it? Thanks a lot! :)


Disable the admin bar

I have the WP3.4 and I would like to disable the admin bar. I have tried to do that with many ways, but the admin bar do not display. Is possible to do on this version of WP (3.4) or i make a mistake in the code? Below are the ways that I've tried. Thanks in advance. The 1st :               function my_function_admin_bar(){                 return false;             }             add_filter( 'show_admin_bar' , 'my_function_admin_bar');      The 2nd :               add_action( 'init', 'disable_admin_bar', 1 );     function disable_admin_bar() {         add_filter( 'show_admin_bar', '__return_false' );      The 3rd                   <?php     if (!function_exists('disableAdminBar')) {              function disableAdminBar(){              remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); // for the admin page         remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // for the front end              function remove_admin_bar_style_backend() {  // css override for the admin page           echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';         }              add_filter('admin_head','remove_admin_bar_style_backend');              function remove_admin_bar_style_frontend() { // css override for the frontend           echo '<style type="text/css" media="screen">           html { margin-top: 0px !important; }           * html body { margin-top: 0px !important; }           </style>';         }              add_filter('wp_head','remove_admin_bar_style_frontend', 99);            }          }          // add_filter('admin_head','remove_admin_bar_style_backend'); // Original version     add_action('init','disableAdminBar'); // New version                   ?>


Can wordpress theme folder name be changed freely and nothing technically happens

Can the wordpress theme folder be renamed any time freely and everything works fine after that ,               themes/oldthemename     themes/whatevernewname      or is it so that if you change the folder name that contains theme files - then the theme wont work any more because theme folder name is related to the theme files somehow ...


Issue with Multisite and SSL

I have a multisite with subdirectories and an SSL. I cjanged the options tables for the main site and one subsite, but the ssl is only registering for the main site. I even checked the "Update siteurl and home as well" option. If it physically type https then the site registers and no insecure flag is shown on the checkout page, but the little lock doesnt display and it says the site isnt totally secure. How can I get it situated? https://www.kickinkaratesystems.com/ https://www.kickinkaratesystems.com/akitournament/


require one tag for each post

How would I go about requiring each post to have no more than one tag? I would like to require the user to create a tag or choose one previous tag for each post. If you could give me any information, that would be very helpful.


How do I search events between two set dates inside WP?

I am building a WP site with an events feature. The events page was made with custom post types. I want to make it possible for people to search/ filter events by dates. For example, they can search for all events happening between 2nd December, 2011 and 1st March, 2012 and get results from events that have their dates between the months of December and March (ie. december, january, february and march). I want to know the best way to go about this. Any ideas? You can see an example of what I want to achieve by looking at the "Search events by date" feature on this page http://www.londontown.com/events If that won't be possible, is there any way I can get them to search for events happening between certain months, say December and February(excluding the days)? Thanks in advance.


Custom Nested Wordpress Comments with avatar

I am developing a theme and has no idea how wordpress handles the comment outputs. I have `wp_list_comments` in my comments.php, but I'm not sure how to customize the output to get the desired output as in the enclosed image. Any suggestions on how to customize the output rendered by `wp_list_comments`? ![enter image description here](http://i.stack.imgur.com/i83iW.png)


select to search in category AND custom post type

I try to do something but which I block. What I need is simple: a search textbox and a select which allows the user to search either in whole or in custom post types, or in category. Separately, I can do everything, but I blocked to "embed" all this Basically, should give this, but with two more options to select two custom post types. Can you help me?               <form method="get" id="searchformheader" action="<?php echo esc_url( home_url( '/' ) ); ?>">         <input type="text" name="s" id="sheader" placeholder="Recherche" />         <select name="cat" id="searchheaderdropdown">             <option class="level-0" value='0' selected='selected'>Dans ...</option>                <option class="level-0" value="3">Dans les news</option>             <option class="level-0" value="15">Dans les tests</option>             <option class="level-0" value="16">Dans les vidéos</option>             <option class="level-0" value="18">Dans les guides</option>         </select>         <input type="submit" class="submit" name="submit" id="searchsubmitheader" value="" />     </form>      Thank's!


How do I implement a .diff changeset from core.trac.wordpress.org locally?

I have a local copy of the latest version of wordpress that I set up using               svn co http://core.svn.wordpress.org/trunk/      There is a diff that I want to pull into my local fileset: http://core.trac.wordpress.org/attachment/ticket/19371/19371.diff Is this something that I can do with subversion? What commands do I need to use?


Display old posts if no future posts exist

I have a loop setup to display future posts but would like to set up an if statement where if there are no future posts, it will show a certain amount of published posts. My current query below:                       <?php                 query_posts('posts_per_page=5&order=ASC&post_status=future');                 if ( have_posts() ) : while ( have_posts() ) : the_post();             ?>      Any ideas?


Excerpt Length & List Category Posts Plugin

I'm trying to filter out the excerpt by character length for a plugin called "List Category Posts". I've been trying to get the excerpts working for the past week, but nothing is doing the trick. The plugin actually comes with a feature that allows you to post the excerpt or not, then filter it by character length.. by adding "excerpt_size=" in the shortcode. But unfortunately, it doesn't work at this time, and I've tested it with multiple different themes. Anyways, here is the code it uses to get the excerpt:               public function get_excerpt($single){         if (                 $this->params['excerpt']=='yes' &&                 !($this->params['content']=='yes' &&                 $single->post_content) ){             /*              * Strip shortcodes - #5              * http://codex.wordpress.org/Function_Reference/strip_shortcodes             */             if($single->post_excerpt){                 return $single->post_excerpt;             }             $lcp_excerpt = strip_shortcodes(strip_tags($single->post_content));             $exc_lim = intval($this->params['excerpt_size']);             $lcp_excerpt = mb_substr($lcp_excerpt, 0, $exc_lim) . '...';             return $lcp_excerpt;         } else {             return null;         }     }      and the excerts are set by default like so (I've tried changing the 'excerpt_size' default parameter below, and it did not work):               'excerpt' => 'no',     'excerpt_size' => '255',      I don't even need a grand solution to get the whole shortcode excerpt filter to work with any number I enter. If anyone could help me get it to work so all the excerpt character lengths are say, 100. That would be amazing!


How can I send an email in my plugin?

I'm making a plugin that emails the site webmaster when I go to the 404 page. The script checks if the referring link is on our site, and then sends an email to the webmaster.               $message = "                           <title>Alton Bible Church - Broken Link</title>
There's a broken link on My Website

                         Broken Link	Referring Link

                         " . $broken . "	" . $referrer . "

              ";     $headers = 'MIME-Version: 1.0' . '\r\n';     $headers .= 'Content-type: text/html; charset=iso-8859-1' . '\r\n';     $headers .= 'From: My Website <no-reply@mysite.net>' . '\r\n';     mail("Webmaster <webmaster@mysite.net>", "My Website - Broken Link", $message, $headers);      The problem is, the email is not being sent. Does WordPress not allow me to use mail()? The problem shouldn't be with the server. Thanks!


How to add "supports" parameter for a Custom Post Type?

Is there a way to add support for a custom feature for a custom post type, after it has been created? I know how to create a custom post type using register_post_type(), and how to use the supports parameter to specify what the CPT should support;               'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt' ,'headway-seo')       But for the situations when the CPT is being registered by a plugin or theme, is there a way to 'inject' support elements (manipulate the support array) of the CPT after it has been registered, using a WP hook/filter?


Can't match title in database

This is very perplexing and hope someone can help me. Here is some code I'm using to see if a title exists in wp_posts table               $mypostids = $wpdb->get_results("select ID from $wpdb->posts where   post_title='$thisTitle'");               if(!empty($mypostids)){     echo $thisTitle.' already exists'; }else{         echo $thisTitle.' does not exist';      }      where $thisTitle is simply the title. Here is the output from this Pics: Sarah Michelle Gellar & Freddie Prinze Jr step out post-baby already exists Saturday Night Live lampoons Pandora music channels, but don't expect NBC to stream it online does not exist Report: Adele is a mum! Baby Konecki born Friday already exists As you can see, the output says the title "Saturday Night Live, etc." doesn't exist, but you can see by the image (in the link below) it certainly does exist. I have no idea why this is happening. Am I missing something obvious? Thanks. https://dl.dropbox.com/u/3132388/screenshot_415.jpg


Query on custom field count?

I have the following code:

                 <?php                 $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;                 query_posts( array(                             'cat' => '6',                              'posts_per_page' => 5,                             'meta_key' => 'krit_karakter',                             'orderby'=> 'menu_order',                             'order'=> 'DESC',                             'caller_get_posts' => 1,                              'paged' => $paged ) );                         if (have_posts()) : while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><img src="<?php bloginfo('url');?>/wp-content/files_mf/<?php get_custom_field('game_poster', TRUE); ?>" width="80" height="110" alt="<?php the_title();?>" />
<?php the_title();?>
                              <?php endwhile; ?>                         <?php else : endif; ?>
                 <?php wp_reset_query(); ?>
      I want to show only posts that have at least 5 entries in the custom field 'krit_karakter'. Is that possible?


Exclude the_content (); from page password protection

I use a page template to show custom post type. All content from the custom post type should be password protected. I´d like to use the wordpress editor for some additional public information. Can I exclude `the_content();` from wordpress password protection? ### page-my-custom-post-type.php               // ================ PUBLIC AREA BEGINNS ================
Pubic-Area
          <?php     if (have_posts()) : while (have_posts()) : the_post();     the_content();     endwhile;      endif;     // ================ PUBLIC AREA ENDS ================                            // ================ PROTECTED AREA BEGINNS ================     if ( post_password_required() ) {             echo get_the_password_form();     }     else {               $index = 'A';     $terms = get_terms('marke');          foreach ($terms as $term) {         if($index != strtoupper(substr($term->name, 0, 1))) {             $index = strtoupper(substr($term->name, 0, 1));                  echo '
'. $index . '
';         }              ?>
<?php echo $term->name; ?>
         <?php $args = array( 'post_type' => 'cpt_auto', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC',              'tax_query' => array(                 array(                     'taxonomy' => 'marke',                     'field' => 'slug',                     'terms' => array($term->slug)                 )             )         );              // ============================= OUTPUT ==============================         $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();             the_title('
', '
');             the_content();              endwhile;          }     ?>               <?php }     // ================ PROTECTED AREA ENDS ================     ?>      Thanks Ogni


How modify the comment content persistently based on $wp_query?

For a plugin, I need to build my own very early post content and comment content filter. Post content/text changing works, i.e. the modifications end up in the client's browser. But my comment content/text modifications somehow are not persistent, i.e. the client receives the original comment text. The point in time I "hook in" is defined by the template_redirect hook. I then execute something like this:               global $wp_query;          // Iterate over all posts in this query.     foreach ($wp_query->posts as $post) {         // Edit post text         $post->post_content = "foo"; // works: ends up at the client              // Iterate over all approved comments belonging to this post         $comments = get_approved_comments($post->ID);         foreach ($comments as $comment) {             // Edit comment text             $comment->comment_content = "bar"; // this one is lost             }          }      As indicated via the source comments above, `$post->post_content = "foo";` has effect in this context, but `$comment->comment_content = "bar";` doesn't. To track this down at least a bit more, I applied a debug filter to the post content and to the comment content:               add_filter('the_content', 'var_dump');     add_filter('comment_text', 'var_dump');      After the content modification routine above, these filters print "foo" in case of post content, but the comment content is printed unchanged (the original content is printed). Hence, `$comment->comment_content = "bar";` seems to be a local modification, while `$post->post_content = "foo";` works as desired: globally. Or is the database even queried two times for comments so that my modification somehow gets overwritten at some point? I've tried to work with `$wp_query->comments`, too. But this variable is `NULL` at the point in time I want and need to hook in. The final and primary question is: **In my loop above, what do I have to do, to modify the comment content persistently?** FYI: I am using WordPress 3.0.1


What causes this error (generated while uploading any theme to this WP site)               Unpacking the package…          Incompatible Archive. PCLZIP_ERR_BAD_FORMAT (-10) :      Unable to find End of Central Dir Record signature      I've tried to upload several different popular themes to the site.


Problem with single posts not showing correct category sidebar

I'm looking for something very specific: I'm using a plugin called "Category and Tag Specific Widgets" to create category-specific html in the sidebar of each category. This only works if I click on the category name (`www.myblog.com/category`), but on a single post (`www.myblog.com/category/post`) it doesn't work... Is there a way to modify the single.php file so it ties the single posts to the categories? My permalinks are set to `%category/%postname`


Add Div IDs dynamically to CSS

I am trying my best to convert this amazing design in a wordpress plugin, but since I am not a developer and a noob, I can't get my head around it. Background image can be added in the post loop with div style. But what about: \-- Dynamic Ids (HTML & CSS) for each div box? -- Clip path for each image? Is it even possible to do it in wordpress? **EDIT:-** Sorry about not being clear. Below are the codes. Here's the JSfiddle   1. How do I make a sequential loop for the first markup where the post title is so that each post gets an id like box1, box2, box3 and so on.   2. in the second markup where the featured image is going to be a background image, how do I give the same post the id bg1, bg2, bg3 etc.   3. How to do a +240 in the `<x>` origin in the clip-path for each post. HTML

rooftops

streetstyle

citylife

citylife

      CSS                body { background:#ccc; margin:0; }     .container { /*width:1000px; margin:0 auto; position:relative;*/ }           .bg {        position:fixed;        top:0;        left:0;        width:100%;        height:100%;        background-position:50% 50%;       background-size:cover;       z-index:1;     }      .bg.reveal { -webkit-clip-path:none !important; z-index:2; }          .box {        width:200px;       height:200px;       position:relative;       z-index:10;        float:left;       line-height:200px;       text-align:center;       color:#fff;       cursor: pointer;       font-size:20px;       text-transform:uppercase;       font-family:Tahoma;       letter-spacing:1px;       margin:15px 0 0 35px;     }      JS               $('.box').hover(function(){       $($(this).data('bg')).addClass('reveal');     }, function(){       $($(this).data('bg')).removeClass('reveal');     });


Clearing cookie on logout and session expiration

I would like to clear the session cookie when a user logs out or when their session expires. I understand that `wp_clear_auth_cookie();` clears the cookie but I am struggling to understand how to implement it. I am using the following code to log a user out automatically if they are inactive for 10 minutes. (I think I found that in here too)               function myplugin_cookie_expiration( $expiration, $user_id, $remember ) {         return $remember ? $expiration : 600;     }     add_filter( 'auth_cookie_expiration', 'myplugin_cookie_expiration', 99, 3 );      Could someone kindly direct me to the right direction to achieve this result?


Move content between custom post types

I am importing a large amount of content from Expression Engine, the content in the other Expression Engine is all grouped together. I have created all the custom post types and taxonomies to organize the content better. However, Once I import the content to WordPress, I need to move the content into the newly created post types. How do I move content from one custom post type to another?


URL Redirection From Custom Type to Posts

I have a problem with Wordpress. I have custom type "review" and I migrate all its content into posts successfully. But I don't know how to redirect the old URL into new URL. The old URL format: **www.mysite.com/review/this-is-post** The new URL after migration into posts: **www.mysite.com/this-is-post** How to make redirection from old URL into new URL? So, if visitor visit the old URL, they automatically redirect to new URL. Thank you


Auto disable comments with custom field

i have this code to disable comments after X days based on publish date. How can edit this code to auto close comments based on a specific date using custom field? Thank you.               function close_comments( $posts ) {         if ( !is_single() ) { return $posts; }         if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( 30 * 24 * 60 * 60 ) ) {             $posts[0]->comment_status = 'closed';             $posts[0]->ping_status    = 'closed';         }         return $posts;     }     add_filter( 'the_posts', 'close_comments' );


404 errors when updating options in admin dashboard

Whenever I try to update my Permalink settings or use the Theme Editor to modify some file, I am redirected to a 404 page. This also happens when I update the All-In-One SEO Pack plugin's settings. This does **not** happen in the case of other settings pages or plugin options. I have tried re-uploading WordPress from a fresh local copy, and have also tried deactivating all plugins. My hosting provider has given up, blaming WordPress. What is wrong here? Some things I suspect:   * My `.htaccess` file. I am not using anything extra, other than turning off `mod_security`.   * Suhosin. After a recent security breach, my provider recompiled PHP with Suhosin. I have disabled it currently, which solved a lot of compatibility problems with other plugins.   * File/folder permissions.   * PHP memory issues, maybe?


What is the best way to enable nested shortcodes?

Is this the best way to enable nested shortcodes?: `add_filter( 'the_content', 'do_shortcode' );` I keep finding mixed results and want to be sure I won't break anything else!


Where to insert get_comments?

I'm trying to setup a page and extract comments from an external post. I took this advice how to pull wordpress post comments to a external page and now I have this get_comments code at my disposal:               <?php      $comments = get_comments('post_id=15');         foreach($comments as $comment) :         echo($comment->comment_author);     endforeach;     ?>      Where on the page do I place this? Sorry for the noob question!


Don't send notification if author comments his own post plugin help?

is there any way to set an IF statement, that If the author of the post commented or replied on his own post that the wp notification is not sent to him, only if a different user comments he would recieve the notification?. I am using the Notify on comment plugin.               <?php     /*     Plugin Name: Notify on comment     Plugin URI: http://www.artbits.it     Description: Send a notification on comment to the author of the post     Version: 1.03     Author: Fabio Trezzi      Author URI: http://www.artbits.it     */          function notifyOnComment_send($commentID){     global $wpdb;     // Get the email of the post's author     $comment = get_comment($commentID);     $post = get_post($comment->comment_post_ID);     $user = get_userdata($post->post_author);     $to = $user->user_email;     // Set the send from     $admin_email = get_option('admin_email');     $headers= "From:noreply@bonetoz.com\r\n";     $headers .= "Reply-To:$noreply@bonetoz.com\r\n";     $headers .= "X-Mailer: PHP/".phpversion();          $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);     $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");          $moderationOpt = get_option('notifyOnComments_moderationRequired');          if($moderationOpt == 'true'){         // Only send the notification if the comments requires to be moderated         $approved = $comment->comment_approved;         if($approved != 0) return;  // No need to send the mail the comment is already approved     }             $template = get_option('notifyOnComments_emailTemplate');      // If not setted load the default from file     if($template || $template == "") $template = file_get_contents(dirname(__FILE__) . '/defaultTemplate.php');          // Replace all the constant with the rights values     $template = str_replace("{postID}", $post->ID, $template);     $template = str_replace("{postTitle}", $post->post_title, $template);     $template = str_replace("{author}", $comment->comment_author, $template);     $template = str_replace("{authorIp}", $comment->comment_author_IP, $template);     $template = str_replace("{authorDomain}", $comment_author_domain, $template);     $template = str_replace("{authorEmail}", $comment->comment_author_email, $template);     $template = str_replace("{authorUrl}", $comment->comment_author_url, $template);     $template = str_replace("{commentContent}", $comment->comment_content, $template);     $template = str_replace("{commentLink}", get_permalink($comment->comment_post_ID), $template);     $template = str_replace("{commentID}", $commentID, $template);     $template = str_replace("{commentsWaiting}", $comments_waiting, $template);     $template = str_replace("{siteUrl}", get_option('siteurl'), $template);          $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_option('blogname'), $post->post_title );          @wp_mail($to, $subject, $template, $headers);          return true;          }          function notifyOnComment_menu() {     $path = dirname(__FILE__);     $pathElements = explode('/', $path);     add_options_page('NotifyOnComments options', 'NotifyOnComments', 'manage_options',   $pathElements[count($pathElements) - 1] . '/options.php');     }          add_action('comment_post', 'notifyOnComment_send');     add_action('admin_menu', 'notifyOnComment_menu');          ?>


Adding The Post Template Dropdown to WP-Admin

I'm developing a WP theme from the ground up for the first time. Having build WP sites before, I know there to be an option in Posts that will allow for the selection of a specific template. I have created the custom Post Templates with the appropriate headers, but the option to select anything is simply not there in WP Admin. Do I need to add something in functions.php in order for this to show? I've searched high and low for an answer but no-one seems to be having this issue and simply recommend disabling and enabling the theme, which has no affect. Thanks in advance! Template Code:               <?php     /*     Template Name Posts: Rooms Template     */     ?>          <?php get_header(); ?>

                          <?php if (have_posts()) :?><?php while(have_posts()) : the_post(); ?>
<?php the_title(); ?>

<?php the_content();?>
                             <?php endwhile; ?>                     <?php endif; ?>
               <?php get_footer(); ?>


Wrap all post images inside a div element

I searched for all kind of solution but i really could find one that did what i was looking for, what i simple want done is wrapping all images inside a div element, old post aswell as new posts. All help is very much appreciated p.s. I did a little jquery snippet but I really would like another solution the jquery code               <script>     $(function(){         $('a:has(img.postthumbimage)').wrap('<div class="myphoto" />');     });     </script>


getting url in wp_enqueue_style

I'm having trouble getting the second argument in wp_enque_style. Here's how my site is setup:   * style.css    * custom_style.css   * index.php In a template, I have this code:               $stylesheet_url = bloginfo('template_directory') . '/custom_style.css';      wp_enqueue_style( 'custom_style', $stylesheet_url );       Which isn't working. Any reasons why? The output is just the path to my template directory, outputted as raw text, which is obviously not the correct behavior.


Trouble Adding New Logo

I'm trying to replace an old logo on a site with a new one.   * The old logo was 222×120px    * and the new one is 222×150px.  I uploaded the new one and had it overwrite the old one. My site hasn't changed though. The 30px added to the new logo is the only difference between the two and it just says "Productions". There should be room for at least part of the "Productions" part to show, but it looks exactly like the old one. How can I fix this? I'm supposed to have this site finished today and this is the last thing stopping me from being done. The logo I'm talking about is the one in the top-left corner of this site. Thanks


Query from a different database than the default

I'm making a layout for a wordpress page. The layout needs to connect to a second database (both databases are in the same domain). But the problem is, when i execute just the file it works. But when i included inside the wordpress layout i don't get data, no errorrs, nothing The script is just:                $con = mysql_connect('host','user','pass');      mysql_select_db('db', $con);      $q = mysql_query('SELECT * FROM vars', $con);      var_dump(mysql_fetch_array($q));      As i say. If i execute the file alone: > http://example.com/blog/connect.php it works great, and returns data. But if i do inside the layout (creating a wordpress page, and giving the layout to it) Returns nothing. Any idea what can be happening there?


Modification to wp_list_categories

I dug this up to help me modify wp_list_categories and place the featured image from the latest post in that category, inside the generated li.               class CategoryThumbnail_Walker extends Walker_Category {         // A new element has been stumbled upon and has ended         function end_el( &$output, $category, $depth, $args ) {             // Output the standard link ending             parent::end_el( &$output, $category, $depth, $args );                  // Get one post             $posts = get_posts( array(                 // ...from this category                 'category' => $category->cat_ID,                 'numberposts' => 1             ) );             // If a post has been found             if ( isset($posts[0]) ) {                 // Get its thumbnail and append it to the output                 $featured = get_the_post_thumbnail( $posts[0]->ID, 'extrathumb', null );                 $output .= $featured;             }         }     }         Used thusly:-               <?php wp_list_categories( array(                                       'show_count' => 1,                             'walker' => new CategoryThumbnail_Walker()) ); ?>      This does almost exactly what I want, to output the featured image along with the category name and the post count from that category. The only problem is it outputs the img OUTSIDE the li, like so
Around The Web  1
           I need that image to be INSIDE the category li Any ideas?


What is a trackback

A new trackback on the post "Roll-o-matic_4" is waiting for your approval http://onboardsolutions.com/clean-room/disinfection-technology/vileda- professional/roll-o-matic-clean-room-mop/roll-o-matic_4/ Website : My Homepage (IP: 5.157.45.216 , 5.157.45.216) URL : http://www.z9U8DJqqx.org Trackback excerpt: **... [Trackback]**


get_posts and wp_autop (remove filter)

I just transformed my query_posts function in a get_posts function. Here is my old function:               <?php     // The Query     query_posts( 'cat=170&showposts=4' );     remove_filter('the_excerpt', 'wpautop');     // The Loop     while ( have_posts() ) : the_post();         echo '
 '; the_title(); echo '

'; the_excerpt(); echo '
';     endwhile;     // Reset Query     wp_reset_query();     ?>      Here's my new one                   <?php     $args = array( 'posts_per_page' => 4, 'category' => 170 );     $tag_posts = get_posts( $args );         foreach ( $tag_posts as $post ) :           setup_postdata( $post ); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

<?php the_excerpt(); ?>
         <?php endforeach;         wp_reset_postdata(); ?>      The problem is that now the `remove_filter('the_excerpt', 'wpautop');` directive doesn't work anymore.. I tried putting it before and after get_posts( $args );, doesn't affect the output.. :( how can I remove the filter for get_posts too?


How can I get the blog page ID?

As above, for example this is the blog page url: `http://192.168.1.100/wordpress/?page_id=30` Let assume that I don't know the exact ID of blog page and I want to write `if` condition for this page.


Putting php inside an echo php shortcode

I am using wordpress. I am using the plugin social locker. I have figured out how to display the shortcode via PHP: `<?php echo do_shortcode('[sociallocker id="3071"] My content Here [/sociallocker]'); ?>` However I want to display this button that will allow for a print popup in between there. This code is: `<?php if ( function_exists( 'pdf_print_popup' ) ) pdf_print_popup(); ?>` So my question is can I do this: `<?php echo do_shortcode('[sociallocker id="3071"] <?php if ( function_exists( 'pdf_print_popup' ) ) pdf_print_popup(); ?> [/sociallocker]'); ?>` If not what do I need to do? My goal is to make it so the social locker dissapears once the user shares and they see the print button. Thanks Guys :)


paginate_links() returns NULL instead of the pagination links, but pagination is actually happening

**What I'm trying to do:**   Print the pagination links on the home, which uses template `index.php`, with pagination functions such as `paginate_links()`, outside The loop. **What happens instead?**   Instead of getting the pagination links, `paginate_links()` just returns NULL. This would be ok if there was no pagination, I.E. there are fewer posts found by the query than the max posts per page setting. But there are actually 10 posts found (`paginate_links() == 10`) and only 5 are showing (`$wp_query->query_vars['posts_per_page'] == 5`) so it's evident that some kind of pagination is actually happening. If I set max posts per page to 10, all 10 posts show up on the home. **My code**   There's no significant code to post, but this is it:               get_header();     if( have_posts() ) {         while( have_posts() ) {             the_post();             the_title();         }     }     echo paginate_links();     get_sidebar();     get_footer();


Single Multisite Signup Page

I'm trying to turn the WordPress multsite signup page into a one step process instead of two. I'm wanting people to choose their username, email, password and a confirmation of their password, along with choosing their blog domain (subdomain), blog title, along with the captcha on one page. The way I have it set up now though, it doesn't work. It displays all the forms correctly, but it doesn't register the user or the blog and just takes you to a blank page when you hit "Create site." Here's the code for my custom sign up page: http://pastebin.com/pje9icNL What am i doing wrong here? Thanks in advance!


How do i retrive a post from a custom post type

How can i retrive a post from a Post Type were "distributie_seriale" is a relationship field. Ex: I add an Actor to PostType - actors ( Add post) next I add an Serial on PostType- serial ( Add post) I link the serial in Relathionship Field with the actor. After i do that i click Publish. Results: On the Serial Page i retrive the actor, but the question is... How i retrive the serial on Actor Page. Extra : The movies are in WP Post's The code down it retrive me the movies of post's Page. How can i retrive a post's that is select, from a Post Type , in my case -- serial               $movies = $wpdb->get_col("SELECT post_id FROM $wpdb->wp_postmeta WHERE meta_key = 'distributie' AND meta_value LIKE '%".get_the_ID()."%'");         $the_query = new WP_Query( array( 'post__in' => $movies) );


get_*_meta doesn't always return an array

I find it annoying that functions like `get_user_meta` or `get_post_meta` will return an array if the meta key exists or false if it doesn't. This means I need to do a check like so:               $meta = get_post_meta($id, $meta_key);     if ($meta) {         foreach ($meta as $value) {             // ...         }     }      I was hoping for a way where I wouldn't have to check if it's not a falsy value first.


How to use is_rtl with my main style.css?

Sorry if this is an ignorant question. I'm a first timer on working with rtl languages. Say we have a theme with standard style.css for English languages. so I use is_rtl() and this returns TRUE, we won't load the style.css and only rtl.css? IF someone can provide an example on this on loading rtl.css on rtl languages and style.css on other languages (aside from the WordPress documentation which I already seen), I would be happy. Thanks.


Filter results with custom field values and dropdown

I need to filter posts by a custom field value. My specific example:   * User browse to products > category 1 > subcategory A.    * ALL "subcategory A" items (products custom post type) are displayed as default by date.   * Each item in subcategory A has a custom field "size". User can select the size with a dropdown menu and posts are filtered displaying only items with "custom field:size" = "selected size". Filter is kept also in pagination, because products are on more pages. I've checked a lot of answers, but no case was simple as that. I was thinking about doing it using a custom search or a plugin, but I really don't know where to start. thanks for your help. EDIT: the custom field values are fixed, not auto-populated. The select can be built in plain html without extra queries.


how to add a .php file to wordpress

I have a php file in my server (say www.example.com/up/up.php). If i access that file through the url, my site says no page found. but i want to call that php file using url parameter. I want to call that file to a download file using url access( say www.example.com/up/up.php?f=207). can someone help me how to do this. as usual i searched fr few days for my problem and came here when i totally cornered. my up.php contains the following code               <?php /* Template Name: Upload */ ?>               <?php       $app_id = "12345678901234567890";       $app_secret = "12345678901234567890";       $post_login_url = "www.mysite.com";       $album_id = "7777";       $photo_url = "URL";       $photo_caption = "cool pics";            $code = $_REQUEST["code"];            //Obtain the access_token with publish_stream permission        if (!$code){          $dialog_url= "http://www.facebook.com/dialog/oauth?"           . "client_id=" .  $app_id           . "&redirect_uri=" . urlencode( $post_login_url)           .  "&scope=publish_stream";         echo("");       } else {         $token_url="https://graph.facebook.com/oauth/access_token?"           . "client_id=" . $app_id           . "&client_secret=" . $app_secret           . "&redirect_uri=" . urlencode( $post_login_url)           . "&code=" . $code;         $response = file_get_contents($token_url);         $params = null;         parse_str($response, $params);         $access_token = $params['access_token'];              // POST to Graph API endpoint to upload photos         $graph_url= "https://graph.facebook.com/"            . $album_id . "/photos?"           . "url=" . urlencode($photo_url)           . "&message=" . urlencode($photo_caption)           . "&method=POST"           . "&access_token=" .$access_token;              echo '';         echo file_get_contents($graph_url);         echo '';       }     ?>      I should pass a value to the url by using link


Getting all months in one year Wordpress Archive

Alright, I was starting on the code for my blog today when I ran into a little issue. However, before I ask my question, it my help if I actually explain what the functionality I am hoping to achieve. (you can also view my header comp at http://louisstephens.cc/comps/blog.png ) In my header, I am going to have the year with all the months listed under it. The current month will be selected showing all the posts for that month. However, the other months will also be selectable, and doing so will fade out the current month's post to show the newly selected month's posts (as well as changing the "active" state of the selected month). When a new year comes around, you can simply click on a side arrow (that will be next to the year), and it will slide the header over to that year and month set). Maybe this can't be done, but I was having an issue. For the life of me, I can not figure out how to show all the months regardless of them containing any posts. I know I can use:               <ul>     <?php wp_get_archives('type=monthly'); ?>     </ul>      But if no posts are present, no months show up. Has anyone ever figured out a way around this, or have any clue of what can be done to achieve my desired effect?


Raw output (preventing wpautop)

Using WordPress 3.5. I'm trying to put a `<form>` into a Page of a WP-based site. Unfortunately, WP is "helpfully" screwing up the formatting of the form by inserting `<br>` and `<p>` tags in inappropriate places next to the form controls. I don't want to disable `wpautop` globally, as it's still helpful for blog posts (particularly as this is a multi-author site). I don't even want to disable it for the whole of the page. I want some way to disable it only in this one specific section of this one page. I read in the WP changelogs that supposedly shortcodes do not run `wpautop` on their output any more, so I tried creating the following shortcode:               function raw_shortcode( $atts, $content = null ) {        return $content;     }     add_shortcode('raw', 'raw_shortcode');      Unfortunately this does not appear to work -- surrounding the form with this still results in undesirable breaks and paragraphs being added. I've seen a few examples suggesting a modification to the standard filters, but I've also read some other pages that suggest this is a bad idea.


Image uploaded in media library, can only see it when I using the WP Edit Image feature. 404 when trying to view in browser

I have an image that I've uploaded through the WP media library. I can see this image in my uploads folder via ssh/ftp. I cannot see this image if I put the URL in my browser, like www.site.com/files/image.jpg (It's a multisite and all uploads go into individual folders rather than be separated out by months). In WP, the image shows as broken in the media library listing of uploaded files. Only when I select this image file and choose "edit image" does the image show up. The 404 is not the regular WP 404 page template, it's a blank page that only says "404 — File not found." And the best part is that this does not happen for all images/uploads. Does anyone have any ideas I can take action on? EDIT: It looks like any file with "pdf" in the file NAME (not file extension) is having this problem. .pdf files work fine. I don't know why the filename would make this happen...


How to get userid at wp_logout action hook?

I need to perform some cleanup after a user logged out, so I added a wp_logout action hook. Problem is, wp_get_current_user() already returns null if called from within the wp_logout action hook. How do I get the logging out users userid inside a wp_logout action hook?


Wordpress wp_unregister_GLOBALS causing 100% Apache CPU Usage

I've been testing the Wordpress (by making about 5 requests/s) CMS, but the problem is that Apache is constantly using 100% of the CPU. Lately I've had enough of that and I've traced down a problem to the wp_unregister_GLOBALS function that's located in the /wp-includes/load.php file and called from wp- settings.php. The function is as follows:               function wp_unregister_GLOBALS() {             if ( !ini_get( 'register_globals' ) )                    return;                  if ( isset( $_REQUEST['GLOBALS'] ) )                    die( 'GLOBALS overwrite attempt detected' );                  // Variables that shouldn't be unset             $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' );                  $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );             foreach ( $input as $k => $v )                    if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) {                            $GLOBALS[$k] = null;                    unset( $GLOBALS[$k] );                    }     }      I've tried commenting out the whole function body and commenting the function call in wp-settings.php, but the Apache was still using 100% of the CPU. THe only thing that helps is chaning the name of the function; then Apache is fine and everything is OK. But I would like to know why; I know that the function unregisters the GLOBAL variables, but why is it taking up 100% of the CPU. And why is it taking up 100% of the CPU when I've commented out the entire function's body and just returning null? If anybody know the answer to the question, please let me know; otherwise it would be great to knowing whether I can change the name of the function for good: it's just for testing purposes only.


expecting 404 but redirecting to post with url subdirectory in post title

I'm seeing something unexpected, although I'm not sure whether it's a feature I can disable or whether it is something introduced by the custom theme I'm using that I need to track down. If I enter a url for a non-existent page, e.g. mysite.com/london, before throwing a 404 it will search for a post with a title that starts with "london" and show that if it finds it, e.g. mysite.com/events/london-weekend- party. (I have a number of different CPTs, but this redirect is CPT-agnostic, i.e. it doesn't seem to care which post type contains 'london' in the title. When I register the CPTs the only rewrite rule is for the slug, e.g. `'rewrite' => array('slug'=>'events'`.) I used the plug-in Debug This to look at the rewrite rules, but it hasn't helped because it appears to be showing the rule that matched after the rewrite happened, i.e. not that it matched against `mysite.com/london` but against the post it found, i.e. `events/([^/]+)(/[0-9]+)?/?$`. I only discovered the 'problem' because I was looking at how to intercept 404s before the 404 template is loaded to check the urls against a whitelist so that if I get a match for, say mysite.com/london, I can do something London- specific before a redirect. If anyone has any tips on where to get started with that, I'd be grateful to hear them. My first instinct was to $_GET hooked into wp but I'm not talking about `?name=value` style parameters.


Print_r displaying two different post->ID if placed in sidebar or single.php

My website is displaying, if print_r, two different ID for the same post. If i ask:               <?php echo $post->ID;?>      in the single.php it gives me a number. If i do the same thing in the sidebar it gives me a completely different one. This is what I get with the print_r on the single.php               stdClass Object ( [ID] => 59 [post_author] => 1 [post_date] => 2012-01-01 20:29:18      [post_date_gmt] => 2012-01-01 20:29:18 [post_content] => È universalmente     riconosciuto (...) [post_title] => fdsfdsfs [show_in_menu] => 1 [link_link] => 1     [no_follow_link] => 0 [alt_link_text] => [custom_link_class] => [redirect_url] =>     [target_blank] => 0 [alt_title_attribute] => [post_excerpt] => [post_status] => publish     [comment_status] => closed [ping_status] => closed [post_password] =>     [post_name] => fdsfdsfs [to_ping] => [pinged] => [post_modified] => 2012-01-07 19:53:44     [post_modified_gmt] => 2012-01-07 19:53:44 [post_content_filtered] =>     [post_parent] => 0 [guid] => http://www.museidibra.it/prova/?p=59 [menu_order] => 0     [post_type] => post [post_mime_type] => [comment_count] => 0     [ancestors] => Array ( ) [filter] => raw )      While this is what I get from the sidebar:               stdClass Object ( [ID] => 93 [post_author] => 1 [post_date] => 2012-01-02 08:39:29     [post_date_gmt] => 2012-01-02 08:39:29 [post_content] => prova 3 (...)     [post_title] => prova 3 [show_in_menu] => 1 [link_link] => 1 [no_follow_link] => 0     [alt_link_text] => [custom_link_class] => [redirect_url] => [target_blank] => 0     [alt_title_attribute] => [post_excerpt] => [post_status] => publish     [comment_status] => closed [ping_status] => closed [post_password] =>     [post_name] => prova-3 [to_ping] => [pinged] => [post_modified] => 2012-01-07 13:06:15     [post_modified_gmt] => 2012-01-07 13:06:15 [post_content_filtered] =>     [post_parent] => 0 [guid] => http://www.museidibra.it/prova/?p=93 [menu_order] => 0     [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw )      It is basically 2 different posts. NOTE: this thing happens only in post that i tagged. I f i don't tag the post, the resulting IDs will be the same. Here, you can find an example of this from my website, where print_r shows 2 different IDs for the same post. Help please, this thing is freaking me out. Thanks


More Fields WP Plugin

one of my clients use More Fields WP plugin and we want to generate a feed of the data entered using that plugin. http://wordpress.org/support/plugin/more-fields Have installed JSON WP plugin to generate the feed but the feed does not pick up the data entered using More Fields plugin. http://wordpress.org/extend/plugins/json-api/ is there a another WP plugin that will be able to pick up data entered using More Fields plugin? if not, what are the other options to get that data via a feed? also couldn't locate the data in the main tables?


Checking post format during xmlrpc_publish_post

WordPress apparently stores post format information outside of the `$post` object. During `publish_post` this isn't (usually) a problem because you can check on formats via `get_post_format( $post->ID )` outside the loop. This doesn't appear to work during `xmlrpc_publish_post` or `app_publish_post`. People have to be working around this to get plugin/theme functions working on mobile/desktop apps. My specific code is below in case it's an error on my end.               function posse_twitter( $post_ID ) {         error_log('Executing posse_twitter()');         global $post;         // check post format if necessary         if ( get_post_format( $post->ID ) != 'status' ) return;         error_log('posse_twitter() made it past format check');              $post_id = $post->ID;         $shortlink = wp_get_shortlink();         $tweet_content = $post->post_content.' '.$shortlink;              // ...run code once         if ( !get_post_meta( $post_id, 'tweeted', $single = true ) ) {                  error_log('posse_twitter() not tweeted before');                  // require the relevant libraries             require get_template_directory() .'/inc/posse/libraries/tmhOAuth/tmhOAuth.php';             require get_template_directory() .'/inc/posse/libraries/tmhOAuth/tmhUtilities.php';             $tmhOAuth = new tmhOAuth(array(                 'consumer_key'    => 'XXXXX',                 'consumer_secret' => 'XXXXX',                 'user_token'      => 'XXXXX',                 'user_secret'     => 'XXXXX',             ));                  $code = $tmhOAuth->request('POST', $tmhOAuth->url('1/statuses/update'), array(             'status' => $tweet_content             ));                  error_log('posse_twitter() made it past tmhOAuth, should be on Twitter now');                  update_post_meta( $post_id, 'tweeted', true );         }     }          add_action( 'xmlrpc_publish_post', 'posse_twitter' );      add_action( 'app_publish_post', 'posse_twitter' );     add_action( 'publish_post', 'posse_twitter' );      `error_log()`s included since I've been debugging this. It's firing when `xmlrpc_publish_post` and `app_publish_post` get hit, but it doesn't make it past the format check. Update: This also doesn't work even if I save the post as a draft first (via XML-RPC).


Combining wordpress themes

Is there any way to combine two Wordpress themes without using a plug-in that renders pages in different themes, and if there is, what is the most efficient way to do so? Is it as simple as copying and pasting one theme's function.php (and other files) into the first theme? Do I make a child theme? I'm trying to build a database for clean energy initiatives across the globe, and like the map functionality of one the themes I've purchased. However, once you go pass the map, the theme is not very user-friendly and cannot hold a lot of information. This is where the second theme comes in. I want to keep both the functionalities of both themes if possible.


Adding a filter to qTranslate to change display of language chooser

This is a problem I am having with qTranslate, but I suppose the solution is more of an instruction in how Wordpress hooks and filters work. Instead of using the qTranslate widget, I am using the hook               <?php echo qtrans_generateLanguageSelectCode('text');?>      to call the language chooser in my header and then modifying its appearance in my CSS. This is no problem. However, I would like to add a "style" to the Language Select Code function so that instead of displaying the full language text, which would be "Francais" and "English" in my case, it will show just the language code instead (`EN` and `FR`). I had figured this out by changing (and I know this a very bad thing to do) `qtranslate_widget.php` and adding a new case to function `qtrans_generateLanguageSelectCode($style='', $id='')`. This worked great, but then I updated Wordpress and had to update qTranslate as well, so obviously my modification went away. So instead of re-doing that operation, I was wondering if anyone has any suggestions for how to add a filter to the function in my own theme's functions.php? I figure it would be something like               add_filter('qtrans_generateLanguageSelectCode', 'qtrans_myLanguageSelectcode',      but after that I get lost and don't know enough about filters. I hope this is clear enough! When I updated, I obviously lost my modification but I think that below is what should work (I haven't tested it yet!)               case 'code':     foreach(qtrans_getSortedLanguages() as $language) {                 $classes = array('lang-'.$language);                 if($language == $q_config['language'])                    $classes[] = 'active';                 echo '''.$language.'';              }     break;      Not to make this post too long, but the following is the existing function in the qTranslate plugin:                   // Language Select Code for non-Widget users     function qtrans_generateLanguageSelectCode($style='', $id='') {         global $q_config;         if($style=='') $style='text';         if(is_bool($style)&&$style) $style='image';         if(is_404()) $url = get_option('home'); else $url = '';         if($id=='') $id = 'qtranslate';         $id .= '-chooser';         switch($style) {             case 'image':             case 'text':             case 'dropdown':                 echo '
';                 foreach(qtrans_getSortedLanguages() as $language) {                     $classes = array('lang-'.$language);                     if($language == $q_config['language'])                         $classes[] = 'active';                     echo '
'.$q_config['language_name'][$language].'
';                 }                 echo "

";                 if($style=='dropdown') {                     echo "\n";                 }                 break;             case 'both':                 echo '
';                 foreach(qtrans_getSortedLanguages() as $language) {                     echo '
'.$q_config['language_name'][$language].'
';                 }                 echo "

";                 break;         }     }


Posts in sidebar only by admin

I want to show in latest posts widget only posts by admin (now its showing latests posts by all suers). How I can do it ? via wp query ? Thanks :)               <?php // setup the query                         $args='&posts_per_page='.$numreviews.'_reviews&order=DESC&orderby='.$feedsort.$metakey;                                                      $cust_loop = new WP_Query($args);                          if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;                             // if we're sorting by rating and this item does not have a rating, hide it                             $rating = get_post_meta(get_the_ID(), "Rating", $single = true);                              if(($rating && $feedsort=="meta_value") || ($feedsort!="meta_value")) {                                                                      $ratings = con_setup_rating($rating); //setup the ratings array                                       ?>
                                                                                <?php con_show_rating($ratings[0], $ratings[1], $ratings[2]); // show the stars or hearts ?>                                          <a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>
                              <?php } ?>                          <?php endwhile;                      endif;                      wp_reset_query(); ?>


Separate page for comments using permalinks and add_rewrite_rule

I have been at this for days now, going through plenty of answers here, guides on using .htaccess, guides on using add_rewrite_rule() within Wordpress and examples throughout the web. I am not sure if there is a malfunction in my regex to detect the correct URL, or a disconnect between what I want to accomplish and what can be accomplished. Basically, I am trying to separate comments from posts (or better yet, comments from content) by forcing them to a separate page "associated" with the content. So for example, `http://localhost/wp/2011/02/25/hello-world-2/` is a post, and the comments for that post should appear at `http://localhost/wp/2011/02/25/hello-world-2/comments/`. Now, a "little bird" once said that this could be done with the following: `RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/comments/?$ /index.php?year=$1&monthnum=$2&day=$3&name=$4&comments=1 [QSA,L]` (seeing as I do not really need to work inside the /archives/ for my above example to work, I removed it), which I translated into this plugin:               <?php     /*     Plugin Name: Gingah Permalink Rewrite     Plugin URI: http://gingahmail.com/wordpress/     Description: Useful Permalink-structures, that required a plugin to work.     Version: 1.0     Author: Gingah     Author URI: http://gingahmail.com/     */          register_activation_hook( __FILE__, 'gingah_rewrite_activate' );     function gingah_rewrite_activate() {         gingah_rewrite();         flush_rewrite_rules();     }     register_deactivation_hook( __FILE__, 'gingah_rewrite_deactivate' );     function gingah_rewrite_deactivate() {         flush_rewrite_rules();     }     add_action('admin_init', 'gingah_rewrite');     function gingah_rewrite() {         add_rewrite_rule( '^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/comments/?$', '/index.php?year=$1&monthnum=$2&day=$3&name=$4&comments=1 [QSA,L]', 'top' );     }     ?>      (based on countless examples _just_ like it, around the web) This does, however, not work. Even though, visiting `http://localhost/wp/2011/02/25/hello-world-2/?comments=1` does produce the expected result. So what is going wrong here?