Customize the Sorting Dropdown in WooCommerce

It would be great if there was a way to change the default sort by dropdown in WooCommerce on the shop page. Right now the sorting drop down looks like this: http://cld.wthms.co/OBgj And I would very much like to be able to remove a couple of options (`Sort by price: low to high` & `Sort by price: high to low`). The final result should look something like this: http://cld.wthms.co/NHVw


wp nav menu: show submenu below li item

I'm trying to figure out if it's possible to show the submenu's outside of the relevant `li` tag.   For example, this php:               wp_nav_menu(array(         'menu'  =>  'side',         'container' => false,         'menu_class'      => 'side-menu'     ));     ?>      will render the menu like so:

Menu 01

Menu 02

Sub 01

Sub 02

Sub 03

Menu 03

Menu 04

      ...when what I'd actually like to achieve is something like this:

Menu 01

Menu 02

Sub 01

Sub 02

Sub 03

Menu 03

Menu 04

      with the relevant submenu sitting below it's corresponding menu item, the reason being the submenus are initially hidden and slide down upon clicking the relevant menu item and each menu item is styled, thus wrapping a submenu inside it throws everything out. Is this at all possible?


Multisite Subdomain Redirect Mask

I've seen many questions and answers regarding this subject, yet I can't seem to get this to work. Here is my setup. I have my main domain: **www.example.com** On that domain, I've installed WP multisite as a subdomain. The root of the network sits at: **sites.example.com** I have multiple wordpress sites setup under that subdomain, all under the format of: **sites.example.com/Some-WP-Site/** Now, if I register some new domains for the purpose of pointing them to these individual wordpress sites, how would I edit my .htaccess files to achieve something like the following: User navigates to: **www.New-Domain.com** and gets redirected to: **sites.example.com/Some-WP-Site/** all while still seeing **www.New-Domain.com** in the address bar. I've managed to setup a mask where **www.New-Domain.com** is _always_ displayed in the address bar, but I would like to have the structure of the site follow the domain, as the user navigates through the site. For example, **sites.example.com/Some-WP-Site/wp-content/image.jpg** would become **www.New-Domain.com/wp-content/image.jpg** Is this at all possible?


How to display a single(current) post from a category

How do I get the code below to display just the current post that corresponds to the current URL and not all the post from the same category? Barakadam, It works but it brings all the posts in the category instead of the one that was clicked on.               <?php      $category = end(get_the_category());      $current_name = $category->cat_name;     ?>     <?php         // assign the variable as current category        $category_name = $current_name;            // concatenate the query       $args = 'category_name=' . $current_name;            // run the query       query_posts( $args );            if ( have_posts() ) : while ( have_posts() ) : the_post() ;            // do something here          the_title();     the_content( __('Read the rest of this page »', 'template'));          endwhile; endif;          wp_reset_postdata();          ?>


Error inserting row into table

I am trying to insert a row into a table. Given below are the various functions to create table. insert data into the table- but its not working. Also given below is the sample output showing all fields that are being attempted to be inserted.               /* Function: Insert Zillow property data into table     * Input: $zillowid String, $date DateTime     * Output: Boolean     */     function zillowInsertData($zillowid, $date_val, $postid, $url) {     global $wpdb;     $table_name = $wpdb->base_prefix."Zillow";     if(trim($date_val) == '')         $date_val= string2DateTime("0000-00-00");     $sql = "         INSERT INTO $table_name (ZillowID, PostID, PropertyURL, DateUpdated)         VALUES ($zillowid, $postid, $url,$date_val)";     return $wpdb->query($sql)===1;     }          echo " Values being inserted-          Zp id=" . $current_zpid . ",          postid=" . $post_id, "url=" . $propertyurl;     zillowInsertData($current_zpid, "", $post_id, $propertyurl );      Sample output showing values being inserted into the table-               About to insert row in Zillow table      Values being inserted-          Zp id=51605333,          postid=111         url=http://www.zillow.com/homedetails/1457-Golf-Course-Dr-Windsor-CA-95492/51605333_zpid/      Table creation code--               global $wpdb;         $table_name = $wpdb->base_prefix."Zillow";         $sql = "CREATE TABLE $table_name(             ZillowID text NOT NULL, PostID text NOT NULL,             PropertyURL text,              DateUpdated datetime DEFAULT '0000-00-00 00:00:00' NOT NULL         );";         $wpdb->query($sql);      What am I doing wrong here? Update-- The string2datetime function uses strtotime php function. Thanks, Arvind.


What could be causing my wp_query pagination to break?

I'm using categories and wp_query to create an "advanced search" feature on my website. It was working great until recently I noticed that the pagination was broken. The following 2 links should demonstrate the problem: On page 1 I get 185 results: > > http://www.barbadospropertylist.com/?cat%5Boffer%5D=24&cat%5Btype%5D=-1&cat%5Blocation%5D=-1&cat%5Bbedrooms%5D=-1&cat%5Bfurnishings%5D=-1&budget=1000000&cat%5Bparish%5D=-1&cat%5Bagent%5D=-1&cat%5Bbathrooms%5D=-1&submit=Advanced+Search But on subsequent pages the query string breaks: > > http://www.barbadospropertylist.com/page/2/?cat%5Boffer%5D=24&cat%5Btype%5D=-1&cat%5Blocation%5D=-1&cat%5Bbedrooms%5D=-1&cat%5Bfurnishings%5D=-1&cat%5Bparish%5D=-1&cat%5Bagent%5D=-1&cat%5Bbathrooms%5D=-1&budget=1000000&submit=Advanced+Search You should see the second link redirect to: > > http://www.barbadospropertylist.com/page/2/?budget=1000000&submit=Advanced%20Search What with recent upgrades to WordPress I have no idea what might be causing this. Any pointers would be very, very welcome! I've been trying to figure this one out all day. :) Here is my query code:                   query_posts(         array_merge(             wp_query->query,             array(                 'category__and' => $pladvsearchcatids,                 'meta_key' => 'price',                 'orderby' => 'meta_value_num',                 'meta_compare' => '<=',                 'meta_value' => $plbudget,                 'order' => 'DESC'             )         )     );      Just noticed something really strange. When I download my site and work locally the problem goes away. The query string is not redirected on page 2 and paging through the results works as expected.


wp_editor textarea value not updating

I am using the `*_add_form_fields` action to add fields to a custom taxonomy. One of those fields is a wp_editor(). The problem I am facing is that when I output the WordPress editor on the page like so:               wp_editor('test', 'mydescription', array('textarea_name' => 'my_description'));       and then if I click in the editor on the page and change the default value from `test` to `something else` the `$_POST['my_description']` variable is still set to `test` Should I be adding an additional setting to my editor? Is there a reason why I cannot change the value of the textarea? **EDIT** Below is a very simple test case that shows this happening. Place this in your functions.php file and then create a new **tag**. The posted value for 'my_description" will not change.               class Test{              function __construct() {                  add_action('add_tag_form_fields', array($this, 'add_tag_form_fields'));                  add_action('created_term', array($this, 'created_term'));         }              function add_tag_form_fields($tag){                  if ( current_user_can( 'publish_posts' ) ): ?>
                 <?php wp_editor('test', 'mydescription', array('textarea_name' => 'my_description')); ?>
                  <?php         }              function created_term($tag){             echo '
';             print_r($_POST);             echo '
';                 die();         }     }     new Test();      **EDIT** This ONLY happens when attaching to "created_term" action. If you attach to "edited_terms" it works as expected and I think this is a result of ajax being used on the create term page... I have updated the test code to show this.


Importing specified data/field

I'm creating a website for a publisher that contains +- 1.500 registered and these books have its prices rearranged time to time, obviously it would be a hard time to manually upload each one of them. For these books I must have some custom fields, like author, pages, format, cover(image), first chapter, authors page (internal page of the author), and some others that I can put some files for download. So since you guys know the main function of the site, I have some questions: Which are the the best way of creating these functions? (I've tried some e-commerce/store themes but the next question ruined it) I will have to upload the prices of the these books time to time, so there is a way of importing just the information that is contained in the field price all in once? I mean like importing a xml, a sql direct in the data base that will upload/overwrite only this field for all the books, since they have different prices? (I know I will have to specify the id or some other field of each one of the books for the data base understand which posts it must change) I know that is complicated (at least for me) but I've trying to figure out how I'm going to do all of these programming and yet I don't know. If anyone could help me, that would be amazing! Thanks!


Problem with custom user meta field

I've recently added a new field into the User Profile section of my blog So that I may define the gender of the user. On the author bio section I have this code:               $authorgender = strtolower(get_the_author_meta('gender'));          if ($authorgender = "male") {         $genderoutput = "his";     } else {         $genderoutput = "her";         };'      And the place i'm using it is:
<a href="<?php the_author_meta('url'); ?>" target="_blank" title="<?php the_author(); ?>'s website (new window)">Check out <?php echo $genderoutput; ?> website      I have two users, One myself which I changed the gender to 'Male' and one a random woman called sally-louise-fredericke-swann and her gender was set to 'Female'. However, the $genderoutput generates 'his' for both users. Not happy :/ Any Ideas?


"You do not have sufficient permissions to access this page" upon accessing my newly created plugin page

I am following "Write your own plugin tutorial" and I made it, activated it, added it to settings to have it's own plugin page but upon trying to access that plugin page I get above message saying that "I do not have sufficient permissions to access this page" even though I am logged in as admin and I did `chmod -R 777` to wordpress directory?? What else could it go wrong? _**Plugin code follows:_** `oscommerce_importer.php`               <?php           /*          Plugin Name: OSCommerce Product Display          Plugin URI: http://www.orangecreative.net          Description: Plugin for displaying products from an OSCommerce shopping cart database          Author: C. Lupu          Version: 1.0          Author URI: http://www.orangecreative.net          */                function oscimp_admin() {            include('oscommerce_import_admin.php');       }                function oscimp_admin_actions() {             add_options_page("OSCommerce Product Display", "OSCommerce Product Display", 1, "OSCommerce Product Display", "oscimp_admin");           }                add_action('admin_menu', 'oscimp_admin_actions');                 ?>      `oscommerce_import_admin.php`
         <?php    echo "
