Using add_filter() in Widgets

Just have a query reference the `add_filter()` function. Can you use this function inside a WordPress widget class. **Example** I have a widget with dynamic created code that I want to pass to another function created within the plugin. Can this be achieved?               <?php     /**      * Display the actual Widget      *      * @param Array $args      * @param Array $instance      */     public function widget($args, $instance){              extract($args);              /* All the widget code. Hidden to save space */              /* Generate unique id if shortcode - used for styling */         $sc_id = mt_rand(1, 100000);         $wcss = '';              /* Here is the actual output code that I want to pass to another function I created */         $wcss .= ".awp_archive_widget_sc".$sc_id." { border:".$awp_archives_border_width.' '.$awp_archives_border_style.' '.$awp_archives_border_color." !important }\n";         $wcss .= $awp_archives_border_radius == 'round' ? '.awp_archive_widget_sc'.$sc_id.' { -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px }' : ''.''." \n";         $wcss .= ".awp_archive_widget_sc".$sc_id." li a, .awp_archive_widget_sc".$sc_id." li { font-size:".$awp_archives_font_size." !important }\n";         $wcss .= ".awp_archive_widget_sc".$sc_id." li a { color:".$awp_archives_link_std." !important }\n";         $wcss .= ".awp_archive_widget_sc".$sc_id." li a:hover { color:".$awp_archives_link_hover." !important }\n";              $out = '';              /* Rest of widget code - hidden to save space */              echo $out;     }     ?>      The code marked `$wcss` is the actual code that I want to pass to another function. I thought I could do something like this from within the plugin constructor.               add_filter('advanced_widget_pack_css',array(&$this,'$this->widget'));      Any help would be greatly appreciated. Just not sure how to achieve this from within the widget class. **Additonal Code** The plugin allows for custom css styles through creating a custom CSS file through WordPress AJAX. Here is how I generate the custom AJAX CSS stylesheet: **Generate WordPress AJAX CSS file**               /**      * Enqueue the widgets stylesheet      */     public function add_awp_css(){              wp_enqueue_style($this->hook, plugins_url('advanced-widget-pack/css/advanced-widget-pack.css' , dirname(__FILE__)), array(), '', 'screen');               wp_enqueue_style(             $this->hook.'-custom',             add_query_arg(                 array(                     'action' => 'advanced_widget_pack_gen_css',                     /* Include this to ensure changes don't get cached by the browser */                     'layout' => substr(md5(serialize($this->hook)), 0, 8)                 ),                 site_url()             ),             array($this->hook),             $this->version         );       }      This works greats. Now the function that the above enqueue calls is this: **The callback function for the WordPress AJAX CSS file**               /**      * Echo the CSS for the custom widgets style      */     public function advanced_widget_pack_css() {         if(empty($_GET['action']) || $_GET['action'] != 'advanced_widget_pack_gen_css') return;         if(!isset($_GET['ver'])) return;              $css_text = '';              /* ============================= */         /* Archives Widget               */         /* ============================= */         if(awp_option('archives_style_border') == 'true'){                   $css_text .= ".awp_archive_widget { border:".awp_option('archives_style_border_width').' '.awp_option('archives_style_border_style').' '.awp_option('archives_style_border_color')." !important }\n";             $css_text .= awp_option('archives_style_border_radius') == 'round' ? '.awp_archive_widget { -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px }' : ''.''." \n";         }             $css_text .= ".awp_archives_colour { color:".awp_option('awp_archives_dropdown_inst_colour')." !important }\n";               /**          * Filter the unprocessed CSS array          */         $css_text = apply_filters('advanced_widget_pack_css', $css_text);              header("Content-type: text/css");         echo $css_text;         exit();     }      This above function also works fine. It outputs a CSS file.


I am not able to enable jQuery in theme settings

