The images in the post arent Visible after publishing them?

I write a post in new post editor and then add media. I can see the images in the editor but when i publish them they aren't loading up and a frame with little square in the middle comes up. This is the link to one of my posts: http://getprogramcode.com/2013/03/c-program-for-bit-stuffing/ . For some people only link to the image comes up and it opens up with 404 error. See the line after OUTPUT: bit stuffing. Also i want to remove the featured image from appearing in my posts. I have a option in my theme on a new post: "disable featured image" - but that doesnt work . Also if i dont put the image or i remove the featured image the empty image appears: see the home page: http://getprogramcode.com Please help me to solve this problem


Custom front end login not working

I'm trying to create a photo sharing site for my brother and his fellow guardsmen who are over in Afghanistan. I'm having issues with wordpress login/register. I have everything set up so you can log in, in the header or register in the main content area. When you are logged in you can view the photos. I'm trying to do with all with using just index.php by doing this...               <?php get_header(); ?>                                  <?php if (is_user_logged_in()) :?>                             <?php include('loop.php'); ?>                             <?php else : ?>                             <?php include('register.php'); ?>                             <?php endif; ?>                    <?php get_footer(); ?>      So if the user is logged in they see the loop, if they aren't they see the register form. Then then in the header you see the login form which I found a solution for by looking around...                 <?php if (!is_user_logged_in()){ ?>       <?php wp_login_form() ; ?>        <a href="<?php echo wp_lostpassword_url( get_permalink() ); ?>" title="Lost Password">Lost Password            <?php } else { ?     Welcome,        <a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout            <?php }?>      When I hit "login" it just stays on the page and adds the info to the url. Nothing changes. You can see it live @ www.kevinmonahan.com/test I've never done a user login on the front end before, so thanks for the help in advance!


How to add a default item to a custom taxonomy?

Wordpress default taxonomy (Categories) has the item Uncategorized by default. How to add a default item to a new custom taxonomy? **functions.php:**               // === CUSTOM TAXONOMIES === //     function my_custom_taxonomies() {         register_taxonomy(             'block',        // internal name = machine-readable taxonomy name             'static_content',       // object type = post, page, link, or custom post-type             array(                 'hierarchical' => true,                 'labels' => array(                     'name' => __( 'Blocks' ),                     'singular_name' => __( 'Block' ),                     'add_new_item' => 'Add New Block',                     'edit_item' => 'Edit Block',                     'new_item' => 'New Block',                     'search_items' => 'Search Block',                     'not_found' => 'No Block found',                     'not_found_in_trash' => 'No Block found in trash',                 ),                 'query_var' => true,    // enable taxonomy-specific querying                 'rewrite' => array( 'slug' => 'block' ),    // pretty permalinks for your taxonomy?             )         );     }     add_action('init', 'my_custom_taxonomies', 0);      **EDIT: I just want to have the taxonomy item there when the theme is installed. It doesn't have to automatically be added to any empty term**.


Ajax future single post query doesn't work when NOT logged in

I am having a problem with an ajax request for a single post, when the user is not logged in. The post is a calendar date and is in the future. the query works fine if I am logged into wordpress but doesn't when I am logged out. This type of query also works when there is no ajax involved, for example if I want to display all future dates in a category page. Do I need to fire up an instance of wpdb to get the results? Must be a permission thing but cant find any answers.               function ajax_get_date_post()      {         // get the submitted parameters         $post_id = $_POST['post_id'];              $args = array(             'post_type' => 'mandy_dates',             'p' => $post_id,             'post_status' => 'future,publish'         );              // build and make query         $clicked_date =  new WP_Query( $args );              // response output         header( "Content-Type: application/html" );         if ( $clicked_date->have_posts() ) {             while ( $clicked_date->have_posts() ) {                 $clicked_date->the_post();                 include( $this->get_single_post_template_path() );             }         } else {             echo "Sorry, Date not found";         }              exit;     }      UPDATE: these are the hooks:                   add_action( 'wp_ajax_nopriv_ajax_get_date_post', array(&$this, "ajax_get_date_post") );         add_action( 'wp_ajax_ajax_get_date_post', array(&$this, "ajax_get_date_post") );      this is the Ajax JS:               function ajax_get_post( _id )      {         $.post(             mandy_dates_js_config.ajaxurl,             {                 action : 'ajax_get_date_post',                 post_id : _id             },             function( response ) {                 on_date_loaded( response );             }         );     }      UPDATE 2: I figured it out. modified the "show-future-posts-on-single-post" to work in my ajax request, here the updated code               function ajax_get_date_post()      {         // get the submitted parameters         $post_id = $_POST['post_id'];              $args = array(             'post_type' => 'mandy_dates',             'p'         => $post_id             // 'post_status' => 'future,publish'         );              // build and make query         $this->clicked_date = new WP_Query();              add_filter( 'the_posts', array( &$this,'show_future_posts') );         $this->clicked_date->query( $args );         remove_filter( 'the_posts', array(&$this,'show_future_posts') );              // response output         header( "Content-Type: application/html" );         if ( $this->clicked_date->have_posts() ) {             while ( $this->clicked_date->have_posts() ) {                 $this->clicked_date->the_post();                 include( $this->get_single_post_template_path() );             }         } else {             echo "Sorry, Date not found";         }              exit;     }          function show_future_posts( $posts )     {         global $wpdb;              if( $this->clicked_date->post_count == 0 ) {             $posts = $wpdb->get_results($this->clicked_date->request);         }              return $posts;     }


wp_insert_post bulk import 500 server error

I am working on a Wordpress import tool, where I use a custom city table in my database with longitude, latitude which combine with some other text and then import by `wp_insert_post()`. This works great but after 3200 - 3600 the script stops and I get a 500 internal server error. I have tried multiple solutions to fix this problem: I increased the following php.ini settings:   * max_input_time   * max_execution_time   * memory_limit    * mysql.connect_timeout   * max_input_time   * post_max_size Increased the WP_MEMORY_LIMIT is wp_config.php:               define('WP_MEMORY_LIMIT', '128M');      And increased my time limit in wp_config.php too.               set_time_limit(240);      Tried it also with my htaccess file:               php_value max_execution_time 240      Debugged my bugs but I still got the 500 error. I contacted my host and they told me to set the `set_time_limit();` which I have set in function.php, in the file of my importer and wp_config.php, but no success. I viewed my php settings by `phpinfo();` and there I have a max_execution_time of 120. I have asked my host to increase it and still the same problem. This is my import script:               // Get results             global $wpdb;             $results = $wpdb->get_results( "SELECT * FROM stn_locations" );              if( $results ) {                  // Submit button clicked             if( isset( $_POST['submit'] ) ) {                      foreach( $results as $result ) {                          // Set variables                     $location_name      = $result->stnl_name;                     $location_longitude     = $result->stnl_longitude;                     $location_latitude  = $result->stnl_latitude;                     $location_country       = $result->stnl_country;                     $location_term      = $_POST['term'];                          // Content                     $location_content       = $_POST['stn_filter_import_content'];                     $location_content       = str_replace( '%%location%%', $location_name, $location_content );                     $location_content       = str_replace( '%%category%%', $location_term, $location_content );                          // Build post_title                     $post_title = $location_term . ' ' . $location_name;                          if( $location_country == $_POST['country'] ) {                              // Import data                         $import_data = array(                             'post_title'    => $post_title,                             'post_content'  => $location_content,                             'post_status'   => 'publish',                             'post_type' => 'filter',                         );                               // Insert post                         $post_id = wp_insert_post( $import_data );                              if( ! is_wp_error( $post_id ) ) {                                  // Set Term                             wp_set_object_terms( $post_id, $location_term, 'service' );                                  // Set meta fields                             update_post_meta( $post_id, 'longitude', $location_longitude );                             update_post_meta( $post_id, 'latitude', $location_latitude );                                  $success = true;                              } else {                             $error = true;                           }                               }                      }                      }     }      Does anyone have a solution, tip, setting or other function for me? Let me know! Thank you.


return page name in url

This the url format: `www.mysite.com/pageone` How do I get the page name? what is the wordpress function/method for this? bloginfo('name') return the site name. I want the function that returns (return not echo) the name of the current page.


Do not run this code on posts with a specific tag!

This is sort of complicated. I am looking for some php help related to WordPress blog. The basic requirement is that some HTML code (ad code) is not supposed to run on posts with a specific tag. In simple terms... I do not want to run ads in posts which have a specific tag! How can it be accomplished? I believe this would use this WordPress function: http://codex.wordpress.org/Function_Reference/has_tag I am not very proficient at PHP. I suppose this can be easily used to run specific code if the post has a specific tag. I want to do the opposite!


meta_query displays all results and none, my query is wrong

I´ve read almost this articles but unfortunately my query is no working, I think i´m very close but could be so far away. I´m trying to get metadata using a custom form with method get, $rob = $_GET['rob'];   $bedrooms = $_GET['beds'];   $bathrooms = $_GET['baths']; the array is $args = array( 'meta_query' => array( array( 'key' => 'beds_value', 'value' => '$bedrooms', 'compare' => 'LIKE',                       ),             array(             'key' => 'baths_value',             'value' => '$bathrooms',             'compare' => 'LIKE',                  ),             array(             'key' => 'rob_value',             'value' => '$rob',             'compare' => 'LIKE',                  ),               ),     );          $args = array_merge( $args , $wp_query->query );     query_posts( $args );      depending on final query the results are diferent this display none, seems to be this clean the query   $args = array_merge( $args , $wp_query->query ); query_posts( $args ); but if is used $query = new WP_Query( $args ); I get all results without any filter. but I can see the query data Ex 2 beds, 2 baths Do I need to write something more?