" . __( 'OSCommerce Product Display Options', 'oscimp_trdom' ) . "
"; ?>              <form name="oscimp_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">             <input type="hidden" name="oscimp_hidden" value="Y">             <?php    echo "
" . __( 'OSCommerce Database Settings', 'oscimp_trdom' ) . "
"; ?>
<?php _e("Database host: " ); ?><input type="text" name="oscimp_dbhost" value="<?php echo $dbhost; ?>" size="20"><?php _e(" ex: localhost" ); ?>

<?php _e("Database name: " ); ?><input type="text" name="oscimp_dbname" value="<?php echo $dbname; ?>" size="20"><?php _e(" ex: oscommerce_shop" ); ?>

<?php _e("Database user: " ); ?><input type="text" name="oscimp_dbuser" value="<?php echo $dbuser; ?>" size="20"><?php _e(" ex: root" ); ?>

<?php _e("Database password: " ); ?><input type="text" name="oscimp_dbpwd" value="<?php echo $dbpwd; ?>" size="20"><?php _e(" ex: secretpassword" ); ?>

             <?php    echo "
" . __( 'OSCommerce Store Settings', 'oscimp_trdom' ) . "
"; ?>
<?php _e("Store URL: " ); ?><input type="text" name="oscimp_store_url" value="<?php echo $store_url; ?>" size="20"><?php _e(" ex: http://www.yourstore.com/" ); ?>

<?php _e("Product image folder: " ); ?><input type="text" name="oscimp_prod_img_folder" value="<?php echo $prod_img_folder; ?>" size="20"><?php _e(" ex: http://www.yourstore.com/images/" ); ?>

             <input type="submit" name="Submit" value="<?php _e('Update Options', 'oscimp_trdom' ) ?>" />
         </form>
        Thanks


wp new post expert probleme?

