How to disable edit post option after period of time?

How to disable edit post option for post one day after publication?


Giving Multiple Authors Access to a Plugin's WP.org Repo

A plugin I've released has a collaborator. So I put them into the readme.txt file and they show up on the plugin page and all that. Does doing this automagically give them access to the SVN repository for the plugin? Or is there some other process to go through to get them access? Or is only one user allowed per repo? Thanks!


custom types taxonomy hide_empty

I have a custom type, which uses custom taxonomy to create categories. I can add 'products' and assign them to the category structure that I have created. There is a top level menu which displays the parent categories, clicking each takes the user into the category hierarchy. If there are no products in any sub-category of a parent category, then that listitem shouldn't display in the top level nav. If I set hide_empty=1 _all_ the parent categories disappear, not just the one with no products. Can anyone advise?


How to do a particular wp_query taxonomy search

I have added a custom taxonomy called _experience_ to the _page_ post-type, and the taxonomy has terms " _vfds_ " and " _plcs_ " I am trying to create a search where a user can select one or more _experience_ taxonomy terms from a select list, press the submit button, and see the results of a wp_query. I need the query result to show pages with 1) the _experience_ taxonomy has no (zero) terms selected 2) one or more terms selected I have an html select list with an array `experience[]` to capture multiple selections:               <select name="experience[]" multiple="multiple">     <option value="vfds">VFDs</option>     <option value="plcs">PLCs</option>     </select>       Then I feed this array into a wp_query:                   <?php                  $_GET['submit'];             $experience = $_GET['experience'];             $args = array             (                        'post_type' => 'page',                           'tax_query' => array(                         array(                             'taxonomy' => 'experience1',                             'field' => 'slug',                             'terms' => $experience                         )                      )             );         $query = new WP_Query( $args );      The query works fine in the sense that it will show pages that have one or more terms selected under the experience category. The problem I am having is this: IF a page has empty (no) values for the experience category, then it is not shown in the result list. Is there a way where wp_query will show pages with   1. no terms selected   2. one or more terms selected Thank you * * * **EDIT #1** Please let me add that in general I am trying to move away from using Drupal with Views. I am trying to replicate Views capability of being able to search using select fields with multiple values. I have tried to use `wp_query` with a custom select field with multiple values, and failed miserably so far. Hence I switched to using categories with multiple terms and am close to replicating a Views type search result. If anyone knows any other way of doing what I would like to do in WP, I would very much appreciate it. Thanks again! * * * **EDIT #2** I realize maybe my question does not make full sense. Let me try and explain further. The reason I need to search result to show pages with ZERO or more terms instead of ONE or more terms, is that I would like to combine the taxonomy search with a another field search, eg City. If a user fills in only a value for city, and no value(s) for experience terms, the search results will be zero because he did not fill in terms. Instead I need to show all pages with the city that was selected, whether or not any experience terms are selected


after_setup_theme always runs

