How to use `wp_insert_user` & `wp_insert_post` simultaneously without `headers already sent` error?

I'm creating a front end posting form using `wp_insert_post` that asks a user for three basic fields: their first and last name and their email address. If the user is logged in I pre-populate the text fields and ignore them when submitting a form. If however the user is not logged in, my function checks to see if the email entered is registered. If it is, the function grabs the associated user_id and assigns that user as the post_author. If the email is not associated, a new user is created via `wp_insert_user`. The form is returning this error:               Warning: mysql_real_escape_string() expects parameter 1 to be string, object given in /home/wp-includes/wp-db.php on line 885          Warning: mysql_real_escape_string() expects parameter 1 to be string, object given in /home/wp-includes/wp-db.php on line 885          Warning: Cannot modify header information - headers already sent by (output started at /home/wp-includes/wp-db.php:885) in /home/wp-includes/pluggable.php on line 876      What am I missing?               if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {              // $tags = $_POST['post_tags'];         $first_name = $_POST['first_name'];         $last_name = $_POST['last_name'];         $author_email = $_POST['author_email'];              $business_name = $_POST['business_name'];         $business_city = $_POST['business_city'];         $business_state = $_POST['business_state'];         $methodgroup = $_POST['methodgroup'];              if ( ! is_user_logged_in() ) {             if ( email_exists( $author_email ) ) {                 // email has an account                 require_once(ABSPATH . WPINC . '/ms-functions.php');                 $userid = get_user_id_from_string( $author_email );             }             else {                 // create an account                 $user_id = wp_insert_user(                      array (                         'first_name' => $first_name,                         'last_name' => $last_name,                         'user_email' => $author_email,                         'user_login' => $author_email,                     )                 ) ;                 wp_set_password($last_name, $user_id);             }         }         else {             $user_id = get_current_user_id();         }              // ADD THE FORM INPUT TO $new_post ARRAY         $new_post = array(             'post_title'    =>  'Project',             'post_status'   =>  'draft',             'post_type'     =>  'project',             'post_author'   =>  $user_id,             'business_name' =>  $business_name,             'business_city' =>  $business_city,             'business_state' => $business_state,             'methodgroup'   =>  $methodgroup,              //  Other options            //  'ID'             => [ <post id> ] //Are you updating an existing post?         //  'menu_order'     => [ <order> ] //If new post is a page, it sets the order in which it should appear in the tabs.         //  'comment_status' => [ 'closed' | 'open' ] // 'closed' means no comments.         //  'ping_status'    => [ 'closed' | 'open' ] // 'closed' means pingbacks or trackbacks turned off         //  'pinged'         => [ ? ] //?         //  'post_author'    => [ <user ID> ] //The user ID number of the author.         //  'post_content'   => $description,         //  'post_date'      => [ Y-m-d H:i:s ] //The time post was made.         //  'post_date_gmt'  => [ Y-m-d H:i:s ] //The time post was made, in GMT.         //  'post_excerpt'   => [ <an excerpt> ] //For all your post excerpt needs.         //  'post_name'      => [ <the name> ] // The name (slug) for your post         //  'post_parent'    => [ <post ID> ] //Sets the parent of the new post.         //  'post_password'  => [ ? ] //password for post?         //  'post_status'    => [ 'draft' | 'publish' | 'pending'| 'future' | 'private' | custom registered status ]         //  'post_type'      => [ 'post' | 'page' | 'link' | 'nav_menu_item' | custom post type ]         //  'tags_input'     => array($tags),         //  'tax_input'      => [ array( 'taxonomy_name' => array( 'term', 'term2', 'term3' ) ) ] // support for custom taxonomies.          );              //SAVE THE POST         $pid = wp_insert_post($new_post, true);              //KEEPS OUR COMMA SEPARATED TAGS AS INDIVIDUAL         // wp_set_post_tags($pid, $_POST['post_tags']);              //REDIRECT TO THE NEW POST ON SAVE         $link = get_permalink( $pid );         wp_redirect( $link );              //ADD OUR CUSTOM FIELDS          add_post_meta($pid, '_trade_name', $business_name, true);          add_post_meta($pid, '_location_1_city', $business_city, true);          add_post_meta($pid, '_location_1_state', $business_state, true);          add_post_meta($pid, '_method', $methodgroup, true);               /*         //INSERT OUR MEDIA ATTACHMENTS         if ($_FILES) {             foreach ($_FILES as $file => $array) {             $newupload = insert_attachment($file,$pid);             // $newupload returns the attachment id of the file that             // was just uploaded. Do whatever you want with that now.             }         } // END THE IF STATEMENT FOR FILES         */          } // END THE IF STATEMENT THAT STARTED THE WHOLE FORM          //POST THE POST YO     do_action('wp_insert_post', 'wp_insert_post');      The form follows the VoodooPress model. Edit: Would using the WP_User class make a difference? That's a little over my programming head but I could find someone to do it if that would be a better fix.


Can I set up Wordpress Multisite where one of the subdomains has ssl?

I would like to install wordpress multisite on a live server and have one of the sub-domains be https. The main site is not https and neither are the other sub-domains. Is that possible? Thanks!


how do I use the walker class to display categories in their correct heirarchy?

One would think that returning categories using wordpress functions would automatically display them in their heirarchy? Ive noticed that categories dont necessarily do this, so I am trying to find a way to make sure they are returned correctly.


Multiple Permalinks per Media Library Image

I'm importing a CSV file for Woocommerce Products, a number of products link to the same (already uploaded) image file. They link fine, however in the Media Library I now have multiple versions of the same image being created each with a different Permalink. I know the Permalink has to be saved, but is there a way of having them all saved in the same image file in the Media Library?


How to get the "stats" plugin that comes with a .wordpress.com blog?

On the free version of wordpress, ie the one you setup for free and get hosted at "myblog.wordpress.com", it has a very nice module on the dashboard for tracking statistics. It displays a nice hit-counter graph and shows search engine terms used etc, without any clutter Is it possible to get this for a self hosted install of wordpress? I can't see it installed by default


Search and replace text across all posts

I had used the ZD Video Plugin for WP a long time, and now, since my move to WP 3.0.2, it doesn't work anymore. To embed a YouTube video using the plugin, I would just write > [zdvideo]url-of-youtube-video[/zdvideo] Now I need to go back to plain YouTube embedding. How do I write a MySQL query that searches for `[zdvideo]*[zdvideo]` and replaces it with `*`?


Custom post type content using custom fields without template

When I first heard about custom post types I thought it would solve an old "problem" I have, so I was thrilled.   But when I tried to setup something I couldn't achieve what I want.   So I'd like to know if I'm using WP tools correctly, or if there is a plugin (or a combination of plugins) that would do what I want. **Context** :   On my blog I have several categories that contains "copy pasted posts", which are posts that have a static structure and where only a few information change (a category = a specific post "format"). So to create it, I copy/paste an old one and replace a few things (some urls, titles...). **There are a dozen of these**.   I use a site template found on WP.com, but heavily modified **and single.php has a lot of content** that I don't want to copy/paste to other files. **Problem** :   I tried to use a plugin to manage custom post types. The idea was to define a post type for each category. I think this is the intended use, but my problem is that **I don't want to duplicate the single.php** because any modification of my template would imply that I have to edit a dozen of files and all of my "custom types" are all almost the same as "normal" posts, it's only their content that is fixed. And it also implies to edit other files : search results, listings...   Moreover **I see some possible issues** here : as the post titles are not defined and are dependant on the custom fields content, I'm afraid that the search may not work on them (I didn't try it though).   Moreover I prefer to be able to define the post content template as "WP admin" (through UI) instead of "WP developer" (through file editing & FTP). **What I would ideally want** :   So I imagined another solution, but I don't know how feasible it is :   I'd like the mix of two plugins : "Ultimate Post Type Manager" and "Simple post template" (this plugin allows to define a default post content. It adds a button on the "new post" page which, when clicked, fills the post body with a predefined content). I'd like, when I create a custom post type to **define a default post body (and title).** (as it is possible with "Simple post template" but this plugin only allows the creation of **one** global post template only).   As we can define custom fields, I'd like to be able to put fields replacement tokens in that content template.   The result would be that when I click on "Add new [my type]" for my custom post type, I don't see a title or body field, but **only my custom fields**.   When I click on publish, it would fill the title and body with the content defined with the tokens replaced by the value entered in the fields and save it to the database. In short, it would create the **post layout** from some data entered in a form **before** writing it in the database while the common use is to set the layout at "display time", a kind of "creation-side" template (versus a "display-side"). I know this is quite agains the "less display instructions in DB, more in template", but I prefer this way in my situation. I'm I thinking it in a wrong way (You have the right to say that it is a total nonsense !) ? Is there already something that would allow me do to that ?   What would be my best solution to get something similar ?   After some thinking, I'm not sure using custom post types is a good idea here... _**Updated** :   Rephrased, edited layout, added details & links._


Strategy to get post meta for use outside the loop

I need to know solutions for the question above. There are cases, when we need post meta information outside the loop. Let's say, I'm developing theme that will display ads from certain vendor on that page (everywhere on that particular page) based on post meta information. Because, I've bilingual blog and I will use different vendor for each language (for CTR reason). So, do you guys have a solutions for this kind of problem?


Which tabs widget plugin for wordpress is better?

I see there are a lot of plugins to create tabbed widget in side-bar:   1. Fun with tabs   2. Post 2 tabs   3. Hybrid Tabs   4. Wordpress Tabs Slides   5. AmR Tab Menu Navigation   6. Tabbed Widgets Which one is the best in configuration, speed and code-optimized? If any other plugin, please let me know.


Unable to call specific dynamic_sidebar

I've created a sidebar called "Mountain". I can add it through the Wordpress back-end except for on the Taxonomy page. There I wanted to hard code it by replacing:               <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('post-widgets')) : else : ?>     <?php endif;?>      with               <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Mountain')) : else : ?>     <?php endif; ?>      or               <?php get_sidebar("Mountain");?>      Not sure why, but this is leaving the old sidebar in place and adding the "Mountain" sidebar at the bottom of my content.


