wordpress page filter problems

Hello I been working on post type filter so I can filter my content for taxonomies type but for what ever reason I can never get it to filter when I click filter               public function product_filters( $args = array() ) {         global $typenow, $wp_query;              //if ( $typenow != 'product' )         //  return;              $post_types = get_post_types( array( '_builtin' => false ) );              // check we're in the right place, otherwise return         if ( !(in_array( $typenow, $post_types )) )              return;              $filters = get_object_taxonomies( $typenow );              foreach ( $filters as $tax_slug ) {             $tax_obj = get_taxonomy( $tax_slug );                  // check if anything has been selected, else set selected to null             $selected = isset($wp_query->query[$tax_slug]) ? $wp_query->query[$tax_slug] : null;                  wp_dropdown_categories( array(                 'show_option_all'   => __($tax_obj->label . ' - All'),                 'taxonomy'          => $tax_slug,                 'name'              => $tax_obj->name,                 'orderby'           => 'name',                 'selected'          => $selected,                 'hierarchical'      => false,                 'show_count'        => false,                 'hide_empty'        => false             ) );         }          }          public function product_filters_query( $query ) {         global $typenow, $wp_query;              if ( $typenow == 'product' ) {                  $query->set( 'post_type', 'product' );                  $filters = get_object_taxonomies( $typenow );                  foreach ( $filters as $tax_slug ) {                 if ( isset( $query->query_vars[$tax_slug] ) && $query->query_vars[$tax_slug] != '0' ) {                     $tax_query[] = array(                         'taxonomy' => $tax_slug,                         'field' => 'id',                         'terms' => get_terms( $tax_slug, array( 'fields' => 'ids' ) ),                         //'operator' => 'AND'                         'operator' => 'IN'                     );                 }             }                  $query->set( 'tax_query', $tax_query );             echo print_r($query, true);             return $query;         }     }      can anyone help as I run a foreach to build the table and set the tax query but no matter what I try this does not seem to be working


What does $_registered_pages do?

I would like to know what $_registered_pages does and where am I supposed to use it. Thanks. p.s was unable to find any documentation on it online.


Display category tree of a post in search results

Do anyone know how to display a category tree of a post in the search result. Foe example: If a post is in level 3 category level 1-> level 2 -> level 3 where the level one is the parent one.


Function to add custom HTML into head in custom post-type list page

![enter image description here](http://i.stack.imgur.com/C21BS.gif) How can I add custom HTML/PHP file into head where custom post-type list showing like this ? Any Wordpress function can do this ? or I can only do by JS(jQuery) to append my custom content ?


Why is `--` converted into ndash and how can I get rid of it?

I have a blog where I publish Linux tutorials. Some of the commands I listed have a `\--` before command-line arguments. e.g.: `dpkg --get-selections`. The problem is that WordPress automatically switches `\--` to an - (`–`). I know I could use the `−−` HTML entities, but the display is slightly different than the keyboard `-` sign. What I want is to disable this behaviour of WP. Is there a way to solve this?


Change position of Post Formats box?

I have added post formats support to my theme. The post formats box appears on the bottom of the sidebar in the New/Edit post page. It appears below the Categories, Tags and Featured Image. Is it possible to change its position in the sidebar and for example show it before the categories? I understand we can drag and drop the boxes, but I want to set the default position. Thanks.


Conditionally enqueue a widget's script/stylesheet in HEAD (only when present on page!)

I've been trying to load scripts and styles for a WordPress widget with the following conditions...   1. The scripts MUST load in the HEAD (else they break).   2. The scripts must ONLY load when the widget actually displays (they're quite heavy). I've done a lot of searching, and this seems to be a common (unsolved) problem...but I'm hoping someone here has successfully implemented a workaround. This is the best I've got so far... The following is a simple widget that prints text to the sidebar. It successfully loads jQuery conditionally (when the widget is actually displayed)...though only ever in the footer! (Note: it may also only work on WordPress 3.3, though this hack may provide backwards compatibility).               class BasicWidget extends WP_Widget     {              function __construct() {             parent::__construct(__CLASS__, 'BasicWidget', array(                 'classname' => __CLASS__,                 'description' => "This is a basic widget template that outputs text to the sidebar"             ));         }            function form($instance) {         $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );         $title = $instance['title'];     ?>
<label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
     <?php       }            function update($new_instance, $old_instance) {         $instance = $old_instance;         $instance['title'] = $new_instance['title'];         return $instance;       }            function widget($args, $instance) {              extract($args, EXTR_SKIP);              echo $before_widget;         $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);              if (!empty($title))           echo $before_title . $title . $after_title;;              echo "
This is a basic widget!
";              echo $after_widget;                  // if we're echoing out content, enqueue jquery.                  if (!empty($after_widget)) {                 wp_enqueue_script('jquery');             }         }     }     add_action( 'widgets_init', create_function('', 'return register_widget("BasicWidget");') );      It seems once WordPress starts handling widgets, it's too late to enqueue (or even deregister something enqueued earlier). Any ideas would be much appreciated! Mark.


Menu page with minimum capability as 'Subscriber' doesn't allow 'Admin' to access it?

I've added a separate menu page (an object page) with minimum access level required as 'Subscriber'. I'm doing this because I'm registering new users and they'll be 'Subscribers' with an extra capability to edit a section that my plugin creates. So I want them to be able to see this menu as well. I created my menu page as follows: `add_object_page('Personal Section', 'Personal Section', 'subscriber', 'personal-section', 'personal_section_fn');` Now when I log in with the subscriber credentials, I'm able to see this menu, but I'm not able to see it when logged in as Admin. Am I doing something wrong here? Thanks in advance!


Theme Install using a Custom Repository

The standard WP Themes Install is available in Appearance --> Theme Install nav-tab. There is a way to add a new nav-tab and browsing into a Custom Themes Repository? Thanx


Anyone using unzip_file successfully? It uploads the zip but doesn't extract it!

When I call the WordPress unzip_file() function below, instead of actually extracting the zip, it merely moves it into the target folder. When I trace $file and $to from includes/file.php I get:               file: C:\xampplite\htdocs\testsite/wp-content/themes/mytheme/styles/myzip.zip           To: C:\xampplite\htdocs\testsite/wp-content/themes/mytheme/styles/      What am I missing?               <?php     require('../../../wp-blog-header.php');     require('../../../wp-admin/includes/file.php');     ?>     <?php       if (!is_user_logged_in()){         die("You Must Be Logged In to Access This");     }     if( ! current_user_can('edit_files')) {         die("Oops sorry you are not authorized to do this");     }     ?>          <form enctype="multipart/form-data" action="" method="post">         <input type="file" name="fupload" />

         <input type="submit" value="Install" onclick="doLoader();" />     </form>          <?php          if(isset($_FILES['fupload'])) {         $filename = $_FILES['fupload']['name'];         $source = $_FILES['fupload']['tmp_name'];         $type = $_FILES['fupload']['type'];          $name = explode('.', $filename);          $target = TEMPLATEPATH.'/styles/';              // permission settings for newly created folders         $chmod = 0755;                $saved_file_location = $target . $filename;         if (move_uploaded_file($source, $saved_file_location))          {             unzip_file($saved_file_location, $target);         }          else          {             die("There was a problem with the upload. Plese verify you have uploaded a valid zip file");         }     }     ?>


Adding fields to category manager. Does a method exist to get the link to the category edit screen?

This code is working fine, just want to make sure I'm ok with hardcoding the href to the category edit screen with...               "edit-tags.php?action=edit&taxonomy=category&post_type=post&tag_ID='.$cat_id.'"      Or is there a method I should call to get the category edit link dynamically (in case the call ever gets changed)?               //add the filter in order to add custom columns to the category manager      add_filter('manage_category_custom_column', 'display_cat_columns', 10, 3);          //This function outputs the custom category image onto each row of the category manager grid.     function display_cat_columns($arg1, $column_name, $cat_id){       if ('ce4_cat_image' == $column_name) {       return 'get_category_thumbnail_admin($cat_id, 'thumbnail').'';}     }


Get the url of the full sized attachment image using post ID?

I have this function:               function get_image_link( &$post ) {              $image_link_meta = get_post_meta( $post->ID, 'as_link_to_image', true );                    $image_link_from_post = '';                   if ( function_exists( 'has_post_thumbnail' ) && has_post_thumbnail( $post->ID ) ) {                 $attachment_image_link = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), full );              }                   if ( $attachment_image_link[0] )                 $image_link_from_post = $attachment_image_link[0];                   if( !empty( $image_link_meta ) )                  $final_image_link = $image_link_meta;                   elseif( !empty( $image_link_from_post ) )                 $final_image_link = $image_link_from_post;                    else                 $final_image_link = WP_PLUGIN_URL . '/link/to/no-image.png';                   return $final_image_link;         }     }      Any idea why `$image_link_from_post` isn't getting a value?


Where to store PHP files created by plugin / themes

There are cases in which a plugin or theme needs to create a php file somewhere that can later include it. For example a captcha plugin, or some kind of a templating system like twig/smarty (In my situation it's simple template engine for a collection of widgets). Where should be this file created? The only place I can think of is `wp-content/uploads/`, but that just doesn't sound right :) So is there a safe place where you can create files, and not worry about them being deleted on WordPress/plugin/theme update ? One solution could be to create a child theme / directory in the themes / plugins directory...


Using Genesis - content archive not displaying all items from post

