Check if post has image

I'm displaying a list of posts and I want to indicate if the posts have images. I'm using this code to check if a post has an image.               <?php              $attachments = get_children(array(             'post_type' => 'attachment',             'post_mime_type' => 'image',             'post_parent' => $post->ID         ));              echo count($attachments);              if(count($attachments) > 0) {              echo 'image';         }else{           echo 'No image';         }          ?>      Some of the posts have images but it echo's 'No image' Is there a better way to check if a post has an image.                 <?php get_header(); ?>
                  <?php                 $allideas_args  = array(                     'post_type' => 'post',                     'order' => 'ASC',                     'orderby' => 'date',                     'posts_per_page' => 10,                 );                      $allideas_loop = new WP_Query($allideas_args);                      if($allideas_loop->have_posts()):                     while($allideas_loop->have_posts()):                         $allideas_loop->the_post();                  ?>
                      <a href="<?php echo get_permalink($post->ID); ?>">
                         <?php                                  $attachments = get_children(array(                                 'post_type' => 'attachment',                                 'post_mime_type' => 'image',                                 'post_parent' => $post->ID                             ));                                  echo count($attachments);                                  if(count($attachments) > 0) {                                  echo 'image';                             }else{                                 echo ' No image';                             }                              ?>

<?php the_title(); ?>

by
                          <?php the_excerpt(); ?>
                    <?php                 endwhile;                 endif;             ?>                  <?php wp_reset_postdata(); ?>
              <?php get_footer(); ?>


why does installer/update screens not progress on some webhosts?

I have 20+ WP sites installed for clients on different web hotels. All WP- installs are updated to run latest versions of everything. On some of my sites, the update- and install screens work as expected when I update or install a theme/plugin, the page updates and ends displaying the sucess/finished message. On some of my sites however, these screens always just show the first line like "downloading package" (or something like that, you get the point), but then they never progress. It seems however that everything always gets installed updated as it should. Even when I do a batch update of more plugins. It seems to be a hosting issue, as it's the same for all sites on the same host. Does anyone have a hint at what it might be in the server configuration that is preventing these screens from updating on the progress?


offload media to external services

Does anyone know a way (plugins or similar) to offload media (images mostly) in wordpress to an external service? like flicker, or imageshak? I think that offloading images from the wordpress installation increase significantly the mante the maintainability of your site, and not mentioning the speeding up of the backupping process! One sad note is that many themes need the images on the same server to create thumbnails for post previews, while I thinks a better approach would be to create temporary made up files of the images. thanks!


wp enqueue style on specific page templates

I am in the process of a theme, I would like to add landing pages using page- templates. I cannot find anywhere that shows how to enqueue style or js for specific page templates. Any suggestions. Ex. Landing Page 1 - landing-page- template-one.php will need very different style and js than the blog or homepage.


Allow admin to determine the order of queries?

I have a custom query that I created to display the team members of a company, but my client has asked whether they can have control over the order in which each team member is displayed. Is this possible? At the moment, the default display is to order by date, but it would be great if you could actually control the order of custom post types in a query, within the admin area. `<?php while ($teamFeed->have_posts() ) : $teamFeed->the_post(); ?>
  <?php if (has_post_thumbnail( $post->ID )): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?> <img src="<?php bloginfo('template_directory'); ?>/thumbs.php?src=<?php echo $image[0]; ?>&w=95&h=107&zc=1" alt="<?php the_title(); ?>" />
 <?php the_title(); ?>
 <?php meta('position'); ?>
 <?php endif; ?>
<?php the_title(); ?>
 <?php the_content(); ?>
 <?php endwhile; ?>` Thanks


Find attached images for one post type

I would like to query for images attached to ALL posts of certain custom post type (e.g. 'gallery'). I can't see a way to do this by using only WP_Query. The workaround would be to query for all posts of a custom post type, then get the attachments and stuff everything together. But i don't think that this would be a good solution, because you end up doing multiple queries for something that should be done in one. Please help =)


Add "Post Options" for new wordpress post

How i can add "Post Options" section under wysiwyg editor? **Like this**


Display the number of unseen comments on a page since the user last visit

The community is private and it has several pages /wordpress /design /etc . When users go to those pages the only thing they can do is to comment. Now, what I am trying to do, Idk if possible, but if it is I need some directions/hints on what too search for. http://jsfiddle.net/melbourne/uPqBe/4/ Instead of those numbers I want to display like the title says, the number of lastest comments since the current user visited those pages. I thought of using localStorage/cookies but then if the user decides to login from somewhere else, that won't do the job, in others words I dont have a clue on where to go from here. Any suggestions would really be appreciated.


Disabling automatic teasers

I have a custom theme that displays the excerpt:                   $data = get_the_excerpt();         if ($data) echo "
$data
";      if nothing is entered in the excerpt field in the post editor, Wordpress will automatically use the auto-generated teaser. I would like to get rid of this behaviour. Is there any way to do so? At the moment, I have to entere a space into the excerpt field of every post to prevent the automatic teaser from showing.


This Wordpress plugin isn't creating links correctly

To get my PHP and Wordpress skills, I've been trying to code a small plugin a day. Today's project was to create a plugin that searched over every word in my posts, checked if http://reddit.com/r/$word was a valid link, and added the link to the word if it was. The plugin works correctly for the first post.               "**trees**" links to **http://reddit.com/r/trees**          "**php**" links to **http://reddit.com/r/php**      However, for every other post, the $word variable does not change.               "**trees**" links to **http://reddit.com/r/$word**          "**php**" links to **http://reddit.com/r/$word**      I've been scratching my head for the past hour trying to get this plugin to work. Here's the code:               add_filter('the_content', 'subreddit_replacer');          function subreddit_replacer($content) {                 global $id;       $post_id = get_post($id);       $post_content = $post_id -> post_content;       //delete_post_meta($id, 'jordan'); die;       $derp = get_post_meta($id, 'jordan');            if (empty($derp)) {       $words = preg_split('@[\W]+@',$post_content);       $derp = array();       foreach ($words as $word) {              $link = "http://reddit.com/r/$word";         $x = get_headers($link);         $wordf = ($x[6] == 'HTTP/1.0 200 OK') ? '' . $word . '' : $word;         $derp[] = $wordf;            }         add_post_meta($id, 'jordan', $derp, 1);       }            $derp = is_array($derp[0]) ? $derp[0]: $derp;            return implode($derp, " ");          }      Any guesses on what this problem could be?


Insert into post button missing on custom post type

I have just purchased a theme called **HQ Photography** from themeforest which has a custom post type called `gallery`. I can add images from my hard drive no problem - but if I click the media tab and select an image the 'Insert into post button' is missing I found a site which suggested I needed to add a custom filter to functions.php               add_filter('get_media_item_args', 'force_send_to_post');           function force_send_to_post($vars) {          $vars['send'] = true; // 'send' as in "Send to Editor"          return($vars);      }      This brings the button back but the button then does nothing. Does anyone one know what could be wrong? **UPDATE:** It seams the above function does work! - **however** only for images that are 'unattached' - once an image has been 'attached' the insert into post does nothing Can you attach images to multiple posts?


wpdb result arrray inside an array

I am trying to run a database query as below:               $id = $_GET['id'];     $query = 'select * from ';     $query .= $wpdb->get_blog_prefix() . 'fxdescription ';     $query .= 'where id= '.$id;     $currency = $wpdb->get_results( $wpdb->prepare( $query ), ARRAY_A );      The result of doing print_r($currency) is as below:               Array (      [0] => Array ( [id] => 1 [code] => EUR [name] => Euro [description] => [format] => direct )      )      The question is - is the above result normal, as the result is an array inside an array, and to access the data I have to use `$currency['0']['code']`, in place of `$currency['code']`?


How to make custom dashboard widget to display alert in front-end?

I need to make a widget to display any alert in front end The widget is in dashboard section on backend and any user can use yet. The content of the widget in dashboard is:   * Welcome message   * On/off (with checkbox or select option) to display alert section in the front end   * Green/red selector in backend to display in the front-end with any message, for example: If red color "Stop!" else green color "Go!"   * Textarea for any message to display under the red/green area in the front end   * Finally submit button. Any idea?


How do I list categories and the common categories for posts beneath those categories?

I have four categories:   * 2013   * 2012   * 2011   * 2010 These categories contain posts that are also categorized   * Cat A   * Cat B   * Cat C So basically there's a bunch of posts that are categorized (2013, Cat A), (2013, Cat B), (2012, Cat A), (2012, Cat C), etc Without having to add Cat A, Cat B and Cat C as four sets of child categories under 2013, 2012, 2011 and 2010 is there a way that I can programmatically list those unique subcats with posts under each year so that they list as:   * 2013     * Cat A     * Cat B     * Cat C   * 2012     * Cat A     * Cat B     * Cat C   * 2011     * Cat A     * Cat B     * Cat C   * 2010     * Cat A     * Cat B     * Cat C AND have those subcats link to their respective category page?


Is there a default template file for child pages / subpages?

This seems like a very simple question. I'm looking for something like sub- page.php or page-child.php where I can do some different things on the child pages of my theme. They are different enough in design and content that I'm having to use a lot of php or the CSS .page-child class to do all the dirty work. I'm looking for a simpler method. One caveat - I would like this to happen automatically so I don't have to tell the client "make sure to always select the 'subpage' template when you create a subpage!" which is precarious..


How to use different domains for different blogs hosted in the same host in subdomains with .htaccess

## Background i have a website running on wordpress and all its files are located in public_html of my host. Within it i created a sub domain "phantomomaga" and redirected an other domain to that sub domain to make it "www.phantomomaga.tk" instead of "phantomomaga.my-domain.com" for this i added some code to the .htaccess of my public_html as told here to make it like follow ## Code               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress          #Fix missing trailing slash character on folders.     RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]          #www.phantomomaga.tk and phantomomaga.tk will map to the folder {root}/phantomomaga/     RewriteCond %{HTTP:Host} ^(?:www\.)?phantomomaga\.tk$     RewriteCond %{REQUEST_URI} !^/phantomomaga/     RewriteRule ^(.*) phantomomaga/$1 [NC,L,NS]      ## Problem Due to this edit i was able to achieve what i wanted but for some reason not known to me now the permalink of my subdomain is not working and i keep getting not found errors from my wordpress install that is in my root folder and if i remove               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress       from the .htaccess the sub domain works perfectly but the root one messes up so i think the problem is with the .htaccess of either of root or sub domain and i cant figure out the solution even after i googled it so please help.


How can I query all users who registered today?

I'm trying to use `meta_query` to return all users that have registered today :               $args = array(         'meta_query' => array(             array(                 'key' => 'user_registered',                 'value' => date('Y-m-d'),                 'compare' => '=',                 'type' => 'DATE'             )         )     );          $query = new WP_User_Query( $args );     $users = $query->get_results();      This doesn't seem to work though. What am I missing ?


Member plugin - register approval, restrict downloads, members only pages

I've seen a few members plugins but was wondering if any of them can do a few things i need. 1) I need two different types of users. One is a standard user another is a Partner. The standard user needs to be able to register without any approval, but the Partners need to have the account approved to ensure they are actually a partner. 2) I have file upload fields on one of my custom post types. I need to only allow registered users to view the files. When someone who isn't logged in clicks on one of the files they get taken to the registration/login page, then when they login they get taken back to the page they were on. 3) Members only pages. There needs to be some pages that only user that are logged in can see and view. So the page isn't even visible in the menu unless the user is logged in. These pages will contain downloads as well for members only. There will be a couple of different sections for members only. Some only for Partners the rest for all members. Is there any plugin that can do this? Thanks


