AJAX function not working

One person on the site wrote a function, but I do not know why it works. This function displays a random quote. The functions implemented the ability to download new quotes via AJAX (link New Quote), and it just does not work. Help please understand why. I myself can not understand this. Sorry for my bad English. ## The PHP `/wp-content/themes/%your_theme%/js/ajax-load-quote.php`                <?php      /* uncomment the below, if you want to use native WP functions in this file */     // require_once('../../../../wp-load.php');           $array = file( $_POST['file_path'] ); // file path in $_POST, as from the js      $r = rand( 0, count($array) - 1 );           return '
' . $array[$r] . '
';      ?>      ## The jQuery `/wp-content/themes/%your_theme%/js/ajax-load-quote.js`               function ajaxQuote() {         var theQuote = jQuery.ajax({             type: 'POST',             url: ajaxParams.themeURI+'js/ajax-load-quote.php',             /* supplying the file path to the ajax loaded php as a $_POST variable */             data: { file_path: ajaxParams.filePath },             beforeSend: function() {                 ajaxLoadingScreen(true,'#randomquotes');             },             success: function(data) {                 jQuery('#randomquotes').find('p').remove();                 jQuery('#randomquotes').prepend(data);             },             complete: function() {                 ajaxLoadingScreen(false,'#randomquotes');             }         });         return theQuote;     }     /* Loading screen to be displayed during the process, optional */     function ajaxLoadingScreen(switchOn,element) {         /* show loading screen */         if (switchOn) {             jQuery(''+element).css({                 'position': 'relative'             });             var appendHTML = '

';             if( jQuery(''+element).children('.ajax-loading-screen').length === 0 ) {                 jQuery(''+element).append(appendHTML);             }             jQuery(''+element).children('.ajax-loading-screen').first().css({                 'display': 'block',                 'visibility': 'visible',                 'filter': 'alpha(opacity=100)',                 '-ms-filter': '"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"',                 'opacity': '1'             });         } else {             /* hide the loading screen */             jQuery(''+element).children('.ajax-loading-screen').css({                 'display': '',                 'visibility': '',                 'filter': '',                 '-ms-filter': '',                 'opacity': ''             });             jQuery(''+element).css({                 'position': ''             });         }     }     /* triggering the above via the click event */     jQuery('#newquotes').click( function() {         var theQuote = ajaxQuote();         return false;     });      ## functions.php `/wp-content/themes/%your_theme%/functions.php`               function random_quote( $atts ) {         /* extracts the value of shortcode argument path */         extract( shortcode_atts( array(             'path' => get_template_directory_uri() . '/quotes.txt' // default, if not set         ), $atts ) );         $array = file( $path );         $r = rand(0,count($array)-1);         $output = '
' .                 '
' . $array[rand(0,count($array)-1)] . '
' .             '
' .             'New Quote';              /* supplying the file path to the script */         wp_localize_script(            'ajax-quote',             'ajaxParams',             array( 'filePath' => $path, 'themeURI' => get_template_directory_uri() . '/' )         );         return $output;     }     add_shortcode( 'randomquotes', 'random_quote');     /* loads the js */     function wpse72974_load_scripts() {         if ( ! is_admin() ) {             wp_register_script(                'ajax-quote', get_template_directory_uri() . '/js/ajax-load-quote.js',                 array( 'jquery' ),                 '1.0',                 true             );             wp_enqueue_script( 'ajax-quote' );             /* supplying the theme URI to the script */             wp_localize_script(                 'ajax-quote',                 'ajaxParams',                  array( 'themeURI' => get_template_directory_uri() . '/' )             );         }     }     add_action ( 'init', 'wpse72974_load_scripts' );


How to include core files into plugin

I did some search about this but I don't realize which is the correct way to include a wordpress core file into a plugin. I wish to include the **wp-includes/ms-funcition.php** file. For example if I use include_once('../../../wp-includes/ms-functions.php') it wont load. Any suggestions? Thank you very much.


Hooking into the Meta Boxes (Name/Web Address/Description) on the 'Add New Link' Page

Is there a way to modify/adjust the meta boxes (Name/Web Address/Description) on the 'Add New Link' page? I'm trying to add some jQuery functionality to them but am unsure how to 'hook' into them.![enter image description here](http://i.stack.imgur.com/AicfO.png)


Searching custom fields with pre_get_posts