Choose User to email when adding a new post?

I am trying to find out a way to "email" users when a post is made? It would be nice to have a drop down menu or check box to check to "email that user" when Publishing a new post?? So I can just check one of the USERS to notify?? Anything like this available? I have found this as a plugin - Email Post Changes -- but it doesn't individualize each post??


Custom Post Type, Pagination and 404s?

Head is getting melted with this pagination crap in WordPress! What am I doing wrong here… **Test site** http://www.clients.eirestudio.net/savvas/reviews/ **Code**               <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     query_posts("post_type=bingo_review&posts_per_page=1&paged=$paged");     if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>        blah     <?php endwhile; ?>           <?php endif; ?>          <?php wp_paginate(); ?>


How to remove/exclude specific posts in a category from RSS feeds after particular date

I want to remove/exclude some posts of a category from RSS feeds after particular date. First of all i want to specify that same requirement i already accomplish for front page posts. I have two categories x and y and i am showing the posts of these categories on front page. I have created custom field name **'expiration'** in which i am giving the date like 2011/08/12 as value which will remove the particular post from front page on given date. Below is the code to remove particular post where custom field expiration is set.               <?php if (have_posts()) :query_posts($query_string .'&cat=3'); while (have_posts()) : the_post();              $currentdate = date("Ymd");             $expirationdate = get_post_custom_values('expiration');             if (is_null($expirationdate)) {             $expirestring = '30005050'; //MAKE UN-EXPIRING POSTS ALWAYS SHOW UP;             } else {                  if (is_array($expirationdate)) {             $expirestringarray = implode($expirationdate);             }             $expirestring = str_replace("/","",$expirestringarray);             } //else             if ( $expirestring > $currentdate )              {              // Enter your post display code after that.?>                 <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>" class="recent_news"><?php the_title(); ?>

<?php the_time('l, jS F Y'); ?> at <?php the_time('g:i a'); ?>
            <?php } endwhile; endif; ?>      In the above code you can see that '&cat=3' is mention which is my category X and similar for Category Y. Now come to the point how can i set the date once in custom field expiration for front page posts as well as RSS feeds. i used ( exclude ) tag whose id is ('7') on the posts and filter out but problem is when i put the exclude tag it immediately remove/exclude the post from RSS Feeds. I want to exclude on the basis of expiration date. Below is the function placed in function.php file which filter out the tag on basis of ID.               <?php function filter_feed_posts($query) {     if($query->is_feed) {          $exclude_tags = array(7);     $query->set('tag__not_in',$exclude_tags);     }     }     add_filter('pre_get_posts','filter_feed_posts');     ?>      Please help me to get this done. Your help is appreciated.


Clean links in: the_author_meta('description')

I need to clean any links returned from the_author_meta('description') The code I use is simply that:
<?php the_author_meta('description'); ?>
      I Searched old question but could not find the right anwer.. ideas anyone?


Secure Wordpress: Change admin

I'm sorry if this is an extremely stupid question. I've been looking for ways how to secure my WP and a lot of websites suggest to create a new admin user account and delete the old one. Now, if I use a different screenname as author (when writing comments etc.) - how could hackers still find out what my admin username is anyways? I'm just wondering if this step really makes sense unless your administrator username is "admin". Thanks a lot for clarification.


get_posts not working as expected

I'm trying to get posts from 3 different categories and list them on the front page:                 // Carousel articles       $args = array( 'numberposts' => 3, 'orderby' => 'date', 'category' => 'karusell' );       $carousel = get_posts($args);            // News articles       $args = array( 'numberposts' => 3, 'orderby' => 'date', 'category' => 'nyheter' );       $news = get_posts($args);            // Featured articles - max 2 posts       $args = array( 'numberposts' => 2, 'orderby' => 'date', 'category' => 'feature' );       $featured_posts = get_posts($args);      Then I output them by doing this:               foreach( $carousel as $post ) : setup_postdata($post);      // code here     endforeach;      My problem is that all my loops outputs the same posts. Am I using the wrong function for getting posts? I could use something like this:               query_posts("category_name=feature&posts_per_page=2&orderby=date");     while (have_posts()) : the_post();     //code     endwhile;      But I was hoping I could fetch all the articles at the top of my code and not "inline".


need help to arabic text in wordpress

I am doing a worpdress theme which is in Arabic language. When I write anything in Arabic. It turn into ????(question mark). Please help to fix this. Thanks


Run shortcode at certain resolution

I've gone a roundabout way of trying to ask a question about this here: Loading shortcode with ajax but figured it might be worth asking the fundamental question of what I am trying to do without adding my confused, naive problem-solving into the mix. I want to run this:               <?php echo do_shortcode('[metaslider id="8302"]'); ?>      But only if the window size is greater than, for example, 800px. Any ideas would be much appreciated!


the_content() returning null in one category only, even though there is content

A friend's heavily customized blog has a category with a specific `categoryname-single.php` file to display posts. Apparently for no special reason, since yesterday, `the_content()` is not returning any content any more for posts in that category, even though the WP back-end is clearly showing content in the post. All other categories are unaffected. What I have tried / excluded:   * There are no PHP errors: I have tried with `echo get_the_content()` instead, to no avail.   * I am working on the correct file: When I change something else in the file or hard-code some HTML text in it, it shows up on the page. That also excludes any caching issues                <? echo "start"; the_content(); echo " end"; ?> // outputs "start end";        * The content is physically missing, it's not just hidden or something: I have inspected the DOM using the DOM inspector, and looked into the HTML source. Where there is supposed to be content, there is nothing.    * This affects all articles in that category; none of them has been changed for weeks. They are all published.    * The problem is not caused by some shortcode that doesn't get parsed: I have tried entering pure text into a post, with the same results.   * There is no loop mix-up: `the_ID()` returns the correct post ID.   * The problem occurs for logged-in and not logged-in users.  There has been some installing and uninstalling of plug-ins yesterday, and some editing of files (although purely hygienic measures like removing superfluous comments and such) by the blog owner. I can't exclude that one of these things caused the issue, but I can't really see how. I'm at my wit's end. My questions:   * Is there any way to output the raw, unfiltered post HTML to find out whether this is a rogue filter deleting all the content in that specific category for some weird reason?   * What else could cause a wholesale deletion of content in one category only?   * Does anybody have any other ideas on how to debug this?


How to insert content from another Custom Post type into Post?

Say I have a custom post type called "Performers". This gets populated with different bands/performers. These posts have a featured image as well as custom fields (mp3 file, facebook link, myspace link, etc). I have another custom post type called "Events". When I create a new Event post, I would like the option to have a drop box to select one of the bands from the "Performers" custom post type. This will insert all data from the specific Band/Performer into the Event post (custom fields, featured image, etc.). What is the best method for inserting/injecting this sort of loop from the "Event" admin?


wp_insert_post hook for a wordpress plugin

I'm trying to make a wordpress plugin to auto-translate posts just before it's inserted, it's for a specific need where I want to write in a language, post in a different one, so far, I'm not able to hook the wp_insert_post, or I don't understand how to do this properly, I posted my hook code here, I note it's my very first plugin, I appreciate any help or helpful remarks. Mike,               function tr_insert_post($post, $wp_error = false)     {              $post ['post_title'] = "the title: ".$post ['post_title'];              return $post;     }               add_action('wp_insert_post', 'tr_insert_post',1,2);


Default archive URL wordpress

In wordpress you have a few 'default' archive URL's. Like for example: http://www.mydomain.com/2011/ generates an overview of the posts of (only) that year. If you have an category blogs the url http://www.mydomain.com/blogs/ generates an overview of all the posts within that category. (Spread over multiple pages) Now is my question is there any link which generates an overview of all posts (spread over multiple pages) starting with the newest first and going back in time? So not like the 2011 url, which only fetches from this year, but go's further back in time when applicable. My current permalink structure is:               /%category%/%postname%/      Thanks.


Changing Top Level Items into Radio Buttons in the Categories Meta Box?

I know it is possible to change the WordPress category list to radio buttons in the admin panel for posts, but I would like to make the just the Parents radio buttons and the sub categories or children checkboxs... something like this.

<input type="radio"> Category 1

<input type="checkbox">Category 1 - Sub Cat 1

<input type="checkbox">Category 1 - Sub Cat 2

<input type="radio"> Category 2

<input type="radio"> Category 3

<input type="radio"> Category 4

<input type="checkbox">Category 4 - Sub Cat 1

<input type="checkbox">Category 4 - Sub Cat 2

<input type="radio"> Category 5

      I don't really want to mess around with the core files and wondered if anyone knows a way to override the output via the theme functions or another method.


CSS not updating in browser when I change it

I am working on the CSS of my wordpress site. When I make changes and refresh the page the changes are not reflected. When I clear the browser history and cache the changes are still reflected. When I view the source code of the page and look at the css file it has the old content before the change. How do I get this to update so I can develop?


2 small questions: How to redirect to a created page & show that pages title in wp, bp

im trying to redirect the loggedin user to a page i created on the backend, i want to use my index to do so so, i added a `do_action` wrapped in an if statement `is_user_loggedin()` to call my function. here's the function:               function my_redirect() {       global $bp;           if ( $bp->current_component == $bp->root_domain ) {       bp_core_redirect($bp->current_component == MY_CUSTOM_SLUG  );       }      }      but it's not working. The page shows when you navigate to it, but it wont redirect when viewing the root page (index). Here's whats in the index.php                <?php if ( is_user_logged_in() ) : ?>           <?php do_action( 'my_redirect'); ?>           <?php endif; ?>      Thanks ahead of time :)


How to display related posts from same category?

Is it possible to display related posts from same category as the current post?