I have set genesis to display post content with a limit of 400 characters. Everything is fine except it is not posting the social media share icons. They appear on the individual blog posts but not on the content archive page. On my custom posts content archives they are fine. ![enter image description here](http://i.stack.imgur.com/x6oeT.png) ![enter image description here](http://i.stack.imgur.com/ZuPcp.png) The site is here: http://www.getconnectedmedia.com/wp/?cat=2


Beginning with Multi-Site LOCAL Installation

I'm not sure if this question is appropriate for this forum or not. If not, perhaps someone can point me to a better forum. I have several affiliated websites running on a CMS I put together myself and am thinking of upgrading to WordPress and/or Drupal. That is, I might use WordPress for some sites, Drupal for others. Or maybe I'll go WordPress all the way. I work with PHP and MySQL on a Mac running MAMP. My websites display locally at URL's like h t t p://GW and h t t p://GZ I think the quickest way to check out WordPress would be to do a LOCAL multi- site installation. I would then set up parallel sites that display at h t t p://GW2 and h t t p://GZ2. In other words, I would essentially copy all my websites and upgrade that copy to WordPress. I could then view an original site or the WordPress version in my browser. If everything works out, I could then replace a dozen online websites with a dozen WordPress sites. Or if I decide to just change one site to WordPress, I could just publish that site. Can this be done? I suspect I'll also have to deal with conflicts between databases, JavaScript and CSS files, etc. I'll probably hire a consultant to help me get started, but I would like to know if my basic plan will work. P.S. I read the discussion @ WordPress multi-site, developing locally and syncing live changes but it's a little confusing for me. These two articles were some help... Installing WordPress locally http://codex.wordpress.org/Installing_WordPress_Locally_on_Your_Mac_With_MAMP


How to implement a WordPress comments function?

**I have loop, wich create news feed, it looks like:** (part of news template) News.php

                 <?php query_posts('category_name=News');?>                 <?php  if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php the_title(); ?>

<?php the_time('F jS, Y'); ?>

<?php the_content(); ?>
                             <a href="<?php comments_link(); ?>">Comments to this post     (<?php comments_number('0', 'One Response', '%' ); ?>)
                 <?php endwhile;?>                 <?php endif; ?>

      <?php         get_footer();      ?>         Comments.php               <?php     /**      * @package WordPress      * @subpackage Starkers HTML5      */     // Do not delete these lines             if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' ==         basename($_SERVER['SCRIPT_FILENAME']))             die ('Please do not load this page directly. Thanks!');              if ( post_password_required() ) { ?>
This post is password protected. Enter the password to    view comments.
             <?php             return;         }     ?>               <--edit from here-->     <?php get_header();     get_template_part('nav');  ?>

        <--end editing heret-->          <?php if ( have_comments() ) : ?>
<?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”
              <?php previous_comments_link() ?> <?php next_comments_link() ?>                       <?php wp_list_comments('callback=html5_comment&end-callback=close_comment'); ?>              <?php previous_comments_link() ?> <?php next_comments_link() ?>          <?php else : // this is displayed if there are no comments so far ?>              <?php if ( comments_open() ) : ?>                    <?php else : // comments are closed ?>
Comments are closed.
          <?php endif; ?>
<?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?>

<?php cancel_comment_reply_link(); ?>
          <?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
You must be <a href="<?php echo wp_login_url( get_permalink() ); ?>">logged in to post a comment.
     <?php else : ?>          <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">              <?php if ( is_user_logged_in() ) : ?>
Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out »
              <?php else : ?>
<input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" <?php if ($req) echo "required"; ?> />         Name <?php if ($req) echo "(required)"; ?>

<input type="email" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" <?php if ($req) echo "required"; ?> />         Mail (will not be published) <?php if ($req) echo "(required)"; ?>

<input type="url" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" />         Website
              <?php endif; ?>                            <textarea name="comment" id="comment" cols="50" rows="10" required></textarea>              <button type="submit" name="submit" id="send">Submit Comment</button>              <?php comment_id_fields(); ?>              <?php do_action('comment_form', $post->ID); ?>          </form>          <?php endif; // If registration required and not logged in ?>
          <?php get_footer(); ?>      Link to comments works fine, comments appear inside of container "content" and looks good. but previous, current and next posts appear outside of container "content", after header and before all other content. I made changes only in news page template and my_theme/comments.php file. (tags "edit from here" and "end editing here") Which files I need to modify else? What is the problem could be?


Social sharing toolkit is not showing on ajax load

I am using Social sharing toolkit (http://wordpress.org/plugins/social- sharing-toolkit/) in my website. This plugin is working fine with common posts but not working with ajax loaded posts. Is there any fixes for this?.


WordPress Network (sub folder) 404 issue

I've installed WP 3.7.1 on Apache (Linux). Note that this is a brand new install. I configured it for Network Sites (Sub folders). When I go to the root site (i.e. `http://example.com/`) I see the blog. When I go to a new site that i created in the main dashboard (`http://example.com/newsite/`) I get a 404 error message. I've searched a lot of articles but have been unable to resolve the issue. Here's my `.htaccess` file:               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]     RewriteRule . index.php [L]      My `wp-config.php` file looks like this (just at the bottom, these are all the changes I've made):               /* Multisite */     define( 'WP_ALLOW_MULTISITE', true );          define('MULTISITE', true);     define('SUBDOMAIN_INSTALL', false);     define('DOMAIN_CURRENT_SITE', 'aggrssgator.com');     define('PATH_CURRENT_SITE', '/');     define('SITE_ID_CURRENT_SITE', 1);     define('BLOG_ID_CURRENT_SITE', 1);      Update: I've solved the issue (see my comment below - wasn't allowed to answer my own question)


Customizing the custom post type permalink

I understand how to register a custom post type, customize the slug and decide whether to add the 'front' (the WP permalink settings) or not. What I'd like to do is customize the permalink by adding               ?username      At the end of the custom post type's url. Now I know the cleaned up Author Name can be added in the WP permalink settings but I don't want that - I'm looking for the username used to login. For example: I create a custom post type called 'Home' (singular) with the custom slug 'homes.' The url would be: > www.mydomain.com/homes/postname I want the url to look like this instead: > www.mydomain.com/homes/postname?username I'm not sure how to do it by modifying the usual method of registering a content type:               add_action( 'init', 'create_posttype' );     function create_posttype() {       register_post_type( 'home',         array(           'labels' => array(             'name' => __( 'Homes' ),             'singular_name' => __( 'Home' )           ),           'public' => true,           'has_archive' => true,           'rewrite' => array('slug' => 'homes'),         )       );     }      I experimented a bit and ended up making my site completely inaccessible so I decided some help would be worth asking for :P


Can I use MariaDB instead of MySQL in wordpress?

Is it possible to use MariaDB instead of MySQL in Wordpress installation? If possible: how do I do that? Is there any drawback or complexities?


attachment custom values are'nt inserted to database