Membership Plugin with Facebook integration

Any suggestions on a Plugin for Wordpress that can allow People to register and sign up for the site through a form as well as through facebook? Been searching around really only found one or the other.


JS behavior differs depending on page tree

I'm a developer for a very large real estate plugin and I'm having a lot of trouble with one of our agent sites: The init methods used to initialize ajax functionality are called using a `jQuery(document).ready()` handler. However, this doesn't always fire, and it seems to be less dependent on the page contents than the location in the sitemap. The theme script also uses the same jQuery ready script to run methods, and that works on all pages. This file is included in the header. My file is included in the footer, that jQuery ready script does not load on certain pages. The site is http://mportlandrealestate.com/. The scripts seem to load on every page but those underneath the Areas and Neighborhoods top level page. Also, Areas and Neighborhoods -> Inner NE and its subpages DO work, but all others do not. If I move a page from the Inner SE tree to be a child of Inner NE it begins to work, with no content changes. You can tell the scripts are loading through some console.group statements output in the javascript console: lightbox::init, clipboards::init, and ajax::init should all be present if the footer scripts are initializing. Any ideas? This is baffling me.


Wordpress set taxonomy on post?

hello this is my code to select taxonomy for post by post id. this is my code and this code is doesn't work please help.               wp_set_post_terms( '2653', array('Bus'), 'category_type_bus');      this is my code when i run that code.and then after checked in backend. the Bus is not selected please tell where i am wrong. thank you.


Wordpress blog code format

I am new to wordpress and I just created a new blog(free version). Now It seems that code fromat doesn't work. All lines are aligned to the left. Please look at the image below. ![image](http://i.stack.imgur.com/7POZI.png) Thanks.


Will WordPress username displayed somewhere in the site?

I am considering enforcing all my users to use `email` as their login name. But I am afraid that the username is being used somewhere that is publicly accessible, e.g. author pages, such as that it will lead to the problem of privacy or SPAM. Is my worry valid? It is a good practice to use email as WordPress username? (ignore the fact that user might change their email..)


How to combine multiple sites to Wordpress MU

I have multiple well-established Wordpress sites. I am considering combining them into one Wordpress MU site. I have found that a few of the sites probably do not get as much of my attention as they should. I think this may simply be because they are "out of sight, out of mind." I believe with all sites in one dashboard, they will get much more attention. Is this the way to go? What is the best method to combine the sites? I haven't been able to find a tutorial or really too much information.


Load Javascript from Plugin in One Page Only?

I use the ALO EasyMail Newsletter.   But the plugin is loading lots of Javascript in the head. I have a mobile site and the scripts are loading in all the pages. I think this affects the mobile performance and want to load it only on the newsletter pages. How can i do that and load it only in the `/nieuwsbrief` page? The php starts with:               <script type="text/javascript">     //<![CDATA[     <?php if ( is_user_logged_in() ) { // if logged in ?>


Conditionally add apt. Open Graph meta data to different pages on WordPress site

The **officialFacebook plugin** does an excellent job of adding appropriate Open Graph meta tags to different pages (Home, Posts, Pages, Archives, etc.) of a WordPress site. The problem is it does many things without my permission. Is there a way to get the functions responsible for adding Open Graph meta data from the plugin, so that I can add them to my theme's functions.php?


Missing image sizes

I have Wordpress 3.5.2 installed. GD is enabled and working. The theme supports post-thumbnails. When I go to upload an image, the system doesn't create the default thumbnail and intermediate sizes. There are no errors given. When I go to insert an image into a post - it only has the Full size showing. Any clues? What else can I look for? Thanks!


Display gallery on bottom after content

How to execute the gallery shortcode after any other content no matter where the shortcode is in the post HTML? Thanks.


How to insert data to a database table when the field is not yet created?

Supposing I have an existing table(already created in dB) that handles user- registration (a plugin) and insert data using the $wpdB->insert like this:                       $success = $wpdb->insert(                 $wpdb->mytable,                 array(             'first_name' => $first_name,             'last_name' => $last_name,             'email' => $email,             'activation_key' => $activation_key,                 ), array('%s', '%s', '%s', '%s')         );      Now my problem is I want to add another field to my existing table in dB. This field should have also have its own data. What would be the best practice to handle this type of situation? Do $wpdB->insert class creates a column automatically if its not there in the dB? For example, supposing I would like to add a hobby field name in the insert:                       $success = $wpdb->insert(                 $wpdb->mytable,                 array(             'first_name' => $first_name,             'last_name' => $last_name,             'email' => $email,             'hobby' => $hobby,                         'activation_key' => $activation_key,                 ), array('%s', '%s', '%s', '%s')         );      Would the "hobby" data be automatically inserted to the dB with a new column? If not, what would be the simplest and recommended method in doing this? Thanks for any help.


Contributing to the community

I have recently found myself with some time on my hands and with no problem of my own, I would like to solve someone's problem. I'd like to contribute to the WP community how best would I be able to do this? I would like to contribute in way of code. I can take a suggestion of a modules/features I could pick one, maybe the one with the most up votes.


Where did the screen options menu go?

Where did the screen options menu go? I can't seem to find it anywhere in the new "improved" admin interface. Screenshots from the dashboard page: ![enter image description here](http://i.stack.imgur.com/OUXug.png) ![enter image description here](http://i.stack.imgur.com/fmqgI.png)


Notice: attribute_escape is deprecated

I have WP_DEBUG set to ON to show errors and notices. Of all notices the one that is bothering me is `Notice: attribute_escape is deprecated since version 2.8! Use esc_attr() instead. in /Users/john/Documents/htdocs/wp- includes/functions.php on line 3467`. I started commenting the code to find which function or statement was generating these notices. To my surprise these notices were thrown by `wp_head()`, `echo get_the_title()` — The core Wordpress functions. I switched the theme to twentyeleven where the problem does not appear at all. So, I'd like to find out why these core functions are throwing notices in my theme and what can I do to debug, isolate and resolve these? Regards, John


Wordpress Varnish Age=0 or Not Caching (Cookies?)

I'm using Wordpress `3.8.1` and Varnish `3.0.5`. I'm sure the Varnish is not caching, because of the VCL nightmare. And i also don't know where is the very standard / correct VCL for Wordpress. My Wordpress is **Multisite** , and i'm putting Varnish just on the top of the box, of Wordpress VM itself. `Varnish @ 8080` and `Apache @ 80/443`. Since i don't know anything about VCL, i just used a random VCL i found:               backend default {         .host = "127.0.0.1";         .port = "8080";         .connect_timeout = 60s;         .first_byte_timeout = 60s;         .between_bytes_timeout = 60s;     }          sub vcl_recv {         if (req.restarts == 0) {             if (req.http.x-forwarded-for) {                 set req.http.X-Forwarded-For =                 req.http.X-Forwarded-For + ", " + client.ip;             } else {                 set req.http.X-Forwarded-For = client.ip;             }         }         if (req.request == "PURGE") {             if ( client.ip != "xx.xx.xx.xx") {                 error 405 "Not allowed.";             }             return (lookup);         }         if (req.request != "GET" &&             req.request != "HEAD" &&             req.request != "PUT" &&              req.request != "POST" &&             req.request != "TRACE" &&             req.request != "OPTIONS" &&             req.request != "DELETE") {                 return (pipe);         }         if (req.request != "GET" && req.request != "HEAD") {             return (pass);         }         if (!(req.url ~ "wp-(login|admin)") &&             !(req.url ~ "&preview=true" ) ) {             unset req.http.cookie;         }              if (req.http.Authorization || req.http.Cookie) {             return (pass);         }         return (lookup);     }          sub vcl_hit {         if (req.request == "PURGE") {             purge;             error 200 "Purged.";         }         return (deliver);     }          sub vcl_miss {         if (req.request == "PURGE") {             purge;             error 200 "Purged.";         }         return (fetch);     }          sub vcl_fetch {         if (!(req.url ~ "wp-(login|admin)")) {             unset beresp.http.set-cookie;             set beresp.ttl = 96h;         }              if (beresp.ttl <= 0s ||             beresp.http.Set-Cookie ||             beresp.http.Vary == "*") {                 set beresp.ttl = 120 s;                 return (hit_for_pass);         }         return (deliver);     }      _(and i used my ip for 'xx.xx.xx.xx')_ But anyway, this is NOT working by means of always getting `age : 0`. I've known the VCL has to handle the Wordpress COOKIES and other COOKIES, like G.A, etc. How to do it, or where can i find the standard/correct VCL for Wordpress, please?


Display child pages on a parent and child page using Featured Thumbnails

How would I display a list of my child pages using featured images on a its parent page as well as its other siblings child page? For example, if my parent page is called 'Music', I'll have my main content with child pages thumbnails at the bottom. I'd like to have thumbnails with permalinks to other child pages from within the parent Music page displayed across all of the child music pages. Is this possible? Thanks


save_post action not firing when save

Below is my code that will take the post_id and randomly get 3 posts from the same category and store them as custom field. The code is clearly working, because when I click "New Post", I see the custom field being populated, but when I clicked "Publish" or "Save", the code below didn't get executed, from what I understand, Save_Post will be called once when creating new post and one more time when you actually save the post. Funny thing is that the code below works in Local server, WAMP, but not on my production server, I don't know why. They all use the same plugins.               function update_postmeta($post_id) {     global $post;          if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {         return;     }          unset($rand_id);          $cat_id = get_the_category($post_id);          $args = array(     'showposts' => 3,       'orderby' => 'rand',       'cat' => $cat_id[0]->cat_ID,       );        $my_query = new WP_Query($args);       while ($my_query->have_posts()) : $my_query->the_post();         $rand_id = $rand_id.get_the_ID().',';       endwhile; update_post_meta($post_id, 'related_id',$rand_id);       }          add_action('save_post', 'update_postmeta');


Get custom taxonomy term url on archive page

This is driving me crazy, so please help me guys with this. I'm trying to add a metatag to custom taxonomy ter archive page header which contains the url of the term archive page of a custom taxonomy. How to get the URL of the archive page when there's neither specified term nor the taxonomy itself.