I have tried to - enable `Use jQuery` & then save changes. But after saving changes, checkmark `Use jQuery` automatically unchecks itself. I am not sure whats going on. Please help me here. ![enter image description here](http://i.stack.imgur.com/pjmS7.png)


PHP code for link with text

I was exploring and ran across this post: Grab First Link From A Post, Grab First Blockquote I would basically like to do the same thing, but have it call not only the URL but also the link, since I am using the link as an excerpt title. For example; if my link is `<a href="http://www.facebook.com/>Facebook</a>` I want it to call a link that says `Facebook` not one that says `http://www.facebook.com` like the current code does. This is probably easy when given the code provided already, but I can't figure it out.


What is the general cut-off date for reviewed themes in the WordPress.org repository?

I know that the theme review team has been active for about one year now. Thanks to their hard work and diligence, the themes in the repo are _much_ better now than ever before. However, I have noticed that there are still older themes in the repo that, at first glance, probably would not pass the review if submitted or updated today. Is there a date that anyone can point to where we might want to be wary of any themes that were last updated before then? On a related note, is there a plan to possibly phase out some of these themes?


Admin - create custom post status and display above table

How do I create a custom post status and display it above the table of my custom post type? Example: `All(9) | Published (7) | Custom_Status(2)` I used the advance custom fields plugin to create a dropdown which represents the status of the post. But I'm sure that that does not represent the actual status of the post since it won't be saved in the `post_status` column in the database. Feel free to suggest plugins. I tried the edit flow plugin, but it's kinda inconvenient because every time I change the status of my post it will un- publish the post. Thanks!


Fast way to add countries as a custom taxonomy term?

Is there a quick way to add a list of countries as terms to a custom taxonomy called "Country"? Is there an existing import file, SQL script ect... I don't want to be there all day manually adding them. Any ideas would be great.


query a newly created table using $wpdb

i created a new table inside my wordpress database called `forms`, this table consist of `ID` and `names` i want to query all the list from this table using the wordpress `$wpdb` this is my code below               <?php         global $wpdb;         $result = $wpdb->get_results ( "SELECT * FROM  $wpdb->forms" );         foreach ( $result as $print ) {               echo $print->ID.'<br/>';        }     ?>      but im only getting a text `Array` from my `echo`


Sortable columns and admin like interface for tables/report in custom plugin?

We have wordpress admin interface for "all posts" list. Sortable column methods are available for "custom post type". But can we not implement this type of wp-admin like interface with sortable columns in any reporting/table in our any custom plugin that show a tabular report or listings fetched from database?


Manage PDF downloads and protected pages

I am re-building an old CMS site (I think it was built using Front Page) to update its appearance, and usefulness. Have successfully completed most of its structure and content, but am quite uncertain as to how I can implement 2 new and different page types. I need one page to show a 2-column, 13-row table which will contain hyperlinks for current year's and previous year's monthly newsletters (which would be uploaded as PDFs). Cannot find how to do this. My second problem is that I wish to have 1 to 3 separate pages that would require logins/registration for privacy. (All other pages on this site are Public). Each page would address a different population, so most names would not repeat from one page to another, but a few will. Again cannot find a method to implement this. Is anyone able to point me in the right direction? Would most appreciate it...


How to implement filesystem cache in Wordpress

I'm currently using the Transients API to cache some product details from Amazon. Now I'm looking into adding a file system cache. But I have no idea how to implement it. The only thing that I can think of is to actually save the JSON string representation of a specific product into a text file. Is this worth it? Are there any proven performance benefits when doing this or does it have the same performance to that of the database? Thanks in advance.


Separately formatting date elements

I am trying to achieve the following look in the time format: ![enter image description here](http://i.stack.imgur.com/u4Rh9.png) I have for now several issues,   First is that the month and year are not displayed at all, I use `<?php the_date('D'); ?>` `<?php the_date('M'); ?>` `<?php the_date('Y'); ?>` for start and only the day is shown, Second - Are there WP functions I can use to   * Get the month in 3 cap letters?   * Get only 2 last digits of year? Or I have to use my own PHP functions for that? Also, it must be hard-coded in the theme, because otherwise it will mess up the design. **Update**   I used `<?php echo get_the_date('M'); ?>` and I got all the times, but isn't `the_date` meant exactly for that?


pagination links not displaying

I'm unable to get my 'next_posts_link()' and 'previous_posts_link()' to display. So far I've tried the standard first debug by deactivating all plugins and clearing the cache, I've also tried removing the optional parameters from the call. And I've also tried using wp-pagenavi, which does display but oddly only when I set my Reading options to show 1 post per page and even then it only shows 2 page links. The site I'm having the problem with is pixelsandtea.com and here's the code on my home template page.               <?php get_header(); ?>

             <?php                 $args = array( 'post_type' => array( 'post', 'portfolio', 'news' ) );                 $loop = new WP_Query( $args );                 while ( $loop->have_posts() ) : $loop->the_post();             ?>             <li class="article preview" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>
                 <?php $content = $post->post_content;                 $searchimages = '~]* />~';                 preg_match_all( $searchimages, $content, $pics );                 $iNumberOfPics = count($pics[0]);                 if ( $iNumberOfPics > 0 ) { ?>                     <a href="<?php the_permalink(); ?>" class="thumb" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&w=279&zc=1" alt="<?php the_title(); ?>" /><?php                 }                 the_excerpt(); ?>
                     Posted: <?php the_time(__('l, jS F, Y')) ?> ˑ <?php printf(__('Filed under: %s'), get_the_category_list(', ')); ?> ˑ <?php the_tags(); ?>
                     <?php comments_popup_link(__('No commentaries for this post yet. You could be the first!'), __('1 Comment'), __('% Comments'), '', __('Comments are closed') ); ?><?php edit_post_link(__('Edit this entry'), ' ˑ ', ''); ?>

             <?php endwhile; ?>

<?php next_posts_link() ?>

<?php previous_posts_link() ?>

     <?php get_footer(); ?>      Thank's all!


Custom nav menu not showing

I want to make a custom menu that will be a select-box, I registered a custom menu:               add_action( 'init', 'register_my_menu' );          function register_my_menu() {         register_nav_menu( 'primary', 'Primary Menu' );     }      I added a custom menu crawler to the heading using this: How to use wp_nav_menu to create a select menu dropdown?                                <?php                 class Walker_Nav_Menu_Dropdown extends Walker_Nav_Menu{                     function start_lvl(&$output, $depth){                         $indent = str_repeat("\t", $depth); // don't output children opening tag (`<ul>`)                     }                          function end_lvl(&$output, $depth){                         $indent = str_repeat("\t", $depth); // don't output children closing tag                     }                          function start_el(&$output, $item, $depth, $args){ // add spacing to the title based on the depth                         $item->title = str_repeat(" ", $depth * 2).$item->title;                              parent::start_el(&$output, $item, $depth, $args);                              // no point redefining this method too, we just replace the li tag...                         $output = str_replace('<li', '<option', $output);                     }                          function end_el(&$output, $item, $depth){                         $output .= "</option>\n"; // replace closing
 with the option tag                     }                 }                      wp_nav_menu(array(                     'theme_location' => 'primary', // your theme location here                     'walker'         => new Walker_Nav_Menu_Dropdown(),                     'items_wrap'     => '<select>%3$s</select>',                 ));             ?>               And created a custom menu in the WP-Admin ![enter image description here](http://i.stack.imgur.com/pnvJ2.png) But still the menu doesn't show. What am I missing? **Update**   Apparently The crawler function does make an output but it is messed up,   When I use just `register_nav_menu( 'primary', 'Primary Menu' );` I get a working menu.

                 <option id="menu-item-54" class="menu-item-54"></option>                 <option id="menu-item-24" class="menu-item-24"></option>                 <option id="menu-item-30" class="menu-item-30"></option>                 <option id="menu-item-18" class="menu-item-18"></option>                 <option id="menu-item-22" class="menu-item-22"></option>                 <option id="menu-item-26" class="menu-item-26"></option>                 <option id="menu-item-13" class="menu-item-13"></option>                 <option id="menu-item-28" class="menu-item-28"></option>                 <option id="menu-item-15" class="menu-item-15"></option>                 <option id="menu-item-2" class="menu-item-2"></option>                 <option id="menu-item-20" class="menu-item-20"></option>

           This is what I get when using the exact same function in twenteleven theme (which is what I want):
             <select>                 <option id="menu-item-59" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-59">Sample Page </option>                 <option id="menu-item-60" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-60">  News</option>                 <option id="menu-item-65" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-65">About   </option>                 <option id="menu-item-62" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-62">  Contact Us</option>                 <option id="menu-item-63" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-63">  Our Location</option>                 <option id="menu-item-61" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-61">History</option>                 <option id="menu-item-64" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-64">Links</option>             </select>
           **Update**   I solved the problem. apparently the custom menu was selected when I used another theme and I assumed every theme will uset. well - no! I had to select custom menu for each theme separately.


Sort posts based on multiple custom fields

I have a three custom fields   * Meta Key -> YOUR_PREFIX_newcar_body_type   * Meta Key -> YOUR_PREFIX_newcar_transmission_type   * Meta Key -> YOUR_PREFIX_newcar_variant and I have to sort posts based on these custom fields and print the title of the post... Any ideas?


how to exclude "featured" posts from the main loop?

In a category.php template, I built a function that lists "featured" posts before the main loop. The featured posts are selected using a custom field and get_posts():               function list_featured_articles(){      $featured_posts = get_posts('meta_key=featured_article&meta_value=on&numberposts=10&order=DESC&orderby=post_date');     }      My category.php template:               echo list_featured_articles();     get_template_part( 'loop', 'category' );      It works fine, except that the featured articles are listed also in the category list of articles. I would like, from my function, get the featured posts' ID and remove them from the main loop. Is there a proper way to do it? I figure i could use a GLOBAL variable storing an array of excluded ids, but i'd like to avoid using Globals for that.


Get total number of comments from posts in a specific custom taxonomy

I’m having some difficulties trying to get total number of comments from posts **within** a specific custom taxonomy. The setup is as such: I’ve created a custom taxonomy for my posts, called “features”. Within that taxonomy I’ve like four or five terms. Then, some of my posts are put into feature-term 1, feature-term 2, etc. I can get this to work and when making a query I can also retrieve how many posts are in each term. But then I would like to show the total number of comments that all the posts within each feature-term has. So for example, under feature-term 1, the total number of posts is 12 and the total number of comments are 34. I’ve tried with this query:   `SELECT SUM(comment_count) AS totalcc FROM wp_posts, wp_term_relationships WHERE wp_term_relationships.term_taxonomy_id = {$term->term_id} AND object_id = ID`   But it gives me an incorrect answer can I can’t quite get an overview of where I’m failing. Maybe there is an easier way to do it, a way that Wordpress provide but if so I haven’t been able to locate that. Any help or suggestions would be appreciated. Sincere   - Mestika


How to group the loop posts in a particular by author?

I have links going to category pages on a WordPress blog. These category pages show all the posts that are in that category and sub-categories. I want to group these lists by the authors. I guess need to modify category.php to first list all the authors which have posts in that particular category and then run WP_Query multiple times for each author. The second part is okay, but I can't figure out how to get the list of authors of only those posts in this category.


Redirect Loops Problems

I don't know what happened actually. Yesterday, it was just working fine. I recalled what I did to put me in this difficult situation this morning. Yesterday, I was just editing posts with PhpMyAdmin. Well, anyway, I disabled all plugin and find out what is not working. It's the Plugin Custom Permalinks. **My problem is that I have about hundred videos in youtube, and each video is given with Custom Permalink set. I want to keep the Custom Permalink Plugin and get rid with Redirect Loop Problems.** I now disable my Custom Permalink Plugin and everything work as it is. But this of course is not a good solution. Please help. If you need whatever codes and details plugin lists, please let me know.


Aligning the thumbnail image

I want to control the alignment of the featured image(the thumbnail) with the options given in the 'Set featured image' pop box.               <?php if(has_post_thumbnail()) {        echo '
'; the_post_thumbnail(); echo '
';     } ?>      I want to add to the div with the class of border a class floatleft or floatright(or nothing) according for what the user chooses. Thanks!


Multisite get_home_url(); - Getting URL for current site

What would be the replacement for get_home_url() when using a multisite? For example, if I have one theme installed across several sites, and within the theme there are links that need to be specific to the current site. On my single install, using get_home_url(); would give me http://domain.com/, which was great, and if I moved the theme to a different domain, nothing would be affected. But when I'm using the same theme on a multisite, get_home_url(); gives me http://domain.com/ no matter which site I am currently on. What I would need for each one is domain.com/sitename/. Is there a different tag to use in this case? Thanks! EDIT Can't answer my own question yet, but `<?php echo get_bloginfo( 'url' )?>` was exactly was I was looking for.


Custom post type adding additional markup

I'm creating a template but every time I add a new custom post type (in this example neighborhood) it keeps injecting a new `<ol>` and `<li>` here is the code I currently have and I'm using the ACF Advanced Custom Fields plugin to create my custom fields.               <?php          /*            Template Name: Neighborhoods Page          */          include(TEMPLATEPATH."/header-internal.php");?>

              <?php              $args = array(             'post_type' => 'neighborhoods'         );              $the_query = new WP_Query( $args );              ?>                   <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

<a href="<?php the_field( 'url_neighborhood' ); ?>"><?php the_field( 'neighborhood_name' ); ?>

              <?php endwhile; else: ?>
There are no posts or pages here
              <?php endif; ?>
               <?php get_footer(); ?>


filter on the_content stopped working when I updated to WP 3.6.1

I created a filter to add a pin button on to my blog posts' images, which after much playing worked. Then, a few weeks later, I updated to 3.6.1, and the filter stopped working. Did something change in the new release that would prevent filters on the_content from working?               function cd_insert_pinterest($content) {             global $post;             $postID = $post->ID;                if( is_singular() && is_main_query() ) {                     $posturl = urlencode(get_permalink()); //Get the post URL                     $pindiv = '';                     $pinurl = '';                     $pinend = '';                     $pattern = '//i';                     $replacement = $pindiv.$pinurl.'$2.$3'.$pindescription.$pinfinish.''.$pinend;                     $content = preg_replace( $pattern, $replacement, $content );                     $newpattern = '/<\/a><\/span><\/a>/i';                     $replacement = '';                     $content = preg_replace( $newpattern, $replacement, $content );                }                                     return $content;          }          add_filter( 'the_content', 'cd_insert_pinterest');


Some doubts about how to show posts in a custom theme?

I am pretty new in WordPress theme development and I have some doubt about this WP function used to show my post in the homepage:                   <?php             if ( have_posts() ) :                 // Start the Loop.                 while ( have_posts() ) : the_post();                          /*                      * Include the post format-specific template for the content. If you want to                      * use this in a child theme, then include a file called called content-___.php                      * (where ___ is the post format) and that will be used instead.                      */                     get_template_part( 'content', get_post_format() );                      endwhile;                 // Previous/next post navigation.                 twentyfourteen_paging_nav();                  else :                 // If no content, include the "No posts found" template.                 get_template_part( 'content', 'none' );                  endif;         ?>      Intuitively I understood that as long as there are posts these are displayed in the homepage. My doubt is related about this line of code:               get_template_part( 'content', get_post_format() );      Reading the documentation it seems to me that: 1) **get_template_part** : Load a template part into a template. So I think that by this line I am including a template part used to show a post (the structure of a post into my homepage), is it correct? 2) What exactly do get_post_format() ?


Add Sort Link in Custom Post Type List

I need to add a link here, beside the Published link: ![enter image description here](http://i.stack.imgur.com/TwnQL.jpg) How can I do it? I'm trying to filter my custom post type by meta values and need a link to do it. Thanks.


User Attach Images To Post From Front End

Making a site that deals with custom parts. Id like to make it so when i make a post about a part i have a image upload button on that post in the frontend that lets users upload their custom pics to that post. The images would of course have to attach to that post. Looked over the search results here and on google and all i see is posting on front end with images. Nothing about letting users just attach data.


Load complete image, but don't bother the site speed

I designed and developed a site for my client. For images, I used the default WordPress sizes: `original`, `large`, `medium` and `thumbnail` (although I made some minute changes in their dimensions). As I heard about the resizing images (i.e. `large`, `medium` etc.), it enhances the site speed, and I need them eagerly. Just now, I've learned about the LazyLoad, I hope I'll implement it later inshALLAH, but for now...   in homepage I used the `thumbnail` size: `the_post_thumbnail( 'thumbnail' );`. But unfortunately the cropped `thumbnail` image from the `original` is looking bad. And also I don't want to load the `original` sized image, because that will hamper the site speed badly. **Question:**   How can I manage it then? ### EDIT I, actually want my `thumbnail` images to be cropped with the complete detail of the `original` image, but it actually cropping very precise part of the `original`. How can I enable my WP to crop the `original` image to a `thumbnail` with its complete detail? ### EDIT 2 It's actually nothing but a default WP things:                       <?php if ( has_post_thumbnail( ) )  { ?>                 <a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'your-theme'), the_title_attribute('echo=0') ); ?>" rel="bookmark">                 <?php the_post_thumbnail( 'thumbnail' ); ?>             <?php } else { ?>                 <a href="<?php the_permalink(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/no-image.jpg" width="168" height="168" alt="Sultan Stationery - no image provided"/>             <?php } ?>


Add select field to media uploader that adds a class to the image

I'm looking for a way to add a `<select>` menu to the media uploader that will have two options: normal image, which will do nothing, and profile image, which will add a CSS class to the image if it is selected. I have gotten as far as adding the select menu to the uploader, but I don't know how to:   * apply a class to the image based on the selected option   * make sure the selected option stays selected   * make sure the selected option can be changed later This is what I have so far:               function my_profile_image_select( $form_fields, $post ) {         $form_fields['image-type'] = array(             'label' => 'Image Type',             'input' => 'html',             'helps' => 'Enter "profile-image" to enable profile image caption',         );              $profile_image = 'profile-image';         $normal_image = 'normal-image';         $form_fields['image-type']['html'] = '<select name="Profile Image Select" id="Profile Image Select">';         $form_fields['image-type']['html'] .= '<option value="' . $normal_image . '">Normal Image</option>';         $form_fields['image-type']['html'] .= '<option value="' . $profile_image . '">Profile Image</option>';         $form_fields['image-type']['html'] .= '</select>';             return $form_fields;     }     add_filter( 'attachment_fields_to_edit', 'my_profile_image_select', 10, 2 );


yoast seo plugin - remove bulk title and description editor menu from non-admins

Is there a way to remove the yoast-seo-plugin's bulk title and description editor menu from the non-admins. It is an awesome feature but I would like my users to keep off from it. I am using the very latest versions of wp and the plugin. ![enter image description here](http://i.stack.imgur.com/8rqsB.png) * * * I am trying a few variations of this code, but does not seem to be working.               if ( ! current_user_can('create_users') ) {          add_action( 'admin_menu', 'nonadmin_remove_bulk_menu', 999 );              function nonadmin_remove_bulk_menu() {         remove_menu_page('page=wpseo_bulk-title-editor.php');       }     }


Force Uploads Use Yearmonth to off (0) for all existing sites in Multisites

In WordPress Multisite, by default the site option **Uploads Use Yearmonth Folders** is on (set to 1). Is it possible to force this value for all existing sites in the Network? Perhaps a hook?   I know that for new sites created one can use:               function simplify_upload_folder($blog_id){         switch_to_blog($blog_id);         update_option('uploads_use_yearmonth_folders', false);         restore_current_blog();     }     add_action('wpmu_new_blog', 'simplify_upload_folder');      But what about already existing sites can one force this value via an action or filter? As an alternative to using a filter, I have written up the following to toggle the value in the DB but for some reason the field remains empty. Not sure where I am going wrong here:               if ( get_option( 'uploads_use_yearmonth_folders' ) == true || get_option( 'uploads_use_yearmonth_folders' ) == '' ) {           switch_to_blog($blog_id);           update_option('uploads_use_yearmonth_folders', false);           restore_current_blog();     }


Load page template with custom content using a plugin

I want to load the `page.php` template with the content I specify (using variables and not from the database) if the request contains a particular query string. So lets say a user requests `example.com/?var1=str1` the page template should be displayed with the title and content I specify using variables. This is the pseudo code of what I'm trying to achieve               <?php     function my_page_function() {     if($_REQUEST['var1'] == "str1")     {     $title="This will be the title of the default page template";     $content="This content will be displayed on the default page template.";     //Load the page.php here with the title and content specified in the variables above     }     }     add_action("template_redirect","my_page_function");     ?>      I wish to use this code in a plugin, so it should work with any theme's page.php.


How to remove the extra characters passing in the Custom post type

I have created the custom post type and the custom taxonomy. Then I have created the template file in the name of taxonomy taxonomy-product-categories. I created the post type, then added to the menu. When the menu is clicked . The url takes the junk character as #.UW1Rl0pfTxU at the end


nextgen gallery: how to get picture url by gallery id

All posts in my site have custom field with nextgen gallery ID. To display gallery I use this code:               $gallery_id = get_post_meta( $post->ID, 'galerijos_id', true); // Get gallery id from custom field data      if( $gallery_id ){        echo '
';        echo nggShowGallery( $gallery_id ); // Display the gallery        echo '
';      How do I get pictures urls by gallery ID? I need url to pass to xml file. Thanks in advance.


Add "drop-down arrow" for menu items with sub-menus

WordPress doesn't add `parent` class to menu items that have submenus. Therefore this is required to extend this:               function add_parent_css( $classes, $item ) {         global $have_children;         if( $have_children ) {             $classes[] = 'parent';         }         return $classes;     }     add_filter( 'nav_menu_css_class', 'add_parent_css', 10, 2 );          class custom_walker extends Walker_Nav_Menu {       function display_element($element, &$children_elements, $max_depth, $depth=0, $args, &$output){         $GLOBALS['have_children'] = (isset($children_elements[$element->ID]))? 1:0;         parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);       }       [...]     }      The code will insert `parent` class to all menu items that have sub-menus and this can be then used in CSS like:               .parent:after { content: ">"; }      I'm wondering though, if there is a way to do that without custom menu walker? Just with filters? The reason I'm asking this is because some plugins like WPML ignore custom menu walkers for menu items and their "language switcher" in the menu doesn't get `parent` class even if has sub-items. Instead of waiting for WPML to fix that I would prefer to just update the menu in a theme to do it in a simpler way.


Wordpress plugin for nicer looking slugs? Have multiple pages named the same but they get different slugs

This wordpress site I'm touching up has a page hierarchy which is responsible for the urls. Basically the urls look like page1/subpage/subsubpage etc. The problem is, this site is for a recurring competition and therefore the urls are like 2011/results 2012/results 2013/results Which wordpress in turn makes 2011/results 2012/results-1 2013/results-2 Which doesn't look that great.. Is it possible to mod_rewrite or something to work around this? I understand the need in Wordpress for unique slugs but I really can't see why they enforce it even when it's impossible to get duplicate urls for different pages...


Comment `Reply` link doesn't work if comments are loaded from ajax

I am writing a plugin that displays custom home page that is in fact **only one post with comments**. The first time home page is displayed by the initial call by php. Then user can click a menu button to get another post. This is handled by ajax. So the whole page does not reload. Getting and displaying other posts via ajax works fine till I 'refresh' the page via ajax. Then the comment `reply` link doesn't work any more. I implemented [AJAXified commenting system][1] but I guess it has nothing to do with reply link. Reply link before ajax is used looks like               Reply      When the same post is loaded via ajax the reply button looks like               Reply      The difference is in the `href` attribute. The second (ajax) one got `wp- admin/admin-ajax.php` part that does not supposed to be there. I use one php function to generate html for both the fist time post is being displayed and for ajax call too. Part of the function looks like                  function my_get_comments($post_id, $number_of_comments){         //Gather comments for a specific post          $comments =     get_comments(array(             'number' => $number_of_comments,             'post_id' => $post_id,             'status' => 'approve' //Change this to the type of comments to be displayed         ));              ob_start(); //workaround how to capture the output from comments_number() function             comments_number( 'no comments', 'one comment', '% comments' );         $capture_comments_number = ob_get_clean();              $return_string ='
'                         . ''                         . '
'                             . $capture_comments_number                             . ' Show / Hide Comments'                         . '
'                         . '
'                         . '
';                   //Display / format the list of comments              ob_start(); //workaround how to capture the output from wp_list_comments() function             wp_list_comments(array(                 'reverse_top_level' => false //Show the latest comments at the top of the list             ), $comments);         $capture_wp_list_comments = ob_get_clean();         return $return_string;     }              ob_start(); //workaround how to capture the output from comment_form() function             comment_form("", $post_id);         $capture_comment_form = ob_get_clean();                   $return_string = $return_string                      . $capture_comment_form                     . '
'                     . '
';      I need to fix the `href` part of the reply link?


1 wordpress site on 2 VPS how update sync

I have WordPress site on 2 VPS using A record both VPS have same copies of file one VPS get fails mean one get active but problem is I have to update post on both VPS. Is there any solution that of post once both VPS get that same contain?


How to get a value from wp_dropdown_user?

In the admin dashboard, I want to show a list of all users (done so far by wp_dropdown_users) and then take the selected userID and use it as a parameter in another function. :) Sounds easy eh. I've got the dropdown happening, i've got the code to display other info for a selected ID(currently has $output in it..but this could be any userid), just need to know how to attach the two...like how to call the selected user's id and use it. Current code:               function wps_userlist_dw() {          $output = wp_dropdown_users(array(              'exclude'                 => '1',              'name'                    => 'author',              'show'                    => 'ID',              'echo'                     => true         ));               $user_info = get_userdata($output);           echo 'Username: ' . $user_info->user_login . "\n";           echo 'User level: ' . $user_info->user_level . "\n";           echo 'User ID: ' . $user_info->ID . "\n";     }      Any thoughts would be great!


Insert image or ad script after 3 posts using the loop

There are many scripts/hacks out there to insert ads into the middle of the post (after 'x' number of paragraphs), however I haven't found a good enough script that can do the above. This is the script that comes close,               <?php $post_counter=0; ?>     <?php if (have_posts()) : ?>     <?php while (have_posts()) : the_post(); ?>     <?php require('post.php'); ?>     <?php     $post_counter++;     if ($post_counter == 2 || $post_counter == 3) { ?>     INSERT ADSENSE CODE HERE     <?php } ?>     <?php endwhile; ?>      Taken from here. But my index.php uses this instead:               <?php     $page_num = $paged;     if ($pagenum='') $pagenum =1;     query_posts('cat=-3&showposts=6&paged='.$page_num); ?>                 <?php if (have_posts()) : ?>             <?php while (have_posts()) : the_post(); ?>                 <?php get_template_part('includes/index-loop'); ?>                 <?php endwhile; wp_reset_postdata(); wp_reset_query(); ?>

                  <?php else : ?>             <?php endif; ?>      I tried putting in the               <?php     $post_counter++;     if ($post_counter == 2 || $post_counter == 3) { ?>     INSERT ADSENSE CODE HERE     <?php } ?>      before endwhile, but I see a repetition of 'INSERT ADSENSE CODE HERE' twice. Any suggestions?


How to use array in function to get only value I want

I am trying to work this function in wordpress theme the way where I can get value only what I want and not all to gather. I am not much familiar with using array in function so I need you expert help to make it works and I would really appreciate that. Here is my code               function gallery_artist($arg=null, $arg2=null, $arg3=null){              global $png_gallery_meta;         $png_gallery_meta->the_meta();              $gallery = get_post_meta(get_the_ID(), $png_gallery_meta->get_the_id(), TRUE);              $gallery_value = $gallery['image_artist'];         $artist_info = $gallery_value;              $string = $artist_info;         $artist = substr($string, 0, stripos($string, "/") );              // getting first name and last name from user id         $author_first_name = get_userdata(basename($string))->first_name;              $author_last_name = get_userdata(basename($string))->last_name;              $author_full_name = $author_first_name . ' ' . $author_last_name;              $user_id = '' . $artist . '';                   $arg = $author_first_name;               echo $arg;              $arg2 = $author_last_name;               echo $arg2;              $arg3 = $user_id;         echo $arg3;               }      After than I want to use this function to get any value I want and not unnecessary to render all three to gather. Means if I want only first name than I pass value only for that and it will render only first name so on.. Here how I want to use something. but you can suggest any code and type of function I have no issue.               <?php call_user_func_array('gallery_artist', array('first_name','last_name','artist_id') ) ?>      Big Big thanks to you all..


Category nicename inside loop in wordpress

How can I echo the current post's category nicename inside main loop.               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>           echo
            <?php endwhile; else : ?>
<?php _e( 'Sorry, no posts matched your criteria.' ); ?>
     <?php endif; ?>      I want to echo the category nicename inside div tag as a class and then want to target the css Any suggestions?


Which hook should be used to validate custom form fields on the login form?

I've added a custom input field with `login_form` hook. So, I need to process the post data to validate. I've used the `lostpassword_post` for `lostpassword_form` and works great, but I cant find a hook to validate my data at login form. Any Ideas?


Retrieving multiple values to the Post Meta (using an array)

I'm having a problem retrieving post_meta values that I have stored in an array. I use this for storing the array:               add_action( 'comment_post', 'add_food', 1 );     function add_food(){         global $post;         $testvalues = array('bread', 'cake');         update_post_meta($post->ID, 'food', $testvalues);     }      and this for retrieving it:               add_filter('the_content', 'print_food');     function print_food($content){         global $post;         $custom_fields = get_post_custom($post->ID);         $food_field = $custom_fields['food'];         $content .= $food_field[0];         return $content;     }      however, this is added to the content of my page: a:2:{i:0;s:5:"bread";i:1;s:4:"cake";} The technique works fine for the comment_meta. What am I doing wrong here?


adding pages to the menus in wordpress admin side

Hi i'm new to wordpress and just started to study it. i already got a css and index.php files for studying with practicals. i integrate it to my local wordpress and created files header.php,footer.php,index.php,style.css,functions.php. my pblm is when i add new pages to the menu it is not added to my menus. instead the page link appears separately above the header template.


How Wordpress remembers which active editing modes are used?

I noticed that when I save page in Visual editor. Wordpress remembers it the next time I edit the page even if I clear all my browser cookies and cache. In what section of the WordPress database does this setting is saved? I searched for it and couldn't found it.


get_the_excerpt on mobile still displays continue reading

I'm writing a plugin where I'm using the excerpt field as just another field. In order to get rid of the 'Continue Reading' Link, I'm removing all possible theme filters:               add_action( 'after_setup_theme', array( $this, 'run_plugin_setup' ) );          public function run_plugin_setup() {         if ( get_post_type() !== $this->get_post_type() ) {             remove_all_filters( 'get_the_excerpt' );             remove_all_filters( 'excerpt_more' );         }     }      This works perfectly on desktop and iPad versions, however on a mobile phone, the dreaded 'Continue Reading -->' is still there and I cannot get rid of it...


What's $GLOBALS['wp_settings']['media']['embeds']?

In `wp-admin/options-media.php`, there are a few lines that go:               <?php if ( isset( $GLOBALS['wp_settings']['media']['embeds'] ) ) : ?>
<?php _e('Embeds') ?>

     <?php do_settings_fields( 'media', 'embeds' ); ?>
     <?php endif; ?>      'embeds' and "embeds" are nowhere else to be found in the WP code base. Might anyone know what it's for?


bloginfo no show the right path

I use bloginfo( 'stylesheet_directory' ) for show the link to css styles , in localhost in my computer i can see the url right as `http://127.0.0.1 , etc` The problem it´s inside of domain , i see the DOM and see that no show http:// only show domain.com and by this no let me the css load , if i add http:// until of this function works all and if no , no works Why in localhost show http and inside domain this function give the url without http ? In my options all it´s ok with http i don´t know what happend really , thank´s , Regards !!! I use these 2 functions :               bloginfo( 'stylesheet_directory' );      get_stylesheet_directory_uri() ;


How to hide post meta

I have disqus installed in my website. It adds `dsq_thread_id` meta. And while showing the post meta in post with tag;               <?php the_meta(); ?>      I want to hide `dsq_thread_id` in all posts. How can I do this?


URL of blog when using index.php as blog and front-page.php as homepage

I am building a theme and I am using front-page.php for an individuall homepage and index.php (or home.php) for the blog. What is the URL of the blog / how its possible to define the URL of the blog?


Display a post count from a custom metabox selection

**I was wondering if this is possible.** I have a custom post type call projects that displays a metabox with drop down menu. In that drop down menu I have a few choices listed, draft, open, pending, and completed. Once you select which field you would like, I would like the ability to display a post count of that choice on the front end from the selected author only when they are login. Example would be author A selects complete 4 times on 4 different posts. So when author A logs onto the site he will see on the front end a number 4 with the word completed. This is what I am using to display the drop down menu                array(                 'name'    => __( 'Project Status', 'projects' ),                 'desc'    => __( '', 'projects' ),                 'id'      => $prefix . 'project_select',                 'type'    => 'select',                 'options' => array(                     'Select a Status' => __( 'Select a Status', 'projects' ),                     'Draft' => __( 'Draft', 'projects' ),                     'Open'   => __( 'Open', 'projects' ),                     'Pending'     => __( 'Pending', 'projects' ),                     'Closed'     => __( 'Closed', 'projects' ),                     'Completed'     => __( 'Completed', 'projects' ),                 ),


Media upload finished hook

I'm developing a plugin which uses wordpress's thickbox media library to handle media upload and selection. All is well but for the fact that I would like to automatically 'redirect' to the 'media library'-tab after I uploaded/ wordpress finished crunching the file. So basically i'm looking for a hook that's fired after the crunching of an uploaded file is finished. I can't imagine this would be such an extreme thing but I can't seem to find the right hook for this.


If on Category Page add "active" class?

I am trying to register an "active" class on my `li` if the category matches the page. If you click the `horror` category it will show you a loop with all the videos in that category. But the button for `horror` does not show an active class. I know I need an `if else` statement but the things I have tried simply do not work and break the site. Im not good enough with PHP or Wordpress to really figure this out. Site here **CATEGORY.PHP**               $args = array(             'orderby' => 'name',             'parent' => 0             );           $categories = get_categories( $args );           foreach ( $categories as $category ) {             echo '
 term_id ) . '">' . $category->name . '
';     }         **Can something like this do the trick?**               if ( $category->slug == $category->term_id )


Custom Widget Area outside theme's border

I'm having an issue i would like your help with. I am a beginner with wordpress and wordpress themes so your patience would be appreciated! I am running a website www.besmart.com.cy and i have used a wordpress theme builder to build my theme from scratch. This is what i am trying to accomplish:screenshot. Through the theme builder i did not manage to do that. The way i am trying to accomplish this is by creating new custom widget areas on the left and right of my website so i can place plugins that will display photos (ads). I have registered my new custom widget areas in the functions.php and i can see them normally in my Widgets area from the WordPress admin panel. I have also adjusted their size and position through style.css. My questions are:   * Where should i place the new sidebars to get displayed where i want them? I have tried placing them in my header.php and although i can see them where i'm supposed to, my whole site gets dragged down (screenshot)   * Am i doing this the wrong way? Is there an easier way to do it - a plugin perhaps? Thanks in advance, Charis


Display single most recent post in category on every page of category archive

I am trying to display a single "featured post" in the archive.php template using a custom query. This featured post should be the **most recent post** in that category or tag. I'm using pagination for the rest of the archive page (also a custom query so that pagination is retained), and this **same post** should appear at the top of **all the subsequent pages** (i.e. /page/2/, /page/3/, etc.) I've got this working on home.php, but archive.php is showing the most recent post from _each page_ , not overall. This is what I'm using in archive.php.               global $query_string;     $query_args = explode("&", $query_string);          $args = array(         'posts_per_page' => 1,         'post_not_in' => get_option( 'sticky_posts' )     );          $query1 = new WP_Query($args);          if ( $query1->have_posts() ) {           while( $query1->have_posts() ) {               $query1->the_post();                   get_template_part( 'content', 'latest' );         }     }           wp_reset_postdata();       And here's the working code from home.php:                   $args = array(             'posts_per_page' => 1,             'post_not_in' => get_option( 'sticky_posts' )         );              $query1 = new WP_Query($args);              if ( $query1->have_posts() ) {               while( $query1->have_posts() ) {                   $query1->the_post();                       get_template_part( 'content', 'latest' );             }         }               wp_reset_postdata();      Hope I've expressed myself clearly. Any help would be greatly appreciated :)


display only the title of the post into a certain category

My site works with phrases and texts In one category, the users send statements and debate about it. In another category, are sent statements and debate about them. I would like to show only the title of the post into a certain category, since they are not phrases and content needs, just the title. in another category, the pots are usually shown, with title and content. as might be the code in single.php if you are in category X displays content and title Y if the category content is not displayed, only the title


Best way to get user id for get_users function?

I'm trying to make a table of users by role type. What is the best-practices method of getting the user id? My goal is to print each users first & last names, username and email. What I have now:               $get_admins = array(         'blog_id' => $GLOBALS['blog_id'],         'role' => 'administrator',     );          $blogusers = get_users($get_admins);     foreach ($blogusers as $user) {      $userid = get_userdata($bloguser->user_id);     $user_info = get_userdata($userid);              echo '
';             echo ''. $user_info->user_firstname .'	';             echo ''. $user_info->last_name .'	';             echo ''. $user->user_login .'	';             echo ''. $user->user_email .'	';         echo '
';     }      note: In my example above getting the user id does not work. Codex reference: get_users()


Hosting plugin Google Code with auto update?

I've been developing a WordPress plugin for a friend who needs something completely out-of-the-box, at least what WordPress is cornerned. Now, I could use the WordPress plugin repository to host this, but I've already hosted this project on Google Code and was wondering if there was any fancy code which would make WordPress check for updates from that repository. I feel this plugin isn't really for the general WordPress crowd and don't want to clutter the directory. So I was wondering if this was possible. Thanks! Davey


Voting System, database connections?

Basically I'm trying to make it so that all pending posts can be voted on if the user is logged in. once it gets to 10+ votes it will become published. OK so no longer using database connections and now using Meta Keys, therefore the code has been changed to show what I now have               <?php      //if the post is pending show     if(get_post_status() == 'pending') {          //added a post_vote to the wp_posts database for use later          //if the user is logged in show     if ( is_user_logged_in() ) {              add_post_meta( get_the_ID(), 'post_vote', '0', true );         $post_vote = get_post_meta( get_the_ID(), 'post_vote' );         echo 'Votes: ' .  print_r( $post_vote);         //form for submit button         echo "<form method=\"POST\" action=\"";         echo '';  //code in here for adding 1 to meta         echo "\">";         echo '<input type="button" name="submit" value="+">';         echo '</form>';          } else {         echo'Please Sign in to Vote';     }          } else {     // do nothing     }      ?>      The following                   add_post_meta( get_the_ID(), 'post_vote', '0', true );         $post_vote = get_post_meta( get_the_ID(), 'post_vote' );         echo 'Votes: ' .  print_r( $post_vote);      Returns this "Array ( [0] => 0 ) Votes: 1" It should only say "Votes: 0"


Separate table or usermeta

We are creating custom fields for users like annual income, gender, city, country, etc. There are about 10 odd new fields. We will be importing approx. 30,000 records for each user in a month through a CSV import function. There will be new as well as update to old records. The process will continue for a year. In this scenario, please suggest which option to choose from Scenario 1: Create a new WordPress table with these new fields Scenario 2: Use wp_usermeta to add custom fields Apart from CSV import, we will be regularly extracting reports of users. This will keep the wp_usermeta table busy. Please suggest which scenario we should go far and why? My recommendation is to go for Scenario 1 as here we can use WordPress functions quite efficiently though the database load will be high.


Pre Get Posts fails with more than 1 Post Type

**Inside Functions.php**               function custom_filings_archive( $query )      {         if(is_post_type_archive( 'filings' ))         $query->set('post_type',array('the-reports','press-release'));         return $query;     }     add_action( 'pre_get_posts', 'custom_filings_archive' );      **Inside archive-filings.php**               while(have_posts()):the_post();     the_title();?>

     <?php     endwhile;      **Result: Reverts to index.php and does not work..... However... if I set the pre-get posts to just 1 custom post type then it works just fine.... I want to have more than one post type though.**


Get Link to Feed On Term or Taxonomy

Instead of building the link myself, I was wondering if wordpress has a function which generates a link to a given feed, be it a taxonomy, term, or post type. Perhaps it might even generate the little feed icon. Before building it myself, it occurred to me they probably have a function. But my research turns up nothing.


How to use/enable Pagination?

I'm creating a shortcode to display the list of users with a particular profile in WordPress. But I can not enable or display the pagination. I have 25 users on my site and would like to display 5 profile users per page and include the pagination. I added a new Role student, and multiple custom fields using Advanced Custom Fields for the student profile. So I need to display a list of students as the appropriate fields. So far so good, the problem is with paging that I could not enable. Here a example of my code:               add_shortcode('list-users', 'list_users');          function list_users($atts){          global $wpdb;          $args = array(         'blog_id'      => '',         'role'         => 'student',         'meta_key'     => 'pw_user_status', //I'm using the New User Approve Plugin         'meta_value'   => 'approved',//If user is denied, he is not appears in the list         'meta_compare' => '',         'meta_query'   => array(),         'include'      => array(),         'exclude'      => array(),         'orderby'      => 'display_name',         'order'        => 'ASC',         'offset'       => '',         'search'       => '',         'number'       => '2',         'count_total'  => true,         'fields'       => 'all',         'who'          => ''     );          $students = get_users($args);          if(is_user_logged_in()){          $content = "
";             foreach($students as $student){              $content .= "
";         $content .= "
";         if(current_user_can('administrator')){            $link_of_profile_of_user = get_edit_user_link($aluno->ID);            $content .= ""."Edit this profile"."";          }         $content .= "
";         $content .= get_avatar($student->ID);         $content .= "Name: " . get_the_author_meta('display_name', $student->ID) . "
";         $content .= "Date of Birth: " . get_the_author_meta('date_of_birth_acf_student', $student->ID) . "
";         $content .= "Course: " . get_the_author_meta('course_acf_student', $aluno->ID) . "
"         $content .= "Email: " . get_the_author_meta('user_email', $student->ID) . "
";         $content .= "Phone: " . get_the_author_meta('phone_acf_student', $student->ID) . "
";         $content .= "City: " . get_the_author_meta('city_acf_student', $student->ID) . "
";         $content .= "
";             }//close foreach          $content .= "
";              return $content;          }//close the conditional for user logged          }//close function


WP Supersized & Easy Fancybox Conflict

I am using WP Supersized and Easy Fancybox Wordpress plugins. Everything is works fine till the point I am not clicking the link to open a fancybox. Image is opening perfectly just having some issues with the position. Its shifting towards the left on opening up. Here is the link to my demo page where I am using fancybox : http://martinushoeve.dig-id.be/?page_id=5 Regards.


Redirect user after login/registration globally

How it possible to redirect all users, even administrators after login to specific page? And also redirect users after successful registration? Any simplest way? For example I want to redirect users after login, to the "Updates" page of my website. And after registration, to the "Home" page of website.


How can I get all author written content?

I have a site that needs two different tabs: 1. all author written content (Posts, comments, CTP) 2. all author _followed_ content (categories, taxonomies, other users content) For the first all I could come up with was using unoion on wp_comments and wp_posts filtered by author sorted by date Have no idea how to do the 2nd one... Would love some advice


Retrieving a list of menu items in an array

I am currently am working on a custom theme. In this theme, I have a menu that I registered using `register-nav-menu`, and then I am displaying the menu to my web page using the `wp_nav_menu` function. However, I like to retrieve the list of menu items only (the actual menu item names only that were used in wp-admin area to create the menu, and without any html), and I would like save that list of items to an array (i.e, mot display it). So, a psuedo code would look like this               $menu_items = get_list_of_items($name_of_menu); // $name_of_menu is the result of register-nav-menu, and get_list_of_items is the psuedo function     foreach ($menu_items as $item) {         // do something with the item     }      Is there a way of doing so? Thanks.


same comment list for two posts

I've an unique problem, I'm using WPML to translate my website. WPML takes post and duplicates it, so that translation becomes another post. Thus keeping Gallery/Comments/Ratings separate. I'm on the quest to unite Gallery/Comments/Ratings for all languages. Problem is with comments, because wp-list-comments function doesn't accept post ID as an argument. What are my options? how do I unite comments of two posts? given that I know ID of parent and ID of translation? I think this is an interesting question :) ty!


How to merge two or more WordPress posts?

I need to be able to merge two or more posts. What is the exact query (or queries) to make this happen? The scenario is multiple recommendations that need to be merged into one. I have already sorted out comments merging and meta merging. Let's say a user recommends **Bill Gates** , another one **Gates Bill** and another one makes a typo and adds **Bil Gates**. I need to merge these three posts and choose the destination one. **UPDATE:** What I need is a complete SQL query for deleting a post and all references to that post. Something like this pseudo-code:               DELETE FROM wp_posts WHERE id = X;     DELETE FROM wp_posts_meta WHERE id = X;     DELETE FROM wp_another_table WHERE id = X;     DELETE FROM wp_yet_another_table WHERE id = X;      where X is the ID of my post. The code (or plugin) shouldn't auto-detect duplicates. I will present the user a dropdown with a list of posts and the "Delete" option. Before deleting, I will copy the post content from one post to the other using an SQL UPDATE query. **UPDATE 2:** I think I found something, I'll have to check though:                   $custom_field_keys = get_post_custom_keys($postid);         foreach($custom_field_keys as  $key => $value) {             $valuet = trim($value);             if('_' != $valuet{0} ){                    delete_post_meta($postid, $key, '');             }        }        $result = wp_delete_post($postid);


wordpress database restore - broken link

I've tried to play with db backup and restore but I am dealing with difficulties. This what I've done: I backed up database using cPanel option and got 8MB large SQL file. Afterwards I installed new Wordpress in it's own new home. I accessed database associated with new installation of Wordpress through phpMyAdmin and dropped all the tables. Then I clicked on Import and choose to upload file from my Computer. After some time process reported it's success with over 200 queries executed. I checked the database and tables were really there with content as well. Now when I tried to start my new WP instance with hope to get it populated with DB data I get a broken link error, like URL that I've entered doesn't even exist. I tried to keep it simple so I changed new WP `wp-config.php` to direct to an actual database(not backup) but then I get the old site run with page not found error. Let me point that I installed new WP instance in existing WP installation folder. I placed it in a new folder of course called `development`. That makes it: example.com (being my live version) example.com/development (testing version) So testing version works fine with default install but once I change it's config file to overwritten database it gets broken, or when I change it to use main database(example.com) I get Page not found error generated by Wordpress. Hope all this makes sense. Any help appreciated.


enqueue_scripts() in child theme doesn't work

I'm trying to enqueue my "scripts.js" located at the root folder of my child theme. I don't understand why the following code (located in "functions.php") doesn't work:               function enqueue_scripts() {     if ( ! is_admin() ) {         $scriptsrc = bloginfo('stylesheet_directory') . '/scripts.js';              wp_register_script( 'scripts', $scriptsrc );             wp_enqueue_script( 'scripts' );         }     }     add_action( 'wp_enqueue_scripts', 'enqueue_scripts' );


In Which Contexts are Plugins Responsible for Data Validation/Sanitization?

I want to make sure all of the data in my plugins/themes is handled securely before entering the database and before being output to the browser. My problem is that there are situations where the API handles the sanitization for you -- like when saving post meta fields -- and others where the plugin/theme author is wholly responsible for doing it -- like when saving custom settings. For the scope of this question, I'm not concerned about validating data at the domain level -- e.g., checking that an Age field on a form is between 0 and 120, or that an e-mail address is valid. I'm only concerned about security -- e.g., escaping SQL queries to avoid SQL injection when saving to the database, or sanitizing data that's output to HTML templates to avoid XSS. For output sanitization, I know that you always need to use functions like `esc_html()` and `esc_attr()` when echo'ing variables into HTML templates. But, what about when using template tags? Do they all sanitize the output already? If so, for which context (general HTML, tag attributes, etc)? Some functions have variants for different contexts (like `the_title_attribute()`, but most don't. For input sanitization, I know that I need to use `$wpdb->prepare()` when making manual queries, but what about when using the Settings API to create a plugin settings page, or saving post meta fields for a custom post type? Right now I've just been digging through Core and reading tutorials every time I use a function to find out if it sanitizes or not, but that's error-prone and time consuming. I'm hoping to find some kind of comprehensive list of all the possible situations and whether or not the API handles it. e.g., # API validates/sanitizes   * Saving post meta with `update_postmeta()`   * Saving user meta with `update_user_meta()`   * Outputting a post title - use the contextually appropriate variant of `the_title()`   * etc # You have to manually validate/sanitize   * Saving plugin options with the Settings API. Pass a callback as the 3rd parameter of `register_setting()`.   * Direct database queries: Wrap the query in `$wpdb->prepare()`.   * Outputting variables in HTML. Use `esc_attr()`, `esc_html()`, etc   * etc I'd also be interested to understand why the API provides it in certain situations, but not others. I'm assuming it has something to do with the unknown nature of the data, but would love to hear a thorough explanation.


Adding SSL verification seal javascript from Thawte breaks website

We are trying to add Thawte SSL seal javascript to our website, but it keeps everything else from loading if added to a normal text widget. For example, if we add it to where the Thawte SSL image link it is right now on the sidebar of the site - then it does not load the footer or anything on the sidebar below it. The javascript from Thawte is:               <script type="text/javascript" src="https://seal.thawte.com/getthawteseal?host_name=www.billioncreation.com&size=S&lang=en"></script>       Any suggestions?


after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()

after wordpress update to 3.5+ i get many errors in this plugin. i found that the reason is: http://make.wordpress.org/core/2012/12/12/php-warning-missing- argument-2-for-wpdb-prepare/ I do not understand how to fix it. If anyone can help me with these problems or give me an example of how to fix it. this is the plugin core file http://pastebin.com/Tk5Gf1HR               WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘wp_jsrm_menus’ at line 1 for query SHOW TABLES LIKE wp_jsrm_menus made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate     WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘wp_jsrm_items’ at line 1 for query SHOW TABLES LIKE wp_jsrm_items made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 169 and defined in /wp-includes/wp-db.php on line 992     PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, integer given in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 170     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 173 and defined in /wp-includes/wp-db.php on line 992     WordPress database error Duplicate column name ‘menuorder’ for query ALTER TABLE wp_jsrm_menus ADD menuorder mediumint(9) NOT NULL made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate, jsrm_update_db_tables     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 176 and defined in /wp-includes/wp-db.php on line 992     WordPress database error Duplicate column name ‘label’ for query ALTER TABLE wp_jsrm_menus ADD label tinytext NOT NULL made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate, jsrm_update_db_tables     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 179 and defined in /wp-includes/wp-db.php on line 992     WordPress database error Duplicate column name ‘itemheader’ for query ALTER TABLE wp_jsrm_menus ADD itemheader tinytext NOT NULL made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate, jsrm_update_db_tables     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 182 and defined in /wp-includes/wp-db.php on line 992     WordPress database error Duplicate column name ‘valueheader’ for query ALTER TABLE wp_jsrm_menus ADD valueheader tinytext NOT NULL made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate, jsrm_update_db_tables     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 189 and defined in /wp-includes/wp-db.php on line 992     WordPress database error Duplicate column name ‘valueheader2′ for query ALTER TABLE wp_jsrm_menus ADD valueheader2 tinytext NOT NULL made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate, jsrm_update_db_tables     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 193 and defined in /wp-includes/wp-db.php on line 992     HP Warning: mysql_fetch_array() expects parameter 1 to be resource, integer given in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 194     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 197 and defined in /wp-includes/wp-db.php on line 992     WordPress database error Duplicate column name ‘image’ for query ALTER TABLE wp_jsrm_items ADD image tinytext made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate, jsrm_update_db_tables     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 200 and defined in /wp-includes/wp-db.php on line 992     WordPress database error Duplicate column name ‘linked’ for query ALTER TABLE wp_jsrm_items ADD linked tinyint(1) NOT NULL made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate, jsrm_update_db_tables     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 203 and defined in /wp-includes/wp-db.php on line 992     WordPress database error Duplicate column name ‘linkurl’ for query ALTER TABLE wp_jsrm_items ADD linkurl tinytext made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate, jsrm_update_db_tables     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 206 and defined in /wp-includes/wp-db.php on line 992     WordPress database error Duplicate column name ‘itemhidden’ for query ALTER TABLE wp_jsrm_items ADD itemhidden tinyint(1) NOT NULL made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate, jsrm_update_db_tables     PHP Notice: Undefined variable: vh in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 212     PHP Warning: Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/simple-retail-menus/simple-retail-menus.php on line 213 and defined in /wp-includes/wp-db.php on line 992     WordPress database error Duplicate column name ‘value2′ for query ALTER TABLE wp_jsrm_items ADD value2 tinytext NOT NULL made by activate_plugin, do_action(‘activate_simple-retail-menus/simple-retail-menus.php’), call_user_func_array, jsrm_activate_loop, jsrm_activate, jsrm_update_db_tables      **the errors comes from this code: i tried to fix as Charles Clarkson suggested but seems not helping.**               [11-Oct-2013 05:27:09 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_menus' at line 1 for query SHOW TABLES LIKE wp_jsrm_menus made by activate_plugin, do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     [11-Oct-2013 05:27:09 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_items' at line 1 for query SHOW TABLES LIKE wp_jsrm_items made by activate_plugin, do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     [11-Oct-2013 05:27:11 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_menus' at line 1 for query SHOW TABLES LIKE wp_jsrm_menus made by do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     [11-Oct-2013 05:27:11 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_items' at line 1 for query SHOW TABLES LIKE wp_jsrm_items made by do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     [11-Oct-2013 05:27:11 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_menus' at line 1 for query SHOW TABLES LIKE wp_jsrm_menus made by do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     [11-Oct-2013 05:27:11 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_items' at line 1 for query SHOW TABLES LIKE wp_jsrm_items made by do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     [11-Oct-2013 05:30:45 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_menus' at line 1 for query SHOW TABLES LIKE wp_jsrm_menus made by activate_plugin, do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate     [11-Oct-2013 05:30:45 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_jsrm_items' at line 1 for query SHOW TABLES LIKE wp_jsrm_items made by activate_plugin, do_action('activate_simple-retail-menus/simple-retail-menus.php'), call_user_func_array, jsrm_activate_loop, jsrm_activate


How do I make the server response faster on search results

I have my own virtual server in the cloud, running nginx and APC. On this server I have one wordpress blog using the W3TC-plugin. I've enabled page cache and object cache using APC. When accessing front page, pages and posts the response from the server comes almost instantly. But when doing a search, the response takes 1 second. I'm wondering if it is possible to make the response faster. Using the Debug Queries WP-plugin I've profiled the search sql query and it only takes 0.002 to complete. And according to W3TC most objects are cached. In fact, the Debug Queries plugin give the following report on a search result:                   Total query time: 0,01482s for 120 queries.         Page generated in 0,00000s, 0,00% PHP, 0,00% MySQL      So it seems as if the page is generated very quick. But the response from the server still takes 1 second to complete. How can I find out what it is that makes the response is taking long, even though the page is generated quick? _Note: I'm only talking about the response time from the server, not the time that it takes to generate the page in the browser._ Here is a example search result from my site.


How to bring custom meta boxes to custom post types?

I had created a custom meta box with the help of this answer but this meta box only appear in Post edit screen. How I can make it visible on "Pages" as well as on custom post types which created by my current theme. **Update:** The code is from `function.php` which add Custom Meta Box:                   /* Define the custom box */     add_action( 'add_meta_boxes', 'wpse_61041_add_custom_box' );          /* Do something with the data entered */     add_action( 'save_post', 'wpse_61041_save_postdata' );          /* Adds a box to the main column on the Post and Page edit screens */     function wpse_61041_add_custom_box() {         add_meta_box(              'wpse_61041_sectionid',             'Does this page is in Englsih?',             'wpse_61041_inner_custom_box',             'post',             'side',             'high'         );     }      I do not understand how to add `page` & `custom-post-types` to make that `meta-box` visible there.


Custom Post Type or Custom Tables?

I am trying to build an application that takes 2 pieces of input from a user and saves it to the database. This is how users enter these two pieces of input; this form will be displayed using shortcode: ![this is how users enter these two pieces of input; this form will be displayed using shortcode.](http://i.stack.imgur.com/9FXHA.jpg) I have tried Custom Post Type, but its concept is foreign and confusing to me - I don't know if I should use pre-existing fields (Title, Content) or create the fields to store the input in the database, or create a separate table to store all of this information. Here is my code:               // Register Custom Post Type     function int_init() {              $labels = array(             'name'                => 'Stories',             'singular_name'       => 'Story',             'menu_name'           => 'Story',             'parent_item_colon'   => 'Parent Stories:',             'all_items'           => 'All Stories',             'view_item'           => 'View Story',             'add_new_item'        => 'Add new Story',             'add_new'             => 'New Story',             'edit_item'           => 'Edit Story',             'update_item'         => 'Update Story',             'search_items'        => 'Search Story',             'not_found'           => 'No story found',             'not_found_in_trash'  => 'No story found in Trash',         );         $args = array(             'label'               => 'int',             'description'         => 'INT information pages',             'labels'              => $labels,             'supports'            => array( 'title', 'editor', ),             'hierarchical'        => false,             'public'              => true,             'show_ui'             => true,             'show_in_menu'        => true,             'show_in_nav_menus'   => true,             'show_in_admin_bar'   => true,             'menu_position'       => 5,             'menu_icon'           => '',             'can_export'          => true,             'has_archive'         => true,             'exclude_from_search' => false,             'publicly_queryable'  => true,             'capability_type'     => 'post',         );         register_post_type( 'int', $args );          }          // Hook into the 'init' action     add_action( 'init', 'int_init', 0 );      All this code does is show the Title and Content fields in the backend. Should I just use the Title and Content fields to store the input, or should I create new fields, or create a custom table to store this data? How do I add new fields to use in a project such as this? How would you approach this problem? **EDIT:** The content is unique per user inasmuch _every_ user will be asked to enter two pieces of alpha numeric data per submission using a form created using shortcode. I know how to do this already. The pair of data items entered will be saved to the database, and will need to be retrieved and posted on the public side of the site. The pair of data items will be retrieved and displayed on one page for each data pair as such: _I want to_ **eat a peanut butter sandwich** _then_ **drink a glass of milk**. The submitted data is shown as bold. This retrieval and formatting of the data will be done using shortcode. I do not know how to create custom fields to make this work. The data is submitted on the public side of the site by users who are not logged into the site. To recap my problem, I don't know how to store the pair of data. Do I use pre- existing Title and Content fields or do I create something different?


Why should I put if(have_posts()), is while(have_posts()) not enough?

I have a question about "the loop".               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>     <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
     <?php endif; ?>      Code taken from The Loop WordPress Codex page. Why should I put `if` part? It seems like if there is `while` loop, works fine. In what case problem occurs if there is no `if` statement? ## Edit I accepted @Chip's answer. but honestly saying I need only last part. I know now what I wanted to know from my question. > `if` statement is only when necessary, if you want to put a header or footer > that should be write only once. if you don't use the "wrapper", then `if` > statement is not necessary.


menu dissaperead after upgrade

I have just upgraded to WP 4.0 and item Menu has disappeared from administration. I can not understand this. It never happened before. I call the menu by this function:               add_theme_support( 'menus' );     if ( function_exists( 'register_nav_menus' ) ) {         register_nav_menus(             array(               'main-menu' => 'Hlavní menu',             )         );     }      Does anybody have this problem too?


Woocommerce - Making product pages child of shop

I'm new to WordPress and trying out woocommerce, but I've ran into a small problem. Here is my site. The products pages are no childs of the _Shop_ page, so whenever I click on a product, the active underline under _Shop_ disappears. Does anyone know how to change this? Im using the Mystile theme.


Uploaded files have permission 000

two days ago i updated wp to the newest version and this problem occurs since then. when i upload files to the media library, their file permissions are set to 000. means no rights. the files are copied to the server, but since nobody has any right to read / write / execute i can't do anything with it (the files are defenetly on the server, but wp can not create the thumbnails etc. and i can't view the files with my ftp client, but when i download them, they are just fine). the uploads folder and all containing folders have 777 and i cant find any solution to this. is it some hosting problem, that just popped up?? thanks for the help


How to populate a Wordpress install with a lot of categories, quickly?

I'm looking at starting a new project, but I've not done anything like this before. I'm hoping someone with more experience will be able to offer me advice on this one. The site revolves around geographical structure. It's the UK, cut into 50 parts. Each part has many towns, and within each town, many services. Each of the 50 sites will be a different URL, all running on a multisite. It's going to take quite a while to set up the first area, and all the towns. All towns and services will be categories in the admin panel. Once this is done, I need a fast way of populating the other 29 installs! I'll be seeking a way to effectively "find and replace" town names, so that page titles, meta and categories can be re-used over and over. Is this possible? How would you tackle this? At the moment, I've no real ideas, apart from sitting here with PHP and seeing if I can pass a huge array of towns through a function which adds categories for each town and inserts them into the database... I know this isn't a question, like "how do I fix this code" but I don't know how to plan for this, and with no plan I think I'm stuffed :)


Is there a WordPress theme for twittstrap?

I would like to know if there is a WordPress theme that uses twittstrap (a derivative from Twitter Bootstrap)?


Display message depending on capability outside loop

I want to display a unique message on the post (single.php) page **outside the loop** on author box. I want the message to be different depending on the author's capabilities. So for instance, if the author can `manage_options` then echo `this is admin`, else if the author can `edit_others_posts` then echo `this is editor` and finally else `this is contributor`.


has_excerpt yields true but no post_excerpt when retrieved

echo has_excerpt($att); //Results in True     echo $att->post_excerpt; // results in empty.     echo $att; // results "782" which is the ID of the attached image.      If I use `get_post_meta( $att , '_wp_attachment_image_alt', true)` I get the alternate text but I can't seem to retrieve the caption via `$att->post_excerpt;`.


How to make an interface similar to multi-site for switching between multiple (single) sites for administrators?

I have a few WordPress sites and I want to make it easier to manage. I was thinking of being able to switch sites in the dashboard like WordPress multi- site, but when I was looking into it I see that's only for blogs inside blogs (if that makes sense). Is there anyway to link to different blogs together (I have around 5 blogs all with content on them so I don't want to make them in to 1 site with mapped domains). So to sum up, I want to make it really easy/fast to switch between sites for the admins. I like how WordPress multi-site does it, but I don't want to move all the blogs in to one and map the domains, the domains are all on 1 server. Is this at all possable and if so how? Are there any plugins? EDIT: If there is no way, how would I make 6 single WordPress sites into a WordPress multi-site?


Displaying Posts Related to Other Posts by a Taxonomy Term?

I have a custom post type for musician's profiles, and a taxonomy for their location (categorised hierachically into Countries and then Cities). On the musician's individual profile pages I need to display a list of musicians in the same city (i.e. the child taxonomy). It'd also be good to display posts in the same country seperately (the parent taxonomy). The problem seems to be retrieving the taxonomy dynamically, seperating the parent and child taxonomies and using these in a new loop. I can display a list of the taxonomies, and strip out the links...               $terms = get_the_term_list( $post->ID, 'locations', '', ', ', '' ) ;     echo strip_tags($terms);      ... which returns a result like this: New York, USA And I can easily loop through posts by a fixed taxonomy value...               <?php $my_query = new WP_Query( array( 'locations' => 'new-york', 'showposts' => 10 ) ); ?>     <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
     <?php endwhile; ?>      But I am having problems combining the two: as far as I can tell 'get_the_term_list' doesn't have the ability to return only one taxonomy, and there doesn't seem to be a taxonomy equivalent of 'get_the_category'. Any help much appreciated!!!


List category posts - thumbnail_size problem

I'm using the list category posts plugin, and can't get the thumbnail_size parameter to work with a given pixel size. The parameter can be a word, but also a size in X- and Y-dimension, as I understand it. Can someone give me an example of how to write this? Thanks.


404 Error on Custom Post Type even after permalink flush

This is what my code looks like:               add_action( 'init', 'create_my_post_types' );          function create_my_post_types() {         register_post_type( 'competitor_claims',                            array(                                  'labels' => array(                                                   'name' => __( 'Competitor Claims' ),                                                   'singular_name'  => __( 'Competitor Claim' )                                                   ),                                  'public' => true,                                  'show_ui' => true, // UI in admin panel                                  '_builtin' => false, // It's a custom post type, not built in!                                  '_edit_link' => 'post.php?post=%d',                                  'capability_type' => 'post',                                  'menu_position' => 20,                                  'hierarchical' => true,                                  'query_var' => true,                                  'supports' => array(                                                      'title',                                                      'editor',                                                      'excerpt',                                                      'custom-fields',                                                      'thumbnail',                                                      'page-attributes'                                                      ),                                  'rewrite' => array(                                                     'slug' => 'claims',                                                     'with_front' => false                                                     ),                                  // Add taxonomies...                                  'permalink_epmask' => EP_PERMALINK                                       )                            );     }


Moved to a new server, backup was a day old and missing 3 posts, anyway to recover them from old host?

I made a backup for my clients site the other night, apparently after I made the backup they made a few posts. I then moved the site to another host and resetup wordpress and imported the database and backup files. Now my question is, I still have access to the old host, I can login via FTP or cPanel, is there anyway I can grab the posts from the database possibly? In phpMyAdmin? Thing is I cant just login since the nameservers are changed. Thanks, Matt


If Meta Checkbox is checked, do something?

I created a custom checkbox that when I check, I wish it to display slightly different content (specially special css styling). For some reason it is not functioning properly. In my functions:               add_action( 'add_meta_boxes', 'add_special_checkbox' );     function add_special_checkbox()     {         add_meta_box( 'special-checkbox', 'Special Box', 'special_checkbox_func', 'post', 'side', 'high' );     }          function special_checkbox_func( $post )     {         $values = get_post_custom( $post->ID );         $check = isset( $values['special_box_check'] ) ? esc_attr( $values['special_box_check'][0] ) : '';         wp_nonce_field( 'my_special_box_nonce', 'special_box_nonce' );         ?>         <p>             <input type="checkbox" name="special_box_check" id="special_box_check" <?php checked( $check, 'on' ); ?> />             <label for="special_box_check">Is this post 'special?'</label>         </p>         <?php        }               add_action( 'save_post', 'special_checkbox_save' );     function special_checkbox_save( $post_id )     {         // Bail if we're doing an auto save         if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;              // if our nonce isn't there, or we can't verify it, bail         if( !isset( $_POST['special_box_nonce'] ) || !wp_verify_nonce( $_POST['special_box_nonce'], 'my_special_box_nonce' ) ) return;              // if our current user can't edit this post, bail         if( !current_user_can( 'edit_post' ) ) return;              // now we can actually save the data         $allowed = array(              'a' => array( // on allow a tags                 'href' => array() // and those anchords can only have href attribute             )         );              // This is purely my personal preference for saving checkboxes         $chk = ( isset( $_POST['special_box_check'] ) && $_POST['special_box_check'] ) ? 'on' : 'off';         update_post_meta( $post_id, 'special_box_check', $chk );     }     ?>      In my loop:               <?php if (get_post_meta($post->ID, 'special_box_check', true)) { ?>     //add special styling     <? } else { ?>     //dont add special styling     <?php } ?>      When I save some posts, they have the special styling even though I did not check the box for them. And when I uncheck a box, I'd like the special styling to go away, but it is not when the box is unchecked. I am sure I am doing something wrong here. Thanks in advance.


User Training Materials

Does anybody know of any good publicly-available Wordpress training materials (videos, manuals, etc.) that could be used to give content editors a basic overview of Wordpress. We have a a handful of blogs on a Wordpress server and I'd really like to be able to automate training some more.


How can i call an article from each category and still paginate properly?

I want to have my front page, with three columns, each assigned to a different category. Ideally I would like to query to fetch one post, per column, per page where possible, leaving the column empty if not. My current loop simply gets 3 posts at a time. It is reasonable to assume that the 3 will not be one of each category. Here is the loop:               <?php                      global $query_string;                 parse_str( $query_string, $my_query_array );                 $paged = ( isset( $my_query_array['paged'] ) && !empty( $my_query_array['paged'] ) ) ? $my_query_array['paged'] : 1;                 query_posts('post_type=post&posts_per_page=3&paged='.$paged);                           if ( have_posts() ) : while ( have_posts() ) : the_post();                      $category = choose_one_category(get_the_category());                      switch ($category){                     case "Festival News":                         $left[] = $post;                         break;                     case "Industry News":                         $centre[] = $post;                         break;                     case "Other":                         $right[] = $post;                         break;                 }                           endwhile;                  ?>

<?php previous_posts_link('« Previous') ?>

<?php next_posts_link('Next »') ?>

                 <?php endif;                                ?>


Reverting from a newer version of wordpress to an older version

For some reasons I need to degrade `wordpress` version of a site(I understand that it is **not** a **good practice** to do and I can fall into many troubles by doing so) but I still need to do it for some reasons. I want to degrade from `3.0` to `2.9`.I tried to upload the `wp-admin` folder of `wordpress 2.9` installation into my `wordpress 3.0` site but it was unable to load all the files. I can not delete the upgraded version as it contains images of posts. Is there any way to revert back to 2.9? Moreover, is there a plugin that can get this done? Thanks in advance.