I have created attachment custom field. After I uploading image and inserting to new-post.php (post creating window) no meta values are saved in database. Even that I have set a default value for custom attachment field.               array(2) {       ["_wp_attached_file"]=>       array(1) {         [0]=>         string(22) "2014/09/pics-076-1.jpg"       }       ["_wp_attachment_metadata"]=>       array(1) {         [0]=>         string(769) "a:5:{s:5:"width";i:500;s:6:"height";i:500;s:4:"file";s:22:"2014/09/pics-076-1.jpg";s:5:"sizes";a:3:{s:9:"thumbnail";a:4:{s:4:"file";s:22:"pics-076-1-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:22:"pics-076-1-300x300.jpg";s:5:"width";i:300;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";}s:14:"post-thumbnail";a:4:{s:4:"file";s:22:"pics-076-1-500x372.jpg";s:5:"width";i:500;s:6:"height";i:372;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:11:{s:8:"aperture";i:0;s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";i:0;s:9:"copyright";s:0:"";s:12:"focal_length";i:0;s:3:"iso";i:0;s:13:"shutter_speed";i:0;s:5:"title";s:0:"";s:11:"orientation";i:0;}}"       }     }      This makes an error, because I'm calling                   $attachment_meta = get_post_custom($attachment['id']);       function and it returns nothing. But When I edit custom meta attachment at image edit window, meta appears in database and above mentioned function returns good values. and $attachment_meta looks like               array(5) {       ["_wp_attached_file"]=>       array(1) {         [0]=>         string(22) "2014/09/pics-076-1.jpg"       }       ["_wp_attachment_metadata"]=>       array(1) {         [0]=>         string(769) "a:5:{s:5:"width";i:500;s:6:"height";i:500;s:4:"file";s:22:"2014/09/pics-076-1.jpg";s:5:"sizes";a:3:{s:9:"thumbnail";a:4:{s:4:"file";s:22:"pics-076-1-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:22:"pics-076-1-300x300.jpg";s:5:"width";i:300;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";}s:14:"post-thumbnail";a:4:{s:4:"file";s:22:"pics-076-1-500x372.jpg";s:5:"width";i:500;s:6:"height";i:372;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:11:{s:8:"aperture";i:0;s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";i:0;s:9:"copyright";s:0:"";s:12:"focal_length";i:0;s:3:"iso";i:0;s:13:"shutter_speed";i:0;s:5:"title";s:0:"";s:11:"orientation";i:0;}}"       }       ["meta_link"]=>       array(1) {         [0]=>         string(0) ""       }       ["_image_stars"]=>       array(1) {         [0]=>         string(1) "1"       }       ["_image_disposition"]=>       array(1) {         [0]=>         string(8) "portrait"       }     }      Should I add action or hook for permanent meta value inserting to database or what the heck is going on here?


Wordpress link to show popup box

I have a button on my wordpress page that is wrapped in tags. Can I edit the link so that when someone clicks on it, it just shows them a popup message box, and stays on the page that they were on? Thanks! Sample code:


Is there a way of retrieving the core WP capabilities?

I've created a plugin that adds new capabilities & assigns them to both WP & core WP roles. I would like to remove these capabilities when the plugin is deactivated, but I need to check that I'm not removing a core WP capability. Is there a way to get an array containing just the WP core capabilities rather than hard coding the list (which would not be future-proof)?


link to a random custom post while excluding current post

I am using the below code to create a link from a custom post to another random custom post.               <?php $args=array('post_type'=>'projects', 'orderby'=>'rand', 'posts_per_page'=>'1'); $projects=new WP_Query($args); while ($projects->have_posts()) : $projects->the_post(); ?>      <a href="<?php the_permalink() ?>">Another Project      <?php endwhile; wp_reset_postdata(); ?>      however, the link is still picking up the current post in its random selection so would like to try and exclude the current post somehow.


How do I change the order (ASC and DESC) in the following retrieval method using WP_Query?

The following code retrieves only custom post types with the custom taxonomy "Slider." I would like to change their order to ASC. The code:               <?php // Retrive custom post type with a custom taxonomy assigned to it      $posts = new WP_Query('post_type=page_content&page_sections=Slider (Front Page)') ?>      <?php while ( $posts->have_posts() ) : $posts->the_post(); ?>      <?php the_content(); ?>     <?php endwhile; ?>     <?php wp_reset_query(); ?>      Not sure if I should use an array (not sure how anyways). Any suggestions?


Wordpress E-mail Config

For built-in Wordpress functions such as the "forgot password" option, where is the SMTP server configured? Does it just default to the local daemon? What e-mail does it send messages as?


Converting a hierarchy of off-site web-links to Word-Press

I'm looking at converting several PHP-Fusion sites to WordPress. I'm wondering how to convert a page like this: http://biztalk-training.com/weblinks.php. Is there a plug-in for links that will create a similar type page. Each link can have an abstract and the URL, and with PHP-Fusion it even tracks which links get clicked, but I can do without the counts or use Google-Analytics for that.


Looking for a way to include/embed text from a file on a page so that the short codes are processed

I'm using WP as a CMS. I've got multiple pages that share the same header. group 1 has header 1. group 2 has header 2. etc. I've looked at these two plugins for a quick way to insert a combination of html and shortcodes. http://wordpress.org/extend/plugins/wp-include-file/ http://wordpress.org/extend/plugins/post-snippets/ Both solutions are neat, but they do not process the short codes. Example:
          [caption id="attachment_214" align="alignnone" width="75" caption="Pack Rat"][/caption]          [caption id="attachment_218" align="alignnone" width="75" caption="Pocket Gopher"][/caption]
      Does anyone know of an alternative way to embed or include this code from an external file (in an include folder on the server) and have the shortcodes processed? Thanks!


What does "link" refer to when you delete a user?

I'm not sure if this is BuddyPress or not but what does "links" refer to when you delete a user? http://screencast.com/t/ZeMQUG368t


How to add line breaks inside Gallery Captions

I am using this excellent piece of code to insert a line break in single image captions by way of inserting a pipe character... Now I would like your help to try to incorporate this into the gallery image captions too. Here's the original code that works for single image captions. My attempt at the gallery code is below.               /*     *********************************************     Function to allow multi-line photo captions.     This function will split captions onto multiple lines if it detects     a "|" (pipe) symbol.     **********************************************     */     /* Override existing caption shortcode handlers with our own */     add_shortcode('wp_caption', 'multiline_caption');     add_shortcode('caption', 'multiline_caption');          /* Our new function */     function multiline_caption($attr, $content = null) {     extract(shortcode_atts(array(     'id' => '',     'align' => 'alignnone',     'width' => '',     'caption' => ''     ), $attr));          if ( 1 > (int) $width || empty($caption) )     return $content;          if ( $id ) $id = 'id="' . esc_attr($id) . '" ';          $new_caption = str_replace("|", "
", $caption);          return '
'     . do_shortcode( $content ) . '
' . $new_caption . '

';    }      Original code by Mark Wood: http://digitalnotions.net/multi-line-captions-in- wordpress **Here is my attempt with the gallery shortcode in functions.php file** This is basically the code copied from wp-includes/media.php gallery function. I've amended the output function at the end of this code (original code commented) to try to get the pipe in there, but it's not working on my gallery captions ! Your help greatly appreciated.               remove_shortcode('gallery', 'gallery_shortcode');          add_shortcode('gallery', 'multiline_caption_gallery');               /* Our new function */          function multiline_caption_gallery($attr) {     global $post;          static $instance = 0;     $instance++;          extract(shortcode_atts(array(         'order'      => 'ASC',         'orderby'    => 'menu_order ID',         'id'         => $post->ID,         'itemtag'    => 'dl',         'icontag'    => 'dt',         'captiontag' => 'dd',         'columns'    => 3,         'size'       => 'thumbnail',         'include'    => '',         'exclude'    => ''     ), $attr));          $id = intval($id);     if ( 'RAND' == $order )         $orderby = 'none';          if ( !empty($include) ) {         $include = preg_replace( '/[^0-9,]+/', '', $include );         $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );              $attachments = array();         foreach ( $_attachments as $key => $val ) {             $attachments[$val->ID] = $_attachments[$key];         }     } elseif ( !empty($exclude) ) {         $exclude = preg_replace( '/[^0-9,]+/', '', $exclude );         $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );     } else {         $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );     }          if ( empty($attachments) )         return '';          if ( is_feed() ) {         $output = "\n";         foreach ( $attachments as $att_id => $attachment )             $output .= wp_get_attachment_link($att_id, $size, true) . "\n";         return $output;     }          $itemtag = tag_escape($itemtag);     $captiontag = tag_escape($captiontag);     $columns = intval($columns);     $itemwidth = $columns > 0 ? floor(100/$columns) : 100;     $float = is_rtl() ? 'right' : 'left';          $selector = "gallery-{$instance}";          $gallery_style = $gallery_div = '';     if ( apply_filters( 'use_default_gallery_style', true ) )         $gallery_style = "                  ";     $size_class = sanitize_html_class( $size );     $gallery_div = "
";     $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );          $i = 0;                    foreach ( $attachments as $id => $attachment ) {         $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);              $output .= "<{$itemtag} class='gallery-item'>";         $output .= "             <{$icontag} class='gallery-icon'>                 $link             </{$icontag}>";                              /* ORIGINAL CODE DISABLED                       if ( $captiontag && trim($attachment->post_excerpt) ) {          $output .= "                 <{$captiontag} class='wp-caption-text gallery-caption'>                 " . wptexturize($attachment->post_excerpt) . "                 </{$captiontag}>";         }         $output .= "</{$itemtag}>";         if ( $columns > 0 && ++$i % $columns == 0 )             $output .= '
';     }          $output .= "

\n";          return $output;}                */   // end disable original code                         // REPLACEMENT CODE added by sol to allow line breaks in the captions                  if ( $captiontag && trim($attachment->post_excerpt) ) {      $new_captiontag = str_replace("|", "
", $captiontag);                       $output .= "                 <{$new_captiontag} class='wp-caption-text gallery-caption'>                 " . wptexturize($attachment->post_excerpt) . "                 </{$new_captiontag}>";         }         $output .= "</{$itemtag}>";         if ( $columns > 0 && ++$i % $columns == 0 )             $output .= '
';     }          $output .= "

\n";          return $output;}


Can I specify post__in for one particular post type in the query?

I want to do something like this               $query_args = array(         'post_type' => array( 'cpt_1', 'cpt_2' ),         'post__in' => array( 1, 3, 5, 7 )     );      where I can specify which post type the post__in applies to. For example, I want to get **all** the posts from cpt_1, but I only want the cpt_2 ones that are specified in post__in. Is there an SQL hook (like posts_where) that can help me accomplish this? If not I guess I'll have to do two queries?


Using a Custom Field instead of original title field but only for Custom Post Type

I am trying to get a custom field value (Field "bildname") as my post title, and another (Field "bildbeschreibung") as my content in my Custom Post Type. It is not really working though. First it kept outputting "Auto Draft" for my Title. SO I started researching here, then I managed to make it visible as Title in the Backend but it didn't show up in the search when using the code from here. It seems it didn't really overwrite the Database entry. So now I've been using this code suggested in another Forum:               //SAVE CUSTOM FIELD "TITLE" AS TITLE         add_action('save_post', 'change_title');         function change_title($post_id) {                  $post_title = get_post_meta($post_id,'bildname',true);                 $my_post = array();                     $my_post['ID'] = $post_id;                     $my_post['post_title'] = $post_title;             remove_action('save_post', 'change_title');                         wp_update_post( $my_post );             add_action('save_post', 'change_title');              }          // SAVE CUSTOM FIELD INPUT CONTENT AS POST CONTENT     add_action('save_post', 'change_content');     function change_content($post_id) {             $post_content = get_post_meta($post_id,'bildbeschreibung',true);             $my_post = array();                     $my_post['ID'] = $post_id;                     $my_post['post_content'] = $post_content;     remove_action('save_post', 'change_content');                         wp_update_post( $my_post );     add_action('save_post', 'change_content');     }      That seemed to be working fine, until I realized it would now also change my PAGE's titles. From the title I set there in the original title field to nothing. Because I don't have a custom field "title" for pages. Now I need help to modify the functions I found to something, that will only affect my Custom Post Type "albertis-kunstwerke". I found this code, that is supposed to figure out if I am on a page, or post or whatever.               function get_current_post_type() {       global $post, $typenow, $current_screen;            //we have a post so we can just get the post type from that       if ( $post && $post->post_type )         return $post->post_type;            //check the global $typenow - set in admin.php       elseif( $typenow )         return $typenow;            //check the global $current_screen object - set in sceen.php       elseif( $current_screen && $current_screen->post_type )         return $current_screen->post_type;            //lastly check the post_type querystring       elseif( isset( $_REQUEST['post_type'] ) )         return sanitize_key( $_REQUEST['post_type'] );            //we do not know the post type!       return null;     }        It's from http://themergency.com/wordpress-tip-get-post-type-in-admin/ but I don't know how to combine it with the code above so the title changes will only happen for my CPT "albertis-kunstwerke" So, again. What I want to achieve is to make my Custom Field "bildname" (that I made with Advanced Custom Fields Plugin) my post-title. But this should only happen for Custom Post Type "albertis-kunstwerke". I need to be able to disable it for pages, since I don't have a custom field "bildname" there. And in case any of you wonder - I can not use the regular title field, because it has been specifically requested to use all Custom Fields.


How to display recent posts added in custom post types

I have tried a code posted here>>Custom Post Type: Get most recent permalink But the thing is-it is showing only one post from the recent and without get_the_title,,, can anyone help me to achieve, upto 10 posts' Title and permalink of custom post type. I am googling from about 1 hour.. Please anyone help me


Query posts dynamic date range

So, I'm using the following to filter posts:                                   $paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );                         $args['paged'] = $paged;                         $args['post_type'] = 'coupons';                         if(isset($_GET['sort']) && $_GET['sort'] == 'populair') {                             $args['orderby'] = 'comment_count';                             $args['order'] = 'desc';                              }                         elseif(isset($_GET['sort']) && $_GET['sort'] == 'best-beoordeeld-oplopend') {                             $args['paged'] = $paged;                             $args['post_type'] = 'coupons';                             $args['orderby'] = 'meta_value';                             $args['meta_key'] =  'gemiddeld_beoordeeld_met';                             $args['order'] = 'ASC';                                     }                              query_posts($args);      So, I know how to filter by monthnum, but unfortunately that's not sufficient. I am trying to query posts from the latest 7 days. Any clue, anybody?


Custom wp_query pagination - next_posts_link() or wp_pagenavi() always empty

I'm aware this is a topic discussed to death, but I have read through many solutions and can't understand why my pagination simply isn't working. I have a very simple custom wp_query:               $current_page = (get_query_var('paged')) ? get_query_var('paged') : 1;          $project_query = new WP_query(array(       'post_type' => 'project',       'paged' => $current_page,       'posts_per_page' => 50     ));      There are about `2000` projects in there, so without a doubt, there are pages. This is on my `index.php` of the theme. No matter what, the URL `/p/pageno` returns a 404. The function `next_posts_link('Older Entries »', $project_query->max_num_pages);` is always empty. I have tried, based on reading several similar questions:   1. Setting reading settings to display 1 post max at a time, to ensure pagination kicks in.   2. Installing wp_pagenavi - same result   3. Setting the homepage to a static page with this code in a custom page template - this finally works somewhat (`/p/2` etc don't 404), but then `next_posts_link()` stops at page 2 and goes no further.   4. change `get_query_var('paged')` to `get_query_var('page')` in the custom page template   5. rename `$project_query` to `$wp_query` I'm at a loss, this should be so simple, but pagination _always_ seems to be the one thing that kills me when working with Wordpress.


Wordpress Option Api:Using Image in Checkbox

I am using radio in settings api.I want to replace "Left" and "Right" with image.My code is               function menu_position() {     $options = get_option('plugin_options');     $items = array("Left", "Right");     foreach($items as $item) {         $checked = ($options['menu_position']==$item) ? ' checked="checked" ' : '';         echo "<input ".$checked." value='$item' name='plugin_options[menu_position]' type='radio' /> $item
";     }     }      This is basically replacing text with image.


How does register_post_type know how and which function to use from the add_action function?

This is from the WordPress site, and I can't find my answer in the documentation. When I issue the `register_post_type`, how does it know which function to use? I know the `init` action was populated with the custom hook `codex_book_init`, but when I look at register_post_type. It just has "book":               add_action( 'init', 'codex_book_init' );          register_post_type( 'book', $args );      How does this work? Not asking about all the `$args`, only the one(s) that matter for this question.               add_action( 'init', 'codex_book_init' );     /**      * Register a book post type.      *      * @link http://codex.wordpress.org/Function_Reference/register_post_type      */     function codex_book_init() {         $labels = array(             'name'               => _x( 'Books', 'post type general name', 'your-plugin-textdomain' ),             'singular_name'      => _x( 'Book', 'post type singular name', 'your-plugin-textdomain' ),             'menu_name'          => _x( 'Books', 'admin menu', 'your-plugin-textdomain' ),             'name_admin_bar'     => _x( 'Book', 'add new on admin bar', 'your-plugin-textdomain' ),             'add_new'            => _x( 'Add New', 'book', 'your-plugin-textdomain' ),             'add_new_item'       => __( 'Add New Book', 'your-plugin-textdomain' ),             'new_item'           => __( 'New Book', 'your-plugin-textdomain' ),             'edit_item'          => __( 'Edit Book', 'your-plugin-textdomain' ),             'view_item'          => __( 'View Book', 'your-plugin-textdomain' ),             'all_items'          => __( 'All Books', 'your-plugin-textdomain' ),             'search_items'       => __( 'Search Books', 'your-plugin-textdomain' ),             'parent_item_colon'  => __( 'Parent Books:', 'your-plugin-textdomain' ),             'not_found'          => __( 'No books found.', 'your-plugin-textdomain' ),             'not_found_in_trash' => __( 'No books found in Trash.', 'your-plugin-textdomain' )         );              $args = array(             'labels'             => $labels,             'public'             => true,             'publicly_queryable' => true,             'show_ui'            => true,             'show_in_menu'       => true,             'query_var'          => true,             'rewrite'            => array( 'slug' => 'book' ),             'capability_type'    => 'post',             'has_archive'        => true,             'hierarchical'       => false,             'menu_position'      => null,             'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )         );              register_post_type( 'book', $args );     }


