How to use wp_footer() on a 404 page?

I am designing my 404 error page, for which I created a separate header and of course I need a separate footer. As for the latter, instead of creating a new one, would be enough for me to ensure the`wp_footer();` to be just before the closing body? Or is there something in the `get_footer()` function that makes it necessary?


new line after the_content

Trying to properly indent a theme I wondered if it would be possible to create a new line `"\n"` directly after `<?php the_content(__('Continue reading <span class="meta-nav">→</span>', 'mytheme')); ?>`? Edit: At the person who did a -1 on this topic, could you perhaps explain which part of > This question does not show any research effort; it is unclear or not useful > (click again to undo) I didn't follow?


Programmatically Creating Page using $wpdb and getting 404 error

## EDIT: Turns out I had a permalink issue that was causing the 404 error. ### Original Posting below: I am creating a page programmatically using $wpdb->insert() and the resulting page returns a 404 error. ### A few things to note   * I am using a $wpdb object to create the page because I am creating it on a separate WordPress website, so wp_insert_post() doesn't work, because it would insert the post into the website I making the call from. Basically I have a network of websites, and I am creating a post on one site from a different site.   * I am creating a custom post_name (slug) value for the page. So, when I add the page programmatically, everything in the database looks just as if it were added via the WordPress Admin Area. I can even go to that website's WordPress Admin area, and edit the post. However, if I go to view the page it throws a 404. Now, if I "update" the post from the WordPress Admin area, the 404 goes away. If I create a post programmatically and create it from the WordPress Admin area, and then look at the database columns, they are the EXACT same values (or appear to be). Why would one work, and one wouldn't? Also I'm using permalinks ( ~~nothing custom, just one of those predefined choices~~ ). ### This is the wpdb insert call I'm using...               $post = array(         'post_author' => 1,         'post_date' => date('Y-m-d H:i:s'),         'post_date_gmt' => date('Y-m-d H:i:s'),         'post_content' => '',         'post_title' => 'My Page',         'post_name' => 'my-page',         'post_excerpt' => '',         'post_status' => 'publish',         'comment_status' => 'open',         'ping_status' => 'open',         'post_modified' => date('Y-m-d H:i:s'),         'post_modified_gmt' => date('Y-m-d H:i:s'),         'post_parent' => 0,         'post_type' => 'page',         'comment_count' => 0     );          $wpdb->insert(         'wp_posts',          $post,         array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' );     );


How to show posts of an columnized different categories on the same line or row?