I am setting up a child theme for some of my faculty members, and as a part of the theme, I would like a handful of plugins to be activated at the time that the theme is activated. So, naturally, I used the after_setup_theme action and called my setup function. It works great, except it runs on EVERY request (admin and otherwise). I proved this by adding this to the end of the setup function: `echo '<script type="text/javascript">alert("This action was run")</script>';` And as a result get a javascript alert on every admin request and every front- end request (I have a network setup, so obviously on sites where this theme is not active, it's not running the function) So the question is, is this a bug? Am I somehow doing something wrong? Here is the complete code that I am using:               add_action( 'after_setup_theme', 'fwp_setup' );     function fwp_setup(){         // -- Unrelated code remove for the sake of brevity          require_once($_SERVER['DOCUMENT_ROOT'].'/wp-admin/includes/plugin.php');         activate_plugin('enable-media-replace/enable-media-replace.php');         activate_plugin('seo-image/seo-friendly-images.php');         activate_plugin('w3-total-cache/w3-total-cache.php');         echo '<script type="text/javascript">alert("This action was run")</script>';     }      Any insight would be much appreciated!


Duplicate posts and change category (frontend)

I am trying to create a button inside a post and, when the user clicks on it, I'd like the post to be duplicated and this new post goes to another category, is it possible? For example: I have "post 1" in "category1". When the user clicks on the button "duplicate", it should duplicate the "post1" inside the "category2". Thank you!


How can I delete all my existing trackbacks?

I'm sorting out a long-neglected wordpress.org blog. It has over 100,000 pieces of trackback spam. How can I remove them all?


Visual editor broken after upgrade

Yesterday a colleague updated WordPress and a number of plugins on our site. Since then, the visual editor displays the contents of pages and posts as HTML, it is also white, whereby we first thought that it wasn't displaying the contents as well. I have been able to switch to HTML-mode which displays as expected, but when I switched back, the Visual/HTML tabs stopped working. Going through a few troubleshooting ideas offerd on a number of fora, like re- uploading the wp-admin and wp-includes folders, deactivating plugins one by one to single out the culprit... all to no avail. The fact that the text is white is annoying, but on top of that, most of my colleagues have no idea what HTML is. Any help would be greatly appreciated.


How can I make different page templates for one category?

I need this for menu "red car", "blue car", "green car". Information is retrieving from a single category (cars). But the output on pages depending on the values in the metaboxes (colors). On the page with blue cars shouldn't be a green cars. Cars and colors for illustrative purposes only. How can I do this?


Using categories as multilingual mechanism

Is there something wrong with the following approach. I dislike installing plugins (with database access) on my wordpress. But I want my wordpress to be multilingual . What do you think about the option using the categories as the Language differentiation.   When some user creates a new post, he choose the language (Category).   In the theme Ill identify the language by the category. Do you think it might work? Thanks


BuddyPress Xprofile check if user can view field

I use the following code to get a custom BuddyPress Xprofile field:               <?php if($field = bp_get_profile_field_data('field=field_name')) : ?>
<?php echo $field; ?>
     <?php endif; ?>      But how can I check if the current viewer has the permission to view the field (from the visibility setting who the user can set)?


show image in mail contact form 7

I am using contact form 7.   I have a file field to upload images. Code of file field in contact form 7               [file* image filetypes:jpg|png|gif]      I need to display the uploaded image in mail using contact form 7. How can i do that?


Linking from a list of custom post type items to a single - get_post_permalink not working correctly

I have created a custom post type of Case Studies, and created a list page which gives an overview of each. Some have a link straight to the case study in PDF form and some have a link to a single case study view, where full text and a full size image can be seen. The problem is with the link to the single view. When you hover over the link it shows a URL which is correct for the name of the case study, and when you click on it, the correct URL is brought up, but the content on the page is the content of a different case study. Hope someone can help, it's driving me mad now! This is the list page code:
     <?php if(have_posts()) : ?>     <?php while (have_posts()) : the_post(); ?>     <?php the_title('
' , '
'); ?>     <?php the_content(); ?>     <?php endwhile; ?>     <?php endif; ?>     <?php $loop = new WP_Query( array( 'post_type' => 'case-study', 'category_name' => 'construction-case', 'posts_per_page' => -1 ) ); ?>     <?php while ( $loop->have_posts('post_type=case-study') ) : $loop->the_post(); ?>     <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_title(); ?>

     <?php if (has_post_thumbnail() ) { ?>
     <?php the_post_thumbnail(); ?>

     <?php the_excerpt(); ?>     <?php } else { ?>
     <a href="<?php the_field('upload_case_study'); ?>">

     <?php the_excerpt(); ?>     <?php } ?>     <?php if (get_field('upload_case_study')) { ?>
<a href="<?php the_field('upload_case_study'); ?>">Download <?php the_title(); ?>
     <?php } else { ?>
<a href="<?php echo get_post_permalink(); ?>">Read more >
     <?php } ?>
     <?php wp_link_pages('before=
' . __( 'Pages:', 'blankslate' ) . '&after=
') ?>     <?php edit_post_link( __( 'Edit', 'blankslate' ), '
', '
' ) ?>

     <?php comments_template( '', true ); ?>     <?php endwhile; ?>
      And this is the single case study page code:
     <?php query_posts( 'post_type=case-study' ); ?>     <?php the_post(); ?>     <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_title(); ?>

     <?php the_content(); ?>
     <?php      if ( has_post_thumbnail() ) {     the_post_thumbnail();     }      ?>     <?php edit_post_link( __( 'Edit', 'blankslate' ), '
', '
' ) ?>

     <?php comments_template( '', true ); ?>
      The actual development site can be viewed here: http://wp.perfect-image.co.uk/construction/construction-case-studies/


wpdb update multiple row?

I need to change the meta value of all users at once. Seem there are no api for this,except using custom database query. This is my code:               $matches = array('meta_key' => 'user_token');     $data = array('meta_value' => '100');     $wpdb->update( "$wpdb->usermeta", $data, $matches);      The problem is this only update one user meta value, not all users meta value with the meta key of 'user_token'.   Does $wpdb->update limited to update single row only? Or I did something wrong?


list child pages as slug

I have a section on my site that needs a list of pages that are descendents of a particular ID. I need them listed on the child and grandchildren pages. But the page titles are too long, so I need to use the slugs as the titles. I thought I could just use wp_list_pages and specifically call descendents of this ID BUT there doesn't seem to be a way for wp_list_pages to list the slugs instead of page titles. furthermore, i have to use a str_replace for the dashes in the slugs. can someone tell me where i can even start with this? i ended up using the below, which isn't working any better... any insights?               function is_tree($pid) {           global $post;              $anc = get_post_ancestors( $post->ID );          foreach($newanc as $ancestor)      {         if(is_page() && $ancestor == $pid) {         return true;         }     }     if(is_page()&&(is_page($pid)))      return true; // we're at the page or at a sub page else return false; // we're elsewhere };


Return one of user's post from a category in user's profile

I'm working on a site which requires requires users to submit a custom profile of sorts, and then one post in a specific category (all of that is being done through Gravity Forms and their User Registration add on). I then need to display that post with the user's profile which is being displayed at the top of single posts and archives (because that one post is being used in conjunction with a voting plugin...so whenever someone views any post written by that author, they're also viewing that author's profile and entry post, which includes the voting button). First, I've got this on customizing the author box: http://www.billerickson.net/code/customize-author-box/ and this is the entirety of what I need to display with the author profile (here it in pastie, I keep trying to get it all in correctly here: http://pastie.org/5379532 ):                    <?php     $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) :    get_userdata(intval($author));     ?>
           <?php query_posts('category_name=contestants&posts_per_page=1'); ?>     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php echo $curauth->user_nicename; ?>
     <?php the_post_thumbnail('medium', array('class' => 'alignleft')); ?>     <?php act_last_connect($author) ?>
     <?php if(function_exists('getvote5')) getvote5('get'); ?>

About Me
     Posted: <?php the_time('M. d, Y'); ?>          <?php the_content(); ?>          <?php endwhile; else: ?>
<?php _e('This contestant has not created his/her entry.'); ?>
     <?php endif; ?>
      But from here, I don't really know how to merge the example from Bill and what I have. Can someone help me understand?


Tabs in post of a wordpress?

I want to add tabs on a post of my wordpress website. But i am a new user of wordpress and don't know how to do it. Can anybody tell me how to do it. I will be very grateful.


WooCommerce Checkout page customization

I'd like some help with customizing the functionality of my WooCommerce driven site. The link can be found here: http://seekoften.com/eCommerce/checkout How can I customize the output so that it shows the product images that you have in your cart, but on the checkout page ? Also, as a side note to this question, what files / lines of code might I want to look at if I'd like to add another drop-down to the checkout form. Also, if I'd like to change the wording of "select a state" to be "select a province" ? Thanks in advance for your help, as you guys have always aided me in my web- ventures. Sincerely, Chris Coffin.


Best practices - Should I create a child theme vs. customizing a framework theme? (such as HTML5 reset)

I have built quite a number of wordpress sites and have worked frequently with the HTML5 reset theme. My workflow has been to simply edit the files in the theme because I often use quite a bit of custom CSS, php and custom wp_query loops etc. In the end, the theme is really quite drastically different from the original HTML5 reset theme. However, I am wondering if there is a particular reason I should be creating a child theme instead? I find that I am doing so much customization that to me, I only really use the HTML5 reset for its basic header, footer and html structure overall. I'm not entirely sure how I could really implement a child theme and manage enough customization. Thus my question is – as a best practice, should I still be using a child theme and basically have so many of the same files overriding the parent that it's not even really necessary? To me, I can only see child themes as a way to customize the parent but still keep the majority of the look/function the same. Is this an inaccurate perception? Many thanks in advance!


How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms

I want to export all Wordpress categories (no posts, just categories) from one blog to another. How can I do that ?


Where to place custom functions?

Straight to the question: It seems that there are only so many places to place custom code: functions.php, plugin, template, shortcode. Having too many plugins slows down your load times, inflating the functions.php file can get unmanageable, same with a template, and shortcodes really depend on the situation. I have a homepage with a lot of custom code and queries on it: Latest comments, most popular content, most liked content, featured content, custom slider of featured content, newest posts, etc. This makes for a cluttered homepage when I'm trying to make edits to the code. I've used shortcodes for a lot of the queries but I'm still left with a cluttered page. My plugins is maxed out (39 active) and my functions is quite full as well. I am packing a lot of custom code into my site but I'm curious as to what your thoughts on the best way to organize all of your custom functions. How do you choose between placing your code into functions.php vs making it a plugin? Are there ways of extending functions.php so that you don't have to run-up your plugin count and you can better organize your custom functions?


How to Pass External Variables to Filters/Actions

I find myself needing to pass custom data to a filter provided by a 3rd party plugin. All of the ways I've seen to do this are really complicated and hard to wrap my head around. Take this example:               $score = 42; //Some crazy calculation I don't want to repeat.          function add_score_to_title($title) {         return 'Quiz Results (' . $score . '/') - ' . $title;     }          add_filter( 'aioseop_title_single', 'add_score_to_title');      How can I pass the `$score` variable to `add_score_to_title()`? What I ended up doing was adding my variable onto the global `$wp` object. So you end up with this:               global $wp;     $score = 42; //Some crazy calculation I don't want to repeat.     $wp->some_random_name_for_score = $score;          function add_score_to_title($title) {         global $wp;         $score = $wp->some_random_name_for_score;         return 'Quiz Results (' . $score . '/') - ' . $title;     }          add_filter( 'aioseop_title_single', 'add_score_to_title');      Dirty? Maybe. Simple? Yup! Any downsides to this technique? Please discuss. **UPDATE** Here is the complete code in question -> http://pastebin.com/fkSXY04m


Transposh Japanese language transaltion not showing up

If you go to this site and click on japanese in the top left corner, it shows the japanese page with this showing up: `<!--[if gt IE 8]><!--> <html class="no-js" lang="ja" dir="ltr"> <!--<![endif]-->` but the actual content remains in English, other non-latin languages like हिन्दी work fine but Japanese doesnt. I have no idea why this is happening. If you need anymore info i'll be happy to provide it. P.S. QTranslate is also enabled on this site, disabling it had no effect. Using WP 3.4.2 and the latest Transposh. **EDIT:** DEBUG SHOWS THIS:               Notice: Undefined variable: cache_wptouch in /home/content/34/8802234/html/sarvatma/wp-content/plugins/wp-super-cache/plugins/wptouch.php on line 109          Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/34/8802234/html/sarvatma/wp-content/plugins/wp-super-cache/plugins/wptouch.php:109) in /home/content/34/8802234/html/sarvatma/wp-content/plugins/transposh-translation-filter-for-wordpress/transposh.php on line 513          Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/34/8802234/html/sarvatma/wp-content/plugins/wp-super-cache/plugins/wptouch.php:109) in /home/content/34/8802234/html/sarvatma/wp-content/plugins/transposh-translation-filter-for-wordpress/transposh.php on line 513          Notice: Undefined variable: google_font_link in /home/content/34/8802234/html/sarvatma/wp-content/themes/sarva/header.php on line 42          Notice: Undefined variable: before_widget in /home/content/34/8802234/html/sarvatma/wp-content/plugins/transposh-translation-filter-for-wordpress/wp/transposh_widget.php on line 266               Notice: Undefined variable: after_widget in /home/content/34/8802234/html/sarvatma/wp-content/plugins/transposh-translation-filter-for-wordpress/wp/transposh_widget.php on line 342


Add more widget areas to a theme

what's the best approach to add more widget areas to a theme? currently, my theme has 2 columns that display the widgets, but I'd like to extend it to 4 for example. It currently looks like this: ![enter image description here](http://i.stack.imgur.com/GL3io.jpg) And I'd like it to look like this: ![enter image description here](http://i.stack.imgur.com/QgiWM.jpg) All the widgets of this theme are located above the footer. The theme is called Time by s5themes.com. The widget initializer is not located in the functions.php as far as I know. Is this a simple fix at all? thanks! Edit: Now that the sidebar is displaying in the theme, I think the rest of how each sidebar is shown is located in the style.css. Thanks.


Auto create pages on WordPress multi site register

I'm creating a multi site and would like to have:   1. A few pages that are automatically created with the new site (at the moment only the default home and sample page are created with a new site, anyone know how that is being done?)   2. Even better but maby separate, a way to create pages in a form (on the register form or otherwise) so that means optimally i want 4 pages (with content) made when a site is registered, and then a form asking them for the titles of 2 more pages that get created. answers or ideas for either much appreciated!


Exclude Private, Draft pages from Primary Nav when using custom menu

I'm looking for ways to prevent "private" and "draft" pages from appearing (to non-logged-in admins) in a site's Primary Navigation menu which is based on a custom menu - other than manually removing such pages from the WP custom menu and then dragging them back when they are published, that is. FWIW, I'm surprised the behavior I'm looking for isn't the default. Using: WP 3.4.2


Keep post's draft date after publishing?

I let users add posts in draft status. After I check and see that everything is ok, I publish them. I noticed that drafts created two days ago change date after being published. Is there any way of keeping that original date?


Add 'title' attribute to stylesheets with wp_enqueue_style()

Read below if you want to start from where I left off in core. But the basic question is: I need to add a "title" attribute to my stylesheets and wp_enqueue_style() doesn't allow for that parameter, as far as I can tell. Other than a hard embed, are there any ways WordPress allows us to add the title to a stylesheet? In digging around core I notice that there's a `$title` variable that can be set using `$style->extra['title']`.               $title = isset($this->registered[$handle]->extra['title']) ? "title='" . esc_attr( $this->registered[$handle]->extra['title'] ) . "'" : '';      (class.wp-styles.php) And $title also figures in the filter that is applied when you enqueue a stylesheet. So how can you set that 'extra' array within the style object?


Why am i getting this error? WordPress database error: [Query was empty]

I am using Wordpress 3.4.2, latest version! I have no plugins installed except the one that I am writing. So Here's the deal, I'm reading a json feed and i'm trying to import its content into a table that i created in my wordpress database. I've used a similar set of code in another plugin that I wrote and it works fine there. I do not understand why it does not work here. When i run this different plugin that i am writing i am get the dreaded and oh so clear "WordPress database error: [Query was empty]". Here is my code...               // Setup the array     $values = array();          foreach ($bugs as $bug) {      $status_text = $bug['text'];      $tContent = htmlSpecialChars(html_entity_decode($status_text));      $imported = 2;           [ shortened to keep this post short, but other values are listed here. ]                 // for the values insert part       $values[] = '("'.$tContent. '", "'.$imported.'")';     }          if(is_array($values)) {        echo "
WHAT TO IMPORT?
";        var_dump(implode(',', $values));     }      This output all of the values as expected. Everything is wrapped in parentheses and seperate by a comma. Then i do this...               global $wpdb;     $table_name = $wpdb->prefix . "bugtbl_temp";          $sql = $wpdb->prepare (         "INSERT INTO $table_name         (`post_content`, `imported`)         VALUES ". implode(',', $values) . " ON DUPLICATE KEY UPDATE imported = 1"     );     $wpdb->query($sql); // execute query               $wpdb->print_error(); // any errors?     $wpdb->last_query; // show the qry     $wpdb->flush(); // cleanup      And then when i run this function I get the "WordPress database error: [Query was empty]" and nothing is imported into my table. I saw on here one other guy was having problems with $wpdb->prepare. Am I using it incorrectly?


Drop down list in user profile page

I am having problems finding an answer to this. I need to have a custom user meta field. I can create them which is fine but I need to create a drop down one. For example I want the user meta to be Unit type and the drop down values to be Residential and Commercial Any help on this would be great. Thanks.


Is there a PressThis that doesn't hotlink?

What are some plugins or alternatives to the PressThis function? I want to use the PressThis bookmarklet to quickly blog about what I see online, but every time I do and include an image, it hotlinks to the image from the site I'm blogging about. That's bad, because I don't want to tax the site I'm writing about. I don't want to use a full-sized image. And I don't want the image to be broken on my site if the site I'm writing about to goes down.


Image Upload from URL

I really like the way SE uploads an image from a URL (I'm sure many do!). I've been searching, but can't find, **is there a plugin or a method similar to this available for WordPress?** I know an image can be uploaded and crunched directly from a URL by entering the image URL into the File Name box after you click Upload/Insert Media >> From Computer >> Choose File ![enter image description here](http://i.stack.imgur.com/RHQWJ.png) This is a great feature, but not very widely known (I actually just discovered it). I would like something a little more like SE, where there is an option that let the user know to add the image URL. How can I go about adding simply the upload file field to a new tab in the media uploader? Here is a tutorial for How to add a new tab in Media Upload page in wordpress, but I want to add only some text and the file upload field to that tab. Any ideas? I couldn't find anything in the WordPress Codex that deals with this feature or the file upload field directly. Thanks.


Function to get thumbnail img source

I have this function call that displays an entire img tag with the correct url for that post.. the thumbnail img...               ?php the_post_thumbnail('blog-page'); ?>      What I need is just the source address for that img. How can I get that source dynamically? * * * Here is a little more explanation of what it is exaclty that I'm doing... This is the code that displays the thumbnail for a page in my wordpress:
     <a rel="lightbox" href="<?php the_permalink(); ?>"><?php the_post_thumbnail('blog-page'); ?>
       I need that a tag's href to use the img's source instead of linking to the blog post it's self to get lightbox to work properly.


Woocommerce Cart Going toAdmin Login Page

When I try and add/remove something from the cart, it sends me to the admin login page. However, when I go back to the shop page, it shows that the item has been added to the cart. I can't get past this to see my cart and continue to buy the product(s). What can I do to fix this problem?


Wordpress show bad the php hour and date

For my surprise today i see wordpress put bad the hour In settings i have the hour of my country , France and City Paris And today i try for create one function the php date function for show the date               <?php     echo date("dmY");     ?>      For my surprise as i tell until , see wordpress change my php time and put day 19 and change the hour and no show the real time actually If the same code insert in other site - no use wordpress - and the date show right , day 20 How it´s possible wordpress change native function of php and show when runnning this thedate of php , by other side in settings of wordpress i se utc different hour to local time , utc show 19 and local time show 20 I don´t understan all this ..... Thank´s for the help


Total number of authors with more than one post

<?php      $users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");     echo '(', count( get_users( array( 'role' => 'author' ) ) ); echo ')'      ?>      code by Jan Beck I need to know what is my best option for displaying the total number of authors who have at least posted and/or published something on my blog. Currently the code is counting all the authors even if they haven't posted anything. Please let me know if there is a simple solution to this. I have looked throughout the wordpress codex and have not found a solution to this yet.


Variable Not Working Inside is_author() Array

I'm using a plugin (User Groups) to separate out users into, well, groups, and I need to figure out a way to create a conditional to check if an author is in a certain group. So, using get_term_by and get_objects_in_term, I was able to build a string of author IDs. See below:               $taxonomy = 'user-group';     $taxonomy_group_name = 'author-group';     $taxonomy_group_id = get_term_by('slug' , $taxonomy_group_name, $taxonomy, 'OBJECT');     $taxonomy_group_ids = get_objects_in_term($taxonomy_group_id->term_id, $taxonomy);     $taxonomy_id_list = implode(',', $taxonomy_group_ids);      So, I can take the list stored in $taxonomy_id_list and echo it out and get a string that looks like the below:               1,2,3,4,5,6,7      For the conditional, I should then be able to say:               if(is_author(array($taxonomy_id_list))) { }      But that doesn't work. If I paste the raw list into the array, it works as it should, but if I try to use the variable inside the array, the conditional does not work. What am I missing? Why wouldn't that variable work?


Can plugin2 uninstall plugin1 at the very beginning of plugin2's installation?

As per the title. I have a new version of a plugin. It installs fine on a clean WordPress. When a user tries to install it when they have a previous version installed, the plugin does not function. It does not matter if the previous version was active or not. Ideally, I would like to ensure that the new version uninstalls the previous version before writing any files itself. Is this possible? Alternatively, if anybody has any idea why we are encountering this issue, I would not be opposed to just fixing it. :)


Mass Mail Plugin to Email Specified User Roles

I'm not looking to spam anyone, but I am looking for a mass mail plugin so I can select the User Roles (whether core or custom) by check box or comma separated entries of the roles, then type my message and send. The reason: I have a multi-author website with active contributors, authors and editors. I am looking for a simple way to email these groups. I don't care if it is a free or premium plugin. # UPDATE I tried the solution provided below, Emu2 - Email Users 2, but after using it for a few days, I found there is a conflict with the WordPress media uploader, causing http errors on upload with the new WordPress uploader and timeouts using the classic WordPress uploader.


Time Issue xx hours ago

I'm facing a strange issue, first time in my life :) After publishing a post/page/custom post type, it's tell that published 10 hours ago. It's happening always, for all posts. As I've deployed a VPS for hosting my websit


What should I write in hostname when I try to install a theme?

I am a beginner with WordPress and I have no idea what hostname I should specify when I try to install a theme. Thank you for a help! ![enter image description here](http://i.stack.imgur.com/WG9Ph.png)


Custom Search results page based on search

I am trying to find a way to create custom search results pages based on what the user searched for. I don't think it's possible with a global search since multiple posts may be pulled in but I wanted to narrow it down some and have the user do the following: Visitor choose a category drop down then when they enter in the search terms in the text filed it pulls in a custom search results page based on category 5. I have something like this already so when a user views a post or tags related to food it automatically pulls in a custom page. The code I use starts off like this:               <?php     $post = $wp_query->post;     if ( in_category( array('restaurants')) ) {include_once( $theme_path . 'single-restaurants.php' );}      How would I do something close to this but by telling search.php to redirect to search-restaurants.php if category 5 is selected?


wp_head() not including styles and javascripts after a template redirect

I am using the template_redirect action to redirect a user to a custom template which has no header, sidebar or footer (the intent is for it to be in an iframe as a dialog box). After I done the redirect though, I could not seem to get all the enqueued JS and CSS to list. Here's the code:                   <?php         /**          * This theme file is accessed by template redirect          * No header, sidebar or footer          */              ?>         <!DOCTYPE html>                  <title>Customize Product</title>              <?php wp_head()?>

                          <?php                     /**                      * Output the content of the template                       */                     do_action('product_customize_display_customization_content');                     ?>

                    Edit: Here's how I am including the JS               // bootstrap code, will refactor later as necessary     if (is_admin())     {         global $admin_class;         $admin_class = new product_customize_admin();         $admin_class->init_admin_actions();         $admin_class->init_ajax_actions();              add_action('admin_menu', 'init_admin_menu');         add_action('admin_print_scripts', 'my_admin_scripts');         add_action('admin_print_styles', 'my_admin_styles');               }     else     {         add_action('wp_head', 'include_frontend_scripts');                   // setup frontend         global $frontend_class;         $frontend_class = new product_customize();               }          function include_frontend_scripts()     {                      // preset scripts         wp_register_script('product-customize-preset', plugin_dir_url(__FILE__).'js/preset.js');         wp_enqueue_script('product-customize-preset');     }      Here's the code for the template redirect               function theme_redirect()     {         global $wp;         $plugin_dir = dirname(__FILE__);              //echo '
'.print_r($_GET, true).'
';              // if we are doing product customization         if ($_GET['prod_cust_do_customize'] == 1)         {             $return_template = $plugin_dir.'/themefiles/customize_preset_page.php';             echo "template = $return_template";             $this->do_theme_redirect($return_template);              }          }          function do_theme_redirect($url)     {         include ($url);         exit();     }


Problems with cron

I have a this code that delete some post meta at al 7:55 hour of the server:               if ( !wp_next_scheduled('borra_meta_datos') ) {        wp_schedule_event( mktime(7, 55, 0, date('n'), date('j')), 'daily', 'borra_meta_datos' );     }          function borra_todos_los_meta_datos() {        $args = array(        'meta_key' => 'destacados',        'post_status' => 'publish',        'numberposts' => -1,        'category' => -14     );     $allposts = get_posts($args);          foreach( $allposts as $postinfo) {        delete_post_meta($postinfo->ID, 'destacados');     }          $args = array(        'meta_key' => 'portada',        'post_status' => 'publish',        'numberposts' => -1     );     $allposts = get_posts($args);          foreach( $allposts as $postinfo) {        delete_post_meta($postinfo->ID, 'portada');     }          $args = array(         'meta_key' => 'slider',         'post_status' => 'publish',         'numberposts' => -1     );     $allposts = get_posts($args);          foreach( $allposts as $postinfo) {        delete_post_meta($postinfo->ID, 'slider');     }     }     add_action('borra_meta_datos', 'borra_todos_los_meta_datos');      All the week the code works fine, but today the code executed early that the hour, i dont know if i am doing something wrong. Additionally i have another code that program all the post of specific user at 3 am of the local hour but today all the posts appear like lost schedule.               function programa_post($data, $postarr){         $hora_de_publicacion = 3;         if( $data['post_type'] == 'page' ){             return $data;         }         global $current_user;         get_currentuserinfo();         if($current_user->user_login == 'luis' or $current_user->user_login == 'jorge'){             $hora_actual = date('H', current_time('timestamp', 0));             //Forget this if :S             if($hora_actual >= 3 && $hora_actual <= 23){                 $time_3am = mktime($hora_de_publicacion, 0, 0, date('n'), date('j'));                 $data['post_date'] = date('Y-m-d H:i:s', $time_3am);                 $data['post_date_gmt'] = date('Y-m-d H:i:s', $time_3am - ( get_option( 'gmt_offset' ) * 3600 ));             }elseif($hora_actual >= 0 && $hora_actual < 3){                 $time_3am = mktime($hora_de_publicacion, 0, 0, date('n'), date('j'));                 $data['post_date'] = date('Y-m-d H:i:s', $time_3am);                 $data['post_date_gmt'] = date('Y-m-d H:i:s', $time_3am  - ( get_option( 'gmt_offset' ) * 3600));             }         }              if(trim($data['post_excerpt']) == ""){             $data['post_excerpt'] = ' ';             return $data;         }else{             return $data;         }              return $data;     }     add_filter('wp_insert_post_data', 'programa_post');      i dont know if is problem of code or error of cron, i am lost :(


customize continue reading

This is the code of continue reading in function.php               <?php the_content( __( 'Continue reading →', 'twentyten' ) ); ?>      It has a class which named **meta-nav** I tried to find the class and change it but I couldn't find that. Where is that? Thanks in advance


Stop wordpress from "correcting" my code?

I'm starting to lose my patience with Wordpress. I've downloaded a raw html plugin that should stop wordpress from converting some characters to their entities, I won't use the visual editor but still, every once and a while, it messes up my code. It converts `<` and `>` to `<` and `>` from some parts of the code and leaves me wondering where the problem is. I'm using 3.4.2, and I'm wondering if there's a way to **COMPLETELY** stop wordpress from editing my stuff. I mean no automatic paragraphs, no character converting, etc.


Change Featured Image direcly in the Page

In Doing an Image Gallery with Fancybox( lightbox ) using a wordpress loop, take a look at the code inside the loop:

             <a rel="gallery_fancybox" href="<?php echo $image_attributes_large[0]; ?>" title="<?php echo get_post_meta( $attachment->ID, $key, true ); ?>">                 <img style="width:187px; height:124px;" alt="" title="<?php echo get_post_meta( $attachment->ID, $key, true ); ?>" src="<?php echo $image_attributes[0]; ?>" />                 <?php the_time("Y"); ?>                 <?php the_time("j"); ?> de <?php the_time("F"); ?>                 Access

      There is in Another page an Image that the source is the Featured Image of this Gallery, and all of this is working without problems. However I want to do a fast change of that Featured Image, so, inside each image box loop add a button that just the admin will see ( with `<?php global $user_ID; if( $user_ID ) : ?> <?php if( current_user_can('level_10') ) : ?>` )that when it is clicked, the Featured Image of this Gallery change to the image that is inside that div. Is it Possible? Thanks a lot in Advance. Sorry for the bad English, and sorry for the weird Question.


wordpress paginate_links url

my code looks like this:               paginate_links(        array(        'next_text' => __('>'),         'prev_text' => __('<'),         'base' => @add_query_arg('page', '%#%'),         'format' => '?page=%#%&a='.$a,         'total' => ceil($count/$per_page),         'current' => $page)     )      Everything works perfectly but if I click on for example second page my url goes to `www.domain.com/something/2/?a=5` instead of `www.domain.com/something/?page=2&a=5` Is it possible to change it into `www.domain.com/something/?page=2&a=5`?


image path error in wordpress multisite

I have a WordPress multisite and I can upload and display images in the main site, but not in the others. When I upload an image, it doesn't show any error, but the image doesn`t display, like when a path is wrong. If I use it in a post, the same occurs. The image display with wrong path. This is the path: `http://www.codetocode- developments.com/personal/files/2014/01/scottwills_building11-450x250.jpg`


Get term slug of current post

I am working on a single post type template where I show a navigation menu with links to all the posts from the same term. Now I want to use this template for all the different terms so $term_slug needs to hold the term slug of the current post so they can correspond to the other posts. I have found many times over the internet this code to do the job but it doesn't work for me:               $terms = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );     $term_slug = $term->slug;      This article says that this would do the job: http://www.wpbeginner.com/wp- themes/how-to-show-the-current-taxonomy-title-url-and-more-in-wordpress/ What am I doing wrong?               $args = array(         'post_type'     => 'myposttype',         'mytaxonomy'    => $term_slug,         'order'         => 'ASC'     );                        $current_id = get_the_ID();     $the_query = new WP_Query( $args );     if($the_query->have_posts() ) {         while ($the_query->have_posts()) { $the_query->the_post();                  echo '
ID ? ' class="current"' : '') . ' href=" ' . get_permalink() . ' ">' . get_the_title() . '
';               }      }


How to correctly escape query variables to be used in WP_Query

I've got custom query variables that are added via `query_vars`. For example, 'industry'. In `pre_get_posts` action I construct and add taxonomy query if there is a value for the 'industry' parameter, like so:               add_action( 'pre_get_posts', 'alter_posts');     function alter_posts( $q ) {         $tax_query = array();              // industry taxonomy         if ( get_query_var( 'industry' ) ) {             $tax_query[] = array(                 'taxonomy' => $my_taxonomy,                 'field' => 'slug',                  'terms' => get_query_var( 'industry' )             );         }              // set all previously determined values to the query         $q->set( "tax_query", $tax_query );     }      How do I correctly escape query variable that I get via `get_query_var( 'industry' )`? Do I use esc_sql function, like so `esc_sql( get_query_var( 'industry' ) )` ? What's the correct way to handle the escaping of query variables? Many thanks, Dasha


wp_enqueue_script vs. wp_register_script

Trying to do the right thing here, and tying myself in a knot! So, in my header.php before `wp_admin`, I have:               wp_enqueue_script('commonfunctions', child_template_directory . '/script/commonfunctions.js', array('jquery', 'jquery-ui-draggable'), '1.0', true);      which works. Basically, I have a custom js file which needs jquery and jqueryui as dependencies. I since took 'jquery' out as it seems to be loaded twice irrespectively. I also had a function hooked into 'init' in functions.php, but that didn't seem to have any advantage? I want to include the validate script from CDN as this will also be a dependency of my custom script. I thought I would register the script like so:               wp_register_script('validate', 'http://ajax.microsoft.com/ajax/jQuery.Validate/1.6/jQuery.Validate.min.js', true);      and then add 'validate' to the dependencies array in enqueue, like so:               wp_enqueue_script('commonfunctions', child_template_directory . '/script/commonfunctions.js', array('jquery', 'jquery-ui-draggable', 'validate'), '1.0', true);      in that order, as jquery is also a dependency of validate. Phew! That doesn't work, I'm obviously misunderstanding something - please help me uncurl what I'm trying to do here...


Oauth user Authorisation

I work with Oauth 1. I want when the user enters the admin page of my plugin, it is redirected to the site should perform authorization and come back on my page but it does not work `get_user_authorization();` do not work.                 session_unset();            $OAUTH->set_site("http://www.site.com/fr/", $key, $secret);       $OAUTH->set_callback($callback_url);            $OAUTH->get_request_token()           ->get_user_authorization();


How can I edit pages from my local environment?

Is there any to edit and/or create wordpress pages from my local environment? Or shall I use the wordpress editor no matter what?


do_shortcode() within Admin Page

I'm using a few plugins that have shortcodes ... however, instead of creating a public page for the content, I've created some new pages within the admin using `add_menu_page` and I need to know how to utilize `do_shortcode()` within this context. As it stands, all the function does it spit out the string. I'm assuming it's because the shortcode API isn't available within an admin page. How do I get around this? There is no documentation that I can find that explains how to utilize shortcodes within the WP Admin... or if it's even possible. * * * Specifically I'm trying to utilize WooCommerce shortcodes within the WP Admin. I hate the fact that plugins don't utilize the WP Backend for account/user management.


Trying to load content of a post via AJAX

OK I'm trying to load content of a post via AJAX. So here is the functions.php part                   wp_localize_script('ajax-script', 'ajax_object', array('url' => $blogurl,'path' => $path,'ajaxurl' => admin_url( 'admin-ajax.php' )));         add_action('wp_enqueue_scripts', 'javascripts');         add_action('wp_ajax_ajax_action', 'ajaxify'); // ajax for logged in users         add_action('wp_ajax_nopriv_ajax_action', 'ajaxify'); // ajax for not logged in users         function ajaxify() {             $post_id = $_POST['post_id'];             $post_data = get_post($post_id);             setup_postdata( $post );             echo json_encode($post_data);         }      and here is the jQuery part               $("a.ajaxed").click(function(event) {         event.preventDefault();         doAjaxRequest();     });     function doAjaxRequest(){         jQuery.ajax({             type: 'POST',             url: ajax_object.ajaxurl,             data: ({action : 'ajaxify',                 post_id: $(this).attr('id')                 }),             dataType: 'JSON',             success:function(data){                 console.log(data.post_title);             }         });     }      But when I look at the console it outputs 0, I don't see the content. What am I missing?


populate select options from extra mysql table data

hi guys i am trying to populate a select element with options from the data in one of my sql tables heres what i have so far:                <?     $SQL = "SELECT * FROM pt_country ORDER BY name";         $rs = $wpdb->query($SQL);         $nr = mysql_num_rows($rs);             for ($i=0; $i<$nr; $i++) {             $r = mysql_fetch_array($rs);             echo "<OPTION VALUE=\"".$r["countrycode"]."\">".$r["country"]."</OPTION>";            }     ?>      im guessing quite a bit of this is wrong but to start with i cant get wordpress to return the data i just get false what am i missing here ?


How do I fix my static page

I have tried a few option with static pages. First i created a template called homepage.php and had it designed a certain way, and also on that template were the post. Then i created another template called news.php and this is the regular blog set up with the news post and navigation. When i set the front page to the homepage template the post didn't show up. Next i created home.php and then created a page called News and everything in the index.php template i pllaced in the news.php, for the News page i selected the news.php template but nothing showed up


Remove specific shortcode from get_the_content()

I have a variable like this:               $post_content = get_the_content();      Here i want to remove some specific shortcode from the $post_content variable e.g i want to remove only this `[video height="300" width="300" mp4="localhost.com/video.mp4"]` all other shortcodes and content formatting should be leaved intact. How could this be done? **UPDATE:** I'm able to remove some specific shortcode by using code something like this ...               <?php echo do_shortcode( str_replace('[video height="300" width="300" mp4="localhost.com/video.mp4"]', '', get_the_content()) ); ?>      But it is also removing all html tags/formatting of get_the_content(). How to avoid it?


How does admin-ajax.php work?

we are having some issues with an external developer. i am not a wp person so i turn to the masses to help out. we want to limit access to the wp-admin site to internal access only (via vpn). simply so it will not be attacked by external people. we can enumerate the admins from the site and do not want them to be phished. the developer is saying we cant do that because the site needs to have the admin page accessible externally so the page will function. specifically the admin-ajax page. what does the admin-ajax.php page do? it is located in the admin section of wp.. is it accessed unauthenticated by end users? is it an unsafe practice to have this available to external users?


Handling complex multi-level architecture / menu for large site

I am trying to get feedback and ideas for solving an information architecture / content management problem using wordpress. I have a large site ( 1,000+ pages, hundreds of posts ) made up of sections. Each section needs its own secondary navigation menu that contains both pages and custom links. This is easily done, but not necessarily easy to manage ( for non-programmers ). Imagine this structure: Parent 1   * Page 1a   * Page 1b   * Page 1c   * Custom Link 1d  Parent 2   * Page 2a   * Page 2b   * Parent 3      * Page 3a     * Page 3b     * Custom Link 3c    * Page 2d   * Custom Link 2e  Here are the solutions I have come up with ( and noted problems ):   1. Create menus using the normal WP 3 + navigation system. Associate each parent page with a menu ( through a custom meta tag / taxonomy / slug / other ), then on each page grab it's parent ( if it does not have children itself ) and display the correct menu     * Problems? Plenty! Since this is a large site, it will contain many menus making maintenance confusing.      * Adding pages becomes a hassle - add the page, declare the correct parent page, then add the page again to the correct menu ( could be simplified by attaching this last piece programmatically to the save_page hook ).      * What if a user adds a page and declares a parent page that does not have a menu associated with it?      * Keeping track of the parent page - menu association will be tedious and not intuitive   2. Use multisite - each site gets its own menu that is shown on all of the pages contained within.      * Many issues with multisite ( plugins, server resources, etc )     * This is really only one large site, not a network of different but interconnected sites   3. Forgo the WP 3+ navigation system, instead create pages for ALL menu items ( including custom links ) and use a plugin / forwarding / redirect to change certain dummy pages into custom links. Use wp_list_pages to programmatically create menus based on page parent relationship      * There will be a lot of actual pages already, adding fluff ( pages which just redirect ) to the pages list is probably not a good idea     * Use custom post types for each section of the site, with a menu for each custom post type     * How do we replicate the nesting shown above ( Parent 3 nested in Parent 2 )?     * Many of the same issues as #1 above I hope my explanation of the problem and possible solutions are clear - if not, please ask away. Otherwise, any feedback or ideas as to how to accomplish this are very welcome.


How to add an "or" instead of and "and" (&) in a Wordpress query?

I would like to accomplish something like this:                       <?php $custom_posts = new WP_Query(); ?>             <?php $custom_posts->query('category_name=Business OR category_name=Technology OR category_name= Lifestyle'); ?>             <?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
                     <?php the_content(); ?>
             <?php endwhile; ?>      So that if the post belongs to only one of those categories it should be listed in that loop. Any suggestions?


PHP logging framework to be used with WordPress

There are different PHP logging frameworks out there e.g. Log4php, KLogger. I want to choose one based on its experience with WordPress. Please suggest me one.


get_the_author_meta not working

So I have this website that I am building and I am using get_the_author_meta to display various information about the user / author including user image. I added a function in my functions.php which allows to add more options to the author profile such as: facebook profile, twitter, image etc etc.. this is the basic function which display the value in the theme files:               <?php echo esc_attr( get_the_author_meta( 'slider_pic', $user->ID ) ); ?>      Now - it works fine throughout the whole site and all templates: single.php, page.php etc etc but in my homepage (in my case index.php) there is a problem: I included a slider which contains the images of the authors + link to their respective profile pages and beneath that slider I am showing the 9 latest blog posts of the site and next to the name of the author should be the image using the code above. for some reason the slider preventing the images to display in the 9 boxes. when I use this code:               <?php echo esc_attr( get_the_author_meta( 'slider_pic', $user->ID ) ); ?>      in the slider it works fine but beneath that in the another loop the image dont appear at all. when I remove the include that calls the slider the images in the 9 boxes show.... This is the code Im using for the slider: https://dl.dropbox.com/u/4405634/slider.php and this is the code I am using for the homepage which include the slider in it: https://dl.dropbox.com/u/4405634/index.php I am assuming it is either a conflict or something that has to do with loops or whatever would love to have a solution Thanks, Gil


How to get media objects

I am busy with a loop to return all media in the medialibrary in objects. I figured out how to get the images ( with `wp_get_attachment_image('$mediaID')` where the $mediaID is the id of the image ) But I want to loop all media, not just the images, is there a function that I can use for video's and audio that is also from the medialibrary. I tried `get_attached_media` but this will only work if the media is actually attached and I want to loop all media. Is there a way to do this and to get it as objects? Thanks in advance. P.S. The code I am using is:                           <?php                 $query_images_args = array(                     'post_type' => 'attachment', 'post_mime_type' =>'', 'post_status' => 'inherit', 'posts_per_page' => -1,                 );                      $query_images = new WP_Query( $query_images_args );                      foreach ( $query_images->posts as $media) {                     //save the url in a variable to test with                     $media_url = wp_get_attachment_url( $media->ID );                          $mediaID = $media->ID;                     echo wp_get_attachment_image( $mediaID );                 }                ?>      P.P.S. I do this because I want to show the media in some sort of library on the front end. Later there will be categories like 'video', 'audio' and 'img'


Twenty Eleven home page show only excerpt

I am using the brand new twenty eleven theme, my home page is set to show latest posts, but it displays the entire posts, I want to only show the excerpts, not the entire content, Here is the index.php code
                      <?php if ( have_posts() ) : ?>                          <?php twentyeleven_content_nav( 'nav-above' ); ?>                          <?php /* Start the Loop */ ?>                     <?php while ( have_posts() ) : the_post(); ?>                              <?php get_template_part( 'content', get_post_format() ); ?>                          <?php endwhile; ?>                          <?php twentyeleven_content_nav( 'nav-below' ); ?>                      <?php else : ?>

<?php _e( 'Nothing Found', 'twentyeleven' ); ?>

<?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?>
                             <?php get_search_form(); ?>

                      <?php endif; ?>


Creating custom AJAX requests

My question pertains to where I should create an ajax function that I'd like to call from my page view. I am using a jQuery validator on a custom form that should check the inputted zipcode against my database of valid zipcodes. I just need to know where this function should exist. Normally when using a non wordpress site I'd create a PHP file with my ajax functions and call them by referencing the URL to this page and passing some parameters. How can I achieve this with wordpress? Where can i explicitly call a php file and pass it arguments? Note: I'd like to call the ajax function like so:               $.post('http://mysite.com/ajax-functions.php?fxn=zipcodes',         {zipCode:00000},         function(response){           // do stuff         });      Thanks


Latest 5 post excerpts from 5 different authors in Sidebar

I'm attempting to display the latest 5 post excerpts from 5 different authors in my blog sidebar. Below is the code I'm using which I tweaked from this thread: Find most recent authors So far, I've gotten it to work however rather than display each individual author's most recent post, it's showing the author's earliest post. Any ideas on what I'm doing wrong? I've been struggling w/ this for a few days so appreciate any direction you can give. I'm a newbie to PHP but can understand enough to tweak code. Thanks!! You can see it working on my site: wearestd.com               <?php     global $wpdb;          $post_IDs = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY post_author ORDER BY post_date DESC LIMIT 5" );          $my_query = new WP_Query( array( 'post__in' => $post_IDs) );          if( $my_query->have_posts() ) {       while ($my_query->have_posts()) : $my_query->the_post(); ?>     <?php userphoto_the_author_thumbnail() ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?>

     <?php the_advanced_excerpt('length=50'); ?>     <?     endwhile;     }     ?>


How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?

I'm trying to write a class that would allow for easy removal of all plugin- related data when the plugin is uninstalled. Specifically, I want it to remove plugin options, custom post type entries, and custom taxonomies and their terms. What I have written mostly works, but the get_terms function returns an 'invalid_taxonomy' error. Looking into it further, I found that the global $wp_taxonomies does not recognize the custom taxonomies created by the plugin during the uninstall.php process. So my question is: How does one remove custom taxonomy terms when a plugin is uninstalled? Here is my code: http://pastebin.com/geH1wzRC Bonus points if you can tell me how to avoid loading this class twice if two plugins contain it. I tried just wrapping the class in `if( !class_exists( 'WP_Plugin_Janitor' ) ) { ... }` but then the class never loaded. **EDIT** I was able to prevent the class from loading more than once by putting the class in a separate file and wrapping the `include_once` statement in the `if( !class_exists(` statement. Thanks in advance!


How to activate flash cards

I have been blogging at wordpress for the past 6 months and very recently i came to know about the flash cards. Can anyone let me know as to how to activate flash cards in wordpress. I tried going to the "extras" option but then i can't see anything regarding flash cards over there.


Problem the_permalink

Morning everyone, I'm sorry to disturb, but I need help if possible. The code below I need to publish part of the contents of some pages. Firstly I have a problem with "the_permalink" despite write the correct address, this is where he wants (see image). Puts for example before H2 and however outside the tag A. ![problem the_permalink](http://i.stack.imgur.com/oFjkM.jpg) Secondly I would like to filter out and ONLY a few pages with specific ID but have not been able to find a solution. I tried to put it but it does not work.               new WP_Query( 'post_type=page&include=30,60' );      Code that I used                   <?php     // Lista Pagine con the_excerpt e the_post_thumbnail          // Query Pages        $my_query = new WP_Query( 'post_type=page' );          // The Loop        while ( $my_query->have_posts() ) :        $my_query->the_post();        echo '
' . get_the_title() . '

' . get_the_excerpt() . '

' . get_the_post_thumbnail() . '
           ' . get_the_title() . '';        endwhile;             wp_reset_query();     ?>      Thanks in advance.


What's the purpose / logic of split_the_query in WP_Query->get_posts

In the get_posts method of WP_Query, there's a section relating to split_the_query The logic of split_the_query is               $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 );      Which can be summarised as. If:   * The calculated query hasn't been modified ($old_request == $this->request)   * And we're just loading posts ("$wpdb->posts.*" == $fields)   * And we've set a limit (!empty( $limits ))   * And that limit is less than 500 rows ($q['posts_per_page'] < 500) Then it triggers this bizarre alternative way to load content. * _Edit: *_ Maybe bizarre is a harsh word, I'm sure there's a purpose, it seems to update some caches in the process :)  It's causing issues with one of my custom post types as it also triggers some weird caching mechanism and I run out of memory. I'm aware I can overwrite it with a hook but I'm wondering what the purpose of it is? Doesn't seem to be documented. It also seems odd to randomly do it for less than 500 rows.


Recent comments from my blogs only

I'd like to create a list of recent comments, specific to each user on my network (Buddypress). My best idea so far is pretty lame: DB Query on all user's blogs, compare dates, select top 10 by date. To me, it sounds a too heavy load for the the server. Any alternative and _better_ ideas? :) Thanks!


Can I integrate Google Analytics with my blog, hosted at wordpress.com?

I have a blog hosted at wordpress.com. How do I integrate it with Google Analytics?


Wordpress front-end post form and email after

I have coded a front-end form that posts to a custom post type, i have a form input field for an email and when the form posts to the custom post type i want an email sent to the email address inserted into the email input when it's submitted. Any ideas?? Edit...Here's my code (forgot lol)               if('POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_booking") {          if(isset($_POST['submit'])) {              $sucess = "We will contact you regarding this booking.";              $errors = "";              if(!empty($_POST['booking_name'])) {             $booking_name = trim($_POST['booking_name']);         } else {             $errors .= "
Please enter your name.
";         }              if(!empty($_POST['booking_email'])) {             $booking_email = trim($_POST['booking_email']);         } else {             $errors .= "
Please enter your email.
";           }              if(!empty($_POST['booking_address'])) {             $booking_address = trim($_POST['booking_address']);         } else {             $errors .= "
Please enter your address.
";         }              if(!empty($_POST['booking_phone'])) {             $booking_phone = trim($_POST['booking_phone']);         } else {             $errors .= "
Please enter your phone number.
";         }              if(!empty($_POST['booking_rooms'])) {             $booking_rooms = trim($_POST['booking_rooms']);         } else {             $errors .= "
Please enter number of rooms.
";         }              if(!empty($_POST['booking_adults'])) {             $booking_adults = $_POST['booking_adults'];         } else {             $errors .= "
Please enter number of adults.
";         }              if(!empty($_POST['booking_arrival'])) {             $booking_arrival = trim($_POST['booking_arrival']);         } else {             $errors .= "
Please enter an arrival date.
";           }              if(!empty($_POST['booking_departure'])) {             $booking_departure = trim($_POST['booking_departure']);         } else {             $errors .= "
Please enter a departure date.
";           }              $booking_requirements = trim($_POST['booking_requirements']);              if(empty($errors)) {             $new_booking = array(                 'post_title' => $booking_name,                 'post_status' => 'publish',                 'post_type' => 'listings',                 'booking_email' => $booking_email,                 'booking_address' => $booking_address,                 'booking_phone' => $booking_phone,                 'booking_rooms' => $booking_rooms,                 'booking_adults' => $booking_adults,                 'booking_arrival' => $booking_arrival,                 'booking_departure' => $booking_departure,                 'booking_requirements' => $booking_requirements             );                  $pid = wp_insert_post($new_booking);                  add_post_meta($pid, 'booking_email', $booking_email, true);             add_post_meta($pid, 'booking_address', $booking_address, true);             add_post_meta($pid, 'booking_phone', $booking_phone, true);             add_post_meta($pid, 'booking_rooms', $booking_rooms, true);             add_post_meta($pid, 'booking_adults', $booking_adults, true);             add_post_meta($pid, 'booking_arrival', $booking_arrival, true);             add_post_meta($pid, 'booking_departure', $booking_departure, true);             add_post_meta($pid, 'booking_requirements', $booking_requirements, true);              }          }      } do_action('wp_insert_post', 'wp_insert_post');


Problem importing categories and sub-categories

I have an array with the categories and sub-categories I want to import to the "campsite-district-county" taxonomy. My sub-categories are not being inserted with the correct parent. They're being inserted on the root level. After some investigation I come across the information that I needed to clear the taxonomy cache after each insert, so I did but I still have the same problem.               $dist[]=array('Açores','Angra do Heroísmo');     $dist[]=array('Açores','Corvo');     $dist[]=array('Aveiro','Águeda');     $dist[]=array('Aveiro','Anadia');     foreach($dist as $d) {         $i++;         if(is_array($d)) {             if ($parent_term=term_exists(trim($d[0]), 'campsite-district-county')) {                 //do nothing - let's add the county bellow             } else {                 //Adds district                 $parent_term=wp_insert_term(trim($d[0]), 'campsite-district-county');                 delete_option("campsite-district-county");                 wp_cache_flush();                 echo '
'.trim($d[0]).'
';                  }             $id_parent=intval($parent_term['term_id']);             echo '
*'.$id_parent.'*
';             //Add county             $child_term=wp_insert_term(trim($d[1]), 'campsite-district-county', array('parent', $id_parent));             delete_option("campsite-district-county_children");             wp_cache_flush();             echo '
'.trim($d[1]).'
';         }     }


Using Wordpress 3.5 Media Uploader in meta box?

Is this possible to do? I love how the new uploader works. I'm guessing it has to do with a jQuery call like the other way did. _EDIT_ This is the code I am currently using               jQuery(document).ready(function($) {     $('.custom_upload_image_button').click(function() {         imageField = $(this).prev('input');         tb_show('', 'media-upload.php?type=image&TB_iframe=true');     });     window.send_to_editor = function(html) {         imgurl = $(html).attr('href');         $(imageField).val(imgurl);         tb_remove();     };     $('.clear_field').click(function() {         var defaultImage = jQuery(this).parent().siblings('.custom_default_image').text();         jQuery(this).parent().siblings('.custom_upload_image').val('');         return false;     });     });


Custom maintenance page

Is there a way to add a custom maintenance page from theme folder? I have the code for the activate maintenance mode but i can't get the styling..               function activate_maintenance_mode() {         if ( !(current_user_can( 'administrator' ) ||  current_user_can( 'super admin' ))) {             wp_die(             '
Website Under Maintenance

Hi, our Website is currently undergoing scheduled maintenance.             Please check back very soon.
Sorry for the inconvenience!
', 'Maintenance Mode');         }     }     add_action('get_header', 'activate_maintenance_mode');      Thanks in advance, Nikola.


_.omit is not function

I have just upgraded Wordpress to the latest version (3.5) and it's now throwing me a Javascript error when I try to add a media : _.omit is not function Please, any help would be really appreciated


Image.php Problem - Post Images Not Displaying In It

When I insert an image into a post and link to that image, the link is sending me directly to the file rather than displaying the image via my image.php template. How can I solve this? I haven't been able to find the solution online. This is not a problem with my [gallery] shortcode, which is bringing me to image.php - just with single images.


The WordPress Gallery, Grabbing The Link and Images?

I have created a template for gallery named image.php which allows me to create a news website style image gallery that can be embedded in posts. But I need two more things to make this complete.   * First, I want to know **how to create a text link to the first image in a gallery** , rather than displaying thumbnails for the gallery as the built-in [gallery] shortcode currently does. For example, check out "click here to start" on this page: http://www.businessinsider.com/android-vs-iphone-debate-quotes-2011-12   * Secondly, if anybody knows **how to generate a list of all the images in a gallery** which I can add to my image.php file that would be great to have so I could use it to create a slider on the bottom of each page featuring an image with the other images in the gallery.


Jquery UI implementation

I have to register the jQuery UI in function file. I don't want it directly in header.php               function my_jquery_ui() {     // register your script location, dependencies and version     wp_register_script('jquery-ui-1.8.16', get_template_directory_uri().'/js/jquery-ui-1.8.16.js', array('jquery'), '1.8.16');     // enqueue the script     wp_enqueue_script('jquery-ui-1.8.16');     }     add_action('wp_enqueue_scripts', 'my_jquery_ui');      According to firebug, the jQuery plugin is registered I'm trying to create tabs which you can see it here: http://www.vmjconsulting.com/wordpress01/testing/#tabs-1 Please Advise.


wpdb->get_var - count author posts, meta value

In an author.php template, i count the author post in a custom post type with $wpdb->get_var,               $post_author = $curauth->ID; //author id     $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = $post_author AND post_type IN ('ideas') and post_status = 'publish'" );      is it possible to count the author, total votes saved in post meta with key 'votes'?   the value for every post is a number updated each time a user votes a post thanks!


Using PHP mail; getting Header warning

I've created a contact form using PHP mail() directly inside a page. It successfully emails te contact information to the recipient. However, it won't advance to the confirmation page identified in header() and outputs the following error: Warning: Cannot modify header information - headers already sent by (output started at /home/redacted/redacted.com/wp-content/themes/diner/includes/theme- functions.php:752) in /home/redacted/redacted.com/wp- content/themes/diner/page.php on line 163 Any advice or resource links on how to fix this?               <?php     function spamcheck($field)       {       //filter_var() sanitizes the e-mail       //address using FILTER_SANITIZE_EMAIL       $field=filter_var($field, FILTER_SANITIZE_EMAIL);            //filter_var() validates the e-mail       //address using FILTER_VALIDATE_EMAIL       if(filter_var($field, FILTER_VALIDATE_EMAIL))         {         return TRUE;         }       else         {         return FALSE;         }       }          if (isset($_REQUEST['contact_email']))       {//if "email" is filled out, proceed            //check if the email address is invalid       $mailcheck = spamcheck($_REQUEST['contact_email']);       if ($mailcheck==FALSE)         {         echo "Invalid input";         }       else         {//send email         $inquirer_name = $_REQUEST['contact_name'] ;         $email = $_REQUEST['contact_email'] ;         wp_mail(     "redacted@gmail.com",     "Subject: Test contact",     "Name: $inquirer_name     Email: $email "     );     header("Location:http://redacted.com/contact-confirmed");         }       } else { //if "email" is not filled out, display the form ?>          <form method="post" action="http://redacted.com/contact">

First Name: <input name="contact_name" type="text" />

Email: <input name="contact_email" type="text" />

<input type='submit' />

          <?php } ?>


Forcing nickname as display_name in custom edit profile template

# Context I've created a front-end "edit profile" template. When I input a value into the nickname text box only the nickname is updated. The default WordPress forum has a select menu that allows/requires the user to select their display_name (a text box for the nickname, a select menu for the display_name). My form doesn't do this because I can't figure out a means of forcing the nickname to update the display_name additionally (i.e. I have a text box for the nickname but not a select menu for the display_name - I want to automate this). display_name is stored in the 'users' table. nickname is stored in the 'users_meta' table. # Code for saving:               <?php     /* Get user info. */     global $current_user, $wp_roles;     get_currentuserinfo();          /* Load the registration file. */     require_once( ABSPATH . WPINC . '/registration.php' );          /* If profile was saved, update profile. */     if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' ) {              /* Update user password. */         if ( !empty($_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) {             if ( $_POST['pass1'] == $_POST['pass2'] )                 wp_update_user( array( 'ID' => $current_user->id, 'user_pass' => esc_attr( $_POST['pass1'] ) ) );             else                 $error = __('The passwords you entered do not match.  Your password was not updated.', 'profile');         }              /* Update user information. */         if ( !empty( $_POST['url'] ) )             update_usermeta( $current_user->id, 'user_url', esc_url( $_POST['url'] ) );         if ( !empty( $_POST['email'] ) )             update_usermeta( $current_user->id, 'user_email', esc_attr( $_POST['email'] ) );         if ( !empty( $_POST['first-name'] ) )             update_usermeta( $current_user->id, 'first_name', esc_attr( $_POST['first-name'] ) );         if ( !empty( $_POST['last-name'] ) )             update_usermeta($current_user->id, 'last_name', esc_attr( $_POST['last-name'] ) );         if ( !empty( $_POST['description'] ) )             update_usermeta( $current_user->id, 'description', esc_attr( $_POST['description'] ) );                            if ( !empty( $_POST['display_name'] ) )             update_usermeta($current_user->id, 'display_name', esc_attr( $_POST['display_name'] ) );        if ( !empty( $_POST['memberlocation'] ) )             update_usermeta($current_user->id, 'memberlocation', esc_attr( $_POST['memberlocation'] ) );        if ( !empty( $_POST['skype'] ) )             update_usermeta($current_user->id, 'skype', esc_attr( $_POST['skype'] ) );                        /* Redirect so the page will show updated info. */         if ( !$error ) {             wp_redirect( get_permalink() );             exit;         }               global $wpdb;          global $current_user;     $current_user = wp_get_current_user();          $user_id = wp_get_current_user();     $nickname = 'testname';     update_user_meta($user_id, 'nickname', $nickname);               }               ?>      # Code for form:               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>             <div id="post-<?php the_ID(); ?>">
                     <?php the_content(); ?>                     <?php if ( !is_user_logged_in() ) : ?>
                                 <?php _e('You must be logged in to edit your profile.', 'profile'); ?>
                     <?php else : ?>                         <?php if ( $error ) echo '
' . $error . '
'; ?>                         <form method="post" id="adduser" action="<?php the_permalink(); ?>">
                                 <?php _e('Add display name *', 'profile'); ?>                                 <input class="text-input" name="nickname" type="text" id="nickname" value="<?php the_author_meta( 'nickname', $current_user->id ); ?>" />

                                 <?php _e('E-mail *', 'profile'); ?>                                 <input class="text-input" name="email" type="text" id="email" value="<?php the_author_meta( 'user_email', $current_user->id ); ?>" />

                                 <?php _e('Member Location *', 'profile'); ?>                                 <input class="text-input" name="memberlocation" type="text" id="memberlocation" value="<?php the_author_meta( 'memberlocation', $current_user->id ); ?>" />

                                 <?php _e('Website', 'profile'); ?>                                 <input class="text-input" name="url" type="text" id="url" value="<?php the_author_meta( 'user_url', $current_user->id ); ?>" />

                                 <?php _e('Password *', 'profile'); ?>                                  <input class="text-input" name="pass1" type="password" id="pass1" />

                                 <?php _e('Repeat Password *', 'profile'); ?>                                 <input class="text-input" name="pass2" type="password" id="pass2" />

                                 <?php _e('Biographical Information', 'profile') ?>                                 <textarea name="description" id="description" rows="3" cols="50"><?php the_author_meta( 'description', $current_user->id ); ?></textarea>

                                 <?php echo $referer; ?>                                 <input name="updateuser" type="submit" id="updateuser" class="submit button" value="<?php _e('Update', 'profile'); ?>" />                                 <?php wp_nonce_field( 'update-user' ) ?>                                 <input name="action" type="hidden" id="action" value="update-user" />
                         </form>                         <?php endif; ?>

                 <?php comments_template( '', true ); ?>                 <?php endwhile; ?>             <?php else: ?>
                     <?php _e('Sorry, no page matched your criteria.', 'profile'); ?>
             <?php endif; ?>      # My question How do I force the display_name to be updated whenever the nickname is updated in my custom page template?


restrict posts per page

I want to display in a _featured slideshow_ only 3 posts, but it is ignored and it shows a lot of posts. How to fix it?               $my_query = new WP_Query(         array(              'posts_per_page' => 3,              'post_id' => $featitem          )     );     while ($my_query->have_posts()) :          $my_query->the_post();


Why is 'pre_get_posts' having no effect?

I'm trying to use pre_get_posts for the first time without any success. It's a very simple piece of code on the index page of an otherwise empty theme, purely to get the hang of the action hook:               function just_one( $query )     {         $query->set( 'posts_per_page', 1 );     }     add_action( 'pre_get_posts', 'just_one' );      From what I have read, I cannot see anything wrong with this, but when I run this below it:               echo get_query_var( 'posts_per_page' );      it displays the default '10', rather than the '1' I was expecting. Am I doing something wrong? The index page is entirely empty apart from the above code. Cheers for any help.


Adding a filter to wp_edit_posts_query() to prevent hierarchical display of pages

So I have a Wordpress 3.3.2 installation with around 8k pages in it now. I seemed to have gotten past a threshold that causes edit.php and the page listing in the admin to take about 20 minutes to load. I've tried multiple server setups, one with a 1GB memory limit, and nothing helped, this is also on a development server so there is no user traffic. I submitted this as a bug, and a developer said that as I could "turn off hierarchical display in edit.php. A filter in wp_edit_posts_query() might be able to accommodate this" as a potential workaround until they fix it in an update. Does anyone know how this can be done? Kind of a repost of Too many pages causes Wordpress admin to be unusable but I narrowed down a possible solution and was hoping to get feedback on that specifically.


How do I ensure custom post type information is displayed in correct order?

I would like to display some category archives below whatever the user has typed in on a custom post type. How do I make sure that the user's content displays above mine?


How to make blog posts appear under different menu items?

On my site, I have a 'blog' menu item and a 'portfolio' menu item. http://richardclunan.com/blog/ http://richardclunan.com/portfolio I'd like to make it so that when I post a blog post, I can determine whether it appears under 'Blog' or under 'Portfolio'. Is it possible to do this? How? I read that it's possible to do this using categories, but I can't get it to work. So perhaps I'm misunderstanding the instructions.


How to programmatically detect how many posts are displayed per page?

Part of a custom post type that I am building needs to simulate page 1 of a category archive. How can I found out how many posts are displayed per page across the WordPress installation? (I assume it is in `wp_options` but I cannot find it.) Thank you!


Adding custom field to Lightbox in header only pulls current page data, not Lightbox item data

I'm currently using Advanced Custom Fields to create a custom field `has_the_portrait_sold` which will be indicated on my Prettyphoto / Lightbox item. However, when I use PHP from the example (it is true or false):               if(get_field('has_the_portrait_sold')){     echo "The item has been sold.";     }else{     echo "The item has not been sold";     }      In header.php:                     However, while this may include the custom field in the lightbox as needed, it apparently only displays custom field data for the current page. I am needing custom field data to print for the current lightbox item / WordPress' image attachment. I therefore tried including the custom field call in `post-template.php`. Please note my PHP skills are limited, I am VERY determined to make this work.               return apply_filters( 'wp_get_attachment_link', "$link_text<?php     if(get_field('has_the_portrait_sold')){     echo "do something";     }else{     echo "do something else";     }     ?>", $id, $size, $permalink, $icon, $text );     }      I feel like I am on the right path in including the custom field call in `post-template.php` . However, I just do not have the PHP skills necessary to create the correct call. I'm wondering if someone here can help. I am very desperate, but not willing to give up. Thanks in advance.


Migrated Wordpress site renders Chinese

So, I have no idea what happened, but I tried to migrate a WP site and for some odd reason, it just renders in all Chinese/Japanese. ![enter image description here](http://i.stack.imgur.com/ZCawv.png) I've been working on this site locally, and it renders fine without errors. I've disabled all of my plugins and nothing changes. I've deactivated the theme and selected another theme, which will work, but then when I select the other theme, it goes back to the asian characters. So, I'm sure it's with the theme, but I have no idea what's different from my local copy versus the one that I've put up on the dev environment. I'm just wondering if anyone has ran into this issue before all. I was using Grunt to compile and compress my SASS files to CSS as well as compress my JS files as well. But I don't know why everything works without issue on my local version versus the one online.


how to json_encode(); the Loop content so that the encoded array is ["0":content, "1":content]

<?php     $dVC=array();     query_posts('meta_key=featuredt&posts_per_page=5');     if (have_posts()) :     while (have_posts()) : the_post();     $dVC []= $post->post_content;?>     <div id="featuredt-<?php echo $wp_query->current_post;?>">     <?php echo get_post_meta($post->ID, 'featuredt', TRUE);?>
     <?php endwhile;     endif;     json_encode($dVC);     ?>      This is my loop at the moment. I need the json encoded variable to look like ["0":content, "1":content] so I can use jQuery.parseJSON() on it. I don't mind people telling me about jQuery.getJSON() but I have less of an idea how to use it then parseJSON. Please provide detailed examples when explaining, I really would appreciate any help I could get though.


How to limit wp_get_archives to show months for the X years only

Can anybody show me how to set a limit on wp_get_archives to show archives by month BUT only those for the year 2010 and above - so the 2009 monthly archives are not shown on the sidebar archive widget. Thank you!


Problem with Wordpress Comment

Im sorry about my english. I have made more than 5 comments on post pages. I have publish all the comments. But there are no comments that appear on the post page. This is my **Comments.php** content:               <?php     /**      * @package WordPress      * @subpackage Default_Theme      */          // Do not delete these lines         if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))             die ('Please do not load this page directly. Thanks!');              if ( post_password_required() ) { ?>
This post is password protected. Enter the password to view comments.
         <?php             return;         }     ?>                    <?php if ( have_comments() ) : ?>
<?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”

         <?php wp_list_comments('avatar_size=58'); ?>

<?php previous_comments_link() ?>

<?php next_comments_link() ?>

           <?php else : // this is displayed if there are no comments so far ?>              <?php if ( comments_open() ) : ?>                            <?php else : // comments are closed ?>
Comments are closed.
              <?php endif; ?>     <?php endif; ?>          <?php comment_form(); ?>          <?php if ( comments_open() ) : ?>

<?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?>

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

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

<input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />     Website
          <?php endif; ?>
<textarea name="comment" id="comment" cols="58" rows="10" tabindex="4"></textarea>

<input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />     <?php comment_id_fields(); ?>
     <?php do_action('comment_form', $post->ID); ?>          </form>          <?php endif; // If registration required and not logged in ?>
          <?php endif; // if you delete this the sky will fall on your head ?>      In my **single.php** , I load the comment using this code: `<?php comment_form(); ?>` Why i using ( `<?php comment_form(); ?>` ) this code, because "Theme Check" required that. Please help me. Thank you


Different Ways to Query Custom Post Types?

I'm using this code to use custom post types like regular post:               add_action( 'pre_get_posts', 'add_my_post_types_to_query' );          function add_my_post_types_to_query( $query ) {     if ( is_home() && $query->is_main_query() )         $query->set( 'post_type', array( 'post', 'miss_behave', 'emily_davies','gemma_patel','poppy_smythe' ) );     return $query;     }      But I also saw this code to display custom post types:               $query = new WP_Query( array(     'post_type' => array( 'post', 'page', 'movie', 'book' )     ) );      I'm wondering what the differences are between the two methods. Thanks.


Facebook meta tags not working properly on WordPress Site

I want tow things in my site. First when any user click on `facebook` button to `share` any post it shwo `image` and `content`, `title` only and the 2nd one is when any one copy the link of my site and directly paste it into `facebook` then it show. site `name`,`logo` and `description`. Now the main problem is i have two option one is i use `meta tag` of `facebook` in header or i can use any plugin in for this. Now i am using `plugin` in Wondermoon's. Now the problem is some post creating little problem. i attach images ![enter image description here](http://i.stack.imgur.com/9z3ut.png)![enter image description here](http://i.stack.imgur.com/xjqHi.png)![enter image description here](http://i.stack.imgur.com/kyPvj.png)![enter image description here](http://i.stack.imgur.com/2uKKQ.png) Now these are 4 images. First three images are when user click on `share` button. And it show different content. The correct one is 3rd. Don't know what is problem with 1st two. And the last image is when any one paste the link of site on facebook. It not show any `logo` or `site` `name`,`description`. So is there any solution for this. Or any `plugin` in. Thanks


How can I serve different images depending on screen size with wordpress

I am creating a responsive WordPress website with a mobile-first approach. When my client uploads an image for a blog post, I would like WordPress to then generate smaller versions of the image (with a smaller file size!) which then get served to smaller screen sizes? Even if the user has to upload several versions of the image themselves, this would still be a good solution. I am aware there is a function called add_image_size, however I believe this only changes the dimensions of the image, and not the actual file size. The different file sizes are the most important thing here. So is there any plugin or code I have to write to enable this? I look forward to hearing any help or advice on this question. Thanks


I want to load post content by categories using Ajax

I have question. I would like to load post content, custom post, depends on category. So first of all I would like to have drop down menu which will list all my categories then once user will select category list of post title will appear in second drop down (post from that particular category) then once that title selected post content will load. All that needs to be done on one page and without reloading so using Ajax. I stacked at the very beginning               <script type="text/javascript">     $(function(){                 $('#main_cat').change(function(){                         var $mainCat=$('#main_cat').val();                              // call ajax                          $("#sub_cat").empty();                             $.ajax({                                 url:"/wp-admin/admin-ajax.php",                                 type:'POST',                                                             data:'action=my_special_action&main_catid=' + $mainCat,                                       success:function(results)                                      {                                     //  alert(results);                     $("#sub_cat").removeAttr("style");                     $("#sub_cat").append(results);                                             }                                        });                               }                                         );     });     </script>      And I found that bit which was inserted into function.php and I do realize that that needs to be modified somehow to pull out posts rather then children of categories               add_action('wp_ajax_my_special_action', 'my_action_callback');     add_action('wp_ajax_nopriv_my_special_action', 'my_action_callback');     function implement_ajax() {     if(isset($_POST['main_catid']))                 {                 $categories=  get_term_by('child_of='.$_POST['main_catid'].'&hide_empty=0');                   foreach ($categories as $cat) {                     $option .= '<option value="'.$cat->term_id.'">';                     $option .= $cat->term_id;                     $option .= ' ('.$cat->category_count.')';                     $option .= '</option>';                   }                        echo '<option value="-1" selected="selected">Scegli...</option>'.$option;                 die();                 } // end if     }     add_action('wp_ajax_my_special_ajax_call', 'implement_ajax');     add_action('wp_ajax_nopriv_my_special_ajax_call', 'implement_ajax');//for users that are not logged in.      Thats as far as i got. Any help will be appreciated


Upgrade to 3.4 error: Call to undefined function get_option()

After running the automated upgrade to 3.4, I receive the message > Fatal error: Call to undefined function get_option() in /.../wp- > admin/admin.php on line 32 I have renamed plugins/ to plugins2/, renamed themes/ to themes2/, created themes/ and placed twentyten in there. Still fails with same error. I have downloaded a copy of 3.4, and uploaded /wp-admin and /wp-includes. Still fails with the same error. When I try to run wp-admin/upgrade.php I receive: "Fatal error: Call to undefined function timer_start() in /.../wp- admin/upgrade.php on line 20" Line 32 of /wp-admin/admin.php is:               if ( get_option('db_upgraded') ) {      I tried manually inserting this option set to true in the wp_options table in phpmyadmin, but the same error remains.


How to display date such "x ago"

I want display date based on how much time has passed since, i. e. _Posted 12 minutes ago_


How can I scale down the width of images in bulk that are embedded in posts throughout the site?

I am building a new WordPress theme and it is quite different from my current theme. Currently the dimensions of my images are much wider than how I would like them to be for my new theme I am developing. Is there way to scale down the widths programmatically and in mass? Is there a plugin that accomplishes this task?


User profile Pick a premade Design/theme

i currently have been working on a huge project for the last few months and im not a big coder myself but i know a bit, so i needed help, i wanted to assign each user with a already premade design kinda like twitter has you preview the design/with icons and live preview/ were they can pick a few premade designs, if they desire it of course if possible but it seems i run into issue because my lack of skills , its kinda would be a custom design for each user ?… its this possible or is there another alternative? like can i provide custom images/backgrounds, they can pick as there background at least that.. i really hope someone can help me out thank you, have a nice day.!


Search results from a specific database table

I have to display search results using the wordpress search, but searching in a database table that's not from the wordpress tables. So, for example, if my table's name is "customers", how can I write the code for do that search? Thanks a lot