header.php-tweak: How to do that getting Meta-Slider into the header-center?

running wp 3.9.1 with the following things on a truely beta-page called http://www.maedchenhaus.org theme 2014, child-theme (twentyfourteen-child) fourteen-colors-plugin and the meta-slider-plugin (( Easy to use slideshow plugin. Create SEO optimised responsive slideshows with Nivo Slider, Flex Slider, Coin Slider and Responsive Slides. Version 2.8.1 | By Matcha Labs | Visit plugin site )) well i want to place the plugin in the center of the header - - similar to the following site http://www.amadeu-antonio-stiftung.de/ is this possible? note: as it is now - it looks funny. i have put the plugin to the first posting - see it and besides this i have tried to put the shortcode into the header - while editing the header.php. But this looks pretty worhless. well question: where do i have to edit the header.php - where to put the shortcode of the meta-slider? love to hear from you see the code that i have found out - while using firebug - lemme know - where to add the shortcode to get the slider into the header - center. **update** guess that i have to enter this code               <?php          echo do_shortcode("[metaslider id=36]");      ?>      **end of update**               <!DOCTYPE html>

      see the header.php - and where i have edited it - well this is damned worthless. it makes no sense - no sense at all.               <?php     /**      * The Header for our theme      *      * Displays all of the  section and everything up till
      *      * @package WordPress      * @subpackage Twenty_Fourteen      * @since Twenty Fourteen 1.0      */     ?><!DOCTYPE html>                    <html <?php language_attributes(); ?>>                   <meta charset="<?php bloginfo( 'charset' ); ?>">         <meta name="viewport" content="width=device-width">         <title><?php wp_title( '|', true, 'right' ); ?></title>         <link rel="profile" href="http://gmpg.org/xfn/11">         <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">                  <?php wp_head(); ?>               <body <?php body_class(); ?>>
         <?php if ( get_header_image() ) : ?>
             <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">                 <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="">
         <?php endif; ?>

<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?>

                     <?php _e( 'Search', 'twentyfourteen' ); ?>
             [metaslider id=36]                                           <button class="menu-toggle"><?php _e( 'Primary Menu', 'twentyfourteen' ); ?></button>                     <?php _e( 'Skip to content', 'twentyfourteen' ); ?>                     <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>

                     <?php get_search_form(); ?>


Unwanted "crawl delay: 10" line added to my robots.txt

I've noticed that when I make a request to my `robots.txt` page, I get it with a `crawl delay: 10` line added to it. I double-checked the file, and it doesn't have that line, so why does it appear? Is it maybe a strange behaviour of some plugins?


Enable WordPress Sessions

I'm wondering why WordPress does not support sessions and many people out there claim that putting the following code in functions.php might not be a good idea (it in fact works for me but returns PHP warnings, too):               function cp_admin_init() {     if (!session_id())     session_start();     }          add_action(‘init’, ‘cp_admin_init’);      Is it good idea to enable sessions in WordPress? What would be the correct way to do this?


create template for one page

I want to create a one page template here and this is the content of `page- contactWohnsinn.php`: hello world So the php file only contains hello world and is stored in `...wp- content/themes/mytheme` I also created a page in the database with name `contactWohnsinn` The page is visible on the link, but not the hello w. Is it clear? Of course I did the mapping php-file-name and page-name. Why is "hello world" not spread to the world?


Add insert/edit link functionality to front end tinymce

I would like to know how to insert/edit link functionality at front end tinymce added by plugin. Before that I thought I can use WordPress's tinymce by wp_editor() but, wp_editor is not working on ajax call at all (tried everything but failed). Then I used external tinymce script. I have added custom button on new tinymce,               ed.addButton('new_link', {             icon : 'new_link',             title : 'New Link',             onclick : function() {                 wpActiveEditor = true;                 console.log(wpLink);                 wpLink.open(); //open the link popup                 return false;             }     });      I also enqueue the script,               wp_enqueue_script( 'wplink' );      Ref. - http://stackoverflow.com/questions/11812929/use-wordpress-link-insert- dialog-in-metabox Please help me to achieve this.


Is it possible to get a theme customizer setting from wp.customize using jquery?

I am wondering if it is possible to directly interop with the wp.customize api to get a value of a theme customizer setting. The way I am doing it now is using ajax to get a response from a php function. I seem to be having alot of issues with it. I know that you can bind to theme customizer controls using jquery with the wp.customize api, although I am wondering if I can directly access a setting from jquery? **EDIT: More information** I know that you can interact with controls directly through the API like this:               /** Site title and description. */     wp.customize( 'blogname', function( value ) {         value.bind( function( to ) {             $( '.site-title a' ).html( to );         } );     } );      I am wondering if it is possible using the same API to directly access theme setting values, using jquery alone? If not I think it wouldn't be hard and would be beneficial to extend the wp.customize api(and maybe all other wp functions for that matter) to do exactly what I am manually doing with ajax and php, so this way it would be possible for users to only use jquery themselves to interact with wp functions and have wordpress do the dirty work behind the scenes. This may be a good feature for a later version of WP.