WordPress auto update for core but use local package

I have several local WordPress dev environments but, for the moment, a very very slow internet connection. The WordPress auto updater for core is very convenient, but would it possible for it to use update packages from localhost instead of downloading it for every site?


Where can you find the available filter tags?

In my attempt to alter navigations current-menu-item class, I found a possible solution http://stackoverflow.com/a/7941864/520265 ,               add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1);      He makes use of a filter who is called with a tag 'nav_menu_css_class' , But it got me wondering, where can you find information about what filters are available to use? http://codex.wordpress.org/Function_Reference/wp_nav_menu does not mention anything about filters...


List terms of custom taxonomy if matches other taxonomy

So the title is confusing but I can't think of a better way to word it. Basically, I have two taxonomies of "state" and "city" (that have to stay separate for other reasons). Lets say for instance, a term in the taxonomy of "state" is "Connecticut" I then want to display a list of terms from the taxonomy of "city" that populate only from posts with the "state" term as "Connecticut". Basically, I want to dynamically call the state and display the cities in the sidebar on the archive page... I know, this sounds really confusing. This code works but obviously causes duplicates, I would like each one only listed once.               <?php     $pterms = get_the_terms( $post->ID, 'property_location' );          if ( $pterms && ! is_wp_error( $pterms ) ) :           $prop_links = array();          foreach ( $pterms as $el_term ) {         $prop_links[] = $el_term->name;     }          $st_location = join( ", ", $prop_links );        ?>     <?php endif; ?>     <?php endwhile; ?>                    <?php     $args = array(      'post_type' => 'property',      'post_status' => 'publish',      'posts_per_page' => -1,      'property_location' => ''.$st_location.''     );     $the_query = new WP_Query( $args ); ?>     <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
<?php echo get_the_term_list( $post->ID, 'city', '', '', '' ); ?>
           <?php endwhile; ?>      Any suggestions?


Conditional Tags for Membership Levels when using Wishlist Member Plugin?

I am currently using a plug-in called Wishlist member. It allows you to create membership levels in WordPress. I want to be able to display different content on a page depending on the membership level of the viewing user. Something like this -               <?php global $current_user; get_currentuserinfo();      if ($current_user->user_level == 10 ) { ?>       Admin Stuff (In my case I left this blank)     <?php } else {   ?>       Stuff Seen By Visitors     <?php } ?>      But not just for the admin. I have found that this plug-in create creates these for each member level "wpm_access[1296320588]" and "wpm_level[1296320588]". Any ideas on how I could check the current user against this? Thanks!


How to apply a class to the second word in menu list item?

I want to apply a class to a word in my menu. For example, say I have a list item in my menu called "My Item". I would like to apply a class to the word "Item" so that I can style it anyway I want. Do I need to add a span to the list item and then add the class to my css like this?

My Item

          #nav ul li a.dark-blue {         color: #00008B;     }


Display first name instead of username

I have a plugin that outputs username after login, I want it to display first name instead. Here is the code that does it.                       global $userdata,$user_identity;             get_currentuserinfo();                  if ($userdata->ID>0) {                 // User is logged in                 echo '
' . $before_widget . $before_title . "Welcome ".$user_identity . $after_title . '
';                 echo '

Logout

Dashboard

Profile

                 ';             } else {             // User is NOT logged in!!!                     echo $before_widget . $before_title . '
Welcome Guest, Login
' . $after_title;      $user_identity is what outputs that username I searched through wordpress forums and someone said I have to add `$current_user->first_name` to the code. The question is, where and how do I add it? I assume I would need to add it to this line `global $userdata,$user_identity;` But how do I properly syntax that? I tried doing this but getting syntax errors `global $userdata,$user_identity = $current_user->first_name;` Your help is highly appreciated.


Hooking custom PHP output into WP: how to do it, parse_request almost works but not quite

I'm new to wordpress, so chances are I'm missing something pretty basic here. I'm trying to write a plugin which uses custom PHP code to generate output. I managed to get this working on the admin-side, but on the user side a properly working solution eludes me. I've managed to find the following 2 hooks to use:               add_action ('parse_request', 'myPluginFunc');     add_action ('wp', 'myPluginFunc');      When I call index.php?MyPlugin=myPluginFunc this works in the sense that myPluginFunc() is called and it's output is echoed back on the screen, _however_ the output is placed _above_ the main theme output area (right below the top black WP menu bar). So: How do I display output generated by a custom PHP function (output which is not a Post) on the main display area of the page? What hooks do I use to achieve this? Any pointers would be much appreciated. Greetings/Thanks Robert


Custom Post Type, limit to one

I'm using custom post types for a few pages where I have a very customized template...but I only need one of each post (maybe not the best way to go about this...but it's built so I'd like to not have to change this). Is there a way to remove the "Add New" link on the **left side admin menu** just so the user doesn't keep making more than 1 version of this post? I'm okay with the "Add new" inside the actual page as that seems a bit harder to find.


Running a function on comment status change

I am making a review system where i need to find update rating average when:   * A comment gets approved from pending/trash/spam.   * A comment gets upapprove from approve   * A admin post reviews (auto approved)   * A comment gets edited (from backend or frontend custom dashboard when user wants to edit/update/remove his already made review) **Here is the code i've written:**               add_action('edit_comment', 'update_business_rating_avg');     add_action('comment_post', 'update_business_rating_avg');     add_action('comment_unapproved_to_approved', 'update_business_rating_avg');     add_action('comment_approved_to_unapproved', 'update_business_rating_avg');     add_action('comment_spam_to_approved', 'update_business_rating_avg');     add_action('comment_approved_to_spam', 'update_business_rating_avg');              function update_business_rating_avg($comment){             //fb($comment);             $post_id = $comment->comment_post_ID;             $post_type = get_post_type($post_id);             if('business' == $post_type){             //fb($post_type);                 $args = array(                                         'post_id' => $post_id,                                         'status' => 'approve'                             );                 $comments = get_comments($args);                 $total_ratings = 0;                 $avg = 0;                 foreach($comments as $comment){                     $total_points += get_comment_meta($comment->comment_ID, 'rating', true);                         $total_ratings++;                 }                 if($total_ratings > 0){                     $avg = $total_points/$total_ratings;                     $avg = (float)$avg;                 }                 $avg = roundToNearestFraction($avg,0.5);                 update_post_meta($post_id, 'avg_rating', $avg);             }         }      **Problem:**   * I am still missing something because when an admin post a review the function not triggered (Its gets auto approved).   * Check the function `update_business_rating_avg()` and how I use `get_comment_meta()` inside foreach. Is it performance killing? Is there a better way to do this? Custom SQL parhaps? Appreciate your help, Thanks! **SOLVED:** _Final Code_ Thanks to @Soulseekah to send me to right direction. Here is final code for the solution if someone needs it in future. The SQL is a complex one because i had to JOIN both `wp_comments` and `wp_commentmeta` to compare approved comment and comment associated with the current post ID.               add_action('edit_comment', 'update_business_rating_avg');     add_action('comment_post', 'update_business_rating_avg');     add_action('comment_unapproved_to_approved', 'update_business_rating_avg');     add_action('comment_approved_to_unapproved', 'update_business_rating_avg');     add_action('comment_spam_to_approved', 'update_business_rating_avg');     add_action('comment_approved_to_spam', 'update_business_rating_avg');     add_action('comment_approved_to_trash', 'update_business_rating_avg');     add_action('comment_trash_to_approved', 'update_business_rating_avg');          function update_business_rating_avg($comment){         if ( !is_object( $comment ) ){             $comment = get_comment( $comment );         }              $post_id = $comment->comment_post_ID;         $post_type = get_post_type($post_id);         if('business' == $post_type){             $avg = 0;             global $wpdb;             $query = "SELECT AVG(meta_value) FROM $wpdb->commentmeta ";             $query .= "INNER JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID " ;             $query .= "WHERE $wpdb->commentmeta.meta_key = 'rating' ";             $query .= "AND $wpdb->comments.comment_approved = 1 ";             $query .= "AND $wpdb->comments.comment_post_ID = '$post_id'";                  if( $result = $wpdb->get_var($wpdb->prepare($query)) ){                 $avg = roundToNearestFraction($result, 0.5);                 update_post_meta($post_id, 'avg_rating', $avg);             }else{                 // report error                 //$wpdb->print_error();             }         }     }


2 seperate installation 1 theme same server

i got 2 separate installation on the same folder   each in their own sub folder - they use the same theme   which i copied twice. Every time i edit a file i need to do it twice and its   a real hassle... How can i define so that they both   use the same theme - a shared theme but a different   database? I have no "initial code" to share since i don't know   where to begin so an example code would be much appreciated


Getting taxonomy images to display on single-post with their terms

Having some trouble with taxonomy images plugin. I am on single-post.php and I want to display my post's taxonomy terms & the term's associated images. Ideally, I'd like the taxonomy description there too. No idea why this has me stumped because it seems like it should be a simple thing to do. I have this code, which displays just the post's term's images:               $terms = apply_filters( 'taxonomy-images-list-the-terms', '', array(                 'taxonomy' => 'comedians',             ) );                  foreach( (array) $terms as $term){                 echo $term;             }      I also have this, which displays the post's terms:                       print get_the_term_list( $post->ID, 'comedians', '
', ',

', '
' );      And then I have this code, which displays all of the term's images, with the terms & links & descriptions:               $terms = apply_filters( 'taxonomy-images-get-terms', '', array(                 'taxonomy' => 'comedians',             ) );             if ( ! empty( $terms ) ) {                 print "\n" . '
';                 foreach( (array) $terms as $term ) {                     print "\n" . '
';                     print "\n\t" . 'image_id ) . '" rel="lightbox unique-woo-feature">' . wp_get_attachment_image( $term->image_id, 'unique-woo-feature' ) . '';                     print "\n\t" . '
' . esc_html( $term->name ) . '
';                     print "\n\t" . '
' . esc_html( $term->description ) . '
';                     print "\n" . '
';                 }                 print "\n" . '
';             }      What I need is something in between. I understand the crucial part is the filter, specifically the difference between `get-terms` and `list-the-terms` but the latter one, which gets the post's terms like I need, doesn't seem to do anything but just the images no matter what I do. Any help with this, much appreciated.


How to Filter Facebook Plugin to Post a Specific Only Custom Post Type

I am using WordPress Facebook plugin to post my new posts from WordPress to my Facebook Page. So far everything works perfectly and I set up an app on my Facebook to integrate with my WordPress. Now my question is, is there any way to filter the plugin to ONLY post just one specific Custom Post Type, lest's call it "News", to Facebook and not the other post from WordPress native Post or even any other


How to integrate external user tables with WP?

I have about 10K+ users that I get from a company feed (LDAP). I can authenticate WP via SSO based on someone's username matching on the WP user table. I would like to take the user table I have and combine it with the wp- user table so that I can set permissions, change display name and things like that. Is there a best way to do this? Also we have about 15 WP installs and will probably have 30 by mid next year. How can I manage these users in one table given that some may have admin rights on one site yet not admin rights on another site?


VERY weird problem with switch in meta box

I created a new custom meta box and everything work well (saving, outputting) but I don't get any change when I try to add some lines of code to the switch statement For example: when I delete few 'cases' from the 'switch' statement no changes taking place... or even when I add new class to an input inside the switch, still I get no changes Here is the full code:               $prefix = 'ks-';     $header_meta = array(       array(         'name' => 'header-options',         'id' => $prefix . 'header-options',         'type' => 'radio',         'options' => array(             array('name' => 'Show Page Title', 'value' => 'title-true'),             array('name' => 'Hide Page Title', 'value' => 'title-false'),             array('name' => 'Fancy Header', 'id' => 'fancy-header-setting', 'value' => 'fancy-header'),             array('name' => 'Slideshow', 'value' => 'slideshow')         )     ),     array(         'name' => 'header-effect',         'id' => $prefix . 'header-effect',         'type' => 'radio',         'options' => array(             array('name' => 'Normal', 'value' => 'normal'),             array('name' => 'Overlaping', 'value' => 'overlaping')         )     ),     array(         'name' => 'Text box',         'desc' => 'Enter something here',         'id' => $prefix . 'text',         'type' => 'text',         'std' => 'Default value 1'     ),     array(         'name' => 'Textarea',         'desc' => 'Enter big text here',         'id' => $prefix . 'textarea',         'type' => 'textarea',         'std' => 'Default value 2'     ),     array(         'name' => 'Select box',         'id' => $prefix . 'select',         'type' => 'select',         'options' => array('Option 1', 'Option 2', 'Option 3')     ),     array(         'name' => 'Radio',         'id' => $prefix . 'radio',         'type' => 'radio',         'options' => array(             array('name' => 'Name 1', 'value' => 'Value 1'),             array('name' => 'Name 2', 'value' => 'Value 2'),             array('name' => 'Name 3', 'value' => 'Value 3')         )     ),     array(         'name' => 'Checkbox',         'id' => $prefix . 'checkbox',         'type' => 'checkbox'     ),     array(         'name' => 'Colorpicker',         'id' => $prefix . 'colorpicker',         'type' => 'text',         'default' => '#ffffff',         'class' => 'ks-display-colorpicker',       )     );          // Meta box output html     function ks_header_settings_display( $post ) {       global $header_meta, $post;       echo '
';       foreach ($header_meta as $field) {          // get current post meta data          $meta = get_post_meta($post->ID, $field['id'], true);          echo '
',                 '', $field['name'],    '	',                 '';         switch ($field['type']) {             case 'header-options':                 echo '<input type="radio" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />', '
', $field['desc'];                 break;             case 'header-effect':                 ?>
<?php                 echo '<input type="radio" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />', '
', $field['desc'];                 break;             case 'text':                 echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />', '
', $field['desc'];                 break;             case 'textarea':                 echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>', '
', $field['desc'];                 break;             case 'select':                 echo '<select name="', $field['id'], '" id="', $field['id'], '">';                 foreach ($field['options'] as $option) {                     echo '<option ', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>';                 }                 echo '</select>';                 break;             case 'radio':                 foreach ($field['options'] as $option) {                     echo '<input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'];                 }                 break;             case 'checkbox':                 echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';                 break;             case 'colorpicker':                 echo '