UPDATE: 12.4.13 I'm now using a posts_where filter. It looks like this:               function posts_where( $where ) {              if ( is_search() ) {             global $wpdb;                  $beds      = ( ! empty( $beds ) )  ? sanitize_text_field( get_query_var( 'beds' ) )  : 0;             $baths     = ( ! empty( $baths ) ) ? sanitize_text_field( get_query_var( 'baths' ) ) : 0;             $min       = sanitize_text_field( get_query_var( 'min-price' ) );             $max       = sanitize_text_field( get_query_var( 'max-price' ) );             $min_price = ( ! empty( $min ) )   ? sanitize_text_field( $min ) : 0;             $max_price = ( ! empty( $max ) )   ? sanitize_text_field( $max ) : 999999999;                  $where .= " AND ($wpdb->postmeta.meta_key = 'beds' AND $wpdb->postmeta.meta_value >= {$beds}) AND ($wpdb->postmeta.meta_key = 'baths' AND $wpdb->postmeta.meta_value >= {$baths}) AND ($wpdb->postmeta.meta_key = 'price' AND $wpdb->postmeta.meta_value BETWEEN {$min_price} AND {$max_price}) ";              }              return $where;     }      This is nearly working. The only piece that doesn't work is the price query. I'm not getting any effect no matter what I put in. Also, I'm now getting a database error that doesn't make any sense to me:               WordPress database error: [Unknown column 'tbg_postmeta.meta_key' in 'where clause']     SELECT SQL_CALC_FOUND_ROWS tbg_posts.ID FROM tbg_posts WHERE 1=1 AND (((tbg_posts.post_title LIKE '%441%') OR (tbg_posts.post_content LIKE '%441%'))) AND tbg_posts.post_type = 'property' AND (tbg_posts.post_status = 'publish' OR tbg_posts.post_status = 'private') AND (tbg_postmeta.meta_key = 'beds' AND tbg_postmeta.meta_value >= 0) AND (tbg_postmeta.meta_key = 'baths' AND tbg_postmeta.meta_value >= 0) AND (tbg_postmeta.meta_key = 'price' AND tbg_postmeta.meta_value BETWEEN 0 AND 999999999) ORDER BY tbg_posts.post_title LIKE '%441%' DESC, tbg_posts.post_date DESC LIMIT 0, 5      Any help is greatly appreciated. -Jacob I have a custom post type, Property, with a series of custom fields generated by Advanced Custom Fields. I'm attempting to build a search form that includes fields for some of the custom fields. Here's what the search form looks like:               <form method="get" action="<?php echo site_url('property/'); ?>">         <input type="text" name="s" value="" placeholder="Address, City, Zip, etc" />         <input class="half alpha" type="text" name="min-price" value="" placeholder="Min $" />         <input class="half" type="text" name="max-price" value="" placeholder="Max $" />         <select name="beds" id="beds" class="half alpha">             <option value="1">1</option>             <option value="2">2</option>             <option value="3">3</option>             <option value="4">4</option>             <option value="5">5</option>             <option value="6">6</option>             <option value="7">7</option>             <option value="8">8</option>         </select>         <select name="baths" id="baths" class="half">             <option value="1">1</option>             <option value="2">2</option>             <option value="3">3</option>             <option value="4">4</option>             <option value="5">5</option>             <option value="6">6</option>             <option value="7">7</option>             <option value="8">8</option>         </select>         <input type="hidden" name="post_type" value="property">         <button class="btn-search btn">Search <i class="icon-caret-right"></i></button>     </form>      which produces queries like this: http://example.com/?s=441&min- price=6000000&max-price=8000000&beds=1&baths=1 I'm using pre_get_posts to filter the search query like so:               function SearchFilter($query) {                  if ( is_admin() || ! $query->is_main_query() )             return;                if ( $query->is_search ) {                  // setup empty arrays             $beds_query  = array();                 $baths_query = array();                 $price_query = array();                  // setup query for beds             if ( ! empty( $query->query['beds'] ) ) {                 $beds_query = array(                         'key'     => 'beds',                         'value'   => sanitize_text_field($query->query['beds']),                         'compare' => '>=',                     );               }                  // setup query for baths             if ( ! empty( $query->query['baths'] ) ) {                     $baths_query = array(                         'key'     => 'baths',                         'value'   => sanitize_text_field($query->query['baths']),                         'compare' => '>=',                     );                 }                      if ( ! empty( $query->query['min-price'] ) || ! empty( $query->query['max-price'] ) ) {                     $min_price   = ( empty( $query->query['min-price'] ) ) ? 0 : $query->query['min-price'];                     $max_price   = ( empty( $query->query['max-price'] ) ) ? 999999999 : $query->query['max-price'];                     $price_query = array(                         'key'     => 'price',                         'value'   => array( sanitize_text_field($min_price), sanitize_text_field($max_price) ),                         //'type'    => 'numeric',                         'compare' => 'BETWEEN'                     );                 }                      $meta_query = array(                     'relation' => 'AND',                     $beds_query,                     $baths_query,                     $price_query                                 );                 $query->set( 'meta_query', $meta_query );                 $query->set( 'posts_per_page', 1 );                     } // end is_search and property archive                return $query;         }          add_filter('pre_get_posts','SearchFilter');      so far, so good. When I print out my $query, I get what I think is correct. Here's the relevant portion:               [meta_query] => Array                 (                     [relation] => AND                     [0] => Array                         (                             [key] => beds                             [value] => 1                             [compare] => >=                         )                          [1] => Array                         (                             [key] => baths                             [value] => 1                             [compare] => >=                         )                          [2] => Array                         (                             [key] => price                             [value] => Array                                 (                                     [0] => 6000000                                     [1] => 8000000                                 )                                  [compare] => BETWEEN                         )          )      What I'm not getting is a filtered search. I'm getting all posts based on the "s" variable, but no meta_query otherwise. Any ideas what I'm doing wrong? Thanks, Jacob


Filter posts by tax (dropdown) and meta value

I'm having a page on which all my custom post types are displayed. I now need to add another to the existing ones:               $args = array(         'post_type' => 'bkroadkill',         'post_status'    => 'publish, future',         'posts_per_page'    => '15'     );          if ( 'POST' == $_SERVER['REQUEST_METHOD']  && isset($_POST['filterform']) && wp_verify_nonce($_POST['filterform'],'filterform') )     {                    if (isset($_POST['own']) && !empty($_POST['own'])){                 $args['author'] = get_current_user_id();             }             if (isset($_POST['comments']) && !empty($_POST['comments'])){                 $args['orderby'] = 'comment_count' ;             }                }     query_posts( $args );      This is working perfeclty fine. What I want to do now is add these filters   * Filter by selecting one or more categories from `wp_dropdown_categories` of my custom taxonomy   * Filter by meta value which is already set For all of the filters except the category simple checkboxes are used. I just check if they are set and when they are I change my string. My attempts for the other 2 filters failed:                   if (isset($_POST['cat']) && !empty($_POST['cat'])){             $args['roadkill_category'] = $_POST['cat'];         }      As I am very new to wordpress even this simple stuff is confusing me **EDIT:** I was able to create the filter for my meta value now:               if (isset($_POST['bestimmung']) && !empty($_POST['bestimmung'])){                $args['meta_query'] = array(array(                                                 'key'     => 'bestimmung',                                                 'value'   => 'nein',                                                 'compare' => 'IS'                                             ));         }      So I'm just missing the filter for the custom taxonomy.


Dumping variable in custom pre_gets_post function in functions.php, returns NULL

## **Problem Summary:** I am using firePHP to analyze my variables in a custom function, but it does not display their contents into the console as I would expect. I also used var_dump(), it returns NULL. * * * ## Problem Details: I am using firePHP exactly as described by @brasofilo as seen on http://wordpress.stackexchange.com/a/71599/41479 . It is normally very helpful, but I am confused why sometimes I cannot see contents of my variables in the console. * * * Here is a specific example, this is in **page-sr2.php:**               <?php get_header(); ?>

                     <?php while ( have_posts() ) : the_post(); ?>                         <?php get_template_part( 'content', 'page' ); ?>                         <?php get_template_part('nav_menu', 'explore');?>                          <?php logit( $wp_query, '$wp_query:' ); ?> /*Logit function from @brasofilo*/                     <?php logit( $variable, '$variable: '); ?>                     <?php var_dump($variable); ?>/* This outputs NULL on the page*/                     <?php endwhile; // end of the loop. ?>
                 <?php// get_sidebar(); ?>

               <?php get_footer(); ?>
      * * * In **functions.php** I am using a custom pre_get_posts action:               add_action('pre_get_posts', 'page_sr2_pgp');          function page_sr2_pgp( $query )     {              if( is_page('sr2') ){             return $query;         }              //global $variable;   //tried this, didn't help         $variable ="something";         logit( $variable, '$variable: ');               if( isset($_GET['yr']) )         {                  $query->set('meta_key', 'yr');             $query->set('meta_value', $_GET['year']);              }                 // always return         return $query;          }      * * * The result is that `logit()` works for `$wp_query`, but not for `$variable`. ![Screenshot of console, page-sr2.php](http://i.stack.imgur.com/pNJqT.jpg) > **Note:** Yes I am calling `logit( $variable, '$variable: ');` in both > `page-sr2.php` and in the function `page_sr2_pgp` inside of `functions.php`. > I am doing that because I don't know which location is correct, and I didn't > believe it would cause a problem.


FTP access downloading files from live site to XAMPP sandbox

Where do I enter the IP address of my other live server so I can start my sandbox on XAMPP so I can start downloading the data file across. XAMPP just refers me to `C` drive, do I download the files separately or is there an option in XAMPP?


Handeling Multi-level custom taxonomy hierarchy

I am trying to sort through a multi level hierarchy in a custom taxonomy. I have custom taxonomy's with multiple sub taxonomy's. Eg:               Level1     -Level2     --Level3       ect At the moment I can use `get_term_children()` to return the children for a top level taxonomy but this doesn't tell me anything about there position in the hierarchy.


Prevent installation of style.css cookies and file caching

I'm having a problem which I have never encountered before. When I update my `style.css` file within my child theme, the webpage does not use the new style. I have pinpointed that to a cookie within my browser which seems to use `style.css?ver=3.8.1` instead of the basic `style.css`. Incidentally, 3.8.1 is my version of WordPress. The only fix I found is to manually delete the cookie, but it's a hassle to do whenever I make changes. Any ideas on how to fix ?


Moving Plugin Code into a Theme - Class Declaration - what hook should I use to create new instance?

I'm planning on moving a Plugin Inside a Theme I'm creating. The Plugin currently utilizes a Class to declare and set up the Custom Post Type and all of the other functionality of the plugin itself. The plugin both has a CPT that is populated in the Admin Dashboard and shortcodes that output data into the Theme. Since the plugin itself declares a new instance of the class, where should I move this declaration if I move the plugin code into the theme so that it only creates one instance of this class? Thanks!


What is the best way to move an entire multi-site Wordpress to a new domain?

I have a multi-site Wordpress 3.x instance set up with over 100 sites. I'm preparing to upgrade to version 3.7.x I want to allow my users to test what version 3.7 is going to look like ahead of time. They want to test to see if any plugins or their custom themes break after the upgrade. My production instance is running on mywordpress.mydomain.com. I have another server, mydevwordpress.mydomain.com that I could use to stage the upgrade. How can I do this best ? I could copy the code base from production to dev. Then I could use mysqldump to export the database and import into the other server. But what about all the links and base-site variables ? How would you accomplish this ?


Redirect if not logged in?

I've tried this to redirect people who aren't logged in to certain page. It ultimately shouldn't matter what front end page they visit, but should redirect to whatever page is chosen as the landing page (which I'm assuming would be the URL in the wp_redirect). I still need access to wp-login and dashboard etc... I placed the following code in my functions.php, but did not work.               function my_redirect() {            if ( $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] == 'mybigfatsite.com/' ) {         if ( ! is_user_logged_in() ) {            wp_redirect( 'mybigfatsite.com/landing/' );            exit;         }     }     }     add_action( 'init', 'my_redirect' );      Thanks for any help!


how could I get the pagination as I want to when query posts using get_posts function

I am using WP3.5, and I have a `post_list.php` which will show all the posts order by post date DESC. Everything is ok except `pagination`. I have 15 posts, for test purpose, I want to every page show 2 posts, others will be show next page like this.               Prev 1 2 3 4 5 Next      Some parts of post_list.php               define('WP_USE_THEMES', false);     require_once '../blog/wp-load.php';          $query_args = array(         'orderby' => 'date',         'order' => 'DESC',         'post_type' => 'post',         'post_status' => 'publish',         'posts_per_page' => 2,         'offset' => 0          );     $lateset_posts = get_posts($query_args);          <?php      global $post;     foreach($lateset_posts as $post) :         // do something         the_content();     <?php endforeach;?>          <?php next_post_link(); previous_post_link(); ?>      Yes, as you see, every page show 2 posts as I set, but I cannot get the pagination as I want to. Instead, it shows me like this               Post1's title >> << Post2's title      How could I get the pagination style like below               Prev 1 2 3 4 5 Next      Thanks. Edit: Now I use `paginate_links` function, yes, I got what I want.               $query_args = array(         'orderby' => 'date',         'order' => 'DESC',         'post_type' => 'post',         'post_status' => 'publish',         'posts_per_page' => 2,         'offset' => 0          );     $lateset_posts = get_posts($query_args);               $paging_args = array(         'base'         => '%_%',         'format'       => '?paged=%#%',         'total'        => count($lateset_posts),         'current'      => max(1, get_query_var('paged')),         'end_size'     => 1,         'mid_size'     => 1,         'prev_next'    => True,         'prev_text'    => __('« Previous'),         'next_text'    => __('Next »')     );     $lateset_posts_paging = paginate_links($paging_args);      I have 15 rows , and it shows like this                1 2 3 .. Next      Now I am in the first page, and I want to go to the second page, so I click the number 2, and I notic the url is :               http://localhost/x/post_list.php?paged=2      But after I click it ,it `still in the first page`, and the data is also the first two rows. Where is am I wrong , Thanks.


How to limit characters of the post title?

How do I limit the number of characters in a post title? I've seen it done in Yoast's Wordpress SEO plugin but I want to do something similar for the WP title. I checked out a plugin called Limit a post title to X characters but it seems like it's been abandoned and it also breaks the Edit Media page since the media too has a title.


How can 2 blogs share the same users

I have a running normal WP blog (blog 1). I want to create a Q&A section for my users, so I setup another blog with WP-Answer theme (blog 2). The problem is I don't want my users at blog 1 have to register at blog 2 to post questions. I want they automatically grant the same privileges at blog 2. How can this be achieved? Do you have any advice for me? Thank you very much.


How can I create a user generated photo wall

I'm looking for a way to create a user generated photo wall. Like a memorial site so to speak. I would have a big header image up top, than people could submit their own photo and it would post below the big header image I posted. Does anyone know of a way I can do this either with a plug in or a theme? Thanks!


Custom Post Type Pagination & duplicate posts

I'm working on a template which will use some custom-post-types & custom- taxonomies.. I'm having problems with pagination and duplicate posts. **HOME.PHP** LOOP #1 On the homepage (home.php) I have 2 Loops. The fist one shows 1 post (custom post type: Projects) which has the custom-taxonomy "Featured" assigned to it. LOOP #2 On the second loop I have the six most recent "Projects" (Custom post type) but I dont want a duplicate from the first loop. Under the six posts I'd like a pagination Both loops in home.php work.. but I still have that duplicate and I can't get pagination to work.. **PasteBin**   * home.php: http://pastebin.com/6ac2asue   * functions.php: http://pastebin.com/1SK206Bh              <?php $do_not_duplicate = array();     $folio_loop = new WP_Query( array         (             'featured' => 'featured-post',             'post_type' => 'projects',             'posts_per_page' => '1',             )         );               while ( $folio_loop->have_posts() ) : $folio_loop->the_post();         $do_not_duplicate[] = $post->ID; ?>

               <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >                          <?php                 global $post;                 $text = get_post_meta( $post->ID, '_cmb_project_meta', true );                 echo $text;             ?>
             <?php                 global $post;                 $text = get_post_meta( $post->ID, '_cmb_client_meta', true );                 echo $text;             ?>

                  <?php if ( has_post_thumbnail()) : ?>                 <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >                     <?php the_post_thumbnail('featured'); ?>                              <?php endif; ?>
          <?php endwhile; ?>


Can an update corrupt my installation?

Ive got a wp theme I use on a website - the theme in question was purchased from a popular site ending in forest... So the code is not mine and I can’t speak as for its quality either way. Every time a new version / update of WordPress comes out I update to it, but before I do I get a warning in my dashboard, saying that I should backup my site, as the update might corrupt the site. I’ve always backed up the site, using the export setting and also exported my theme settings. But what I was wondering is how necessary is this, as my host makes auto 24hr backups of the site both the files and mysql db. From those site backups would I be able to easily restore my site in the event of it becoming corrupted? Also out of interest I know its a bit of a vague question but how common is it to see a WordPress update corrupting a site ?


How to set featured image from a variable

I have an image displayed on my post via a variable {$poster}. How could I set this variable to a featured image? This is what I have in my post:


Custom post-type, multiple loops not displaying on page?

I have an issue with a loop within my page not displaying. The first loop I created (OUR SPONSORS) is displaying fine but the second (OUR PARTNERS) loop isn't displaying (confused!) Below is the site link. See the bottom where I have three sections. Partners, Judges and Sponsors. And you will see partners doesn't display. You can see the page here: http://chimpmarketing.com/testing/msa/?page_id=35 Any help would be much appreciated. Regards Gary


add bootstrap modal after login in wordpress

I'm trying to add a boostrap modal just after login in my website. I have my javascript:               jQuery(document).ready(function($){          $('#after_login_modal').modal();          });      I have my div:

                     <button type="button" class="close" data-dismiss="modal">×Close</button>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

                     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur purus metus, imperdiet id blandit sit amet,                     ornare et nisl. Nullam elit nunc, fermentum id diam eget, auctor ultricies urna. Ut sodales maximus sodales.                     Fusce lacus libero, blandit quis maximus ut, lacinia in velit. Maecenas ligula leo, cursus vel turpis id, fermentum venenatis purus.                     Donec eleifend nisl auctor ex ullamcorper semper. Pellentesque nec varius elit, sed mollis urna.                     Integer suscipit orci id sapien dapibus vulputate. Suspendisse mollis, est non condimentum vulputate, quam quam suscipit nunc,                     eu blandit nibh massa et augue. Curabitur ultrices pretium massa vel egestas.

      I have my action in functions.php:               function after_login_display_modal() {         //stuff     }     add_action('wp_login', 'after_login_display_modal');      But I need to integrate everything...and I'm a bit stuck... Ideal would be load div and javascript only just login.


How to use rewind_comments() - when and how to use it?

I've never messed with the comments loop before, but I'm trying something out here. Basically, I have my comments form in a popup iframe, an ajax action which handles the form submission, inserts the comment, and updates the list of comments. I'm having a problem running the comments loop a second time on the page, though. The comments form comes through fine, but the comments don't show on the Ajax refresh. `have_comments()` turns up false, and `wp_list_comments()` outputs nothing. Any ideas what's going wrong? Here's my Ajax handler, in case there's an issue in there:               /* Submit Comments Through AJAX */          add_action ( 'wp_ajax_submit_comment', 'ajax_insert_comment' );     add_action ( 'wp_ajax_nopriv_submit_comment', 'ajax_insert_comment' );          function ajax_insert_comment() {              /* obviously all of this needs sanitization,             its oversimplified, just to get the idea across */         $data = extract( wp_parse_args( $_POST ) );         $current_user = wp_get_current_user();         $comment = wp_insert_comment( array(             'user_id' => $current_user->ID,             'comment_author' => $current_user->display_name,             'comment_author_email' => $current_user->user_email,             'comment_post_ID' => intval( $comment_post_ID ),             'comment_parent' => intval( $comment_parent ),             'comment_content' => $comment,             'comment_type' => $comment_type             ) );              wp_reset_query();         global $post; $wp_the_query;              $post = get_post( $comment_post_ID );         setup_postdata( $post );              /* Here's the problem: How to rewind the comments query              so that it will actually display comments. I've tried              all of these things, but they're not working right now */         $wp_query->current_comment = -1;         $wp_query->rewind_comments();              // send comments list again.         include( get_stylesheet_directory(). '/comments.php' );              die(0);         }      The callback just takes the Ajax reponse and updates the comments div with the result. But its missing the whole comment list. Any ideas what I need to call to rewind the comments loop and make it actually display?


How make modular WP plugin based on OOP?

For example I have _"my-plugin"_ plugin created using class:               class My_Plugin {              public function __construct() {              }         /**          * Other code where I creating plugins admin pagec etc.          */     }     new My_Plugin();      So basically functionality is simple - it creates its option pages in admin. But I want to extend it. For example: one module for adding filter to `the_content` and second module for adding filter to `the_title`. Yes, it is simple may be used in one plugin but this is just for example to understand how to make modular plugin using OOP. So most idea is - user may download only needed part/module of plugin. So if he need only filtering title then he loading `The_Title` module. So question is - how to develop this plugin modules using OOP in WordPress? Maybe code classes that extend main class or additional classes for every module? If so, please, provide me some examples.


Mobile version redirects to a whole different website?

I have everything set up fine on my desktop/laptop version of the site, but anybody that types my site in on their mobile phone gets redirected to another site that belongs to the same hosting. Is there a way to fix this?


Featured image and Media Grid

I am trying to get an image in Media Grid's lightbox to another page. I have the images set up in the media grid plugin and when you click on the image it opens a lightbox with a larger version of the image. At the bottom of the lightbox modal there are links to social and then a link that I added that is just text that says "request info" when the user clicks the request info they are taken to a page with a form (I'm using contact form 7) and there is a field that populates with that image title. What I also want to do is grab that image and have it show up next to the request form. The image variable is $mg_id which shows up in the address bar when you click the original image. The code I'm using to get the title is:
     <?php      global $post;     echo 'Request Info'; ?>
      then there is some shortcode that you put into the contact form 7 admin. I just want to know how to grab the image from the previous page and have it show on the info page. Like I said I can see the $mg_id variable when the lightbox is open I just want to know how to get it to the other page. Thank you


custom sort posts in archive/taxanomy page

I want to override the default sort order of posts in archive and taxonomy pages. what hooks should I implement?


Meta box values are displayed on Custom Fields list. Is it possible to hide them?

I have multiple meta boxes for my Custom Post Type posts. I want my users to add new fields using Custom Fields. The problem is - Custom Fields display all the garbage from my metaboxes and it might be very confusing for users. Here's a screenshot, the two first fields were added by an user and the rest comes from the theme itself (there are metaboxes above this "Custom Fields" box which use / reset these fields on post save). How do I hide them? ![](http://i.stack.imgur.com/mSQbJ.png)


Replace .wordpress.com url with a domain name

I purchased a domain and set redirection to my WordPress blog. If some user shares any of my posts to Facebook it shows the URL example.wordpress.com instead of example.com. What changes should I make to see my original URL (www.example.com) in the Facebook shares?


Custom Module, Extending WP with a Plugin?

I'm trying to determine the best way to expand on WP. I love the base of WP for a website... it has pretty much everything needed for a website. But now and again I need to be able to create some custom "pages" or small apps within the WP framework. For example, I've created a small app within a sub-directory of my WP install (/cart) for a purchase form. I'm including the WP head for access to the WP methods, but I don't feel that this is the most effective way of extending WP. I've also looked into integrating other PHP frameworks like CodeIgniter and Yii ... again, I'm not sure this is the best approach. Is there a way to create a WP plugin that has it's own "directory" or path? http://mywpinstall.com/customapp/ WP has so many great things going for it, that I'd love to be able to expand on it without touching the core. Thanks in advance.


Collect posts from last 48 hours

I want to create a custom rss feed               <?php     /*     Template Name: Custom Feed     */          function filter_where($where = '') {         //posts in the last 30 days         $where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'";         return $where;       }     add_filter('posts_where', 'filter_where');         $args=array(           'post_type' => 'post',           'post_status' => 'publish',           'showposts' => -1,           'caller_get_posts'=> 1           );     $my_query=new WP_Query($args);     remove_filter('posts_where', 'filter_where');     header("Content-Type: application/rss+xml; charset=UTF-8");     echo '<?xml version="1.0"?>';     ?><rss version="2.0">     <channel>       <title>Something</title>       <link>#</link>       <description>The latest blog posts from #</description>       <language>en-us</language>     <?       if( $my_query->have_posts() ) {         while ($my_query->have_posts()) : $my_query->the_post(); ?>           <item>         <title><?php the_title(); ?></title>         <link><?php the_permalink() ?></link>       </item>          <?php         endwhile;       } //if ($my_query)?>     </channel>     </rss>     <?PHP wp_reset_query(); //just in case     ?>      Now the final code for Custom Rss feed fetch from 48 hours. I can get right results from it. Thanks for your help. Mohammad Umer


How to add defer="defer" tag in plugin javascripts?

I couldn't add defer tag in plugin javascripts. Google developer pagespeed test suggests me to add defer tag in **contact form 7** javascripts. This is how contact form 7 includes javascript in header.               add_action( 'wp_enqueue_scripts', 'wpcf7_enqueue_scripts' );          function wpcf7_enqueue_scripts() {         // jquery.form.js originally bundled with WordPress is out of date and deprecated         // so we need to deregister it and re-register the latest one         wp_deregister_script( 'jquery-form' );         wp_register_script( 'jquery-form', wpcf7_plugin_url( 'jquery.form.js' ),             array( 'jquery' ), '2.52', true );              $in_footer = true;         if ( 'header' === WPCF7_LOAD_JS )             $in_footer = false;              wp_enqueue_script( 'contact-form-7', wpcf7_plugin_url( 'scripts.js' ),             array( 'jquery', 'jquery-form' ), WPCF7_VERSION, $in_footer );              do_action( 'wpcf7_enqueue_scripts' );     }      Now how to add **defer="defer"** tag in the above code?


Mapping multiple URLs to same page

I just came across this page with almost similar requirements as mine Multiple endpoints to same page i have to achieve same functionality but i also want to pass some parameters to the page where all these URL will be map. say example               http://mysite.com/test/link1     http://mysite.com/test/link2      http://mysite.com/test/link3       i want to map them to same URL               http://mysite.com/test/finalDestination      along with it i also want to send some other parameters like   1. user email   2. user name so that i can use them at that page for my custom logic.i know how to do it in JSP/Java where i can send them as a request parameters in POST request and can reterieve them in the final JSP how i can achieve this is wordpress using php.my prefrences are not to use any query string. Or is it possible like if i create URL with like               http://mysite.com/test/user1     http://mysite.com/test/user2      http://mysite.com/test/user3      where user1 etc can be fetched from the database and we can ensure that they will be unique through the application and mapping these URLs to same end point. how can i fetch the username in my final page? Thanks in advance


Home Custom Menu Link not Working

I'm trying to have the menu link per default when using my custom menus, and in my `functions.php` document I have this:               function home_page_menu_args( $args ) {         $args['show_home'] = true;         return $args;     }     add_filter( 'wp_page_menu_args', 'home_page_menu_args' );      The thing is, in the custom menu options > pages I have this: "No items." So not sure what's going on, it was working in other websites but not in this one, any idea?


Add body class of category parent

I am not a coder, but I usually get by with Wordpress by doing my research and find my solution. I can't find what I need to do this time so I have attempted to crib together some code - what I am attempting to do is, when I am on the Category Archive, I want to add a body class of the category parent. This is what I have tried and it is working apart from I am getting the parents category ID, but I want the slug/nicename:               add_filter('body_class','hw_custom_body_class');       function hw_custom_body_class($classes){       if(is_category()){       $categories = get_the_category();       $category = strtolower($categories[0]->category_parent);       $classes[]='category-'.$category;       return $classes;    }}


Removing short versions of category archive URL

I'm looking after a site where someone has configured /%category%/%postname% as the Permalink structure. A side-effect of this seems to be that a category archive will appear both at the usual /category/foo and also /foo. One downside of this is that it creates a duplicate page. Another is that any "Older posts" link on that second page won't work, since it will point to /foo/page/2 which will return a 404. Is there any way to _disable_ the /foo version of the page without changing the Permalink structure?


Copying post thumbnail to custom field

I've just moved to another theme, and it uses the custom field `bigimage` for associating an image with a post, instead of using WordPress's post thumbnails. How do I copy the URLs of all existing post-thumnails to their corresponding post's `bigimage` custom field? Could we possibly write a bunch of MySQL statements to achieve this?


CAPTCHA plugin where I can use my own images and ask my own questions?

Just wondering if any of you have run across this kind of plugin. Basically I'd like to be able to (a) specify my own image; (b) specify my own challenge question; (c) specify my own answer. As in: (a) an image of the word "orange" written in Old English (b) "Type the word you see in the picture" (c) the answer is "orange" Does such a plugin exist? Thanks!


Category listing with thumbnail and description on home page

I really need a comprehensive solution to this, so I'm offering up almost a quarter of my rep in bounty :) I would like to have a plugin that creates a custom category listing on my home page. To do this, I'd like the "Category Edit" screen to be augmented with some additional functions as described below...   * Adds "Upload/Delete Image" handler to the Category Edit Screen for a Given Category (this allows the end user to upload an image that will be used to represent the category. Ideally, it should automatically be resized to 125 pixels wide by the plugin when uploaded.   * Adds "Category Title" input field to the Category Edit Screen for a Given Category. This is in addition to the existing default "Name" field.   * Adds a checkbox titled "Show on homepage listing" to allow selective display of each category on the home page listing.   * When the home page is viewed, the plugin appends the_content with the custom category listing, including each category's custom thumbnail and title. The resulting markup should be an unordered list with no nesting, like so...

                          Category 1 Title The category description text goes here

                          Category 2 Title The category description text goes here
         etc...
      Here's a stub file I've started...               add_filter( 'the_content', 'cb_category_listing' );          function cb_category_listing( $content )     {         if ( is_home() ) {             $cat_args['title_li'] = '';             $cat_args['exclude_tree'] = 1;             $cat_args['exclude'] = 1;             $myContent = wp_list_categories(apply_filters('widget_categories_args', $cat_args));              $content .= $myContent;         }         return $content;     }


raw code vs wordpress

I am currently a CS student and an aspiring programmer/web developer. I am wondering whether it is worth taking the time to master html and css to make websites when CMS services/wysiwyg like wordpress and various others seem to be becoming more and more functional. **Does anyone think these publishing services might eventually make the need to design websites from raw code unnecessary? If not, please explain why.** If designing a website eventually becomes as simple as using Photoshop I would much rather invest my time in programming languages.


Remove the theme info from main dashboard screen- not appearance

I've successfully used the code from the post: Restrict ADMIN menu items based on username, replace username with an actual user's name. The problem is the theme still shows on the main dashboard and by clicking on the theme name the admin is taken to the appearance menu which had been hidden by using the code. Any thoughts how to get around this? Here is the code from the post mentioned:               function remove_menus()     {     global $menu;     global $current_user;     get_currentuserinfo();          if($current_user->user_login == 'clients-username')     {         $restricted = array(__('Posts'),                             __('Media'),                             __('Links'),                             __('Pages'),                             __('Comments'),                             __('Appearance'),                             __('Plugins'),                             __('Users'),                             __('Tools'),                             __('Settings')         );         end ($menu);         while (prev($menu)){             $value = explode(' ',$menu[key($menu)][0]);             if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}         }// end while          }// end if     }     add_action('admin_menu', 'remove_menus');


Form to Add Posts to Custom Post Type (Again)

I pretty much got my answer in my last question, but not quite. I was supposed to add one last code to my source and it would have worked but the person helping hasn't replied now and I don't know what to do :S Form to Add Posts to Custom Post Type So can anybody tell me where to put `wp_redirect(get_permalink($pid)); exit;` in my code to have it redirect to the post after the post is added to the database?


Get custom post_type's archive URL

It seems like stupid question. But, I can't figure it out :(. I need to display button at home that goes to custom post_type's archive URL (archive-{post_type}.php). How do I do that?


Back End Interface Plugin

The Back-end of Wordpress is nice, but I would like to customize the UI to some degree. My goal is to make the user experience REALLY simple for untrained users. I suspect plugins exist for this, but I thought I would ask the experts of Stack Exchange, before chasing any ideas down potentially deep rabbit holes. So, what is the preferred method of UI customization in wordpress?


Edit / delete custom post types through web page (not admin)

I want it to be possible for the users to edit and delete their own posts, not only through the admin panel as it is by default. I've look around on the net but haven't found any information about it. How can this be done?


changing permalink for custom template in posts of a certain category

I've created a unique single post template to give people the option of reading all posts of a certain category using the awesome "reveal.js" which they access via this link               presentation      The problem is the ugly URLs, which end up looking like               website.com/post-name/?show=presentation     website.com/completely-different-post-name/?show=presentation      I would like them to look like               website.com/post-name/presentation/     website.com/completely-different-post-name/presentation/      I've spent the last 10 or so hours trying to figure this out (I haven't even gone to sleep yet, lol); unfortunately, nothing has worked. Is there a way to do this? As a side note, the site I'm trying to do this on is installed in a subdirectory (localhost/wp) but I'm developing this for my actual website which is installed in a top level directory


Add page as static html into another page

Is there a way to include a wordpress Page into another one? I'm not just talking about getting the content using get_page(), but to import the whole page (theme + content). I have been looking around for hours for a way to achieve this but I can't find a way, I guess it's a pretty unusual thing to try to do, but it's necessary for what I want to do with my site. What I want to achieve is this: Page1 uses this template:               <?php     /*     Template Name: page-template1     */     ?>
      <?php if (have_posts()) : while (have_posts()) : the_post();?>
      <h2 id="post-<?php the_ID(); ?>"><?php the_title();?>

       <?php the_content('
Read the rest of this page »
'); ?>

      <?php endwhile; endif; ?>

     Hello     import_page("page2");
      Page2 uses this template:               <?php     /*     Template Name: page-template2     */     ?>
     World
      <?php if (have_posts()) : while (have_posts()) : the_post();?>
      <h2 id="post-<?php the_ID(); ?>"><?php the_title();?>

       <?php the_content('
Read the rest of this page »
'); ?>

      <?php endwhile; endif; ?>

      Result:
     World
      <?php if (have_posts()) : while (have_posts()) : the_post();?>
      <h2 id="post-<?php the_ID(); ?>"><?php the_title();?>

       <?php the_content('
Read the rest of this page »
'); ?>

      <?php endwhile; endif; ?>

     Hello
     World
      <?php if (have_posts()) : while (have_posts()) : the_post();?>
      <h2 id="post-<?php the_ID(); ?>"><?php the_title();?>

       <?php the_content('
Read the rest of this page »
'); ?>

      <?php endwhile; endif; ?>


What's the difference between post thumbnails and featured images (if any)?

On the Codex on Post Thumbnails, I see: > Post Thumbnails is a theme feature introduced with Version 2.9. It was > quickly changed to Featured Images with Version 3.0. Post Thumbnail, now > Featured Image, is an image that is chosen as the representative image for > Posts, Pages or Custom Post Types. On the changelog for Version 3.0: > Change Media UI labels from "Post Thumbnails" to "Featured Image" Is there any difference in behaviour of post thumbnails and featured images, or was in 3.0 only the name changed? Why did the name change? It is a source of misunderstanding, as the image size is still called `thumbnail` or `thumb`, while it on the UI everywhere says Featured Image.


Valid characters for actions, hooks and filters

I haven't ever seen a tag such as `do_action('something_10')`. Is it invalid if I use numbers? If the method is valid, how can I write different numbers in the tag string conditionally? For example, is the following code correct($grade is the number)?               do_action("new_grade_$grade")


Export specific menu

How can I export a specific menu out of wordpress? I have a list with many URLs and I need to copy it to multiple sites. But I don't want to do it manually.


is_user_logged_in returning nothing on custom page

I am trying to use WordPress authentication on a custom PHP page however when checking "is_user_logged_in" it returns nothing at all and other functions are also returning nothing helpful. The code I am using is:               require $_SERVER['DOCUMENT_ROOT'] . "/wp-load.php";     require $_SERVER['DOCUMENT_ROOT'] . "/wp-blog-header.php";     print_r(is_user_logged_in());      I have logged into the admin area prior to testing this. When being logged in or logged out the function still doesn't return anything and there are no PHP errors.


Move site to new server causes 500 Server error

I am moving my WordPress site from my old hosting company to the new one. I am at the current version, 3.5.1. I created the domain on the new site copying over all the files inclusive of any hidden ones, at least to my knowledge, and placed it on the new server. I made sure that the system has PHP5. For the time being, wp-config.php points to the old server for the database. I did copy the database over, but for the time being, as said, the database points to the old site. The problem that I have is that going to the new site causes a 500 server error. How do I find out what the problem is and how to fix the problem? Here is the complete text of the error:               Internal Server Error     The server encountered an internal error or misconfiguration and was unable to complete your request.     Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.          More information about this error may be available in the server error log.


Wordpress Gallery shortcode: Display one category ID only

Good Day. I am using a Gallery shortcode in my wordpress site to display images. Problem is that I wasnt the gallery to show only images from a certain category, for example category id 35. How do I specify it in the shortcode? Shortcode:                [custom_gallery style="1" source="**cat=%cat_id%**" link="image" description="0" size="200x200" limit="10"]      Now I have tried the following, but does not work -               cat=%35%     cat=%cat_id=35%      Any suggestions? Thank you SHORTCODE code:               /**      * Gallery posts shortcode      */          function gallery_posts_func($atts, $content = null) {         extract(shortcode_atts(array(             "limit" => '5',             "cat" => '',             "thumb_width" => '',             "thumb_height" => '',         ), $atts));         global $wp_query,$paged,$post;         $temp = $wp_query;         $wp_query= null;         $wp_query = new WP_Query();              $query .= '&posts_per_page='.$limit;         $query .= '&post_type=gallery';         $query .= '&taxonomy=gallery_cat';         $query .= '&gallery_cat='.$cat;              $wp_query->query($query);         ob_start();         ?>         <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
     <?php                          $gogo_gallery_video_url = get_post_meta($post->ID, 'gogo_gallery_video_url', true);                     $gogo_gallery_links_to = get_post_meta($post->ID, 'gogo_gallery_links_to', true);                     $gogo_gallery_title_links_to = get_post_meta($post->ID, 'gogo_gallery_title_links_to', true);                     $gogo_gallery_custom_link = get_post_meta($post->ID, 'gogo_gallery_custom_link', true);                          if ($gogo_gallery_title && $gogo_gallery_video_url && $gogo_gallery_title_links_to=="gallery_title_links_image") {                     echo '
';                         echo '';                     echo ''.get_the_title().'';                     echo '';                     echo '
';                          } elseif ($gogo_gallery_title && $gogo_gallery_title_links_to=="gallery_title_links_image") {                     echo '
';                         echo '';                     echo ''.get_the_title().'';                     echo '';                     echo '
';                          } elseif ($gogo_gallery_title && $gogo_gallery_title_links_to=="gallery_title_links_content") {                     echo '
';                         echo '';                     echo ''.get_the_title().'';                     echo '';                     echo '
';                          } elseif ($gogo_gallery_title && $gogo_gallery_title_links_to=="gallery_title_links_link") {                     echo '
';                         echo '';                     echo ''.get_the_title().'';                     echo '';                     echo '
';                          } elseif ($gogo_gallery_title) {                     echo '
';                         echo ''.get_the_title().'';                     echo '
';                          } else {                     echo '';                     }             ?>

             <?php if (has_post_thumbnail()) { ?>                 <?php                     $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');                          if ($gogo_gallery_video_url && $gogo_gallery_links_to=="gallery_links_image") {                      echo '';                     echo '';                     echo '';                          } elseif ($gogo_gallery_links_to=="gallery_links_image") {                     echo '';                     echo '';                     echo '';                          } elseif ($gogo_gallery_links_to=="gallery_links_content") {                     echo '';                     echo '';                     echo '';                          } elseif ($gogo_gallery_links_to=="gallery_links_link") {                     echo '';                     echo '';                     echo '';                          } else {                     echo '';                     }                 ?>             <?php } ?>
     <?php if ($gogo_gallery_short_desc) { ?><?php echo $gogo_gallery_short_desc; ?><?php } ?>

         <?php endwhile; ?>                   <?php $wp_query = null; $wp_query = $temp;         $content = ob_get_contents();         ob_end_clean();         return $content;     }     add_shortcode("gallery_posts", "gallery_posts_func");


Add a custom text to admin footer in a Custom Post Type page

I want to customize the footer text in a Custom Post Type admin page. I have a plugin that creates this custom post type and want to add in it a function to customize admin_footer_text. As you can see in code below I can change the footer text, but only globaly.               function my_custom_footer_admin_text () {         echo 'my custom message,';     }     add_filter('admin_footer_text', 'my_custom_footer_admin_text');      Does someone knows the hook of a custom post type page? Or how can I change the footer text of a certain Custom Post Type page?


Dynamic sidebar nav with current page highlighting

My sidebar loops through all of the child pages based on the parent page. For example, if you're in the "About" section you'll only see "About" child pages in the sidebar. My problem is that I have no way of highlighting the current page. For example, if you're on the child page "Our Team" (under "About") I'd like to give the sidebar "Our Team" a tag link a "current-page" class. Is there a way to add a "current-page" class dynamically to the child page you're on?               <?php      if ( $post->post_parent == '4' ) {         query_posts("post_type=page&post_parent=4&orderby=menu_order&order=asc");      } elseif ( $post->post_parent == '6' ) {         query_posts("post_type=page&post_parent=6&orderby=menu_order&order=asc");     } elseif ( $post->post_parent == '8' ) {         query_posts("post_type=page&post_parent=8&orderby=menu_order&order=asc");      } elseif ( $post->post_parent == '10' ) {         query_posts("post_type=page&post_parent=10&orderby=menu_order&order=asc");      }     if ( have_posts() ) : while ( have_posts() ) : the_post();     ?>     <a href="<?php the_permalink(); ?>"><?php the_title(); ?>     ...


How to reset post data properly

I have this piece of code that I am calling within the loop to get image metadata ( title/caption and description ). It works fine but it only works for the first post in the loop. So I assume it needs to be reset. From looking here I think `wp_rest_postdata();` is the right way to reset the query, but still the output fails for all but the first post, it repeats the data from the first post for every other post.               function get_image_metadata() {              $image_id = get_post_thumbnail_id($post->ID);         $args = array(             'post_type' => 'attachment',             'post_status' => null,             'post_parent' => $post->ID,             'include'  => $image_id             );          $image_data = get_posts($args);              if ($image_data && isset($image_data[0])) {             $meta_output['title'] = $image_data[0]->post_title;              $meta_output['caption'] =  $image_data[0]->post_excerpt;              $meta_output['description'] =  $image_data[0]->post_content;          }         //wp_reset_query();         wp_rest_postdata();         return $meta_output;     }


Problem display only posts with comments

I'm trying to make a page that will show only the posts that have comments. I have this in my page template:               <?php     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     query_posts( 'cat=-8378, -13444&orderby=comment_count&paged=' . $paged );     while (have_posts()) : the_post();     ?>      But it's not working. It still just shows my normal post display. Any suggestions? Thanks!


Use wp_localize_script for non existing script

## Task: What I'm trying to do I'm fetching data via the WP Http API from a remote server. The data I'm getting back is `JSON` encoded. In one of my methods, I'm converting them back and then push it into a class variable, so I can use it later in some scripts. ## Example: How I'm trying to do it               // Simplified... please note, that all names/vars/etc. in my class got unique names.     // ...the same goes for the script handler.     class http_api_example     {         public $remote_data;         public $response;              public function __construct()         {             $this->request();         }              public function request()         {             $request = wp_remote_request( 'http://example.com/HereYouGetSomeJSON' );             $this->response = json_decode( wp_remote_retrieve_body( $request ) );         }              public function deliver_to_javascript()         {             wp_enqueue_script( 'json_handler', null, array(), null, true );                  // ...then I'm trying to localize it             wp_localize_script( 'json_handler, 'json_object', array(                  'ajaxurl'    => admin_url( 'admin-ajax.php' )                 ,'ajax_nonce' => wp_create_nonce( 'json_handler_nonce' )                 ,'action'     => 'json-handler-action'                 ,'data'       => $this->response              )              }     }      * * * ## Problem: What's not working > For some reason, I can't access the `json_object` from the console (it works > for other objects in other classes just fine). * * * ## Debug so far ### Is it registered and queued? I tried to take a look if the script is registered:               // 'registered': TRUE     var_dump( wp_script_is( 'json_object' ) );          // 'queue': TRUE     var_dump( wp_script_is( 'json_object', 'queue' ) );      to be sure, I've also taken a look into the `global $wp_scripts` and can confirm, that it's there. ### Is it localized?               // Data shows up, JSON encoded     var_dump( $GLOBALS['wp_scripts']->registered['json_object']->extra;      ### Where in core does it stop? I went into core and backtraced it the following way:   1. `wp_localize_script()` **✓**   2. » `$wp_scripts->localize()` **✓**   3. »» `WP_Dependencies: add_data()` **✓**   4. »»» `WP_Dependencies: add_data()` **FIN!** The **FIN!** notes a call to itself. As you can see from the Link to the WP repo on GitHub, inside `->add_data()`, there's another call to `->add_data()` (to itself). I dumped the result and got `TRUE` back. I'm currently out of "what can I try else?"-options. Maybe someone got an idea, how this is supposed to work or maybe just where I could try to look further. Thanks.


Help With A Reverse Pagination Plugin

I saw this presentation about why pagination on the Internet is weird. https://speakerdeck.com/u/espylaub/p/pagination-on-the-internet-and-why-its- weird It inspired me to try and make a WordPress plugin to do just that. Here's what I've got so far...               <?php     /*     Plugin Name: Reverse Pagination     Description: Pagination starts higher and goes lower for more consistent archive page numbering.     Author: Russell Heimlich     Version: 0.1     */                function reverse_pagination_pre_get_posts($t) {            $q = $t->query_vars;          if ( empty($q['order']) || ((strtoupper($q['order']) != 'DESC') && (strtoupper($q['order']) != 'ASC')) ) {             $q['order'] = 'ASC';          }               $t->query_vars = $q;     }          function reverse_pagination_wp() {         global $wp_query;         $wp_query->posts = array_reverse($wp_query->posts);     }          if( !is_admin() ) {         add_action('pre_get_posts', 'reverse_pagination_pre_get_posts');         add_action('wp', 'reverse_pagination_wp');     }       I hook into the `pre_get_posts` action and switch the order query var to ASC instead of the default DESC. Next I needed to reverse the order of the posts returned so they are in reverse chronological order. I chose the `wp` action for the reasons outlined in this answer http://wordpress.stackexchange.com/a/22768 So things are looking good so far. I just need to fix the first page. Right now if my blog has 50 pages and there is no `paged` parameter set the blog index page will show my very first post instead of the latest post. I need some logic to check if `paged` isn't set to set it to the same value of `$wp_query->max_num_pages` for that query. I also need to disable the canonical redirect that removes /page/1/ from the URL and tweak the `get_pagenum_link()` function so it returns /page/1/ for `get_pagenum_link(1)` http://hitchhackerguide.com/2011/02/12/get_pagenum_link/ If there is anything else that can be added to make this plugin better please speak up! Thanks and I hope we can make this happen by working together on it.


Associating post id with its post type

i'm making modifications to a portfolio theme. the theme has the blog and portfolios. the portfolios are custom post types with their respective taxonomies. the theme homepage only displays one portfolio. that is, it only shows the posts for one custom post type. the theme displays the most recent posts for each category of the custom post type and creates a filter menu that is populated with the categories. this way a user can filter the displayed posts by category like "graphic design" and a JS script hides the posts that are not of that category. i need to mix the posts of all portfolios and the blog on the homepage. so i need to query all the recent posts from all portfolios and the blog, populate the filter menu with post types, and then pass that over to the JS script to hide the posts that are not of the selected post type. i've managed to query all the recent posts from all portfolios and the blog, and populate the filter menu with post types using the code below: THE COMMENTED CODE IS THE ORIGINAL CODE, e.g. $terms                <?php      $args=array(         'post_type' => array('post', 'test-bscm', 'test-btum', 'test-other', ),         'posts_per_page' => 16     );     $temp = $wp_query;      $wp_query = null;     $wp_query = new WP_Query();     $wp_query->query($args);     /*$terms = get_terms($pcat);*/     ?>          //populate the filter with post types     <?php      $args=array(  'show_in_menu' => true);     $output = 'names';     $terms = get_post_types($args);     ?>                    <?php if ($home_portfoliolayout=="No Categories") {          echo '
';     } else if ($home_portfoliolayout=="Categories") {         echo '
';     } ?>
             <?php             echo '
'.__('All Projects', 'apex').'|
';             foreach ( $terms as $term ) {                 $filter_last_item = end($terms);                 if($term!=$filter_last_item){                     echo '
'.ucwords(str_replace('-', ' ', $term)).'|
';                 }else{                     echo '
'.ucwords(str_replace('-', ' ', $term)).'
';                 }             }             ?>

      i am able to see a 16 posts that represent the most recent posts to the blog, test bscm portfolio, test bum portfolio, and the test other portfolio. the filter shows: All Projects, Post, Pages, Test Bscm, Test Btum, and Test Other. i need to remove Pages from the results because it is not needed. here's the code to how the results are displayed and so how the JS script hides posts...                             <div class="sixteen columns row <?php echo $folioteasers ?> portfolio">              <?php if ($wp_query->have_posts()) : ?>         <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>              <?php                $custom = get_post_custom($post->ID);             $foliocatlist = get_the_term_list( $post->ID, $pcat, '', ', ', '' );             $entrycategory = get_the_term_list( $post->ID, $pcat, '', '_', '' );             $entrycategory = strip_tags($entrycategory);             $entrycategory = strtolower($entrycategory);             $entrycategory = str_replace(' ', '-', $entrycategory);             $entrycategory = str_replace('_', ' ', $entrycategory);             $entrytitle = get_the_title();             $blogimageurl = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );             if($blogimageurl==""){                 $blogimageurl = $templateurl.'/images/demo/460x272.jpg';             }         ?>              <div class="<?php echo $foliocolumns ?> columns teaser all-group <?php echo $entrycategory ?>">            <a href="<?php the_permalink(); ?>" data-text="» <?php _e('Visit Project', 'apex'); ?>" class="hovering"><?php echo ''; ?>
                <a href="<?php the_permalink(); ?>" class="bigplus">
<a href="<?php the_permalink(); ?>"><?php echo $entrytitle ?>

<?php echo $foliocatlist ?>

              <?php endwhile; ?>         <?php else : ?>

<?php _e('Oops, we could not find what you were looking for...', 'apex'); ?>

         <?php endif; ?>              <?php          $wp_query = null;          $wp_query = $temp;         wp_reset_query();         ?>

      as you can see it's based on the post category. so of course when i try to filter by one of the listed post types all results are hidden. so the solution is to associate the post id with its post type. i know it comes after the $custom = get_post_custom($post->ID); and i'll replace all that code for foliocatlist and entrycategory i just haven't found it in the codex. thanks.


Applying post title filter: Last Viewed Posts + qTranslate

I'm using Last Viewed Posts (LVP) plugin on a qTranslate-enabled website. LVP shows post titles in both languages. I found this hint: titles in recent posts appear together in all languages with qtranslate But not sure how to apply this filter. Relevant code in LVP:                       foreach ($zg_post_IDs as $value) { // Do output as long there are posts             global $wpdb;             $zg_get_title = $wpdb->get_results("SELECT post_title FROM $wpdb->posts WHERE ID = '$value+0' LIMIT 1");             foreach($zg_get_title as $zg_title_out) {                 echo "post_title . "\">". $zg_title_out->post_title . ", \n"; // Output link and title             }      Instead of `echo $post->post_title;` it has `$zg_title_out->post_title`. Replacing the whole zg string with `apply_filters('the_title',$post->post_title)` didn't work.


How do post a Photo to Facebook when a post is published?

I have a wordpress site. It is now using the official Facebook plugin. When a new post is published, an action will be posted to Facebook. The posted message contains a small thumbnail , post title and some description. But I want to change this approach. I found Posterous allow user post a photo to Facebook when a post is published. Does anyone know any Wordpress plugin which can post a photo to Facebook when publishing? Thanks all. :)


How to know which wordpress plugin is exporting site information to plugin author?

Is there any plugin or method to know outgoing data? Nowadays every 5th plugin use to fetch data from sites. And I noticed that plugin authors are very enjoying this function. But as plugin users I'm liking it sometimes. So far I've been digging into plugin files to remove their codes. But its not possible to do after every plugin update. I think this features is facilitated by wordpress own functions. Is there any method to turn it off? **Edit:** For example Yoast seo plugin uses this file to fetch information about users. He even gets contents from database queries. Isn't it too much? The same way any plugin can get passwords too.


Creating and Using Tables in the Wordpress Database

I plan on having over 2,000 pages per subject on my WordPress website and since each subject will require custom page types I would like to create tables for each subject in the WordPress Database. Each page will also require lat/long and alternate title's for each page created. Can someone explain how you would go about making and using a dedicated table for each custom Page Type? I assume that you could use an exact copy of wp_post table?


Identical members roles on all sites in a multisite

In a multisite system I need editorial accounts with custom rights. Therefore I have chosen the members plugin. As I do have lots of sites, creating and synching the roles for all sites becomes quite tedious. a) is it possible to manage my roles for all sites globally (network-wise)?   b) would you suggest to use a different plugin?


How to create pagination that links to Posts directly and not a numbered page?

I have site that displays 1 post per page, I would like to paginate this automatically with numbers underneath the post. Default function for pagination is to link to say ?page=2. I searched but can't find specifics that closely match my requirements, I also attempted to use this answer: But it would not automatically update. So, the function required. 8 post = 8 numbers, Click on a number, takes you directly to that post, < and > to take you to the next post, This has to be done from index and not from inside a post, Automatic and dynamic So far I can get it to work it's neither dynamic nor automatic pagination. Already answered? how could I get the pagination as I want to when query posts using get_posts function I don't think it has been answered, That person has 2 posts per page and wants the pagination to link different. From reading the page which was difficult I was unable to establish a similarity. I want to have 12 posts, the index aggregates these 12 posts, if I set to show 1 post per page that is 12 pages for 12 posts in the pagination and when I select it say number 2,the url becomes the page/2/. What I want is when you click the pagination number 2, it takes me to /%date%/%post_name% Which is a different setup from the post linked as already being answered, hope this makes better sense.


Add a widget to a static front page

I'm using a premium theme, which I purchased and would like to add a social widget to the static front page. I've made a static page with a image slider my home page. An example of the page can be found here. How do I go about adding a social widget to this page? Any help will be greatly appreciated. Thanks in advance.


add_action in a function, is it possible?

I am trying to add some js to the head using `add_action('wp_head', 'js_func');` which works when posted just after the function, however I do not want it posted on every page, just the page that it's relevant to and I am trying to do it like so               function things_to_do_on_this_page() {         add_action('wp_head', 'js_func');         //other functiony things     }      However when it is called like so the js isn't placed at all, thus breaking the page. Is it possible to do this?


White screen on front page only

I've got the famous white screen, but only on my home page. Deeper pages load just fine. I moved my `themes` directory to `themes-old` and made a new `themes` directory that only has twentyten in it. I changed my theme to twenty ten. I don't have any plugins enabled, but I moved my plugins directory and created a new, empty plugins directory. I turned debugging on. I'm at a total loss here. I did make some theme tweaks today, but I already restored the back up of my theme which didn't help, and anyway I've now set twentyten as my theme.


Make a difficult page editable

There's this page http://voitair.com/scent-system/scent-system I need to make editable via admin panel. It has to be understandable for a non-programmer. What system or plugin or anything can I use to make it still function as now but be editable?


wordpress login blank screen

i wanted to make an offline copy of my live website on my pc so i installed xamp and installed on it wordpress and exported the database and took a copy of files on fttp and after i have done eveything and i wanted to make open my live website to edit something it gives me a blank page when i open                "www.sitename.com/wp-admin"       but when i open               "www.sitename.com/wp-login.php"      it open put when i insert username and password it also gives me blank page i opened the wp-config and i found that dp host became **"localhost"** i think this is my problem but how can i get my dbhost back is there a way to find it


Can I host WP-admin locally for a remote blog?

I'm having an issue where my theme creates a pile of images sizes on uploads (because it's supposed to), and my server periodically gags on the process. It's resulting in a pile of "MySQL server has gone away for..." problems, and I end up with media uploads that contain no data. A dedicated server isn't in the budget. And my web host isn't a big fan of making more RAM available to my account. So moving from my current hosting solution isn't an option. However, I've got a test server sitting here in my office with 4 CPUs and 16GB of RAM, and I thought, "Hey, is there a way I can host all the WP-admin functions locally, and simply push changes to the remote server?" A thousand apologies if this has been asked elsewhere. Everything I could find on the subject was just about setting up a local testing server. My case is different - I want the back end hosted somewhere other than the front end (and yes, the final DB should obviously also be remote, unless I can find a way to simply push DB changes to the live server).


save_post not called in plugin / custom field still saving overwriting metaboxes

I have a plugin that writes metaboxes to certain pages. It writes the metaboxes fine and everything works as should...until I save. The save_post is not getting called, and I can't figure out why. Here is the code in my __Construct               class Plg_Admin_Meta {          public static function start() {      return new self();     }           public function __construct() {       $this->plugin_url = WP_CONTENT_URL . '/plugins/' . basename(dirname(__FILE__));       $this->plugin_dir = dirname(__FILE__);            add_action('admin_init', array($this, '_admin_init'));         add_action('save_post', array($this, '_save_post'), 99);     }      The metaboxes are made from custom fields, and if I edit a custom field text area it saves fine, but I want it to save the data entered from the metabox instead. For whatever reason the save_post will not fire. I tried putting a die(var_dump($_POST)) at the start of my _save_post function and it isn't even firing. Here is my _save_post function               public function _save_post($post_id) {       //die(dump_var($_POST));       update_post_meta($post_id, 'content__service_overviews', "test2");       // Post meta isn't sent for autosaves       if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {         return;       }     }          Plg_Admin_Meta::start();      As you can see I am just manually trying to update a field right now, but the function isn't even getting called. EDIT: Requested entire class:                 class Plg_Admin_Meta {              public static function start() {          return new self();         }               public function __construct() {           $this->plugin_url = WP_CONTENT_URL . '/plugins/' . basename(dirname(__FILE__));           $this->plugin_dir = dirname(__FILE__);           $this->prefix = 'content__';           $this->page_fields = array(             'site' => array(               'textarea:slideshow',               'text:address',               'text:phone',               'text:fax',               'text:twitter_link',               'text:weather_link',               'text:meta_description',               'text:meta_keywords',               'text:google_analytics_account_number',               'text:google_site_verification_code'             ),             'home' => array(               'textarea:about_enernex',               'textarea:introducing_utility_stats',               'textarea:recent_content',               'textarea:workshop_button'             ),             'about' => array(               'textarea:what_we_do_photo',               'textarea:what_we_do',               'textarea:our_mission_photo',               'textarea:our_mission',               'textarea:get_to_know_us_photo',               'textarea:get_to_know_us_principals',               'textarea:get_to_know_us_staff'             ),             'careers' => array(               'textarea:why_enernex_photo',               'textarea:why_enernex',               'textarea:support_our_mission_photo',               'textarea:support_our_mission',               'textarea:the_innovation_valley_photo',               'textarea:the_innovation_valley_our_location'             ),             'contact' => array(               'textarea:photo',               'textarea:contact_information',               'textarea:map_image',               'textarea:directions'             ),             'employees' => array(               'text:title',               'textarea:text',               'textarea:photo'             ),             'support' => array(               'textarea:announcing_utility_stats',               'textarea:faq',               'textarea:utility_ownership_key',               'textarea:support'             ),             'newsroom' => array(               'textarea:service_overviews',               'textarea:media_contacts',               'textarea:industry_resources_and_related_links'             ),             'services' => array(               'textarea:main_text',               'textarea:power_systems_consulting_photo',               'textarea:smart_grid_engineering_photo',               'textarea:smart_grid_labs_photo',               'textarea:workshops_photo'             ),             'iec-workshop' => array(               'textarea:first_photo',               'textarea:course_overview',               'textarea:topics_covered',               'textarea:our_instructors',               'textarea:workshop_dates',               'textarea:who_should_attend',               'textarea:key_benefits',               'textarea:schedule_location_and_cost',               'textarea:second_photo',               'textarea:location'             ),             'cyber-security' => array(               'textarea:meet_the_team',               'text:media_kit_download_link'             )           );                $this->post_fields = array(             'news' => array(               'textarea:overview',               'textarea:story'             ),             'press' => array(               'textarea:overview',               'textarea:story'             ),             'whitepapers' => array(               'textarea:overview',               'textarea:uploads'             ),             'areas' => array(               'textarea:overview',               'textarea:uploads',               'textarea:projects'             ),             'links' => array(               'text:URL'             ),             'jobs' => array(               'textarea:basic_function',               'textarea:education_and_experience',               'textarea:skills',               'textarea:duties_and_responsibilities',               'textarea:contact_information',               'textarea:notes'             ),             'employees' => array(               'text:position',               'text:department',               'text:year_joined',               'text:power_industry_years',               'text:education',               'text:expertise',               'text:phone',               'text:email_address',               'textarea:biography',               'textarea:headshot'             ),             'blog' => array(               'textarea:author',               'textarea:content'             ),             'announcements' => array(               'text:link_to_announcement',               'textarea:content'             )           );                          add_action('admin_init', array($this, '_admin_init'));             add_action('save_post', array($this, '_save_post'), 99, 2);                           }                   public function _admin_init() {                $post_id = isset($_REQUEST['post']) ? $_REQUEST['post'] : false;           if ($post_id) {                  $content = get_post($post_id);             $slug = $content->post_name;             $post_type = $content->post_type;                  if (isset($post_type)) {                    switch($post_type) {                      case 'page':                   $this->_create_metaboxes('page', $this->page_fields[$slug]);                 break;                      case 'post':                   $category = get_the_category($post_id);                   $slug = $category[0]->slug;                   $this->_create_metaboxes('post', $this->post_fields[$slug]);                 break;                    }                  }                }              }              public function _create_metabox_content($post, $metabox) {                $post_id = $post->ID;              $meta_key = $metabox['args']['meta_key'];           $meta_value = get_post_meta($post_id, $meta_key, true);                switch ($metabox['args']['type']) {                  case 'text':                    ?>                    <input type="text" name="<?php echo $meta_key; ?>" value="<?php echo $meta_value; ?>" style="font-family:'Georgia', 'Times New Roman', 'Bistream Charter', 'Times', 'serif';font-size: 13px; line-height: 19px; color: #333; width: 100%;" />                    <?php                  break;                  case 'textarea':                    wp_editor(                  $meta_value,                 $meta_key,                 array(                   'textarea_name' => $meta_key,                   'textarea_rows' => 4,                   'tinymce' => array(                     'content_css' => $this->plugin_url . '/tinymce.css'                   )                 )                       );                       break;                }              }              public function _create_metaboxes($post_type, $fields_array) {                if (!empty($fields_array)) {                    wp_enqueue_style('admin', $this->plugin_url . '/admin.css');                      foreach ($fields_array as $field) {                        $tokens = explode(':', $field);                   $type = $tokens[0];                   $meta_key = $this->prefix . $tokens[1];                   $id = 'metabox_' . $tokens[1];                   $title = ucwords(preg_replace('/\_/', ' ', $tokens[1]));                                    add_meta_box(                     $id,                     $title,                     array($this, '_create_metabox_content'),                     $post_type,                     'normal',                     'high',                     array(                       'meta_key' => $meta_key,                       'type' => $type                     )                                     );                      }                }              }                public function _save_post($post_id) {              //die(var_dump($_POST));         // Post meta isn't sent for autosaves         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {           return;         }              update_post_meta($post_id, 'content__service_overviews', "test2");                     if (isset($_REQUEST['post_ID'])) {                         foreach ($_REQUEST as $meta_key => $meta_value) {                 if (strstr($meta_key, $this->prefix)) {                      //update_post_meta(intval($_REQUEST['post_ID']), meta_key, meta_value);                      }                    }                     }              }                 }                 Plg_Admin_Meta::start();


WP_Nav Highlight Parent Issue

I'm trying to figure out how to highlight the parent nav of a page and becoming stuck. I've seen something like this :               <li <?php if(is_page('services')) { echo 'class="current_page_item"'; } ?> >          Services
      I have different post types going on and I've split each post type into a page, the problem begins when I click down into the "services" tab and click a "service request" the blog navigation highlights instead of the services one. How can I fix this? I don't mind using PHP or CSS for this as the site is for myself.


Error timed out with succesfull wp_remote_post

**What I'm trying to do:** Passing POST data by using wp_remote_post.               foreach ( $articles as $article_id ) {         $postarray = array(         'method'        => 'POST',         'timeout'       => 5,         'redirection'   => 5,         'httpversion'   => '1.0',         'blocking'      => true,         'headers'       => array(),         'body'          => array(             'article_id' => $article_id             ),         'cookies' => array()         );              $response = wp_remote_post($url, $postarray);              if ( is_wp_error($response) ) {             $error_message = $response->get_error_message();             echo $error_message;         } else {             // the rest of my code here         }     }      I'm working with 20+ posts per call. Everytime the loop finish, I get this error message: > "Operation timed out after 5001 milliseconds with 0 bytes received" The strange thing is, the data are actually received and stored successfully on the designated `$url` server. Can anyone point me to the right direction, where should I look to avoid getting that error message? Reference: wp_remote_post


Dynamic Sidebars based on page name

I would like to do a dynamic sidebar for my WordPress site, so it would pull in the correct Sidebar template based on the page title of the page. So if I had 10 sidebars all named like this: Sidebar Template Name: About Sidebar Template Name: Contact Sidebar Template Name: Jobs Sidebar Template Name: Etc Sidebar Template Name: Page1 So the Sidebar 'About' would appear on the About page, and the same for contact, etc... Any idea How I would do this? Or Is there an alternative way on how to do it?


Dont' charge customer until product ships - woocommerce

Is it possible to set woocommerce to not charge the customer until the product actually ships?


How to display first post

I want to display in the front page of my theme the first most recent post in the header and then continuing the loop in the main content section starting from the second to post and so on, how can i achieve this?


Child Site doesn't appear in the Network menu

As you see in the snapshot, just the main site appear in My Sites menu, Although it appears correctly in the "Network Admin". I used the subdomain installation when I configured the Wordpress MU. And this is the Wordpress MU part in wp-config.php               define('WP_ALLOW_MULTISITE', true);          define('MULTISITE', true);     define('SUBDOMAIN_INSTALL', true);     define('DOMAIN_CURRENT_SITE', 'www.mydomain.com');     define('PATH_CURRENT_SITE', '/');     define('SITE_ID_CURRENT_SITE', 1);     define('BLOG_ID_CURRENT_SITE', 1);      ![just the main site appearing](http://i.stack.imgur.com/8e4nB.png)


How do I create custom tags for Wordpress SEO?

I'm using Wordpress SEO by Yoast, the free version and wondering if there is a way to create custom tags such as %%city%%. I want to make my own that can pull data from another plugin i'm using as a "directory" called Web 2.0 Directory. I want to input options inputted from that such as %%doctorname%% and %%city%%. Is this possible? If so what file(s) should I reference and can you give me a brief overview on how to go about that?? Each directory listing has separate fields for these items, but I cannot seem to figure out where I can create my own tag calls to produce these custom tags. Thanks!


Wordpress Search documentation: how to improve search query using taxonomy terms, custom meta fields?

I'm trying to understand how Wordpress search works. I haven't found much info on the Codex. Arguably, search is not the best WP feature. Even Wordpress.org uses Google Search. I would like to make a custom search form to allow people search using my custom taxonomies and custom meta fields. I'd imagine the search query would work exactly as a normal WP query, therefore a tax query and a meta query should be possible. But how to pass the user submitted form data to a search query? Is it possible to pass form variables to the /?s= search string in the address bar? that would make things easier... I know there are many plugins around. Some of them quite complex. But I don't mind learning my own way and eventually the few I tried would require some adaptation for my theme (which uses almost ten different post types and a bunch of custom taxonomies, plus loads of custom fields handled by Advanced Custom Fields plugin). Is there any detailed article that goes in depth regarding this matter? EDIT I just came up with an idea, to make a form in one page, then pass the input fields variables with $GET to another page template which holds a custom WP_Query and with some IFs and ELSEs perform a custom query... Eventually I will post an answer with the code when I'm done. This is close to what I was asking, although I wanted to know if it was possible without creating a new template with a new query, oh well...


Can't save postmeta data

I am trying to save custom fields data in custom post type but nothing reach the database. Same code was working fine in another plugin but won't work here. Here is the code.               class SH_job_post_class{                        public function metaboxes(){             add_action('add_meta_boxes', function(){                 add_meta_box('SH_job_listings_metabox', __( 'Extra Information Required For Job*', 'sh_textdomain' ),                     array($this, 'cb_function_for_meta_box'), 'sh_job_listings', 'normal', 'high');             });         }              public function cb_function_for_meta_box($post){             // Nounce field to protect form             wp_nonce_field( 'my_meta_box_nonce', 'sh_meta_box_nonce' );             $value = get_post_meta($post->ID);          $applyby = isset($value['SH_applyby'])? $value['SH_applyby'] : '';             ?>
                 Apply For                 <input type="text"  name="applyby" id="applyby" value="<?php echo esc_attr($applyby);  ?>" />
                   <?php             add_action('save_post', function($post_id){                  // Stop the script when doing autosave                 if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;                      // Verify the nonce. If insn't there, stop the script                 if( !isset( $_POST['sh_meta_box_nonce'] ) || !wp_verify_nonce( $_POST['sh_meta_box_nonce'], 'my_meta_box_nonce' ) ) return;                 // Stop the script if the user does not have edit permissions                 if( !current_user_can( 'edit_post' ) ) return;                      // Save the textfield                 if( isset( $_POST['applyby'] ) ){                     update_post_meta( $post_id, 'applyby', strip_tags( $_POST['applyby'] ) );                 }                       });                   }                              }          add_action('init', function(){         new SH_job_post_class();     });


Rewrite post type slug only for child theme

I'm in multisite where some blogs share the same parent theme for maintenance reasons. All my cpts come from that parent theme, but I would really like that, for one of the blogs, it had an URL mask. I found this answer very useful to change labels, but I've tried to do the same and assign a different slug to `$wp_post_types[$post_type]->rewrite['slug']` and it fails, bringing the whole rewrite array to NULL. I've also tried .htacces with `RewriteRule ^/newslug$ /oldslug [L]` but with no success. Is there a clean way to do this?


Rewrite rules not working in WordPress

I'm trying to add the new rewrite rules using the rewrite API:                add_rewrite_rule('product/([A-Z0-9]{10})', 'index.php/product/?asin=$1', 'bottom');      add_rewrite_rule('product/(([A-Za-z0-9_])*)', 'index.php/product/?product=$1', 'bottom');      add_rewrite_rule('compare/((([A-Z0-9]{10}),?)*)', 'index.php/compare/?asin=$1', 'bottom');      add_rewrite_rule('categories/(([A-Za-z0-9]|\-|\_)*)', 'index.php/categories/?subcategory=$1', 'bottom');      After the permalink is updated it adds the following lines to the `.htaccess` file:               RewriteRule ^product/([A-Z0-9]{10}) /index.php/product/?asin=$1 [QSA,L]     RewriteRule ^product/(([A-Za-z0-9_])*) /index.php/product/?product=$1 [QSA,L]     RewriteRule ^compare/((([A-Z0-9]{10}),?)*) /index.php/compare/?asin=$1 [QSA,L]     RewriteRule ^categories/(([A-Za-z0-9]|\-|\_)*) /index.php/categories/?subcategory=$1 [QSA,L]      resulting to the following `.htaccess` file:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteRule ^product/([A-Z0-9]{10}) /index.php/product/?asin=$1 [QSA,L]     RewriteRule ^product/(([A-Za-z0-9_])*) /index.php/product/?product=$1 [QSA,L]     RewriteRule ^compare/((([A-Z0-9]{10}),?)*) /index.php/compare/?asin=$1 [QSA,L]     RewriteRule ^categories/(([A-Za-z0-9]|\-|\_)*) /index.php/categories/?subcategory=$1 [QSA,L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      But when I tried to access the following URL:               http://example.com/product/ABCDE324AB      It doesn't seem to work. I always get a page not found page. Any ideas?


custom post type tags

I have this code:               $args=array(             'post_type' => array ('portfolio'),             'orderby' => $orderby,             'order' => 'DESC',             'paged' => $paged,             'posts_per_page' => $post_per_page,             'ignore_sticky_posts' => $do_not_show_stickies           );             if($pf_categorynotin){                 $args['tax_query'] = array(                     array(                         'taxonomy' => 'portfolio_category',                         'field' => 'slug',                         'terms' => $pf_categorynotin,                         'operator' => 'NOT IN'                     )                 ); //category__in             }      What I'm asking is how to add also "portfolio_tag" taxonomy because I want to list tags from my custom post type. Any suggestions on how to achieve this ? Thanks! Later edit: here is snippet of the code that is used to retrieve portfolio categories and how they are displayed: snippet


How can I only display links from a child category

Using this code from the codex:                      <?php     $category = get_the_category();     if($category[0]){     echo 'term_id ).'">'.$category[0]->cat_name.'';     }     ?>      Codex link: http://codex.wordpress.org/Function_Reference/get_the_category I am able to display the category the post is in as a link (e.g. Business). However, I don't want to display the parent categories. I only want to display the child categories of a certain parent category. My category structure is like this: Premium (Parent) > Premium Themes (Child) > Ecommerce (Child), Business (Child), Photography (Child), etc. So I only want to display the children of the Premium Themes category. Any help much appreciated.


How to recognise on which site the content is being rendered?

I've created a child theme basing on twenty twelve. Since I present the content a little bit different on home and on the archive page, I'd like to know inside `content-[format].php` on which page the post is being rendered. Then, I can decide which image size I can present. How can I know it?