How to handle responsive and non responsive websites in one WordPress Theme?

I am using iPage hosting service to display my webpage. I am using a WordPress theme called Mantra. I want to display my website without been responsive (responsive to screen size in mobile phone). `Mantra` allowed me to disable this responsiveness at their setting. But I would like to create two separate web-pages where, if a user coming from a desktop/laptop computer display the default website, else direct them to another webpages which is responsive.               <script type="text/javascript">     <!--        if (screen.width <= 699) {        document.location = "http://example2.responsivesite.com";     }     //-->     </script>      Can you please tell me if this is possible. In another word, is it possible for me to install two WordPress theme in Ipage hosting service which can be used to maintain the same Domain name ? so that I can make one theme handle responsive websites and other one handle non responsive website. (or can this done by using one single wordpress theme)


Limiting the amount of posts this displays

I currently have this query_posts that i have done, (I am new to PHP!) And would like to know how I would go about limiting it to latest 4 posts and 4 posts only..               <?php query_posts('post_type=page&post_parent=2&posts_per_page=-1&orderby=title&order=ASC'); ?>     <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>                    <?php $key = 'next_open_day'; $themeta = get_post_meta($post->ID, $key, TRUE); if($themeta != '') {           echo '
';     echo '';     echo '
';     echo '
';     echo '';     the_title();     echo '';     echo '
';     echo '
';     the_field('next_open_day');     echo '
';     echo '
';     the_field('open_day_description');     echo '
';     echo '';     echo 'Visit Website';     echo '';     echo '
';          } ?>                           <?php endwhile; ?>     <?php wp_reset_query(); ?>


Saving/Writing/Adding file to upload folder

Within a plugin I am generating an image, I would like to save this image to the upload folder and update the WPDB with the location of said file. I cant find any build in wordpress functions to handle saving/writing/adding a file to the upload folder, should I just do this the old fashioned way with php, or is there something built into WordPress that I'm missing?


Add_image_size not generating correct size

I have 2 additional image sizes i've added to my theme and the for some reason when I use the Force Regenerate Thumbnails plugin, my images are created but the files sizes are not exact. Here is the setting I have in my function.php file.                add_theme_support( 'post-thumbnails' );           add_image_size( 'cmntouch_featured', 450, 300, true );      add_image_size( 'cmntouch_tile', 150, 150, true );      So the images that are regenerated should look like this: img1_150x150.jpg img1_450x300.jpg Some of them are generated correctly but about 25% come back with images that are totally off like this: Future-of-webdesign-New-york-450x144.png Future-of-webdesign-New- york-150x144.png Aladdin-450x127.jpg Calvant-450x160.jpg Has anyone see this issue when creating additional image sizes?


What is the best way to store thumbnails for a non-image attachment?

I'm in the process of extending Document Gallery to support generating and displaying thumbnails for each document. I've got thumbnail generation under control, but I'm curious as to what best practices for storing both the physical image files for each thumb and the references to these file paths. The research I've done thus far turned up attachment thumbnails (which appear to be different than Post Thumbnails) and these seem like an ideal foundation for creating this new functionality without reinventing the wheel. Documentation on how to hook into this existing framework, specifically, creating new attachment thumbnails, seems to be quite sparse. As much as possible, I'd like to use existing functionality rather than duplicating functionality. With this in mind, looking at `wp_get_attachment_thumb_file` (below), it seems like I could simply set the thumb filed in attachment metadata to the name of the thumbnail which would live in the same directory as the attachment file. In doing this, I would also indirectly handle removing the thumbnail file when the attachment is deleted since `wp_delete_attachment` checks for a thumbnail on deletion and removes it if present. I believe this solution will work, but I was hoping someone with a working knowledge of all of this could verify not only that it will work but, more importantly, whether it is the "best" way to handle my needs.               function wp_get_attachment_thumb_file( $post_id = 0 ) {         $post_id = (int) $post_id;         if ( !$post = get_post( $post_id ) )             return false;         if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )             return false;              $file = get_attached_file( $post->ID );              if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) )             return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );         return false;     }


update_post_meta() whenever custom post type is updated

I need the following functionality. Whenever my custom post type is updated or saved I need to overwrite certain custom post metas. I need to make sure this only affects posts of the post type 'VA_LISTING_PTYPE' and posts that have the have for the 'meta_key' => 'featured-cat' the 'meta_value' => 1 The code I'm using at the moment is the following (not working)               //Remove urls from free listings     function remove_url_free_post( $post_id ) {          $slug = 'VA_LISTING_PTYPE',         if ( $slug != $_POST['post_type'] ) {         return;         }              $meta_values = get_post_meta( $post_id, 'featured-cat', true );     if ( $meta_values != 1 ) {         return;         }              update_post_meta($post_id, 'website', '');         update_post_meta($post_id, 'twitter', '');         update_post_meta($post_id, 'facebook', '');          }     add_action('save_post', 'remove_url_free_post');      I also tried different action hooks like pre_post_update coming from this answer I just can't seem to get it working. The only really ugly fix that is working for me right now is this one:               //Remove urls from free listings     function remove_url_free_post() {         //Fetches all the listings that have featured cat which equals free listing for us         $r = new WP_Query(          array(              'post_type' => VA_LISTING_PTYPE,             'no_found_rows' => true,             'meta_key' => 'featured-cat',             'meta_value' => 1         ) );         if ( $r->have_posts() ) :         while ( $r->have_posts() ) : $r->the_post();              //removes the website, twitter and facebook         $post_id3 = get_the_ID();         update_post_meta($post_id3, 'website', '');         update_post_meta($post_id3, 'twitter', '');         update_post_meta($post_id3, 'facebook', '');              endwhile;         endif;     }     //Not ideal at all as called everytime, save_post not working as intended     add_action('wp_footer', 'remove_url_free_post');


How to increase load time of an archive/search page (WP_Query)

I'm currently looking at why the archive and search pages take so long to use, and have found that the bulk of processing time is spent on the `query_posts` that is called before the template has even been called. Does anyone have any ideas how you can either stop `WP_Query` from being called on such a page, and then manually do it later, or how to improve the time it takes for these processes to occur? It's also worth noting that it seems that it's to do with caching of postmeta that is taking the most time to load. ![Load time of an archive page](http://i.stack.imgur.com/1yGfq.png)


Adding code using functions.php in child theme

I am using a child theme and try to get some code show up after the content on single post/pages               function app_bits() {     global $post;     $app_logo = get_post_meta($post->ID, 'AppLogo', TRUE);     $zund_id = get_post_meta($post->ID, 'AppURL', TRUE);     if ( is_single() || is_page() ) {     ?>

          sample

     <?php     if ($zund_id !='') {     ?>
custom code goes here
     <?php } else { ?>
custom code goes here
     <?php } ?>

     <?php         }     }     add_filter( 'the_content', 'app_bits');      The issue is it replaces the content. Is there a `after_the_content` hook I can use so that the content I want goes after the content? After reading what @toscho said that I came up with this ( I am not some one who uses PHP , which should become obvious after looking at the code below -_- ) if anyone esle is looking for the same , here is what I used               function app_bits($content) {     global $post;     $app_logo = get_post_meta($post->ID, 'AppLogo', TRUE);     $zund_id = get_post_meta($post->ID, 'AppURL', TRUE);     if ( !is_singular() )      {     return $content;     }     $custom_bits1='

          sample here

';     $custom_bits2='
custom code goes here

';     $custom_bits3='
custom code goes here

';     if ($zund_id !='') {     return $content . $custom_bits1. $custom_bits2;     } else {     return $content . $custom_bits1. $custom_bits3;     }     }     add_filter( 'the_content', 'app_bits');


What is the difference between feeds served by my WordPress install vs feeds served by FeedBurner? How to disable hosted Wiordpress feed completely and use feedburner?


get_file_data to read data for Custom Template File?

I have a plugin in which I'm trying to allow users to create their own variants of the styles, and upload them as custom "templates". Essentially these templates are php files with some HTML in them. I'm trying to add a template tag to the top of each files, so I can extract certain data such as the template name and maybe an author. I've been doing a bit of research and came across a function I haven't used before `get_file_data();`. There doesn't seem to be too much information regarding how to use the function to extract data from a template file. Each time I try and run this function to return some data it either returns empty or with an array with one key and no value assigned. I must be doing something wrong. Unfortunately their is not much in the codex http://codex.wordpress.org/Function_Reference/get_file_data https://developer.wordpress.org/reference/functions/get_file_data/               $template_data = get_file_data( $content_path . 'template_1.php' , array( 'Template Name' => 'Template Name' ) );     print_r($template_data );      I can't seem to figure out what the default headers argument (2nd argument) is doing. The contents of the `template_1.php` file is :               <?php       /*       Template Name: Cool Template File       Template Author: Evan       */     ?>      I'm not sure what it is I'm doing wrong, or what I should be doing to extract the data at the top of this file properly. Thanks


Replace Main Query With Custom Query

I want to replace the main query with my own custom query. The thing is I don't want to go through the hassle of manual paging. I know there's a filter `posts_results` but I'm not sure how to use it exactly, I couldn't find a bunch of info on it. It looks like `pre_get_posts` is only altering the query instead of replacing it entirely. I tried to just dump my query into `$posts` but then I lost paging. Is there a way around this? I'm using `$posts = wpdb->get_results($query);` to replace the main query with my own. `$query` is my custom SQL. I'm adding the snippet above right under `get_header()`. I'm trying to edit the main query on my custom taxonomy page: `taxonomy-mytax.php`. **The Situation** Currently my client has Manufacturers (Taxonomy) and Products (Taxonomy) then an actual Product (Custom Post Type). They requested to show Product posts (on the product category page - `taxonomy-producttax.php`) in an order by their most favorable Manufacturer (taxonomy). So I added an extra field into the manufacturer taxonomy where they can set a number that declares an order. This number is saved into `$wpdb->terms.term_group`. Now on the Product Category page I'm trying to replace the main query entirely with a brand new query that will get all the products and put them in order by a manufacturers `term_group`. Both Product and Manufactuers (both taxonomies) have an order, and both are put into `$wpdb->terms.term_gruop` which was troublesome. I created a custom query that works, and will show posts in manufacturers `term_group` order . I just need to replace the main query on `taxonomy- producttax.php` with my custom SQL query, but I didn't want to get into manual paging I wanted to use anything Wordpress has built in to help me.


How to import a TypePad blog including all media?

Is it possible to import a hosted TypePad blog into WordPress self-hosted, _including_ all of the image files and other media? I generated an export file from within TypePad but it is just a text file with the image URLs contained within the post content.


Next/Prev posts on same page

Hello WordPress Users, I'm stuck with a problem building my wordpress website and I can't figure out what to do about it. Currently I'm showing 2 posts form the category 'News' at the page 'News'. At the bottom of this page I want a Prev/Next button that shows the next or previous 2 posts from the same category. So I was searching how I coud do that. So I found this code:               previous_posts_link('Newer Entries »')     next_posts_link('« Older Entries');      This displays a link like I was expecting. But both links are not working (page reload, but same entry's shown). I also found this in this codex:               posts_nav_link('∞','Go Forward In Time','Go Back in Time');      Also at 'Setting' > 'Reading' I had set max posts to 2. I don't know how I can handle this. Is there a way to show the next 2 (or 'X') posts from the same categorie when a button 'Next' or 'Prev' is pressed? Thanks! Edit: This is how I get the posts:               $args_news= array(             'cat' => 1,             'posts_per_page' => 2,             'orderby' => 'post_date',             'order' => 'DESC'         );              query_posts( $args_news );              if ( have_posts() ) :             while ( have_posts() ) :                 the_post();                    the_title();               the_content();                    endwhile;         endif;      But still no idea how I can make pages of this posts. Currenty it's displaying the last 2 posts..


Smooth Scroll and Slider Conflict

my website is http://eclat.sg/gourmet running on Wordpress(obviously.). I have a slider on the front page and I've installed jQuery Smooth Scroll plugin. The plugin works awesome but unfortunately, it conflicts with my slider at the front page. Now, when I click the left/right arrows of the slider, it just scrolls down and doesn't go to the next picture. Any way I can enable the plugin for specific pages or to solve this conflict issue?


bulk edit attribute order in woocommerce

How can i edit the global/ default attribute order (not attribute term order) for all items? http://i.imgur.com/eQfXlhw.png I can do this for individual products, and attribute terms, but not default/ global. Thanks.


get page id's - not get pages?

I'm trying to do something like this: Hide a page in the admin end without a plugin? However, I don't want to hardcode the page-ids. I want to get the page id's based on template-name.               $pages = get_posts(array(             'post_type' => 'page',         'meta_key' => '_wp_page_template',         'meta_value' => 'product.php'     ));       ^^This probably does the job, but it gets entire pages, and I start worrying about efficiency, especially when I only need id's and there could be thousands of pages being returned by this command. I know SQL pretty well, so if I should just write my own query, then let me know. Or maybe I don't need to worry about this at all?


Contributors can still publish content after user downgrade

I'm trying to slowly hand over WordPress access to other site users but when I downgrade their user type from "Author" to "Contributor," I'm finding that WordPress isn't restricting their respective privileges correctly. In other words, even though WordPress is telling me User X is now a Contributor, she still has the publishing privileges of an Author. As a test, I created a new user as a "Contributor" from the get-go and the proper privileges seemed to be all there (i.e. I could start new posts, but only submit them for review not publish them myself). The issue did not repeat itself with the new user account. Has anyone experienced a similar issue?


How to link to page AND anchor with Menus and/or wp_nav_menu()

Basically I am trying to create a menu that can link to a page and an anchor on that page in one go. I currently have a menu using `wp_nav_menu()` but I can't see any argument that could directly modify the URL. Would that involve creating a custom walker function? Ideally I'd like to combine the Page and custom link panels so that it could be modified from admin. Perhaps a box to check under screen options.


Make a select where the options are the different multisites

I've been wondering this for a while; If you run a multisite setup on your WordPress installation, are you able to create a `select` on the main page (e.g. _www.example.com_ ), where the options in the select are the different multisites? Once you select one of the options the browser automatically redirects you to the directory of the multisite (e.g. _www.example.com/23_ ). If yes—how?


how can i show a google map in custom post type

i m making a plugin in which, custom type posts are used, for the Location Custom type, how can i show a Google map for any location. The Output will be shown as ![enter image description here](http://i.stack.imgur.com/a4FNz.jpg)


WP_Query in functions.php

I've got some code that I want to turn into a function. It works great until I wrap it in said function:                   $args = array(             'posts_per_page'    =>  -1,             'post_type'         =>  'asset',             'category_name'     =>  $cat         );         $cat_query = new WP_Query( $args );         $matching_category_ids = array();                while ( $cat_query->have_posts() ) : $cat_query->the_post();             array_push($matching_category_ids, $post->ID);         endwhile;      The function looks something like this:               function grab_ids_in_category($cat) {         //stuff from above here         return $matching_category_ids;     }      What am I doing wrong?


Hook onto Add New Category

When a user clicks the Add New Category for my custom post type of Packages I wish to create a new page with the same name as the new category at the same time. I can create a new page through code but I cannot find the right hook for my function.php to run it. What I need is a hook that will run for only the Packages post type. Thanks


Is having multiple theme customizers for different pages possible?

If you have a theme that for instance has a blog, front page and misc pages is it possible to have more than one theme customizer, so that you can provide a live preview when editing styles? My theme has a front page, and a blog. Other than the header and footer, the blog doesn't take much from the front page because of the type of theme it is. If I wanted to allow the users to edit both the front page and blog pages using the theme customizer, would I be able to run more than one customizer, so I have one for front page, and one for blog? This would allow users to have the ease of use of the theme customizer, along with the ajax live preview. I haven't seen this done as of yet. I am guessing the norm in this situation would be to either offer an additional options page in the backend, or add sections to the theme customizer for the other pages(even though you wont be able to see changes in real time) Can anyone give me advice on this particular situation?


How to install Wordpress Popular Posts plugin twice?

I've installed Wordpress Popular Posts plugin but found that it displays popular posts only from category. I want to display popular post for custom taxonomy. I found some hack in that plugin. Plugin might be work with custom taxonomy replacing category to custom taxonomy name. So I'm thinking to install same plugin twice with minor changes. for that, How to install that plugin second time? Or Is there another way to achieve it?


100+ terms in any taxonomy slows down post updates?

I'm making a fairly large (for me) e-commerce shop with Woocommerce. The shop has ±1300 products and will be going to ±2000 products. There are also ±2500 Product Tags. I've had speed problems on a shared hosting server; updating posts took over 1 or 2 minutes from time to time. The front-end of the website has always been really speedy. So I've moved the server to a VPS server with 4 processor cores of 4.9Ghza and 2048 Mb Ram. There's no visitors on the website; no traffic problems. As said before, the front-end is really snappy. Every pages loads in under two seconds. However, certain things are really slow in the dashboard/admin of Wordpress. Everything in the dashboard is really quick and responsive. Changing from posts to pages, to settings, to listing products in Woocommerce: all very snappy. Updating products (a Woocommerce custom post type) is quick when changing the_content and adding text in custom fields. Every product has a lot of custom fields (≠50) that are served via the plugin Advanced Custom Fields. No problems there. The BIG problem comes when I try to add 'Product Tags'. When I add one or more Product Tags, they appear quickly in the dashboard sidebar box. However, when I then try to Update the product, the spinning Wordpress wheel keeps spinning forever. The website hangs for one to two minutes and than finally update the post. I can try to access another part of the Wordpress dashboard, before the update is complete, but it doesn't react anymore. Only restarting the browser helps when I did that. There's also an important issue with the 'Product Tags' menu item under 'Products' in the sidebar. I tried to add tags from there, but it blocks the site as well in a different manner. I can fill out the field to add a Tag and than hit 'Add new product tag'. Then I get NO message whatsoever that the tag has been added... the text of the new tag stays in the text field too. The button can be clicked multiple times, but it looks like nothing ever happens. When I restart the browser, the new tag has been added though. Plugins: 14 active. It doesn't change when I turn off all other plugins besides Woocommerce. Could you please help me out?


increase maximum upload file

I want to increase the maximum upload file (media default:32mb). Before posting i search, but i didn't have the result that i want. My host didn't support .htaccess. I create my own `php.ini` with these:               memory_limit = 32M     upload_max_filesize = 120M     upload_max_filesize = 120M     post_max_size = 100M     file_uploads = On      After that i upload in the /wp-admin but i didn't see anything for increase. Also, i edit the `wp-config.php` with this:               define('WP_MEMORY_LIMIT', '120M');,       even after this i didn't see any change to increase. How can do that? Thanks in advance


Admin only menu/page

Is it possible to show a menu item If only admin is logged in) For any other user the menu item does not appear. For example: if there are a few pages that have shortcodes or other functionality exampled to show how to build toggles etc, but only want the admin to be able to see them. These pages generally come with pre-built themes and show the admin how to build pages within the site. By hiding the menu items, a series of pages can be "hidden" from a user but allow the admin to see them to be able to build pages, without having to remove them entirely from the site :P make sense?


Custom Post Type post not appearing

I am new to WordPress. My problem is that I created a custom post type named `Atividades` and when I create a post, it does not appear on the website.               // fuctions.php     add_action( 'init', 'create_post_type' ); function create_post_type()     { register_post_type( 'acme_atividade',         array(          'labels' => array(                     'name' => __( 'Atividades' ),                     'singular_name' => __( 'Atividade' )            ),      'public' => true,       'has_archive' => true,      )   ); }          // index.php

                             <div style="background: url('<?php echo $thumbnail; ?>') no-repeat;" id="q-1">                          <?php                     $thumbnail = '';                     if (function_exists('has_post_thumbnail')) {                     if ( has_post_thumbnail() ) {                     $thumbnail = get_the_post_thumbnail($post->ID,'thumbnail');                     }                     }                     ?>                          <?php                      query_posts(array(                      'post_type' => 'Atividades',                     'posts_per_page' => 1                      ) );                       ?>                          <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                          <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?>
                          <?php the_content(); ?>                          <?php endwhile; else: ?>
Ups...

... pedimos desculpa mas nenhum post foi encontrado!
                          <?php endif; ?>
<?php posts_nav_link(); ?>

      Is there anything wrong?


Bulk category update is not updating

I am using wordpress 3.1. and I have to reorganize categorize my posts. For this purpose, I am willing to remove some categories. Therefore, after login to admin section of my blog, I go to post > posts > I select the articles I want to edit > I select edit option from "Bulk Action" select box > I select new categories and put some tags as well. But it adds tags only. It doesn't remove previously assigned categories. Please let me know if there is any plugin to do the same work. Or some other alternative.


Crossposting from WP to Blogger with comments

I know that there is a way to crosspost from WP to Blogger but I am curious if there is a way to essentially mirror WP blog on Blogger completely, in other words crosspost both posts and comments?


Vote It Up Plugin - Add ascending numbers to MostVotedAllTime Chart Function

The following function shows a top 10 chart of most voted posts. How would I add acceding numbers to this chart eg **1** - example Post1 **2** - example Post2 etc               function MostVotedAllTime_Widget() {     $a = SortVotes();     //Before           ?>

Most Recommended Albums
     <?php     $rows = 0;          //Now does not include deleted posts     $i = 0;     while ($rows < get_option('voteiu_widgetcount')) {     if ($a[0][$i][0] != '') {             $postdat = get_post($a[0][$i][0]);         if (!empty($postdat)) {             $rows++;                  if (round($rows / 2) == ($rows / 2)) {                 echo '
';             } else {                 echo '
';             }             echo get_the_term_list( $postdat->ID, 'artist', ' ', ', ', '' );              echo ' - guid.'" title="'.$postdat->post_title.'">'.$postdat->post_title.'';             echo '
';         }     }     if ($i < count($a[0])) {     $i++;     } else {     break; //exit the loop     }     }          //End     ?>
      <?php          }


get_intermediate_image_sizes Get the Size Names but How Do I Get the Sizes?

I'm setting up a widget that allows to add an image to a sidebar / widget area. Basically I have a dropdown that allows the user to select one of the available sizes inside the theme's `functions.php` file using `add_image_size()`. Apart from the obvious ( renaming all the `add_image_size()` ) is there a way to get the size so that I can display that as well as the name? This is my current drop down code:               <?php                $sizes = get_intermediate_image_sizes();         $available_size  = '<select name="' . $this->get_field_name('image') . '" >' . "\r\n";         $available_size .= '<option value="0" selected="selected">Choose</option>' . "\r\n";         foreach ( $sizes as $size ) {             if ( $instance['size'] == $size ) :                 $available_size .= '<option value="' . $size . '" selected="selected">' . $size . '</option>' . "\r\n";             else :                 $available_size .= '<option value="' . $size . '">' . $size . '</option>' . "\r\n";                      endif;         }              $available_size .= '</select>' . "\r\n";              echo $available_size;         ?>


Automatic adding thumbnail to post

I have got following code.                $postData = array(        'post_category' => array(get_category_id("website")),        'post_content' => 'My website about cars.',        'post_title' => 'my little cars',        'post_type' => 'post',        'post_status' => 'publish',        'tags_input' => 'cars, hobbies'       );       $pID = wp_insert_post($postData);       update_post_meta($pID, "language", "English");       update_post_meta($pID, "author", "John");      And how I can add a post thumbnail? Code written below is incorrect.                $filename = "http://damianc.pl/th.jpg";      $wp_filetype = wp_check_filetype(basename($filename), null);      $wp_upload_dir = wp_upload_dir();      $attachment = array(       'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $filename ),        'post_mime_type' => $wp_filetype['type'],       'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),       'post_content' => '',       'post_status' => 'inherit'      );      $attach_id = wp_insert_attachment( $attachment, $filename, $pID );      require_once(ABSPATH . 'wp-admin/includes/image.php');      $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );      wp_update_attachment_metadata( $attach_id, $attach_data );      Path to image is well. I have no idea.