';                 echo '

';                 break;             ?>
<?php         }         echo     '	',             '
';     }     echo '
';     }          // Save metaboxes     function ks_save_pagedata( $post_id ) {      global $header_meta;           // Verify the nonce before proceeding      if ( !isset( $_POST['ks_page_header_nonce'] ) || !wp_verify_nonce( $_POST['ks_page_header_nonce'], basename( __FILE__ ) ) )         return $post_id;           // If this is an autosave, our form has not been submitted, so we don't want to do anything      if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )         return $post_id;           // Check the user's permissions      if ( 'page' == $_POST['post_type'] ) {         if ( ! current_user_can( 'edit_page', $post_id ) )             return $post_id;      } else {         if ( ! current_user_can( 'edit_post', $post_id ) )             return $post_id;      }           // Save data      foreach ($header_meta as $field) {         $old = get_post_meta($post_id, $field['id'], true);         $new = $_POST[$field['id']];         if ($new && $new != $old) {             update_post_meta($post_id, $field['id'], $new);         } elseif ('' == $new && $old) {             delete_post_meta($post_id, $field['id'], $old);         }       }          }     add_action( 'save_post', 'ks_save_pagedata' );      Here is a screenshot of the meta box ![enter image description here](http://i.stack.imgur.com/SDmoa.png) Thanks   Michael K.


Move Jetpack Stats dashboard widget to right side

is there anyway to move this? I've followed the instructions in the WP docs to no avail.. /               / Global the $wp_meta_boxes variable (this will allow us to alter the array).     global $wp_meta_boxes;          // Then we make a backup of your widget.     $my_widget = $wp_meta_boxes['dashboard']['normal']['core']['{dashboard_stats}'];          // We then unset that part of the array.     unset($wp_meta_boxes['dashboard']['normal']['core']['{dashboard_stats}']);          // Now we just add your widget back in.     $wp_meta_boxes['dashboard']['side']['core']['{dashboard_stats}'] = $my_widget;


WP Plugin Running before jQuery

I'm having problems with jQuery and a plugin, the console error says jQuery is not defined. What I don't understand is it only fails when I load it to the production server, on my local dev installation it worked perfectly. > ReferenceError: jQuery is not defined. The plugin code:               add_filter( 'wp_footer', 'enqueue_footer_scripts', 9);     add_filter( 'wp', 'enqueue_styles', 11);          function enqueue_footer_scripts() {         wp_register_script( 'sjs', plugins_url('/js/sjs.js', __FILE__), array('jquery'));         wp_enqueue_script( 'sjs' );         echo "<script>jQuery(document).ready(function ($) { $('p').sJS();});</script>";      }          function enqueue_styles() {         wp_register_style('sjcss', plugins_url('/css/sjs.css', __FILE__), false, '2.1');         wp_enqueue_style('sjcss');     }


Site transferred to new server produces 404s

I have transferred my site to a new server. I can login to wp-admin ok and can view the home page but all other pages produce 404s. I have changed the 'Home' and 'Site URL' options in the settings area but this makes no difference. Does anyone know how to amend this?


Can free plugin on WordPress.org site promote pro-version of this plugin?

* **Can free plugin onWordPress.org site promote pro-version** (not free version) of this plugin? Or it requires special permission from WordPress team? _Example: "All in one seo pack" plugin_   * Can one free plugin on WordPress.org promote other pro-version plugin on another site?   * What type of licence pro-version plugin should be?   * Is there any official WordPress docs about it? Can somebody explain more detailed the quote of Mika Epstein?: > All plugins must be GPLv2 compatible. You can sell 'em on your own site, you > can even upsell them from wordpress.org provided you're not crippling the > free plugin. GPL being 'free' isn't about cost, change what you want.


I used the Buddypress Message Compose to send a site wide email to all members wasnt sent though. Where would I look to see why messages were not delivered to all site members of my buddypress wp site? Can I configure this to use smpt instead? I researched this some and found others have had similar problems with the "send to all" from the buddypress message compose screen but couldn't find solutions. I am thinking it may have something to do with the wp config file and how emails configured? Thanks


Email notifications: Where in database to save user options?

I'm working on an email notifications plugin which sends emails when events happen on my site. So for example, if someone comments on a post, the post author will receive a custom email notification. There will be about 5 or 6 different types of email notification sent out. I'm planning to let authors disable notifications via a form containing radio button options such as:   * Would you like to receive an email when someone comments on your posts? Y - N   * Would you like to receive an email when someone mentions you in a comment e.g @username? Y - N etc... Where in the database would you recommend I save these user options? I was thinking about user meta but is there somewhere more suitable?


Pages, aside from admin-side and the home page, read "500 Internal Server Error - nginx/1.1.19".

I've set up a WordPress website. I'm able to login, and browse the front page- but everything but the admin-side brings me to a white page with the texts "500 Internal Server Error - nginx/1.1.19". I've read up on this and can't seem to solve the issue. I'm unable to find the .htaccess, even with my FileZilla forcing the showing of hidden files. I read that you may have to enable 'fancy' permalink, so I did, but it held no results.