How Do I Merge Categories With phpMyAdmin

I tried the following phpMyAdmin query to merge my category 112747 into my category 112748: `UPDATE `wp_term_relationships` SET `term_taxonomy_id` = 112747 WHERE `term_taxonomy_id` = 112748;` It did not work. What errors does the query contain? wordpress 3.8.2 phpMyAdmin 4.18 MySQL 5.5.34-cll-lve A wordpress website of mine has nearly 300,000 posts, with most categories containing, at least, 5,000 posts. I want, among other things, to merge many of the categories, in an attempt to improve website speed and performance. I have tried using several different plugins to merge categories from within the wordpress dashboard, but it seems my ability to successfully use the plugins is being adversely affected by various mysql, cpu, and php automatic kill/limiting features of the shared hosting environment(cloudlinux) where my website is located; in other words, the tasks get "killed" before they complete, sometimes, "crashing" the entire website. I am aware that deleting a category, using the wordpress dashboard, moves that category's posts to the default category; so, I have even tried changing the default category to a category into which I want to merge "another" category and deleted the "another" category, but, apparently, the task still, eventually, gets "killed" or "times out". What, typically, has been occurring, when I attempt to merge categories, from the wordpress dashboard, using a plugin or by deleting a category, is that the "merge" only partially completes. For example, maybe 30 or 400 posts from a category do get merged, but, then, the task gets "killed" or "times out", sometimes generating an error in the wordpress dashboard, sometimes "crashing" the website, and sometimes doing both. Typically, if all posts do not get merged, I am able to, incrementally, repeat the task, using the wordpress dashboard, but this may take repeating the task many times, to get a category of 15,000 posts merged into another category. Moreover, if the website "crashes" on a particular "repeat", then, I must wait for the website to "recover" from the crash. So, considering the aforementioned problems I have encountered, while attempting to merge categories from within the wordpress dashboard, I felt it would be much more efficient and simple to just use phpMyAdmin to merge categories, etcetera. However, it seems as if the wordpress database structure has become much more complex. I thought I was able to use phpMyAdmin to do this kind of thing 5 years ago, or so, with much greater ease and simplicity. In this particular instance, I confirm "term taxonomy id's", etc., multiple times, before attempting the actual query; in order to avoid needless mistakes. Some of my forum posts, however, may show incorrect term taxonomy ids, because, in this particular instance, of the manner in which I have copy/pasted from a text file that lists all my failed attempts. Again, when I am actually attempting a query, however, I check such things as "term taxonomy id's" multiple times, before proceeding with the query.


How Can I Change The Tax Query For The Main Loop For Taxonomy Archives?

I am trying to change an argument in the tax query in the main WP_QUERY object for creating the archive view for my the archive of my hierarchical taxonomy. My goal is to change one of the arguments in the tax query while leaving the rest intact. I tried to get the current query, modify the tax_query array and then pass it to set.               add_action( 'pre_get_posts', 'slug_cpt_category_archives' );     function slug_cpt_category_archives( $query ) {         if ( is_tax( 'TAXONOMY NAME') )  {             $tax_query = $query->tax_query->queries;             $tax_query['include_children'] = 0;             $query->set( 'tax_query', $tax_query );         }          }      Not only did it not produce the desired effect, of not including child terms, when I add this action:               add_action( 'wp_head', 'preh' );     function preh( ) {         global $wp_query;              print_r( $wp_query->tax_query  );     }      I see that there are now two tax_queries and both have `[include_children] => 1`


How to change value in wp-include/taxonomy.php without exchanging the Wordpress-core

I had the problem that tags of private posts didn't show up in a widget tag- cloud even if the user is logged in. The reason seems to be the value of "post_status" in the function `_update_post_term_count` in wp- include/taxonomy.php. At least when I change this value to "private" private tags are displayd. My question is: how can I change this value without editing taxonomy.php, thus the core? This is the altered function (changes in > ****...**** ):               function _update_post_term_count( $terms, $taxonomy ) {         global $wpdb;              $object_types = (array) $taxonomy->object_type;              foreach ( $object_types as &$object_type )             list( $object_type ) = explode( ':', $object_type );              $object_types = array_unique( $object_types );              if ( false !== ( $check_attachments = array_search( 'attachment', $object_types ) ) ) {             unset( $object_types[ $check_attachments ] );             $check_attachments = true;         }              if ( $object_types )             $object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) );              foreach ( (array) $terms as $term ) {             $count = 0;                  // Attachments can be 'inherit' status, we need to base count off the parent's status if so             if ( $check_attachments )                 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = '**private**' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = '**private**' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) );                  if ( $object_types )                 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = '**private**' AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );                  do_action( 'edit_term_taxonomy', $term, $taxonomy );             $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );             do_action( 'edited_term_taxonomy', $term, $taxonomy );         }     }


Wordpress - manually relate a post to page(s)?

So, either I'm searching for a plugin or I'll try to develop one for this purpose but I can't seem to find anything applicable. Perhaps I wasn't searching with the correct terms. What I have setup is something like this: there are 3 types of posts/pages that I want to relate to one another. Lets say I have a baseball player as a post. That player has an agent and a team they play for. When I go to their edit-post area in the Wordpress admin I want to be able to have a drop-down list that allows the admin to choose who their agent is from a pool of all agent's in the system. A similar drop down would let you designate what team they play for from a pool of all teams in the system. In addition to this, each team and each agent would have the same functionality. As an admin, you would be able to inter-relate each type of post (player/team/agent) using a similar method. Basically, it would look in the database for all of the posts with the category "player", "team" and "agent", then let you link them together, either once or multiple instances for a post so that when you go to the players page, you can find out their agent's info and their team info, all with the ability to go to the agent's post or team post as well. Any idea if something exists or what I may be looking for?


Remove the parent name from permalink

I have a problem with the address of the categories in my website. At first, I have to say I checked all the similar topic and question in stackexchange, but none of them solved my problem. Problem is with Wp 3.8 . We have some parent and some child categories, Also my permalink is:               /%postname%/      But the link of the parent and child categories are like this:               siteurl.com/parent/child/      I just want to remove the parent and have this:               siteurl.com/child/      I need a piece of code to solve this.


Can't access Dashboard after Worpress 3.3 Update?