How to upload files straight to S3 without using local storage?

I'm looking for a WordPress plugin that would allow me to upload files straight to We are a development shop that actively co-creates CMS websites with clients. This means that we are often iterating sites that clients are using and uploading files to. In our projects, we store the database and code in a git repository which makes it easy to move code from production to local development. The problem with this process is that some of the files that clients upload are very large and we do not want to upload them to the repository, but we would still like to be able to access them as if we have them. So, I thought, instead of moving the files around we could just use a 3rd party that would host the files and we would just access them. I could use Amazon S3 with a backup plugin, but I would prefer to just upload to S3 through the admin interface. The second reason for wanting this plugin is that we hosts blogs that have 20-30GB of high resolution images. I would prefer to not keep these files on our server because server space is expensive. Its less expensive to use Amazon S3 to host the files. In conclusion, is there a plugin that allows to use the WordPress Media upload, but it will actually bypass the local storage and upload files straight to the server? Thank you in advance for your answers!


Markdown in WordPress 3.2?

I found the question Create posts using markdown? about using Markdown on WordPress, however the plugins referred to haven't all been upgraded to WordPress 3.0 or higher. Since I happen to be a bit pedantic about using updated plugin, what options are available to integrate Markdown for both editing and displaying on a WordPress 3.0 or higher setup?


Display all posts in a custom post type, grouped by a custom taxonomy

I’m working on a member page where I use a custom post type with a custom taxonomy. My custom post type is called “member” and my custom taxonomy is called “member_groups”. I want to list all the members but group them together into their respective groups. So to be clear, I’ve 35 members divided into 9 groups – so instead of making the same query nine times I want to do it once but group them together, so that Member1, Member4 and Member 11 is grouped together in one group, called “Marketing”. I’m using WP_Query to retrieve all posts under post type member. I’ve tried different attempts but with no successful result. Any help or suggestions would be much appreciated. Sincere   - Mestika


How to filter the edit comments admin page, show only current logged in author comments

> **Possible Duplicate:**   >  Filtering the Admin Comments List to Show Only Comments from the Current > User? I am trying to get the edit-comments admin page to only show comments for the logged in author. Comments left on their posts that is. It shows all comments but disables the logged in author from viewing/editing ones that are not his/hers. How can I get only the comments from his/her posts to show up? I looked through the edit-comments.php file but couldn't find anywhere to hook into or filter. Thanx in advance!


Create database on installation

I'm working on a custom wordpress plugin, but I can't seem to figure out how to create the database when installing the plugin. (Or when updating) When searching around this is what I came up with, but this doesn't seem to do anything.               function to_install() {         global $wpdb;         $sql = "CREATE TABLE to_issues (             id int(11) NOT NULL AUTO_INCREMENT,             name varchar(125) NOT NULL         );";              require_once(ABSPATH . 'wp-admin/includes/upgrade.php');         dbDelta($sql);         add_option('to_db_version', TO_VERSION);     }     function to_install_data() {         global $wpdb;         $welcome_name = "Hello";         $welcom_text = "Install successfull";     }     register_activation_hook(__FILE__, 'to_install');     register_activation_hook(__FILE__, 'to_install_data');      On a side note, when updating the plugin, will this reinstall all the tables? Or will wordpress handle this correctly?


How to put Login, Register and newsletter widget on the same page?

I would like to create a template file and put there a login code, register code and widget code. I can do it for a widget, but I do not know how to do such thing for login and register. Any advice how to accomplish that?


Change permalink for a single post type only

At present I'm using this permalink structure `/%category%/%postname%/`. There are some existing post type. I want to change permalink for image post type to `image/%post_id%/`, and don't want to affect other post type and their permalinks.


WP_query : meta_key with custom rule for specific value