Inject post (from specific category) between posts in Loop

I would like to add a post (from specific category) between posts in the WordPress Loop (such as 'Sponsors'). Example: P P P S   P P S P   P S P P How can I achieve this? I am a beginner with coding, so I don't know enough to modify a Loop on my own. Any Loop Coding Ninjas out there that can provide a solution? Note that below is my current Loop. It is used to sort posts by price, or by random order: index.php               <?php while (have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?>
     <?php  the_excerpt(); the_meta ();     endwhile;           previous_posts_link();     next_posts_link();     ?>      functions.php               function my_custom_query($query){      if ( $query->is_home() && $query->is_main_query() ) {            $sort= $_GET['sort'];            if($sort == "A"){        $query->set( 'orderby', 'rand' );        $query->set( 'posts_per_page', '2' );       }            if($sort == "B"){        $query->set( 'meta_key', 'price' );        $query->set( 'orderby', 'meta_value_num' );        $query->set( 'order', 'DESC' );        $query->set( 'posts_per_page', '2' );       }     }     }          add_action( 'pre_get_posts', 'my_custom_query' );      **Edit: Update** Birgire's plugin works! Initially, I had problems getting the plugin to work on my theme. The problem was this piece of code that I use within the Loop in index.php (I use it to call for the custom field to appear).               <?php         global $wp_query;         $postid = $wp_query->post->ID;         echo get_post_meta($postid, 'price', true);         wp_reset_query();     ?>


can't customize facebook sharing basic properties

How can I populate opengraph meta tags with actual post data? How does it work? Right now I have this on my single post template:

      It shows the sharing buttons with counters but it gets a random (i suppose) image from the page. I tried to use a function that was supposed to add the open graph meta tags:                   //Adding the Open Graph in the Language Attributes     function add_opengraph_doctype( $output ) {             return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';         }     add_filter('language_attributes', 'add_opengraph_doctype');          //Lets add Open Graph Meta Info     function insert_fb_in_head() {              global $post;              if ( !is_singular()) //if it is not a post or a page             return;              echo '<meta property="fb:admins" content="912649817492374"/>';         echo '<meta property="og:title" content="' . get_the_title() . '"/>';         echo '<meta property="og:type" content="article"/>';         echo '<meta property="og:url" content="' . get_permalink() . '"/>';         echo '<meta property="og:site_name" content="Vida Nova Imóveis"/>';              if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image             $default_image="http://example.com/image.jpg"; //replace this with a default image on your server or an image in your media library             echo '<meta property="og:image" content="' . $default_image . '"/>';         }else{             $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );             echo '<meta property="og:image" content="' . esc_attr( $thumbnail_src[0] ) . '"/>';         }         // echo "";     }     add_action( 'wp_head', 'insert_fb_in_head', 5 );      But nothing is added to the header. The function that adds the opengraph_doctypes works though. I deactivated all plugins from the website and it still doesn't work. How can I pass the post data (image/title/description) to the open graph meta tags? How does it work? Am i obligated to register an app on Facebook to be able to simply share a page with a custom title / image / description? Thanks alot


Storing user meta as an array, empty array index shows as "Array" on front end

I am storing user meta data as a single entry in the DB as an array. If any of the array index values are empty, when I display the empty data it shows up as "Array". In particular in my user update form on the front end. I've tried setting a default value of '' but I still can't get the user meta value in the form to just be empty. It always shows as "Array" How can I fix this? Thanks in advance EDIT ----------------------------------------------------------------- Here's my code for saving the meta data. Nothing special just the default saving. The Name attribute of my user fields are set up like this meta_key_name[inner_meta_key][inner_inner_meta_key_name] Not all inner_meta_key have an inner_inner_meta_key               //each $_POST is a      foreach( $_POST as $meta_key => $meta_value ):                                //delete old meta value         delete_user_meta( $user_id, $meta_key );                  //use new meta value to update/add         update_user_meta( $user_id, $meta_key, $meta_value );               endforeach;      And my code to display/retrieve the meta values               function ds_get_user_data( $user_id, $meta_id, $key1 = NULL, $key2 = NULL ){                   //$meta_id is the key that stores the array of data as a single value in the wp_usermeta table         $meta = get_user_meta($user_id, $meta_id, true);                   if( $key1 && $key2 )             return isset($meta[$key1][$key2]) ? $meta[$key1][$key2] : false;         elseif( $key1 )             return isset($meta[$key1]) ? $meta[$key1] : false;         else             return $meta;               }//end ds_get_user_data


What do I need to do to fully integrate a custom session login into WP?

I have a very simple session login using my company's SSO. I just take their authenticated username and sign them in with no password. Right now this sits as a single page. We have 7 used WP installs and counting and would like an easy way to ensure that:   1. It doesn't cause issues with plugins or themes or whatever.   2. User gets proper error reporting   3. The login lasts as long as possible   4. Bonus would be adding user to database if they are not in the WP database already.              require('wp-blog-header.php');                 session_start();                             $appKey = "xxxxxxxxxxxxxxxxxxx";         $safeurl =  'https://safe.xxxxxxxxxxxxxxxxxx.com/login/sso/SSOService?app=playbooks';         // first call back after safe login - POST is set         if ($_POST && isset($_POST['digest']))          {          $digest = $_POST["digest"];          // set the session variables ...          $_SESSION['usernamef1'] = $_POST["firstname"]." ".$_POST["lastname"];          $_SESSION['firstname'] = $_POST["firstname"];          $_SESSION['lastname'] = $_POST["lastname"];          $_SESSION['email'] = $_POST["email"];          $_SESSION['uid'] = $_POST["uid"];         // Needed for key          $uid = $_POST["uid"];          $time = $_POST["time"];          // Read the property file with the key and URL so this won't go into the main code ...          // this sets $appKey and $safeurl          $mykey = "".$uid.$time.$appKey;          $mydigest = md5($mykey);         }             // session is not initialized as we never got the post above to set session vars         // call now the safe login to get the post to set the session vars ...         if (!isset($_SESSION['usernamef1']) || empty($_SESSION['usernamef1']))         {          // Read the property file with the key and URL so this won't go into the main code ...          // this sets $appKey and $safeurl          header("Location: ".$safeurl);         }                      $username = $_SESSION['uid'];         $user = get_user_by('login', $username );             // Redirect URL //         if ( !is_wp_error( $user ) )         {             wp_clear_auth_cookie();             wp_set_current_user ( $user->ID );             wp_set_auth_cookie  ( $user->ID );                  $redirect_to = user_admin_url();             wp_safe_redirect( $redirect_to );             exit();         }


Create a post variable processing page