Hi I am having a problem, I updated my wordpress site to version 3.3 and the site itself seems to be working fine except I cant log into the dashboard anymore. When I login using my admin details it keeps re-directing me to /forums/profile page for admin user. Please can anyone help me out or has anyone came across this problem before? Thanks Louise ![enter image description here](http://i.stack.imgur.com/fjIyN.png)


WordPress or Drupal for data-heavy content site

Looking to build a very data-heavy content site and not sure if what I'm looking to do can be accomplished in WordPress (my preference) or even in Drupal for that matter. The problem isn't the content, which I assume Custom Post Types (or maybe Pods??) could do. It's the relationships between the content. Basically want to build pages for individual baseball players, with a some stats (not totally crazy, just basics), RSS headlines from various sites, photos, etc. but with relationships to teams, individual games played in, etc. That's where I'm unsure. Even in Drupal it looks like I would have to use the Entity reference module to accomplish this. So, player is on a team, a team plays in a game, etc. being able to sort and browse by these relationships. Thoughts on if WordPress (or Drupal, or other) is up to this or I would have to go complete custom app/framework? Thanks!


Pages, Custom Posts & Custom Taxonomy defining slug structure

I'm struggling to set up the structure of my wordpress site correctly so that the slugs, work correctly. The page & custom post setup works fine and is as follows:               Archive for fruits (page):     - site.com/fruits     Singular fruits (custom post)     ---- site.com/fruit/apple     ---- site.com/fruit/pear          Archive for Veg (page):     - site.com/vegtables     Singular fruits (custom post)     ---- site.com/vegtable/spud     ---- site.com/vegtable/carrot      I would like to include a custom taxonomy, say colour, and using the plural have the following permalink:               Archive page for fruits by colour     - site.com/fruits/colour/green     - site.com/fruits/colour/red      I have been going round in circles trying to figure this out, but I believe the correct method would be:                Create a page template for the custom post  custom taxonomy archive, e.g      page-fruit-color.php      and create a page for the above.           Set permalinks so all request for      - site.com/fruits/colour/%colour%      go to the above page      Could some please clarify that this would be the best method, if would they have any pointers as to how I may actually achieve this? If it isn't, could someone please suggest the preferred method. Any assistance would be greatly appreciated. Thanks Noel


Custom post type and have_posts() return empty result

I'm very confused regarding the have_posts(). It returns an empty result even though I have one post that match the query. The below code is used in a widget which should display exactly one post, if it exists. I use wordpress 3.3...               $singleargs = array('p' => 2040, 'post_type' => 'event', 'post_status' => array('any'), 'posts_per_page' => 1);     $singlequery = new WP_Query( $singleargs );     //print_r($singlequery);     echo "I'm here 1!!
";     while ( $singlequery->have_posts() ) :     echo "I'm here 2!!
";     $singlequery->the_post();     // output post data...     endwhile;      The above code outputs only **"I'm here 1!!"** , nothing else. But if I remove the **while ( $singlequery->have_posts() ) :** and **endwhile;** then I get **"I'm here 1!!"** , **"I'm here 2!!"** and the correct output of the post that was found. So why do **$singlequery->have_posts()** not return true!!???


Shortcode in pages or tempate files for custom post type

I am using WordPress to develop a coupon site. Merchant `pages` are somewhat similar to this. I am using shortcodes in these `pages` for Facebook Like, Google +1, Customer Review, Codes from similar stores etc. The thing I want to ask is: is this a good way of doing all that? I am comparing this particularly with theme based solution i.e. developing templates files for custom (non- hierarchical) post type. Which one would be more fast and elegant? Any other suggestion is welcomed. Thanks!


Why doesn't WP recognize images in posts like other content?

I've noticed a problem I have with images in my posts: they seem to go unnoticed to my CSS. For example, I have a span tag that is adding a 100px margin to the top of itself under the last paragraph in each post. But when an image is present the span tag seems to ignore the image as part of the paragraph content. There is no 100px margin created. I'd usually say this is a CSS problem... but I think it may be a WP problem. Any thoughts? Website


What's the earliest point I can get the queried object ID?

I'm writing a supplement plugin to Wordpress Mobile Pack because I would like to use the default theme on pages that are assigned a certain page template. My plugin will only deal with the mobile switcher portion of that plugin, so the other components can be ignored (I think). Looking at the source for `wpmp_switcher.php`, all the `add_action` and `add_filter` calls of relevance are not in a function -- they are executed when the file is included as so:               add_action('init', 'wpmp_switcher_init');     add_action('admin_menu', 'wpmp_switcher_admin_menu');     add_action('wp_footer', 'wpmp_switcher_wp_footer');     add_filter('stylesheet', 'wpmp_switcher_stylesheet');     add_filter('template', 'wpmp_switcher_template');     add_filter('option_home', 'wpmp_switcher_option_home_siteurl');     add_filter('option_siteurl', 'wpmp_switcher_option_home_siteurl');      I have removed the actions/filters associated with what make the WPMP plugin tick by using the `plugins_loaded` hook:               function remove_all_wpmp_switchers() {       remove_action('init', 'wpmp_switcher_init');       remove_action('admin_menu', 'wpmp_switcher_admin_menu');       remove_action('wp_footer', 'wpmp_switcher_wp_footer');       remove_filter('stylesheet', 'wpmp_switcher_stylesheet');       remove_filter('template', 'wpmp_switcher_template');       remove_filter('option_home', 'wpmp_switcher_option_home_siteurl');       remove_filter('option_siteurl', 'wpmp_switcher_option_home_siteurl');     }     add_action('plugins_loaded', 'remove_all_wpmp_switchers');      So far, so good. Now I would like to use the following code to add back the actions/filters when my template is not being used:               function wpmp_switcher_exclusions_init(WP_Query $wp_query) {       $template_file_name = get_post_meta($wp_query->get_queried_object_id(),                                           '_wp_page_template', true);       if ($template_file_name != 'my-responsive-template.php') {         wpmp_switcher_init();         add_action('admin_menu', 'wpmp_switcher_admin_menu');         add_action('wp_footer', 'wpmp_switcher_wp_footer');         add_filter('stylesheet', 'wpmp_switcher_stylesheet');         add_filter('template', 'wpmp_switcher_template');         add_filter('option_home', 'wpmp_switcher_option_home_siteurl');         add_filter('option_siteurl', 'wpmp_switcher_option_home_siteurl');       }     }     add_action('parse_query', 'wpmp_switcher_exclusions_init');      The problem is that, even as early as the `parse_query` hook is, the `wpmp_switcher_init` function is called too late. The `functions.php` files for both the desktop and mobile templates attempt to load, causing fatal errors due to re-defined functions. If the template can be retrieved earlier than this, I'm not sure how to do it. It looks like I need to somehow run my code using the `setup_theme` hook. If I can figure out how to do this, I will likely only need the one function in my plugin since `setup_theme` is called before `init`. Any help with this is VERY appreciated!


Duplicate notifications for new user registration

I am trying to figure out why new user registrations are receiving duplicate notification emails. They arrive at the exact same time but from different addresses, one is from the admin owner (myself) and the other one from wordpress@mysitedomain.org. I am using a custom registration form. Here are the relevant pieces of code:               // auto generate a password     $user_pass = wp_generate_password();          // setup new user     $userdata = array(         'user_pass' => $user_pass,         'user_login' => esc_attr( $_POST['user_name'] ),         'user_email' => esc_attr( $_POST['email'] ),         'first_name' => esc_attr( $_POST['firstname'] ),         'last_name' => esc_attr( $_POST['lastname'] )     );          //insert it in db     $new_user = wp_insert_user( $userdata );          //send notification to user     wp_new_user_notification($new_user, $user_pass);      Any help would be appreciated.


WP URL /icons returns 403 forbidden error

So, this is odd. On WordPress, I'm not allowed to have a page `http://mysite.com/icons`. Apparently that slug doesn't work, and I get an error 403 (forbidden) if I try to go there. This seems silly, as there is no "icons" folder in WP to protect. Any ideas where this is coming from, and how to disable it? Strangely, if I go to that URL and I haven't made a page, I get the standard 404. But once I've made a page with the slug `icons`, I get a 403.


Show a special message for private page?

If I set a page to private, can I have it show a message instead of a 404 page for public users?


Error after transfer to a new domain

After transfering my Wordpress to a new domain, database and template I am unable to add new files to media library. An error occurs: "An error occurred while sending the file to the server. Please try again later." PS. Installing (updating core) method is not working... :( Please help me! Best regards.


how does $wpdb differ to WP_Query?

I'm going to write a function to return the next/prev post in a specific category. can anyone tell me what the differences would be in using `$wpdb` as opposed to `WP_Query()`; eg `new WP_Query(args)`? what determines which of these should be used? cheers,   Gregory


Populating content dynamically via AJAX and Advanced Custom Fields

I am using a repeater field from Advanced Custom Fields to create multiple photo galleries. There are 4 pages and each page has multiple image galleries. Because of this, I want to reduce load by using a single external PHP file to generate the content and AJAX to only load one gallery at a time. I am not quite sure how to accomplish this, because since the ACF fields are being defined in an external file, it doesn't know what page to grab the fields from. Here is my JavaScript so far:               var passObject = {};              $.ajax({             url:"<?php bloginfo('template_directory'); ?>/inc/galleries.php",             type: 'POST',             data: passObject,             success: function(resp) {                      $('#photos').append(resp);                  }         });      And here is the content of galleries.php:

Photo Gallery
         <?php if( have_rows('gallery') ): ?>                  <?php while( have_rows('gallery') ): the_row();                   // vars             $photo = get_sub_field('photos');                  ?>
<img src="<?php echo $photo['sizes']['gallery-thumb']; ?>" alt="<?php echo $photo['alt']; ?>" />
             <?php endwhile; ?>              <?php endif; ?>


Add a class to links in the visual editor (how to get old dialog back)

New: ![This is new new Dialog](http://i.stack.imgur.com/l0Gyy.png) Old: ![Old wordpress Add link dialog](http://i.stack.imgur.com/76AxV.png) In short, i want a list of some classes **inside** the add link dialog. Because this was default there might be a easy way to get it back like this? Long: I like to have the ability to add classes to themes. I have found 2 plugins for that. One breaks tinymce and the other add link class plugin produces a hell of a lot notices (with `WP_DEBUG` enabled) but it works it puts a select box to tiny mce and there i can change classes. But i don't like it that way. It created span's when there is no link marked. Back in the days it was just like I want it now. Also there are all sort of wordpress default classes in that dropdown box a also don't like. There is this question about it, but no good answers there, the author stated that he found a better way to accomplish his goal but did not bother to share it with us.


Force page to open in html mode

Hi I have a page that always gets messed up when opening in Visual mode, can I force this particular page to always open in HTML mode for all users in the dashboard?


Typing local Wordpress URL works, but clicking the same link does not

Wordpress is installed locally on WAMP (win 7 x64) and the front page of my site loads fine when I type http://lc.loc. However when I click the link to this URL on the loaded page, I am taken to a DNS fail page that downloads from my DNS host. All the links on the page that start with http://lc.loc/ are broken in this way; if I type them into the address bar they work, if I click that same link on the page I get the DNS 'page not found' error. I have tried firefox, chrome and IE but the same thing happens in all of them. mod_rewrite is enabled, and the LoadModule rewrite_module modules/mod_rewrite.so line is uncommented in http.conf, as is Include conf/extra/httpd-vhosts.conf No .htaccess file was created by wordpress which could be the issue, but I believe I've enabled all the settings it requires to do this. I set the permissions of all the files in the www folder so that 'everyone' had full access. I also manually added an .htaccess file from a fresh wordpress installation I'd made on my shared hosting account, but this hasn't helped. Virtual host config in httpd-vhosts.conf:               NameVirtualHost *:80     <VirtualHost *:80>     ServerName lc.loc     ServerAlias lc.loc     DocumentRoot "e:/wamp/www/lc"      I've tried changing the permalinks structure to post type, and while this does change the urls of the links successfully, clicking those links still fails in the way described. hosts file config:               127.0.0.1    lc.loc      I would really appreciate some help in solving this as I have no idea if it's a setting in apache, wordpress or elsewhere. Thanks, Carl


How can I get all posts data from within a paginated search result?

Let's say I'm doing a search on my site, and get 50 posts as a result. The pagination is set to 10 posts per page, so I have 5 pages of results. When I'm on the first page of results, if I inspect the global var `$posts`, it gives me data for the 10 posts of the current results page only. How can I access the data of ALL the results, no matter which page I'm on?


Get posts from category of custom taxonomy

I am using the GamePress theme, which has a custom Taxonomy/Post type for videos. When using the built-in Nivo Slider, it displays all videos, rather than the ones put into the "Featured" category. Inside of the slider's PHP code, there are a few lines responsible for grabbing the videos out of the video taxonomy.               $vid_term_ids = array();                         $vid_tax = get_terms( 'gamepress_video_category' );     foreach ($vid_tax as $term) :       $vid_term_ids[] = $term->term_id;     endforeach;           if ( in_array( $cat, $vid_term_ids ) ) :            $wp_query = new WP_Query( array(         'posts_per_page' => $limit         'post_type'      => 'gamepress_video',         'tax_query'      => array(            'taxonomy'       => 'gamepress_video_category',            'field'          => 'id',            'terms'          => $cat         ),       ) );          endif;      What I would like to do is modify the code so that it only displays videos placed in the "Featured" category inside of gamepress_video_category rather than display every video in the taxonomy. I am not skilled at PHP, but I do fare well in Java and a handful of other languages. How would I go about using get_terms() to grab videos in the "Featured" video category? Or am I going about this all wrong?


How to add 'data-caption' inside an anchor tag

bellow is custom gallery code.               function custom_gallery_shortcode( $attr = array(), $content = '' )          {                  $attr['itemtag']        = "li";             $attr['icontag']        = "";             $attr['captiontag']     = "p";                  // Run the native gallery shortcode callback:                 $html = gallery_shortcode( $attr );             // Remove all tags except a, img,li, p             $html = strip_tags( $html, '

' );             // Some trivial replacements:             $from = array(                        "class='gallery-item'",                  "class='gallery-icon landscape'",                  'class="attachment-thumbnail"',                 'a href=',                   );                                $to = array(                       '',                      '',                      '',                       'a data-caption="" class="ilightbox" href=',                   );                  $html = str_replace( $from, $to, $html );                  // Remove width/height attributes:                  $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );             // Wrap the output in ul tags:                  $html = sprintf( '
%s
', $html );                  return $html;          }                    add_shortcode( 'gallery', 'custom_gallery_shortcode' );     add_filter( 'use_default_gallery_style', '__return_false' );      but now i want to add image caption inside a. look at my code **`'a data- caption="" class="ilightbox" href=',`** there data-caption="image caption i want to add" now image caption coming outside a like this way *
                     testing caption


How to point my domain to a Wordpress install in a sub-directory?

I have recently been re-designed a client's website (whose website is - for example purposes - mywebsite.co.uk)/ I have developed the new website (a heavily modified wordpress install) in a sub-directory (eg: www.mywebsite.co.uk/new). I would now like for my new website to replace my existing website, and for visitors to find the new site when they visit mywebsite.co.uk. How is this best achieved? Any help is greatly appreciated, Dan


Add Excerpt On Quicksand Plugin

I'm using this plugin called "Quicksand" for Wordpress.. You might wanna check the link. What it does normally is it filters posts based on the category.. It shows the   1. Featured Image   2. Title of the Post  I want to add an excerpt below the Title of the posts.. I opened the quicksand_fucntion.php I tried to add it but i think im missing something... Here's the PHP code
         <?php                                                              $args = array(         'posts_per_page' => '-1',         'post_type' => 'post',         'post_status' => 'publish',         'category__in' => $quicksand_categories          );         $query = new WP_Query( $args );         foreach ($query->posts as $item) {         $categories = wp_get_post_categories($item->ID);          ?>         <li id="item" class="item" data-id="id-<?php echo $item->ID ?>" data-type="<?php foreach ($categories as $c) { echo $c . ' ';}?>" >         <?php  if (get_option('featured') == 'yes') { ?>         <a href="<?php echo get_permalink($item->ID); ?>">         <?php  echo get_the_post_thumbnail($item->ID,array(100,100));  ?>                  <?php } ?>
         <?php if(get_option('titles') == 'yes') { ?>         <a href="<?php echo get_permalink($item->ID); ?>">          <?php echo get_the_title($item->ID); ?>
           <?php         $q = new WP_Query(array($item));         if($q->have_posts()) : while($q->have_posts()) : $q->the_post();             the_excerpt();         endwhile;endif;         ?>
              <?php } ?>
         <?php  }  ?>
      It now shows the excerpt below the title.. But it only shows the excerpt of 1 post only.


How to turn WordPress into a paid member site

I need a plugin which adds a few abilities to WordPress. I want to create a site with the exact same structure like woothemes.com. A user can buy a single theme (paid one time) or a membership subscription (all themes, paid every month). However what the user buys he becomes a member and can download his stuff. I hope someone knows a good plugin.


Plugin Repo: Why do some plugins get version charts while others don't?

I've noticed that some plugins have the version charts displayed on the Stats page while some others do not. What's necessary for the chart to show in the stats page? Also, how does WordPress.org know about the versions currently running on servers around the world?


is_admin() conditional statement

I built front-end log in like this.               <?php if( is_user_logged_in() ) { ?>     <?php      /*       Template Name: front page        */           get_header();     global $user_identity;     $redirect = $_SERVER['REQUEST_URI'];         ?>             <?php while ( have_posts() ) : the_post(); ?>                 <?php get_template_part( 'content', get_post_format() ); ?>             <?php endwhile; // end of the loop. ?>       <?php } else { ?>      <form action="<?php echo get_option('home'); ?>/wp-login.php" method="post"     id="main_comment_form" class="comments-form">
Login

                 Username
                 <input type="text" class="text" name="log" id="log" value="<?php echo     wp_specialchars(stripslashes($user_login), 1) ?>" required/>

                 Password
                 <input type="password" class="text" name="pwd" id="pwd" required/>
             <input type="submit" value=" Login " name="submit">             <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />             </form>     <?php      }     ?>      here what I want is   if **users** log in, it will remains on that page and   if **admin** would log in, it will automatically redirects to /wp-admin/ dashboard. How can I code like that ?   I'm stuck with **if** statement. help me . thanks


Display post_object content using Advanced Custom Fields plugin

I have a hard time figuring out what's wrong with this code. **What I'm trying to do:** setup up a custom field in admin using the ACF plugin to lists in a meta-box on all pages a list of testimonials (custom- post-type). From the drop-down menu the client can select a testimonial that will show up on that specific page. I'm using a slightly modified version of twentytwelve theme and this is the code I'm using in my front_page template. **The code:**               <?php $featured_testimonial = get_field('testimonial', $post_object->ID); ?>         <?php foreach ($featured_testimonial as $post_object): ?>                 <a href="<?php echo get_permalink($post_object->ID); ?>">
<?php echo get_the_title($post_object->ID) ?>
                          <?php endforeach; ?>       **The problem:** this code doesn't show anything on the front-page. I did a `print_r( $post_object )` and it showed all the info in my testimonial (title, date, content etc). **The solution:** For the last 2/3 days I'm trying to get an answer on the ACF support forums and this is the reply I got: > The post object field will return a post object, not HTML. using the_field > on a post_object field will result in nothing being displayed. > > You need to store it as a variable, then use the ID or post_title variable > to output the desired HTML Did I not understand the solution or I'm actually doing exactly what the message says and the problem is elsewhere? **Later edit:** This is my current setup in ACF for the testimonial field: > >     Rules: Post Types - Page. >     Field Name - Testimonial. >     Field Type: Post Object. >     Post type: Testimonial. >     Filter from taxonomy: All. >   The 'rules' means that the custom field will only appear on pages, and it will only list 'post objects' from the 'testimonial' custom post type. In admin everything seems to be working fine, it's just that I can't get anything to show up on the front-end. **Final edit:** Following the suggestion of @s1lv3r I changed the field-type from 'post-object' to 'relationship'. I've also modified the code like this:               <?php $posts = get_field('testimonial'); ?>         <?php if( $posts ): ?>         <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>             <?php setup_postdata($post); ?>             <?php echo get_the_excerpt(); ?>... <a href="<?php the_permalink(); ?>">+More             <?php the_title(); ?>         <?php endforeach; ?>         <?php wp_reset_postdata(); ?>         <?php endif; ?>      Now everything works OK on the front-end. Thanks everyone for helping.


Multiple instances of query_posts

I need to have 8 of these on a single page. Each post list will be in its own numbered switch tab. Is there a better, more efficient way of doing it?

             <?php                 // The Query                 query_posts( array ( 'category_name' => 'CV', 'posts_per_page' => -1 ) );                      // The Loop                 while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>

<?php the_content(); ?>
             <?php endwhile;                      // Reset Query                 wp_reset_query();                         ?>

      EDITED TO ADD FINAL CODE:               <?php     // getting only children of category ID 16     $categories = get_categories('child_of=16');     // do not need to check for empty categories     {     ?>
     <?php foreach ($categories as $c ) { ?>
           <a href="#tab<?php echo $c->term_id; ?>">             <img src="<?php bloginfo('template_directory'); ?>/images/logo-<?php echo $c->slug; ?>.png" alt="<?php echo $c->name; ?>" />
     <?php } ?>
           <?php } ?>          <?php { foreach ($categories as $c ) { ?>     <div id="tab<?php echo $c->term_id; ?>">
         <?php         $q = new WP_Query( array( 'posts_per_page' => -1, 'cat' => $c->term_id ) );         if ( $q->have_posts() ) : ?>
 <?php while( $q->have_posts() ) : $q->the_post();         ?>

           <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">           <?php the_title(); ?>
           <?php the_content(); ?>
         <?php endwhile; ?>
 <?php endif; wp_reset_postdata(); ?>

     <?php } } ?>


Custom post type 404s with rewriting even after resetting permalinks

I created a custom post type, of which the (simplified) arguments are:               register_post_type(         'Event',         'public' => true,         'rewrite' => array( 'slug' => 'eventy'),         'has_archive' => false,         'hierarchical' => false     )      It works fine in general. However if I try to rewrite the URLs in `functions.php`, for example:               function my_post_type_link_filter_function( $post_link, $id = 0, $leavename = FALSE ) {        return str_replace('eventy', 'eventx', $post_link);     }     add_filter('post_type_link', 'my_post_type_link_filter_function', 1, 3);      The result is that the new 'eventx' URLs appear correctly in links, lists, etc, generated by WordPress. But when I go to those 'eventx' URLs I get a 404. Going to an 'eventy' URL still works. I've tried changing the permalinks settings to default and back to post name, many times. This is supposed to reset permalinks and fixes this issue for many people I've seen online. Not for me. Anyone know what the cause might be? How do I go about troubleshooting this? I'm weak on the theory of URL rewriting. If you're interested, my purpose is not the trivial eventy -> eventx substitution mentioned above. I actually want to slip in the year/month an event starts (not when it was was published) into its URL. Debugging got me to realise I had a more basic issue as even this trivial x -> y rewrite still throws 404s. Thanks for reading! [clarification added] At the moment I have say three events (posts in my custom post type) called say "Fishing trip". These get assigned permalinks by default like   * mysite.com/events/fishing-trip    * mysite.com/events/fishing-trip-2    * mysite.com/events/fishing-trip-3  Which is boring and inelegant. I want instead   * mysite.com/events/2013/january/fishing-trip    * mysite.com/events/2013/may/fishing-trip   * mysite.com/events/2013/may/fishing-trip-2    * mysite.com/events/2014/march/fishing-trip Prettier and more informative. I'm not interested in having category-style pages like   * mysite.com/events/2013 The year and month is just cosmetic in the URL.


Saving Custom Field in Attachment Window in WordPress 3.5

I'm using the code below to add a custom text field in WP 3.5 Attachment Window (from this question # Expanding new Media Uploader in WordPress 3.5) ...               add_filter( 'attachment_fields_to_edit', 'xf_attachment_fields', 10, 2 );     function xf_attachment_fields( $fields, $post ) {         $meta = get_post_meta($post->ID, 'meta_link', true);         $fields['meta_link'] = array(             'label' => 'More Media Management',             'input' => 'text',             'value' => $meta,             // 'html' => '
<input type="text" />
',             'show_in_edit' => true,         );         return $fields;     }          add_filter( 'attachment_fields_to_save', 'xa_update_attachment_meta', 4);     function xa_update_attachment_meta($attachment){         global $post;         update_post_meta($post->ID, 'meta_link', $attachment['attachments'][$post->ID]['meta_link']);         return $attachment;     }          add_action('wp_ajax_save-attachment-compat', 'xa_media_xtra_fields', 0, 1);     function xa_media_xtra_fields() {         $post_id = $_POST['id'];         $meta = $_POST['attachments'][$post_id ]['meta_link'];         update_post_meta($post_id , 'meta_link', $meta);         clean_post_cache($post_id);     }      This code adds the field there and I can also save and afterwards retrieve value for any of my attachment. But the issue is **this code does NOT saves value of any attachment by using AJAX.** Mean, if for any attachment image I define any value in this custom field, then selecting another image will remove my defined value for that image apparently. However, if I update the post and check again that field the saved value is there.


Show a 404 error page if Public query variable's value doesn't exist?

> Public query vars are those available and usable via a direct URL query. On my site, I've created some custom URLs with their own query variables like so:               example.net/?category_name=uk&tag=highlights      (e.g. list posts that belong to both - the 'Tech' category and 'gadgets' tag) And have rewrite rules (using `add_rewrite_rule`) in place to pretty the URLs, for example, like this:               example.net/uk/tag/highlights/      (The category base is removed by default from category permalinks.) Now, the problem with using public query vars is that, they almost never show a 404 error page. For example, take a look these two URLs:               example.net/?category_name=uk&tag=jdfjdsjfdlkf     example.net/uk/tag/jdfjdsjfdlkf      Even though the tag `jdfjdsjfdlkf` doesn't exist, the visitor is shown a "Nothing found" page (`content-none.php`) instead of throwing a 404 error (404.php) with appropriate headers. When I think about it, it does make sense. But to suit my specific case, I want a specific set of public query vars (`category_name`, `tag`, and `channel` - a custom taxonomy query_var) to show a 404 error page when the value supplied doesn't exist. My initial attempts got me here:               add_action( 'template_redirect', 'my_page_template_redirect' );     function my_page_template_redirect() {              global $wp_query, $post;              $cat = get_query_var( 'category_name' );         $category = get_term( $cat, 'category' );              $chnl = get_query_var( 'channel' );         $channel = get_term( $chnl, 'itsme_channel' );              $tag = get_query_var( 'tag' );         $post_tag = get_term( $tag, 'post_tag' );              if( $category && !is_wp_error($category) && $channel && !is_wp_error($channel) ){         // If URL is like `example.net/?category_name=uk&channel=tech` and both of the         // supplied values (i.e. Category and Channel taxonomy terms) exist                  // Do nothing              } elseif( $category && !is_wp_error($category) && $post_tag && !is_wp_error($post_tag) ) {         // If URL is like `example.net/?category_name=uk&tag=highlights` and both of the         // supplied values (i.e. Category and Tag taxonomy terms) exist                  // Do nothing              } elseif( $category && !is_wp_error($category) && $channel && !is_wp_error($channel) && $post_tag && !is_wp_error($post_tag) ) {         // If URL is like `example.net/?category_name=uk&channel=tech&tag=highlights` and all the         // supplied values (i.e. Category, Channel, and Tag taxonomy terms) exist                  // Do nothing              } else {         // If one or all of the supplied values don't exist throw a 404 error                  $wp_query->set_404();             status_header(404);             nocache_headers();              }     }      ## Problem Looks like the conditions in place are wrong, or the term objects (`$category`, `$channel`, `$post_tag` aren't set properly), as I am always shown a 404 error page, i.e. even if the terms exist. What am I doing wrong here?


Get the excerpt by page ID from another blog in a wordpress multisite?

I am trying to get the first paragraph on a page where page ID=2 and blog ID=1. I want to display this paragraph on a page in blog id=2. I have added the following code to the template page.               //gets active blog     global $blog_id;     switch_to_blog(1);     $pageid = 2; //author page     $post = get_post( $pageid );      $excerpt = get_the_excerpt( $pageid );     //$content = apply_filters('the_content', $post->post_content);  //filters just the post content     echo "
";     echo $excerpt;     //echo $content;     echo "
";     restore_current_blog();      I have the following in the functions.php file of each theme:               function custom_excerpt_length( $length ) {     return 20;     }     add_filter( 'excerpt_length', 'custom_excerpt_length', 206 );      This is the page where I am grabbing the content from: http://alandracl.com/author/ This is the page I want to display the first paragraph (without the image) on: http://alandracl.com/the-sussex-deal/ (under the about section on this page). Thank you for your help in advance.


Use menu structure for permalinks

I'm building a blog that is kind of split into 5 different parts. Example: I try to combine 4 brands and the company owning those brands on one website. Let's say the company is called "Apple" and the 4 brands are called "iPad", "iPhone", "iPod" and "Mac". What I want to do is to slice the website into 1 part for each of the brands and 1 part for company in general. So when I go to apple.com I get the home page of the company. The iPhone sub-part of the page can be found under apple.com/iphone, the iPad one under apple.com/ipad and so on. For each of those 5 parts I have created a menu-location in my Wordpress theme and a category. Under the "Apple" part of the website, there is a menu item called "Products" and it has sub-items for each product. The product parts of the website have a menu item called "Product Info". Both menu items, e.g. "Products/iPad" of the "Apple" part and "Product Info" of the "iPad" part of the website are linked to the same page that lies under "Product pages/iPad" in the page administration of Wordpress. Thus, the permalink of the page is apple.com/product-pages/ipad. What I want it that this very same page can be accessed via apple.com/products/ipad AND via apple.com/ipad/product-info - depending on what menu was used to get to that page. (I don't care whether the page is still reachable unter apple.com/product-pages/ipad afterwards, or not.) How can I make this possible without having to duplicate the menu structure in the pages administration (and thus having to create the iPad page 2 times with the same content)? For better understanding, here's a menu structure -> page structure mapping. Menu Structure:   * Apple (a) -> Posts from all 5 Categories      * Products (b) -> Page (1)        * iPad (c) -> Page (3)       * iPhone (d) -> Page (4)       * iPod (e) -> Page (5)       * Mac (f) -> Page (6)   * iPad (g) -> Posts from category "iPad"      * Product Info (h) -> Page (3)   * iPhone (i) -> Posts from category "iPhone"      * Product Info (j) -> Page (4)   * iPod (k) -> Posts from category "iPod"      * Product Info (l)-> Page (5)   * Mac (m) -> Posts from category "Mac"      * Product Info (n) -> Page (6) Page Structure:   * Product Overview (1) -> Linked in menu item (b)   * Product Pages (2) -> Not linked, used for structure purposes only      * iPad (3) -> Linked in menu items (c) and (h)     * iPhone (4) -> Linked in menu items (d) and (j)     * iPod (5) -> Linked in menu items (e) and (l)     * Mac (6) -> Linked in menu items (f) and (n) Or is there a better way to achieve my goal? Thanks in advance! :)


where is images/image.jpg?

I am being forced to use a SOAP service on a site, and for some of the UI elements it is calling images that I have to put in place. I can't point them to a theme folder, as I have no control over the HTML, and I am reluctant to use javascript. the code points to `<img src="images/image.jpg" >`, I have tried adding an images folder to the root of my WP installation, to no avail. So my question is where should I put the image so that the HTML can find it?


Create a filter that is using 2,3 or more custom fields

I want to integrate a archive search by custom field into my website. I have this tutorial. It works fine, but I need to integrate more custom fields. Ex: I want to integrate 2 more custom fields ...and I want to display all in archive, and search by (culoare,marime,materiale) >   1. Custom field : marime >   2. Custom field : materiale > This is my function.php               add_action('pre_get_posts', 'my_pre_get_posts');          function my_pre_get_posts( $query )     {         // validate         if( is_admin() )         {             return;         }                   // get original meta query         $meta_query = $query->get('meta_query');                  // allow the url to alter the query             // eg: http://www.website.com/events?location=melbourne             // eg: http://www.website.com/events?location=sydney             if(!empty($_GET['culoare']) )             {                   $culoare = explode(',', $_GET['culoare']);                      //Add our meta query to the original meta queries                 $meta_query[] = array(                     'key'       => 'culoare',                     'value'     => $culoare,                     'compare'   => 'IN',                 );             }                  if(!empty($_GET['marime']) )             {                   $marime = explode(',', $_GET['marime']);                      //Add our meta query to the original meta queries                 $meta_query[] = array(                     'key'       => 'marime',                     'value'     => $marime,                     'compare'   => 'IN',                 );             }              // update the meta query args         $query->set('meta_query', $meta_query);              // always return         return;          }      and this is my archive page code that is added in sidebar.                   h2 class="side">Filtru dupa culoare

     <?php      $field = get_field_object('culoare');     $values = explode(',', $_GET['culoare']);     ?>
             <?php foreach( $field['choices'] as $choice_value => $choice_label ): ?>
             <input type="checkbox" value="<?php echo $choice_value; ?>"              <?php if( in_array($choice_value, $values) ): ?> checked="checked"<?php endif; ?> />             <?php echo $choice_label; ?>
     <?php endforeach; ?>

Filtru dupa marime

     <?php      $field = get_field_object('marime');     $values = explode(',', $_GET['marime']);     ?>
             <?php foreach( $field['choices'] as $choice_value => $choice_label ): ?>
             <input type="checkbox" value="<?php echo $choice_value; ?>"              <?php if( in_array($choice_value, $values) ): ?> checked="checked"<?php endif; ?> />             <?php echo $choice_label; ?>
     <?php endforeach; ?>


Custom Post Types: How-to get rid of editor (-meta box)

I'm questioning how i can **get rid of the post-editor** (visual + html). I tried to not register post type support, and it still appears (de-registering works fine with every other default meta box on post edit screen). I also tried to deregister it with remove_meta_box, which didn't work too (works for everything else except the title meta box). Maybe i'm missing something. Already searched the web and couldn't find anything. I hope someone can tell me. Thanks! Ps. I would be happy about a sollution for disabling the title field too, but that's 2nd (not registering it with the post type works). _(Wordpress version is 3.0.4.)_


Is it better to create a Git repository at the root level or in the WordPress theme directory?

I've currently been creating my Git repositories at the root level for each of my WordPress installations. Git of course then notices any core updates, plugins, and uploads. I'm considering just tracking the theme I'm working on or perhaps the entire themes directory. I'd like to hear from other WordPress developers as to what are their preferred version control practices.


How to prepend route with /blog for blog listing page only

My permalink settings is simply `/%postname%/` (yes I read from the codex that this is bad performance practice). The result is:   * a page url might look like `site.com/pagename`   * a blog post looks like `site.com/post-title`   * a portfolio (custom post type) post will look like `site.com/portfolio/item-1` I would like my blog post page (`single.php`) to have a URL like `site.com/blog/post-title`. How might I do that?


show x number of posts from y category on homepage

I am trying to alter my query_posts. My homepage is currently displaying all posts from all categories at random (posts_per_page =>16) The problem is, one of my categories is advertisements and I want to only show 2 advertisements per page. I want to keep the randomness, but sometimes I get way to many ads returned. I want to limit it to 1 or 2. So how do I say get all posts from all categories but only 2 posts from category x. Thanks


I have a 1300 line excel spreadsheet that needs to get into a wordpress site ASAP - Looking for ideas

I have an excel spreadsheet that needs to get on a WP site PDQ and IE is choking on it. I tried making an html table, but it's huge. I looked into some kind a database plugin that would let me import a cvs and then let users browse it, but I can't even figure out the right search terms. I would appreciate any input. Thanks. My question: Do you have any suggestions? * * * ### update 1/15/2011 I ended up using these steps -   1. Go to **Google Docs**   2. open the spreadsheet    3. click **Share**   4. **Publish as a web page**   5. select the sheet to publish   6. click Start publishing    7. click on All cells field    8. insert the cells range, e.g. A2:A3   9. click **Republish now**   10. copy _the-link_   11. **Close**. Example -               <iframe src="The-Link" width="w" height="h" frameborder="0"></iframe>        * `the-link` = url from google   * `w` = width in pixels   * `h` = height in pixels


Wordpress CPT Upload Audio Files to wp-content/upload/audio

I'm working on a custom post type for my blog that will read files in the directory specified and create a post for that file. I also want to use the wp upload handler in my custom post type but I want it to upload the files to the specified folder. Can anyone point me in the right direction on how to achieve this?


how to set the link in wordpress such that on clicking it doesn't open another page but go to the bottom of same page

I have one word press project and in that index page is having 7 menus like home, about, contact, offering, invitation, evolution and downloads now how to set the this links such that on clicking it doesn't open another page but go to the bottom of same page where i have added contents of each page.


Rebuilding a Site: How to Show Several Category Posts in Woo Framework Theme?

I am having a hard time managing a big site with 2000+ pages. Right now, I am restructuring the site architecture. So, for example, if there are categories like x, y, z... I want to put them under "A." This A can be a page or a blog, but it should have a pagination (should update dynamically whenever a new post is added under x, y, z category). Similarly, I want to put several other categories in "B." I have tried various plugins, like posts to page, posts for page... and even List Categories with Pagination plugin. What I am looking for is another archive/blog page that lists the posts from defined categories. Any help is highly appreciated. Here is the template-blog.php file, if it helps.                  <?php      /**       * Template Name: Blog       *       * The blog page template displays the "blog-style" template on a sub-page.        *       * @package WooFramework       * @subpackage Template       */            get_header();       global $woo_options;      ?>                <?php woo_content_before(); ?>

                                   <?php woo_main_before(); ?>
                  <?php get_template_part( 'loop', 'blog' ); ?>
             <?php woo_main_after(); ?>                  <?php get_sidebar(); ?>
                       <?php get_sidebar( 'alt' ); ?>
     <?php woo_content_after(); ?>           <?php get_footer(); ?>      **Edit:** Going through Codex.WordPress, I see that there is a possibility:               $query = new WP_Query( 'cat=2,6,17,38' );      I wonder how to incorporate this code into my blog file. Edit 2: Modified it this way, still doesn't work. Check edit 3. Edit 3: Here is the loop-blog.php template.               <?php     /**      * Loop - Blog      *      * This is the loop file used on the "Blog" page template.      *      * @package WooFramework      * @subpackage Template      */     global $more; $more = 0;           woo_loop_before();          // Fix for the WordPress 3.0 "paged" bug.     $paged = 1;     if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); }     if ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); }     $paged = intval( $paged );          $query_args = array(                         'post_type' => 'post',                      'paged' => $paged                 );          $query_args = apply_filters( 'woo_blog_template_query_args', $query_args ); // Do not     remove. Used to exclude categories from displaying here.          remove_filter( 'pre_get_posts', 'woo_exclude_categories_homepage', 10 );          query_posts( $query_args );          if ( have_posts() ) { $count = 0;     ?>

          <?php     while ( have_posts() ) { the_post(); $count++;              woo_get_template_part( 'content', get_post_type() );          } // End WHILE Loop     } else {         get_template_part( 'content', 'noposts' );     } // End IF Statement          woo_loop_after();          woo_pagenav();     ?>


Show Posts to Author Only

I've developed invoicing system in WordPress for one of my website. I've used custom post type with custom meta field, integrated payment gateway to meet my needs. User generally generate invoice to upload fund. I've used a post submission from in frontend so that user can create an invoice by himself. Everything is running smoothly but one invoice created by an user is visible to other users. Ex. A created invoice, id: APL-2012110489586. User B can access the invoice by typing domin.com?invoice=APL-2012110489586. Now I want to restrict the invoice to be accessed from other user. Only admin and invoice creator can access the invoice. All users are in subscriber role. Need your guideline to perform this job.


Exclude Specific Categories?

the code I'm currently using to display categories is `<?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' ';}?>` I would like to exclude a category called "home-featured" or the category with ID "65" how would I add this to the code above?


Cache DB queries result

On my new site i am displaying most of the images instead of text. I show images for recently written, recently viewed, mostly viewed posts etc. I found that in 40% of cases posts are same. so i need not to hit the DB to extract the image. It can save number of hits to Db & processing time. I intially thought to cache post IDs. So before querying to DB or processing contents to extract image, i can search for post id into cache. If post id found in cache then i can directly show image from disk. I found that there are many of the plugins who cache DB queries and their result. I am using wp-total cache. Please tell me whether it can fulfill my requirement or i should write my own logic


Creating open content area and restricted content area

I'd like to create a site that has two separate areas of content. One for members with a payment system and another one for regular viewers that gives teasers so that they would want to read more and engage in the proprietary content. Is this something that WordPress is capable of or should I search for more complex content management systems for solution? How can I do that?


get all posts ID from a category

Problem: I need to get an array of ID's of posts from a given category If the category have any posts. This is to be used on a plugin options page. So far I have:               $posts = get_posts(array('numberposts' => 10000, 'category' => 5));      But I'm struggling with How do I gen an array containing just the ID of each post on that category. Any Ideas ? Thanks


show category in woocommerce

This code show tags from a specific category such as id = 3. I want to make automatically check which category I am. Can someone please help me ?               $args = array('categories'=> '3');      $tags = get_category_tags($args);      $content .= "
";      foreach ($tags as $tag) {          $content .= "
tag_link\">$tag->tag_name
";     }      $content .= "
";      echo $content;


Display all taxonomy, children and grandchildren with links

I have a post type named Package, and have 4 taxonomy associated with it, treks, tours, adrenaline and expeditions. All of these taxonomies have chidren categories(eg. treks region 1, treks region 2.....), and in those categories are multiple packages(content). Now how can i display all taxonomies, their children and the title of all their packages, with links(treks and it's children to taxonomy.php and packages to single-ntp_package.php)? (i need to make a dropdown nav) i tried with wp_list_categories(), it just shows the children. can't even pass all taxonomy types in array i also tried get_object_taxonomies, it shows the taxonomy name like 'ntp_trek', the one i used to make it unique, not the one in 'labels',which is 'Treks'. and i've tried all these functions with terms and objects, but can't get what i want. Please help, i've been trying it from yesterday. Thanks


Display recent comments with gravatar and excerpts?

I couldn't seem to find a plugin with both functionality so I created mine(not a plugin) thru the help of my old friend google. My code works but there's a small glitch, the title of the posts are the same for all recent comments.               $comments = get_comments('status=approve&number=5'); ?>
 <?php      foreach ($comments as $comment) {          $post_obj = get_post($comment->post_id);          $title = $post_obj->post_title; ?>
<?php             echo get_avatar( $comment, '42' );             echo strip_tags($comment->comment_author); ?> <?php             echo wp_html_excerpt( $comment->comment_content, 35 ); ?>
             <a href="<?php echo get_permalink($comment->post_id); ?>" rel="external nofollow" title="<?php echo $title; ?>"> <?php echo $title; ?>
     <?php }  ?>
      Any help would be appreciated. Thanks! **UPDATE:** Here's the current code. Edited according to Ambitious Amoeba.               $comments = get_comments('status=approve&number=5'); ?>
     <?php foreach ($comments as $comment) { ?>
<?php             $title = get_the_title($comment->post_ID);             echo get_avatar( $comment, '42' );             echo strip_tags($comment->comment_author);             ?> <?php             echo wp_html_excerpt( $comment->comment_content, 35 ); ?>
<a href="<?php echo get_permalink($comment->post_ID); ?>" rel="external nofollow" title="<?php echo $title; ?>"> <?php echo $title; ?>
     <?php }  ?>      Still getting the same result. All with the same title. Though it changes the post title according what is currently viewed.


How does Wordpress handle HTML Tables interaction with jQuery

I have javascript that gets the width of a table and reduces the css fontsize of text within the table until the table width is less then the width of its parent div. The code bellow shows the principle ONLY. This approach works out side Wordpress. Within Wordpress the fontsize is reduced to 0px and the width of the table width shrinks, but remains wider than the width of its parent. Outside wordpress the browser adjust the table width to fit the text. So how does Wordpress handle HTML Tables different?               function ShrinkTable() {     var FontSize = parseInt($("#tbl").css('font-size').replace('px', ''),10);     var TabWidth = jQuery("#tbl").width();     var DivWidth = jQuery("#narrorColumn");     if (parseInt(DivWidth.css('width').replace('px', ''),10) <= TabWidth) {         jQuery("#tbl").css('font-size', FontSize - 1 + 'px'); /* you can change 4 with any number, the smaller is better but it may require more loop */         //Shrink the font while div width is less than table width         ShrinkTable();       }     }


Run wp_kses_decode_entities on atom feed?

I would like to convert the htmlentities in only my atom feed to their corresponding characters. Using the below in my functions.php I've gotten close, but obviously the commented out line doesn't work, and the change is applied to all of my feeds. Is there a way to do this using filters/hooks? Thanks.               function decode_feed_entities($content) {         return wp_kses_decode_entities($content);     }     // add_filter('do_feed_atom', 'decode_feed_entities');     add_filter('the_content_feed', 'decode_feed_entities');     add_filter('the_excerpt_rss', 'decode_feed_entities');


Use ajax to update_post_meta

2 days ago I asked this then I tried to work on my code to be able to understand how ajax and php work and now I have a new issue that, probably would be easily solved. These are my codes:               <?php     /*     Template Name: Nuovo form     */     ?>     <html>      <head>          <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>          <script src="http://malsup.github.com/jquery.form.js"></script>               <script>              // wait for the DOM to be loaded              $(document).ready(function() {                  // bind 'myForm' and provide a simple callback function                  $('#myForm').ajaxForm(function() {                      alert("Thank you for your comment!");                  });              });          </script>      <?php wp_head();?>     </head>      <body>     <form id="myForm" action="<?php echo get_template_directory_uri();?>/nuovoform/comment.php" method="post">          Name: <input type="text" name="name" />          Comment: <textarea name="comment"></textarea>          <input type="submit" value="Submit Comment" />      </form>     </body>     </html>      Then this is my Comment.php               <?php      // This is comment.php content     $nuovoform = 0;     $nuovocommento = 1;     if ( isset( $_POST['name'] )){     $nuovoform = $_POST['name'];}     if ( isset( $_POST['comment'] )){     $nuovocommento = $_POST['comment'];}     update_post_meta($post->ID,'varcontrollo',$nuovoform);     $controlliamo = get_post_meta($post->ID, 'varcontrollo', true);     ?>      'varcontrollo' is a custom meta field created using Custom Field Template plugin. What I'm trying to do is use the form I created to store the result inside my custom field. If I try to browse to comment.php it says this: > Fatal error: Call to undefined function update_post_meta() in > D:\Locali\xampp\htdocs\wp-content\themes\slotlandia\nuovoform\comment.php on > line 8 Probably i have to 'import' WordPress 'global' variables but I don't know what have I to write. Is there anyone who can help me? Thank you very much.


Inconsistent translation on a WP site

I have a WP site that I installed with the French translation, as provided by Wordpress France, and which is quite accurate. I wanted to apply an English- only theme, which is not using the PO files, but rather has all text hard- coded in the PHP code. I translated all files, but I noticed that when I display the home page, some of the words remain in English, but whenever I display something other than the home page, those are all in French. Is there something either in Wordpress or the theme files that actually make a distinction between the home page and others to display different pieces of text ?


Custom user profile URLs

I have created a page "profile" that when visited with get variable of user id like:               http://example.com/profile/?uid=1      Then it will display the profile details of user id `1`. Now I want to rewrite …               http://example.com/profile/?uid=1       … to …               http://example.com/profile/admin       How to accomplish this?


Moving Site From Development to Production

I have a WordPress site at the root of a bluehost account ( inside public_html ) and there is an add-on domain also residing in a folder named devsite inside public_html. We have spent months developing the content in the devsite to be ready to promote to production. On Saturday, I made a control panel snapshot and downloaded copies of both the current production site as well as the development site. Then I tried the upgrade. The first way I tried was to use a tool called DesktopServer on my Mac to import the devsite. That worked. I then tried to deploy it to the production domain as per instructions but the deployment failed. I restored the site via the snapshot. On Sunday I tried the "WordPress" way of FTPing the files to public_html and exporting the database, fixing the links using "Search & Replace for Wordpress databases" and modifying the WP-Config to point to the new database. None of the pages on the site transferred, the menus didn't transfer, the widgets were not set ... in short, the promotion was a disaster. Today, I tried the DesktopServer method on the Windows 7 machine at work. However, after making the site archive, DesktopServer reports that it is unable to locate the main index.php in the site archive but I checked and it is there. I am out of ideas on how to move this site to production and would appreciate and guidance or help. Thanks, Jon


wp_insert_post creating duplicate post with Safari

I have a front end form users use to create custom posts. It works fine with Chrome and FF, but when in Safari two posts are created. The code i'm using is below. I've tried a few conditionals shown in other answers but none worked. How can I prevent wp_insert_post from creating duplicate posts when submitted from Safari? Thanks               if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {          $tags = $_POST['post_tags'];          $new_post = array(         'post_title'    => $title,         'post_content'  => $description,         'post_category' => array($_POST['cat']),         'tags_input'    => array($tags),         'post_status'   => 'publish',etc.         'post_type' => 'website'     );          global $current_user;     get_currentuserinfo();          $user_name = strtolower($current_user->user_login);  //custom caps will default to lowercase anyway     $pid = wp_insert_post($new_post);          update_post_meta($pid, "s2member_ccaps_req", $user_name, true);          wp_redirect( get_permalink($pid) );      exit();      The form                               <form id="new_post" name="new_post" method="post" action="">
Title
                         <input type="text" id="title" value="" tabindex="1" size="20" name="title" />

Category:

<?php wp_dropdown_categories( 'tab_index=3&taxonomy=category' ); ?>

Content
                         <textarea id="description" tabindex="4" name="description" cols="50" rows="6"></textarea>

Tags:                         <input type="text" value="" tabindex="5" size="16" name="post_tags" id="post_tags" />

<input type="submit" value="Publish" tabindex="6" id="submit" name="submit" />
                              <input type="hidden" name="action" value="new_post" />                         <?php wp_nonce_field( 'new-post' ); ?>                     </form>


Prevent plug-in scripts on a specific template?

I have a plug-in which is interfering with my Google Map Embed in the template I'm using for my about page. Is there a way to prevent that plug-in from hooking in all of it's script files through wp_footer just on that particular template. It adds like 4 js files which aren't necessary for that page/template.


Wordpress 3.5 Media Manager - Default view to "Uploaded to this post"

I'm trying to figure out how to default the select box above the media gallery in the new media manager so that it shows the images "uploaded to this post" by default. I can't seem to find a way that works properly. Thx folks.


Wordpress 3.5 Media Manager - Reorder Selectbox items on Media Library Tab

The new media library is awesome but its a bit inefficient. When the page loads, it puts ALL MEDIA ITEMS as the default view. Which causes the page to load a LOT of images. I'd like it to default to "Uploaded to this post". I've tried other solutions, such as changing the default selection Change the default-view of Media Library in 3.5? But this is done via JS and when there's a lot of images on the page, it first starts loading the "ALL MEDIA ITEMS" tab and then switches tabs to "Uploaded to this post" so I think the better way to do this would be to reorder the select box so that "Uploaded to this post" is first and the default. I'm not sure how to go about doing that. Or if its even possible with filters. Would love some feedback from the experts. Thanks!


Is there a hook for user activation (after they click the email confirm)? I am creating a plugin to automatically add them to my email software, but I want them to have to confirm their email first.


How to Get All Posts but the Private ones?

I am creating a frontend mosaic view where i need to show the most recent posts. So i need to show all published posts to every visitor, but keep the private ones for the logged in users. I know how to add the private posts, but I don't find a way to remove them from the query. (Removing them from the results would work but, then, the number of posts on the page will vary depending on how many recent posts are private: this is not what I want!) (As a workaround, I can refrain from publishing the private posts and showing the private on top of the published for the members...) Any idea?


SetCookie simply not working

I cannot get a cookie to set properly through WordPress theme. I am putting the following code on the bottom of my `functions.php` page for my theme.               function set_cookie() {     if (isset($_GET['id'])) {         $referrerID = $_GET['id'];             setcookie('referrerid', $referrerID,time()+ 3600 * 24, COOKIEPATH, COOKIE_DOMAIN, false);         }     }     add_action( 'init', 'set_cookie');      I even went as far as using JavaScript to alert if the script reached the function (which it did). Why are my cookies not being set?? (The code works locally - outside of WordPress that is).


How to add attachment without uploading?

When save post, I made dir in wp_uploads_dir, and copied 2 files and one folder in this dir. Now I want to do the WP_insert_attatchment process to make the 2 files as attachements. How can I do it? Edit: I inset_attatchement by directly using their URL. Now they show up in Media Libray, but I can't see whether the attachment_id is recorded or not. Which table in database can I go to find it?


How to get child categories of a given Post

how do I get names of child categories of an arbitrary Post? For example i got category slug - 'motorbikes' and I got subcategories for it. So I need to get each posts subcategory name thats inside category with slug motorbikes. Y2ok