Disable the post save process completely

I need a way to disable the save process completely using an `action/filter`. Something that works (for e.g.:) in the `query`, `posts_clauses` or `wp_insert_post/save_post/update_post` hooks. So far I only tried to `return '';`, which gives me tons of errors for missing values for post object parts in the admin UI. This should happen "silently", so no errors get thrown when `php_error/WP_DEBUG` and such are set to `TRUE/On`. Btw: I'm _not_ asking for how to disable the autosave feature.


Two-tone menu items

wp_list_pages seems to print out menus ok, but is there a way to alter the functionality so that i can display the menu in two colors..? So, if the titles of 3 actual pages are:               Big Cinema * Monaco     Theatre * San Franciso     Sport * Berlin      (each page really has two titles, the asterisk used to separate them. another character could be used..... or is there a way of entering two titles?) When these are displayed you would get the two titles for each page displayed a little differently: _Big Cinema_ Monaco _Theatre_ San Franciso _Sport_ Berlin (the italics above representing blue, the rest green) Is there a way to alter the wp_list_pages behaviour, or is there a better technique to do this?


How to get pagination working with "Pending" Posts

I'm working on a site that allows users to browse through pending posts/content on the front-end. However, I can't seem to get pagination working with those posts. I've got a custom query that brings up the first page of pending posts on a category page, archive, etc. But the Page 2, 3, etc. doesn't work. Any thoughts? Thanks! Here's the example code I'm working with:               $args = array(         'cat'      => $cat_ID,         'paged' => get_query_var('paged'),         'showposts' => 50,         'posts_per_page' => 50,         'post_status' => 'pending',          );          query_posts($args);          if( have_posts() ) : while (have_posts()) : the_post();          //Post code inserted here          <?php endwhile; ?>     <?php endif; ?>