I need to create a blank PHP page that processes a POST request. Basically, a site will send me a few post variables. I need to use these variables with the mycred plugin. Here is my code:               require_once("../../../../wp-load.php");     if (isset($_POST['reward_amount'])) {          $toaward = $_POST['reward_amount'];         $user = $_POST['sid'];              if (!function_exists(mycred_add))                 echo "Failed to add!";         if (mycred_add('Points_for_______________', 1, 1, '%plural% for ------ completion', $_POST['oid'] )) {                 echo "Success!";                 //header("HTTP/1.1 200 OK");         } else {                 echo "Fail!";                 //header("HTTP/1.1 412 Precondition Failed");         }     }      This works, but the site I am using does not allow HTML to be returned in the HTTP response. How do I remove the HTML code that is included from `wp- load.php` but still keep the Wordpress function support so I can use wordpress functions? I also tried including `wp-blog-header.php` as well, but to no avail.


Custom posts affecting Recent Posts

I have built a plugin that uses custom post types. Everything works exactly as it should except when you list posts by category; the recent post widgets just displays the recent custom posts type. http://testblog.co.uk/events-list/ \- All OK (these are the custom posts) http://testblog.co.uk/category/derek/ \- Only Recent custom posts display The plugin has a wp_query call:               $args = array('post_type'=>'event','orderby'=>'meta_value_num','meta_key'=>'event_date','order'=>'asc','posts_per_page'=>-1);     query_posts( $args );      But I can't see how this would affect things. Any suggestions as to where I should start looking? EDIT: Not using pre_get_post so that's not the issue. I do use:               $output_string = ob_get_contents();     ob_end_clean();     return $output_string;      after clearing the query but when I removed this it made no difference. It was a user that alerted me to the problem so it's not my theme (although I have tested using 2014 and all other plugins deactivated). It's got to be a reset not firing in the right place... EDIT 2: Debug is now on and apart from a few undefined variables there isn't anything being reported. EDIT 3: The 'recent posts' list that appears seems totally random. It displays posts and events and deleted items - most bizarre, Debugging is complete - there is one warning related to another plugin that can be ignored. Taxonomy is               $args = array('taxonomies' => array('category','post_tag'));register_post_type('event',$args);      Obviously a lot more labels and args in the plug8in but that's the only reference to categories. Tested using 'tags' and archive queries and al lis ok. So it's only to 'category' queries. Removing the category from the CPT taxonomy makes no difference.


Use WP_Filesystem to list files in directory

Is there a way to list files in a directory using WP_filesystem instead of something like:               function listFolderFiles($dir){         $ffs = scandir($dir);         echo '
';         foreach($ffs as $ff){             if($ff != '.' && $ff != '..'){                 echo '
'.$ff;                 if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff);                 echo '
';             }         }         echo '
';     }          listFolderFiles('Main Dir');      I want to list all the files and folders in my uploads folder so I was writing something like:               class ff     {         public static function listFolderFiles($dir)         {             $ffs = scandir($dir);             echo '
';             foreach($ffs as $ff){                 if($ff != '.' && $ff != '..'){                     echo '
'.$ff;                     if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff);                     echo '
';                 }             }             echo '
';         }     }     $upload_dir = wp_upload_dir();      return New ff::listFolderFiles($upload_dir['basedir']);      but wanted to see if there is a better way..


add_image_size() width not actually working

I've been attempting to add an image size to my code, for an image that needs to be 708px wide. Height can be variable. I've added the code this way:               add_image_size( 'full-blog-width', 708 );      add_filter( 'image_size_names_choose', 'my_custom_sizes' );          function my_custom_sizes( $sizes ) {         return array_merge( $sizes, array(             'full-blog-width' => __( 'Full Blog Width' ),         ) );     }      However, when I go to add the images in the media library, the width seems to max out at 474px with the height varied based on proportions. I've attempted hard cropping, but that doesn't seem to affect anything but the ratio in the end. Best I can tell, this 474 number comes from the is the width of the blog post container. Does the media library set a maximum size for the images based off the blog post CSS? Is there a way to override this?


xypic on Wordpress

Is it possible to use xypic on Wordpress (for those who don't know what xypic is, it's a LaTex tool for drawing diagrams- see Wikipedia)? On a related note, is it possible to use the LaTeX package chemfig on Wordpress?


Get post id in wordpress action?

I have this code               add_action( 'delete_post', 'my_delete_function' );      function my_delete_function() {         global $wpdb;        $wpdb->query("         DELETE FROM wp_votes WHERE post=".$thePostID."     ;);      }      How can I get the id of the post being deleted? Additionally, will this still work if multiple posts are deleted in the admin?


How to load JQuery easing script in wordpress?

Ok, first of all, I know how to do this manually.   I could just download easing, place it in my plugin folder and load it using `wp_enqueue_script`. However, I want to load my script in a long-term way, ensuring that I use the same version of the easing script wordpress uses. So what I am looking for, is a way to load easing in wordpress using `wp_enqueue_script`, as seen below. I have looked at the function reference for `wp_enqueue_script`, but I can't seem to find the right file/handle to enqueue. Is there anyone who knows how to load the WordPress-native easing script?               //I know this works because I've used it a thousand times already     wp_enqueue_script("jquery");          //I want something like this without having to use my own script     wp_enqueue_script("jquery-easing");


Avoid converting ">" to >

I'm using a Markdown plugin and trying to write a blockquote > Like this But Wordpress converts ">" to an html entity, so the result looks > like this Is there a way to avoid this?


Wordpress protected Pages

Would be possible to access the protected pages with password through of a token. What I mean I pass the token by URL, is going to be checked if the page is protected, if yes check if the URL has the token than the token to be check if match or not.


A plugin for newsletter registration (not sending, just gathering data)?

Most of the plugins I see also send the newsletter, which I don't need. I need a simple, customizable plugin that helps me get user e-mails, name, and other custom fields, and store it in the database. The plugin must also have an unsubscribe option, of course.


As a plugin developer, how to deal with theme developer loading jquery from google?

Theme developers like to deregister wordpress jquery and load jquery from google instead. I've been told it is for speed and I agree. This usually is not a problem **for me** since I always use **jQuery** instead of **$**. But I do see some plugins try to use **$** , well, it generates javascript error and also makes my plugin not working. As a result, clients blame on innocent me. Sometimes my js code depends on the version of wordpress jquery but theme developers tend to load **a specific version** from google. Even though the theme is updated, they may not update the jquery version, not to mention an old theme. **What should I do in such situations?** Actually, I'm thinking about, maybe I should use Zepto.js instead and include it in my js code. p.s. good news, wordpress 3.6 doesn't allow deregister jquery in its backend.


WP custom menus error > menu name already exists?

I'm getting a puzzling error when I var_dump on $menu_id in the code below... First, the test code to create a custom menu on the fly and assign it to a registered menu location called "header-menu" (creates the menu but fails in assigning it to the theme's menu location)...               $menu_id = wp_create_nav_menu('my_test_menu_abc_123');     //var_dump($menu_id);die;     wp_update_nav_menu_item($menu_id, 0, array(         'menu-item-title' => 'First Menu Item',          'menu-item-url' => 'http://mysite.com',          'menu-item-status' => 'publish'));     $theme = get_current_theme();     $mods = get_option("mods_$theme");     $mods['nav_menu_locations']['header-menu'] = $menu_id;     update_option("mods_$theme", $mods);      When I var_dump on $menu_id below, its returning... > object(WP_Error)#110 (2) { ["errors"]=> array(1) { ["menu_exists"]=> > array(1) { [0]=> string(102) "The menu name my_test_menu_abc_123 conflicts > with another menu name. Please try another." } } ["error_data"]=> array(0) { > } } It does not matter what I name the menu, I'm always getting this error. Which leads me to believe I have a flaw in the logic of my code below. Although, it still creates the menu fine, and inserts the menu item into it. It just fails to assign the menu to the theme's header-menu location. Any ideas? **Background** : Thanks to the help of @Bainternet, I've managed to come pretty close to a solution. What I'm trying to do is to programmatically create a new custom menu on the fly **[solved]** , then assign that menu to one of my theme's registered "Menu Locations" [ **still not solved** \- and no one else appears to be able to do this], all via script inside a plugin. However, eve though the code above will create the my_test_menu_test perfectly, its not assigning it to the "header-menu" location of the theme. My first clue to a problem, is the fact that the echo statement appears to be in conflict with the code I'm using to create the menu. Here is an external reference I've been using... http://wordpress.org/support/topic/how-to-assign-a-wordpress-3-menu-to- primary-location-programmatically However, its unclear whether the author's solution actually works for anyone else (according to my experience and that of the other responders on the post)... _Interestingly, as some have noted, the assignment of a custom nav menu to a theme's custom menu locations does not appear to be included in the Custom Menu API..._


Get ID of "root-page"

I have an url that looks like this http://apploadny.appload.nu/tjanster/webbutveckling/ I want to get the ID of the page "tjanster", how can i do that?


Metabox doesn't retain values

I have this code in functions.php in order to have a meta box displayed in the backend. The problem is, this was functioning normally until I've moved the website from a subdomain (dev) to the root and now even if the metabox appears in the backend, it doesn't retain the values anymore.               <?php     define('MY_WORDPRESS_FOLDER',$_SERVER['DOCUMENT_ROOT']);     define('MY_THEME_FOLDER',str_replace('\\','/',dirname(__FILE__)));     define('MY_THEME_PATH','/' . substr(MY_THEME_FOLDER,stripos(MY_THEME_FOLDER,'wp-content')));          <?php     define('MY_WORDPRESS_FOLDER',$_SERVER['DOCUMENT_ROOT']);     define('MY_THEME_FOLDER',str_replace('\\','/',dirname(__FILE__)));     define('MY_THEME_PATH','/' . substr(MY_THEME_FOLDER,stripos(MY_THEME_FOLDER,'wp-content')));          add_action('admin_init','my_meta_init');          function my_meta_init()     {         $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;         if ($post_id == '2') {         foreach (array('post','page') as $type)          {             add_meta_box('my_all_meta_home', 'Additional info', 'my_meta_setup', $type, 'normal', 'high');         }         }         add_action('save_post','my_meta_save');     }     function my_meta_setup()     {         global $post;         $meta = get_post_meta($post->ID,'_my_meta',TRUE);         include(MY_THEME_FOLDER . '/meta.php');         echo '<input type="hidden" name="my_meta_noncename" value="' . wp_create_nonce(__FILE__) . '" />';     }          function my_meta_save($post_id)      {         if (!wp_verify_nonce($_POST['my_meta_noncename'],__FILE__)) return $post_id;         if ($_POST['post_type'] == 'page')          {             if (!current_user_can('edit_page', $post_id)) return $post_id;         }          $current_data = get_post_meta($post_id, '_my_meta', TRUE);           $new_data = $_POST['_my_meta'];         my_meta_clean($new_data);         if ($current_data)          {             if (is_null($new_data)) delete_post_meta($post_id,'_my_meta');             else update_post_meta($post_id,'_my_meta',$new_data);         }         elseif (!is_null($new_data))         {             add_post_meta($post_id,'_my_meta',$new_data,TRUE);         }         return $post_id;     }     function my_meta_clean(&$arr)     {         if (is_array($arr))         {             foreach ($arr as $i => $v)             {                 if (is_array($arr[$i]))                  {                     my_meta_clean($arr[$i]);                     if (!count($arr[$i]))                      {                         unset($arr[$i]);                     }                 }                 else                  {                     if (trim($arr[$i]) == '')                      {                         unset($arr[$i]);                     }                 }             }             if (!count($arr))              {                 $arr = NULL;             }         }     }      Would you please help me understand what's wrong? I can't figure this out and is quite frustrating. The code is not changed at all, the output for my metabox is in another php file in the theme root, nothing is changed really. The only thing I can think of, is that developing the website on a subdomain, when I've copied the files to the root I didn't create another database as I didn't need one and have used the one I had and then used a plugin to change all the URL's. And then I've used a plugin to search and replace URL values in the database, but this was happening before altering the database. I can't be this anyway. When I edit the metabox in the back end, I have no error, the post/page is updated, but it's obvious the database doesn't retain the new values and after editing the fields are emtpy. Here's what I have in the meta.php:               <input type="text" name="_my_meta[title]" value="<?php if(!empty($meta['title'])) echo $meta['title']; ?>"/>     Enter in a title               Body text     <textarea name="_my_meta[body-text]" rows="5"><?php if(!empty($meta['body-text'])) echo $meta['body-text']; ?></textarea>     Enter in the body text               Link     <input type="text" name="_my_meta[link]" value="<?php if(!empty($meta['link'])) echo $meta['link']; ?>"/>     Enter in the URL of the link          e.g.  View our Services page       Later edit: This is how I get my metabox values:               <?php      global $wp_query;     $postid = $wp_query->post->ID;     $array = get_post_meta($postid,'_my_meta',TRUE);            echo "
"; echo $array['title']; echo "
";        echo '
'; echo $array['body-text']; echo '
';        echo $array['link']; ?>


Wordpress Related Plugin - only show when related content

I'm using the Wordpress related plugin : http://wordpress.org/extend/plugins/related/ Which uses the following markup to call the plugin:               <?php echo $related->show(get_the_ID()); ?>      I would like to add a title and a division around the plugin... but would only like this to display if there is a related post/page. How should I modify the code? This is the result I would like to see, but only when there is related content:
Related products
     <?php echo $related->show(get_the_ID()); ?>


Posts and Pages w. private visibility don't show up in existing content

when I create or edit a link in the editor (post or page) pages & posts with private visibility don't show up in the "existing content" section of the "insert/edit link" popup. All pages/posts with public visibility are shown. Is there a fix for that behavior? This doesn't make sense as I have all necessary privileges to see and edit these private pages/post. Any help is appreciated! Thanks Heiner


Display navigation menu item conditionally based on user capabilities

I have one "branch" of my main site's navigation tree that should only be accessible to a set of registered, logged-in users. I understand how to query a user's role and capabilities. This question is specifically about what is the best way to leverage the build-in nav menu, but just hide an item conditionally. Do I need to overload the built-in default navigation and write a custom query and build the navigation structure manually? I'd love to avoid this if possible. I don't need full code samples, just your ideas and general framework / approach. Appreciate the advice! T


prefix table and plugins

I changed my prefix of my tables from the wp_ to something else for security reasons and good practice etc. I was curious most of new plugins installed take on the new prefix but I have one that refuses and still installs with wp_ it still works but i was curious is that normal practice or just a bad written plugin?


Wordpress Admins or Roles per Page

I would like to define an admin that has Administrator rights to everything - thats of course possible, its the default functionality. then i would also like to create an admin (or role) that can only edit and see certain PAGES in the backend. i have gone through many plugins but i can't seem to find this functionality anywhere! any ideas? thanks! mark


How can I build a query that returns all attachments of a page and it's children pages?

I'm using this query to return attachments of a page.               $args = array(         'post_parent' => $post->ID,         'post_status' => 'inherit',         'post_type' => 'attachment'     );      Is there a way to adapt this in order to return attachments for the current page _and_ the attachments of all child pages ?


Populate Custom Field Dropdown on Theme Install?

Is there a way to populate the custom field dropdown box when you install a theme? I want to make it easier for users and avoid having them add the terms manually when they first set it up.


Why are my sidebars not registering in unit tests

I am trying to unit test the function I'm using in a theme to register sidebars. Here is the function from functions.php.               function fp_register_sidebars() {     register_sidebar( array(         'name' => __( 'Sidebar 1', 'fp' ),         'id' => 'sidebar1',         'before_widget' => '
',         'after_widget' => '
',         'before_title' => '
',         'after_title' => '
'     ) );          register_sidebar( array(         'name' => __( 'Sidebar 2', 'fp' ),         'id' => 'sidebar2',         'before_widget' => '
',         'after_widget' => '
',         'before_title' => '
',         'after_title' => '
'     ) );     }          add_action( 'widgets_init', 'fp_register_sidebars' );      Here is the unit test method.               function test_fp_register_sidebars() {         do_action( 'widgets_init' ); // Run the widgets_init hook              /** @var array $sidebars Array containing all active sidebars and their widgets. */         $sidebars = wp_get_sidebars_widgets();              $this->assertTrue( array_key_exists( 'sidebar1', $sidebars ), 'Sidebar 1 is registered at the widgets_init hook.' );         $this->assertTrue( array_key_exists( 'sidebar2', $sidebars ), 'Sidebar 2 is registered at the widgets_init_hook.' );     }      The unit test fails. Looking into this I found that the sidebars are not being updated from the sidebars for twentythirteen to the sidebars for this theme (they stay at sidebar-1 and sidebar-2). I'm switching to my theme in the unit test class setUp() method using switch_theme() and that is successful. Activating the theme on a WordPress environment does correctly register these sidebars so I'm thinking it is something to do with how switch_theme() works.


Form to Add Posts to Custom Post Type

Basically I want to display a form on my blog (on a certain page) that will allow anyone to fill it out and it will create a post in a custom post type. I saw the answer once before but I can't find it now.


Recommended File Permissions

Hey guys, I have been spending the longest time trying to figure out this issue. I would like to know what the file permissions should look like in WordPress **in order to use the autoupdate feature**. As of now, my wordpress installation keeps asking me for my FTP information and I do not want to use that method of upgrading/installing, I want to use pure/direct PHP. Some context:   * webserver and php fcgi daemons run as `www-data:www-data`   * wordpress installation is at `/home/blaenk/sites/domain.tld/` At first, I read that all files/folders should be owned by my user (blaenk) and writable by my user. But this wasn't working, after spending many hours researching, someone on the IRC channel told me to try setting _everything_ to ownership `www-data:www-data` and this worked. I was no longer asked for FTP information and the plugin installation worked automatically. However, I originally placed the site files in my home directory precisely because I wanted to be able to write/create them as my user. I even added myself to the `www-data` directory as stated in this guide. ## Question I already know that files should be 644 and directories should be 755. However, this seems more of an issue of ownership. I don't want to have to set `www-data:www-data` on everything in my wordpress installation, so I'm wondering what files/directories specifically require this ownership level? **EDIT** : I believe that the reason for which everything seems to work on my shared hosting wordpress installation despite all of the files being owned by my user is that the shared host I use seems to use suexec which presumably runs PHP as me, so in other words, the files _are_ owned by the webserver, so to speak.


Wordpress 3.0 Media Upload Directory

I am using Wordpress 3.0 and would like to organize the directory where uploads are made. Is there any way to change where the files get uploaded or is the only real organization the Media tag plugin? What would be ideal is when a user uploads a file, they can specify a sub directory where to dump the file (or default to date). So a user could say "flowers" and the file would go in uploads/flowers. Thanks!


How do I use a custom theme for the WP Maintenance Mode plugin?

How do I use a custom theme, rather than the themes included with this plugin? Here is the link to the plugin: http://wordpress.org/extend/plugins/wp- maintenance-mode/ I see that under the plugin's settings there is a way to choose "own style" theme and a way to link to custom stylesheet, but I want to use my own html as well.


Can WordPress handle these functionalities?

I'm a front-end designer/developer whose weapon of choice for the back-end is WordPress. Up to this point all of my projects involving WordPress were fairly basic and it has handled everything beautifully. I just landed a new client that wants some extra functionality built into his next project and I'm hoping some of you WordPress wizards can give me some good advice while I'm putting together the quote. I'm trying to limit the need for any subcontracting for the back-end functionality, so my question is whether or not WordPress can handle the following (via plugins or light custom manipulation): The idea behind the site is to be a community calendar based on location that Health Care providers can log in and post their events to, as well as participate in discussions, blogs and all the other WordPress goodness. The specific functionalities that I'm unsure of the best way to accomplish are:   * Full featured calendar that members with access can add their own events to - must be searchable by date/type of event/location etc   * Event generator module for members that integrates with calendar - includes upload field for images and forms for details event info   * Interactive map to filter both of the above by location (I'm assuming this will need to be flash, but I'd rather find another solution if possible) I know there are other solutions out there that may be more suited to this than WordPress (Drupal, custom build, etc) but if it's at all possible to tackle this as a one man show then I'm going to charge it head-on! Humble web folk and fellow WordPress fans...your insight would be much appreciated. Thanks in advance for your time.


Check is category parent or not from its ID

question is simple (i don't know is aswer too ;)   I just want to check that, does a category has child (or is ancestor) from its cat-id with a function.   Eg.   `function check_category ($catid){   ............   ...//true if is ancestor, false if not   return $result;   } `   Note: I can only pass cat-id parameter for function because i need to use it in functions.php   Thanks in advance...


custom post type - use default or create new?

I'm building a website that will only have one post type called Work. This post type will need a field as well. Should I just use the default post type (post) and use custom fields or hide the default post type and create a brand new one called Work? If the former, is there a way to change "Post" to "Work" in the dashboard?


w3c validation problem - Twitter share button pulling content

I have this twitter share button that pulls 100 characters from the content of the post and its URL for the twitter share.               <a class="popup"         href="http://twitter.com/share?url=<?php             echo urlencode(get_permalink($post->ID));         ?>&text=<?php the_content_limit(100, "");?>">                    It's working but I always get the following validation error ![Error](http://i.stack.imgur.com/L03pP.png) Can someone help me?


Custom Menu in Admin doesn't change menu in browser

i've just begun participating these stack overflow forums yesterday and had a great experience with someone who could problem solve with me. working from the admin panel under the themes tab i have what looks like a working theme locations panel. i followed instructions i found for installing the proper php code in the proper functions.php file and then placed it where i wanted it to appear in the proper file for my theme. my issue is it won't actually function the way it was intended, i have 3 different menu's created but the site displays every page i created. i obviously slipped somewhere along the way but i can't find where. here's what i have in my functions.php:                       add_theme_support( 'menus' );          add_action( 'init', 'my_custom_menus' );     function my_custom_menus() {         register_nav_menus(             array(                 'primary-menu' => __( 'Primary Menu' ),                 'secondary-menu' => __( 'Secondary Menu' )             )         );     }                 here's whats in my sidebar.php:

             <?php wp_nav_menu( array( 'theme_location' => 'extra-menu' ) ); ?>

           still learning, even posting on this site has a learning curve... thanks for reading this and any help or time is appreciated.


limit post by a taxonomy in the admin

I have a site with authors from different locations. I have created a taxonomy called locations and has different countries (ex. Canada, Germany). Each author need only to see his country's post for the admin. For example, the author of Canada only can see and edit the post of Canada. Its is just for the admin, not the frontend. Authors should never ever be able to see any other posts. It is possible to limit posts by taxonomy in the admin? thanks!


Pass query param to custom page

I had to create custom .php file that representing one page on my website. I did it by creating new page in admin panel, and then renaming my .php file to page-customslug.php (where customslug is slug value of created page). This works fine, and I can access my custom file via www.mydomain.com/customslug What troubles me, is sending GET params to this page, like www.mydomain.com/customslug?par=1. In this case I receive 404 Page not found. Any suggestions why is this happening? Thanks!


Page to output sub-pages (children)

I want to output all sub-pages of a particular page in a neat `ul li` list. Including: featured image, title, and first 50 characters of page content. I'm very new to Wordpress, I've tried reading through the codex and I seem to have found something but I cannot get it to work. First, I have created a new template of "list page" (listpage.php) so that I can choose pages where I wish them to list out sub pages. I still need the content of that page to display, and the `ul li` list to output below, essentially so the client can add some intro text. Here is the code I have from the codex               <?php get_page_children( $page_id, $pages ) ?>      I tried to change the parameters to meet my requirements, the page ID is page 6 (you can see it here) I cannot work out what the `$pages` parameter is meant to be, but looking at other examples on the Codex page it seems that `$all_wp_pages` can be used. So I tried this:               <?php get_page_children( $6, $all_wp_pages ) ?>      And got an error: > Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' > in /mnt/vol2/home/b/a/barkin10/public_html/wordpress/wp- > content/themes/Yasmin/listpage.php on line 27 So I really don't know what I'm supposed to be doing :( Also... Even if this did work, because I have to put the page ID it has occured to me that this `listpage` template will only be useable on the page that the ID corresponds to. I want to be able to give any page a template of `list page` and be able to output the children (featured image, page title and first 50 chars) but no idea how.


How to delete in the pages the pre tag added automatically by Wordpress

i have been looking around but there is not a specific answer to my issue. I have set up a slideshow by Wordpress, then i paste the short code in the page where i want to display. The slideshow is completely messed up because Wordpress automatically adds `pre` tag before the div containing all the slideshow. If i edit in the browser and delete the `pre` tag, the slideshow is displayed perfectly. I had a look to a demo using the same Theme and actually there is not this `pre` tag. So this is obviously causing the error. I am not espert with PHP but there is the possibility to delete this `pre` tag in my wordpress pages in order to display properly the Slideshow?


product export and import using xml

I am use eCommerce plugins for the eCommerce support in wordpress I am export my all product using `Tools->export` from my `http://localhost/first` wordpress site and i am try to import in my wordpress another site like `http://localhost/second` and it is not give any error but not display product main image. I am try to debug the code and i found the problem in xml attribute name like               <wp:postmeta>      <wp:meta_key>_wpsc_product_metadata</wp:meta_key>      <wp:meta_value>dtails</wp:meta_value>      </wp:postmeta>      and               <wp:postmeta>      <wp:meta_key>_thumbnail_id</wp:meta_key>      <wp:meta_value>253</wp:meta_value>     </wp:postmeta>      i am not understood how can i change this two attribute value please help me thanks in advance


Divide WP_Query posts by date & post type

I have a WP_Query that divides 2 Posts types by date but the functionality is not there. Currently it outputs the dates and posts on the same level like.. **-Date**   -Post   -Post   **-Date**   -Post   -Post   What I would like is to wrap each date and its associated posts inside a div, as well as split the two post types for each date into two columns. ![enter image description here](http://i.stack.imgur.com/NkYYM.png) **Update** I managed to split the posts up by date and wrap them in separate divs, now I just need to figure out how to divide the two CPTs into separate columns under each date **Updated Query**               <?php     $day_check = '';     $index = new WP_Query( array(        'orderby'=>'post_date',        'post_type' => array('cpt1', 'cpt2'),        'posts_per_page' =>12));     while ( $index->have_posts() ) : $index->the_post();        $day = get_the_date('j');        if ($day != $day_check) {           if ($day_check != '') {              echo '

'; // close the divs           }           echo '

' . get_the_date() . '

';        }?>
<?php the_title(); ?>
     <?php $day_check = $day; endwhile; ?>     <?php if ( $index->have_posts() ) :?>                                              <?php endif; ?>


Create WordPress pages with PHP

I'm using MongoDB to store separate data for a WordPress website and need to be able to create pages with the data from MongoDB rather than from manually created pages in the dashboard. I've searched all over for this and can't seem to find anything for creating pages in the backend. Is this even possible and if so, does somebody know a good starting point or way to do it? Any information would be great.


None of the Facebook Like Box Plugins working

I have transferred my Wordpress site from Shared Hosting to Digital Ocean. http://livingwithict.com I have installed various plugins for Facebook Likebox and tried to place it under the "Find Us On Facebook" at the right Sidebar. But the like box is not displaying. It was working on localhost as well as the previous shared hosting. But after migrating the site to VPS from Digital Ocean, it stopped working. Thanks in Advanced. Regards, Tushar


Admin Posts List (edit.php) by post IDs

I'm writing a plugin that creates posts in bulk. I provide a way for the user to set certain parameters of the created posts beforehand. But it would be useful to use the WordPress default "All Posts" (`edit.php`) interface to fine-tune the details after the posts are created. I had a look at the `class- wp-list-table.php` and duplicating its functionality is going to be a lot of work. The best solution would be to just send the user to edit.php - limited only to the posts created by my plugin. I have the IDs of the posts, so I'm looking for a solution like `edit.php?id=1&id=2`, revealing a nice list table with only the posts with those IDs.


wp_query() get_col error

I'm trying to create an auto search jQuery function by using AJAX to send data to the database and back to the search field. In my wordpress theme, I create a folder called "include" and in there I created a file called "autoSearch.php" In that file I have my PHP code like so:               global $wpdb;          $searchQuery = mysql_escape_string($_POST['value']);          $mypostids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_title LIKE '$searchQuery' LIMIT 5");          $args = array('post__in='.$mypostids);          $res = new WP_Query($arg);            $titles ="";          while ( $res->have_posts() ) : $res->the_post();         $titles .= get_the_title().'<br />';     endwhile;          echo json_encode(array("everything"=>$titles));     wp_reset_postdata();      However, I get the error: Fatal error: Call to a member function get_col() on a non-object. I have no idea why that's happening. Thanks for the help in advance.


GUID not updated on import

I've exported data from my dev server and imported it to my prod server.   One template is listing child pages and uses `$page->guid` to get link to page. The problem is that this link still points to my internal dev server. Has anyone else had similar problems? And if yes, how do I solve it without having to edit my DB directly?


Domain Mapping for Wordpress MU and https redirection - How to?

Ok, here is my setup. I have a Wordpress MU site setup which uses domain mapping. The root of the site is greatwhitehosting.com.au. Any other site I add using domain mapping works fine and all sites are set to use the primary DNS name as the primary domain. IE say I have a subdomain site greatwhitehosting.com.au/site1 I have set it's primary domain as site.com and typing this in a browser works perfectly fine so this means domain mapping is working correctly. The issue I have is that I want to use my certificate (assigned to greatwhite) for authentication on these domains FOR THE ADMIN SECTION ONLY. This is possible by configuring domain mapping to redirect the admin control panel to greatwhitehosting.com.au/site1. Again this works perfectly fine if I manually browse to https://greatwhitehosting.com.au/site1/wp-login.php. Now here is the issue - I want all http traffic to admin sections (logins etc) to be over a https. I have heard this is possible using rewrite rules in Apache. I have found the code and added it to my httaccess file as follows:               RewriteCond %{HTTPS} !=on      `RewriteRule ^wp-login\.php$ https://greatwhitehosting.com.au/wp-login.php [R=301,L]` The problem I have is that two redirects happen at once and ultimately screw up the redirection. When you use domain mapping and login to the site it tries to redirect you back to site1 using some kind of redirection technique built into the domain mapping plugin. But because Apache also redirects this URL to a https URL it gets screwed up. How do I fix this?


Where can I find documentation for the WP_UnitTestCase factory classes?

In recent versions WP_UnitTestCase has included a $factory property. For example: `$post = $this->factory->post->create();` Where can I find documentation on this useful feature?


Woocommerce price including tax with formatting from options

Af first, I'm not a programmer. In Woocommerce I need to display both product prices, including tax and excluding tax. Code in price.php               <?php if ( $price_html = $product->get_price_html() ) : ?>      is showing default price we entered as product price (this price is excluding tax). I have a problem with displaying price including tax - I'm using this code I found at stackoverflow:               <?php echo $product->get_price_including_tax(); ?>      But the price this code is showing is without formatting and currency I set in Woocommerce settings. Can you help me with this? How to display price_including_tax with proper formatting and currency? I will use this code in some woocommerce template pages, I'd like to avoid editing functions or classes if possible.


Return number of items in a table with post id

I am trying to return the number of reviews for a given page id, I have this so far...               <?php     global $wpdb;     $countreviews = $wpdb->get_var($wpdb->prepare("SELECT COUNT(ID) FROM $wpdb->wpcreviews     WHERE page_id = ID"));     echo 'Number Of Reviews ' . $countreviews . '';     ?>      Its not working and I assume its the end part page_id = ID How do I change the ending to that it searches the wpcreviews table for items with the current page ID, which is the same as my post id?