i use rss post feed after feed no **post expert** or descripion just images and three point (...) ![image](http://i.stack.imgur.com/JM3LD.jpg) and after go to post edit page   `i don't edit anything` just change writing mode ! from html to visual and click update i see the description !! please help and thanks


PHP to Programatically delete a file

I am writing a plugin that allows the user to upload files to the upload directory of WordPress. I want them to be able to "uninstall" the files with the click of a button. When the user clicks the button, I want the files to be deleted. I have successful been able to set up uploading and placing the files in the correct directory, but when it comes to deleting the files it is not working. I am trying a very simple `unlink('file/path');` but it doesn't seem to be deleting my file.               <?php          $filename = 'direct/path/to/file/for/testing/purposes';     unlink($filename);          ?>      It seems like the function is running when I click the button, but the file is never deleted. The path is correct as I've double checked it a few times. Is there something I am doing wrong?


How to change the length of excerpt() method?

I am using the_excerpt() method to display some wordings from the blog posts. I have read the post from this link. http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length But my situation is different. I am displaying some wordings from the posts in two places. In the first place I want to display 20 words and in the 2nd place I want to display 50 words. So what will I do for this?


CSS Twentyeleven / Sidebar has to be changed IN the CSS Stylesheet. Sidebar on the left side

I have to change my wordpress look. The sidebar should be placed on the left side. I was already looking for solutions, but the piece of codes I found didn't fit into mine. I dont know where I have to change it. I know I can change it in the Options, but I need to change it IN the CSS Stylesheet. Thanks for your help ! Twenty Eleven/twentyeleven.44: Stylesheet (style.css)               body {         padding: 0 2em;     }     #page {         margin: 2em auto;         max-width: 1000px;     }     #branding hgroup {        margin: 0 7.6%;     }     #access div {         margin: 0 7.6%;     }     #primary {         float: left;         margin: 0 -26.4% 0 0;         width: 100%;     }     #content {         margin: 0 34% 0 7.6%;         width: 58.4%;     }     #secondary {         float: right;         margin-right: 7.6%;         width: 18.8%;     }               /* Singular */     .singular #primary {         margin: 0;     }     .singular #content,     .left-sidebar.singular #content {         margin: 0 7.6%;         position: relative;         width: auto;     }     .singular .entry-header,     .singular .entry-content,     .singular footer.entry-meta,     .singular #comments-title {         margin: 0 auto;         width: 68.9%;     }               /* Attachments */     .singular .image-attachment .entry-content {         margin: 0 auto;         width: auto;     }     .singular .image-attachment .entry-description {         margin: 0 auto;         width: 68.9%;     }               /* Showcase */     .page-template-showcase-php #primary,     .left-sidebar.page-template-showcase-php #primary {         margin: 0;     }     .page-template-showcase-php #content,     .left-sidebar.page-template-showcase-php #content {         margin: 0 7.6%;         width: auto;     }     .page-template-showcase-php section.recent-posts {         float: right;         margin: 0 0 0 31%;         width: 69%;     }     .page-template-showcase-php #main .widget-area {         float: left;         margin: 0 -22.15% 0 0;         width: 22.15%;     }               /* error404 */     .error404 #primary {         float: none;         margin: 0;     }     .error404 #primary #content {         margin: 0 7.6%;         width: auto;     }               /* Alignment */     .alignleft {         display: inline;         float: left;         margin-right: 1.625em;     }     .alignright {         display: inline;         float: right;         margin-left: 1.625em;     }     .aligncenter {         clear: both;         display: block;         margin-left: auto;         margin-right: auto;     }          /* Right Content */     .left-sidebar #primary {         float: left;         margin: 0 0 0 -26.4%;         width: 100%;     }     .left-sidebar #content {         margin: 0 7.6% 0 34%;         width: 58.4%;     }     .left-sidebar #secondary {         float: right;         margin-left: 7.6%;         margin-right: 0;         width: 18.8%;     }


Display all authors in a theme template

I was having an issue the other day and successfully got a very good answer which helped me alot achive what I wanted. this is the post which I created and have all the correspondence: wordpress.stackexchange.com/questions/63060/display-all-authors-and-their- only-one-latest-post The answer was kindly contributed courtesy of @Sagive SEO This script currently displays all authors in an order of most posts written. I would like to change it to simply display all authors randomly regardless of how many posts they wrote. Hope to get an answer, thanks a lot Gil


How to implement a Google map store locator

I have followed the following Google developer doc about creating a store locator usng PHP & MySql. https://developers.google.com/maps/articles/phpsqlsearch_v3 I have this working but now I would like to integrate this with an existing Wordpress installation. My problem with integrating this, is the way WP stores repeatable custom fields. I have a repeatable field to enter multiple markers per custom post type. WP stores this as serialised data within the DB. I cannot see a way of using the Haversine formula select statement mentioned in the doc to perform the radius search based on an entered postcode. I know there are various Google Map plugins out there, but I can't find any that will:   * Add multiple markers per custom post    * Provide a search to list markers within a radius of an entered postcode Has anyone got any suggestions how I can do this, or does these features exist? Thanks in advance for any help on this.


WooThemes Mini Features - modify query_posts to display only sticky_posts

/* Mini-Features */             ?>             <div id="sub-featured" class="<?php echo $main_css_class; ?> section">
<?php echo stripslashes( $featured_title ); ?>
                      <?php                      query_posts( 'suppress_filters=0&post_type=infobox&order=ASC&posts_per_page=' . $mini_features_number );                     if ( have_posts() ) { $count = 0; while ( have_posts() ) { the_post(); $count++;                          $excerpt = stripslashes( get_post_meta( $post->ID, 'mini_excerpt', true ) );                      $button = get_post_meta( $post->ID, 'mini_readmore', true );                     $post_class = 'post block';                          if ( $count % $mini_features_count == 0 ) { $post_class .= ' last'; }                 ?>                     <div <?php post_class( $post_class ); ?>>                                  <a href="<?php echo $button; ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php woo_image( 'key=mini-image&width=300&height=150&class=thumbnail aligncenter&link=img' ); ?>
<a href="<?php echo $button; ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>
                             <?php if ( $excerpt ) { ?>
                                 <?php echo $excerpt; ?>
                             <?php } ?>
                 <?php                     if ( $count % $mini_features_count == 0 ) { echo '

'; }                     } // End WHILE Loop                 } else {                 ?>

<?php _e( 'Sorry, no posts matched your criteria.', 'woothemes' ); ?>

                 <?php } // End IF Statement ?>
      That's the code, somewhere within that I need to specify that only sticky_posts are displayed - this is where I come unstuck. I've taken a look at the Codex for both query_posts & sticky_posts & I've got to be honest - I'm not sure where I'd start to modify the above... The first thing I did was add the ability (to those custom post types) to include a Sticky Post meta box (thanks to: Sticky Custom Post Types - this worked a treat). As part of the theme options I can specify how many posts I'd like to display (in my case 3x) but until I modify the above code to only display sticky_posts - I'll end up with 2x sticky_posts (& one other random one). I'm stuck, so any pointers would be greatly appreciated!


Filter meta request

i've got a multisite where i query _specific custom post types_ from _one specific blog_. It looks like this:               function unify_results_filter( $input ) {     global $wpdb;     $blog_id = get_current_blog_id();     $blog_source_id = '2';          $db_source_prefix = str_replace($blog_id, $blog_source_id, $wpdb->prefix);          // if blog is not 2 and post_type is results, query blog id 2     if ( strpos($input, "post_type = 'results'") !== false )         $input = str_replace( $wpdb->posts, $db_source_prefix . 'posts', $input );          return $input;     }     add_filter( 'posts_request', 'unify_results_filter' );      Now this works for the posts themselves. However, i'd like to the _same for their meta values_. Is there a similar filter for meta request?


Start with multi-site feature now or later?

I have a single installation of Wordpress in my web host and would like it to manage 2 domains or websites. One is for the domain and the other is for its subdomain/s. dummy example: www.swimming.com and videos.swimming.com In my limited knowledge, is this where you use the multi-site feature of WordPress? Another question, is it possible to add that feature later on? I mean, I would have to concentrate first on the main domain and when time comes, I'd focus on the subdomain. So I'm planning to use WordPress without multi-site first and when I'll add a subdomain, that's when I'll switch or add multi-site. Or do I have to start with multi-site now?


Sort query output on taxonomy term archive by post type using pre_get_posts

I'm using `pre_get_posts` to adjust the main query of the taxonomy term archive. What I would like to accomplish is that the output is listed by `post_type`. I have a total of 4 post types and I want to order them as profile, page, post, letter. I have tried already a few different `order_by` parameters, but no luck yet in getting it right. I already have come a bit further by adding a `posts_groupby` filter (and removing it again after the query) and although the output is now indeed per `post_type`, it still is not in the desired order. This is what I have come up with so far:               add_action('pre_get_posts', 'woo_taxonomy_posttype_filter' );     function so_groupby_cpt( $groupby ) {         if ( preg_match( "/(|[ ,.])id(|[ ,])/i", $groupby ) )             $groupby = 'post_type';         return $groupby;     }          function woo_taxonomy_posttype_filter( $query ) {          global $wp_query;          if ( $query->is_tax && ! is_admin() ) {          add_filter( 'posts_groupby', 'so_groupby_cpt' );          // ORDER BY TITLE     $query->set('orderby','menu_order title');     $query->set('order','ASC');     $query->set('posts_per_page','8');          $query->parse_query();          remove_filter( 'posts_groupby', 'so_groupby_cpt' );     }          return $query;          }      Is this at all possible or am I asking for the impossible? Thanks.


WordPress function breaks widget's markup?

Here's a standard function creating widget, it displays Widget's title and echoes "test" below it:                function widget( $args, $instance ) {             extract( $args );             $title = apply_filters('widget_title', $instance['title'] );                  echo $before_widget;                  if ( $title )                 echo $before_title . $title . $after_title;                       echo 'test';                  echo $after_widget;         }      It creates perfect output:

Title
        test
      But when I replace `echo 'test';` with `wp_list_pages();` things start to look nasty because widget's body is being displayed after the tag that closes the widget:

Title

          Paage title
        (...)      Any ideas how to fix it? I've been trying with multiple wp_list_pages() arguments, but nothing seems to help.


How to combine multiple CSS files and concatenate JavaScripts if WordPress recommends enqueuing them?

How would I go about combining multiple CSS files and concatenating my scripts if they're being enqueued as WordPress recommends? My site is pretty slow and would like to optimize for performance.


Browser title script ignoring is_page /else conditional

I've used this code to stipulate different separators for different pages in my clients site:               <title>     <?php if(is_page('Portfolio')){         wp_title( 'of', true, 'right' );         echo wp_specialchars( get_bloginfo('name'), 1 );     }else{         wp_title( 'by', true, 'right' );         echo wp_specialchars( get_bloginfo('name'), 1 );     }         ?>     </title>      What it's outputting regardless of where I am on the site is : > Page Name | Blog Name Which i find really odd, how is it going through the if statement and coming up with it's own answer?


Get current term's ID

Im using the following code to get an array of children taxonomies and write them out with links in an unordered list.                   <?php     $termID = 10;     $taxonomyName = "products";     $termchildren = get_term_children( $termID, $taxonomyName );          echo '
';     foreach ($termchildren as $child) {         $term = get_term_by( 'id', $child, $taxonomyName );         echo '
name, $taxonomyName ) . '">' . $term->name . '
';     }     echo '
';     ?>      What I'm trying to achieve is to get the actual term (category) id so I can replace it on $termID and don't have to hardcode the id of the term. Any help would be kindly appreciated! Thanks!


How to call in Custom Post-Type Categories?

I have our portfolio page here: http://www.slarc.com/portfolio-view/central- control-building-east-texas/ The orange links below the project title are manually inserted on the page content. Is there a way to call in a the post categories to make this automatic? The template I'm using doesn't have our portfolio posts under WP Posts. It's under a custom post-type titled "Portfolio". I have received this code below. But I don't know how to add it to my page. When I tried everything on the page below the PHP code disappeared.               <?php       $args = array(          'type'                     => 'post',          'child_of'                 => 0,          'parent'                   => '',          'orderby'                  => 'name',          'order'                    => 'ASC',          'hide_empty'               => 1,          'hierarchical'             => 1,          'exclude'                  => '',          'include'                  => '',          'number'                   => '',          'taxonomy'                 => 'your_custom_taxonomy',          'pad_counts'               => false );      $categories = get_categories($args);           echo '
';           foreach ($categories as $category) {          $url = get_term_link($category);?>
<a href="<?php echo $url;?>"><?php echo $category->name; ?>
      <?php      }           echo '
';      ?>      Thanks, Lorne


I am trying to create a simple frontend form for posting

i am trying to learn and create some deeper things with Wordpress. My goal is to create a code/script/plugin that will allow me to post from the frontend. I have seen many plugins, like templatic classifieds theme that submit, handle and edit posts from the frontend but are very complex with useless code for my purpose. I would like to have a clearer view on how to get the ID, how to set a title, content and custom fields of course. Once I go through this, I want to study it according to user_meta. Thank you for your examples, codes, ideas, links!


Pull Random Attachments With Pagination

I want to make a archive page that pulls in all uploaded images to the site. I am using the current script. Its paginating somewhat but not showing all the images. Showing around 90 out of 140.                    <?php query_posts(array('posts_per_page'=>'8','paged' => get_query_var('paged'))); ?>            <?php         if ( $images = get_posts(array(             'post_parent' => $post_id,             'post_type' => 'attachment',             'numberposts' => -1,             'orderby' => 'rand',             'posts_per_page'=>'8',             'paged' => $paged,             'post_mime_type' => 'image',)))         {             foreach( $images as $image ) {                 $attachmenturl=wp_get_attachment_url($image->ID);                 $attachmentimage=wp_get_attachment_image_src( $image->ID, postgallery );                 $imageDescription = apply_filters( 'the_description' , $image->post_content );                 $imageTitle = apply_filters( 'the_title' , $image->post_title );                      if (!empty($imageDescription)) {         echo '';     } else { echo '

                                         ID). '" class="view-back" style="display: none;">

     '; }    }         } else {             echo "No Image";         } ?>

               <?php echo paginate_links( $args ) ?>     <?php     global $wp_query;          $big = 999999999; // need an unlikely integer          echo paginate_links( array(         'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),         'format' => '?paged=%#%',         'current' => max( 1, get_query_var('paged') ),         'total' => $wp_query->max_num_pages     ) );     ?>


Can't get correct pagination links on blog single page

I am new to wordpress but I am going through something unusual here. The blog I am designing is something a little different. Let's say there is just a blog index and single posts. I have designed this two pages to act very similar. When you go to blog index there is the latest post on the main content and then there is sidebar which shows the list of posts with a pagination links. It uses ajax, so when you click on any item in the sidebar list the main content of the page is updated with the contents of the post you clicked on. Every thing works here. But when you directly navigate to a single post, there is much similar thing there except the content is filled with this single post, off course, and the sidebar is again showing a list of posts in the blog. The problem is I can't seem to be able to get the pagination work. Here is the code for `single.php` in my template               <?php get_header(); ?>
         <?php the_post(); ?>
<?php the_title(); ?>

<?php the_content(); ?>

<?php comments_template(); ?>

         <?php query_posts("posts_per_page=10"); ?>         <?php if ( $wp_query->max_num_pages > 1 ) : ?>
            <?php posts_nav_link(); ?>
         <?php endif; ?>
           <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_title(); ?>

         <?php the_excerpt(); ?>
           <?php endwhile; ?>           <?php else : ?>
<?php _e( 'No Posts' ); ?>
           <?php endif; ?>

     <?php get_footer(); ?>      Now, I have read the documentation for the posts_nav_link(); function and it says it is supposed to work at the archive pages like blog index , category etc and not on single.php page. And my problem is that I think it is actually working and showing the pagination next and previous links but with the **wrong urls**. Say we are at the page with the url of `http://site.com/single-new-post` then the Next Page anchor at the sidebar is linking to `http://site.com/single-new-post/page/2` instead of being `http://site.com/blog/page/2`. What can I do to get the correct links at this pagination problem?


Setting META tags such as description and title on programmatic post creation

i am new to WP plugins, and i have made one that auto creates posts and catagories. Anyhow, id like to know if i can set the meta values when creating the post such as:                       $my_post_data = array(                 'post_title' => $collection,                 'post_type' => 'post',                 'post_content' => '
' . $content . '
',                 'post_category' => array(                     $term->term_id                 ),                 'post_author' => 1,                 'post_status' => 'publish',                 'post_date' => date('Y-m-d H:i:s')             );      Is there any way i can set the title and description for this page?


Custom taxonomy displayed in search results

In my search results template within my WP site `search.php`, the function `et_divi_post_meta()` displays a posts meta data. What code would I use to display the the custom taxonomy that I created: `'State'` and `'Product-Type'`? So search results sould include that info and not just: the title, meta and the_content. Example: > **Special Price** > > Monday's Special Price on wall paper is... > > *-Illinois > > -Wall Paper*
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
         <?php              et_divi_post_meta();     if ( 'on' !== et_get_option( 'divi_blog_style', 'false' ) )         truncate_post( 270 );         else         the_content();         ?>     //      Here is the taxonomy Code               // Add custom taxonomies     add_action( 'init', 'specials_create_taxonomies', 0 );          function specials_create_taxonomies()      {         // Town         $town_labels = array(             'name' => _x( 'Town', 'taxonomy general name' ),             'singular_name' => _x( 'Town', 'taxonomy singular name' ),             'search_items' =>  __( 'Search in Town' ),             'all_items' => __( 'All Towns' ),             'most_used_items' => null,             'parent_item' => null,             'parent_item_colon' => null,             'edit_item' => __( 'Edit Town' ),              'update_item' => __( 'Update Town' ),             'add_new_item' => __( 'Add new Town' ),             'new_item_name' => __( 'New Town' ),             'menu_name' => __( 'Town' ),              );         register_taxonomy('town', 'specials', array(             'hierarchical' => true,             'labels' => $town_labels,             'show_ui' => true,             'query_var' => true,             'rewrite' => array('slug' => 'Town' )              ));


Setting the language of RSS feed

What is the simplest / easiest way to set up the language of the rss feed. Currently, that field in my feed xml is blank, it looks like this                <language></language>      and i would like it to look like               <language>en-US</language>      Any help on how to easily implement it?


Can't get jQuery to enqueue into post edit script

In the code below, unless I hardcode a reference to the jQuery library, my jQuery bits on the page do not work. What's wrong with the enqueue method I'm trying to use? In functions.php:               if(is_admin())     {          /* LOAD ADMIN SCRIPTS     **********************************/     require_once(TEMPLATEPATH . '/functions_private.php');          }      In functions_private.php:               if( 'post.php' == $pagenow )     {              add_action('admin_print_scripts', 'my_load_ui_script');              function my_load_ui_script()         {         wp_enqueue_script('jquery');         ?>             <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>-->             <script>             if(typeof jQuery!="undefined"){                 alert("You have jQuery loaded");//WILL NOT FIRE UNLESS I HARDCODE JQUERY INCLUDE             }                             jQuery(document).ready(function()             {             //jquery bits go here             }              }//END FUNCTION           }//END IF


How can I add a Categories page link to a menu?

Not a link to a specific category, but a link to a page that lists all categories of a custom post type (WooCommerce Products).


How can I edit post data before it is saved?

I have a plugin and I would like to be able to run the post content through some filters before it is saved to the database. From looking at the plugin api, I see that two hooks that look like they might be helpful:               save_post     wp_insert_post      The only problem is that it looks like `save_post` does not need return a variable, and so I don't know how to filter the content, and `wp_insert_post` looks documented. I'd like to do something like this:               add_action('whatever_hook_name','my_function');          function my_function($post_content){         return $post_content.' <br> This post was saved on '.time();     }      I am going to do something more useful than append a timestamp, namely running some regex filters, but this is the general type of filter / action I'm trying to add. **Update** Please note that I want to intercept the data on it's way to being saved in the database - not when it is being displayed in the post (eg: Not by adding a filter to `the_content`)


Remove Javascript generated by Comments

In a theme I am working on, the comments form (mostly sure they are both comments form) adds javascript to the header.               <script type='text/javascript' src='http://[URL]wp-includes/js/l10n.js?ver=20101110'></script>     <script type='text/javascript' src='http://[URL]/wp-includes/js/comment-reply.js?ver=20090102'></script>      When I disable javascript I can still add comments and the comment form still works. So I wish to remove these from my header. I cannot find any documentation on how to do so, so **How can I remove these?**


How to hook custom taxonomies to custom post types and make the permalinks work?

So, I have my custom post type with the slug **/news**. And I want my category view to be **/news/category/CATEGORYID**. For that I create my custom taxonomy:               add_action('init', 'create_allfilmnews_categories', 0);     function create_allfilmnews_categories() {         $labels = array(             'name' => _x( 'Categories', 'taxonomy general name' ),             'singular_name' => _x( 'Category', 'taxonomy singular name' ),             'search_items' =>  __( 'Search categories' ),             'all_items' => __( 'All category' ),             'parent_item' => __( 'Parent category' ),             'parent_item_colon' => __( 'Parent category:' ),             'edit_item' => __( 'Edit category' ),             'update_item' => __( 'Update category' ),             'add_new_item' => __( 'Add new category' ),             'new_item_name' => __( 'New category name' ),             'menu_name' => __( 'News categories' ),         );                register_taxonomy('news_category', 'news', array(             'hierarchical' => true,             'labels' => $labels,             'show_ui' => true,             'query_var' => true,             'rewrite' => array( 'slug' => 'category' ),         ));     }      I was hoping, that since it is hooked to **news** custom post-type.. and its slug is "category", so I was hoping that naturally it would work out like I wanted (/news/category/CATEGORYID). And use my custom category-template just by creating a file to the template directory: **category-news_category.php**. However, of course it is not working. Is it even possible to have a custom taxonomy aka. categories inside custom post-type, that work perfectly with permalinks?


How to include the admin bar?

I'm working on a plugin which needs a custom Preview page. In this page i call the neccessary wp functions(wp-load.php & wp-admin/includes/admin.php). The problem is, that the admin bar is not visible. So my question is, how to display the admin bar on this page? Here is the preview.php file:               <?php          //Include wordpress core files     for ($i = 0; $i < $depth = 10; $i++) {         $wp_root_path = str_repeat( '../', $i );         if ( file_exists("{$wp_root_path}wp-load.php" ) ) {             require_once("{$wp_root_path}wp-load.php");             require_once("{$wp_root_path}wp-admin/includes/admin.php");             break;         }     }          //Redirect if user is not logged in     auth_redirect();          //Die if user can't edit posts     if(!current_user_can('edit_posts') ) die(__("You don't have the neccessary permission to preview forms.", "nemus_slider"));          //And the actual preview code     ?>     <!DOCTYPE html>     <html lang="en">     <head>         <meta charset="utf-8" />         <title>Preview</title>         <?php wp_head(); ?>     </head>     <body>         Some preview stuff...         <?php wp_footer(); ?>     </body>     </html>


Customize category URL

I've searched around and have not found the answers im looking for. By default I have:   * example.com/blog (blog archive)   * example.com/blog/entry (single entry)   * example.com/blog/category/announcements (single taxonomy view) Now I've created a custom post type & taxonomy (categories) to go along with it, but I'm having trouble mirroring the blog's URL structure. For example my goal is:   * example.com/talks (talks archive)   * example.com/talks/entry (single talk entry)   * example.com/talks/category/support (single taxonomy view) Here is what I have so far:               function uc_add_talks_post_type() {       $talks_labels = array(         'name'                => 'Talks',         'singular_name'       => 'Talk',         'all_items'           => 'All Talks',          …       );            $talks_args = array(         'labels'             => $talks_labels,         'public'             => true,         'publicly_queryable' => true,         'show_ui'            => true,         'menu_position'      => 5,         'rewrite'            => array( 'slug' => 'talks', 'with_front' => false ),         'has_archive'        => 'talks',       );            $talks_cat_args = array(         'hierarchical' => true,         'labels' => array(           'name' => 'Talk categories',           'singular_name' => 'Talk category',           …         ),         'show_admin_column' => true,         'show_ui' => true,         'query_var' => true,         'rewrite' => array(           'slug' => 'talks',           'with_front' => false         ),       );            register_post_type( 'uc_talks', $talks_args );       register_taxonomy( 'uc_talks_cat', array('uc_talks'), $talks_cat_args );     }          add_action( 'init', 'uc_add_talks_post_type');


Storing Form data in a different database

I have two wordpress websites and I want to store the data submitted by the forms in a centralized database in order to better manage the information. Is there a way I can store form data in a different database?


Loop that displays all posts by logged in user, with Post Edit link

I need a loop that pulls in all posts that were authored by the logged-in user. I have to then create a link to the post with this in the querystring: ?_ninja_forms_action=edit.


Need help rebuilding lost htaccess file

I originally posted this on **Stack Overflow** (7 months ago). I didn't receive any answers and was not in a position to pursue it further. As of now I am working on resolving this, and would greatly appreciate assistance from someone familiar with WP and htaccess. Some time ago I installed Magento in the sub directory of a site with many apps on it, and the Magento downloader/installer replaced the .htaccess file in my root. The automated backups which run via a wordpress installation happened to NOT be capturing the few files in the root folder. I have no back-up. This wouldn't be so bad if I actually knew and understand all that was in that .htaccess file. it has been slowly created over a period of years! What I am looking for is some assistance with rebuilding it. Already I am coming across issues. For instance, when I try to access a fold other than my wordpress folder, I am rerouted to the 404 of wordpress. For instance, I have a proxy app in the subfolder /proxy, but if I go to mysite.com/proxy I see in the address bar: mysite.com/proxy , and the wordpress 404. I've greatly enjoyed learning increasing amounts of regex in past months, and getting my head around .htaccess redirects, rules, etc. So I'd like to more than solve these issues, and actually understand how they are solved. Here is my root .htaccess as it stands (pulled together from a few miscellaneous notes I had on record:               <Files .htaccess>     order allow,deny     deny from all     </Files>          # Redirect     #<IfModule mod_rewrite.c>     #RewriteEngine on     #RewriteCond %{REQUEST_URI} !^/site/     #RewriteCond %{HTTP_HOST} ^www\.     #RewriteRule (.*) http://mydomaint.com/site/$1 [R=301,L]     #</IfModule>          # BEGIN WordPress     <IfModule mod_rewrite.c>     #RewriteEngine on     #RewriteBase /site     #RewriteRule ^index\.php$ - [L]     #RewriteCond %{REQUEST_FILENAME} !-f     #RewriteCond %{REQUEST_FILENAME} !-d     #RewriteCond %{REQUEST_URI} !^/site/     #RewriteRule . /site/index.php [L]          RewriteEngine on     RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$     RewriteCond %{REQUEST_URI} !^/site/     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule ^(.*)$ /site/$1     RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$     RewriteRule ^(/)?$ site/index.php [L]          </IfModule>      I get the impression there is repetition and redundancy in that code. And that it is missing lines to pick up on subfolders that are NOT the wordpress one (which is in /site by the way). I have included showing you what was commented out, as it may help with seeing where I went wrong, or identifying how it should be set up. What I need is that all requests for:   * mydomain.com/site   * www.mydomain.com/site   * mydomain.com (no subfolder) Are directed to `mydomain.com/site` Requests for any other subfolder (assuming it exists) should go through to to the folder requested (e.g. `mydomain.com/proxy` or `mydomain.com/shop` are passed through to their respective folders `/proxy` and `/shop`). Requests for subfolders which do not exist, should be routed through to `mydomain.com/site` I am not sure just yet if anything else has been broken, but I can bring that to the table if and when I discover it. I should add that I have also tried this: order allow,deny deny from all               # Redirect     <IfModule mod_rewrite.c>     RewriteEngine on     RewriteCond %{REQUEST_URI} !^/site/     RewriteCond %{HTTP_HOST} ^www\.     RewriteRule (.*) http://jonathanevatt.com/site/$1 [R=301,L]     </IfModule>      But something odd occurs with this. If I browse to `www.mydomain.com` (or `mydomain.com`) I end up with with that in the address bar, and this appearing on a blank page (as a line of text at the top left of the page:               /home/jonathan/public_html/app/Mage.php was not found      This is exactly what was happening after the installer whipped out my .htaccess file. I have not idea where or how that is being called up, as I see nothing in the .htaccess leading to this address being called. It is very perplexing. ALSO I did manage to find a back-up of some rules I had in my htaccess file, which were there to redirect requests for various types of content from my old Joomla site. These rules are:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /site/     RewriteRule ^en/Page-[0-9]+\.html /site/blog/ [R=301,L]     RewriteRule article&id=([0-9]+) /?p=$1 [R=301,L]    #CATCH ?option=com_content&view=article&id=307&catid=89&Itemid=55     RewriteRule ^articles-other-writing/(Page-[0-9]|index)\.html /site/blog/ [R=301,L]     RewriteRule ^articles-other-writing/[a-zA-Z\-]+/(Page-[0-9]|index)\.html /site/blog/ [R=301,L]     RewriteRule ^what-is-love/([a-zA-Z0-9\-\/\.\_\=\?\&]+) /site/blog/ [R=301,L]     RewriteRule ^media/audio/([0-9a-zA-Z_]+\.mp3)$ /wp-content/uploads/audio/$1 [L,R=301]     RewriteRule ^[A-Za-z\-]+/[a-z\-]+/[a-z\-]+/([0-9]+)\-.+ /?page_id=$1 [R=301,L]     RewriteRule ^/swine-flu\.html$ /site/tags/swine-flu/ [R=301,L]     RewriteRule ^events/event-descriptions/([A-Za-z\-]+)\.html$ /site/events/$1/ [R=301,L]     RewriteRule ^[0-9]{8}([0-9]*)\/(articles|great-products|others-videos|jonathan-s-blog)[a-zA-Z0-9\-\/\.]+ /?p=$1 [R=301,L]   # CATCH POSTS 1     RewriteRule ^[0-9]{8}([0-9]*)\/services[a-zA-Z0-9\-\/\.]+ /?page_id=$1 [R=301,L]                # CATCH PAGES 1     RewriteRule ^myblog[a-zA-Z0-9\-\/\.] /site/blog/ [R=301,L]    #CATCH MYBLOG     RewriteRule ^view-by-tag/([a-zA-Z\-]+)/([a-zA-Z0-9\-\/\.\_\=\?\&]+) /site/tags/$1/ [R=301,L]      I should probably integrate them into the new htaccess file just in case there are still links out there pointing to important content on the old Joomla system.


wp_redirect on multisite

I have a multisite setup with subfolders (rather than subdomains). There are 3 sites installed which will use the same theme but in English, French and Dutch. I want to use wp_redirect in the header of the theme so that the user is redirected to one of the sites based on a cookie that is set when they click on a language option in a popup. The redirect works fine on the english site which has the path '/' but not on any of the other sites which have paths - '/fr/' and /'nl/' I've also tried redirecting using ` header("Location: http://example.com/"); ` and that doesn't work either. It literally does nothing! Is it because the sites are subfolders rather than sub directories? I've removed all the code that detects the cookie and conditional statementents for now and have tried it in the header.php file of 2013 default theme and it still doesn't work. So the top of the header.php file looks like - ` <head> <?php wp_redirect( 'http://www.example.com', 301 ); exit; ?> .... ` And to confirm, this DOES work with the site http://www.example.com but not with the site http://www.example.com/fr I'm stumped. Thanks for help. I hope that all makes sense. Luke


Adding Child Terms Programatically - No Warning but No dice either

Here's essentially what I'm doing :               create_taxonomy_record(array(                 'Label',                 'tax_parent_slug',                 'Label Related',                 'this_tax_term_slug'));     /* ---> Create a child */                 create_taxonomy_record(array(                 'Label 2',                 'this_tax_term_slug',                 'Label Related',                 'this_tax_term_slug_a_child'));      and here's that function named `create_taxonomy_record` (its very vanilla - echos are for debug purposes)               create_taxonomy_record($args)             {                      $term = term_exists($args[0], $args[1]);                 if ($term == 0 || $term == null) {                          wp_insert_term(                         $args[0], // the term                         $args[1], // the taxonomy                         array(                             'description'=> $args[2],                             'slug' => $args[3],                             'parent'=> $args[1]                             )                     );                 }                 else { echo "<h1>" . $args[0] . " exists in parent " . $args[1] ."</h1>";}             }      So this isn't working but its also not hard failing. I have warnings / errors on and this code provides neither. **What's Working:**   * All 1st tier terms in the taxonomy are registering fine(1->n, i've run tests against 10k calls to this function and all perform nominally) **What's Not Working:**   * when I try to assign a child term to a parent term. I do not get a warning, failure or false match of existence, i just don't get anything. **Now I did find this :** Inserting terms in an Hierarchical Taxonomy However this did not seem to fix the issue. Or rather perhaps I am going about the cache clear incorrectly. What I tried for the cache clear looked something like this:               create_taxonomy_record(array(                     'Label',                     'tax_parent_slug',                     'Label Related',                     'this_tax_term_slug'));         /* ---> Create a child */          /* Tried it here */     delete_option("this_tax_term_slug_children");                     create_taxonomy_record(array(                     'Label 2',                     'this_tax_term_slug',                     'Label Related',                     'this_tax_term_slug_a_child'));          /* and here - all permutations/ combinations should be considered attempted */     delete_option("this_tax_term_slug_children");      No dice.


image uploaded cant be shown

im using wordpress 3.2.1 i kinda forgot how this things happen..but i remember updating some plugins/wp and its happen. i can upload an image, but once its finished it show broken link. something like this http://imageshack.us/photo/my- images/688/screenshot20110721at639.png/ anyone can help? already try deactivate all plugins but nothing happen. already empty the "Store uploads in this folder" but nothing happen too anyone can help? thanks


What's the difference with trash_comment and wp_trash_comment?

I don't understand when I'm suppose to use trash_comment over wp_trash_comment. What's the difference?


How to add featured image to a post?

I have a registration form where the user can upload an image. Upon registration I create a post and I would like the uploaded image to featured image. I have tried that but it is no working :               function createNewPost( $response ){     global $userMeta;          $userID = $response->ID;     $user = new WP_User( $userID );     $role = $userMeta->getUserRole();     $categorie = get_user_meta($userID, 'categorie_artiste',true);     $filename = get_user_meta($userID, 'image_profil',true);          if( $role = 'artiste' ){               $newPost = array(           'post_title'    => $user->nickname,            'post_content'  => $user->description,           'post_status'   => 'pending',           'post_author'   => $userID,           'post_type'     => 'cpt_artists',         );              $post_id = wp_insert_post( $newPost );              $wp_filetype = wp_check_filetype(basename($filename), null );         $wp_upload_dir = wp_upload_dir();         $attachment = array(            'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ),             'post_mime_type' => $wp_filetype['type'],            'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename )        ),            'post_content' => '',            'post_status' => 'inherit'         );         $attach_id = wp_insert_attachment( $attachment, $filename );         set_post_thumbnail( $post_id, $attach_id );         }     }


edit_comment capability for subscriber

I have given my site's subscriber role the following permissions (unserialized DB-query):               [subscriber] => Array         (             [name] => Reader             [capabilities] => Array                 (                     [delete_comment] => 1                     [edit_comment] => 1                     [level_0] => 1                     [quick_edit_comment] => 1                     [read] => 1                     [reply_comment] => 1                     [unfiltered_html] => 1                 )              )      I want to make the subscriber be able to edit their comments, but I always get an error "Your are not allowed to edit this comment." I tried the following in debugging (in my comments.php template file):               $link = get_edit_comment_link($GLOBALS['comment']->comment_ID);     $perm1 = current_user_can('edit_comment', $GLOBALS['comment']->comment_ID);     $perm2 = current_user_can('edit_comment');     var_dump($link);     var_dump($perm1);     var_dump($perm2);     global $current_user;     var_dump($current_user->allcaps);      giving the following output (explanation added beside):               (get_edit_comment_link): NULL     (cur_user w/ post-id): bool(false)     (cur_user w/o post-id): bool(false)          (allcaps):      array(9) { ["delete_comment"]=> bool(true) ["edit_comment"]=> bool(true)      ["edit_posts"]=> bool(true) ["level_0"]=> bool(true) ["quick_edit_comment"]=> bool(true)      ["read"]=> bool(true) ["reply_comment"]=> bool(true) ["unfiltered_html"]=> bool(true)      ["subscriber"]=> bool(true) }       As you can see, the allcaps shows that the user is allowed to edit_comments. But get_edit_comment_link stays empty, although the role has the capability AND the current_user is the author of the comment.


Add Custom Fields After Page Title

I want to add my custom fields after the page title when you view it on the site. How do I do this? PAGE TITLE [CUSTOM FIELDS HERE] PAGE CONTENT


How to Detect That WP is Using Mod Rewrite or $_GET variables?

I am trying to get WP is using Mod_Write or $_GET for URLs,   Because by it, I can generate my own links like:               mysite.com/val1/val2      or in a conventional way;               mysite.com/?var1=val1&var2=val2      $_GET or rewrite, how to detect that which way WP is currently using?


Can plugin variables cause conflict?

I write a wordpress plugin. My plugin code in inside a class.               if (!class_exists("Pluginname")) {       class Pluginname {         ...       }     }          if (class_exists("Pluginname")) {       $obj = new Pluginname;     }      Question: What if `$obj` is already used in Wordpress code or in another plugin? Can this be a potential source of conflict? If so, what to do?


PHP random number in email

I have a Wordpress website where i am making a form so that when a user fills out that form he gets a confirmation email and receives a random order number. I have this PHP function which creates that number any suggestions is it possible to embed it to an email with a shortcode. Maybe could someone can put me on the right track?               function genTicketString() {         $length = 8;         $characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";         for ($p = 0; $p < $length; $p++) {             $string .= $characters[mt_rand(0, strlen($characters)-1)];         }         return $string;     }     add_shortcode('quoteticket', 'genTicketString');     ?>


Change background color of subpages

I have several pages, which are ordered like this:               Home     Projects     - Project 1     -- Project 1 Subpage 1     -- Project 1 Subpage 2     - Project 2     -- ...      And I want to change the background color (in this case of `.site-main {}` or any other css classes) depending on the page the user is right now.   1. Currently on Home page (this is the default layout) -> Standard background color light blue   2. I am on Page Project 1 -> background should be green.   3. I am on Project 1 Subpage 1 -> background should be green.   4. I am on Project 2 -> background red or something else This is the standard layout right now (the lightest part should be changed): ![enter image description here](http://i.stack.imgur.com/v1QhV.jpg) What would be the best/easiest way to achieve this? **Edit:** What I did know is this: In my page.php I added this               <div id="main-content" class="main-content <?php echo "roadkill-main-content"; ?>">      This is working fine (I'm getting another color now). What's missing is how to detect if the current page is child or grandchild or whatever of a page with the slug "project1" or others. What is the correct way to do this?


Display one category in one page

I have different categories called as reviews, ideas etc. I have a page called as review, I want to display review category to the review page (only review category). Is this possible? Which file I have to change? I have the code below, but it is displaying only the texts not any links to the posts, 7 is my category id.               if( is_page( 'reviews' )){                   query_posts("cat=7" );                }


Pagination issue with Single.php

I am having issues understanding the worlds most simplest concept when it comes to building a single.php file and using pagination. The code bellow shows a wordpress loop, its contents and then finally the pagination. How ever, the pagination does not show up for me and looking at twenty 10 theme shows this is how you are suppose to do it....So what's going on? This isn't a custom loop.
     <?php      global $post;     $thumb_nail_args = array(         'align' => 'centered',          'class' => 'thumbnail marginBottom20 marginTop20'     );          if(have_posts()){         while(have_posts()): the_post();         ?>
<?php the_title() ?>

             Written by:                  <a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>">                     <?php the_author_meta('display_name'); ?>

<?php          the_post_thumbnail('full', $thumb_nail_args);         the_content();          ?>
         <?php          endwhile;              ?>

             <?php next_posts_link(); ?>

             <?php previous_posts_link(); ?>

<?php      }          if('open' == $post->comment_status){         comments_template();     }          ?>


When to use is_home() vs is_front_page()?

I've found that `is_front_page` appears to return true when I'm viewing the home page and have a single sticky post assigned there. It also returns true when I've assigned a page as the static front page via _Settings > Reading_. Why would I ever want to use `is_home()`?


WordPress filter to hook into menu <li> items and add a custom attribute

I have a WordPress template (I'm using Foundation as a base and https://github.com/olefredrik/foundationpress/ as a starter theme) I'm trying to build and I can't seem to figure out how to hook into the menu that WordPress outputs and add a custom attribute to that menu's `<li>` tags. The current menu outputs like this:

Home

About

My Work

Contact

      (Those links are just there for sample) I need WordPress to automatically add the following attribute to the `<li>` tags: `data-magellan-arrival="[target]"`. `[Target]` needs to automatically be populated by the page_ID that the menu item corresponds to. So for example, let's say that first's `<li><a href="">[PAGE]</a></li>` link is Home and Home's page_ID is "21" (example). I would need `data-magellan-arrival="[target]"` inside of `<li>` to be set to `data-magellan-arrival="21"`. So it would look like: `<li class="menu-item" data-magellan-arrival="21"><a href="">[PAGE]</a></li>` I'll be honest with you, I'm not that great at PHP just yet and WordPress filters/hooks much less. Hoping someone can point me in the right direction or show me how to do it. Thanks!


Custom form action hook

I am writting a simple newsletter subscriber plugin. I created a widget with form:               echo '<form action="'.home_url().'" method="post" name="subscriber_form">';     echo '
<input type="email" name="subscriber_mail" value="" placeholder="'.__('Enter your email','my-text-domain').'" required />
';     echo '<input type="submit" name="subscriber_send" value="'.__('Subscribe','my-text-domain').'" class="Buttons">';     echo '</form>';      I could specify the action directly to the file to handle the form but I need wordpress to be loaded. Is there a hook (like with ajax) to point the form to or is there a way to correctly start the instance of wordpress inside the plugin? Thanks for feedback.


Single.php Category Post Count

I have the following code in my single.php file:               <?php          if ( have_posts() ) :              while ( have_posts() ) : the_post();                  next_post_link('%link', 'Next', TRUE);                  previous_post_link('%link', 'Previous', TRUE);                      the_title();                  the_content();                   endwhile;          endif;      ?>      What I would like to do is count the number of posts in a category and use the `next_post_link` and `previous_post_link` link to navigate through them, then display a count. So, if the post is the second one in the category the output would look like (Post 2 of 20), if it were the third the output would look like (Post 3 of 20), etc. Any help or direction is appreciated :-) Thanks,   Josh


Connecting multiple post types? Or linking "News" posts with "Game" posts how?

I am building gaming news and tutorial website. But i don't know how to link multiple post types with one specific post. For example, i created post types called               Games     News     Tutorials     Videos     Reviews      So the games post type will be basically a list of Games, News will be posts with news, and Tutorials will be tutorials. But i need to somehow link News and Tutorials to the specific post in Games post type. Another example In Games i have made a post with game called Counter Strike. And when user click on that post he goes to the post and reads basic info of the game i inserted when i made that post. But i have a menu where i put               News     Tutorials     Videos     Reviews      So when he click on News, the visitor need to have all the posts from news custom post type related to the game from Game post and have them listed all. Here is a screenshot ![this is custom post types](http://i.stack.imgur.com/6wi1j.png) ![post inside games custom post type](http://i.stack.imgur.com/P3zFC.png) This is a post that i made inside Games custom post type and as you can see its basically a post with informations of the game. But this menu with news, reviews, guides... when i click on news i need to get somehow a list of all the posts from news, related to counter strike game(post) in Games. A way to do this? Custom category or taxonomy and link them?


Display content based on a users login

I was wondering if this is possible. I created a client portal where they can see all of their work that was assigned to them _(this is all being displayed on the frontend)_. Once they login, they are then redirect to their page. I am using the code below to display the projects related to the current user                <?php if ( is_user_logged_in() ) : function filter_posts_by_author( $query ) {              global $current_user; get_currentuserinfo();             $query->set( 'author', $current_user->ID );           }             add_action( 'pre_get_posts', 'filter_posts_by_author' );?>
Post Goes here
      <?php else: wp_die('Sorry, you do not have access to this page. Please sign in to view this page.');endif; ?>      This works perfect. The problem I am trying to figure out is how to display all post from all user when you are login as an administrator _(on the front end)_ I tried this but it then displays all of the post to all clients and administrator                <?php if ( is_user_logged_in() ) : function filter_posts_by_author( $query ) {              global $current_user; get_currentuserinfo();             $query->set( 'author, administrator', $current_user->ID );           }             add_action( 'pre_get_posts', 'filter_posts_by_author' );?>       How would I go about displaying all post once an administrator is login and only display selected post when a user login?


Plugin for choosing categories in steps in admin, parent first then display childs

**Situation:**   I'm setting up a CPT (multiple doing similar thing) where there will be a custom taxonomy only for that cpt... and it will have two levels; parent/child. So like this:               CPT = Vehicles     -- on-road     ----- type 1     ----- type 2     ----- type 3     -- off-road     ----- type A     ----- type B     ----- type C     -- utility     ----- type X     ----- type Y      **What I need to find/build in terms of a plugin / script:** When the user creates a new post in the Vehicles CPT I'd like the category(taxonomy) box to only first display the top level categories... in this case they could only choose between On-road, Off-road, Utility. If they chose on-road then they'd see only the selection for the child elements of that top level category... in this case Type1, Type2, Type3. Point is to make it simple for the user to choose in a way that makes sense for them instead of seeing ALL the categories and subcategories at one time as checkboxes or radios. I haven't seen much out there in searches so... putting it on here to see if anybody's done this yet before, if there's a plugin, a github repo somewhere. May build it if there's extra time in the project but just asking. Thanks in advance!


Sub-Theme (based on Taxonomies)

This feels like a fairly simple question, though I fear, may be a complicated answer. Is there an way (via plugin or code) to make a theme change some basic CSS elements based on a taxonomy term. So if you have camera brands, and you site is all about cameras. Can you have pages about Kodak use a CSS file where colors are blue, and if Cannon it uses a CSS file that is red, etc. Basically you sub-theme your theme based on a taxonomy term?


Get post offset/posts page offset in single post page (outside the loop)

I would like to know how I could get the offset of a custom post or its page, outside the get_posts loop. I developed an external web application which connects to the wordpress blog with JSON API plugin, and show a given posts page using an AJAX request like :               ?json=get_posts&orderby=date&order=desc&count=x&page=n      (This will return the nth page of x posts) This works well, but now I would like to set a link on the wordpress blog "single post" page to this application, like "Show this post in app", with the current page offset as parameter. So I will be able to read this param in the app and get posts of the page containing the post, and highlight this post (sent as parameter). If I can get the offset, I will be able to show the right page with a modulo operator : > If offset = 22 and count = 10, show page 3 and highlight post n°2               page = Math.ceil(offset / count);     post_to_highlight_position = offset % count;      Do you know how I could do that? or if there is a better way to achieve this?


Modify Wordpress SQL Query to pull from within a category

I am using a wordpress plugin called "kf most read" which stores a count of how many times a post was read, and lets you output a list of most read posts. This works well. The issue is, I am trying to pull the most read posts, but only the most read posts within the current category you are viewing. I am close to clueless when it comes to sql. Here us what the plugin is currently using to pull the most read posts:               $sql = "SELECT count(mr.post_ID) AS totHits, p.ID, p.post_title FROM $wpdb->posts p      JOIN {$wpdb->prefix}kf_most_read mr ON mr.post_ID = p.ID WHERE mr.hit_ts >= '".(time() - ( 86400 * $period))."'     GROUP BY mr.post_ID ORDER BY totHits DESC, ID ASC LIMIT $limit";      How could I incorporate the below query which pulls from a specific category into the above?               $sql .= "LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";     $sql .= "WHERE $wpdb->term_taxonomy.term_id IN ($currentcat)";     $sql .= "AND $wpdb->term_taxonomy.taxonomy = 'category'" ;      Any Help on this would be much appreciated.


Plugin options autoloading

In the book 'Professional WordPress Development' I found this tip: _As a rule of thumb, if your options are needed by the public part of the blog, save them with autoload. If they are only needed in the admin area, save them without autoload._ Wouldn't that result in many extra SQL queries in the backend if all plugin developers followed that advice, thus slowing down the admin side? What would be a good example of using autoload with plugin options?


Outputting custom field query from a plugin to the website header

I added the code below to the plugin that I'm working on to display the values of the custom fields but it shows up but blank.               function mySEO() {         require('wp-site-gps-transport.php');     }          // Add hook for admin <head>     add_action('admin_head', 'mySEO');     // Add hook for front-end <head>     add_action('wp_head', 'mySEO');          add_filter( 'cmb_meta_boxes', 'cmb_sample_metaboxes' );      When I add the content of the called file directly to the folder, it shows perfectly. However, I want the user of the plugin to only put value and not touch the code. Below is the code in the called file. Any ideas of what the problem could be?               <title><?php     if ( is_single() || is_page() ) {         $title = get_post_meta( $post->ID, 'title', true );          if ( $title )             echo $title . ' | ' . get_bloginfo('name');         else             wp_title('') . ' | ' . get_bloginfo('name');     }     ?></title>          <?php     if ( is_single() || is_page() ) {              if ( have_posts() ) : while ( have_posts() ) :  the_post();              $description = get_post_meta( $post->ID, 'description', true );          printf( '<meta name="description" content="%s" />',             ( $description ? $description : get_the_excerpt_rss() )         );              endwhile; endif;          } elseif ( is_home() ) {         printf( '<meta name="description" content="%s" />',             get_bloginfo('description')         );     }          if ( is_single() || is_page() ) {              if ( have_posts() ) :   while ( have_posts() ) : the_post();              $keywords = get_post_meta($post->ID, 'keywords', true);         printf ( '<meta name="keywords" content="%s" />',               ( $keywords ? $keywords : the_excerpt_rss(); ?         );              endwhile; endif;          } elseif ( is_home() ) {         printf( '<meta name="keywords" content="%s" />',             get_bloginfo('keywords');         );               }


Return all Tags from search results

I am wondering if it is possible to return a list of all the "tags" that are associated with ALL returned posts. In theory, I would then use this list of terms to build appropriate "filter by" links for refining the search. For instance: A user searches for "Foo" and there are 100 results. Would it be possible to get a collection of all the posts' tags? So, post "Foo 1" might be tagged "little bar" and post "Foo 2" might be tagged, "big bar" and "foo foo", etc and etc. I would like to do this _before_ the `while_posts()` is doing its thing. Failing that, I think I could use the `while_posts()` loop to collect all the tags for each post. This is the most obvious solution to me, except that then the list isn't where I want it in the markup. AND, I'm not sure how to include tags on page 2 (and onward) of the results.


Comments number message in password protected post

I've got a password protected post and `comments_popup_link('No Comments', '1 Comment', '% Comments');` function displays "ENTER YOUR PASSWORD TO VIEW COMMENTS." message. The question is, is it possible to change this message without touching core files, maybe apply filter or something like that. Thanks.


How to create and retrieve data from a special registration form?

What is the recommended way to approach the follow issue? I have to create two pages. On one page I will have a small form where users will be able to register themselves (with or without photo). On the other page, I will show all the users' info entered on the previous form. For the admin section, I just need to have all the registered users listed and to be able to delete them. I don't want to touch the default's WP user registration stuff, because it is already being used and I cannot mix up the things. Is it possible to use some kind of custom post types? Any plugin or idea?


How to change a user's role?

I have custom roles in my setup and I want to be able to automatically change a user's role thru a function. Say user A has a SUBSCRIBER role, how do I change it to EDITOR? When adding a role we just:               add_role( $role_name , $role_display_name , array( 'read' =>  true,                                                        'edit_posts' => false,                                                        'delete_posts' => false, ));      How about changing a role? Is there something like:               change_role($old_role, $new_role);      **UPDATE:** I think this one will do:               $wp_user_object = new WP_User($current_user->ID);     $wp_user_object->set_role('editor');


Filter get_categories() for taxonomy term in WordPress

I want to show a category only if a (custom) post is in that category AND region = $name for that post. So, e.g. I have a custom post (type "business") named "Mamma Mia" in child- category: "pizzerias" (and in parent-category "food"), and in region "Rotterdam" (custom taxonomy: "region", custom taxonomy term: "rotterdam"). => display category "pizzerias" (and parent-category "food") Only, I have no clue how to accomplish this. I'd appreciate any help on this puzzle.               <?php           // $filter = array('region'=>$name);           $categories = get_categories();      foreach ($categories as $cat)      {          if($cat->parent < 1)          {          $cat_name = $cat->cat_name;          $catid = get_cat_ID( $cat_name );          echo $cat_name. '
';               $args=array(            'orderby' => 'name',            'order' => 'ASC',            'child_of' => $catid            );          $categories=get_categories($args);            foreach($categories as $category) {               echo 'term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'
';              }                }      }           // print_r($categories);                 ?>


wp-login.php redirecting to HTTPS

I recently restored a WP multi-site 3.0.1 database from production to a staging environment, and when I try to login, I am being redirected to an HTTPS URL. The browser complains that the certificate is bad, and then when I click "proceed", it says page not found. I have cleared my browser cookies and all that good stuff, but it still won't let me login. Also, I am experiencing intermittent "No site defined on this host" errors when I try to login. I've never seen this issue before, and I have definitely done this backup db restore process before. Thanks for your help, Dave


Converting theme widgets to plugins?

i need a help, i have a theme, where in i have a twitter widget, i just want to separate it, and keep it in different file, as if it is a plugin, here are is the complete code, what i have to do? this code was in file **admin-functions.php**               /*-----------------------------------------------------------------------------------*/     /* Twitter's Blogger.js output for Twitter widgets */     /*-----------------------------------------------------------------------------------*/          function woo_twitter_script($unique_id,$username,$limit) {     ?>                ` and this second code i found in **theme-widget.php** `               /*---------------------------------------------------------------------------------*/     /* Twitter widget */     /*---------------------------------------------------------------------------------*/     class Woo_Twitter extends WP_Widget {             function Woo_Twitter() {            $widget_ops = array('description' => 'Add your Twitter feed to your sidebar with this widget.' );            parent::WP_Widget(false, __('Woo - Twitter Stream', 'woothemes'),$widget_ops);              }             function widget($args, $instance) {           extract( $args );         $title = $instance['title'];         $limit = $instance['limit']; if (!$limit) $limit = 5;         $username = $instance['username'];         $unique_id = $args['widget_id'];         ?>             <?php echo $before_widget; ?>             <?php if ($title) echo $before_title . $title . $after_title; ?>             <ul id="twitter_update_list_<?php echo $unique_id; ?>">

                <?php echo woo_twitter_script($unique_id,$username,$limit); //Javascript output function ?>               <?php echo $after_widget; ?>                   <?php        }             function update($new_instance, $old_instance) {                            return $new_instance;        }             function form($instance) {                         $title = esc_attr($instance['title']);            $limit = esc_attr($instance['limit']);            $username = esc_attr($instance['username']);            ?>
                <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','woothemes'); ?>                <input type="text" name="<?php echo $this->get_field_name('title'); ?>"  value="<?php echo $title; ?>" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" />

                <label for="<?php echo $this->get_field_id('username'); ?>"><?php _e('Username:','woothemes'); ?>                <input type="text" name="<?php echo $this->get_field_name('username'); ?>"  value="<?php echo $username; ?>" class="widefat" id="<?php echo $this->get_field_id('username'); ?>" />

                <label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e('Limit:','woothemes'); ?>                <input type="text" name="<?php echo $this->get_field_name('limit'); ?>"  value="<?php echo $limit; ?>" class="" size="3" id="<?php echo $this->get_field_id('limit'); ?>" />
           <?php        }          }      register_widget('Woo_Twitter');      i just want this code to be a different file, just like a plugin, so that i can use this in my another theme also, can anyone help me here???


Insert link to my thumbnail images

I am try to insert link to my thumbnail images, the link is hyperlink with post. When i put this code inside the loop then instead of showing the first image, first show the second image (template_url)               <a href="<?php the_permalink() ?>" class="alignnone" title="<?php the_title(); ?>">     <?php if (has_post_thumbnail()) : ?>     <a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><?php the_post_thumbnail(); ?>     <?php else : ?>     <img src="<?php bloginfo('template_url'); ?>/images/noimage.jpg" width="213" height="187" alt=""/>     <?php endif; ?>           The code of the tempate :               <?php if (have_posts()) : while (have_posts()) : the_post(); ?>         <div <?php post_class() ?> id="post-<?php the_ID(); ?>=">

          <a href="<?php the_permalink() ?>" class="alignnone" title="<?php the_title(); ?>">          <a href="<?php the_permalink(); ?>" title="<?php the_title();?>">                                                     <?php if (has_post_thumbnail()) : ?>                                                         <?php the_post_thumbnail(); ?>                                                         <?php else : ?>                                                             <img src="<?php bloginfo('template_url'); ?>/images/noimage.jpg" width="213" height="187" alt=""/>                                                         <?php endif; ?>

 Άlbum :  <?php print_custom_field('title_album'); ?>

Photos :  <?php print_custom_field('Number_photos'); ?>

       Even if this part of code, the result is the same..               <?php   echo '';             if (has_post_thumbnail())      {the_post_thumbnail();}     else {echo'';}             echo ''; ?>


redirected to the login screen when I do a blank search

why when I'm offline , when I click the search button and not put any words I am redirected to the login screen? I simply click in search button, don't put any word. If i'm normal user, don't logged user, i go to login page. I want to show a message: Search Empty, please try again.


get_terms() How many is TOO many?

Working on revamping a plugin of mine when I noticed that `wp_count_terms()` is not reflecting the same number as a call to `count( get_terms() )` with the same $args passed. I'm pretty sure this is a bug in WordPress and I'll submit a trac ticket in a little bit. I wanted to get a solid working solution, so I ended up just making one call to `get_terms()` and then using `count()` on the array to get the count. My question is: "How many terms can be returned without slowing everything down". It's possible that there could be scaling issues here where there are a lot of terms in a taxonomy, but how many is TOO many? 1,000? 10,000? Just looking for a ballpark here.


Custom post type archive with dynamic taxonomy filtering - is it possible

I have a custom post type archive template archive-my-posttype.php with pagination. These post types have a custom taxonomy called theme. I am displaying these themes(terms) in the sidebar as a checkbox list. How can I filter the custom post type based on the selected themes/checkboxes? Can this be accomplished by adding a query_var parameter (theme_filter) and somehow modifing wp_query with the pre_get_posts filter? I am trying to let WP handle pagination rather than have to rewrite it myself. Thanks


Add custom post types stats to a custom dashboard widget

I have a lot of custom post types and I have them showing in my "Right Now" Dashboard but it's gotten pretty long so I want to separate them to a custom widget within the dash. See example below: ![enter image description here](http://i.stack.imgur.com/ge0Yy.png) So my question is how do I add the CPTs to a custom dashboard widget? Any help would be awesome. Thanks! EDIT: This is what I have (What am I missing?)               // wp_dashboard_setup is the action hook          add_action('wp_dashboard_setup', 'mycustom_moviestats');               // add dashboard widget     function mycustom_moviestats() {          wp_add_dashboard_widget('custom_movie_widget', 'Movie Stats',                  'custom_dashboard_movie_list');          }          function custom_dashboard_movie_list(){          // here is the code to add custom post types + count see below          function my_right_now() {     $num_widgets = wp_count_posts( 'widget' );          $num = number_format_i18n( $num_widgets->publish );     $text = _n( 'Widget', 'Widgets', $num_widgets->publish );     if ( current_user_can( 'edit_pages' ) ) {          $num = "$num";         $text = "$text";     }             echo '
';     echo '' . $num . '	';     echo '' . $text . '	';     echo '
';     }     add_action( 'right_now_content_table_end', 'my_right_now' );          }


Use template tags in code snippets wordpress

I'm trying to use WordPress template tags (through shortcodes) to merge the post title and url into hyperlink html code. Which looks like this:               [Post Title].      Problem is the text output uses curly quotes around the "Permalink" that are not compatible with html code. I tried placing hyperlink code using template tags (shortcodes) into a code snippet box, however then the shortcodes won't run. I would like to merge the template tags (through shortcodes) into the hyperlink html code first, then have it show up in a code snippet box. Any ideas on how to do that?


Duplicate attribute class causing site validation error

The following bit of code results in a duplicate attribute site validation error. This template script:               <div class="clearfix" <?php post_class() ?>>      produces this source output:               <div class="clearfix" class="post-263 post type-post status-publish format-st…      WordPress adds its own post-related classes to format the blog entry. Is there any way I can add my "clearfix" class to the template without producing the duplicate attributes? Thanks.


Check the password of a user

I want to keep a check if the user has a particular password, so I have been trying it with `wp_check_password` but the account for which it is checked gets logged out and can't login again till there is a call of `wp_check_password` in the code. Digging into the code, I found out that it sets the password by using the new hash. and moreover if I am using `wp_check_password( 'hello', md5('hello'), 1 );`, it doesn't even check what is inside the database and returns true. Isn't that a bug? Any ideas how can I check the user's password?


What Are Security Best Practices for WordPress Plugins and Themes?

As suggested in this question, I am adding this topic as a new question, for community discussion/voting regarding best-practices for Plugin/Theme security. Here is the starting checklist, based on my current (work-in-progress) settings/data security checklist used for reviewing Themes (the principles should be no different for Plugins than they are for Themes). If you want to check out a theme with a secure and solidly-coded theme settings page, check out this theme:   http://wordpress.org/extend/themes/coraline


Behind-the-scenes HTTP Request?

I'm trying to add a line to my functions.php that does a behind-the-scenes HTTP request submitting some user information to a mailing list URL I have. I'm trying to test the code at the moment, but nothing seems to be working. I have tried the following:               $url = 'blabla.org/mailinglist/add?' . $user_email;     $request = new WP_Http;     $result = $request->request($url);      and               wp_remote_post($url);      Neither have worked. However, if I Just copy and paste the URL into my web browser, it works fine. Please help! Thanks, Tre


Search everything (posts, pages, tags, cpt, meta)

I would like to know how to use the built in wordpress search to return results from all content on my site. Specifically, I want to search;   * posts   * pages   * tags   * custom post type (portfolio)   * custom taxonomy used in custom post type (skill, client)   * metaboxes used in custom post type (portfolio_caption, portfolio_excerpt, portfolio_credits, portfolio_links) I would like one search form and don't need to limit the search to certain post types or categories. Just enter the search term > click search > see matches from all content on my site. Simple ;) Update: Preferably, I would achieve this through a function or custom database query rather than using a plugin. This is because I'm developing a theme and want this functionality included out of the box rather than requiring a user to download a plugin. (title changed)


Global custom meta box

I am trying to create a custom meta box for multiple custom post types in WordPress without creating duplicate code. Currently I have:               add_meta_box('adv_form_box1', 'Advanced Form', 'adv_form1', 'custom-post-type1', 'side', 'high');     add_meta_box('adv_form_box2', 'Advanced Form', 'adv_form2', 'custom-post-type2', 'side', 'high');     add_meta_box('adv_form_box3', 'Advanced Form', 'adv_form3', 'custom-post-type3', 'side', 'high');          function adv_form1() {     global $post;     $custom = get_post_custom($post->ID);     $filename = $custom['filename'][0]; ?>     Filename: (this field is required)
<input name="filename" size="70" value="<?php echo $filename; ?>" />     <?php }          function adv_form2() {     global $post;     $custom = get_post_custom($post->ID);     $filename = $custom['filename'][0]; ?>     Filename: (this field is required)
<input name="filename" size="70" value="<?php echo $filename; ?>" />     <?php }          function adv_form3() {     global $post;     $custom = get_post_custom($post->ID);     $filename = $custom['filename'][0]; ?>     Filename: (this field is required)
<input name="filename" size="70" value="<?php echo $filename; ?>" />     <?php }      I feel as though I am creating a bunch of extra un-needed code. Is there anyway to set the meta box as "global" to be used in all post-types?


WordPress category gives 404 after moving to a different domain

I just moved a site from one domain to another and now category links are all 404. I have flushed the rewrite rules, recreated the .htaccess file but still it throws up 404. Weird thing is that if I delete `.htaccess` file, then the posts are still accessible by `domain.com/postname/` and when I save permalinks, then it is created there. So can it be the case it is using some other .htaccess file? Possibly some fallback that I am not aware of? **Re-Edit:** _**Tag pages don't work fine_**. Its all weird. Tags generally give 404, one of them opened a non 404 page but not what it should be (i.e. posts listing under that tag). And a category redirects itself to one of the posts. This all led me to conclude that tags were working but they are not. Also everything works, when I turn off the permalinks. I am using a custom slug for category "cat" and not the default "category" but reverting to the default doesn't solve anything. Any clues? **Edit:** I saw Ipstenu's sticky on WP forums and found that Advanced Permalinks are known to have a problem with WP 3.1, so I disabled it and recreated by permalinks but still no joy. What did I miss? So far, I have tried recreating permalinks, flushing rewrite rules by calling `global $wp_rewrite; $wp_rewrite->flush_rules();` in `functions.php`, deleting `rewrite_rules` in `options table` & even deleting `.htaccess` file. So I am clueless and would appreciate if someone can give me a clue how it can be fixed. **Further Edit:** If I delete the .htaccess file, the site behaves if it was there and I can browse pretty permalinks without any issue (.htaccess file is not there in the WP root) but when I resave permalinks, it is created there. So can there be some kind of fallback for .htaccess because this shouldn't be possible without rules in .htaccess? **EDIT:** I am still stuck at the issue. Can anyone please help me out? **Final Edit:** Is there anything left in the wild that I can do to troubleshoot this issue? I have lost hope on this one.


How to disable or protect against disposable email accounts?

Now im getting a couple of disposable email accounts in users table, how can I avoid this nasty situation?


Cancel jQuery 'noConflict' - is it really unsafe?

I use some external plugins (not wordpress plugins), that use '$', and it's very convenient for me to cancel `noConflict` mode, by adding this line   `$=jQuery`   But I guess they invented `noConflict` mode not for nothing.   The question is how much have to worry about it. And is really a problem to use `$=jQuery`?


No "available widgets" (wordpress 3.2.1 multisite)

I have no widgets available any ideas? I've tried the "Twenty Eleven" Standard Theme and the custom one (Lotus). No widgets are listed, I am looking for the custom_menu widget. In my other wordpress installation I have plenty of widgets available. **Update** : I use a multisite installation and I found that the blog_id in wp_options is set to 0 (not sure this has something to do with it?)


Custom field totals

I have tried searching everywhere for this and although there are some discussions about adding the total to the frontend, there is nothing about the admin side. I have a custom post type that has posts and one fo the fields of those posts is a price. I would like for the statuses (all, published, concept...) to show the relevant sum total of that field. Just like the statuses show the total number of posts in perentheses. Is there a smart way to do this?


Wp die causing 500 Internal Server Error?

I have function to upload images inside my settings API ,it uploads images as expected but the problem comes when user chooses to upload **non-image file** to stop users from uploading other files (non-image files) i am using `wp_die('No image found');` an that leads to dreaded **500 Internal Server Error** message displayed. Strange thing is that my wp_die `wp_die('No image found');` is running fine on my **local computer** but not **online**.               function validate_setting($plugin_options){             //echo '<pre>';  print_r($_FILES); echo '</pre>';       $keys = array_keys($_FILES);        $i = 0;       foreach ($_FILES as $image) {                  if($image['size']){         //Is it an image?         if(preg_match('/(jpg|jpeg|png|gif)$/i',$image['type'])){           $override = array('test_form' => false);           $file = wp_handle_upload($image,$override);                    $plugin_options[$keys[$i]] = $file['url'];         }        else{        wp_die('No image found');//This triggers 500 Internal Server Error WHY??            //echo:'no image found'; //Now this DON'T work locally but works ONLINE?!?        }     }     else{      $options = get_option('theme_options');      $plugin_options[$keys[$i]] = $options[$keys[$i]];     }     $i++;         }          return $plugin_options;         }      I tried to change `wp_die()` to `echo 'no image found';` and this happens: now on my **locall** machine it echoes 'nothing' (no warning displayed), but now **online** it works and displays 'no image found' warning... I know i could simply delete the `else{ wp_die('No image found'); }` part and display no warning, but WHY it is not working as intended? Can someone tell me what is wrong with my code and how to display warning with wp_die('No image found') properly _(without causing "500 Internal server error" )_?