How to Convert Custom Fields from Text to Array?

I want to convert my old post data containing custom fields that are stored in a text format like : `name , url $ name, url $ name, url` etc. I want convert that data and store the new data as an array in a new custom field.   Does anyone know how this can be done? I want to store that data so that I can use the data with this Gist: Repeatable Custom Fields in a Metabox (Author: Helen Hou-Sandi)


reset the users roles - is there a way to do this?

any way would be acceptable for me, even hacking the DB. I have messed up the roles with MEMBERS plugin, and i need a way of reseting the roles somehow. i can't seem to find a proper way. basically, I need to flush all roles, capabilities, and custom post type at once. it wouldn't cause any trouble with the one's who are written to the functions.php file, as i understand, - right?


Merge two WordPress installations into one, and keep posts separated?

I have two Wordpress installations that I would like to make into one installation, but still keep the posts (and their meta-data) separated. Both installations currently share the same database. I would like to be able to loop through both blogs, but each on their own page. I have extracted both databases using the built in export function in WordPress and am now sitting with two .xml files containing the posts from each database. Now I would like to import these posts into a new clean WordPress installation, BUT how can I keep the separated? I don't want them to get mixed up, because then I can't show them on their own page.. I am thinking about using a custom loop using WP_Query. Thanks, I hope you understand what it is I want.


Custom post type, custom taxonomy, query posts only from taxonomy (children of)

I have a custom post type (portfolio-type) with a custom hierarchical taxonomy (portfolio-category) Now I would like to query only posts from potrfolio-type, so i do:               $paged = 1;     if ( get_query_var('paged') ) $paged = get_query_var('paged');     if ( get_query_var('page') ) $paged = get_query_var('page');     query_posts( '&post_type=portfolio-type&paged=' . $paged );      And till here, everything works great. Now, I would like to query only posts, that are in any, of children custom taxonomy "categories" of a custom taxonomy category with given ID. So I tried:               $paged = 1;     if ( get_query_var('paged') ) $paged = get_query_var('paged');     if ( get_query_var('page') ) $paged = get_query_var('page');     $query_args = array(         'post_type' => 'portfolio-type',         'cat' => $CAT_ID,         'paged' => $paged,       );     query_posts( $query_args );      Failed (no results), but I understand Why. those posts are not in standard category, but in custom taxonomy's category, so looking at wp Codex, this is what I came with:               $query_args = array(         'post_type' => 'portfolio-type',         'paged' => $paged,         'tax_query' => array(             'taxonomy' => 'portfolio-category',             'field' => 'id',             'terms' => $CAT_ID         )     );      Failed again, but this time all custom posts from portfolio-type post_type displays (tax_query doesnt work, whatever ID i put there result is all the same) What am I missing?


NextGen Gallery quality, down-sizing and speed issues

I've done quite a bit of testing.   1. When uploading 4000px wide images, quality comes out terrible, jagged edges. Have experienced this in other situations, so I uploaded 1280 and 1936px wide originals with much better result.    2. Regardless of image quality setting in Options>Image tab, the 720px wide large photos are 300K, 400K, huge; as I said, NO change with different image quality settings.    3. At a ridiculously low setting of 20%, the image quality is no worse. Does this setting even work?    4. The built-in Thickbox lightbox functionality is very slow, even with some 60K images I pre-sized and uploaded. Takes 4 seconds minimum to display image. A second pass through, with the images in cache is much quicker. But the delay is not much different on first pass with a 60K or 400K image.    5. The built-in WordPress upload with 3 image re-sizes is a very good result but not accessible from nextGen.    6. Others need to use this, so it needs to be an easy tool.


How to show all posts by author on buddypress profile with navigation

I'm using Buddypress for wordpress and I'm trying to show a loop on the profile page of a user. I use infinite scroll to load more pages but the link to page 2 doesn't point to a group of posts and instead takes me to a blank page template but I do get this link.               "http://mysite.com/exampleuser/page/2"      Any ideas on how to make this page correctly? The following snippet is placed in the `profile-loop.php`.               <?php       global $bp;       global $paged;       global $wp_query;       $temp = $wp_query;       $wp_query = null;       $user_id = $bp->displayed_user->id;       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;       $args = array(             'posts_per_page' => 16,             'cat' => -1,             'post_type' => array(                  'post',                 'fod_videos',                 'fod_music',                 'fod_articles',                 'fod_albums'                ),             'author' => $user_id,             'paged' => $paged         );       $wp_query = new WP_Query($args);       while ( $wp_query->have_posts() ) :   $wp_query->the_post();          get_template_part( 'loop', 'contents' );       endwhile;       echo '
';         next_posts_link('Next');       echo '
';       $wp_query = null; $wp_query = $temp;      ?>


Will the use of a child theme create problems with commercial parent theme's options?

My client has a commercial theme full of options running on his site. I need to apply changes in the header.php and style.css. I plan to create a child theme so he can continue update his theme in the future without losing these changes. Is it possible that using a child theme on top of a commercial theme that has many options can create problems like making some options stop working properly?


1 post, 2 templates

I want to be able to render post in two different styles (2 templates). For example, let's say I have the post ID 133, I would like two URLS to access it and so it renders where different template would apply.   * lorem.com/render1/133   * lorem.com/render2/1333 for example... or it could be something like:   * lorem.com/post/133   * and lorem.com/post/133?template=2 How would you do it?


is there a better way of combining this?

Hoping someone can point me in the direction of writing this in a more succinct way. I'm working on my website, and want to display a total of 5 posts from the category 'general wonderings'. The first post has different styling from the other 4. Please see code below, Now, 2 problems... they way I've written it means that there is a duplicate post and secondly - surely there's a better way of combining this into one, rather than the way I've written it? Any help would be greatly appreciated. Thank you
           <?php     $args = array( 'category_name' => 'General Wonderings', 'posts_per_page' => 1 );     $lastposts = get_posts( $args );     foreach($lastposts as $post) : setup_postdata($post); ?>

<a href="<?php the_permalink(); ?>">               <?php the_title(); ?>

               <?php the_date(); ?>

               <?php the_excerpt(); ?>

<a href="<?php the_permalink(); ?>">Read more

           <?php endforeach; ?>

           <?php     $args = array( 'category_name' => 'General Wonderings', 'posts_per_page' => 4 );     $lastposts = get_posts( $args );     foreach($lastposts as $post) : setup_postdata($post); ?>

<a href="<?php the_permalink(); ?>">               <?php the_title(); ?>
               <?php echo substr($post->post_excerpt, 0,30); ?>...
               <?php the_date(); ?>

           <?php endforeach; ?>


How to read the contents of single post through RSS feed

I am able to fetch the contents of my WordPress site RSS feed through this tutorial on my mobile website. How can I get the contents of a single post through RSS?


Template messed up on viewing posts

Take a look at this post: http://mikewills.me/blog/links-for-2011-02-24/ My images are broke and CSS links are broke. I know the problem is with the permalink, but why would it be broke? I have the same problem with the Twenty Ten theme and the new Twenty Ten Five theme.


Document.body.scrollTop in Wordpress