Clicking Add New button for custom taxonomy only moves element

When trying to click the "Add New Equipment Type" button for my custom taxonomy, it simply moves the DOM element up into the list of entries and fails to add the actual term. Here is my taxonomy code:                 $labels = array(         'name' => _x( 'Equipment Types', 'taxonomy general name' ),         'singular_name' => _x( 'Equipment Type', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Equipment Types' ),         'all_items' => __( 'All Equipment Types' ),         'parent_item' => __( 'Parent Equipment Type' ),         'parent_item_colon' => __( 'Parent Equipment Type:' ),         'edit_item' => __( 'Edit Equipment Type' ),          'update_item' => __( 'Update Equipment Type' ),         'add_new_item' => __( 'Add New Equipment Type' ),         'new_item_name' => __( 'New Equipment Type Name' ),         'menu_name' => __( 'Equipment Type' ),       );            register_taxonomy('equipmenttype',array('powerequipment'), array(         'hierarchical' => true,         'labels' => $labels,         'show_ui' => true,         'query_var' => true,         'rewrite' => array( 'slug' => 'power-equipment' ),       ));      And this is what happens in the editor: ![enter image description here](http://i.stack.imgur.com/UVa2V.png) I'm not using any custom admin JavaScript and the only plugins I have enabled are Akismet and Wordpress Importer. Also, this error does not occur with the standard Categories taxonomy.


Using my WordPress menu on another platform

I have a WordPress site and am adding a Shopify-hosted e-commerce section which will be hosted on their servers and accessible via a subdomain. Is there any way to mirror the WordPress Navigation for my site on another platform and (maybe the harder of the two) subdomain? I don't intend to use Shopify's product menu at all. So I'm not looking to merge the two or anything... just an easy way to get the WP menu to display elsewhere.


paginate_links() adds empty href to first page and previous link

This is really weird. In attempting to solve this problem i ended up with an almost perfect use of paginate_links() instead of a custom pagination function:               $myquery = new WP_Query($args);          $paged = get_query_var('page');     ($paged == 0 ? $paged = 1 : $paged = $paged);              $pagination = paginate_links(array(              'total'     => $myquery->max_num_pages,         'current'   => $paged,         'show_all'  => true,         'type'      => 'list',     ));      This seemed to work fine. Until i found out that no matter what i do, whenever i'm after page 1, the function prints an empty `href=""` on my first links. So i get these markups:

1

2

3

4

Next

Previous

1

2

3

4

Next

Previous

1

2

3

4

      Digging into paginate_links() on wp-includes/general-template.php (circa line 1954) i found that for some reason it explicitly passes empty link arguments to the Previous link when on page 2:               if ( $prev_next && $current && 1 < $current ) :             $link = str_replace('%_%', 2 == $current ? '' : $format, $base);      and to the first link (line 1968)               if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :                     $link = str_replace('%_%', 1 == $n ? '' : $format, $base);      any thoughts on why that would be, and if it's possible to avoid it w/o creating yet another pagination function?


Wordpress Menu Disappears when $query->query_vars['meta_key'] is set

I've set some meta variables on my WP posts. I want to be able to sort by these variables, and everything is working great except when I sort by either "views" or "likes". When I sort by either of those two fields, WP doesn't generate my nav (wp_nav_menu). I've tried "resetting" the $wp_query variable surrounding my wp_nav_menu call:               $old_query = $wp_query;      $wp_query = new WP_Query( array('post_type' => 'any') );      wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) );      $wp_query = $old_query;      But that does not solve it. The only thing that does work is commenting out the line starting $query->query_vars['meta_key'], but obviously that negates the sort as well. Any help would be appreciated.               // Before a query is run, modify the sort order     function jh_popularity_sort_query($query) {       $sort = $_GET['sort'];        if ($sort == "title") {         $query->query_vars['orderby'] = 'title';         $query->query_vars['order'] = 'ASC';       } else if ($sort == "date") {         $query->query_vars['orderby'] = 'date';       } else if ($sort == "views") {         $query->query_vars['meta_key'] = 'jh_page_views';         $query->query_vars['orderby'] = 'meta_value';         $query->query_vars['order'] = 'DESC';       } else if ($sort == "likes") {         $query->query_vars['meta_key'] = 'jh_page_likes';         $query->query_vars['orderby'] = 'meta_value';         $query->query_vars['order'] = 'DESC';       }            return $query;     } add_action('pre_get_posts', 'jh_popularity_sort_query');


wp_set_object_terms creates relationship to REVISION?

I have a custom post type, 'albums'. In it is a taxonomy, 'album_artist'. I am trying to programatically add artists to that taxonomy using wp_set_object_terms in a function that's hooked into save_post.               function get_album_data($post_id) {         // CODE REMOVED FOR BREVITY: IMPORT DATA FROM EXTERNAL SOURCE, PARSE VARS         wp_set_object_terms( $post_id, $album_artist_name, 'album_artist', true );         update_post_meta ($post_id, 'Release Date', $release);     }     add_action( 'save_post', 'get_album_data', 1001 );      I'm using "true" for those cases where, on a compilation album, there is more than one artist (think "21 Original Hits 21 Original Stars"). Going through the wp_terms, wp_term_relationships and wp_term_taxonomy tables in the DB, here's what I'm seeing:   * In wp_terms, the terms are being created properly, with correct slugs (ie "The Police" get a slug of the-police, and term_id 482)   * In wp_term_taxonomy, the term is showing up under the right taxonomy (ie term_taxonomy_id 506 has term_id 482 with a taxonomy of album_artist)   * In wp_term_relationships, term_taxonomy_id 506 shows with object_id 2448 Looks good, right? Sadly, no. Because object_id 2448 refers to POST 2448, which is actually a REVISION of 2447. And when I check the wp_postmeta table, the 'release_date' meta has been updated on 2447, not 2448. So WP seems to be creating a relationship to the wrong post. That's why, I assume, the artist isn't showing up on my album page the way it would if I went into the "Artist" metabox and clicked the checkbox that says "The Police". And yet, **it seems to treat the $post_id variable differently in a update_post_meta versus a wp_set_object_terms**. Because the two statements literally are adjacent to each other in the function, yet the $post_id variable means different things to different functions. How do I force WP to make the relationship between the terms and the PARENT, instead of the revision?


Plugin translations files outside plugin directory?

I'm using the excellent Codestyling Localization plugin to translate themes and plugins. But there's a problem when translating plugins, namely that the translated strings are saved to `wp-content/plugins/gravityforms/languages/gravityforms- LANG-CODE.*` for example. This resulting in overwritten translations for subsequent plugin upgrades. Is it possible to move the language files to another location? For example wp- content/languages or something else?


switch_to_blog() for parent theme

all. Just trying out switch_to_blog() as a way to have a child site get some news items from the parent site. Problem is, the parent site--first tables in database--doesn't have a number, i.e., tables are like www_posts--there's no number to put in the parentheses, 0 doesn't work, empty doesn't work. How can I reference this original install? Also, is it no longer cool to use switch_to_blog()? Thanks!


Widget where it can make changes to the container

Is it possible to create a widget where it can make changes to the container? An example is like this:

               be like this:

               or something else like that. If I use this:                   register_sidebar(            array(               'before_widget' => "
"                                 ."

",               'after_widget' => "
"            )         );      will replace all widget, not just a widget that I want. My main goal is that I can give `<div style="clear:both;"></div>` element among a widget that I can treat as a widget, so it is easily to move.


Change the counter in terms of date

If I have a post or submit a date-field, I would like the counter to say 'this is in 3 days time'. i.e - on my site at the moment, (see here: http://www.universitycompare.com) I have dates for the latest open days. Instead of displaying the date, It would be better to say, 'in 3 days time'. Is there a way to do this and if so how?


Enqueue styles after a plugin

Is there a way to enqueue my `style.css` (and other stylesheets) AFTER a certain plugin enqueues its styles? Specifically, I want my `style.css` to overwrite cforms's styles, but when I change the priority of the add_action, it doesn't do anything. Here's what I have:                   function rm_theme_styles()           {                 wp_register_style( 'rm_styles', get_template_directory_uri() . '/style.css', array(), null, 'all' );                 wp_register_style( 'jquery.fancybox', get_template_directory_uri() . '/js/libs/fancybox/jquery.fancybox-1.3.4.css', false, null, 'screen' );                      // enqueing:                 wp_enqueue_style( 'rm_styles' );                 wp_enqueue_style( 'jquery.fancybox' );         }              add_action('wp_enqueue_scripts', 'rm_theme_styles',10);      cforms:                   ### some css for positioning the form elements         function cforms_style() {             global $wp_query, $cforms_root, $localversion, $cformsSettings;                  ### add content actions and filters             $page_obj = $wp_query->get_queried_object();                  $exclude  = ($cformsSettings['global']['cforms_inexclude']['ex']=='1');             $onPages  = str_replace(' ','',stripslashes(htmlspecialchars( $cformsSettings['global']['cforms_inexclude']['ids'] )));             $onPagesA = explode(',', $onPages);                  if( $onPages=='' || (in_array($page_obj->ID,$onPagesA) && !$exclude) || (!in_array($page_obj->ID,$onPagesA) && $exclude)){                      if( $cformsSettings['global']['cforms_no_css']<>'1' )                         echo '<link rel="stylesheet" type="text/css" href="' . $cforms_root . '/styling/' . $cformsSettings['global']['cforms_css'] . '" />'."\n";                              ### add jQuery script & calendar                         if( $cformsSettings['global']['cforms_datepicker']=='1' ){                             wp_enqueue_script('jquery',false,false,false,false);                             wp_enqueue_script('jquery-ui-core',false,false,false,false);                             wp_enqueue_script('jquery-ui-datepicker',false,false,false,false);                         }                         echo '<script type="text/javascript" src="' . $cforms_root. '/js/cforms.js"></script>'."\n";                      }             }         }              add_filter('wp_head', 'cforms_style');


get_the_category_list open in parent window

I'm opening my posts in an iframe, and I'm using get_the_category_list to list post's categories. The problem is that when a user clicks on the category link, it opens in the iframe. How can I set the target for these generated links to be "_parent"?


Do wp-cron scheduled tasks run asynchronously?

I have a task scheduled to run daily using wp-cron. The task takes over a minute to run (between downloading and parsing a very large file with cURL). According to the WP documentation, > "The action will trigger when someone visits your WordPress site, if the > scheduled time has passed." Could this "someone" have to wait the full minute for my script to run while trying to access my site, or are wp-cron tasks asynchronous?


Can anyone help me with galleries and post types?

Hi i'm opening a blog and i am using custom post types. I don't know if i'm doing this wrong or right. Check out wetpaint.com For example they have a page for every show that they cover, i don't know if it's custom post types they are using or taxonomies. They have wetpaint.com/pretty-little-liars and for a photo gallery they have wetpaint.com/pretty-little-liars/photos and wetpaint.com/pretty-little- liars/photos/title-of-the-gallery-post I created a custom post type but how do i get it to link like mysite.com/custom-post-type/photos or mysite.com/custom-post-type/videos or am i doing it wrong? Should it be a custom post type or are they using pages. I have googled this for hours and still haven't found a solution


qtranslate is not working properly

I have installed qtranslate in my local, it does not show the translated content, so there are two question if anybody have used this plugin.   1. do i need to put the translated text by my self or it[plugin] does automatically?   2. do i need to make changes in php file of the plugin to get the all automatic transnational. the plugin site claims that,when the plugin is activated the dashboard will look like this ![enter image description here](http://i.stack.imgur.com/0Xtiy.png) and this is what i am getting on my local system ![enter image description here](http://i.stack.imgur.com/vP5jH.jpg) and when i see the front page it was supposed to translate all the english text to chines but it's not doing the same. ![enter image description here](http://i.stack.imgur.com/zrLH3.gif) so if any one have used this plugin please clear my doubts and help me activating this plugin properly please advise may be i am wrong some where.


prevent post to have multiple categories in my plugin

I'm writing a plugin, I want to prevent posts have multiple categories _(i.e same product having category "Samsung" & "Apple")_. Any idea on how to use some actions/filters to achieve this using my plug-in?


posts not showing on index.php

Live site. I've got a custom theme, wherein the homepage(front-page.php) is static and the "posts" page is Press(index.php). Everything with the theme works great, with the exception of the posts not showing when viewing the Press page- it shows the homepage content instead. In the Reading settings, I have A Static Page: Front Page is Home(front- page.php) / Posts Page is Press(index.php). Here's what I'm using for index.php:               <?php get_header(); ?>
         <a href="<?php bloginfo('url'); ?>"><img src="<?php echo get_template_directory_uri(); ?>/img/parlour_side.png" alt="Parlour Salon logo" id="logo" />

             <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                 <?php the_content('read more...'); ?>
<?php the_date(); ?>
             <?php endwhile; ?>             <?php else : ?>
I'm not sure what you're looking for.
             <?php endif; ?>
          <?php get_sidebar(); ?>          <?php get_footer(); ?>      Any ideas what could be causing the issue? I'm sure it's something simple, I've just been working on this for so long I need fresh eyes. Thanks. **ETA:** Also, for what it's worth, I've just noticed that style.css doesn't seem to be working in Safari. This didn't happen until I added the Press page and subsequent changes.


How to add options for Pages?

I would like to show an input field on the bottom, everytime, when a user create a new page. How is it possible?