I'm a bit stuck with a WP_Query code. Here it is :               $args = array(           'post_type' => 'post',           'meta_query'=> array(               'key' => 'karma',               'compare' => '>=',               'value' => 0,               'type' => 'numeric'),             'posts_per_page' => 9,             'meta_key' => 'karma',             'orderby' => 'meta_value_num',              'order' => 'DESC',             'post__not_in' => $dont_show_me         );      What I want to do : Show all posts with karma >= 0 (it works fine with this code). BUT if there are posts with karma = 100 only show 3 of them + the rest of posts. Examples : 9 posts with karma = 150, 133, 100, 100, 100, 100, 100, 33, 11. I want to show: 150, 133, 100, 100, 100, 33, 11. (Only 3 posts with karma = 100 are allowed). Do you have any idea how to achieve this? Maybe a `add_filter('posts_where');` ? UPDATE: Okay I got it working, based on @s_ha_dum answer. It's a bit tricky, but the result works ;)               $args = array(            // Check for 9 last posts with karma = 100            'post_type' => 'post',            'meta_query'=> array(               array(                   'key' => 'karma',                   'compare' => '=',                    'value' => 100,                   'type' => 'numeric'                )             ),            'posts_per_page' => 9,            'meta_key' => 'karma',            'orderby' => 'meta_value_num',             'order' => 'DESC',            'post__not_in' => $dont_show_me         );         $karma_qry = new WP_Query($args);              if (!empty($karma_qry->posts)) {             $i = 0;             foreach ($karma_qry->posts as $p) {                 $i++;                 // Check for more than 3 posts with karma = 100                 // Add them in the $dont_show_me array                  if($i > 3){                     $dont_show_me[] = $p->ID;                 }             }         }              // Setup the final query that excluded addional posts with karma = 100         $args['meta_query'][0]['compare'] = '>=';         $args['meta_query'][0]['value'] = 0;         $args['post__not_in'] = $dont_show_me;              $wp_query = new WP_Query($args);


if user has a certain role then display image

so close to figuring this out, or not I'm not to sure! Basically what I want to do is on the authors page (so outside the loop) if a user role is an editor I want to display a little badge (but just outputting their name and role at the mo) in their profile. I have: functions.php:               function get_user_role($id)     {         $user = new WP_User($id);         return array_shift($user->roles);     }      and author.php:               <?php     global $post;     $aid = $post->post_author;     if ($userlevel == '2') {     echo get_the_author_meta('user_nicename', $aid).' | '.get_user_role($aid);     }          ?>      But doesn't seem to work, any ideas?


Use Media upload in custom widget on wordpress 3.5

I'm creating a small widget for wordpress 3.5 that allows you to upload images. The widget is loaded correctly by wordpress. When I add the widget to a sidebar upload button does not work. If I update the page of keeping my widget in the sidebar, button works and I can load and save the image correctly. To build the widget I was inspired by these links: http://stackoverflow.com/questions/13863087/wordpress-custom-widget-image- upload http://stackoverflow.com/questions/13847714/wordpress-3-5-custom-media-upload- for-your-theme-options/13901303#13901303 My widget Code:               <?php          add_action('widgets_init', 'ctUp_ads_widget');     function ctUp_ads_widget() {         register_widget( 'ctUp_ads' );     }          function ctUp_wdScript(){       wp_enqueue_media();       wp_enqueue_script('adsScript', get_template_directory_uri() . '/js/ads.js');     }     add_action('admin_enqueue_scripts', 'ctUp_wdScript');          class ctUp_ads extends WP_Widget{              function ctUp_ads() {             $widget_ops = array( 'classname' => 'ctUp-ads' );             $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'ctUp-ads-widget' );             $this->WP_Widget( 'ctUp-ads-widget',THEMENAME .' - Ads', $widget_ops, $control_ops );         }              public function widget($args, $instance){              extract( $args );            ?>         <img src="<?php echo esc_url($instance['image_uri']); ?>" />         <?php }              function update($new_instance, $old_instance) {             $instance = $old_instance;             $instance['text'] = strip_tags( $new_instance['text'] );             $instance['image_uri'] = strip_tags( $new_instance['image_uri'] );             return $instance;         }            public function form($instance){ ?>
           <label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Text', THEMENAME); ?>
           <input type="text" name="<?php echo $this->get_field_name('text'); ?>" id="<?php echo $this->get_field_id('text'); ?>" value="<?php echo $instance['text']; ?>" class="widefat" />

           <label for="<?php echo $this->get_field_id('image_uri'); ?>">Image
             <img class="custom_media_image" src="<?php if(!empty($instance['image_uri'])){echo $instance['image_uri'];} ?>" style="margin:0;padding:0;max-width:100px;float:left;display:inline-block" />             <input type="text" class="widefat custom_media_url" name="<?php echo $this->get_field_name('image_uri'); ?>" id="<?php echo $this->get_field_id('image_uri'); ?>" value="<?php echo $instance['image_uri']; ?>">             <?php _e('Upload', THEMENAME); ?>
         <?php       }               }      Js code:               jQuery(function($){         $('.custom_media_upload').click(function(e) {             e.preventDefault();             var custom_uploader = wp.media({                 title: 'Custom Title',                 button: {                     text: 'Custom Button Text',                 },                 multiple: false  // Set this to true to allow multiple files to be selected             })             .on('select', function() {                 var attachment = custom_uploader.state().get('selection').first().toJSON();                 $('.custom_media_image').attr('src', attachment.url);                 $('.custom_media_url').val(attachment.url);                 $('.custom_media_id').val(attachment.id);             })             .open();         });     });      Thanks in advance for help!


Using Advanced Custom Fields in a widget

I've built a widget to show pages from a certain category in a dropdown menu. The page that's selected will show up on the homepage. This all works, except the Advanced Custom Fields (ACF) are all showing the same image. I think it's to do with $instance... The code I'm using is:
              <?php $attachment_id = get_field('main_image');         $size = "home-boxes";         $image = wp_get_attachment_image_src( $attachment_id, $size );         ?>              <a href="<?php echo get_permalink($instance['post_id']); ?>">         <img class="headline" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" src="<?php echo $image[0]; ?>" />

<?php the_field('sub_title'); ?>
      All the code works great on the individual pages - it's just when called by the widget that I get these issues. The title and permalink are using the normal Wordpress functions, and these work fine too. Are there any ACF users here that can shed some light on this? Thanks


Use a plugin to handle custom post types?

I've seen some tutorials showing how to create custom post types - the process seems straightforward enough. The issue I have with this is that the custom type information is part of the theme, and not handled by the WP core. So if the theme is switched for another, they custom type information is lost, and must be ported to the new theme. I've seen some plugins that handle the custom types for you. It seems to me that this is kept separate from the theme, and would thus be more portable, provided the plugin is kept activated. There would of course be a need for the theme to template and style the custom type, but it wouldn't have to maintain the type itself. Is it worthwhile to use a plugin for this purpose?


Preserve custom URL parameter on more pages

I created a custom URL parameter for sorting posts by their vote scores. I have a "most voted" link that sends a `?sort=most_voted` URL paramater and using a query posts filter I display posts with most votes. If for instance I want to display most voted posts in category 5, I'll need a URL like this `?cat=5&sort=most_votes` How do I preserve/attach the `sort` parameter in the URL when browsing categories (or even by tag name, search, etc)?


Programatically create multiple pages by passing in array of info

I'm trying to adapt Tom McFarlin's tutorial on programatically creating a page into a function that will create multiple pages by passing in an array of info. The page gets created in Wordpress, but the page information is all empty.


How can I paginate this?

Been trying to use the pagination functions in wordpress with this code               <?php     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;      $args = array( 'post_status' => 'pending', 'posts_per_page' => 3, 'paged'=>$paged);     $recent_posts = new WP_Query( $args );     ?>          <?php while ( $recent_posts->have_posts()) {     $recent_posts->the_post();     echo '

';     echo get_the_post_thumbnail($recent["ID"], 'thumbnail');     echo '
';     echo '
' . get_the_title() .'
';     echo '
' . get_the_excerpt(10) . '
';     echo '

Author: ' . get_the_author() . '

';     echo '
';      }      ?>     <?php posts_nav_link(); ?>     <?php next_posts_link('« Previous Entries') ?>     <?php previous_posts_link('Next Entries »') ?>      And yet each time I try I just can't seem to get it right, any help would be appreciated cheers. Result page here: http://streakingpirates.com/pending/ _excuse the random posts by my friend_ Solution found thanks to cale_b and the link he provided http://wordpress.stackexchange.com/a/120408/11704 needed to swap               <?php next_posts_link('« Previous Entries') ?>      for               <?php next_posts_link( 'Older Posts' , $custom_query->max_num_pages ); ?>      since apparently the previous pages link has some issues with custom loops


Activated plugin is stored as an object, rather than as a path

This seems like a very unusual behavior: Usually, when activating a plugin, a path to the plugin's main file (or bootstrap) is stored in the database under `options.active_plugins`. However, something in the following code is causing Wordpress to store the object itself, rather than a path to it, in the database. Here is the plugin's bootstrap file (`bootstrap.php`):               /**      * Plugin metadata      */          require_once( plugin_dir_path( __FILE__ ) . 'MyPlugin.php' );          $plugin = new MyPlugin();     $plugin->init();      After activation, the `active_plugins` option entry will look like this (retrieved using `get_option( 'active_plugins' )`:               Array {         [0] => (object) MyPlugin     }      When the expected result would be:               Array {         [0] => bootstrap.php     }


Limit image resolution on upload

I'm running into a problem where a particularly huge image is causing my VPS server to reboot because of memory issues. The configuration of this is out of my hands, it's sort of like the host's failsafe. I have a VPS with 300M memory, which I believe is sufficient for my WordPress installation, at least with day-to-day operations. The image I am uploading isn't particularly big in file size (~380 kb) and is mostly black with white letters. However, its resolution is 4583 * 4583. When I upload it through WordPress, I get an HTTP error in the upload window, and when I go check the live site, it's down for a couple of minutes. I was wondering if it's possible to detect an images resolution and prevent it from being uploaded. I'm clever enough to mess around a bit in an image processor, but some of my authors may not be savvy enough to process the image before they upload something as big as this. It would be even better if the limitation could be based on the images bits- per-pixel, but I have no idea what my server's limit is for this, so I guess an error message saying the image can't be uploaded because it's larger than, say, 2000 * 2000 is enough.


Turn off auto 301 on archive pages?

I'm currently using infinite-scroll. The scroll ends when it reaches a 404. For example it will look for   * category/cars/page/2    * category/cars/page/3    * etc until it hits a 404. The problem is that infinite scroll keeps on loading the first page of content because instead of a 404, I'm getting a 301. I also have yoast enabled. Any idea on how to fix this? pretty sure it's yoast although I'm not sure how to turn off the auto 301 setting.


Search Query that Includes Custom Table

I have a WordPress website that grabs product data from a custom table. I would like to be able to also search from fields in the custom table. Could someone provide a sample query of what this would look like? I cannot join the custom table to the posts table because the custom table has data that is not associated with any other database tables (unless I am misunderstanding joins). The end goal is to show all posts and custom table data that match the specified "s" variables data. Thanks! UPDATE Here is the requested table structure of the custom table: ![enter image description here](http://i.stack.imgur.com/0STC6.png) Just to clarify, I am trying to modify the WordPress search so that it searches the posts table using a like query. I also need it to return results that match from the custom table as well. I will need it to search the subarticle and Article fields of the custom table.


Add custom prefix to search URL

I am using Wordpress to manage a site with both a static page structure and a blog under /blog. I've updated my permalinks to use the custom structure `/blog/%postname%/` and all seems to be working well except that I'd like for my search results to be located under `/blog/search/search+terms`. Currently that URL returns a 404, but `/search/search_terms` works as expected. I know I could use a rewrite rule in Apache, but I'm wondering if there's a way to effect this change within Wordpress itself.


How can I call "preview post" from wp_remote_get with authentication?

I've got a plugin that needs to interogate the post preview (the contents of the rendered page that's presented when the user clicks "Preview Post". To attempt to obtain this input stream into a code variable, I'm using wp_remote_get like so:               $response =      wp_remote_retrieve_body(     wp_remote_get(     'http://localhost/mysite/test-post/?preview=true&preview_id=28&preview_nonce=640bc54ca4'));      $post->post_content = $response;      (I'm just replacing the post content with the results of the get for easy previewing during code testing). My problem is that since I'm not passing any authentication parameters in the wp_remote_get, the preview action fails. Is it possible to pass a parameter that authenticates the current user and returns the preview to the script?


Specified file failed upload test. wp_upload_handle

So I managed to write a peice of code that allows me to upload a zip file, im not even sure where it gets uploaded too, and I am doing it on my localhost with apache in control (www-data). the code is as follows:               public function upload_file(array $file){         add_filter('upload_mimes', array($this, accepted_mime_type));              if(wp_handle_upload($file, array('test_form' => false))){             var_dump(wp_handle_upload($file, array('test_form' => false)));         }else{             $this->error('Oops!', 'Something went wrong with the upload. Please try again.');         }            }      the error I get is: Specified file failed upload test Im not sure whats going on, this is localhost.


Development plugin to view and manage scheduled wordpress cron jobs?

Is there a plugin for wordpress that can help a user to view and manage the crons that are currently schdeuled in WordPress? I have looked into Core control but doesn't allow the user to manage the cron jobs.


How do I safely force get_theme_mod() to use a defined get_option("stylesheet") value?

In our development process we have several branches of the same theme for each developer. Theme branches live in different directory names, so when doing `get_theme_mod()`, `get_option("stylesheet")` can return different values, should we for some reason (customer demo) be forced to activate another theme branch besides "master". This makes us have to reconfigure menus, widgets, customizer mods etc etc. In our case, it's very rare that theme mods need to be different across branches, so I would like `get_theme_mod()` to always access the same mods array. The obvious solution seems to be making "`pre_option_stylesheet`" filter as a standard part of the theme codebase, but I am not sure if it may have any unintended side effects. Grepping around, looks like this option is almost exclusively used in a few places in `wp-includes/theme.php`. Q: Is "`pre_option_stylesheet`" filter the way to go here? Or can you think of something else?


get all posts from a custom post type

I'm trying to get all posts from a particular custom post type using the following code:               $auctions = get_posts(array('post_type' => 'auction'));     print_r($auctions);     echo '<select>';     foreach ($auctions as $auction) {         echo '<option value="' . $auction->ID . '">' . $auction->post_title . '</option>';     }     echo '</select>';      Although the print_r() call shows data, the foreach seems to ignore it and doesn't print anything. Any ideas? Any help would be appreciated print_r() output:               Array (         [0] => WP_Post Object (             [ID] => 36             [post_author] => 1             [post_date] =>    2013-05-19 10:58:45             [post_date_gmt] => 2013-05-19 08:58:45             [post_content] =>             [post_title] => My Title             [post_excerpt] =>             [post_status] => publish             [comment_status] => closed             [ping_status] => closed             [post_password] =>             [post_name] => my-title             [to_ping] =>             [pinged] =>             [post_modified] => 2013-05-24 09:55:53             [post_modified_gmt] => 2013-05-24 07:55:53             [post_content_filtered] =>             [post_parent] => 0             [guid] => http://domain.com/?post_type=auction&p=36             [menu_order] => 0             [post_type] => auction             [post_mime_type] =>             [comment_count] => 0             [filter] => raw         )        )


Multisite with a single, shared custom post type, while retaining site URL

Small multisite setup, two very different sites, both need to access an `event` custom post type. I don't want to duplicate posts (there are some plugins that "broadcast" a post to the network). `switch_to_blog(1)` will get me part way there, where `blog 1` is the "master" blog that contains the `event` data, as far as archive-style pages that list all the events. But my concern is that the URL/permalink of the event, when viewed from `blog 2` will point to `blog 1`, and following that permalink will then take the user to the other blog, confusing the user. Is there a solution (possibly using rewrite) that would allow an event post at `//blog1/events/event1` to appear as `//blog2/events/event1` when viewed from `blog 2`?


Ajax Dynamic Archives not showing correct results

Im baffled on why this is not showing the correct results, when selecting the month alone and say 100 posts are on the site, only 3 show up, then if you select the category and month the proper show up. here is the archives template

Month
          <select id="month-choice">     <option val="no-choice"> — </option>     <?php wp_get_archives(array('type'    => 'monthly', 'format'  => 'option')); ?>     </select>

Category
          <?php wp_dropdown_categories('show_option_none= -- ');?>

      here is the archives getter               <?php          /*         Template Name: Archives Getter     */          $year = trim($_POST['digwp_y']);     $month = trim($_POST['digwp_m']);     $cat = trim($_POST['digwp_c']);     $querystring = "year=$year&monthnum=$month&cat=$cat&posts_per_page=-1";     query_posts($querystring);           ?>          <?php if (($year == '') && ($month == '') && ($cat == '-1')) { ?>

Please choose from above.

          <?php } else { ?>
         <?php                 if (have_posts()) : while (have_posts()) : the_post(); ?>
                     <img src="<?php echo get_post_meta($post->ID, 'PostThumb', true); ?>" alt="" style="width: 35px;" />	                     <a href='<?php the_permalink(); ?>'><?php the_title(); ?>	                     <?php comments_popup_link(' ', '1 Comment', '% Comments'); ?>	                     <?php the_date('m/j/Y'); ?>
         <?php              endwhile; else:                      echo "
Nothing found.
";                  endif;          ?>
      and finally the jquery code               jQuery(function($) {     $("#archive-wrapper").height($("#archive-pot").height());     $("#archive-browser select").change(function() {     $("#archive-pot")         .empty()         .html("
loading...
");          var dateArray = $("#month-choice").val().split("/");     var y = dateArray[3];     var m = dateArray[4];     var c = $("#cat").val();          $.ajax({         url: "/archive-getter/",         dataType: "html",         type: "POST",         data: ({             "digwp_y": y,             "digwp_m" : m,             "digwp_c" : c         }),         success: function(data) {             $("#archive-pot").html(data);             $("#archive-wrapper").animate({                 height: $("#archives-table tr").length * 50             });         }     });     });     });


How to receive notification of deprecated API elements and functions?

There is some way to get notifications when deprecated API elements are used in WordPress. How is it done? Put WordPress in debug mode (which also shows all other types of errors) or is there another method that shows only API related errors?


Custom Taxonomy type in nav menu

This might be a stupid question. But I really need the tip. I've created several custom taxonomies in "post" type and everything is perfect. I can insert each custom term i create in the main nav menu. but what i'm looking for any way that if i could all the terms under a taxonomy in a menu item. That is if i click on a menu item say "Services" which is a custom taxonomy consists of terms such as "service 1, service 2 service 3" etc the page open will show all the posts which are under all the terms of this taxonomy. I can add each terms in the menu list but i don't want them to be different. And again I can create another parent term of all those terms and assign it in the nav menu but i don't want it either. But I don't want it to be so tricky. Please any idea from the experts. Thanks in advanced.


Is it possible to us WP Core Maintenance Mode for short pause while a plugin runs?

I've written a plugin to manually (admin button push) delete several hundred posts that are created by another plugin. That other plugin creates posts based on an external API. I'm running into a situation where occasionally the API plugin is starting to creating new posts midway through the deletion. I'm wondering if there is a way to use WP's core maintenance mode for just a few seconds to pause everything else on the site from running while the delete runs? I've looked at update-core.php and update.php but it wasn't quite obvious to me what it was doing to initiate and terminate maintenance mode. I was kind of hoping there was a function to set maintenance mode and another to clear maintenance mode, but I'm not seeing it. Open to other ways to avoid this race condition as well.


grant a privilege for roles (for example editors) and higher

My wordpress theme has a custom post-type. Only editors (and higher) should be allowed to use this post type. I did this with:               function add_capability($role,$cap) {         $role_obj = get_role($role); // get the the role object         $role_obj -> add_cap($cap); // add $cap capability to this role object     }          function set_cpt() {         add_capability('editor', 'edit_cpt');         add_capability('editor', 'read_cpt');         add_capability('editor', 'delete_cpt');         add_capability('editor', 'edit_cpt');         add_capability('editor', 'edit_cpt');         add_capability('editor', 'publish_cpt');         add_capability('editor', 'read_cpt');     }     add_action('init', 'set_cpt');      ~~(I think) in Wordpress 3.1 this was enough - all editors **and higher** had the right to use the post-type.~~ Now ~~, in Wordpress 3.2~~ **only** editors have the right to use the post- type. Is there a way to grant privileges to role X and higher or would I have to mention every role? Thank you! [edit] actually I found out that this never worked before. But is there another way to do it?


Should I remove transients from the wp_options table?

I have been doing some cleaning up in the database of one of my WordPress installs, and I noticed that the `wp_options` table was about 2.1mb, and had 1200 rows. I've gotten it down to around 800 rows, and 1.2mb. However, there are a bunch of transients. Should I remove these? I know they don't autoload, so it probably isn't causing strain on the database. Most of the transients have formatting like the following:               _site_transient_browser_03df11ec4fda7630a5...     _site_transient_browser_065e09a1287aadfb4d...     _site_transient_timeout_browser_03df11ec4f...     _site_transient_timeout_browser_065e09a128...     _transient_feed_1a5f760f2e2b48827d4974a608...     _transient_feed_f8e8c12cc5c787789728d7481a...     _transient_feed_mod_e6460a14e5784b3ee64f91...     _transient_timeout_feed_1a5f760f2e2b48827d...      So, is it worth taking the time to remove these? Thanks for reading! Any thoughts are appreciated.


Custom Field returning Numerical Value for Image rather than URL

I have been trying a way round my latest WordPress problem all morning and I feel now is the right time to shout and ask for help. I have been trying to create a people directory, I'm there except for the overall listing page which I have decided to be rows of 5 images followed by the persons name below each image, followed by another a row etc... Each persons page has a set of custom fields one of which is `name` and another is `mainimage` the idea being that with the following code I can pull the image along with the name from the child pages of `people` and display them all on the one page with the image and name linked to the permalinkof the specific child page.               <?php          // Get the page's children         $args = array( 'numberposts' => 100, 'child_of' => 35, 'post_type' => page, );         $children = get_pages( $args );          if (!empty($children)) {          echo '';         foreach($children as $child) {             // Get the 2 meta values from the child page             $main_image = get_post_meta($child->ID, 'main_image', true);              $name = get_post_meta($child->ID, 'name', true);                   // Display the meta values             echo '
';             echo $main_image;             echo '
';             echo $name;         }         echo '';     }           ?>       It works kind of, but I'm getting a number for the image as opposed something that outputs to an image. Upon checking the custom field I have found the image value is a number, looks to me like media ID. I need to either be able to interpret the ID within the people page as an image or a way to make sure actual urls are being put into the custom field values so I can use standard `img src` html to output the image. I am using Advanced Custom Fields to create the fieldsets for the people page as well as the individual person pages. Any help would be greatly appreciated as I have tried several variations of the code above but just cannot get the number to change in to the associated image.


When I re-save a post with [code] sections, the entities are double-escaped (> becomes > etc)

I've a hard time googling for this issue. On my blog, whenever I update an existing page, code sections are doubly escaped. I.e., on a recent page I have               find /V "QWERTYUIOPPO" < calc.exe:yourads.txt      and after a recent edit it has become:               find /V "QWERTYUIOPPO" < calc.exe:yourads.txt      When I save it once more, it will escape the entities once more:               find /V &quot;QWERTYUIOPPO&quot; &lt; calc.exe:yourads.txt      Etc. Needless to say this is nasty. For pages containing a lot of code this is a real bummer. Until now I just did some search and replace actions, but this can't stay forever. Does anybody recognize this issue? Here's an example page that illustrates this issue. Also in the screenshot for future reference (as I sure hope to solve the issue on my pages sometime soon). ![enter image description here](http://i.stack.imgur.com/X4qLL.png)


jQuery AJAX add json2 dependency?

I am working on a voting system in Wordpress with jQuery and AJAX. To make this voting system work I need jQuery in my theme. So wrote the code down in my functions.php. But for some reason my script doesn't do anything. Watch my full vote script here. So I started reading the codex, and found here to include jQuery for AJAX calls, you need the json2 dependency. Does anyone have experience with this, and can tell me how I need to include this, because jQuery is already registered in Wordpress, so do I need to register jQuery again and add the json2 dependency to this? I don't get it..               // Ajax Voting     wp_register_script( 'ajax-vote', get_template_directory_uri() . '/js/ajax-vote.js', array('jquery') );          $nonce = wp_create_nonce("vote_nonce");     $stn_vote_data = array(         'ajaxurl' => admin_url( 'admin-ajax.php'),         'nonce' => $nonce,     );     wp_localize_script( 'ajax-vote', 'stn_vote', $stn_vote_data );          function stn_script_enqueuer() {             wp_enqueue_script( 'jquery' );         wp_enqueue_script( 'ajax-vote' );          }     add_action( 'wp_enqueue_scripts', 'stn_script_enqueuer' );


How to add in title a date but with other color, like in iMDb titles?

Is there a way to add in title a date but with another color, like in iMDb titles? Like in this title (click on it): http://www.imdb.com/title/tt1606378/ **To be more clear,** see this picture **The result is this:**see this picture Thanks!


Way to hook into a sidebar call to replace it with a custom sidebar

I want to replace the `sidebar-2` in the twentyforteen theme with a custom sidebar based on a conditional statement for CPT. So if the page is showing a certain custom post type then show my custom sidebar, else just show the default sidebar. I want to do this without changing the theme or using a child theme (i.e. purely from a plugin). Here is what I have so far:               register_sidebar( array(         'name'         => __( 'Custom Sidebar' ),         'id'           => 'custom-sidebar',         'description'  => __( 'My Custom Sidebar' ),         ) );          add_action('get_header','change_dd_sidebar');     function change_dd_sidebar() {         if ( is_singular('my_cpt')) { // Check if we're on a single post for my CPT called "ips_due_diligence". Need another check for index pages too.            unregister_sidebar( 'sidebar-2' ); //remove the default right sidebar            dynamic_sidebar( 'custom-sidebar' ); //this doesn't replace the right sidebar - the content appears at the top of the page - no good...        }     }      Is there a way to hook into the call for `sidebar-2` and replace it with my own?


Migrating Markdown (from Drupal)

I'm in the process of migrating my blog from Drupal to Wordpress. I have made liberal use of Markdown in the original posts (and Geshi syntax highlighting). In see that the WP-Markdown plugin converts to (and from HTML) on save (and edit), so I now have a bunch of posts which appear with the Markdown 'on show'. Is there an API call which I can use to effectively do an 'edit and save' operation on each post to force the Markdown on Save plugin to operate on them all? Or alternatively, a different Markdown plugin I should try?


add logout button on admin side menu

I want to add a logout button on the side admin menu (because I disable the admin bar for the users). So I thought add_menu_page() is the way to do it, but how to add the link to the regarded function? Here is what i did:               add_action( 'admin_menu', 'my_logout_menu' );          function my_logout_menu() {     add_menu_page( 'Logout', 'Logout', 'read', 'logout', 'my_logout' );}          function my_logout() {     echo wp_logout_url( $redirect );}//here is I don't know what to do.      Am I using the correct approach? or there are other easier ways to do it?


Shortcode, Concatenating & Parse error: syntax error, unexpected T_FOREACH

I'm learning how to write a shortcode. I'm getting this error: Parse error: syntax error, unexpected T_FOREACH . I'm having problems with concatenating it properly.               <?php     /*     Plugin Name:  My Plugin     Plugin URI: http://mysite.com     Description: This does blah     Version: 1.0     Author URI: http://www.mysite.com     */                         function csf_cap_databaseinfo() {         global $wpdb;                        $greeting = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_test;"));                $out = '

                  ID	                      Greeting
';                 $out .=  foreach ($greeting as $greet){ .'
' . echo $greet->id . '
' . } .'
';                   return $out;           }               add_shortcode('db-info', 'csf_cap_databaseinfo');     ?>      Any suggestion on how to fix this error? Thank you. -Laxmidi


How to create a new theme from scratch?

I'm new to WordPress. Which steps would I need to do, to get my new design implemented as a WordPress theme?


Akismet plugin is deleting spam despite preferences

Curiously, Akismet is deleting old spam comments after a period of time (I'm guessing within a week). This box is **NOT** checked: > Auto-delete spam submitted on posts more than a month old. I've sent a message to Akismet support more than a week ago but I've not yet received a reply. I do not want Akismet to delete anything. I do not check often enough to verify false positives so I want all comments saved indefinitely, even the spam. Does anyone know why it's deleting spam comments even though it's set not to? Does anyone know of a workaround?


CodeColorer: Allow Some Symbols in Java Language

I have a quick question about CodeColorer plugin. How can I allow less then (<) and greater then (>) signs in java code. I am asking this because they are used in Generics but they are being stripped away when I use lang = java, so I am forced to use lang = html for now. Any help is appreciated. Thanks for taking time to read this. **Update:** ok, the issue is resolved now. The thing was that anything resembling html, like , was stripped by WordPress for all roles less then admin. I added this code to make it work for contributor, $role = get_role( 'contributor' ); $role->add_cap( 'unfiltered_html' ); This resolved the issue.


Is there a way to enable bulk edit and quick edit on custom post types?

When viewing a list of all standard post or pages there are convient quick edit and bulk edit functions to edit author, template, status, dates, etc... Is there an easy to enable similar quick edit and bulk edit tools on Custom Post types? For example going to: ../wp-admin/edit.php?post_type=page select all checkboxes, select edit from drop down, click apply, you get options for Author, Parent, Template, Comments, Status, but none of those show up for ../wp-admin/edit.php?post_type=mycustomposttype


How to make the BuddyBar fix and scroll with the page

I've been trying to find a way to force the BuddyBar to scroll with the page instead of float at the top of the browser window when scrolling down the page. I been searching the net for this but can't seem to find anything on it anywhere. Has anyone tried this yet? This is on a multisite install.


Is this post using WordPress Gallery?

Here's an interesting post that I saw toda - check the gallery This website is using WordPress, now if you notice the image URL changes however we can still see the javascript slide effect. If it was a javascript slideshow then it shouldn't have changed the URL. This makes me think that how are they achieving this.


How to make universal gallery and improve admin side of managing galleries?

I will describe here steps I made to make my galleries for my first WP theme. I wanted to have a few links in my menu which will take user to page with thumbnails. Each thumbnail takes user to gallery with bunch of horizontally displayed images. First, in my functions.php file I've added new size for my icons:               add_image_size( 'wide-image-icon', 200, 150, true );      Then, I've made my template file for gallery category (lets call it Gallery1) and category "Gallery1". In my `gallery1.php` template file I used query for posts with galleries:               query_posts(array('category_name'=>'Gallery1','posts_per_page'=>-1))      Then, in posts loop I've displayed my gallery icons (which are featured images of posts):               the_post_thumbnail('wide-image-icon');      So now, after creating new page with "Gallery1" template, I can add post, select "Gallery1" category for it, add pictures using standard "Insert gallery", choose one as featured image and I'm good to go. The problem is that's not universal way of doing this. What if I would like to make another gallery page (Gallery2). Then I need to make new template file, create new category, change category name in query inside template file, add new page with this template attached to it. How do you do it? I'd also like to ask about some admin side improvements for gallery. I've seen themes where there was a completely new tab inside admin area where you saw all galleries, you could easily change images order, add/remove galleries etc. Right now on my website I add my news ( I use the same system here ), galleries, blog posts and normal pages like "Bio" as posts only which is definitely not good. PS. Any articles, video tutorials, books or tips and tricks are welcome. @edit: How can I manage display of my galleries on admin side? I'd like to remove whole editor and leave just pictures if you know what I mean.


What is the Plural of WordPress?

I mean, for what I remember of my english classes it should be `WordPress'`, or not? Would this be a Meta Question? Or a English Language & Usage one? **[update]**   What I ended up writing (in an email) before Comments and Answers was > ...deal with a couple of WordPress' projects... **[update]**   Well, it ended up being an _Engrish_ Fail. Thanks, Johannes, for opening the question at English Language & Usage. Toscho's answer also prompted me to open another at Spanish Language and Usage, but for a person's name. (oh, my, is this apostrophe correct?) _In spanish, it would be "Los WordPress"._


Can I make an ajax response cross-domain?

I am trying to make a single ajax response cross-domain. Is that possible? I tried something like this, but that did not work:               function my_call_callback() {       header("Access-Control-Allow-Origin: *");       if (headers_sent())           echo "headers was sent";       else           echo "headers was not sent"; // This is what I get       die();     }     add_action('wp_ajax_my_call', 'my_call_callback');      UPDATE: It suddenly started working. No idea why. I suspect some problem with the web hotel I am using since I just told about an attach attempt I noticed. They told me to block the attackers IP in .htaccess. Perhaps they did some review of the .htaccess files. I really have no idea though.


How to submit documentation with plugin

When I submit a plugin to the wordpress public repo, how am I supposed to submit documentation? What is considered standard or good practice? Should I just have all documentation on the be page that the plugin is mirrored on, or should I also include a readme of sorts? I know when submitting to CodeCanyon, it's standard to package documentation with the plugin, but it's not super important what file format you use as long as it can be viewed without paid software. I don't, however, know what the standard for submission to the public repo is. Insight anybody?


DB access blocked when initializing WP externally

I have an odd problem I'm hoping the group can help with. The problem is this:   * I have a few situations where I load the Wordpress environment without the overhead of the GUI (details)   * I am able to do this in most environments without a problem but a few (two laptops to be precise) refuse to load Wordpress and instead give me the following error: ![enter image description here](http://i.stack.imgur.com/NOF0r.png) What's so very strange is that:   1. The db connection attributes are correct. This has been validated both by logging in manually from the command-line (using the credentials in the wp-config file); not to mention that this same `wp-config.php` has no problem loading the database when it is loaded normally by Wordpress.   2. The files, OS, PHP version, even the DB connection parameters are all exactly the same on computers that work versus those that don't.  I'm not sure were else to look. Any help would be greatly appreciated.


How can i put a custom field inside this php

Hy, i want to count years of an actor. The date that actor is born is stored in a custom field.               $date = get_field('data_nasterii');      Date stored in custom field is : yymmdd How can i stick bouth togeder to make it work.               <?php                      //date in mm/dd/yyyy format; or it can be in other formats as well                      $birthDate = "12/17/1967";                      //explode the date to get month, day and year                      $birthDate = explode("/", $birthDate);                      //get age from date or birthdate                      $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md") ? ((date("Y")-$birthDate[2])-1):(date("Y")-$birthDate[2]));                      echo $age ."ani";                 ?>      I try this but this returned me year 2012               <?php              //date in mm/dd/yyyy format; or it can be in other formats as well              $birthDate = get_field('data_nasterii');              //explode the date to get month, day and year              $birthDate = explode("/", $birthDate);              //get age from date or birthdate              $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md") ? ((date("Y")-$birthDate[2])-1):(date("Y")-$birthDate[2]));              echo $age ."ani";         ?>


Filter categories/tags to display in multiple metaboxes for selection in back-end

My site uses a lot of categories and tags for author selection in the back- end. To make it more user friendly for authors I need to arrange the categories and post tags in numerous metaboxes for selection on the post edit screen. I would like to display some selected categories and their children in one metabox for author selection while other categories will go into a second and third metabox and so on. The same should apply to the tags. Can anyone point me in the right direction how to accomplish such a customization? Can I register new taxonomies which will include categories/tags based on their ID's and create new metaboxes displaying only those ID's? The Wordpress default metaboxes for categories and tags display all categories in one box. Thanks!


Add unique class or ID information to tinyMCE

Is there a method to apply a unique body class ID to the editor in the same way that body class information is added to the published page? I am using the add_editor_style() function to render the editor's styles to reflect the published page. However, there are some pages where the styles break away from the standard page rules, and I would love to be able to include some of those exceptional style rules in the editor.


wpdb prepare syntax

$arr = [];     array_push( $arr, 'wp_table', 1, '2013-12-24', 3, 'NULL');     $sql_prepare = "INSERT INTO %s (id, datea, one, two) VALUES (%d, %s, %d, %s) ON DUPLICATE KEY UPDATE one = VALUES(one), two = VALUES(two);";          $wpdb->query(            $wpdb->prepare( $sql_prepare,                           $arr )     );      The above code seems to result in an issue with the `datea` value `2013-12-24`. `[You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''wp_table' (id, datea, one, two) VALUES (1, '201' at line 1]` `"INSERT INTO 'wp_table' (id, datea, one, two) VALUES (1, '2013-12-24', 3, 'NULL') ON DUPLICATE KEY UPDATE one = VALUES(one), two = VALUES(two);"` Without `$wpdb->prepare (...)` the query works just fine. `$wpdb->query( "INSERT INTO $table_name (id, datea, one, two) VALUES (1, '2013-12-24', 3, NULL) ON DUPLICATE KEY UPDATE one = VALUES(one), two = VALUES(two);");` Any advice on how to handle the date value? What am I doing wrong? Thank you for further explanation. /edit I see I might be overusing prepare but at least `datea, one, two` are user-submitted input


Help with AJAX front end comment moderation

I am implementing a front end AJAX comment moderation system for a site I manage but I am having a hard time getting it to work. Right now clicking on the link that approves the comment runs the proper php script but it reloads the entire page. So it works but I'd like to approve the comment using ajax without reloading the entire page, but my lack of javascript knowledge is preventing me from getting this to work. Here is the code (located in a plugin):               add_filter( 'comment_text', 'p3_comment_moderation_buttons' );     function p3_comment_moderation_buttons ( ) {         if ( is_author() || current_user_can( 'moderate_comment' ) ) {             // Adds moderation buttons under every comment             $comment_id = get_comment_ID();             $text = get_comment_text();             $nonce = wp_create_nonce( 'p3_comment_moderation' );                  $p3_approve_link = admin_url('admin-ajax.php?action=p3_comment_approve&comment_id='. $comment_id.'&nonce='.$nonce);                  $p3_edit_links = '
Approve
';             return $text . $p3_edit_links;         }         else{             return get_comment_text();         }     }               add_action("wp_ajax_p3_comment_approve", "p3_comment_approve");     function p3_comment_approve() {         if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'p3_comment_moderation' ) ) {             exit("Go away!"); //If nonce check fails stop everything         }         $comment_id = $_REQUEST["comment_id"];         $success = wp_set_comment_status( $comment_id, 'approve' );         $success = update_comment_meta( $comment_id, 'p3_comment_status', '' );              if ( $success = true ) {             $result['type'] = 'success';             $result['comment_id'] = $_REQUEST["comment_id"];         }         else {             $result['type'] = 'error';             $result['comment_id'] = $_REQUEST["comment_id"];             echo "Something didn't work";         }              if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {             $result = json_encode($result);             echo $result;         }         else {             header("Location: ".$_SERVER["HTTP_REFERER"]);         }              die(); // this is required to return a proper result     }          add_action( 'init', 'p3_comment_meta_script_enqueuer' );     function p3_comment_meta_script_enqueuer() {         wp_register_script( "p3_comment_meta", plugins_url().'/p3wp-comments/js/p3_comment_meta.js', array('jquery') );         wp_localize_script( "p3_comment_meta", 'p3cmetaAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));              wp_enqueue_script( 'jquery' );         wp_enqueue_script( 'p3_comment_meta' );     }      And the corresponding javascript:               jQuery(document).ready( function() {              jQuery(".p3-comment-moderation").click( function() {             comment_id = jQuery(this).attr("data-comment_id")             nonce = jQuery(this).attr("data-nonce")                  jQuery.ajax({                 type : "post",                 dataType : "json",                 url : p3cmetaAjax.ajaxurl,                 data : {action: "p3_comment_meta", comment_id : comment_id, nonce: nonce},                 success: function(response) {                     if(response.type == "success") {                         alert("Success!")                     }                     else {                         alert("Something went wrong.")                     }                 }             })              })          })      Can anyone spot the problem? BTW I have already modified the comment template to display unapproved comments so they can be approved on the front end. I also plan to expand this to to work with custom comment meta, and expand the javascript so it does something more useful than displaying an annoying alert Thanks


Protocol relative url not pulling up images on IE, FF, and OPERA

I'm running into an issue where I'm using the protocol relative url for the images from the wordpress Amazon s3 plugin on my SSL pages. In Chrome, all images are loading fine but when I tested it on IE, FF, and Opera, the images aren't showing up. Here is what I inserted into the theme option image input field:               //www3.mydomain.com/wp-content/uploads/my_logo.png      Does anyone know why it's causing this issue? I searched the web and couldn't find a clear answer. Thanks for your time, Hal **Output of HTML**                                                **Solution** Since I'm using the Amazon s3 plugin, I'm required to use the s3.amazonaws.com/bucket/key domain name if I'm pulling contents into a SSL page. Hope this helps if anyone is having problems.


Display category and associated post listings

I am having trouble figuring out a correct loop to display the following: **Category Name:**   * Post 1   * Post 2   * Post 3   * Post 4   * Post 5 See all posts in this category --> Can anyone help me with a correct function or loop?


Query in a Hierarchical Custom Post Type for Children vs Siblings

I have a custom post type with two levels of pages inside of it. the parent level we'll call parent, and child - child. The parents need to be able to pull in their children, and the children need to be able to pull in their siblings (children of the same parent.) If i were doing this in a normal page:               <?php $children = get_pages('child_of='.$post->ID);?>     if( count( $children ) != 0 ) { ?>
     Give us your Children
     <?php }     else { ?>
     Give us your siblings
     <?php } ?>      Of course - this doesn't work since get_pages only works with non-cpt "pages". I'm at a loss for the proper method inside a CPT - help much appreciated.


ob_end_flush error when using wpdb in plugin

I created a small plugin to test database interactions in wordpress. I have a small function that inputs the arguments to the table. If i call my function in a themefile it inputs my test values to my table, but if i call it from another plugin i get this error: Notice: ob_end_flush(): failed to send buffer of zlib output compression (0) in /.../wp-includes/functions.php on line 2504 I have no idea what this error means, can anyone shed some light on it? edit: I use MAMP with PHP 5.4.4 edit2:               function test_db_function($name, $message){       global $wpdb;       $table_name = $wpdb->prefix . "testDB";            if( $name == '' || $message == '' || !isset($name) || !isset($message)) {         //return 0;       }       else{         $rows_affected = $wpdb->insert( $table_name, array(            'time' => time(),            'name' => $name,            'text' => $message) );       }     }


Random element in get_post_meta array

I have a custom field that contains a list of comma separated colors. I want to randomly select one of those colors. If get_post_meta returns an array I thought I could randomly pick from that array. If I try to echo $rand_color_value it just gives me the whole array How can I randomly select one color from the list in the custom field.                   $agrs = array(             'post_type' => 'page',             'tag' => 'colors'         );              $colorLoop = new WP_Query($agrs);              if($colorLoop->have_posts()):             while($colorLoop->have_posts()):                 $colorLoop->the_post();              $theColor = get_post_meta($post->ID, 'colors', false);              /*random color*/         $rand_color = array_rand($theColor,1);         $rand_color_value = $theColor[$rand_color];         echo $rand_color_value;               ?>              <?php endwhile; endif;?>              <?php wp_reset_postdata; ?>


Widget development - Drop down options won't save

So, i successfully managed to add a drop down option, the problem is when i click save all of the options are removed, however the chosen option is implemented successfully. Here is the relevant code:               function widget($args, $instance) {             extract( $args );                  $pfxattribution = $instance['pfx-attribution'];     }          <p>                 <label for="<?php echo $this->get_field_id('pfx-attribution'); ?>"><?php _e('Choose attribution:'); ?></label>                 <select id="<?php echo $this->get_field_id('pfx-attribution'); ?>" name="<?php echo $this->get_field_name('pfx-attribution'); ?>" class="widefat" />                  <option>Purefx</option>                 <option>Foreign Exchange</option>                 <option>Currency Exchange</option>                 </select>                 </p>          function update($new_instance, $old_instance) {             // Get the old values             $instance = $old_instance;                  // Update with any new values (and sanitise input)             $instance['pfx-attribution'] = strip_tags( $new_instance['pfx-attribution'] );                 return $instance;     }      Any help is greatly appreciated


Sort results by name & asc order on Archive.php

I currently use the following code to list posts in Archive.php but I want the results to be ordered by name in ascending order, I have checked the codex but the answer isn't clear to me, how can I get this working?               <?php $post = $posts[0]; // ?>      Thanks in advance.


Custom field values to taxonomy terms

I have a "author" custom field with the names of author. I want to add some new features to the site so I decided that custom taxonomies will be the best solution. So what I need to do is to get the value of the custom field and pass it to the custom taxonomy called artist. Sure I can do this manually but it is more than 1000 posts so it would be hell. I guess the solution will be connected with wp_set_object_terms(); function, but nothing I tried worked. Thank you for any answer.


register_activation_hook and updating

I have used:               register_activation_hook(__FILE__, 'CrayonWP::install');      In `install()` I would like to check the plugin version being installed, and if it is below a certain version, I would like to alter the existing database model to the new format. How would I determine the version being installed?


PHP loop that selects posts with a particular in-post option

Im trying to build a Featured post slider to show any post that i `mark as a "featured"` (with a in-post option) regardless the category or tag type... Im new to wordpress and although I understand a little bit php language im not a coder :( The slider is already working. The question is, how can can i build this slider with a loop to show the last `7` post marked as "featured" with the corresponding featured image? I already have the in-post option set up in a metabox in the post edit page, also the image size configured in my function.php ... Im using wordpress 3.1 with the genesis framework. Here is the slider code

POST TITLE

Post Description limited to 150 character

POST TITLE

Post Description limited to 150 character

POST TITLE

Post Description limited to 150 character

POST TITLE

Post Description limited to 150 character

Content Title H3

20.01.2010 | CATEGORY NAME

Content Title H3

20.01.2010 | CATEGORY NAME

Content Title H3

20.01.2010 | CATEGORY NAME

Content Title H3

20.01.2010 | CATEGORY NAME

      here is a screenshot of the slider.. ![Slider Screenshot](http://i.stack.imgur.com/XxphB.png) UPDATE: in my functions.php files i have this..               // Add new image sizes     add_image_size('Slider', 315, 300, TRUE);          require_once(CHILD_DIR . '/lib/admin/inpost-settings.php');     wich is the code below..      inpost-settings.php               $prefix = 'myslider_';          $meta_box = array(         'id' => 'slider-meta-box',         'title' => 'Featured Slider Options',         'page' => 'post',         'context' => 'normal',         'priority' => 'high',         'fields' => array(             array(                 'name' => 'Show in featured slider',                 'id' => $prefix . 'show_post_slider',                 'type' => 'checkbox'             )         )     );     add_action('admin_menu', 'mytheme_add_box');          // Add meta box     function mytheme_add_box() {         global $meta_box;              add_meta_box($meta_box['id'], $meta_box['title'], 'mytheme_show_box', $meta_box['page'], $meta_box['context'], $meta_box['priority']);     }          // Callback function to show fields in meta box     function mytheme_show_box() {         global $meta_box, $post;              // Use nonce for verification         echo '<input type="hidden" name="mytheme_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';              echo '
';              foreach ($meta_box['fields'] as $field) {             // get current post meta data             $meta = get_post_meta($post->ID, $field['id'], true);                  echo '
',                     '', $field['name'], '	',                     '';             switch ($field['type']) {                  case 'checkbox':                     echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';                     break;             }             echo     '',                 '
';         }              echo '
';     }     add_action('save_post', 'mytheme_save_data');          // Save data from meta box     function mytheme_save_data($post_id) {         global $meta_box;              // verify nonce         if (!wp_verify_nonce($_POST['mytheme_meta_box_nonce'], basename(__FILE__))) {             return $post_id;         }              // check autosave         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {             return $post_id;         }              // check permissions         if ('page' == $_POST['post_type']) {             if (!current_user_can('edit_page', $post_id)) {                 return $post_id;             }         } elseif (!current_user_can('edit_post', $post_id)) {             return $post_id;         }              foreach ($meta_box['fields'] 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);             }         }     }     // check autosave     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {      return $post_id;     }      Thanks in advance.


Conditionally enable autoplay when using oEmbed in a custom widget

I'd like to have all oEmbed urls (youtube, vimeo, soundcloud, etc.) behave as they usually behave, with one exception. In my theme I've created a widget that gets data from a given post. The post content is rendered through `the_content()`. I'm planning to add a checkbox that allows to set the autoplay for any oEmbed media contained in the selected post. The only thing I don't know is how to handle this :) I suppose I must work with some filter, but:   1. I don't know which filter I should use   2. I don't know ho to hook to the filter **only** when rendering the widget. Thanks.


How to stop WordPress emailing a password

I am modifying the WP registration page to allow some additional information to be captured. As well as capturing this new info I have also modified it to allow users to set their own password. Everything works great and the user created password is sent to them in an email and can be used to access the website. However this is immediately followed by a second email with a system generated password. The system generated password does not actually work, and I don't want it to, but I'd like to stop the email being sent. I followed the guide here to get this far. Thanks.               add_action('user_register', 'copper_user_register', 10, 1);     function copper_user_register($user_id){              // Save the password         $userdata = array();              $userdata['ID'] = $user_id;         if ( $_POST['password'] !== '' ) {             $userdata['user_pass'] = $_POST['password'];         }              $new_user_id = wp_update_user( $userdata );         $plaintext_pass =   $_POST['password'];         wp_new_user_notification( $user_id, $plaintext_pass );          }


Update Post Meta for Arrays -- Remove/Replace Single Value from Multi Dimensional Array

I am trying to unset/remove then replace/update a single value from a post meta field, but my code for array_push() and unset() are removing all of the values from each array. Here are the two halves of the code I am currently using. First, to find and remove the old value:                $ID = $_GET["post_id"];      $old = $entry["85"];      $old_meta = array();      $old_meta = get_post_meta($old,'_website',false);           if(in_array($ID, $old_meta[current][items])){             unset($old_meta[current][items][$ID]);        }           update_post_meta($old,'_website',$old_meta);      Second to append the new value to the appropriate location:               $port = $entry["24"];     $new_meta = array();     $new_meta = get_post_meta($port,'_website',false);     $new_meta[content][items] = array();     array_push($new_meta[content][items],$ID);     update_post_meta($port,'_website',$new_meta);      It works to unset and insert the correct value, but any other values that were there (for both updating or unsetting) in the meta[current][items] array are removed


Displaying another main nav menu for specific category

I am pretty new to Wordpress, especially when PHP programming is concerned. I am using Ciola Theme from Theme Forest. What I would like to achieve is to display a sub menu under the main menu, but only for a specific category. I added menu in theme's **core-functions.php** :               add_theme_support( 'menus' );         // registering menus         register_nav_menus(             array(         'top' => 'Top Navigation Menu', // top nav         'main' => 'Main Navigation Menu', // main nav in header         'wybrzeze' => 'Wybrzeże Navigation Menu', // wybrzeze nav in header         'footer' => 'Footer Navigation Menu',  // secondary nav in footer             )         );      My entry is wybrzeze, Wybrzeże Navigation menu. I then edited the **header.php** file to try to add some information my theme supporter asked me to fill:                            <?php  if ( has_nav_menu( 'main' ) ) {                          $cb_main_menu = wp_nav_menu(                             array(                                 'echo'           => FALSE,                                  'container_class' => 'cb-main-menu',                                 'theme_location' => 'main',                                                     'depth' => 0,                                                                    'walker' => new CB_Walker,                                                                   'items_wrap' => '
%3$s
',                                 ));                      }             ?>                       <?php  if ( has_nav_menu( 'wybrzeze' ) ) {                          $cb_main_menu = wp_nav_menu(                             array(                                 'echo'           => FALSE,                                  'container_class' => 'cb-main-menu',                                 'theme_location' => 'main',                                                     'depth' => 0,                                                                    'walker' => new CB_Walker,                                                                   'items_wrap' => '
%3$s
',                                 ));                      }             ?>      If I understand it correctly, this is the place I have to add my sub-menu. At the very end of header.php there are divs which are responsible for displaying the "main" menu:
<?php if ( has_nav_menu( 'main' ) ) { echo $cb_main_menu; } ?>

<?php if ( has_nav_menu( 'main' ) ) {  main_nav(); } ?>
      Now, my question is: is it possible to achieve something like on this picture? Is there any way to make the second line of menu display only for a chosen category? I was thinking about using if/else PHP loop and WP reference `<?php is_category( $category ); ?>` but unfortunately I have no idea how to do this and I do not want to break the theme... I will really appreciate your help :) UPDATE & SOLUTION: Thanks to **Bindiya Patoliya** I have found the solution:               <?php if(is_category('teatr-wybrzeze')) {     wp_nav_menu( array(     'container_id' => 'cb-main-menu',     'container_class' => 'wrap clearfix',     'theme_location' => 'rafalmenu',                         'depth' => 0,                                                                        'items_wrap' => '
%3$s
',     'walker' => new CB_Walker     ) );     } ?>      It works great now! Thank you very much!


How can I exclude code from picture attachment pages?

I have been searching for the answer on this, and still haven't found something that works. Could someone kindly let me know how to exclude the following code from all the picture attachment pages of Wordpress? This code is currently in my single.php file so that I can manage it from a central location. I don't know a whole lot about code so any information you can provide is greatly appreciated. Thanks in advance!               `

                      <class="addthis_toolbox addthis_default_style">

          `


Set right order for query that returns posts based on two custom fields

My query arguments are inspired by a solution here. I needed to get posts with custom field `expert_intown` but I also needed to exclude posts that have the meta_key `coming_soon`. My arguments works fine, as in it returns the posts as expected. Now, I need help to get the results in right order, that is I need the posts with the field `expert_intown` to appear **before** the posts with the custom- field `coming_soon`. I have been trying for a while and currently I have this argument, which again fails.               $intown_args = array(                 'post_type' => 'post',                 'cat'  => 2,                 'numberposts' => -1,                 'post_status'  =>  'publish',                 'meta_query' => array(                                        'relation' => 'OR',                                     array( //posts that contain the meta_key expert_intown                                         'key' => 'expert_intown',                                        'value' => 'yes',                                        'compare' => 'EXISTS'                                     ),                                     array( //posts that dont contain the meta_key coming_soon                                        'key' => 'coming_soon',                                        'compare' => 'NOT EXISTS'                                     )                                 ),                 'meta_key' => 'expert_intown',                 'orderby' => 'meta_value',                 'order' => 'DESC'                 );                       $int_pro = new WP_Query( $intown_args );      NOTE : This query works fine with `'orderby' => title or date`, just fails to group together the posts containing the field `'expert_intown'`. * * * Also please note that every value of `expert_intown` is set to `yes`, perhaps the reason to fail, as I may be trying to order by values which are all equal. But even in that case **shouldn't it be grouped together** ?, because right now the posts with the field `expert_intown` are mixed with posts with field `coming_soon`. * * * **UPDATE FIRST** : As a shot in the dark, I tried the `posts_orderby` filter as suggested in a solution here. Hopefully to get posts by meta_value and then date, but does not seem to work either. Here is now what the code looks like with the filter.               $intown_args = array(                 'post_type' => 'post',                 'cat'  => 2,                 'numberposts' => -1,                 'post_status'  =>  'publish',                 'meta_query' => array(                                     'relation' => 'OR',                                     array(                                          'key' => 'expert_intown',                                        'value' => 'yes',                                        'compare' => 'EXISTS'                                     ),                                     array(                                         'key' => 'coming_soon',                                        'compare' => 'NOT EXISTS'                                     )                                 )                 );           add_filter( 'posts_orderby', 'modify_orderby' );     function modify_orderby( $orderby ) {             global $wpdb;             $orderby = " $wpdb->postmeta.meta_value DESC, $wpdb->posts.post_date DESC ";             return $orderby;     }     $int_pro = new WP_Query( $intown_args );     remove_filter( 'posts_orderby', 'modify_orderby' );


Changing comments avatar

Is there a plugin that lets me change an avatar of a comment? Since I can edit comments, is it possible to add avatars as well? I don't have registered user on my blog, only guests and those who connect to comments via Facebook. Those that use FB authorization have an avatar but those who comment without one don't. I would like to be able to manually change an avatar of individual comments.


How do I list the pages of a custom taxonomy?

Grouping pages/posts into taxonomies is great IF you can list the pages under each category. For instance, I have set a taxonomy as 'WordPress Reference'. Then I have a "category" (I think that's what it is) under the taxonomy called "Subject 1". I have then set two pages to "Subject 1" under WordPress Reference. Then I created a custom page template with a wp_list_categories command:               <?php wp_list_categories('taxonomy=wordpress-reference'); ?>      Now this accomplishes a list of categories but for each category I want to display the list of pages associated with the category. How can I do this?


Determining URIs for plugin pages

Let's say I create a plugin with a menu page and three different submenu pages. How can I determine the URI for each one of them? For example, if I want to have a link on one of the pages to one of the other pages, how do I do that? I had this problem before, too, when I created a form to gather some information. I ultimately solved it by having the page that defined the form handle it. Like this:               <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">      How would I let another page handle the form data, i.e. what would I put in the action parameter. I noticed some people hardcode the URI one way or another, for example through               $_SERVER['PHP_SELF'].'?page=slug      But that won't work with all URL schemes.


How add / edit dynamically same meta boxes in CPT?

What I would like to do? :) I am sorry, but I am not native English, and I a newbie in WP. I don't know how I can search on it. So I created CPT (this is my first wp plugin). In CPT I only need the Title (the editor not), and I need add meta boxes like, what I can do. But this CPT as like a shop cart. The meta boxes are a property of an Betting (Tip).   * Number of the tip   * Name of the tip   * Multiple of the tip. And in the CPT if the admin clicks on the 'new button', the webapp has to create a new line, with these same fields. I can do this, and I can save this with Ajax one by one. I don't know how I can save the all betting with the Publish button. And **I don't know how can I view in the edit page?** Because sometime the webapps has to view 1 and **other times it has to view 3 or 4** betting. I think, I have to create a new template for the edit page. But I don't know how I can do this. So the CPT will be like an Shop cart for every orders. (a collection, I need this collection, to be able to create chunks for it). Where we can see the items of the cart, (different number items), and I can add, delete or edit the items in the cart. Has somebody got a good idea how I should start it? (Or a great link of a tutorial)


Load plugin JS in footer

I am trying to load JS files in my theme's to footer.All my custom JS files are being added to WordPress using `wp_enqueue_script`, but i am unable to find any way which will help me to load them in footer. one possible way is to               remove_action('wp_head', 'wp_print_scripts');     remove_action('wp_head', 'wp_print_head_scripts', 9);     add_action('wp_footer', 'wp_print_scripts', 5);     add_action('wp_footer', 'wp_enqueue_scripts', 5);      but that means , I need to list down all possible JS files being used in plugins and than remove those from `header` and add them to `footer`, but that seems a bit strange to me as I need to take care what new plugin i have added or removed. Is there any other alternate where i can let Wordpress load those JS files (including Plugin's) in footer section. Since I can add/ remove plugin, so i am not sure how to handle it.


Is it possible a one click user registration with Facebook or Twitter (or other Social Networks)?

Would it be possible to create a wp user by signin up with Facebook connect? (And through Twitter app, and eventually other major social networks? Facebook is most important, then Twitter, the rest are not so important) - User fills form with one click, eventually is asked in the form to fill a custom display name (otherwise defaults to Facebook user name / Twitter user etc). I'm a bit confused whether this is achievable or not. Certain plugins seem to allow user publication of comments without registering, but what I really want is to create a normal WP user (also because on my WP site I have a BB Press forum, plus Gravity form modules, so it's not just a blog, I have a complex CMS setup). Is there an existing plugin (even commercial, not free) that does exactly what I want? Furthermore, I would like to make this happen on custom registration/login forms, I do not wish to use the default wp-register and wp-login pages at all. I have tried Simple Facebook connect and Simple Twitter connect, but they do not work on custom login/registration pages and I haven't figured how to make them work there. As for Gigya and JainRain I haven't understood if they actually create a user or just create a login. Can someone clarify? many thanks


Display related posts with same category or same tag return blank

I'm trying to display 4 related posted in the same category or have the same tag with the current post on the single post page. The result is just blank.                   <?php           $rCateogry = wp_get_post_categories($post->ID);           $rTag = wp_get_post_tags($post->ID);           $args =              array(                'tax_query' => array(                 'relation' => 'OR',                 array(                   'taxonomy' => 'category',                   'field'    => 'id',                   'terms'    => $rCateogry,                 ),                 array(                   'taxonomy' => 'tag',                   'field'    => 'id',                   'terms'    => $rTag,                 ),               ),               'numberposts' => 4,               'post__not_in' => array($post->ID)             );           $query = new WP_Query( $args );         ?>         <?php if ( $query->have_posts() ) : ?>
           <?php while ( $query->have_posts() ) { ?>             <?php $query->the_post(); ?>
               <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
                 <?php if ( has_post_thumbnail()) : ?>                   <?php the_post_thumbnail("custom-ss"); ?>                 <?php endif ?>

<?php the_title(); ?>
                              <?php get_template_part('templates/entry-meta'); ?>
           <?php } wp_reset_postdata(); ?>
         <?php endif; ?>


Enable page templates. How?

Basic question, but I want to enable page templates. I have one theme which has page templates enabled. I switched to another but there is no option to change the template, even when creating a new page. How do I switch this option on? I've had a root around on the Codex and forum but can't find it.


Two domains on one Wordpress Installation

I recently changed the base domain on my Wordpress website from http://www.fsdegrees.com to http://www.56degrees.co.uk. I would like to create various of 301 from old domain to new one, but for some reason I can still access pages using the old domain www.fsdegrees.com/blog I though it should come back with 404. I'm just afraid that Google will penalize me for double content. Any idea why that's happening. Many thanks,


Best collection of code for your .htaccess file

We have the Best Collection of Code for your functions.php file thread, so I thought that it might be useful to create a thread for our .htaccess files. **AND PLEASE REMEMBER TO ADD ANY OF YOUR OWN SNIPPETS TO THIS LIST**