I have a script that loads jQuery when an element comes into the viewport, as discovered by Javascript (without a library), and it looks like this: **viewport.js:**               var height = 0;     if( typeof( window.innerWidth ) == 'number' ) {         //Non-IE         height = window.innerHeight;     } else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {         //IE 6+ in 'standards compliant mode'         height = document.documentElement.clientHeight;     } else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {         //IE 4 compatible         height = document.body.clientHeight;     }          function gingah_comments_onLoad() {         var element = document.getElementById("comments");         var current = height+document.body.scrollTop;         var target = element.offsetTop;         console.log(current);         console.log(target);         if (current >= target) {             if (typeof jQuery == 'undefined') {                 $.defer("http://localhost/wp/wp-includes/js/jquery/jquery.js", {                 }).done(console.log('loaded jQuery'));                 window.onscroll = null;             }         }     }     window.onscroll = gingah_comments_onLoad;      **And the html used:**
Top

Comment1

           The DeferJS.min.js refers to a minified version of the following: https://github.com/BorisMoore/DeferJS/raw/master/DeferJS.js However, when I try to implement this in Wordpress (3.1), having used wp_enqueue_script for both viewport.js and DeferJS.min.js, the scrollTop appears to not work at all. When the HTML and JS above is combined, it will log the values to the console, making it very clear when _#comments_ came into the viewport. But when replicating the process in Wordpress, the _current_ var does not count upwards when scrolling down, but stays static. And, according to Firebug, viewport.js, DeferJS.min.js and l10n.js (Wordpress 3.1 localization) are the only scripts loaded. Also, Quirksmode lists the scrollTop method as available in practically all browsers. What could be the cause of this malfunction in document.body.scrollTop?


Does WP delete deprecated plugin/theme files on plugin/theme upgrade?

Let's say theme 1.0 is installed with 30 files in it. Then two weeks later theme is upgraded to theme 2.0 which contains only 10 files. Do those older 20 files get automatically deleted after upgrade? What I wanted to do is to place a file inside the theme directory, trough which the user can customize the theme. This file would be created after the theme is installed trough the theme settings. But if WP does delete files that do not exist in the official theme package, then this file would be deleted as well...


Advanced custom fields - pulling data in from another page

Hello I am using advanced custom fields and I am trying to pull data from multiple pages and display it on another I set up a relationship field called "data", and then on page X where the relationship field is displayed I have chosen page Y where I want to pull the data from               <?php if( get_field('data') ): ?>          <?php the_field('special_offer'); ?> <!--// get content from page Y -->     <?php endif; ?>      I can't get this to work though and Im presuming the above is wrong, does anyone know how I could do this please? Hopefully I have explained it clearly Cheers               <?php if( $related_pages = get_field( 'special_offer_relationship' ) ): ?>              <?php foreach( $related_pages as $page ): ?>             <?php echo get_the_title( $page->ID ); ?>             <?php echo get_the_excerpt( $page->ID ); ?>        <?php endforeach; ?>          <?php endif; ?>


In Loop Output Place Custom Field Content In Between Paragraphs

I'd like to place the contents of a custom field or variable in between the second and third paragraphs in the loop on a page template. Is there a way to do this? So for example, on a client's website I would like them to use the post editor to write out their page content, and keep things simple for them by giving them the ability to write out a call to action in a custom field that diplays between two paragraphs of               the_content();      using either a plugin or a PHP snippet or filter in functions.php. Thanks very much.


the_content is always surrounded by paragraphs (how to disable or remove them)?

`the_content` is always surrounded by paragraphs, it doesn't matter if I'm in HTML view and there's nothing there. Does WordPress have a function to remove them? IS there any way?


woocommerce buy button

My site is a affiliate and I want woocommerce buy button to open up website in a new tab. As i go through the code i see its functions like do_action, calling functions. don't know where are the function based. I checked functions file too but cannot find it. How can i break it down, that which components of woocommerce is being called and editing that function like i want to open the external website in another window.


post_content sanitization / transformation process

What kind of transformation does the post_content go thru when wp_insert_post inserts a post_content into wp_posts programmatically? I'd like to be aware of this before I process 50000 recs into wp_posts?


Search Bar in Thesis Wordpress Site

A friend of mine installed all the Thesis documentation for my new website. I am fairly proficient in HTML and CSS, but I need help with one issue. She tried adding a search bar in my main menu structure--which you will notice is totally random. I added a search widget instead. Where or how do I delete the incorrect search bar (it's in the top right corner of my site)? I can't figure out where it is coded into the site or how to remove it. The site is: www.ladidacreative.com


Update a post's info when clicking on a javascript button

I have a series of posts about various locations. I need people to verify if the location informaton is correct. The question is asked with two buttons for options. If "no" is clicked, they are taken to the edit page. If "yes" is clicked, the person's name is updated as the last person to verify the listing and the page is refreshed. My problem is that the person's name is updated whether or not they click on "yes". The wp_update_post is being run whther they click on the butin or not. Here is my code:
Yes
           What am I doing wrong?


Customize Search Results for Custom Post Type

Is there a way to use a custom PHP template for search results of a custom post type. I know that you can have specific archive and category templates for custom post types. For example, archive-custom.php. But, the same doesn't work for search.php. Any suggestions?


Editing "Kahi's Highlight Used Categories" plugin code - highlighting parent and child category in post page

I´m trying to highlight (using css), the child and parent categories in use in the selected post. So I´ve found this plugin "Kahi's Highlight Used Categories". Plugin´s website: http://kahi.cz/wordpress/highlight-used-categories-plugin/ What it does... It adds a 'used-cat' class and 'used-cat-parent' class to stylize, to the sub- category and main category respectively. The problem is: My website (http://www.mpn.p.ht/wp_br2/), has three main categories "Masculino", (means male), "Feminino", (means female), and "Infantil", (means infant). The sub-categories are the same for all the three main categories. So, let´s say, we are at the post page with main category "Masculino", and sub-category "Acessórios", (means acessories)... The plugin, seems to add 'used-cat' to all "Acessórios" (sub-category), found also in "Feminino" , and in "Infantil". I would like the plugin to add the class 'used-cat', only to the sub-category of the selected post. Not to all sub-categories found with the same name, through the categories list. Here´s the plugin code:               <?php     /*     Plugin Name: Kahi's Highligh Used Categories     Plugin URI: http://www.kahi.cz/wordpress/highlight-used-categories-plugin     Description: In the list of categories, adds classes used-cat and      used-cat-parents to particular list-items (when browsing a post).          Version: 1.0     Author: Peter Kahoun and Dirk Jaster     Author URI: http://www.kahi.cz/wordpress/     */          class KHUC {          function wp_list_categories ($text) {              global $post;              if (is_singular()) {                  $categories = wp_get_post_categories($post->ID);                  foreach ($categories as $category_id) {                      $category = get_category($category_id);                 $category_parent = get_category($category->category_parent);                      $text = preg_replace(                     "/class=\"(.*)\"><a ([^<>]*)>$category->name<\/a>/",                      ' class="$1 used-cat">' . $category->name .         '',                      $text);                      $text = preg_replace(                     "/class=\"(.*)\"><a ([^<>]*)>$category_parent-     >name<\/a>/",                      ' class="$1 used-cat-parent">' .      $category_parent->name . '',                      $text);                  }              }              return $text;          }          }          add_filter('wp_list_categories', array('KHUC','wp_list_categories'));      Does anyone know, what changes in the plugin code should I make, so I get only the sub-category in use to get the 'used-cat' class?


Combine query_posts() and get_posts() into single query

I am creating a site which uses normal posts for a blog and the a custom post type for events(generated by the events plugin). I have successfuly used different queries to grab both but I want to combine them into one query. Have tried various things with no luck. Here is query for blog:               <?php $mainFeatures = array( 'numberposts' => -1, 'order'=> 'DESC', 'orderby' => 'post_date');      $postslist = get_posts( $mainFeatures );      foreach ($postslist as $post) :  setup_postdata($post); ?>                             <?php endforeach; ?>      Here is query for events:                <?php query_posts(array('post_type'=>array(TribeEvents::POSTTYPE), 'numberposts' => -1,'order' => 'ASC')); ?>      <?php while (have_posts()) : the_post(); ?>                 <?php endwhile;?>      Have tried this but again only gets the events:                <?php $tryone = query_posts(array('post_type'=>post, 'posts_per_page'=> 18)); ?>      <?php $trytwo = query_posts(array('post_type'=>array(TribeEvents::POSTTYPE))); ?>      <?php $all_posts = array_merge( $tryone, $trytwo ); ?>           <?php query_posts($all_posts); ?>      <?php while (have_posts()) : the_post(); ?>
stuff
      <?php endwhile;?>


404 error on all pages but custom post types are working OK

I am getting 404 errors on all pages however I have multiple custom post types et up and these are working correctly. I have tried all the usual fixes like htaccess file, flushing the rewrite links but to no avail. I seem to be able to get pages working but have broken custom types or custom types working but no pages. Any ideas gratefully accepted!


What is the proper filter to add html to a post / page title?

I want to use Myanmar Unicode text on my blog. Unfortunatly, pseudo-Unicode Myanmar fonts are common. So, I am writing a plugin that will suround all Myanmar phrases with HTML span tags, and use css to select the proper font. Everything works fine for content, comments, etc. However, after adding HTML using the the_title hook, that HTML gets escaped, and then included in the title attribute of the link tag in the recent posts section. In addition, I'm seeing the raw HTML tags in the post name on my admin post screen. How should I go about solving this problem? I prefer to do everything from within my plugin, not change the theme files or something. Here is my code:               add_filter( 'the_title', 'addThemSpans');     function addThemSpans($theTitle) {       // functionality to add span tags to $theTitle so that a title that looks like this...         // LatinTextHere ကကကကက MoreLatinText       // becomes this...         // LatinTextHere ကကကကက MoreLatinText         // in the final output.       return $theModifiedTitle;     }      As it is now, the title attribute for the link in the recent posts sidebar widget is set to:               LatinTextHere <span class='myText'>ကကကကက</span>ကကကကက MoreLatinText      Which is not right.


Allow multiple contributors to one post

I have been asked how easy it would be to have multiple contributors being able to submit content that would be brought into one post. The rub is that they wouldn't be allowed to see the main post or edit the post, this would be reserved for the site admins - their role would be mainly around adding their piece of the post into the mix and that would be it. I know this isn't standard functionality, but I don't even know where I would begin looking for a plugin - I could roll my own but if this is a solved problem then I would rather utilise that fact. So I guess my main question is _Is this a common power-user feature and what name does it go by?_ This is essentially to replace the current system that involves people emailing in content that gets copied and pasted into the post.


Wordpress REST endpoint with JSON for Mobile App integration

Is there some REST API that Wordpress supports, out of the box or through any plugin that exposes the same information exposed through the normal pages? (I.e. latest posts, filtering by categories etc.) There seems to be a JSON API plugin but it seems to be very old and not maintained. There also seems to be some plugin called Jetpack but not sure if it provides what I am looking for (seems more dedicated to content management rather than exposing it publicly). I am trying to integrate a Mobile App with a Wordpress Blog, and I need to find the best way to transfer the information to the application in terms of performance and also displaying it right. (Any ideas appreciated)


Loading style.css and Jquery using HTTPS

We have several environments and we have just started using wordpress (Dev, QA, Pre-prod, prod etc...). We don't have https enabled in the lower environments and everything is working smoothly. In our prod environments the site redirects all traffic to https. The first issue seems to only be with chrome. Chrome refuses to load anything on the page that isn't https. I am unsure how to get WordPress to load jquery or styles.css (from my theme) over https ( more information below). The second issue also with HTTPS is we cannot log into wordpress in the environments that use HTTPS. When the login screen loads (sitename.com/wp- admin) you get redirected to wp-login as expected but upon entering your username / password the page just refreshes. No errors (checked console / firebug and httpfox and couldn't find any errors). I know we are doing something wrong with https in general because we are having many problems in the environments that support it. I have done a bunch of googling and haven't really come up with much on using HTTPS and wordpress surprisingly. Aside from answers to the questions of how to load jquery via HTTPS and how can we log into the https wordpress instances, are there any good links on how to work with HTTPS in wordpress. Almost everything I have found points to using the plugin WordPress HTTPS and we are going to try that but I am not sure if it will solve all of our issues. Note* In my functions.php I am using Enqueue to load JS and CSS files the proper way, and I am using relative pathing on those loads //sitename.com/bla/bla which works fine. I am loading jquery using: in my header.php and styles.css is loaded automatically as part of my theme loading using , so I don't know how to configure either to load via HTTPS or if that is even the correct approach to fixing these issues. (jQuery is loading from our local file system not a CDN). Any help would be greatly appreciated. Thanks in advance.


How to display class name in this shortcode post query

I need help with this as it's my first project of my new job & I'm stuck at this point. I'm retrieving custom post types portfolio using this code as a shortlist:               extract( shortcode_atts( array( 'limit' => -1, 'type' => 'post'), $atts ) );          $paged = get_query_var('paged') ? get_query_var('paged') : 1;            query_posts(  array (          'posts_per_page' => $limit,          'post_type' => $type,          'order' => 'ASC',          'orderby' =>'menu_order',          'paged' => $paged ) );          $list = ' ';             while ( have_posts() ) { the_post();              $list .= '
'          . '
'          . '
' . get_the_title() . '
'          .'
' . get_the_excerpt() . '
'         . '' . 'View »' . ''         . '
'         . '' . get_the_post_thumbnail($page->ID, 'listing-thumb')  . ''         . '
';     }          return      '
'      . $list      . '
' . get_next_posts_link( __( '← Older posts' ) ) . '
'     . '
' . get_previous_posts_link( __( 'Newer posts →' ) ) . '
'     . '
' .     wp_reset_query();          }     add_shortcode( 'feed', 'section_feed_shortcode' );      I want to display the custom taxonomy "name" at the following point of code:               $list .= '
'       Is it possible to do. If yes, then featured image as well. Thanks!


What are the package and subpackage comment for?

This is included in themes and plugins.               /*      * @package WordPress      * @subpackage Twenty_Ten      * @since Twenty Ten 1.0      */      What are they for? I've read that they are standard and so on, but what is the practical use for it?


db query for retrieving comments without any reply

what is a query for selecting a list of comment id's that have not had a reply yet so I can use it to iterate though each comment id and echo out the post it is on and the excerpt of the comment along with the author name, url and how many comments?


List Recent Post Titles from Custom Taxonomies?

I'm managing a movie related site.. I'm using yoast's simple taxonomies plugin to classify my content with Artists, Genre (action, horror, comedy, drama etc..), Director, Writer etc... On a specific page (template), I want to pull last 5 posts with only their titles from custom taxonomies.. how can I pull last 5 titles from Action, Comedy or Horror taxonomies as list? I will try to get an output like http://tutsplus.com/ Thanks


Posted date format not reflected

WP3.6, Twenty Thirteen theme No matter which `Date Format` I choose, the date on actual posts are shown like this:               %A %B %e%q, %Y      Note that the actual texts look like this; not even the date values (eg. 9/01/2013). Looking at `content-link.php`, date might be displayed by the following that I suspect is not returning a right value?                       <?php twentythirteen_entry_date(); ?>      What's wrong? Thank you.


Any Good WordPress Themes Compatible With The BBPress Plugin?

Does anyone know of any good wordpress themes that are compatible with the bbpress _plugin_? I'm looking for something with a good layout, preferably a magazine/news type theme. Thanks :)


Slidedeck Pro Wordpress Image Size

I was using Slidedeck pro wordpress (dynamic slider), and set it to pull in the first image from the post's gallery as the image. However, it keeps resizing the image down to 270px when I really need to have the image at 500px. Does anyone know how to remedy this? I did find a template file with the resizing ratio. However, I am not even sure what to change to achieve the 500px width I need.               // Correct image aspect ratio to fit within skin's image constraints     if( !empty( $image ) ){         if( !empty( $image['width'] ) ){             if( $image['width'] > 270 ){                 $w_ratio = 270 / $image['width'];                 $image['width'] = floor( $w_ratio * $image['width'] );                 if( isset( $image['height'] ) ) {                     $image['height'] = floor( $w_ratio * $image['height'] );                 }             }         }         if( !empty( $image['height'] ) ){             if( $image['height'] > 250 ){                 $h_ratio = 250 / $image['height'];                 $image['width'] = floor( $h_ratio * $image['width'] );                 $image['height'] = floor( $h_ratio * $image['height'] );             }         }     }      I did try changing 270 to 500 earlier to no avail.


Can't display shortcode in WP_Query loop

I want to display all posts from my CPT `brand`. My WP_Query loop works well but the shortcode I want to use within it doesn't work. This shortcode comes with some plugin called `Download Attachments`, but I suspect the problem is not plugin-related. Here's the code of my loop:               $query_brands = new WP_Query('post_type=brand');     while ($query_brands->have_posts()) : $query_brands->the_post();         the_title();                                             echo do_shortcode("[download-attachments]");     endwhile;      The shortcode line is supposed to display all attachments of the post, but for some reason it does nothing here. Why not?


Custom Meta Box If Else Statement

I have created a custom meta box for posts and I need to display said data. I have been using the below method to display the data, But I am in need of a slightly different solution.               <a href="<?php echo esc_attr( get_post_meta( get_the_ID(), 'my_meta_box_text4', true ) ); ?>">         <img src="<?php echo esc_attr( get_post_meta( get_the_ID(), 'my_meta_box_text3', true ) ); ?>" alt="" onerror="this.style.display='none'"/>           What I need is a way to do a IF/Else statement such is. If `my_meta_box_text3` exists `echo that`, else `echo this`.


How to properly sanitize strings without $wpdb->prepare?

I'm working on an advanced search (which uses custom sql queries), and the query string is formed using variables. For example, if the person checks some options, only those conditions get added to the WHERE clause. I can't use `$wpdb->prepare`, since I want to be able to add variables to my query string that look something like:               $var = "AND pm.meta_value = '%$_POST['val']%'";       I looked at `like_escape()`, but the documentation says: > Sanitizes $string for use in a LIKE expression of a SQL query. **Will still > need to be SQL escaped (with one of the above functions)**. What would be an appropriate way to escape $val?


Is there an advantage of using multisite if I have multiple WordPress websites for myself?

I have multiple WordPress websites, they all have their own domain and are standalone. Is there an advantage of using multisite? Or is my current setup good?


How to make 10 post of one category

How can I make 10 posts of one category. What query should I use. Here in following query I need its limit of post in per page.

                     <?php if ( have_posts() ) : ?>
Category Archives: <?php echo  single_cat_title(); ?>

<?php echo category_description(); ?>

                 <?php while ( have_posts() ) : the_post(); ?>
                         <a href="<?php the_permalink();?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title();?>
                 <?php endwhile;?>                          <?php endif; ?>      **EDIT** I meant to say that I want 10 posts in category.php . Let suppose I am clicking one category in categories so it should show result 10 post of each category.


Why does my visual post editor break when I try to add a TinyMCE button?

I'm trying to add a button to my TinyMCE editor. I'm using WordPress 3.9.1, so I'm following this tutorial to add a new TinyMCE button. Right now, I'm just trying to get the tutorial version working--once that's done, I'll edit the button's script to actually do what I want. I've added this to my child theme's `functions.php` file:               // Hooks your functions into the correct filters     function my_add_mce_button() {         // check user permissions         if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {             return;         }         // check if WYSIWYG is enabled         if ( 'true' == get_user_option( 'rich_editing' ) ) {             add_filter( 'mce_external_plugins', 'my_add_tinymce_plugin' );             add_filter( 'mce_buttons', 'my_register_mce_button' );         }     }     add_action('admin_head', 'my_add_mce_button');          // Declare script for new button     function my_add_tinymce_plugin( $plugin_array ) {         $plugin_array['my_mce_button'] = get_template_directory_uri() .'/js/mce-button.js';         return $plugin_array;     }          // Register new button in the editor     function my_register_mce_button( $buttons ) {         array_push( $buttons, 'my_mce_button' );         return $buttons;     }      I've also created a script with the content below, and saved it as "mce- button.js" in the /js directory of my child theme's folder.               (function() {         tinymce.PluginManager.add('my_mce_button', function( editor, url ) {             editor.addButton('my_mce_button', {                 text: 'New Button',                 icon: false,                 onclick: function() {                     editor.insertContent('WPExplorer.com is awesome!');                 }             });         });     })();      However, when I save all that and load the post editor (in the "Visual" tab), none of the buttons load, and I can't enter text in the editor. In fact, if I go to the "Text" tab and enter text, then switch back to the "Visual" tab, the text I entered doesn't appear. ![Broken WordPress editor](http://i.stack.imgur.com/dwKnY.png) Could someone please help me figure out why my TinyMCE editor is breaking, and how I can add buttons properly without breaking it? Thank you!


Can I use OR relation for one item when calling tax_query from WP_Query and use AND for the rest?

I am trying to refine search in wordpress template. Basically I want to use multiselect with . I am using array to store selected options like this: location[]=term1&location[]=term2 etc etc. This is how the search code looked:                   $form_location = $_GET['location'];              if ($form_location != "")         $form_location = array(             'taxonomy' => 'location',             'field' => 'slug',             'terms' => $form_location         );               // Final Query         $items_args = array(             'post_type' => 'listings',             'meta_query' => array(                 $form_price,                 $form_area_range,                 $rentbuy             ),             'tax_query' => array(                 'relation' => 'AND',                 $form_location,                 $form_property_type,                 $form_rating,                 $form_bed,                 $form_bath             )         );         ?>         <?php $items_args = new WP_Query($items_args); if ( $items_args->have_posts() ) :       ... I modified $location to handle array. I didn't quite done the loop right because I am not sure how to handle tax_query. Here is what I did. I added foreach:                       foreach ($form_location as $loc2) {             $form_location = array(                 'taxonomy' => 'location',                 'field' => 'slug',                 'terms' => $loc2             ); }      This is the output I cached:               WP_Query Object ( [query_vars] => Array ( [post_type] => listings [meta_query] => Array ( [0] => [1] => [2] => Array ( [key] => rentbuy [value] => rent ) ) [tax_query] => Array ( [relation] => AND [0] => Array ( [taxonomy] => location [field] => slug [terms] => term1 ) [1] => [2] => [3] => [4] => )...      Here is the thing, I want the location taxonomy to be used for a query with OR condition for every item from Array it got, and others from tax_query with AND. Is this possible and how? Google is not friendly tonight.


Wordpress multi-query not returning as expected

I am trying to perform a merged query to get _at most_ 6 posts from either the `post` post type and my `events` custom post type. The `post` query is based off of whether or not the Featured Image is set, and the `events` query is based off of whether or not the post has the meta value _Featured_ selected. Everything works except: **The query only returns 5 posts, and they are not balanced in the sense that [depending on which post I set as Featured/Add Featured Image too] they take precedence over one another.** For Example: If I add a Featured Image to a `post` post the results will be _3 event, 2 post_. If I then check the Featured meta value in an `events` post type the results will be _4 event, 1 post_. Here is the code I am using to query and return posts:                       <?php             $post_types = get_post_types('','names');             $featuredEvents = get_posts(array(                 'post_type' => 'events',                 'post_status' => 'publish',                 'showposts' => 6,                 'meta_key' => '_ecmb_featured_event',                 'meta_value' => 'on'             ));             $featuredNews = get_posts(array(                 'post_type' => 'post',                 'post_status' => 'publish',                 'showposts' => 6,                 'meta_key' => '_thumbnail_id'             ));             $mergedPosts = array_merge( $featuredEvents, $featuredNews );             $postIDs = array();                 foreach( $mergedPosts as $item ) {                 $postIDs[] = $item->ID;             }             $uniquePosts = array_unique($postIDs);                  $posts = get_posts(array(                 'post__in' => $uniquePosts,                 'post_type' => $post_types,                 'post_status' => 'publish',             ));                  foreach( $posts as $post ) :             setup_postdata($post);             if( get_post_type() == 'events' ) { ?>                         This is a Featured Event             <?php } elseif (get_post_type() == 'post') { ?>                         This a post with the Featured Image set             <?php } endforeach; wp_reset_query(); ?>      Can someone help me with this? **Edit:** Thanks to the answer below, I figured it out and used the following code:               $sliderQueryArgs = array(         'posts_per_page' => 6,         'post_type' => array(             'post',             'events'         ),         'orderby' => 'post_date',         'meta_query' => array(             'relation' => 'OR',                 array(                     'key' => '_ecmb_featured_event',                     'value' => 'on'),                 array(                     'key' => '_thumbnail_id',                     'compare' => 'EXISTS')         )     );          $sliderPosts = get_posts( $sliderQueryArgs );


Alternative to file_get_contents() for theme operations

My theme options page needs to write to the style.css file in order to store updated theme settings. To do that, I'm using file_get_contents() and file_put_contents() However, theme-check plugin complains about it. What is an acceptable alternative for writing to local files?


Adding Woo Commerce using Hooks

Can't figure out what I'm doing wrong with adding Hooks to the `functions.php` I've added it and the pages are still broken. I'm not sure how it should look. This is what I did. My theme is called "instyle"   My content id is `content-area`:               remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);     remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);               add_action('woocommerce_before_main_content', 'instyle_wrapper_start', 10);     add_action('woocommerce_after_main_content', 'instyle_wrapper_end', 10);          function instyle_wrapper_start() {       echo '
';     }          function instyle_wrapper_end() {       echo '
';     }


How to detect if website has a mapped domain attached to it on multisite network

I'm trying to to detect if a website has a mapped domain attached to it on a multisite network. If not, disable search engine visibility. This is what I have so far:               //* Disable search engine visibility for unmapped sites     add_action( 'init', 'noindex_unmapped_domain' );     function noindex_unmapped_domain( $blog_id ) {         $this->_mapped_domains = array();         $results = $this->_wpdb->get_results( "SELECT blog_id, domain FROM " . DOMAINMAP_TABLE_MAP );         foreach ( $results as $result ) {             if ( !isset( $this->_mapped_domains[$result->blog_id] ) ) {                 $this->_mapped_domains[$result->blog_id] = array();                     add_action( 'pre_option_blog_public', '__return_zero' );             }         }     }      Originally I thought I had a version working, but since I use subdomains in the admin area it was throwing false positives. I believe the code above will work even with using subdomains in the admin area as long as a mapped domain is attached to the site for the frontend, but I'm having issues getting it to work. While we're at it, open to suggestions if there's a more efficient way to do this. Thanks!


Post taxonomy from exif data

Whenever I post a post with a featured image, I want to extract the exif data from that image and attach it as a term for a taxonomy. I already got a plugin which can extract the relevant info, but I dont know where and when to call `wp_set_object_terms` Can anyone point me in the right direction?


Fatal error: Call to a member function add_rewrite_tag() on a non-object in /wp-includes/taxonomy.php on line 333

I get this error while trying to load wordpress in a smarty template. But when I visit wordpress I dont get that error any where. the code I use to load wordpress is :               {php}include $_SERVER['DOCUMENT_ROOT'].'/wordpress/wp-load.php';     get_header();{/php}      The Error : Fatal error: Call to a member function add_rewrite_tag() on a non- object in /wp-includes/taxonomy.php on line 333


Why would running an admin check throw a 500 error? I'm calling is_super_admin();

I have a plugin that I wrote. A user was experiencing compatibility problems with a theme of theirs which uses a masked dashboard to add listings on their site. If the user was logged in, and a contributor, but NOT an admin, my check for is_admin() would return true since they were technically on a dashboard page. So.. my code checks if they are admin, then runs a series of functions. One of the checks is whether or not they have permissions to manage options. If they don't have permissions to manage options, it dies. This is a problem with the theme, so I simply wrapped my add_action tags with the following               if ( is_super_admin() ) {            add_action( 'admin_init', 'myplugin_register');         add_action( 'admin_menu', 'myplugin_menu' );         }      This throws a 500 error when any admin accesses the wp-admin area of the site. I'm not sure why a simple check to see whether or not the user is a super admin would crash the site. More info on is_super_admin() here http://codex.wordpress.org/Function_Reference/is_super_admin


Custom Fields Not Showing

I have this custom field for a post:               key: price     value: 2000      I've added this to my loop:
<?php $price = get_post_meta($post->ID, 'price', true);     if ( $price ) { ?>     Price: $<?php echo number_format($price ,",",",",","); ?>     <?php } else {} ?>
      But all I'm getting is:               Price: $


output the debug lines to the end of the page

Does anyone know a hook, which doesn't depend on the template. A hook I can rely on in any situations? there's some debug data collected while loading pages (i'm using 'all' hook to collect filter names) i would like to log to the screen. i need the data displayed, say, before               </body>       tag. Thanks.


How do I display the index position of a post from a custom post type?

So I have a custom post type (ex. songs) and have a few posts that I created for this post type. I want to display them on a webpage in order (ex. 1, 2, 3, ...). How do I get the index position and display it on my page? Any insight or solutions would be greatly appreciated!


Display the contents of a custom field of a page on their child

Let's see if anyone knows how to accomplish the following: I have a custom field, which is a textarea where the user can enter any text. The idea is that if a page is filled in that field, the entered content appears on all child pages. CASE 1   * Page 1    * Page 1.1 (the user fills out the custom field and displays the   content)   * Page 1.1.1 (displays the contents of the field completed on Page 1.1)    * Page 1.1.2 (displays the contents of the field completed on Page 1.1)   * Page 1.1.3 (displays the contents of the field completed on Page 1.1) CASE 2   * Page 1 (the user fills out the custom field and displays the content)   * Page 1.1 (displays the contents of the field completed on Page 1)   * Page 1.2 (the user fills in the field, so it inherits from Page 1.1, but shows your own)   * Page 1.2.1 (displays the contents of the field completed on Page 1.2) I hope I explained well with the examples of what I get. Thank you in advance.


Only looping through pages that have children or subpages

I have a custom post type called "films", and most films have a subpage (child page) called "press". I am trying to loop through the films, and check to see if a subpage exists. If a subpage exists, loop through the content. If it doesn't exist, leave out the content. My loop is as follows:               <?php $loop = new WP_Query( array( 'post_type' => 'films', 'posts_per_page' => 8,'orderby' => 'date', 'order' => 'ASC', 'film-categories' => 'available-now-shows-on-homepage' ) ); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
          <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>          <?php endwhile; ?>      I only want the linked title to show if it's page has children (a press page). How would I modify the loop to do just that?


Link to full-size image for subscriber only

I'm looking for a way to disable the "link to full-size image" for people that are not logged in. I would like that people become a subscriber before they can download my full size images. Is this possible?


Problem with using wp-load.php outside of WordPress

I'm trying to use wp-load.php in a page outside of wordpress so I can access all the functions in wordpress. Typically I just include the file like this               require( $_SERVER['DOCUMENT_ROOT'].'/blog/wp-load.php' );       But it doesn't seem to be working. Any tips on what can be going on? Thanks, Paul


Simple plugin for showing RSS subscription links?

Does someone know of a simple plugin for showing RSS feeds? I need something dead simple that only show the links and would rather re-use something before rolling one myself.


how do I encode links to specific archive searches?

I want to embed links to the archive pages with specific search criteria. i.e Links to specific categories, links to specific authors etc etc At the moment I am adding the links using anchor tags, but these will fail if the permalinks change


Show links to archive pages based on custom field values

I have a recruitment website on which I want to display a list of Job Location links. The job location has already been entered into a custom field for each post so I just want to display a list of links that when clicked will show posts with only that custom value entered, ie - England Ireland USA etc.. Click a country link above and see all of the posts that have the country in question added as a custom field value??


Add custom text to Page Tamplate without need to know html

I am new to wordpress. I have experience in css \ html \ js and asp.net (and also a bit of php now). I've added to my blog certain areas that are hard coded in html and css. In these areas I'd like to be able to set text based on the admin's input in the panel's page. I want a person who doesn't know html to be able to easily change the content of these hard coded areas. How can this be done? Thank you!


Can't insert caption into image

You can see live example here. When I add a caption into the image, it doesn't show at all!   I've added the caption to the image as you can see in the next picture      ![Here](http://i.stack.imgur.com/hKokm.png)      but it doesn't show as you see below      ![here](http://i.stack.imgur.com/LYvCJ.png)      But when I click edit the picture icon as you see below      ![here](http://i.stack.imgur.com/zcQGI.png)      and fill in the caption field      ![here](http://i.stack.imgur.com/NplmB.png)      the caption works!      ![fine](http://i.stack.imgur.com/ElK81.png) Why it's not working in the first case? I've disabled all plugins and no luck! I've tried the twenty fourteen theme, and no problem there, so the problem is in my theme only. Can you please help!


Redirect certain pages if user logged in

how would one go about redirect certain pages if the user viewing them is logged into the WordPress CMS? For example, we have 2 registration pages that when logged in should direct to some other page / category archive. Thanks.


Are there plugins that interfere with the admin part of Rss widget?

I've been using the Rss widget in my site, and suddenly a few days ago, the admin part stopped responding.   That is, I'd change the link to the Rss and it wouldn't get saved (and therefore would show the old Rss in the site). Or I would add another Rss widget, but after I refreshed the admin page, I'd see the widget, but without the links and the other options I added.   Then I got to thinking that maybe one of the plugins could be causing the problem.   Are there known plugins that would do that?


Is it possible to post with Word 2007 via XML-RPC and limit categories by user?

I'm working on a project for a school district I work at where we want to use Word Press to have employees from all of the buildings post announcements and press releases via Word 2007. We will then use RSS feeds to show the information on the district's web page and other subscribed locations. The problem we are running into is when we create user roles for categories, this basically is not working through the XML-RPC in Word 2007. It is working fine within the administration panel, but when the user goes to insert a category in Word, all of the categories are shown. We would like to limit the available categories by user so that only a building secretay and principla can post the the high school category for example. I have been search for a couple of weeks for a solution to this, if one exists. Does anyone have any ideas?


is_front_page not working at all in any of the themes .php files

I am using the Paragrams theme from the kind folks at wpshower. I have a little different front page that I would like to load with an image rotator and different layout in the for loop. I have tried all of the conditional comments, with no avail. There are some posts on this already that didn't have a solution...   * is_front_page, is_page('slug'), is_page(id) not working   * is_front_page() not working wordpress I even tried this most basic if else from the WP forum without any help. What am i missing? :(               <?php     if (is_front_page())     {?>
Flash Gordon
          <?php } else { ?>
Wins the Battle!
     <?php } ?>


how does get_term_by know which term to return when the same term appears twice in a hierarchical taxonomy?

This is from the codex.               <?php get_term_by( $field, $value, $taxonomy, $output, $filter ) ?>      Suppose I have a taxonomy system as follows; taxonomy: "healthy foods" and it's a hierarchical taxonomy and your hierarchy goes exactly like this;               healthy foods         fruits             red ones             green ones         veggies             red ones             green ones      and you use the `get_term_by` function as follows; get_term_by("name","red ones","healthy foods") Do you get the veggies or the fruits?


My WordPress site always displays a cached version of its homepage

First of all, sorry if I'm making a mistake. I already asked this on the ServerFault forum, but got no answers at the moment and I thought it would be a good idea to ask the question here, considering that it is a WordPress specific question. I have a WordPress site that runs fine, but there's a strange behaviour: one a reader loads the page, **the site shows a "cached" version** of the site, with the same news and comment numbers that the reader viewed when he visited the site last time. So every user **has to reload the page** (Ctrl+F5, Cmd+R) in order to get the "real", and updated homepage. I don't know why this is happening. At the moment I'm not using any cache plugin, and my server is running **Nginx+MySQL+PHP-FPM** on a Ubuntu 10.04 LTS Linux VPS. Is there something I must change on the nginx config files, maybe?


Users Role and Access

I am a bit of a novice to this so please be patient. I am trying to create a site with a programmer using wordpress, but not using it for blogs or post.   I am not a programmer myself. I want people to register for the site, and by default their role will be a modified subscriber. Meaning they will have no access to admin nor to any kind of editing on the site. All they can do is view the pages. Also, I want to restrict them to view only a particular page or pages. Admin can later go and change their status and make their role to a regular subscriber. What I am really trying to do is to create a site with a full restrictions.   Users will register, but still don't gain access until their registration is reviewed by the admin and grant access to them. Is this possible?


get_categories for custom post type and filter by custom taxonomy (brand) and list child categories of a defined category

Thanks to @MikeSchinkel I have the following code:               $term = get_query_var('term');         $brand = get_term_by('slug',$term,'brands'); // This here just to illustrate         $categories = get_cross_referenced_terms(array(         'post_type'        => 'Products',         'taxonomy'         => 'category',         'related_taxonomy' => 'brands',         'term_id'          => $brand->term_id       ));      which uses the following function:               // query to get categories for a specific tag     function get_cross_referenced_terms($args) {       global $wpdb;       $args = wp_parse_args($args,array(         'post_type'        => 'Products',         'taxonomy'         => 'category',         'related_taxonomy' => 'brands',         'term_id'          => 0,       ));       extract($args);       $sql = <<<SQL     SELECT DISTINCT       {$wpdb->terms}.*,       COUNT(*) AS post_count     FROM       {$wpdb->terms}       INNER JOIN {$wpdb->term_taxonomy} ON {$wpdb->terms}.term_id={$wpdb->term_taxonomy}.term_id       INNER JOIN {$wpdb->term_relationships} ON {$wpdb->term_taxonomy}.term_taxonomy_id={$wpdb->term_relationships}.term_taxonomy_id       INNER JOIN {$wpdb->posts} ON {$wpdb->term_relationships}.object_id={$wpdb->posts}.ID       INNER JOIN {$wpdb->term_relationships} related_relationship ON {$wpdb->posts}.ID=related_relationship.object_id       INNER JOIN {$wpdb->term_taxonomy} related_term_taxonomy ON related_relationship.term_taxonomy_id=related_term_taxonomy.term_taxonomy_id       INNER JOIN {$wpdb->terms} related_terms ON related_term_taxonomy.term_id=related_terms.term_id     WHERE 1=1       AND related_terms.term_id<>{$wpdb->terms}.term_id       AND {$wpdb->posts}.post_type='%s'       AND {$wpdb->term_taxonomy}.taxonomy='%s'       AND related_term_taxonomy.taxonomy='%s'       AND related_terms.term_id=%d       AND {$wpdb->term_taxonomy}.parent=0     GROUP BY       {$wpdb->terms}.term_id     SQL;       $sql = $wpdb->prepare($sql,$post_type,$taxonomy,$related_taxonomy,$term_id);       $terms = $wpdb->get_results($sql);       return $terms;     }      This is used on the category.php page and works great, but I need to now use the same code (ideally) on the child category page? So for example I have it on a category page of 'trainers', filtered by brand of 'nike' for the custom post type 'products'. I now need it to show all child categories of 'trainers', also filtered by brand of 'nike' for custom post type of 'products'. Is there a way to simply add?               'category_id'         => '$parent_category',      Any help would be greatly appreciated! Thanks Dave


I have a WordPress site that runs fine, but there's a strange behaviour: one a reader loads the page, **the site shows a "cached" version** of the site, with the same news and comment numbers that the reader viewed when he visited the site last time. So every user **has to reload the page** (Ctrl+F5, Cmd+R) in order to get the "real", and updated homepage. I don't know why this is happening. At the moment I'm not using any cache plugin, and my server is running **Nginx+MySQL+PHP-FPM** on a Ubuntu 10.04 LTS Linux VPS. Is there something I must change on the nginx config files, maybe?


previous_post_link in same taxonomy in custom post type

Im trying to make previous_post_link and next_post_link work inside a custom post type, inside a same category (taxonomy) but its not working. It this posible ? Im trying               <?php previous_post_link('
%link
', 'Next in category',TRUE); ?>


The Jetpack site is inaccessible 32700

I installed Jetpack and I activated JSON API. When i try to access my blog it shows following error: `{ "error": "jetpack_error", "message": "The Jetpack site is inaccessible or returned an error: parse error. not well formed [-32700]" }` What i have to do now?


Restrict authors to seeing ONLY their media files

I'd like to restrict authors ability to see files uploaded by other users because this causes no end of trouble, since they can change captions etc. I tried this code from here How to hide media uploads by other users in the Media menu?               add_action('pre_get_posts','users_own_attachments');     function users_own_attachments( $wp_query_obj ) {              global $current_user, $pagenow;              if( !is_a( $current_user, 'WP_User') )             return;              if( 'upload.php' != $pagenow )             return;              if( !current_user_can('delete_pages') )             $wp_query_obj->set('author', $current_user->id );              return;     }         This only works on the media screen, not when you select a file on a post to actually upload. I also tried the second solution, but it's causing issues with my autocomplete search function and I can't figure out why. Is there a way to stop authors seeing others files when they're making a post?


Wordpress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache

I have been working on a theme for a few days and when I realized my JS file for my theme customizer wasn't updating I decided to clear the cookies and cache, and wow that was problematic. As soon as I did that I recieved this error many times, mainly stating the file I am working on(customize.php and the other file it said was pluggable.php:               Warning: Cannot modify header information - headers already sent by customize.php       After I tried to login I am now receiving this error:               Parse error: syntax error, unexpected T_FUNCTION on line 1      Everytime I replace the file with a previous version it keeps messing up the format of the code and making it all one line of code as soon as I refresh the page and redownload the file. I don't understand what is causing this. Why is it making the whole file 1 line? It makes it harder for me to find the original issue. **Edit:** I ended up creating a an empty file and copy and pasted the code into it. After that my issue stopped. For some reason Notepad++ was adding way too much whitespace to the width of the file causing all of the code to form on 1 line. Therefore causing a plethora of problems. After pasting the code into a new file it works.


Admin permission for creating blogs in multisite

How can I do that ? I have some blogs and anyone can register and build a new blog . I'd like to limit them just to visit and comment not to build a new blog unless I allow them .


dynamic page not indexed

Im writting a plugin who makes dynamic pages with simple page template: http://domain.com/slug the url is rewriting so internally call to http://domain.com/index.php?pagename=users and works, but the problem is, how I can index it to make searches? Any ideas?


To Add Logout Button in Menu

> **Possible Duplicate:**   >  How to use logout function on custom menu link? I want to add a logout button at very last of my nav.. I Found a function               // functions.php     function add_login_logout_link($items, $args)     {       if(is_user_logged_in())       {         $newitems = '
Logout
';         $newitems .= $items;       }       else       {         $newitems = '
Login
';         $newitems .= $items;       }       return $newitems;     }     add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);      But It adds Logout button to the very start of the nav, and i want to to be displayed on very Last. (Ideally it should be float:right, as other menu items are float:left) Thanks


How to fix admin stylesheet muck-up?

I have no idea what's going on here.. running the latest version, just logged in and I find my admin area looking like this: ![enter image description here](http://i.stack.imgur.com/xTyoZ.jpg) To me it looks like it's missing some/many styles and in load-styles.php in the inspector it's showing a bunch of gibberish and I have a 'Uncaught SyntaxError: Unexpected token ILLEGAL' error twice on loadscripts.php. I tried reinstalling the current version of WP and nothing changed. Then I reuploaded the load-styles.php (same size) from the base wordpress files, and it started working. Then suddenly it was doing the same thing on another of my sites. I tried the same trick (and also with load-scripts.php (this time though the load-styles was much larger so I backed it up) but that didn't help. The only thing I can imagine might be causing this is the iOs wordpress app because I recently added it to both blogs. That's the only change I've made in the last little while and I've been on the sites before with no issue.


How to override wp_insert_comment()

I am trying to override `wp_insert_comment()` (wp-includes/comment.php). I added the following lines of code in my `functions.php` file, located in my theme :               add_filter('wp_insert_comment', 'my_insert_comment');     function my_insert_comment($commentdata)     {          /* Some stuff */     }         Here is a line found in the original wp_insert_comment() function :               function wp_insert_comment($commentdata)     {         /* Some stuff */         do_action('wp_insert_comment', $id, $comment);         return $id;     }      After many tests, I have the feeling that the real `wp_insert_comment()` is executed, and when it comes to the `do_action()` line, my filter is taken into consideration and my `my_insert_comment()` function is finally executed.    Of course, my purpose is to replace the original function by my own one. `my_insert_comment()` is working fine if I write it directly in the `comments.php` file, but I would like to keep it _update-proof_. Am I doing something wrong ?


in_category for custom post types

how can I use the in_category for custom post types? here is my code.               <?php get_header('shop'); ?>      ?>               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); global $_product; $_product = new jigoshop_product( $post->ID ); ?>              <?php do_action('jigoshop_before_single_product', $post, $_product); ?>              <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                  <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Lesson Sidebar')) : else : ?>             <?php endif; ?>
             <?php do_action('jigoshop_before_single_product_summary', $post, $_product); ?>

Lesson Pack

<?php the_title(); ?>
                      <?php do_action( 'jigoshop_template_single_summary', $post, $_product ); ?>

Description
             <?php the_content();?>
                          <?php do_action('jigoshop_after_single_product_summary', $post, $_product ); ?>
              <?php do_action('jigoshop_after_single_product', $post, $_product); ?>          <?php endwhile; ?>      ?> thanks


Putting my site live

Can anyone help? I've been building a wordpress site in a sub directory of an umbrella 'development domain' if you will, and am ready to go live with the site. It's a single install of wordpress. The wordpress file location is to remain exactly as it is, and we're just repointing the DNS of the live domain to the subdirectory of the development domain. I hope this makes sense so far. In my general > settings section of the admin, I've set the url to be http://s391121685.websitehome.co.uk/sb As that is the url my development domain has allocated to it. We didn't update the DNS settings of the REAL domain prior to now as there is an existing website already up. Bearing in mind that no wordpress files are going to be moved, can i just change the wordpress address and site address under settings to www.newlivesiteurl.com? Any advice would be appreciated. Thanks _**_UPDATE **** Ok so I've edited my config file with the details suggested below, but now when i try to log into my wordpress admin, I'm stuck in a continuous loop. It juts keeps redirecting me back to the login screen! Any help would be greatly appreciated....


Get current term in single.php

I have a custom post type (dibujos) and 4 custom taxonomy. I would like to get term name in a current post. The probleme is, how to To display the name of the taxonomy, no matter what taxonomy is. The code is:               <?php   // Get terms for post      $terms = get_the_terms( $post->ID , 'my-taxonomy' );      // Loop over each item since it's an array      if ( $terms != null ){      foreach( $terms as $term ) {      // Print the name method from $term which is an OBJECT      print $term->name ;      // Get rid of the other data stored in the object, since it's not needed      unset($term);     } } ?>      Thks!


Taxonomy archive page have no post

I have a taxonomy with posts assigned to terms, and on the term archive page i get no found post               $rewrite = array(         'slug'                       => 'mytax',         'with_front'                 => true,         'hierarchical'               => false,     );     $args = array(         'labels'                     => $labels,         'hierarchical'               => true,         'public'                     => true,         'show_ui'                    => true,         'show_admin_column'          => true,         'show_in_nav_menus'          => true,         'show_tagcloud'              => true,         'rewrite'                    => $rewrite,      and in my post list in admin, i get the same error when i filter by terms by clicking on the term in the post list i have no error, how i can proceed ? thanks in advanced **EDIT** i try to run the wp_query request ( `wp_query->request` ) in MySQL and it's returned the correct posts, but the `wp_query->posts` is empty **EDIT 2** i try to add a new taxonomy , add a term to this taxonomy and add a post with this taxonomy, but the taxonomy leave after update the post


event propagated to google calendar

i am using the default events widget. is there a way, that i could propagate any events created in wordpress to a google calendar? so any time a new event is created in wordpress, it should also be reflected in a google calendar. of course if the event is deleted it should be deleted on the google side as well. i have looked into some plugins, but i could not find anything appropriate. there are plugins, that work the other way around. thanks thoms


WP_Query Sorting Posts by month ... timeline effect

Hoping someone can take a look at my code and help me out. Right now I am trying to show my blog in a timeline style approach. My current query is generating the posts how I would like them to but I am not getting the HTML structure properly. Right now I have a `<div>` that contains a `<ul>` with post info. I would like the `<div>` to generate a unique `<ul>` for each post within that month instead of each time generating a new `<div>` for the post. So for example... if July 2014 has 3 blog posts I want the structure to be:

      Right now it generates as:

      Here is my template:

                  <?php                 $counter = 0;                 $ref_month = '';                 $monthly = new WP_Query(array(                     'posts_per_page' => -1                 ));                      if( $monthly->have_posts() ) : while( $monthly->have_posts() ) : $monthly->the_post();                      if( get_the_date('mY') != $ref_month ) {                     if( $ref_month );             ?>

<?php echo get_the_date('M Y'); ?>

                  <?php                 $ref_month = get_the_date('mY');                 $counter = 0;                 } if ($counter++ < 5) {             ?>                  <div class="timeline <?php echo strtolower(get_the_time('F-Y')); ?>">

                                          <?php if (has_post_thumbnail()) { ?>                                              <?php the_post_thumbnail( 'full' ); ?>                                          <?php } else { ?>                                                                                <?php } ?>

<a href="<?php the_permalink();?>"><?php the_title();?>
                                         By <?php the_author(); ?> | <?php the_time(get_option('date_format'));?>

<?php echo excerpt(25); ?>

                                         <a href="<?php the_permalink();?>" class="more"><?php echo __('Read More >')?>                                          <?php comments_number('0','1 comment','% comments')?>

                                      <?php } else { ?>                                      <?php } ?>

                  <?php endwhile; endif; ?>

<?php next_posts_link(__(' ')); ?>

<?php previous_posts_link(__(' ')) ?>

                  <?php wp_reset_query(); ?>

      Any help is appreciated, thank you!


How can I de-register ALL styles all at once? And same with Javascript?

How can I get all enqueued styles or scripts and then deregister them all at once?


How can I create a bash install script for my Wordpress sites setup (WP+plugins+theme)?

I build a lot of websites with Wordpress, and my initial setup is basically always the same :   * Latest version of WP   * Latest versions of about 5 plugins    * My naked development theme Instead of downloading/uploading these things separately and do that by hand each time I start a new project, I'd like to create a bash script that would do this :   * Download the latest version of Wordpress   * Unzip   * Download the latest version of plugin X   * Unzip to WP plugins folder   * Download my naked theme   * Unzip to themes folder Now downloading the latest WP is easy (http://wordpress.org/latest.tar.gz), downloading my naked theme too, but I'm having trouble getting the latest version of a plugin, as they are not called `latest.tar.gz` but specifict names with the version (ex: wptouch.1.9.26.zip) EDIT : So I'm wonderning now if it's possible to use cURL in my bash script to find the exact URL of the Current version of a plugin. The idea would be to fetch the page, and then find the value of the `href` that is in the paragraph just after the `<h3>Current Version</h3>`. Here's an example, all plugin download pages on WP are like this :
Current Version

         1.1.2


Adding meta_key via pre_get_posts causes navigation to disappear

I'm writing a custom function that allows the posts to be sorted based on a custom field. When the user submits the "sort by" form, the meta_key (as well as orderby and order) parameters by which the posts should be sorted is stored in a $_SESSION variable. I'm using the pre_get_posts action to hook into my function. The function checks that the $_SESSION variable exists and attempts to set the appropriate values as needed               add_action('pre_get_posts', 'ml_order_properties');     function ml_order_properties($query) {              //ml_is_property() function simply returns true/false         //if this is a property listing related page/archive/post              if ( ml_is_property() && is_main_query() ) {             //SET THE SORT ORDER             $query->query_vars['orderby'] = $_SESSION['ml_user']['orderby']['orderby']; //Like 'meta_value_num'             $query->query_vars['order'] = $_SESSION['ml_user']['orderby']['order']; //Like 'ASC'             $query->query_vars['meta_key'] = $_SESSION['ml_user']['orderby']['meta_key']; //Like 'property_price'                  //ENSURE OFF MARKET PROPERTIES ARE NOT DISPLAYED             $args = array(                 'taxonomy' => 'ml_property_status',                 'terms' => array(                     'off-market'                 ),                 'include_children' => true,                 'field' => 'slug',                 'operator' => 'NOT IN'             );                  //ALWAY ADD TO THE END OF THE EXISTING ARRAY             $tax_query = $query->tax_query->queries;             $tax_count = count($tax_query) == 1 ? 1 : count($tax_query)+1;             $tax_query[$tax_count] = $args;                  $query->set('tax_query', $tax_query);         }     }      The problem with this function is that it causes the primary WordPress navigation menu to stop appearing. No PHP errors are generated. Doing a dump of the $wp_query global variable outputs the following:               Object     (     |    query_vars => Array (60)     |    (     |    |    ['ml_property_type'] = String(5) "homes"     |    |    ['error'] = String(0) ""     |    |    ['m'] = Integer(1) 0     |    |    ['p'] = Integer(1) 0     |    |    ['post_parent'] = String(0) ""     |    |    ['subpost'] = String(0) ""     |    |    ['subpost_id'] = String(0) ""     |    |    ['attachment'] = String(0) ""     |    |    ['attachment_id'] = Integer(1) 0     |    |    ['name'] = String(0) ""     |    |    ['static'] = String(0) ""     |    |    ['pagename'] = String(0) ""     |    |    ['page_id'] = Integer(1) 0     |    |    ['second'] = String(0) ""     |    |    ['minute'] = String(0) ""     |    |    ['hour'] = String(0) ""     |    |    ['day'] = Integer(1) 0     |    |    ['monthnum'] = Integer(1) 0     |    |    ['year'] = Integer(1) 0     |    |    ['w'] = Integer(1) 0     |    |    ['category_name'] = String(0) ""     |    |    ['tag'] = String(0) ""     |    |    ['cat'] = String(0) ""     |    |    ['tag_id'] = String(0) ""     |    |    ['author_name'] = String(0) ""     |    |    ['feed'] = String(0) ""     |    |    ['tb'] = String(0) ""     |    |    ['paged'] = Integer(1) 0     |    |    ['comments_popup'] = String(0) ""     |    |    ['meta_key'] = String(14) "property_price"     |    |    ['meta_value'] = String(0) ""     |    |    ['preview'] = String(0) ""     |    |    ['s'] = String(0) ""     |    |    ['sentence'] = String(0) ""     |    |    ['fields'] = String(0) ""     |    |    ['category__in'] => Array (0)     |    |    (     |    |    )     |    |    ['category__not_in'] => Array (0)     |    |    (     |    |    )     |    |    ['category__and'] => Array (0)     |    |    (     |    |    )     |    |    ['post__in'] => Array (0)     |    |    (     |    |    )     |    |    ['post__not_in'] => Array (0)     |    |    (     |    |    )     |    |    ['tag__in'] => Array (0)     |    |    (     |    |    )     |    |    ['tag__not_in'] => Array (0)     |    |    (     |    |    )     |    |    ['tag__and'] => Array (0)     |    |    (     |    |    )     |    |    ['tag_slug__in'] => Array (0)     |    |    (     |    |    )     |    |    ['tag_slug__and'] => Array (0)     |    |    (     |    |    )     |    |    ['orderby'] = String(14) "meta_value_num"     |    |    ['order'] = String(3) "ASC"     |    |    ['tax_query'] => Array (2)     |    |    (     |    |    |    ['0'] => Array (5)     |    |    |    (     |    |    |    |    ['taxonomy'] = String(16) "ml_property_type"     |    |    |    |    ['terms'] => Array (1)     |    |    |    |    (     |    |    |    |    |    ['0'] = String(5) "homes"     |    |    |    |    )     |    |    |    |    ['include_children'] = Boolean(1) TRUE     |    |    |    |    ['field'] = String(4) "slug"     |    |    |    |    ['operator'] = String(2) "IN"     |    |    |    )     |    |    |    ['1'] => Array (5)     |    |    |    (     |    |    |    |    ['taxonomy'] = String(18) "ml_property_status"     |    |    |    |    ['terms'] => Array (1)     |    |    |    |    (     |    |    |    |    |    ['0'] = String(10) "off-market"     |    |    |    |    )     |    |    |    |    ['include_children'] = Boolean(1) TRUE     |    |    |    |    ['field'] = String(4) "slug"     |    |    |    |    ['operator'] = String(6) "NOT IN"     |    |    |    )     |    |    )     |    |    ['ignore_sticky_posts'] = Boolean(0) FALSE     |    |    ['suppress_filters'] = Boolean(0) FALSE     |    |    ['cache_results'] = Boolean(1) TRUE     |    |    ['update_post_term_cache'] = Boolean(1) TRUE     |    |    ['update_post_meta_cache'] = Boolean(1) TRUE     |    |    ['post_type'] = String(0) ""     |    |    ['posts_per_page'] = Integer(2) 10     |    |    ['nopaging'] = Boolean(0) FALSE     |    |    ['comments_per_page'] = String(2) "50"     |    |    ['no_found_rows'] = Boolean(0) FALSE     |    |    ['taxonomy'] = String(16) "ml_property_type"     |    |    ['term'] = String(5) "homes"     |    )     |    tax_query Object     |    (     |    |    queries => Array (3)     |    |    (     |    |    |    ['0'] => Array (5)     |    |    |    (     |    |    |    |    ['taxonomy'] = String(16) "ml_property_type"     |    |    |    |    ['terms'] => Array (1)     |    |    |    |    (     |    |    |    |    |    ['0'] = String(5) "homes"     |    |    |    |    )     |    |    |    |    ['include_children'] = Boolean(1) TRUE     |    |    |    |    ['field'] = String(4) "slug"     |    |    |    |    ['operator'] = String(2) "IN"     |    |    |    )     |    |    |    ['1'] => Array (5)     |    |    |    (     |    |    |    |    ['taxonomy'] = String(18) "ml_property_status"     |    |    |    |    ['terms'] => Array (1)     |    |    |    |    (     |    |    |    |    |    ['0'] = String(10) "off-market"     |    |    |    |    )     |    |    |    |    ['include_children'] = Boolean(1) TRUE     |    |    |    |    ['field'] = String(4) "slug"     |    |    |    |    ['operator'] = String(6) "NOT IN"     |    |    |    )     |    |    |    ['2'] => Array (5)     |    |    |    (     |    |    |    |    ['taxonomy'] = String(16) "ml_property_type"     |    |    |    |    ['terms'] => Array (1)     |    |    |    |    (     |    |    |    |    |    ['0'] = String(5) "homes"     |    |    |    |    )     |    |    |    |    ['include_children'] = Boolean(1) TRUE     |    |    |    |    ['field'] = String(4) "slug"     |    |    |    |    ['operator'] = String(2) "IN"     |    |    |    )     |    |    )     |    |    relation = String(3) "AND"     |    )     |    meta_query Object     |    (     |    |    queries => Array (1)     |    |    (     |    |    |    ['0'] => Array (1)     |    |    |    (     |    |    |    |    ['key'] = String(14) "property_price"     |    |    |    )     |    |    )     |    |    relation = String(3) "AND"     |    )     |    post_count = Integer(1) 4     |    current_post = Integer(2) -1     |    in_the_loop = Boolean(0) FALSE     |    comment_count = Integer(1) 0     |    current_comment = Integer(2) -1     |    found_posts = String(1) "4"     |    max_num_pages = Float(1) 1     |    max_num_comment_pages = Integer(1) 0     |    is_single = Boolean(0) FALSE     |    is_preview = Boolean(0) FALSE     |    is_page = Boolean(0) FALSE     |    is_archive = Boolean(1) TRUE     |    is_date = Boolean(0) FALSE     |    is_year = Boolean(0) FALSE     |    is_month = Boolean(0) FALSE     |    is_day = Boolean(0) FALSE     |    is_time = Boolean(0) FALSE     |    is_author = Boolean(0) FALSE     |    is_category = Boolean(0) FALSE     |    is_tag = Boolean(0) FALSE     |    is_tax = Boolean(1) TRUE     |    is_search = Boolean(0) FALSE     |    is_feed = Boolean(0) FALSE     |    is_comment_feed = Boolean(0) FALSE     |    is_trackback = Boolean(0) FALSE     |    is_home = Boolean(0) FALSE     |    is_404 = Boolean(0) FALSE     |    is_comments_popup = Boolean(0) FALSE     |    is_paged = Boolean(0) FALSE     |    is_admin = Boolean(0) FALSE     |    is_attachment = Boolean(0) FALSE     |    is_singular = Boolean(0) FALSE     |    is_robots = Boolean(0) FALSE     |    is_posts_page = Boolean(0) FALSE     |    is_post_type_archive = Boolean(0) FALSE     |    query_vars_hash = String(32) "225f6b4c460d5ca9fc40d6cf79dcc662"     |    query_vars_changed = Boolean(1) TRUE     |    thumbnails_cached = Boolean(0) FALSE      My gut tells me that the issue may be related to this similar question, but I'm pretty much at a loss otherwise. The function also checks to ensure that the posts being displayed do not have the 'off-market' slug from the 'ml_property_status' taxonomy applied to them as those items should never be publicly shown. Commenting out the following line in the function makes everything display correctly (just no sorting)               $query->query_vars['meta_key'] = $_SESSION['ml_user']['orderby']['meta_key'];


Usage of  the new  "posts_clauses" filter in Wordpress 3.1?

Just noticed that 3.1 added a new filter to customize queries: posts_clauses. All I could find about it is that instead of using the separate query filters like posts_where or posts_join, you can edit them all in one go. I was wondering if someone could give an example of the usage of the new "posts_clauses" filter?


How to apply different themes with custom design in one site?

I am quite a beginner in learning and developing WordPress based website as my client needs a custom-made CMS magazine site which he could easily update the site on his own with his limited computer knowledge. Well then, I started with purchasing a few different themes which I could continue to extensively modify the existing layouts. I have activated one of the theme as the main one (/wp- content/themes/Theme-A) but quite struggling on these issues following:   1. How to apply the 2nd theme (/wp-content/themes/Theme-B) on one specific page under the main theme (as it comes with a new whole set of theme B)? I am totally lost as each theme has its own index.php and the rest of their set files. I am not sure which approach would be the best in calling the different themes: adding functions under the main theme folder in order to redirect the other themes or any better approach? (By the way, try using "page-theme" plugin, it serves the purpose but seems having lots of files conflict between the themes, not my final solution after all.)   2. Without developing under WordPress framework, creating a new page from scratch is not as difficult to understand as in WordPress. For example, I create about-us.php then I could see the file under the directory straightaway and then hand coding it from there. But creating a page in WordPress with the permalink enabled, I couldn't find the physical file anywhere in the directory (apology for my limited knowledge, please correct me if I am wrong). Then not sure what to do next when: (1) I want to create the whole page with my own design under the main theme (2) Tweak/add/modify an existing theme as they include and get and etc. with the other dependent files, takes a lot of time to track them down to the root file.


Use search in fancybox

I'm trying to use FancyBox to open a lightbox-style popup with the `searchform.php`, when the user clicks on the search icon. ## **The setup:**   * in `header.php` I have a link element which will show only the search icon;    * in `script.js` I bind the click on the search icon to fancybox and I open the modal/lightbox `iframe` with the content of `searchform.php`; **The problem:** the `iframe` doesn't load the WordPress environment so nothing is working. How can I use fancybox and still have access to the WP functions? The next step will be to show the results of the search in the same `iframe` using AJAX. **The code:**               // header.php     <a id="search-label" data-fancybox-type="iframe" href="<?php echo get_template_directory_uri(); ?>/searchform.php">          // searchform.php

This is a test
         <form action="<?php echo home_url( '/' ); ?>" method="get">             <fieldset>                 <input type="text" class="notv" id="search" name="s" value="<?php the_search_query(); ?>" />             </fieldset>         </form>
            // script.js     jQuery(document).ready(function($) {              $("#search-label").click(function () {                 $('.search-container').toggle();                 $('#search-label').fancybox({                     maxWidth    : 800,                     maxHeight   : 600,                     fitToView   : false,                     width       : '70%',                     height      : '70%',                     autoSize    : false,                     closeClick  : false,                     openEffect  : 'none',                     closeEffect : 'none'                 })             })         });


Using update_option() and get_option() is echoing escaped strings

I'm using the Option API for my theme settings page. I use the $_POST data to update the options when the changes are saved. My issue is that the strings I send get escaped and when I use this code:               <?php echo get_option('myOption'); ?>      it echoes the escaped string. So for example, say 'myOption' = Bob's Diner Using the above statement, it echoes Bob\'s Diner, which is definitely not what I want. How exactly do I go about removing that backslash when I call the option on the site?


how to create several url aliases for a page

on the root page of a WordPress site we have a custom page template, that also handles some forms and dynamically changes part of the content. Something like this:               <form action="" method="post">     ...     <input type="hidden" name="action" id="action" value="do_this" />     </form>      and then in the page template we check for $_POST['action']=="do_this". Works perfectly. Now we would like that when these forms are posted to have the url change (action="/do_this"). For that to work, we need /do_this to deliver the root page, but the url to not change. we have tried this in .htaccess               RewriteRule ^do_this(.*)$ index.php?p=12 [L]      but it changes the browser url. It must have something with WordPress, since if we use another file RewriteRule ^do_this(.*)$ test.html [L] it works: the url is not changed and the test.html is being delivered. Thanks.


Using WP_Query to Query Multiple Categories with Limited Posts Per Category?

I have 3 categories with each 15 posts, I want to do ONE query to the db bringing only 5 first posts for each category, how can I do it?               $q = new WP_Query(array( 'post__in' => array(2,4,8), 'posts_per_page' => **FIRST_5_OF_EACH_CAT** ));      In case its not possible, what is more efficient, getting all the posts for the parent category and looping through them or creating 3 different queries?


Post selector as Custom Field

I would like to add a custom field for user to select a existing post or page to a post. (eg as related post, or as similar post...) a way that the user can browse trough exisisting and published posts and then select 1, via post editing screen, just like the "LINK FROM EXISTING CONTENT" tool at the TinyMCE


Custom post types with categories in template

I´d like to do something like this: Pages:   1. Sport   2. Business   3. Normal  Custom Category "Car-Types":   1. Audi   2. BMW   3. VW  My custom post type will called "Cars" I´d like to show the cars by using a custom category like "Car-Type".   How can I filter the content from the custom categories, too and show it? E. G.: On Page "Sport" should just show the content from "BMW".               <?php $args = array( 'post_type' => 'cars' ); // How can I add a category-filter to this?          $loop = new WP_Query( $args );     while ( $loop->have_posts() ) : $loop->the_post();         echo '
';         the_title('
', '
');         the_content();         echo '
';     endwhile; ?>      Thanks


Get the attachment URL on single.php

i've been trying to get the attachment URL on single.php, so far this code gets the DIRECT LINK to the image;               <?php          if ( $attachments = get_children( array(     'post_type' => 'attachment',     'post_mime_type'=>'image',     'numberposts' => 1,     'post_status' => null,     'post_parent' => $post->ID     )));     foreach ($attachments as $attachment) {     echo 'ID ) . '">Download Full Size';     }          ?>      but instead i want the attachment URL, PLEASE HELP!


Get a different size of Image thumbnail While working with custom metabox

I am using custom metabox for a page in my new project, I am using it for uploading image, and attaching it to the page. It's working fine, I can select image or upload the image using WordPress' native uploader, and attach it. The issue is that I am getting the large size image only. What happens is I have to resize it by specifying it's width and height. Is there any way to get the other sizes of the uploaded or selected images via wordpress native uploader. I know I can get the thumbnails by using `wp_get_attachment_image_src` function, but in order to work with this function I have to get attachment_id, I don't have it. What I have is only image url. I don't know whether I am missing it somewhere or not.


home_url on IIS missing permalink index.php

I'm using IIS without any URL re-writing that include an index.php at the end. The custom permalink structure is: `/index.php/%year%/%monthnum%/%postname%/` The problem is that the home_url function doesn't include the index.php, so if I want to refer to a custom page `<?php echo home_url() . '/my-page/'; ?>` returns http://domain.com/my-page/ but what I need is http://domain.com/index.php/my-page/ . Is there a WordPress function that will include the index.php or do I have to put in a custom bit of code? N.B. I've tried Googling, but most links point to re-writing the URL which is **not** what I want.


How do plugins get executed automatically from wp-content?

Most plugins that are installed into /wp-content/plugins need to be activated. However, it seems that if you drop scripts directly into /wp-content (object- cache.php comes to mind) they are activated automatically. How is this?


How do I accesss gravatar?

In the administration under Your Profile, which is where I suspect it would be, I can't find anything relating to gravatar


Exclude parent categories from the_category() within the loop

I have typical parent and child categories setup as follows:   * Food      * potatoes     * corn     * beats   * Sports      * soccer     * football     * hockey etc. In my index.php template I'd like to list the categories of the specific post. The problem is, when I use the_category() it lists the parent categories twice. I'm using the following code:               <php echo '<dt>', the_category(', ', 'multiple'), '</dt>', "\n"; ?>      And it prints out: `Food:corn, Food, Food:potatoes` I believe it is listing the child category "corn" as "Food: corn" followed by the parent category "Food" just as "Food." Is there a way to exclude the parent categories? The way I'd like it to read is: `Food:corn, Food:potatoes` Thank you.


Tags as autocomplete values

How can I load regular post tags as values for autocomplete field? What I have now is pretermined values like this:               var data = {items: [     {value: "1", name: "Siemens"},     {value: "2", name: "Phillips"},     {value: "3", name: "Whirlpool"},     {value: "4", name: "LG"}     };     $("#input_1_3").autoSuggest(data.items, {selectedItemProp: "name", searchObjProps: "name"});      I'm using Drew Wilson's Autocomplete plugin found at: http://code.drewwilson.com/entry/autosuggest-jquery-plugin. Any help would be most apreciated.


Wordpress JSON API restrict to specific domain

I have installed and activated the Wordpress JSON API (http://wordpress.org/plugins/json-api) in my self hosted WP site. Now my site content is open to the world via this API in JSON format. But, I want to restrict the access of this JSON API only to the requests that are coming from specific domain. Even though someone got to know that my site has JSON API enabled and the URL endpoint, they should see 'Access Denied' except the requests comes from a specific allowd domain. How to implement this restriction in WP? Thanks in advance.


How to end this loop properly?

I´m using several similar loops to loop in content from different categories into different containers. If there are no posts in category X then it shouldnt open any container at all. Same with all loops. I´ve done this before, I open the container after "have posts" and put the divs belonging to each posts after "the post". But this loop ends differently from what I´m used to, so I dont know where to end my container divs. http://pastebin.com/BcVEse5v How can I end the #wrapper-extra and .thumbnails properly?


old permalinks not found

Looking through Google Webmaster Tools, I have a lot of 404s for posts with permalink structure of /%year%/%month%/%day%/%postname%/ I have since changed permalinks to /%category%/%postname%.html I thought Wordpress could redirect old post URLs to new post URLS, but the old date based URLs are generating 404s. My .htaccess file is writable, set to 644. Why is this occurring? Thanks!


add_meta_box: Datepicker like the one for postdate?

I've built a custom post type called "Events". Each event has a future date and I don't want to use the normal `postdate` of the post. I want to use `add_meta_box` to add some inputs for this "event-date". Do you have any idea how I could use the probably same date-picker as there is right now for the `postdate` in a meta_box? Thank you in advance. matt update:               add_action("admin_init", "admin_init");          function admin_init(){         add_meta_box("event-date-meta", "Event Date", "event_date", "wr_event", "side", "low");     }               function year_completed(){         global $post;         $custom = get_post_custom($post->ID);         //…         ?>         Event-Date:
<?php touch_time(($action == 'edit'),1,4); ?>
         <?php     }


Adding popular posts by category in single posts?

I have been trying out several popular posts plugin but I can't seem to find the right one. I have a page where I want to insert popular posts (in between the textual content). I am looking for a plugin that can grab popular posts from categories and supports shortcode (as I want to insert popular posts only in a handful of pages). Any help is highly appreciated. Edit: The page doesn't contain any sidebar, so I can only display posts within the content area.


Pass data from wordpress to javascript in JSON

Currently using this simplified code to pass data from WP to JS.               function add_map_data() {                  $objName = "MapData";             $array = array(                 "MapViewLatitude" => "51.505",                 "MapViewLongitude" => "-0.09",                  );                  wp_enqueue_script( 'mapdata', get_bloginfo('template_url').'/custom/map.js', null, null, false );             wp_localize_script( 'mapdata', $objName, $array );     }     add_action( 'wp_enqueue_scripts', 'add_map_data');      The only issue is that this is passing object.   **How can I pass data in JSON format?**      Any suggestion much appreciated.


Redirecting home to /wp-login.php?action=register

As I'm currently using WordPress only as a registration platform for GlotPress I was wondering if it would be possible to somehow redirect users visiting `http://translate.mydomain.tld/account/` to `http://translate.mydomain./account/wp-login.php?action=register`? `http://translate.mydomain.tld/account/` being my WordPress installation folder (and `http://translate.mydomain.tld/` being my GlotPress installation folder)


Featured Posts Code - Repeated featured posts

I am soooo close to getting this to work but I have one outstanding issues.   1. The featured posts code keeps repeating itself before/after each post. Any help would be greatly appreciated. The code below is what is currently in my loop. **NEW CODE per CHIP**               <?php     // Define featured posts query     $featured_query = new WP_Query( array(     'posts_per_page' => 3,      'category_name' => 'featured'     ) );     // Open featured posts loop     if ( $featured_query->have_posts() ) :          while ( $featured_query->have_posts() ) : $featured_query->the_post();              // Featured posts loop markup goes here         ?>         <div class="featureportfolio<?php echo $i++;?>">                  <a href="<?php the_permalink() ?>" rel="bookmark" class="title">     <?php the_post_thumbnail('thumbnail'); ?>
            <a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php the_title(); ?>

         <?php          // Close featured posts loop     endwhile;     endif;          // Clear/spacer DIV     ?>

      This "works" minus the fact that ONLY featured posts show on the main page now.


Sanitation needed for WP_Query or get_posts calls?

Just wanted to get a straight answer on this: when submitting query_vars to a call to get_posts or WP_Query, is sanitation needed or does WordPress already take care of that?


How to use JQuery Marquee in Wordpress?

I'm using `<marquee>` in my homepage , I want to use jquery marquee instead , I've added script in my header , in usage it says i have to use "$('marquee').marquee(optionalClass);" , how and where i have to use it ?