I use a custom query retrieving the two categories of the post type, each column show only 6 posts of the category, if was more use pagination. Than I like to do is to show each post on each column on the same line or row, this just for design purposes, I thought than the query must count for the first two post, put on two divs (for example) and then put the next two, and the next later, until complete the sixth row to paginate if there are more. Really appreciate any comment or idea to solve this, didn't really know how to do. Here is the custom query I use:               <?php                     // for a given post type, return all                     $post_type = 'evento';                     $tax = 'categorias-eventos';                     $tax_terms = get_terms($tax);                     $post_counter = 0; // reset so we can generate columns                      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                              if ($tax_terms) { ?>
                                  <?php foreach ($tax_terms as $tax_term) {                              $args = array(                             'post_type' => $post_type,                             "$tax" => $tax_term->slug,                             'post_status' => 'publish',                             'posts_per_page' => 6,                           //'posts_per_page' => -1,                           //'paged' => $paged,                             'orderby' => 'title',                             'order' => 'ASC',                             'caller_get_posts' => 1                             ); // END $args                                  $my_query = null; // clear the query variable                             $my_query = new WP_Query($args);                                  if( $my_query->have_posts() ) { ?>

<?php echo $tax_term->name; ?>

                                      <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
                                     <div class="retailer_wrap retailer_id-<?php the_ID(); ?>">
<?php the_title(); ?>

<?php echo get_post_meta($post->ID, 'eventdate', true);?>

<?php echo get_post_meta($post->ID, 'eventplace', true);?>

                                 <?php $post_counter++; ?>                                      <?php if ( 0 == $post_counter % 6 ) { ?>

                         <?php } // END if $post_counter ?>                       <?php                       endwhile;                       //wp_pagenavi( array( 'query' => $my_query ) );                      } // END if have_posts loop                     wp_reset_query();                        } // END foreach $tax_terms ?>
                 <?php } // END if $tax_terms                 ?>


Why am I timing out when using the Menu Editor?

I'm using a more or less fresh local install of WP 3.3.1. A few days ago I set up a couple menus (Appearance > Menus) without a hitch. Today I tried creating a new menu and add a page to it, but the page was never successfully added to the menu; the spinner just went on forever. I thought maybe the menu name was conflicting with one I had deleted earlier, but I can no longer add pages to new or existing menus. The same goes for custom links; I just get the spinner even after waiting 15 minutes. I only have one plugin enabled, Advanced Custom Fields 3.0.6, which I disabled to no avail. I have no custom post types or taxonomies. There are about 15 pages total with very little content on them, so WP isn't getting stuck sifting through a bunch of data. Any other ideas?


How to retrieve alt attribute for an attachment (uploaded image)?

I have some IDs of attachments (images, not from current post). How to I get the alt attribute for those images? I have tried to look into wp_get_attachment_image_src and wp_get_attachment_metadata but couldn't find the alt attribute stored in neither of those this is where I'm looking for the alt:               while(the_repeater_field('featured_pics')): //this is an array of IDs         $image_id =  get_sub_field('featured_pic'); // this function gets an individual ID from array         $image_attr = wp_get_attachment_image_src(get_sub_field('featured_pic'), 'medium');         echo '
'.wp_get_attachment_image($image_id, 'thumbnail').'
';      endwhile;


retrieve all emails as database in wordpress to view all sent emails

I have a wordpress CMS website,having contact us page to send email.. can i keep track for the use of this page by sender name,subject, attachment at wordpress admin panel or any other way?? anybody have idea How to get database of all received emails from WordPress site's Contact Us Page?


filter wp_query result with custom field values

I'm getting started with advanced custom fields. I have a category field (main_category) where the categories given below are selected using the radio buttons.               1. Electronics     2. Programming     3. Design      where there are sub categories for these categories. they are set using the conditional radio buttons for each category. the sub categories are indexed, the fields are given ion brackets,               Post Type: article     Field Name: Category     Field key : main_category          1. Electronics - - - - - - - - (electronics)             Linear Electronics - -      (elect_linear)             Computer Networks- - -      (elect_networks)             Microwave Engineering-      (elect_microwave)             MicroProcessors- - - -      (elect_micropro)     2. Programming - - - - - - - - (programming)             ObjectiveC - - - - - -      (prog_objc)             Pythion  - - - - - - -      (prog_python)             JavaScript - - - - - -      (prog_js)             PHP  - - - - - - - - -      (prog_php)     3. Design     - - - - - -  - - (design)             Illustrator  - - - - -      (desgn_ai)             Photoshop   - - - - - -     (desgn_ps)             After Effects   - - - -     (desgn_ae)             Cinema 4d   - - - - - -     (desgn_cf)      the WP_Query was made,               $articles = array(       'numberposts' => -1,       'post_type' => 'article',       'meta_key' => 'main_category',     );               $query_articles = new WP_Query( $articles);      it returned an array $query_articles which contains all the posts., how can I filter through the array $query_articles ? so that I would add 'tagged in php' for the articles in the php sub category.? what i could do in my knowledge was to query arrays with different categories..               $electronics = array(       'numberposts' => -1,       'post_type' => 'article',       'meta_key' => 'main_category',       'meta_value' => 'electronics'     );     $programming = array(       'numberposts' => -1,       'post_type' => 'article',       'meta_key' => 'main_category',       'meta_value' => 'programming'     );     $design = array(       'numberposts' => -1,       'post_type' => 'article',       'meta_key' => 'main_category',       'meta_value' => 'design'     );                    //query variables     $query_electronics = new WP_Query( $electronics);     $query_programming = new WP_Query( $programming);     $query_design = new WP_Query( $design );      but the sub categories always messed up and also it eats up lots of resource. ps. this is for a blog i'm developing in localhost. thanks for any help and comment.


reorder a WP_Query, using a dropdown

I have the following loop used to display posts by category & I would like to to re-order them based on a dropdown selector               if (!isset($qry))         $qry = new WP_Query(array('category_name'=>$GLOBALS['city'],'order'=>$orderby));              if ($qry->have_posts($orderby)) {         $do_the_post = null;              if (is_single($orderby)) {             $do_the_post = true;         } else {             $qry->the_post($orderby);             $do_the_post = false;         }              $user = get_userdata($post->post_author);      So far, using some code I found here I have:               if( isset($_GET['o']) && $_GET['o'] != '')         {         $order = $_GET['o'];         switch($order)         {             case 'date-asc': $orderby = 'order=ASC';                 $msg = 'Date Ascending';                 break;             case 'date-desc': $orderby = 'order=DESC';             $msg = 'Date Descending(default)';                 break;             case 'date-mod': $orderby = 'orderby=modified';                 $msg = 'Date Modified';                 break;             case 'title-asc': $orderby = 'orderby=title&order=ASC';                 $msg = 'Title A-Z';                 break;             case 'title-desc': $orderby = 'orderby=title&order=DESC';                 $msg = 'Title Z-A';                 break;             case 'comment': $orderby = 'orderby=comment_count';                 $msg = 'Comment Count';                 break;         }         }         else         {             $orderby = 'order=DESC';             $msg = 'Date Descending (default)';         }                           <div id="sorter-container">                 <select id="order-by">                     <option value="date-desc" <?php echo (!isset($order) || $order == '' || $order == 'date-desc')? 'selected="selected"':''; ?>>Date Desc. (default)</option>                     <option value="date-asc" <?php echo ($order == 'date-asc')? 'selected="selected"':''; ?>>Date Asc</option>                     <option value="date-mod" <?php echo ($order == 'date-mod')? 'selected="selected"':''; ?>>Date Modified</option>                     <option value="title-desc" <?php echo ($order == 'title-desc')? 'selected="selected"':''; ?>>Title Desc.</option>                     <option value="title-asc" <?php echo ($order == 'title-asc')? 'selected="selected"':''; ?>>Title Asc.</option>                     <option value="comment" <?php echo ($order == 'comment')? 'selected="selected"':''; ?>>Comments Count</option>             </select>             </div>      //JQUERY                   <script type="text/javascript">             var orderby = jQuery('#order-by');             var str;             orderby.change(function(){             str = jQuery(this).val();             window.location.href = "<?php echo home_url(); ?>/gallery/?o="+str;         });         </script>      Is calling $orderby as the order is not working - my PHP is rudimentary at best, but can anyone tell me what's wrong here? Thanks...


Top 30 Songs using Custom Post Type

I have successfully created a Top 30 songs ranking via custom post type. Now im stuck with adding "Peak Position" post meta. I don't know how to program it. Peak Position is the position where the song ranked for a couple of weeks. For example, Song 1 has been ranked 5 for 10 weeks and then down to 6 position for 3 weeks.. so the Peak Position for Song 1 is 5 since it lasted for 10 weeks. Now i'm stucked thinking how can i save its peak position using post meta. Can anyone suggest?


Way to force media uploader use custom image size

I've implemented media uploader to my custom category image plugin and was wondering can I somehow force it use my custom image size I've set only for categories. ![enter image description here](http://i.stack.imgur.com/TxWqw.png) ... So in screen shot above, I'd like Size column only contain "Category Image (80 x 80)" and automatically be selected. The way I've added that 'Category Image' to the list is shown below               add_filter( 'image_size_names_choose', 'custom_image_sizes_choose' );          function custom_image_sizes_choose( $sizes ) {           $custom_sizes = array(               'category-image' => 'Category Image'           );         return array_merge( $sizes, $custom_sizes );       }      If in that function I only return `$custom_sizes` it will affect every media uploader context, eg. Posts->Add Media, and not only when setting up my category image. Here's how I've implemented Media Uploader in my plugin               add_action( 'admin_init', 'cat_image_options_setup' );          //------------------------------------------------     // Setup category image media picker     //------------------------------------------------     function cat_image_options_setup() {         global $pagenow;         if ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) {             // Now we'll replace the 'Insert into Post Button inside Thickbox'              add_filter( 'gettext', 'replace_thickbox_text' , 1, 2 );         }     }          //------------------------------------------------     // Replace the media picker button text     //------------------------------------------------     function replace_thickbox_text( $translated_text, $text ) {          if ( 'Insert into Post' == $text ) {             $referer = strpos( wp_get_referer(), 'cat_image_settings' );             if ( $referer != '' ) {                 return __( 'Add as a category image', 'ddr' );             }         }              return $translated_text;     }      Any way to achieve that? Thanks! PS. If someone knows better way to implement that media uploader, please let me know. Now it somehow uses the old media uploader window, and not the same as in Posts->Add Media.


Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)

I have a custom post type named "tours" and a custom taxonomy named "tour_type". "tour-type" taxonomy is hierarchical. In "tour-type" taxonomy, parent terms are limited to "eco-tours", "daily-tours", "package-tours" & "tailor-made- tours". All terms except "tailor-made-tours", have children. I'm trying to reach a permalink structure like below for my tour post type: > /parent-tax/child-tax(if exist)/custom-post-type-name For example it would end up like this: > mysite.com/eco-tours/diving-and-rafting/coast-to-coast/ > > Or like this (for "tailor-made-tours"): > > mysite.com/tailor-made-tours/margoon-waterfall/ I read lots of tutorials and solutions which lead me to these parts of code:               $tours_args = array(         'labels'                => $tours_labels, //Some Labels         'public'                => true,         'menu_position'         => 10,         'query_var'             => true,         'rewrite'               => array('slug'=>'%tour_type%'),         'supports'              => $custom_post_types_supports,         'hierarchical'          => true,     );     register_post_type('tours',$tours_args);               add_filter('post_type_link', 'filter_post_type_link', 10, 2);     function filter_post_type_link($link, $post)     {         if ($post->post_type == 'tours')         {             /*...             Some codes which make $term equal to "parent-tax/child-tax"             ...*/                  $link = str_replace('%tour_type%', $term, $link);         }         return $link;     }               add_filter('rewrite_rules_array', 'mmp_rewrite_rules');     function mmp_rewrite_rules($rules) {         $newRules  = array();              $newRules['eco-tours/(.+)/(.+)/?$']         = 'index.php?post_type=tours&tour_types=eco-tours&custom_post_type_name=$matches[2]';         $newRules['daily-tours/(.+)/(.+)/?$']       = 'index.php?post_type=tours&tour_types=daily-tours&custom_post_type_name=$matches[2]';         $newRules['package-tours/(.+)/(.+)/?$']     = 'index.php?post_type=tours&tour_types=package-tours&custom_post_type_name=$matches[2]';         $newRules['tailor-made-tours/(.+)/?$']      = 'index.php?post_type=tours&tour_types=tailor-made-tours&custom_post_type_name=$matches[1]';              return array_merge($newRules, $rules);     }      Now, permalinks which are shown in post type edit pages, are showing the right url, but when I open each of them, they show an archive page of "tour" post type... What did I drop in my codes?! :(


Safest way to bulk delete post revisions

One of my clients is on a rather large blog in terms of number of posts and traffic. I'm trying to get her database down to a manageable size, and one thing that's bulking up is literally tens of thousands of post revisions. I've already set Wordpress config to limit the number of revisions in the future to two:               define('WP_POST_REVISIONS', 2);      But I want to delete all existing revisions. **Question 1** : Is it safe to directly delete all rows in the wp_posts table that have a post_type of revision? (I've seen conflicting answers on this—but I'd love to be able to just do it this way if it's safe). **Question 2** : _…and this is only relevent if I should **NOT** just do the straightforward delete from question one:_ I found this answer where songdogtech provides a database query to safely delete, but (1) it's specifically in answer to a multisite question (this is a single site) and (2) I have just upgraded the site to 3.6, which included database changes. (So, I'm not skilled enough in reading database queries to know exactly what's going on there and if it would work for a single site in WP 3.6


Store subscription details for users in Wordpress

I want to store subscription details of several category for users. how to store this to wp database. i am beginner to wordpress. whether i want to create new table or can i use meta ,taxonomy or some thing?


Changing Link Attributes for Wp_Link_Pages

I'm wondering if there is any way to change the actual link itself for wp_link_pages. So right now, I have a simple code to display the pagination for a post, it looks like this: `<?php wp_link_pages( array( 'before' => '<div class="link-pages">' . __('Pages:', 'muimedia'), 'after' => '</div>',) ); ?>` It displays the Post pagination like so: Pages: 1 2 3 Page one links two page one, page two links to page 2 etc. Now, I would like to add an attribute called `fromwhere=news"` to the pagination permalinks. So page 1, 2, and 3 pagination links would look like so.. `mysite.com/somepost/post?fromwhere=news"` instead of just `mysite.com/somepost/post` I really hope this is possible, and if anyone could help me out, it would really mean a lot to me! And happy new years!!! :)


Plugin Add New Installer failing

I recently transferred my Wordpress Site to a new host. I have almost everything working, except for the plugin auto installer. If I search for a plugin and install it, it works just fine. If I try to upload my plugin from my computer, I get this error message: Download failed. A valid URL was not provided. I can manually install the plugin through my FTP client, Cyber Duck, by uploading the folder and activating it in the plugins list. I have set all my permissions to 777 on my plugins folder. I do not see anything in my server error logs period. I've had a lot of problems with setting permissions with the transfer, so I think that may be it. Can someone help? Thanks!


Removing buttons from the html editor

I've been searching the codex, and I'm probably overlooking something somewhere, but could someone tell if it would be possible to remove a button/quicktag from the WordPress html editor? http://i.stack.imgur.com/dZBTT.png


Is the current Theme version number cached somewhere?

I need access to my Theme's version number a number of times on each Admin Page view. Right now I'm using `get_theme_data` which in turn parses the Theme's `style.css` file via `get_file_data`, so `style.css` gets parsed multiple times. Is there a built-in caching mechanism for this data? Or should I just build a thin _in-process_ caching wrapper around `get_theme_data`? Thanks!


How to create a plugin that only operates on the home page?

I have a plugin that I only want to execute when the home page is being viewed. How would I stub out my plugin in order to make this happen? This is does not work...                <?php      /*      Plugin Name: My Test Plugin      */                if ( is_home() OR is_sticky() )      {       add_filter( 'the_content', 'my_function' );      }           function my_function( $content )      {        echo "hello world".$content;      }           ?>      This is my original code, but it executes the filter on every page. Which seems overkill to me, since I only want the plugin to run on the home page anyway.                add_filter( 'the_content', 'wpse6034_the_content' );      function wpse6034_the_content( $content )      {       if ( is_home() ) {        $content .= '
Hello World!
';       }       return $content;      }


If taxonomy show class of active

I have a nav which I would like to detect if an li should have a class of active or not. I usually do this for a normal page like this:                   <li <?php if ( is_page('about')) { echo ' class="active"'; } ?>>                                 <a href="<?php bloginfo('url'); ?>/about">About
      However I'm doing this on a taxonomy page and I would like to detect the name of the taxonomy term. So I have 4 terms, `design`, `illustration`, `motion` and `photography`. How would I go about adding a class to the li of the active taxonomy term? Here is what I have so far but its wrong:               <li <?php if ( is_taxonomy('illustration')) { echo ' class="active"'; } ?>><a href="<?php echo site_url(); ?> /talcat/illustration">Illustration
      **Update:** I have changed `is_taxonomy` to `is_tax` and then defining my taxonomy name and term. However this still isnt working. Here is my update coded:               <li <?php if ( is_tax( $Talcat, $illustration)) { echo ' class="active"'; } ?>>


How can a single line in a blog post take down my server?

I've been trying to write a post about a simple Windows Powershell script for the last few hours, but when I try to preview the post with the script included, it takes down my server. Unfortunately the server isn't mine to control (it's hosted by 34sp.com) so I'm limited in what I can do to diagnose the issue - I'm not sure where I'd start anyway. The problem _seems_ to stem from including the following lines in the post :               <pre>         $camera_getid.Parameters.Add("@CameraGUID", [System.Data.SqlDbType]"NVarChar").Value = $guid;     </pre>      I'm having trouble narrowing down the problem precisely, since every time it happens, my server is down for about 5-10 minutes. Has anyone seen anything similar?


wordpress theme backend admin only

Does anyone know of a theme that completely removes all uses and aspects of the frontend. So the sole use of the site will be in the admin section. to use as a portal for something like a school or internal government uses.


How wp_enqueue_script works?

I am trying to get scripts via `wp_enqueue_script();`. I have tried this in header but WordPress is not importing any script. I am using like this `wp_enqueue_script('jquery');` http://codex.wordpress.org/Function_Reference/wp_enqueue_script Is any other step needed for importing script via WordPress?


list posts of two post types in a single template

I have two post types. One is `post` & other one is `event`. Both sharing same categories & tags. I am listing the posts by `archive.php`. Now I am listing the posts as general by two different templates like `archive.php` / `archive- event.php`. But now I want to list them in a single template with mixing the posts and order by date. So any one would help me in this regard.


Show all post of a taxonomy with one specific term not working

I have a custom post type "restaurants" and a taxonomy "location", so I can get the restaurants for one location by URL. On the taxonomy page for one specific location (CityA) I want to display all post types from restaurants and the taxonomy term "CityA". However, Wordpress also gives me posts with taxonomy terms "CityB" or "CityC" in the very same query. Have a look:               $args = array ( 'post_type' => 'restaurants', 'tax_query' => array ( 'taxonomy' => 'location', 'field' => 'slug', 'terms' => 'citya' ), 'order_by' => 'title', 'order' => 'ASC' );          $query = new WP_Query ( $args );     while ( $query -> have_posts () ) {         $query -> the_post();         echo get_permalink($post->ID;     }      This gives me ALL posts of post_type "restaurants". And yes, the slug for CityA is definetely "citya", I double checked all arguments.


tb_show is not defined in advance custom field

I am using the plugin: Advanced Custom Fields. For several more images, I used it to add images using the image input field. Now, when I edit a post, I can't edit/add new image into the image field using the plugin. Using Firebug, it shows a `js` error: > Uncaught ReferenceError: tb_show is not defined But the same fields work, when I add a new image using those fields.


wp-admin won't "remember me" in Chrome & Firefox

When I login to wp-admin, I tick the box to "remember me", so I don't have to login again next time. However, if I close the wp-admin tab, and reopen wp-admin in a new tab, I have to login again. Alternatively, if I browse to another website, and then return to wp-admin, I have to login again. This happens in Chrome and Firefox. It doesn't happen in IE9 - in IE9 I am remembered. In wp-config.php, 'WP_HOME' & 'WP_SITEURL' are set to the same value. Any


Wordpress schedule posting not working

I have Wordpress 3.5.1 and I use Bluehost hosting service. When I schedule posts after that time passed, WP posts dashboard shows "Missed schedule" message under the date. Then I checked my `wp-config.php` has `define('DISABLE_WP_CRON', true);` there's no such a define line. Then I added `define('DISABLE_WP_CRON', false);` under the database lines. After that I added following code to my `.htaccess` file.               <Files "wp-cron.php">     Allow from All     Satisfy Any     </Files>      But still this issue not fixed. What is the reason? Is it my hosting company issue or my WP issue? How do i fix it?


Filters on Login Page

I am trying to modify the login page using built in filters. The add_actions are working as expected, but I cannot get the filters to work. This is the code that I have in my functions.php:               add_filter( 'login_form_top', 'filter_top_login' );     function filter_top_login( $content )     {         return 'This is what I want it to say!';     }      but it doesn't seem to be doing anything when I load the wp-login.php page. What am I doing wrong?


What PHP Needed to Make One Loop with Multiple Styling?

I understand that there is a way to have the loop display multiple ways on one page without using multiple loops... Or in other words something like:               <?php if (have_posts()) : while (have_posts()) : ?>     <!-- Code for the First Post -->     <?php else: ?>     <!-- Code for Posts 2-4 -->     <?php else: ?>     <!-- Code for Posts 5-12 -->     <!-- stuff to close loop -->      Problem is that I don't really know php well, and I have no idea how to have it count posts and how to tell it for the first post do X, for posts 2 through 4 do X, and for posts 5 through 12 do X... If anyone can point me to a clear tutorial or let me know what PHP is necessary, I'd really appreciate it. Thanks in advance!


jQuery Tree View and wp_list_pages

I'm looking to use the jQuery TreeView script on wp_list_pages to get a nice collapsable-tree effect going. The script requires that I add some classes to the list elements such as:               <ul id="red" class="treeview-red">      So I tried putting this in my template: First, load scripts on my template page via wp_enqueue_script()               wp_enqueue_script("av_jquery_tree");     get_header();      Where "av_jquery_tree" is defined in a plugin:               function av_jquery_tree() {     wp_register_script('jquery.treeview', get_template_directory_uri() . '/js/jquery.treeview/jquery.treeview.js', array('jquery'), '1.0' );     wp_register_script('jquery.cookie', get_template_directory_uri() . '/js/jquery.treeview/jquery.cookie.js', array('jquery'), '1.0' );     wp_enqueue_script('jquery.treeview');     wp_enqueue_script('jquery.cookie');     }     add_action('wp_enqueue_scripts', 'av_jquery_tree');      Second, In order to add the class and id to the first ul element on the page, I just insert this script above the call to wp_list_pages:               <script>         jQuery(document).ready(function(){         jQuery("ul").first().attr("id", "red").addClass("treeview-red");         });     </script>      Unfortunately, my output is just a bunch of red lines across wp_list_pages. Also keep in mind that I'm using the Suffusion Theme, which preloads jquery.


Move one option value into another option

I have 2 existing options that I want to move into an existing 3rd option. What is the best way to go about this? Here's the scenario: I have 2 options in existance:               get_option( 'license_key' )     get_option( 'license_key_status' )      I also have another option set that already exists with data already in it:               get_option( 'my_theme' )      The my_theme option contains multidimension arrays:               $options = get_option( 'my_theme' );     $value = $options['key']['value']      I want to take license_key and license_key_status, move them into these 2 values:               $license = $options['key']['license']['license']     $status = $options['key']['license']['status']      Then delete license_key and license_key_status


Filtering the post list in the admin area

How can I filter my custom post type like it's filtered by WordPress itself? By that I mean the links that allow you to show only published, private or trashed posts. I need it because I want to filter my event post type in a way that you'll only see upcoming events at first, being still able to see all events. I came across this question but it would be a dropdown instead of these links. ![filters](http://i.stack.imgur.com/HRuUG.png) [edit] So what I want is to have a link `Past events` next to the `Published` link instead of using the standard dropdown menus. [edit2] I eventually did use a dropdown, based on this answer: http://wordpress.stackexchange.com/a/45447/28916


Custom Post Type Tags Showing Under Regular Post Tags

I have a CPT of Projects that uses the post_tag feature. My CPT tags are also showing up in my regular blog post area under Tags. I added a new "regular" post tag and it also showed up in the CPT Projects tag list. How do I keep these separate? I have CPT specific tag cloud being used on a page, so it can't show tags from regular posts. Thanks. Code is below:               function projects_register() {          register_post_type('projects', array(            'description' => 'Projects',         'show_ui' => true,         'menu_position' => 5,         'exclude_from_search' => false,         'labels' => array(             'name' => 'Projects',             'singular_name' => 'Projects',             'add_new' => 'Add Project',             'add_new_item' => 'Add New Project',             'edit' => 'Edit Project',             'edit_item' => 'Edit Project',             'new_item' => 'New Project',             'view' => 'View Project',             'view_item' => 'View Project',             'search_items' => 'Search Projects',             'not_found' => 'No Project found',             'not_found_in_trash' => 'No Project found in Trash',              ),         'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),         'public' => true,         'capability_type' => 'post',         'hierarchical' => false,         'rewrite' => true,         'rewrite' => array('slug' => 'projects', 'with_front' => true),         'taxonomies' => array('category', 'post_tag'),         'has_archive' => true         )      );          register_taxonomy( 'project', 'projects', array( 'hierarchical' => true, 'label' => 'Projects Categories', 'query_var' => true, 'rewrite' => true ) );            }          add_action('init', 'projects_register');


Making a Comment on a page without being on that page?

I have a built a Wordpress site that enables comments on pages and I am using them as _reviews_ , what I would like to do is for someone to be able to make a comment on a page without being on that page. http://universitycompare.com/university-guide/anglia-ruskin-university/ On the link above, the top right, there is a link that says **_have your say about a university_** , it would be good to have a HTML form and then a dropdown box of all the child pages of **university-guide** ; which is where all the universities are stored, and then I can put my comments.php file into this. So my HTML form appears and when a page is picked from a dropdown box, the comment will then be assigned to that page. Any help or direction? * * * New Question for Toscho: Below is your tweaked plugin to fit into my website, as you can see I have added the select option **yearSelect** and need this to appear when the comments appear. How would I go about doing this? - Could you provide ay help please?                   <?php     /* Plugin Name: haveyoursay */          /**      * Call the form in your template with:      * do_action( 'wpse_67527_comment_form' );      */     add_action( 'wpse_67527_comment_form', 'wpse_67527_comment_form' );          /**      * Create a review form.      *      * @return void      */     function wpse_67527_comment_form()     {         $select_id = 'page_select';         $url = 'http' . ( is_ssl() ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];         $url = esc_url( $url );         ?>     <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post">
Leave us your student perspective

             <?php _e( 'Name' ); ?>                 <input id="author" name="author" type="text" size="40" />

             <?php _e( 'Email' ); ?>                  <input id="email" name="email" type="text" size="40" />

             <label for="<?php echo $select_id; ?>">

                 Pick a university from the list:                             <?php             // Ordered by page name automatically             wp_dropdown_pages(                 array (                     'name' => 'comment_post_ID',                     'id'   => $select_id,                     'child_of' => 2,                 )             );             ?>

Please select your year of study:            <select name="yearSelect">         <option value="1st">First Year</option>         <option value="2nd">Second Year</option>         <option value="2nd">Third Year</option>         </select>

             <textarea name="comment" cols="45" rows="8"></textarea>

             <?php             wp_nonce_field( 'unfiltered-html-comment_' . get_the_ID(), '_wp_unfiltered_html_comment_disabled', FALSE );             ?>             <input type="hidden" name="redirect_to" value="<?php echo $url; ?>" />             <input type="submit" style="margin:15px 0px 0px 0px; padding:4px 10px;" />
     </form>         <?php     }          add_filter( 'comment_post_redirect', 'wpse_67527_redirect' );          /**      * Strip '#comment-number' from redirect url.      *      * @param  string $url      * @return string      */     function wpse_67527_redirect( $url )     {         $parts = explode( '#', $url );         return $parts[0];     }     ?>


Adding new tab to WordPress editor next to visual and text tab

Hi, The topic title says it all, I want to add another tab next to visual and text tab. So far I found this topic here: Add new tab next to Visual and Html in wordpress text editor? and this New editor tab on WordPress edit page But it doesn't help me much. Is there any other way to add another tab to default WordPress editor, instead of creating new one?


How to perform a search inside a specific taxonomy category

My problem is this: I have 3 **custom taxonomies** , let's say **'author'** , **'title'** and **'editor'** , each one applied to regular posts. Let's say I have post_1 that has in the 'author' field 'jorge borges' and post_2 that has 'ray bradbury'. I'm trying to have a search form with a drop down menu containing the three taxonomies and a text field, so that if I select, i.e., 'author' and search for 'jorge borges', the result will be post_1. The other two taxonomies should work like this as well. I couldn't find anything similar, as many questions concern the creation of a drop down menu with all instances of a taxonomy, which is not what I want. I want a drop down menu with taxonomy categories, not values. So how do I do that?


Pull random comment from specific post, display on homepage with shortcode

I'm trying to display a random comment from specific posts on my homepage, using the solution that was provided here: http://stackoverflow.com/questions/11790239/random-comments-on-page- wordpress/11790460#11790460 It works, but it pulls a random comment from a random post, instead of selecting the post I point at with the shortcode. Does anyone know how to fix this?               add_shortcode( 'randomComment', 'randomComment_handler' );          function randomComment_handler($post_id) {     extract( shortcode_atts( array(         'post_id' => '0',         ), $atts ) );     $out = "";     $comments = get_comments("post_id=$post_id&status=approve");     if ($comments) {         $ndx = mt_rand(0,sizeof($comments)) - 1;          $comment = $comments[$ndx];         $out = "

".$comment->comment_author."

".$comment->comment_content."

";     }     return $out;     }      and the shortcode:               [randomComment post_id="463"]


Change site template from php

What is the argument to pass to switch theme, when I have the result of `wp_get_themes()`?                $args = array(             'allowed' => true      );           $themes = wp_get_themes(  );           foreach ($themes as $theme) {                    $argument_to_pass_to_switch_theme = ??????           }


Returning or use form data using a hook?

I have built a plugin that allows a user to submit forms to a third party API via an API call. I'm wondering if it's possible to add in a hook right before (or after) the data gets sent to the third party, and return it for use in a function. Ideally, a user could define there own function and hook into the hook I have set, grab the data and use it how they please, or manipulate it before it gets sent off to the API.               if(!empty($p['form_data']))         {         parse_str($p['form_data'], $fd);         if(!empty($fd['list-id']))             {             // Create and store the variables needed to add a new subscriber                     $email  = false;             $lid  = empty($fd['list-id'];             $api  = 'api_key';             $mv = array();             $optin  = 'true';          // Add custom hook, to capture user submitted data     do_action( 'get_form_data', $p['form_data'] );             }         }      And then ideally the user could write a function to use the data (basic example).               function catch_user_data( $data ) {         $user_email = $data['email'];         update_user_meta( '1' , 'user_email', $user_email );     }     add_action( 'get_form_data' , 'catch_user_data' );      I'm sure I'm doing something wrong here as the data doesn't get updated on form submission. Is the hook written wrong?


Changing permalink of custom category

I've tried reading up on past posts here but my head is just spinning. My problem is I'd like to change my permalink structure for a custom full width posts under a custom category. For example, my permalink structure for posts is `example.com/04/2013/postname` and for my custom posts I'd like the permalink structure to be `example.com/categoryname/postname`. What's the easiest way to accomplish this?


How-To: wpdb Insert Record With Date

I am writing a plugin where I need to pre-load some data in the custom tables that I create upon Activation. My inserts have run fine thus far until I attempt to insert a record with a DATE datatype. Can someone please tell me what I have wrong here? Database Table Definition:               $sql =  "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix.SSM_ACADEMIC_YEAR_TABLE. " (                       id mediumint(12) NOT NULL AUTO_INCREMENT,                       academicyear VARCHAR(200) NOT NULL,                       begin_date date NOT NULL,                       end_date date NOT NULL,                       created_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,                     PRIMARY KEY (id));";              $wpdb->query($sql);      Database Insert:               $current_year = array(                 'academicyear' => '2012 - 2013',                 'begin_date'   => date('Y-m-d', '2012-08-14'),                 'end-date'     => date('Y-m-d', '2013-05-31')             );                  $wpdb->insert($wpdb->prefix.SSM_ACADEMIC_YEAR_TABLE, $current_year);      I have tried many different methods like just using => '2012-08-14' but that doesn't work either. I'm sure there's some syntax I am either missing or I have wrong.


Show User Their Password

I've got a few automated scripts that run to notify users of certain updates to the application, etc... and for one in particular, I need to be able to display the users `user_login` and their password. How do I show the user their password if it's encrypted?


How to remove this filter?

I can't remove a filter that added by media-tags plugin. it was originally added this way:               add_filter( 'attachment_fields_to_edit', 'mediatags_show_fields_to_edit', 11, 2 );      I tried to remove it this way:               remove_filter( 'attachment_fields_to_edit','mediatags_show_fields_to_edit', 11, 2 );      Where I did wrongly? How can I remove this filter?


How to group posts by months and add pagination?

I want to group by posts by months. Like this:   **January 2014**   Post name   Post name   **December 2013**   Post name   **November 2013**   Post name   Post name   Post name   Post name   I need to have 10 months per page, each month can have any number of posts. I use WordPress kriesi pagination to add pagination into the website.


Wordpress custom permalinks not working on OS X localhost

When changing premalinks, none of the pages and links are not working except home page :( ![enter image description here](http://i.stack.imgur.com/0X4gW.png) Result are shown below. Thanks in advance. ![enter image description here](http://i.stack.imgur.com/2Tw2h.png)


how to handle forms in multiple pages?

I have a simple contact form that I set up to display on multiple pages using a shortcode and a widget but since I need to form to post back on the same were it's displayed I'm not sure how to accomplish this. I was thinking about writing a function and plug it to the `wp_head` hook but I'm not sure if it's correct, is there a better way to do this? Thanks in advance.


Make a WP instance go to the 404 page of another WP instance

I have two Wordpress instances: One is in '/' The other one is in /commerce I would like that, when somebody goes to `/commerce/nonexistingpage` or some route that does not exist, the user gets redirected to the 404 page of the WP in /. How can I do that? Do I need to touch `.htaccess`?


Use [shortcode="value"] instead of [shortcode att="value"]?

With shortcodes that have only one attribute, it would be much easier from a content-editing perspective to use, for example, `[icon="myicon"]` instead of `[icon whichicon="myicon"]`. Is this possible in Wordpress? Is it problematic?


Can I change header.php of current theme through a plugin function?

I need to add some html into the header.php but instead of directly changing the header.php of my theme or creating a child theme, how can I do it with just actions and/or hooks?


How can I display the parts of custom posts?

I have a custom post type called Testimonial that includes custom fields "name", "title" and "bank". I would like to display each of these items on a page. Here's what I have so far:                   <?php         while ( $loop->have_posts() ) : $loop->the_post();           the_title();           echo '
';           the_content();           echo '
';         endwhile;         ?>      This gives me something close to what I want but I don't know how to get at the actual fields individually. How do I do that?


Hook/Filter before and after comments

I'm writing a plugin that needs to display a custom link immediately near the comments. I have the option in the plugin admin to display before or after. I'm familiar with the comments_array, but that doesn't allow me to just add a string of html just before the comments or just after the comments but before the comment form.               the_content     -- ?? custom link before ?? --     comments_array     -- ?? custom link after ?? --     comment_form


posts_nav_link on single post template

I have a post type called `journal` and on the `single-journal.php` template I am querying the rest of the `journal` posts like so:               <?php query_posts( array(          'posts_per_page' => 4,          'post_type' => 'journal',          'paged' => ( get_query_var('page') ? get_query_var('page') : 1 ),     ));     ?>      This works great but displaying the navigation: `<?php posts_nav_link(' ',' ','load more posts +'); ?>` is linking to `/journal/POST_TITLE_HERE/page/2` where I want to display `/journal/page/2` (as it shows on the `journal- archive.php` template), if this is at all possible? Any suggestions would be greatly appreciated!


How to update WordPress from the latest trunk

I read somewhere that I can set a constant in the wp-config.php to update WordPress from the latest trunk version and not the stable version. Stupid as I am, I can't find the site anymore where it was written. I know I could also update with SVN, but I thought the autoupdater was a smarter version.


How to get the average of the values from the comment meta

I used the _comment meta_ to add a simple **rating** system. The user can post a rate from the comment form from where I added 3 dropdown comment meta. The rating is working well, reflecting the ratings together with the comment written by the user. My only problem now is this: how can I get the average of all the ratings posted? I need the average to be placed on the post content. My rating system rates the following:   * Price,    * Packaging,    * Quality.  I want an average for each rate:   * Average Price Rate,    * Average Packaging Rate, and    * Average Quality Rate. Thank you so much!


Must-use plugins autoloader: How to use get_plugins() correctly?

My autoloader class is responsible for loading must-use plugins that do not sit in the root of the `mu-plugins` folder. To locate them, I need to use the `get_plugins()` function. According to Codex, the function accepts one parameter: > $plugin_folder (string) (optional): Relative path to single plugin folder. My file hierarchy looks like this:               |-- /mu-plugins     |   |-- autoload.php                    // only includes wpmu/autoload.php     |   |-- /wpmu     |   |   |-- autoload.php                // uses **get_plugins()** and autoloads other MU plugins     |   |-- /mu-plugin-to-autoload-A     |   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded     |   |-- /mu-plugin-to-autoload-B     |   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded      I thought I should go at it this way:               // array to store plugins     $plugins = [];     // get mu-plugin folders     $plugin_dirs = glob(WPMU_PLUGIN_DIR . '/*' , GLOB_ONLYDIR);     // loop through mu-plugin folders     foreach ($plugin_dirs as $plugin_dir) {         $plugins[] = get_plugins($plugin_dir);     }      However get_plugins() function returns an empty array. I want to achieve similar functionality as Sébastien Lavoie did in his Gist on GitHub. Its script should sit on the root of WPMU folder, as it uses `get_plugins('/../mu-plugins')`, which I do not understand at all (does it move back and forth to wpmu plugins folder?).               $plugins = array();     foreach (get_plugins('/../mu-plugins') as $plugin_file => $data) {         if (dirname($plugin_file) != '.') { // skip files directly at root             $plugins[] = $plugin_file;         }     }      Nevertheless, **it works** (as I've tested it). I hope all makes sense. :)


Conditional if statement ($post->ID == get_the_ID) not working

The following code should read: If the current custom post type (bbp_forum), is the one being displayed, assign the **class** 'current' to its respective `<li>` tag. But for some reason the class **'current'** (to highlight the current `bbp_forum` link) is being displayed in all the `<li>` tags: ![enter image description here](http://i.stack.imgur.com/G2NPf.png)               <body <?php body_class(); ?>>

<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?>

                     <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>

               <?php global $post; $cat_posts = get_posts('post_type=bbp_forum');               foreach($cat_posts as $post) : ?>                 <li <?php if($post->ID == get_the_ID()){ ?>class="current" <?php } ?>>                     <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
               <?php endforeach; ?>

      Any suggestions?


Can shortcodes contain conditional statements? Even without them my shortcode renders blank page

The following code is supposed to allow for a shortcode that includes many attributes, but not all of the attributes may always be present in which case I do not want the containing element to show anything. However, with or without the conditional statements, when I upload my functions file I receive only a blank page on the front and back end. Here is the full shortcode with conditional statements:               function info($atts, $content = null) {     extract(shortcode_atts(array(         "name" => '',         "image" => '',         "address" => '',         "phone" => '',         "email" => '',         "website" => '',         "description" => '',         "amenities" => ''     ), $atts));     return ''     if($image) { ''}'     '.$name.'     '     if($phone) { $phone }     if($address) { '• '.$address.' <img src="<?php bloginfo('template_directory'); ?>/_/images/mapmarker.png" width="16" height="16" alt="Map" />
'}     if($email) { 'Send Email' }     if($website) { 'Visit Website' }     if($description) { '
'.$description.'
' }     if($amenities) { '
'.$amenities.'
' }     '     ';     }          add_shortcode("info", "info");      Thanks for your suggestions!


Using WordPress as a document library

I would like to include a "resources" section in a new WordPress site I'm creating. I was looking for a document library plugin for WP, and amazingly, couldn't find anything that would work for the simple task of presenting a list of categories, and then displaying uploaded documents in those categories so they could be downloaded. I could make a resources list by hand, making all the document links myself. But isn't there a better way? You can't even add categories to media library items. I thought about making a blog post for each document, putting those in categories, and then putting a link to the document in the body. But that seems too complicated as well, and I would have to write a special display page myself. Anyone have advice about how to build a document library using WordPress?


Is there a way to visualize / print out which templates were used to render a given piece of UI?

Trying to customize Twenty Elevent theme it would be super useful for me as a beginner to see which templates rendered which pages / parts of the pages. Is there a plugin or manual way to achieve that? The easiest thing that comes to mind would be to add HTML comments to each and every template file but maybe some plugin / procedure automates this task already?


How to: get main plugin/theme file?

There're the functions `get_theme_data();` & `get_plugin_data();` - which both use `get_file_data();` that needs a specific file as `$input`. I got a set of classes that may be used by a plugin or a theme, without a specific location. Everything works, but I don't know how i would determine what the **main** plugin or theme file is - I mean the one containing the comment header that holds the information (Version, Author, etc.) about the Theme/Plugin.


Forum plugin with private forum option

I'm in need of a forum plugin for Wordpress that has an option for a private forum that is only accessible (both for reading and posting) to registered users. Restricted posting appears to be _de rigueur_ , but restricted viewing appears to be harder to find. Ideally, it'll integrate directly with Wordpress but if it needs to open in a separate window ( _a la_ BBPress) then that's fine. I've been looking around at different Wordpress forum options (such as BBPress and Mingle), but I can't see whether any support this feature. Does anyone know of a simple forum solution that offers this? Thanks.


Limit number of Widgets in Sidebars

If I use a custom widgetized area (for example footer) where there is only a limited number of spots for widgets (by design), can I limit the number of widgets the user may include in that specific widgetized area? It doesn't matter if the solution is at the backend or the front end. Thank you.


Transfer taxonomy to custom field

I have a blog with movie critics and I'm using many taxonomies to add some informations about the movies, like director, actors or it's year. Using taxonomies is really useful to display all movies made by the same director (example here). My only concern is with the release year taxonomy. I'd like to keep this information as a taxonomy, since I can, for instance, have a list of all movies released 10 years ago. I'd like to use this information to sort all other taxonomy archives, since it's almost always more interesting than other sort options. For now, I'm using the name of posts, but it can lead to strange behavior, like here, for the Iron Man saga where movies are not in the right order. If I could sort this list with year of release, it would be much more interesting. I understood WordPress doesn't want to add taxonomy orderby in queries, and I'd like tu duplicate this taxonomy and add a release date as custom field, since I can sort using a custom field. I made lot of searches and all I could find was the other way (converting a custom field to a taxonomy). Could you help me adding the date of every posts to a custom field ? I don't know if I should do it with a SQL query (if so, could you tell me what query I should use ?) or with PHP… Or even if I should do something entirely different to resolve my problem… Thanks for your help !


How to display custom type posts in 4-5 column grid layout in wordpress

I just want to display my custom post type named "Phones" (list of phones and tablets) in grid layout with 4 (or 5 columns). i only want post image (featured image) along with title. I have a custom page template called 'phones-thumbnail.php' that placed in theme folder but no clue whatsoever how to implement it to achieve the layout. Should i use 'get_template_part' in archive.php to call the custom template? I only want this multi-column grid layout for that specific post type. how cud I achieve this and what files would have to be edited. here is the archive page i am talking about. I am using wordpress version 3.5.1 and theme "made". thanks :)


Nonce check causing issues when creating new post

I have created a new custom post type and some custom fields for it. My function for saving the custom meta fields fires on the 'save_post' hook. The problem is that I am getting a warning when I go to add a new post: Notice: Undefined index: my_meta_box_nonce....                      // verify nonce         if ( ! wp_verify_nonce( $_POST[ 'my_meta_box_nonce' ], basename( __FILE__ ) ) )             return $post_id;       When I enter the post details and hit publish the error is not displayed, it's only there when I create a new empty post. What's wrong here? My code is almost identical and based on this tutorial: http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-1-intro-and- basic-fields/ In the comments of that tutorial it seems that there were others who had the same problem, but there is no solution given.


Advanced permalinks structure

I would like to get this:               mysite.com/category/tag/      example:               mysite.com/news/sports/      News is a CATEGORY and sports is a TAG How can I do it? Thanks.


How to add a credit line to a photo caption

I'm trying to find a way to automatically add a photographer credit line to user-inserted photos. I've added custom fields to the media uploader for 'Photographer Name' and 'Photographer URL' but I can't figure out a way to automatically insert the input from these fields into the caption field so that they will automatically display with the photo. Here's the code to generate the custom fields:               function attachment_field_credit( $form_fields, $post ) {     $form_fields['photographer-name'] = array(         'label' => 'Photographer Name',         'input' => 'text',         'value' => get_post_meta( $post->ID, 'photographer_name', true ),         'helps' => 'If provided, photo credit will be displayed',     );          $form_fields['photographer-url'] = array(         'label' => 'Photographer URL',         'input' => 'text',         'value' => get_post_meta( $post->ID, 'photographer_url', true ),         'helps' => 'Add Photographer URL',     );            return $form_fields;     }          add_filter( 'attachment_fields_to_edit', 'be_attachment_field_credit', 10, 2 );      Thanks for your help.


rewind_posts() - what actually the use of it, and where using is required or preferred?

The incomplete Codex about this, says very simply: > **rewind_posts():**   >  Rewind the loop posts. As per this WPSE thread, with Eugene Manuilov's answer, I got:               <?php     // fetch first post from the loop     the_post();          // get post type     $post_type = get_post_type();           // rewind the loop posts     rewind_posts();     ?>      With Ian Stewart's theme development tutorial, I found `rewind_posts()`'s use in `archive.php`, `category.php`, `tag.php`, `author.php`:               <?php the_post(); ?>     <!-- echo page title -->     <?php rewind_posts(); ?>     <?php while ( have_posts() ) : the_post(); ?>        <!-- echo content -->     <?php endwhile; ?>      But in TwentyThirteen theme we can't see something like this, but a simple WordPress loop with conditional:               <?php if ( have_posts() ) : ?>     <!-- echo page title -->     <?php while ( have_posts() ) : the_post(); ?>        <!-- echo content -->     <?php endwhile; ?>     <?php endif; ?>      So, I just want to know, while I have the WordPress loop to use, and that works with pagination also, then **where** do I need to REWIND THE LOOP, and **why**? ### EDIT Ok, after the first answer, I got a very good article describing the 3 Query- reset functions in WordPress: > » **3 Ways to Reset the WordPress Loop** by _Jeff Starr_ - DigWP.com I hope with this the answer can be a lot more educative than currently what we got.


Inserting post, thumnail and custom fields with wp_insert_post

I just want to add custom post, a thumbnail of it and custom fields.   Here is my code what I am try is to add post, thumbnail and one custom field. But I not getting the idea how to upload the thumbnail of this specific post. And also how retrieve this post.               $image_url = $_FILES['post_img']['name'];     $tags = $_POST['post_tags'];     $my_post = array(       //'post_mime_type' => $wp_filetype['type'],       'post_title'    => wp_strip_all_tags( $_POST['post_title'] ),       'post_content'  => $_POST['post_content'],       'post_status'   => 'publish',       'post_type'     => 'Custamize_post',       'tags_input'    => array('thread_tag' => $tags),       'post_author'   => $user_ID     );     $post_link = $_POST['post_link'];               add_post_meta($post_id, 'post_link', $post_link, true);       I see on some articles they use this code to upload the file.               $upload_dir = wp_upload_dir();     //$image_data = file_get_contents($image_url);     $filename = basename($image_url);     if(wp_mkdir_p($upload_dir['path']))         $file = $upload_dir['path'] . '/' . $filename;     else         $file = $upload_dir['basedir'] . '/' . $filename;     file_put_contents($file, $image_url);          $wp_filetype = wp_check_filetype($filename, null );     $attachment = array(         'post_mime_type' => $wp_filetype['type'],         'post_title' => 'Custamize_post',         'post_content' => '',         'post_status' => 'inherit'     );     $attach_id = wp_insert_attachment( $attachment, $file, $post_id );     require_once(ABSPATH . 'wp-admin/includes/image.php');     $attach_data = wp_generate_attachment_metadata( $attach_id, $file );     wp_update_attachment_metadata( $attach_id, $attach_data );          set_post_thumbnail( $post_id, $attach_id );      But my main concern here is how to connect the post, created above, to this attachment.


Pretty URLs for lost password functionality

I have WP installed in sub-directory and I'd like to have pretty URLs for the lost password functionality. So, something like this, from WP native -> pretty URL: Initial and any errors lost password page: `http://domain.com/sub-dir/wp-login.php?action=lostpassword` -> `http://domain.com/sub-dir/forgot-password` Success URL of the lost password page: `http://domain.com/sub-dir/wp-login.php?checkmail=confirm` -> `http://domain.com/sub-dir/forgot-password?checkmail=confirm` I've tried using the following code: a re-write rules and a filters. **The re-write rules:**               add_rewrite_rule( 'forgot-password?checkemail=confirm/?$', 'wp-login.php?checkemail=confirm', 'top' );     add_rewrite_rule( 'forgot-password/?$', 'wp-login.php?action=lostpassword', 'top' );      **The filters:**               add_filter( 'lostpassword_url', 'lostpass_url_fix');     function lostpass_url_fix( $link ){         return str_replace( '?action=lostpassword', '', str_replace( network_site_url('wp-login.php', 'login'), home_url( 'forgot-password', 'login'), $link ) );     }          add_filter( 'lostpassword_redirect', 'lostpassword_redirect_fix' );     function lostpassword_redirect_fix(){         return home_url( 'forgot-password?checkemail=confirm', 'login' );     }      However, that doesn't seem to work correctly. Whether it's a success or failure it's always redirected to `forgot-password?checkemail=confirm` without any error/success messages. I've noticed that WP native lost password behavior is the following: 1) **Success**. The URL is `wp-login.php?checkmail=confirm` that displays login form with message to check user's email for the login details. 2) **Failure**. The URL is `wp-login.php?action=lostpassword` that displays lost password page with the error message. In the `lostpassword_redirect` filter I don't think I can test for success or failure of the lost password function.. Any idea how it's possible to make URLs for the lost password functionality pretty? Many thanks, Dasha


How to show 5 posts from specific category on related page?

I'm not familiar enough with wordpress to ask the question directly, so please bare with me as I explain what I'm looking for. I have four primary sections of my business (A, B, C & D, for example).   * each section has it's own page   * each section also has a category with the same name   * various pages and posts are categorized under each section I want an area in the sidebar (probably a widget) to show N (probably ~5) summaries of items categorized as A on page A. And the same on pages B, C & D. Remembering that I am a Drupal developer who does not know the Wordpress landscape very well, how would I go about this? Is there a ready-built widget or am I looking at something custom?


How to extend customize control types to list pages

**I have:** I'm currently using `$wp_customize` to add options to the _customize theme_ area. **My Goal:** My goal is to extend `$wp_customize` so that I can display a list of available pages as checkboxes. I've been using Otto's tutorial, but it only covers text areas. I'm aware that there is a _dropdown-pages_ control type, but I'd like to be able to display the pages as a list of checkboxes, not a select element. So far I've managed the following:               add_action( 'customize_register', 'my_theme_customize_register' );          function my_theme_customize_register($wp_customize) {               // CREATE A CLASS FOR DISPLAYING PAGES AS OPTIONS         class Customize_Pages_Control extends WP_Customize_Control {             public $type = 'pages';             public function render_content() {                 $pages = get_pages(); ?>                 <?php echo esc_html( $this->label ); ?> <?php                 foreach ($pages as $page) { ?>                                              <input type="checkbox" value="<?php $page->ID ?>" data-customize-setting-link="<?php $page->ID ?>">                         <?php echo $page->post_title; ?>                      <?php                 }             }         }         // ADD SECTION         $wp_customize->add_section( 'home_page', array(              'title' => __( 'Home Page' ),              'priority' => 37,          ) );         // ADD SETTING & CONTROL         $wp_customize->add_setting( 'slideshow_pages' , array(             'capability'    => 'edit_theme_options',         ) );         $wp_customize->add_control( new Customize_Pages_Control ( $wp_customize, 'slideshow_pages', array(             'label' => __( 'Add pages to slideshow' ),             'section' => 'home_page',             'settings' => 'slideshow_pages',             'type' => 'pages',         ) ) );     }      This successfully adds the controls and lists the pages in the options menu, but I can't figure out how to actually save the changes once the user checks the boxes off. Likewise I can't currently use the any data that is saved (i.e. I can't check which pages have been selected within the theme itself.) Any help or pointers are greatly appreciated


admin-ajax.php loading many times

My site is running slow, because the file "admin-ajax.php" is loaded many times. see screenshot here: http://f.cl.ly/items/2b0O3Q0X27433X2F2j3U/Bildschirmfoto%202013-02-23%20um%2014.13.14.png Here the functions.php file: http://f.cl.ly/items/3e2D070u2M310W1J321K/Bildschirmfoto%202013-02-23%20um%2014.19.46.png How can i disable the file on the frontend and why is it loaded so many times?! Can i reduce it to only ONE time? Thanks!


do_shortcode & render custom field won't work

I am wondering why this code just won't work.. I am frustrated about it. It creates the tabs, but doesn't render the custom fields (types).               <?php         echo do_shortcode('[xt_tabs_button]'.'                   do_shortcode([xt_tab title="Informatie"] (types_render_field("informatie", array("output"=>"html"))); [/xt_tab]);             do_shortcode([xt_tab title="Spelregels"] (types_render_field("spelregels", array("output"=>"html"))); [/xt_tab]);              '.'[/xt_tabs_button]');     ?>      How can I make this code work?


Post content not showing some content

I'm inserting posts by wp_insert_post function. It works like first a post is created to get its id then an image is attached to that post id. I attach images by media sideload function. Here is the whole code module on which I'm working on :HERE . Initially post content is left blank.               $new_post = array(         'post_title' => $title,            'comment_status' => 'open',         'post_name' => $slug,         'post_content' => '',         'post_status' => 'draft',         'post_date' => date('Y-m-d H:i:s'),         'post_author' => 2,         'post_type' => 'post',         'post_category' => $cat_ids         );         $post_id = wp_insert_post($new_post);      When images is uploaded and attached after that I add a variable $content as below and update the post.               $content = $link[$i].'
'.'';          $link[$i] contains the original url of that image.      $src = wp_get_attachment_url( $img_id );      Everything works fine but problem is when I see the same post in the editor, it only shows as url of image. Rest is not displayed. I tried these:   1. Changed theme if css posing that problem. Result was same content was displayed as above url and no image tags in post editor.   2. I changed the code after `<br>`, as '1234 qwe asd zdc'. Resulted as `url1234 qwe asd zdc` `<br>` doesn't seem to work. There was no break.   3. Echoed direct `$content` variable without changing anything, on a blank `file.php`, displayed url and image correctly. How to resolve this thing? I have been trying this for whole day but no success. **UPDATE** : What I have found is probably, the post is updating but not taking new content in line 52 :here


Hard to find a good rewriting rule

I need to rewrite an adress for my WP site. I encounter difficulties, and I may need your kindfull help. In fact, in need to rewrite `www.sitename.com/?post_type=portfolio&portfolio- category=a-category&portfolio-tag=a-tag` into `www.sitename.com/my-search&your-category=a-category&your-tag=a-tag` How can I do this thanks to functions.php or .htaccess


Woo Commerce filter

I am modifying a job theme and having a problem with woo commerce plugin There are 3 products to purchase.   1. posting a job (options: 1job, 2 jobs, 5 jobs)   2. Able to read full resumes for 1 day (option: for 1 day, 7 days, 15 days)   3. Both of them (posting jobs and read resumes)      I have successfully done with setting options and making a payment. But the problem is how I could update these purchase options to user-meta and a custom table.      there is a meta-value called "_Total-amount-jobs" on user-meta. This is for how many jobs he/she can post. like total job amount you can post.   it looks like this _Total-amount-jobs 3 (that means you can post 3 jobs)      there is also a meta-value called "_Resume-expire-day" on user-meta as well. This is for until when he/she is able to read resumes.   the meta-key is date 2013-10-31 17:56:32 (that means you can read resumes by the day)      How can I update user-meta like this after completed payment OR after admin clicks completed button on order list?   it should be plus (+) for jobs amount. and it should be new date for resume expire day      I have found a hook for it. on docs.woothemes.com/document/hooks/ and "woocommerce_payment_complete" but I am not sure how to update. This is meta for puchased 5 jobs, 7days on wp_woocommerce_order_itemmeta                   280 36  _qty    1         281 36  _tax_class            282 36  _product_id 27911         283 36  _variation_id   28002         284 36  _line_subtotal  170         285 36  _line_total 170         286 36  _line_tax   0         287 36  _line_subtotal_tax  0         288 36  pa_job-posting  5-jobs         289 36  pa_view-resumes view-7-days              270 35  _qty    1         271 35  _tax_class            272 35  _product_id 27888         273 35  _variation_id   27961         274 35  _line_subtotal  300         275 35  _line_total 300         276 35  _line_tax   0         277 35  _line_subtotal_tax  0         278 35  Posting Amount  1         279 35  Location    Normal-listing      please give me a tip or sample source. Thanks


Get the Google+ and Twitter links - Wordpress SEO plugin

I want to use the Google+ and twitter links that can be added in User's profile using the WordPress SEO plugin and display them on the author page. Is there any way I can get those links from the plugin or do I need to fetch them using some other method say directly from database. SEO Plugin @the official repo


Custom-post-type-archive: posts sorted/filtered by year?

I have a custom-post-type `wr_event` whose posts are sorted by `meta_key` "event_date". Therefore I have this handy function …               function get_event_list( $latest = true, $order = 'ASC' ) {         echo '
';              $yesterday = time() - 24*60*60;         $compare = $latest ? '>' : '<';              $args = array(             'post_type' => 'wr_event',             'posts_per_page' => -1, // show all posts             'meta_key' => 'event_date',             'orderby' => 'meta_value_num',             'order' => $order,             'meta_value' => $yesterday,             'meta_compare' => $compare         );              $loop = new WP_Query( $args );         while ( $loop->have_posts() ) : $loop->the_post();             get_template_part( 'inc/event', 'item' );         endwhile;         wp_reset_postdata();         echo '
';     }      If I simply call ` all **"upcoming"** events are listed by their **ascending** event-date. In my event-archive however I call ` so all events that **have already taken place** are sorted by their **descending** date. **My question:** How can I insert the year number between the posts in the event-archive? _Right now I have this …_               - event 04-2012     - event 03-2012     - event 02-2012     - event 01-2012     - event 03-2011     - event 02-2011     - event 02-2011     - event 05-2010     - … and so on      _And what I want is this …_               2012     - event 04-2012     - event 03-2012     - event 02-2012     - event 01-2012          2011     - event 03-2011     - event 02-2011     - event 02-2011          2010     - event 05-2012     - … and so on      How could I insert the year number in between all events of a year? Any clever ideas on that? I really need to find some way of doing this?


how to add custom word press regisration form in word press 3.5 with out module

i want to add custom registration form in wordpress 3.5 ..with out module i tried few code samples in net seems to be not working with 3.5 properly


Geocoding an Exploded Custom Field Array

So, I'm having a little problem with crossing signals in WordPress between Google Maps' API and an exploded custom field. I want to be able to geocode an address that's been exploded from a custom field, formatted "name,address":               <?php     $trucks = get_post_meta($post->ID, "truck", false);     if ($trucks[0]=="") { ?>
No Trucks Operating Today
          <?php } else { ?>          <?php foreach($trucks as $truck) {     $truckdata = explode(',', $truck );     $name = $truckdata[0];     $location = $truckdata[1];     echo $name . ' is located at' . $location .'
'; ?>          <?php } ?>      This code will allow me to call each custom field, explode the value into its name and location into a separate value and echo them below. What I want to do next is map out each value into a Google Map. Here's the code I'm working with:
Google Map
       This is an example, but the code in question is the t, x, y, and h variables. I know I should be able to grab an address, pop it into a geocoder, and output a location for a marker. My question are: 1) how do I loop through my custom fields to grab the addresses inside of a javascript? Is there a way to grab the array with WP_Query (since it's only grabbing from one post) and use those variables in the javascript file? 2) how do I geocode the addresses and get them into the lat and lon positions in order to grab the correct coordinates for the markers 3) once I have the addresses geocoded, how can I get map markers placed that echo the sentiment below?


Is it safe to store a user setting you don't want the user to ever modify as a user option?

I have added some custom user options to the profile page on my site, and most are all OK for the user to modify themselves. These options live in their own section. The users have read access and are able to visit the backend and change some settings in their profiles. There is another per-user option that I do not want the user to ever be able to modify directly. I have the code that creates that option group and section check if the user can edit other users' profiles. If they cannot, the section and the setting are not registered with WordPress (and thus not displayed on the profile page). Only someone with the proper permission can visit to the edit profile page, view, and change the setting via the backend. Can a malicious user ever submit additional POST data with an otherwise valid profile update and set an option that wasn't registered on the page, but does exist in the database? How certain/solid is this protection? Are there any known problems with it?


Post content stays the same but permalink changes ?

This is really weird. I made a posttype ' mediagallery ' via the plugin Types fields. I simply want to load the post content and switch the posts with a next & prev button in de sidebar. The post content loads correct. But when i go to the next or prev post, the content stays the same. But only the permalink does changes. All posts are refering to the same post? This is the code example:               <?php     $args = array( 'posts_per_page' => 1, 'post_type' => 'Mediagallery' );     query_posts($args);     if ( have_posts() ) : while ( have_posts() ) : the_post();     ?>
<?php the_title(); ?>
     <?php echo  apply_filters( 'the_content'  ,  types_render_field('mediaid')); ?>               <?php endwhile; ?>      <?php else : ?> <?php endif; ?> <?php wp_reset_query(); ?>      When i change post_per_page to 2 they correctly show up both, so the post it there but it only shows one (the newest post), i tried different things But somehow i can only show the newest and all posts are loading that content ? i hope someone can help me, Greetz


Show errormessages on wrong username/password on custom loginform?

I use this simple HTML loginform in my sidebar. Does anyone have any clever way to make it show the errormessages when you type in wrong password or username?               <form action="<?php echo wp_login_url(get_permalink()); ?>" method="post">     <input type="text" name="log" id="log" style="width:92%; margin-bottom:3px;" value="Username" onfocus="if(this.value=='Username')this.value=''" onblur="if(this.value=='')this.value='Username'" />     <input type="password" name="pwd" id="pwd" style="width:92%; margin-bottom:3px;" value="Password" onfocus="if(this.value=='Password')this.value=''" onblur="if(this.value=='')this.value='Password'" />     <input type="submit" name="submit" class="button" value="Login" />     </form>


How can I change the publish date based on a custom field? Author uses a date picker to choose the date for journal entry. The date is used to make a list of all the users journal entries. I can order these posts in a list with a `query` and `orderby`. But, then Next and Previous don't match the list. I have read here, codex, and Google how to attempt to fix this, none have worked so far. Maybe the best way would be to set the publish date to the same as the custom field from the date picker? Does anyone know how this can be done?


How to show user's own post in a specific page

I created one page for posts and changed the default post page to that page in **Settings > Reading**. When registering for the site the default new user role is subscriber. The problem is after the login when I click on my `diaryview` page it shows all the posts of other users but I want to see only my posts in my `diaryview` post page. How can I see only my posts on this page?


Get moderation notifications on one post only

I'm running a web based community using wordpress multi-site and buddypress. All users are invited by existing users so no spam accounts exist on site. Therefore we feel no need to moderate logged in users. Since doing this we have found that from now on all moderation requests come from spam attempts. So I have turned off email notifications for moderation. One problem, I have a contact page that currently uses comments for non- members to send a message requesting an invite or otherwise get in contact. Is there any way I can switch moderation notifications on for just this page?


Pagination with custom SQL query

I have my own SQL string to select Custom Post Type posts with specific WHERE clause. I've used the offset and limit to return appropriate posts depending on a page being displayed. That's working fine. Now, I would like to make `previous_posts_link()` and `next_posts_link()` functions work. They both are called from `get_posts_nav_link` which uses `global $wp_query`. Is there a way I can re-assign `global $wp_query` with my SQL string or `$wpdb->get_results` results or anything else? So the native `previous_posts_link()` and `next_posts_link()` WP functions would work. If not, how can I reproduce the prev and next post link functions? I would really appreciate any help and advice! I'm totally stuck with this.   Thanks :) **NOTE:** I have just noticed that `previous_posts_link()` is working correctly on all the pages, but `no idea why` and in this case, why `next_posts_link` doesn't work :S Here is the code:               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $post_per_page = intval(get_query_var('posts_per_page'));     $offset = ($paged - 1)*$post_per_page;          $sql = "     SELECT SQL_CALC_FOUND_ROWS  wp_posts.*, wp_postmeta.*      FROM wp_posts      INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)     INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)      WHERE 1=1           AND wp_posts.post_type = 'movie'          AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')          AND ((wp_postmeta.meta_key = '_expiry_date' AND CAST(wp_postmeta.meta_value AS DATE) >= '".$current_date."')              OR (mt1.meta_key = '_expiry_date' AND CAST(mt1.meta_value AS CHAR) = ''))     GROUP BY wp_posts.ID      ORDER BY wp_posts.post_date DESC     LIMIT ".$offset.", ".$post_per_page;          $movies_all_current = $wpdb->get_results( $sql, OBJECT);          if($movies_all_current) {     global $post;          //loop     foreach( $movies_all_current as $key=>$post ) {         setup_postdata($post);         //display each post         //...     } //end foreach ?>              //navigation

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

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

     }


How are all users now set to inactive?

My client, while working on his WP blog yesterday, was doing some cleanup and claims he just removed an unused admin account. The next time he went to login, the login page rejected his account saying "Inactive Account". At this point, he calls me to let me know and I attempt to login as well - now my account says "Inactive Account". What can cause this and how can it be fixed?


custom page templating in WordPress

I'm in a situation where I need to face a situation when there is a WordPress site with landing page and several internal page designs. I know for such situations there is recommended to create more template files for pages with some comments at the beginning like `Template Name: Some Style` I've done this already, but the problem is that many of the internal pages contains boxes, areas that are independent from the main template. Let me show you: ![enter image description here](http://i.stack.imgur.com/BDhCK.jpg) So let's suppose we have the main article area and two other boxes. All the three areas have different design. First with some nice background, the bottom left article in a box with background and gradient stuff, the bottom right article is a box also with background and gradient with title and content inside. I was asked to solve the situation in a manner when the site admin (who don't know any piece of coding) wants to add another similar article with same structure, to be able to do this. Should I create one single template for this or three? What do you suggest? The idea when new article/page is added, to contain only the usual WordPress generated codes like h2, p, i, etc. So no manually added div's, classes and similar stuff. Did you faced similar situation? I searched the internet and did not found anything yet. I was thinking something about shortcodes but that will involde tu use codes like `[some]content...[/some]` or even to have children pages, but nothing is clear for me yet. What do you suggest for me? Thanks in advance! :)


Wordpress permalink from the database?

I am trying to access selected post information from my WordPress database to display on a second website which is not a WordPress site nor is it php, it is in fact an asp.net website that i want to display the information on. I have a WordPress blog at blog.domain.com and another website at domain.com both running on different servers and I need to display the excerpt, title with link on my asp.net website for selected posts. I can easily grab the excerpt and title from the blog's database but the only problem is that the permalink is not in the database. I had the idea that maybe if I place a short piece of code on every blog to insert the permalink to a new table, i could then grab that to use over on the other website. But that didnt work, perhaps I am not doing it right. This is the code I used and I placed this within the loop on the template file for the page I was testing on.               <?php        global $wpdb;        $table_name = $wpdb->prefix . "posts_pages_url";        $wpdb->insert($table_name , array('post_id' => get_the_ID(), 'url' => get_permalink()));      ?>      I would be very grateful if anyone had any suggestions on how I can access the permalink via a database call. Many thanks


If Statement Post Formats: No post format selected

I'm working with post formats, most of my code looks similar to this:               if ( has_post_format( 'standard' )) {       echo '<?php get_sidebar(); ?>';     }     if ( has_post_format( 'aside' )) {       echo 'this is an aside';     }     if ( has_post_format( 'chat' )) {       echo 'this is the video format';     }      But I also want one of the if statements to include how to call it if the user **did not** select a post format. Anybody know?


Include file in plugin file

I have a working plugin with many functions in it. I want to break the plugin into several file. I removed some functions and place it in a file called activate.php k7Course.php. Then in the file k7Couses.php i include as below:               /*     Plugin Name: k7 Course Management     Plugin URI: http://yourdomain.com/     Description: A plugin to manage k7 Courses Display     Version: 1.0     Author: Noor     Author URI: http://yourdomain.com     License: GPL     */          require_once('activate.php');      The problem is that the code in activate.php in being included but as raw text because i see all the content of activate.php in the admin menu. Also the function are not being executed


Permalinks Works for Custompost type but not with pages Why?

I have Three Custom post Types and one Custom Taxonomy and some pages. The Custom taxonomy is register with one of the post type. The problem is When the default Permalink is enable it works for all pages, custom post types and taxonomies. But when the "Post name" or any other permalink enable it breaks the pages structure, and the rest of links are working fine. After Register the post types and taxonomies i use flush_rewrite_rules() but its not working. Please help me in this situation.               add_action("after_setup_theme","rg_menus");      function rg_menus(){         register_nav_menus(array(                    'header'=> "Primary Menu",             'footer'=> "Footer Menu",             'header_menu'=>'Top Menu'         ));              add_theme_support("post-thumbnails");         add_image_size("home_header",1517,516,true);         add_image_size("page_headers",1517,259,true);              create_product();         create_product_category();              }     /*===============================*/      /* P-Riopel Product */       function create_product(){        register_post_type('priopel_products', array(    'label' => 'PRiopel Products','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => 'product'),'query_var' => true,'has_archive' => true,'exclude_from_search' => false,'supports' => array('title','editor','excerpt','trackbacks','custom-fields','thumbnail','author','page-attributes',),'taxonomies' => array('priopel_cat',),'labels' => array (       'name' => 'PRiopel Products',       'singular_name' => 'PRiopel Product',       'menu_name' => 'PRiopel Products',       'add_new' => 'Add Product',       'add_new_item' => 'Add New Product',       'edit' => 'Edit',       'edit_item' => 'Edit Product',       'new_item' => 'New Product',       'view' => 'View Product',       'view_item' => 'View Product',       'search_items' => 'Search Products',       'not_found' => 'No Products Found',       'not_found_in_trash' => 'No Products Found in Trash',       'parent' => 'Parent Product',     ),) );           }     /*===============================*/          /* P-Riopel Product Category */          function create_product_category(){         register_taxonomy('priopel_cat',           array ('priopel_products',                         ),array( 'hierarchical' => true,                                   'public' => true,                                    'label' => 'Categories',                                  'show_ui' => true,                                  'query_var' => true,                                  'rewrite' => array('slug' => '','with_front' => true,'hierarchical'=>true),                                  'singular_label' => 'Category') );                 }


retrieve theme custom settings

I have modified twentythirteen template adding custom settings for my theme. All settings appear in theme customization section and I am able to save them. I am using WP 3.6. How to retrieve those custom settings in my theme file?


Problem with Fix wrong serialize string in table options

when import data, the widget text is missing, and i find the problem is the serialize string is wrong, so i try to fix that string.                   $fixed = fixString($string);              $wpdb->update(            'wp_options',            array('option_value' => $fixed ),            array('option_id'    => 80) // Id of widget_text option         );      I try the above update query, but it does not work. But it works with                update_option('widget_text', unserialize($fixed ));      So what is wrong ? I need to check and fix all the serialize string in database, so i need to use run sql query


get_comments not working consistantly with post_id

I am trying to get comments from another post. I am getting the post_id and doing a check to see if it has comments I can get the comments for the current post every time but for the other post I am getting mixed results (I did get it working but am unable to reproduce the results) This is the code I'm working on with some alternate attempts commented out:               if(get_comments_number($getLangsPostID) > 0){         //echo "
This post id is ".$thisPostID." The other language post id is (".$getLangsPostID."):";         //var_dump($getLangsPostID);         $altLangReq = array(             'post_id' => $getLangsPostID // have tried with and without trailing comma         );              //$langComments = get_comments($altLangReq);         $langComments = get_comments('post_id='.$getLangsPostID);              echo "
Current post ($thisPostID), request for post id (".$getLangsPostID.") is:
";         var_dump($langComments);         //$x = get_comments('post_id=31'); // hard coded also fails         $x = get_comments(array('post_id'=>31));         var_dump($x);         echo "

";      If it matters I am using polylang and trying to show comments from all language alternatives on each languages post. I am using two posts (id 21 and 31) which have 3 or 4 comments each (these are getting found by get_comments_number. Also I am outside the comment loop on the comments.php template in slightly customised underscore theme. Edit: Some clarification, I wanted to describe most of the conditions incase there was some other factor but basically if I call:               var_dump(get_comments('post_id=21')); // 21 is the current post      I get the current posts comments, if I call:               var_dump(get_comments('post_id=31')); // 31 is a different post      I get an empty array, if I go to post 31, then 31 works and 21 returns an empty array but this seems to be the way to call posts other than the current one (via the post_id). See the first example in the WP codex Edit 2 Answer: (I am adding this for now as I am not able to answer my own question for 8 hours ATM) Turns out it was the language plugin... When I call the comments it adds a language filter:               'lang' => $currentLang      So I had to explicitly override that:               get_comments(array('post_id'=>31, 'lang' => $targetLang));      I still don't know why I was sometimes able to get the other comments without this.


Plugins not working on AJAX requests

I have an AJAX request that retrieves information from a function I coded in my own plugin, here is how I set the ajax function:               function my_ajax_function () {        do_action('my_plugin_function');     }          add_action('wp_ajax_do_ajax', 'my_ajax_function');      Complete file code at this link, will be temporarily available until we get a reply, I commented the line where the request fails, hope it helps: http://www.pokebeach.com/code.txt In the jQuery script I'm able to do the AJAX call but it is returning nothing and it seems that my plugin is not loaded when calling the functions via AJAX, also I know the functions work correctly because I use them in other places in the website where they return the proper data, is there any configuration or something to do with this, so the plugin works with the AJAX requests? Thanks!


Conditional tags to differentiate between profiles and activity with buddypress

I can't get any help on the buddypress forums so I'm going to ask it here. I'm trying to use conditional tags so I can have a different sidebar for the profile page than the activity page. For some reason the way I have it setup in my sidebar.php still returns the default. Any suggestions?               <?php      if (is_single()){       include(STYLESHEETPATH.'/sidebar-single.php');}      elseif (is_page()){       include(STYLESHEETPATH.'/sidebar-index.php');}      elseif (is_category('fame-game')){       include(STYLESHEETPATH.'/sidebar-fame-game.php');}      elseif (bp_is_user_profile()){       include(STYLESHEETPATH.'/sidebar-act.php');}      else {       include(STYLESHEETPATH.'/sidebar-index.php');}     ?>      Link to buddypress conditional statements codex http://codex.buddypress.org/developer-docs/conditional-template-tags/ SOLVED! See answer with comments below given by Boone Gorges. Here is the resolved code.               <?php      if (is_single()){      include(STYLESHEETPATH.'/sidebar-single.php');}      elseif (is_page() && !bp_is_profile_component()){      include(STYLESHEETPATH.'/sidebar-index.php');}      elseif (is_category('fame-game')){      include(STYLESHEETPATH.'/sidebar-fame-game.php');}      elseif (bp_is_profile_component()) {      include(STYLESHEETPATH.'/sidebar-act.php');}      else {      include(STYLESHEETPATH.'/sidebar-index.php');}     ?>


Using Orderby and meta_value_num to order numbers first then strings

I have a list of products, each with a price in a custom field stored as text such as "2.50" or "5.00" and I am displaying them on the page with a custom query that sorts by the price:                   if(!$wp_query) {             global $wp_query;         }              $args = array(             'meta_key' => 'price',             'orderby' => 'meta_value_num',             'order' => 'ASC'         );              query_posts( array_merge( $args , $wp_query->query ) );      This works fine for the prices, but some prices are "POA" and I would like to show them last, however the above orders in such a way that "POA" is shown first. Is there any way to alter this, or a quick hack I could use to sort the array afterwards and put any "POA" prices last?