Output Buffer Issue with Single Post View

I created the following function that I am using to load single post views:               // Post     function basey_single_post() {              global $post;         ob_start();              echo apply_filters('basey_page_title_news', __('
News
','basey')); ?>         <?php basey_post_before(); ?>         <article <?php post_class() ?> id="post-<?php the_ID(); ?>">             <?php basey_post_inside_before(); ?>                                      <?php echo apply_filters('basey_post_title', '
'.get_the_title().'
'); ?>                     <?php basey_entry_meta($post->ID); ?>
                         <?php echo __('Posted in ','basey'); the_category(', '); ?>
                     <?php $tag = get_the_tags(); if (!$tag) { } else { ?>
<?php the_tags(); ?>
<?php } ?>
<?php comments_popup_link( __( ' 0 Comments', 'blank' ), __( ' 1 Comment', 'blank' ), __( ' % Comments', 'blank' ), 'comments-link', __('Comments closed', 'blank')); ?> <?php if ( comments_open() ) : ?>| <a href="<?php the_permalink(); ?>#respond" title="<?php echo __('Add a Comment','basey'); ?>"><?php echo __('Add a Comment','basey'); ?><?php endif; ?>

                     <?php the_content(); ?>
                                      <?php wp_link_pages(array('before' => '
' . __('Pages:', 'basey'), 'after' => '
' )); ?>                              <?php basey_post_inside_after(); ?>             <?php comments_template(); ?>
         <?php basey_post_after();              $display = apply_filters('basey_single_post_view',ob_get_clean());         return $display;     }      and am then overriding it when needed like so:               // Post     function basey_single_post_override() {              global $post;         ob_start();              echo 'TEST ADDITION';              echo apply_filters('basey_page_title_news', __('
News
','basey')); ?>         <?php basey_post_before(); ?>         <article <?php post_class() ?> id="post-<?php the_ID(); ?>">             <?php basey_post_inside_before(); ?>                                      <?php echo apply_filters('basey_post_title', '
'.get_the_title().'
'); ?>                     <?php basey_entry_meta($post->ID); ?>
                         <?php echo __('Posted in ','basey'); the_category(', '); ?>
                     <?php $tag = get_the_tags(); if (!$tag) { } else { ?>
<?php the_tags(); ?>
<?php } ?>
<?php comments_popup_link( __( ' 0 Comments', 'blank' ), __( ' 1 Comment', 'blank' ), __( ' % Comments', 'blank' ), 'comments-link', __('Comments closed', 'blank')); ?> <?php if ( comments_open() ) : ?>| <a href="<?php the_permalink(); ?>#respond" title="<?php echo __('Add a Comment','basey'); ?>"><?php echo __('Add a Comment','basey'); ?><?php endif; ?>

                     <?php the_content(); ?>
                                      <?php wp_link_pages(array('before' => '
' . __('Pages:', 'basey'), 'after' => '
' )); ?>                              <?php basey_post_inside_after(); ?>             <?php comments_template(); ?>
         <?php basey_post_after();              $display = ob_get_clean();         return $display;     }     add_filter('basey_single_post_view','basey_single_post_override');      Getting this error though: `Fatal error: Cannot redeclare basey_comment() (previously declared in /home/usr/public_html/dev/wp- content/themes/basey/comments.php:1) in /home/usr/public_html/dev/wp- content/themes/basey/comments.php on line 26` which looks like:               <?php function basey_comment($comment, $args, $depth) {         $GLOBALS['comment'] = $comment; ?>         <li <?php comment_class(); ?>>             <article id="comment-<?php comment_ID(); ?>">                                      <?php echo get_avatar($comment,$size='32'); ?>             <?php printf(__('%s', 'basey'), get_comment_author_link()); ?>             <time datetime="<?php echo comment_date('c'); ?>"><a href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)); ?>"><?php printf(__('%1$s', 'basey'), get_comment_date(),  get_comment_time()); ?></time>             <?php edit_comment_link(__('(Edit)', 'basey'), '', ''); ?>                                 <?php if ($comment->comment_approved == '0') { ?>
               ×
<?php _e('Your comment is awaiting moderation.', 'basey'); ?>

           <?php } ?>
                     <?php comment_text() ?>
                <?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
     <?php } ?>          <?php if (post_password_required()) { ?>

           ×
<?php _e('This post is password protected. Enter the password to view comments.', 'basey'); ?>

         <?php             return;     } ?>          <?php if (have_comments()) { ?>

<?php printf(_n('One Response to “%2$s”', '%1$s Responses to “%2$s”', get_comments_number(), 'basey'), number_format_i18n(get_comments_number()), get_the_title()); ?>

           <?php wp_list_comments(array('callback' => 'basey_comment')); ?>
              <?php if (get_comment_pages_count() > 1 && get_option('page_comments')) { // are there comments to navigate through ?>
<?php previous_comments_link(__('← Older comments', 'basey')); ?>

<?php next_comments_link(__('Newer comments →', 'basey')); ?>
                               <?php } // check for comment navigation ?>              <?php if (!comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')) { ?>
<?php _e('Comments are closed.', 'basey'); ?>
         <?php } ?>
     <?php } ?>          <?php if (!have_comments() && !comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')) { ?>

<?php _e('Comments are closed.', 'basey'); ?>

     <?php } ?>          <?php if (comments_open()) { ?>

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

<?php cancel_comment_reply_link(); ?>
         <?php if (get_option('comment_registration') && !is_user_logged_in()) { ?>
<?php printf( __('You must be logged in to post a comment.', 'basey'), wp_login_url( get_permalink() ) ); ?>
         <?php } else { ?>         <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">             <?php if (is_user_logged_in()) { ?>
<?php printf(__('Logged in as %s.', 'basey'), get_option('siteurl'), $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php __('Log out of this account', 'basey'); ?>"><?php _e('Log out »', 'basey'); ?>
             <?php } else { ?>           <?php _e('Name', 'basey'); if ($req) _e(' (required)', 'basey'); ?>                 <input type="text" class="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?>>           <?php _e('Email (will not be published)', 'basey'); if ($req) _e(' (required)', 'basey'); ?>                 <input type="email" class="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?>>           <?php _e('Website', 'basey'); ?>                 <input type="url" class="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3">             <?php } ?>           <?php _e('Comment', 'basey'); ?>             <textarea name="comment" id="comment" class="input-xlarge" tabindex="4"></textarea>             <input name="submit" class="btn btn-primary" type="submit" id="submit" tabindex="5" value="<?php _e('Submit Comment', 'basey'); ?>">             <?php comment_id_fields(); ?>             <?php do_action('comment_form', $post->ID); ?>         </form>         <?php } // if registration required and not logged in ?>
     <?php }      Any help would be GREATLY appreciated on this - at my whits end here. Thanks! _EDIT:_ This may be more of a question about correctly using the output buffer and/or WP filters effectively. Thanks!


How to get gallery id inserted to a post?

Is it possible to get a specific Gallery ID inserted to a post in wordpress 3.5? I want to load gallery from post using Ajax. I use shortcode `[gallery]` to do it. But when I use it this way:               echo do_shortcode('[gallery id="'.$_POST['postid'].'"]');      I get all images attached to the post with $_POST['postid'] and not images from the gallery which is inserted to that post.


How to Rename wp-login.php for Multisite?

I want to hide and rename `wp-login.php` in my URL for branding purposes on a Multisite set up. From this forum post I see that I can change `mysite.com/wp-login.php` to `mysite.com/login` by inserting a `RewriteRule ^login$ wp-login.php ` in my `.htaccess`. I like that the URL bar does not show login redirecting to wp- login. If I try to login under a subsite `mysite.com/subsite1/login` it shows as redirecting from `mysite.com/subsite1/wp-login` to `http://mysite.com/subsite1/wp- login.php?privacy=1&redirect_to=%2Fsubsite1%2Flogin`   1. How do I get it to show as `mysite.com/subsite1/login` without the redirect in the URL bar?   2. If I enter `mysite.com/wp-login.php` it shows as page not found. Great!   Now if I enter `mysite.com/subsite1/wp-login.php` it shows as the page exists. Oh no!   How do I hide that this page exists for subsites? I tried the `functions.php` suggestion in my child theme but it created a redirect loop.


Non-standard (new) theme file

in default theme files i.e. index.php, single.php etc. i can use all the WP functions normally. But if i create a new theme file, for example custom- file.php and place it in the theme folder, i don't have access to default WP functions like get_header, etc... Is there anything that could be included in custom files to make them recognized by WP as a part of the theme?


Different 'read more' links

Is there an easy way to add another 'read more' link? I'm using the standard 'continue reading' link for some posts but I also want to use a different text like 'more info' for other posts. Can I do this using `the_excerpt`? Later update: This are the two standard twentyelven functions that are used for the 'read more' or 'continue reading' links.               function twentyeleven_continue_reading_link() {         return ' ' . __( 'more +', 'twentyeleven' ) . '';     }     function twentyeleven_auto_excerpt_more( $more ) {           return ' …' . twentyeleven_continue_reading_link();     }     add_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' );      Based on amit code I though about including an `if / else` statement in the `twentyeleven_auto_excerpt_more` function, but I did something wrong because it doesn't work. This is the code:               function twentyeleven_auto_excerpt_more( $more ) {     $read_more_link_2 = "View Image";     if ( in_category( 'events' )) {         return $read_more_link_2;     } else {             return ' …' . twentyeleven_continue_reading_link();     }     add_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' );      I think it's obvious that PHP is not my strong point.


block seacrh engines for all pages EXCEPT homepage

I have a question. Most of my site is password protected, so it is not indexed by search engines. In other words, they don't show up in searches - this is good. There are, however about 40 or so pages that are not password protected, so they show up in searches - this is not good. I read an interesting bit here at "Yoast": https://yoast.com/prevent-site-being-indexed/ which discusses using: Header set X-Robots-Tag "noindex, nofollow" in the .htaccess file. According to Yoast, it seems to be a preferred method for blocking all pages. But, I want to block all pages and allow only just one page - my main homepage. How can I do this? Is there additional code that I can add to the above example? Please advise. Regards, Steve


Defining capabilities for custom post type

On creation of a custom post type I'm trying to define capabilities but it's not working. What's wrong with this code?               $args = array(       'labels' => $labels,       'public' => true,       'publicly_queryable' => true,       'show_ui' => true,       'query_var' => true,       'rewrite' => true,       'hierarchical' => false,       'menu_position' => null,       'supports' => array('title'),       'capabilities' => array(        'edit_post' => 'edit_video',        'edit_posts' => 'edit_videos',        'edit_others_posts' => 'edit_others_videos',        'publish_posts' => 'publish_videos',        'read_post' => 'read_videos',        'read_private_posts' => 'read_private_videos',        'delete_post' => 'delete_videos'        )        );


display recent posts title in a text box on home page

I've created two text boxes on my home page using z-edity short code and I want to display recent posts titles as a marquee text in the first link and some text also as marquee in the second box. Any help ?


Members area with externally-managed htaccess / htpasswd authentication?

I am looking at the feasibility of converting a client's site from countless hand-built web pages to a WordPress installation. The challenge is that we have a free area and a members-only area. The members-only area is a folder protected by standard Apache .htaccess / htpasswd authentication. The password folder is externally managed by legacy billing software that we do NOT want to change. I think the best answer might be to do TWO WordPress installs, one at the domain root and one inside the members folder. That way neither install needs to be aware of the Apache authentication. I have the impression that MultiSite would not serve my purpose, because I need a real physical members area folder. I'm not sure the "virtual" feature would get me what I want - both the url rewriting and triggering the htpasswd authentication. I've searched the boards and plugin repositories related to members or otherwise private areas. All solutions I can find assume that the members are managed via WordPress. That's not the case for me! I'm intending to use WordPress for the content management, and leave WordPress unaware of the authentication issue. Does a double install sound feasible and the right approach? Can I just do a double install to a single MySQL database, just specifying a custom table prefix (not wp_) for the second install?


What does do_action() function do in wordpress?

In my wordpress project I have seen several times the use of `do_action()` function. I don't know the working of this function, nor why we call it or where we use it? Can someone please explain this to me?


How to implement pagination in backward way eg. first - 20 - 19 - 18 - ... - 3 - 2 - 1 - last

How can I implement pagination in backward style, like shown in the title. (newest) first - 20 - 19 - 18 - ... - 3 - 2 - 1 - last (oldest) I have search plugin, there are not yet plugin for this. Because I want static pagination result, for SEO, I hope I'm not wrong with this opinion. Thank You. **EDIT** I try to explain with sample. eg.: every page limit by 3 posts and have total 15 posts (total 5 pages). The position in Blog Home Default is page 5 (because the latest pages are 5). So the blog home display like this:               (date) - Title     **15** Jan 2011 - A dummy title     **14** Jan 2011 - A dummy title     **13** Jan 2011 - A dummy title     pagination display: (5) - 4 - 3 - 2 - 1      And if I click page 4, content entry not display correctly, it display like this:               (date) - Title     **06** Jan 2011 - A dummy title     **05** Jan 2011 - A dummy title     **04** Jan 2011 - A dummy title     pagination display: 5 - (4) - 3 - 2 - 1      Instead of that, page 4 should be like this:               **12** Jan 2011 - A dummy title     **11** Jan 2011 - A dummy title     **10** Jan 2011 - A dummy title     pagination display: 5 - (4) - 3 - 2 - 1      > notes: I also put sample with **date** , to make it clear sample. How can this will happen without touching the core Wordpress? Thank You.


WordPress Widget multiple use

I created this widget using a simple example on WordPress Codex:               <?php          function widget_container_latest_posts() {                                  global $wpdb;                       global $post;                                     get_template_part( '/includes/containers/container-latest-posts' );     }          wp_register_sidebar_widget(         'widget_container_latest_posts_1',         'Container Latest Posts',         'widget_container_latest_posts',         array(          'description' => 'Container Latest Posts - Adds recent posts.'         )     );     ?>      It works fine, but I want this widget to be used multiple times not only one time after I drag it on a sidebar widgets place, and so I can add it on all the other sidebars for example. Thank


Generic taxonomy-term template page

because of my taxonomy hierarchy, my taxonomy-type.php template is already used, is there a way to have only one taxonomy-type-term.php template ? I've got 13 sub terms, do I need to create 13 taxonomy-type-[term].php templates ? Thanks. Cyril


How to diagnose and keep in check encoding issues?

What we have for a project is:   * multiple sites (production, test, local development);   * migrated by multiple methods (PHPMyAdmin, Navicat, BackupBuddy); And the issue we are having is that **while original production site seems to work fine, rest of the installations are constantly plagued by text encoding issues**. Original site is configured with `latin` MySQL tables, but WP is configured and serves pages as `UTF-8`, which I was told (in our chat) is already problematic. Rest of sites (whose databases mostly mirrors original production site) display issues such as:   * broken characters (correctable by tweaking WP encoding settings);   * broken characters (not correctable by tweaking WP encoding settings);   * site working fine, but feeding broken characters to external libraries. Since I had tried to untangle this for a while and there isn't much info on diagnosing encoding issues in WP, my questions are following:   1. How to reliably diagnose if site has encoding configuration issues, even if it might not display them under normal circumstances?   2. Which rules should be formulated, put into documentation and enforced to prevent encoding issues on migration?


Assign one featured image to multiple posts?

I have implemented a front-end form to submit posts. The image upload is handled with the Wordpress Media Library   1. Users click on "Upload Image"   2. Media Library opens   3. Users either select an existing image or upload a new one   4. The path to the image (URL) gets populated into an `<input>` field  **Problem:** My question concerns the featured image: If users choose an **existing** image from the Media Library, this image get's added to the Media Library again, which I wanted to avoid for two reasons: a) Save disk space   * Right now I have one image saved twice:`http://localhost/?attachment_id=2523` as well as `http://localhost/images/picture.jpg` b) Avoiding duplicates in Media Lirbary   * Users can access the Media Library from the front-end and I don't want them so see duplicate images **Is it possible to assign one image as a featured image to multiple posts?** Here's what I got:                   // $featuredimg contains the URL to the image: http://mydomain.com/wp-content/uploads...              $filetype = wp_check_filetype( basename( $featuredimg ), null );         $wp_upload_dir = wp_upload_dir();              // Prepare an array of post data for the attachment.         $attachment = array(                 'guid'           => $wp_upload_dir['url'] . '/' . basename( $featuredimg ),              'post_mime_type' => $filetype['type'],             'post_title'     => preg_replace( '/\.[^.]+$/', '', basename( $featuredimg ) ),             'post_content'   => '',             'post_status'    => 'inherit'         );                   $thumb_id = wp_insert_attachment( $attachment, $featuredimg,  $pid );              // Make sure that this file is included, as wp_generate_attachment_metadata() depends on it.         require_once( ABSPATH . 'wp-admin/includes/image.php' );              // Generate the metadata for the attachment, and update the database record.         $attach_data = wp_generate_attachment_metadata( $thumb_id, $featuredimg );         wp_update_attachment_metadata( $thumb_id, $attach_data );              update_post_meta( $pid, '_thumbnail_id', $thumb_id );


How can I change my assigned user role in WordPress 3.5.1?

My current user role is "Administrator". I'd like to change my role to "Editor" (through out database field). I read Database_Description, but it did not help.


Restrict acceess of a page in backend

How can I restrict editing of a page from backend only to a specific user? I tried a few plugins but I thought doing it without plugins would be the way to go for me. What measures I can take to solve this?


How to hide fields from my user profiles

I want to hide the fields link `nick name`, `first name`, `last name`, etc. I could not find an answer in the codex and I do not want to touch the core files.   Is there any solution for it?


Plugin: How should I handle deleting comments?

I am writing a plugin that creates an api for a custom post type. Users can comments on the custom post types and the comments are added using WP core comment methods. My question arises when trying to deal with what to do when deleting a comment. I understand what methods to use, but my question is more about the general procedure. When you make a comment it can be a reply to another comment. If the parent commenter decides to delete their comment, what should be done with replies? Should they be deleted as well? Should their parent pointer just move one up the tree? You could also replace the deleted comment content with a message like, 'Comment deleted'. Like a placeholder. Then the replies could keep the same parent pointer, but they would lose the context of the original parent comment's content. Am I overthinking this?


XML parser plugin

I have an XML data source that updates daily. Is there a plugin that will allow me to create a query and update it daily with the least programming possible and display the data on a page?


How can I show my scheduled posts in Google Calendar?

I typically schedule posts well in advance before they get published. At times I can have as many as 5-10 scheduled posts set to be published within the coming weeks. Is there a way to show a calendar with all my scheduled posts? Ideally I would like to see them in Google Calendar.


Plugin for editing options on multisite?

does anyone know of a plugin for mass editing of settings on a multisite installation? Something like Plugin Commander for Settings?


foreach,having wp_query inside, breaks after showing one result

I am trying to make category tabs that show posts from selected category tab. I have tried it my way but m getting only one post for each category, whereas it should return all post in that category. I am pasting the code below, can anyone help me sort this issue ?
                             <?php         $args = array(           'orderby' => 'name',           'parent' => 13           );         $categories = get_categories( $args );     $i=0;     foreach ( $categories as $category ) {         $i++;         echo '
name)).'" href="dtab'.$i.'">' . $category->name . '
';     }     ?>

          <?php     $pargs = array(       'orderby' => 'name',       'parent' => 13       );     $categories_loop = get_categories( $pargs );     foreach ( $categories_loop as $category_loop ) {     query_posts('category_name='.$category_loop->slug.'&posts_per_page=-1&order=desc'); $j=0;     ?>     <?php if ( have_posts() ) : ?>       <?php while ( have_posts() ) : the_post();        $j++ ?>                             <div class="tab-pane" id="dtab<?php echo $j ?>">

                                 DATE	                                 TITLE	                                 SIZE
                         <?php          $file_size = rwmb_meta('file_size');         $file_url = rwmb_meta( 'file_url');       ?>
                                 <?php the_time('d/m/Y'); ?>	                                 <?php the_title(); ?>	                                 <?php echo $file_size; ?>	                                 <a href="<?php echo $file_url ?>" class="button3 download_btn" target="_blank">DOWNLOAD

              <?php          endwhile;  ?>
<?php //previous_posts_link('PREV'); ?>

<?php //next_posts_link('NEXT',$download_query->max_num_pages); ?>
     <?php wp_reset_query();?>     <?php else:  ?>
<?php _e( 'Sorry, no content found.' ); ?>
     <?php endif;      } ?>


How do I display the featured image from an image gallery using a reference in code? (example within)

I've been trying to get the featured image of a post to be displayed outside of the loop for all the image thumbnails. That way, the featured image (of a product) is displayed in large and the thumbnails just below it. All the images in the (product) post are set in their own gallery of images. Please see comment in code- the place where I'm trying to get the featured image to be displayed. I'm sure I'm just missing something easy! Thanks!!               if (themedy_get_option('product_gallery')) { add_action('genesis_post_content', 'themedy_product_images', 1); }     function themedy_product_images() { ?>         <?php          global $post;         $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => 999, 'order'=> 'ASC', 'orderby' => 'menu_order' ) );          if ( $images ) { ?>
     <?php     //How do I insert the featured image of the post over here     ?>

                 <?php                 foreach ( $images as $image ){                     $gallery_image_info = wp_get_attachment_image_src( $image->ID, 'full' );                     $gallery_image = $gallery_image_info[0];                          $gallery_thumb_info = wp_get_attachment_image_src( $image->ID, 'Gallery Thumb' );                     $gallery_thumb = $gallery_thumb_info[0];                          $gallery_image_alt = get_post_meta($image->ID, '_wp_attachment_image_alt', true) ? trim(strip_tags( get_post_meta($image->ID, '_wp_attachment_image_alt', true) )) : trim(strip_tags( $image->post_title ));                          echo '';                 }                 ?>

      If I use:               <?php the_post_thumbnail(); ?>      It Outputs:                     The image is way too big :( I need it to output with the following class..               class="alignnone size-large wp-image-6593"


Move value from one meta key to another

Migrating question: How would I structure a MySQL query to move the value from one meta_key to another meta_key? eg: I have an old meta_key of "guest_sort" associated with "posts" to "tf_exhibitor_sort" under the post type "exhibitor_listing" I've already moved the posts from the original post category over to the post_type. Still possible, or am I outta luck and will have to do some data- entry? Thanks.


How does wordpress know which site to setup (on multisite)?

Ok for subdomain it's easy. I guess it just looks up the subdomain: `blog5.site.com` => `explode('.', $_SERVER['REQUEST_URI'])...` But how does it do it for sub-directory setups? This should be interesting considering that pages, taxonomies and what not can take the first part of the part after the site domain name. How can it distinguish between a inner blog, and a page of the primary blog? The only thing I could think of is database matching against the entire blog list, then if it fails match primary blog content, but that would be a really stupid thing to do because it seriously slows down the site...


How to specify the "Main Sidebar" for a theme

When I install and activate my theme, it places all of the default sidebar widgets into the first sidebar widget that appears at the top of my theme's widget collection. However, since that widget area is a header widget, those elements distort my theme's default view when first activated (the header area gets stretched to tall to accomodate all of those widgets). I believe this is happening because the header widget happens to be the first sidebar I'm registering in functions.php Is there a way, short of rearranging the order of my sidebar widgets, to specify which sidebar the default widgets get assigned to? I understand that I can rearrange the order in which I register the sidebars and the default sidebar widgets will be placed into the first one. However, in my case, I want my "header" sidebar to appear first so that it accurately reflects the top to bottom layout order of the actual widget areas. But I don't want the default sidebars to be placed into the "header" sidebar. I want them placed into the "Sidebar" sidebar (the 2nd one registered as you can see from the code below)               /* SIDEBARS     *******************************/          register_sidebar(array(         'name' => 'Header',         'id' => 'home-header-widget',         'before_widget' => '
',         'after_widget' => '
',         'before_title' => '',         'after_title' => '',     ));          register_sidebar(array(         'name' => 'Sidebar',         'id' => 'home-sidebar-widget',         'before_widget' => '
',         'after_widget' => '
',         'before_title' => '
',         'after_title' => '
',     ));


Allowed memory size of 33554432 bytes exhausted (tried to allocate 9967617 bytes) in ...\wp-includes\functions.php

When a script times out, and there is nothing you can do about it ( cause it's running on a bloddy shared hosted resource where you have 0 control over the script time-outs ), can you run register shutdown or something to that effect? You may ask what on earth does this question have to with wordpress... Well, it kind of does. in my migration routine, I process a 10,000 record table and do some heavy duty parsing. I have to do select * cause I need everything there. The page eventually times out. Next time I run the same page I get a Allowed memory size of 33554432 bytes exhausted (tried to allocate 9967617 bytes) in ...\wp- includes\functions.php on line 3335 No plug ins involved, no settings changed. I can generate this error whenever I want. So don't say check your last actions & plug ins and all that pls. This is on a vanilla version, the one you get after the 5 min install. Well, my first instinct was to run the mysql_free_result over that RS! but the question is at what point? the perfect point for this would be just before the time out occurs. Thus the need for shutdown function... but the question is how do I make it in there?


What is the ID parameter for custom post types in query_posts?

In the Admin section I'm using quesry posts to get the title and content of a custom post this query_posts('post_type=sfnewsletter'); will get me the content I need but unfortunately what I need to do now is to pass the ID of the custom post via a form and then retrieve that content I've tried               query_posts('p=32');       query_posts('page_id=32');       query_posts('page=32');       query_posts('sfnewsletter_id=32');        And not only do I not get the right custom post some of them return a post with an ID of 14 (not the first or last post) I have confirmed that 32 is the correct ID for the custom post I am trying to get. THIS IS THE FORM It passes the ID correctly                       <form method="post" action="<?php echo sfn_form_url(); ?>" >

<?php _e( 'To', 'sfnewsletter' ); ?>	                                                      <select name="sfnewsletter_to" id="sfnewsletter_to">                             <option value="0">Please Choose</option>                             <?php wp_dropdown_roles() ?>                             </select>

<?php _e( 'Newsletter', 'sfnewsletter' ); ?>	                                                      <select name="sfnewsletter_newsletter" id="sfnewsletter_newsletter">                             <option value="0">Please Choose</option>     <?php                              query_posts('post_type=sfnewsletter');                              if (have_posts()) : while (have_posts()) : the_post();                                      echo '<option value="' .get_the_ID(). '">' .get_the_title(). '</option>';                                  endwhile; endif;          ?>                             </select>

                     <input id="sfnewsletter_hidden" class="regular-text" type="hidden" name="sfnewsletter_hidden" value="<?php esc_attr_e( 'SEND' ); ?>" />                     <input type="submit" class="button-primary" value="<?php _e( 'Send Message', 'sfnewsletter' ); ?>" />
             </form>      THIS IS THE SOLUTION I CAME UP WITH. THE ANSWER I HAVE ACCEPTED THE RIGHT WAY TO DO IT THOUGH, MY WAY IS A FUDGE * * * ok, I have come up with a work around that suits my situation. Since I don't seem to be able to use my custom post ID in the query I have used the ID from the form and converted it into the permalink and then used that in the query like so                   $sfnewsletter_slug = basename( get_permalink($sfnewsletter_newsletter) );              $the_query = new WP_Query( array( 'post_type' =>'sfnewsletter', 'posts_per_page'=>1, 'name'=>$sfnewsletter_slug ) );      This gives me the output I am looking for. * * *


Loop for custom post types filtered by a taxonomy

I am using the Custom Post Type feature in Wordpress 3 to create an Events section for my website. I am able to get this to display by using the relevante template files, but I also want the event listings visible on other pages. I've done this with the normal post types but these are based on category IDs which Custom Post Types don't have. Each event has a taxonomy for country and I want to be able to loop through the events and display only events for specific countries so I want to be able to filter that. I've had a look on the Codex and came up with the following but it doesn't display anything:                   <?php $args = array(                     'post_type'=> 'events',                     'country'    => 'england'               );                 $the_query = new WP_Query( $args );                            if ( $the_query->have_posts() ) :                      // The Loop                 while ( $the_query->have_posts() ) : $the_query->the_post();                     echo '<li>';                     the_title();                     echo '</li>';                 endwhile;                      endif;                      // Reset Post Data                 wp_reset_postdata();         ?>


Thumbnail images

Is there any way to auto-generate a 150x150 thumbnail image for each post based on the post's selected featured image? This would be preferable as opposed to manually going into each post, copying the images 150x150 image URL and pasting it thumb custom field.


Adding additional text fields and image upload to a Page?

I have a contact page: ![enter image description here](http://i.stack.imgur.com/oeHb9.png) I would like to add an additional text field below the text editor and another image upload button. And then display it in the template as something like this:               <?php echo get_field('address')?>     <?php echo get_field('photo')?>      Is there an easy way of doing this on WordPress 3.5+?


Serialized Data

I'm trying to add data to a serialized string - I get the serialized string from my database - e.g. a:1:{i:0;s:2:"32";} Unserialize it add a value to it e.g. 128 serialize it and save it back But I get s:33:"a:2:{i:0;s:2:"64";i:1;s:3:"128";}"; Where did the s:33 come into it and surrounded the rest in quotes and ends with a semi colon?                   function addItem($serializedArray, $item)         {            $a = unserialize($serializedArray);            $a[] = $item;            return serialize($a);          }              $lp = $wpdb->get_results( $wpdb->prepare("Select MemNo from YP_Members Limit 0,    10") );                foreach ($lp as $userid){            $user_id = $userid->MemNo;             $meta_value = $wpdb->get_var( $wpdb->prepare("Select meta_value from  iropiusermeta Where meta_key = 'user_iro_area' AND user_id = $user_id") );                       echo "User=".$user_id."
Value=".$meta_value."
";                                      if ($meta_value){                                           $user_iro_area = addItem($meta_value, "128");                                 update_user_meta($user_id, 'user_iro_area_new', $user_iro_area);                                      } else {                             // Add meta_key user_iro_area                             echo "Add New Me
";                             $iro_group_num[] = "128";                             $user_iro_area = serialize($iro_group_num);                                              update_user_meta($user_id, 'user_iro_area_new', $user_iro_area);                                }                                          } // End of Main While Loop


Error after create a new site in a multisite wordpress install

After I access wp-signup.php and create a new user and site, the site is created normally, but appear the error: > Warning: sprintf() [function.sprintf]: Too few arguments in > /home/storage/1/b1/0c/liquidasites2/public_html/wp-includes/ms-functions.php > on line 1271 Any suggestions?


Why my htacess rewrite return 404?

Here is my `.htaccess` file               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteRule ^abc/products-(.+)$ def/products-$1 [R=301,L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /wp/index.php [L]     </IfModule>      I have many url links in /abc/ sub-directory, like               http://www.domain.com/abc/products-12345     http://www.domain.com/abc/products-23456     http://www.domain.com/abc/products-34567     http://www.domain.com/abc/new-items      Now I want to url rewrite /abc/products- to /def/products-               http://www.domain.com/def/products-12345     http://www.domain.com/def/products-23456     http://www.domain.com/def/products-34567     http://www.domain.com/abc/new-items      the code: `RewriteRule ^abc/products-(.+)$ def/products-$1 [R=301,L]` could make the page redirect, but the it when type `http://www.domain.com/abc/products-12345` the browser will go to `http://www.domain.com/def/products-12345` but the page show as `404`. If I remove it, `http://www.domain.com/abc/products-12345` could run well. Why and How to? Thanks. **Update:** I have moved `RewriteRule ^abc/products-(.+)$ def/products-$1 [R=301,L]` ahead of `RewriteRule ^index\\.php$ - [L]` still get `404`. And I add `echo get_query_var('page_id');` in `404.php`, this return `0`. why the url could redirect but miss the right page?


How do I stop a widget from displaying on mobile site?

On my main site I have used the search widget in the sidebar. However, the mobile theme I am using (minileven) already has a search box built into its menu bar. This results in a second search box in the sidebar (which appears after the post content) due to the widget. How do I stop the search widget appearing on the mobile site? This is the code for `sidebar.php` from the mobile theme:               <?php     /**      * The Sidebar containing the main widget area.      *      * @package Minileven      */     ?>             <?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>                     <div id="secondary" class="widget-area" role="complementary">                             <?php dynamic_sidebar( 'sidebar-1' ); ?>                     </div><!-- #secondary .widget-area -->             <?php endif; ?>      Alternatively, would it be better not to use the search sidebar widget and have the search box hardcoded into the main site theme? Is it usual for WordPress themes to do that? (I am planning on publicly releasing the WordPress theme I have made).


Take excerpt of the content of the post and send it as the title to create new post

Explaining my goal: I would create the title by taking the first words of the post content. Ex: In the Admin interface would be the title field blank and the first 10 words of content would be sent as a title when creating a new post. Thanks for any help.


Pagination: How do I always show 'previous'?

I am using the following code for my pagination.               // Pagination     function my_paginate_links() {         global $wp_rewrite, $wp_query;         $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;         $pagination = array(             'base' => @add_query_arg('page','%#%'),             'format' => '',             'total' => $wp_query->max_num_pages,             'current' => $current,             'prev_text' => __(''),             'next_text' => __('next »'),             'end_size' => 1,             'mid_size' => 2,             'show_all' => true,             'type' => 'list'         );         if ( $wp_rewrite->using_permalinks() )                 $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );         if ( !empty( $wp_query->query_vars['s'] ) )                 $pagination['add_args'] = array( 's' => get_query_var( 's' ) );         echo paginate_links( $pagination );     }      When it's on the first page, the 'previous' link doesn't show. I understand why but I'd like it to show because I am designing the site a certain way. Is there a part of the code above I can change to make this happen? I have read through the codex regarding this but couldn't find an answer that made sense to me. I'd appreciate any guidance. Thank you.


Re writing Category Argument

I have a theme which has a category argument, however its displaying them in the wrong order               <?php                        $categories=  get_categories('taxonomy=types&title_li='); foreach ($categories as $category){ ?>      I want it to display this in the slug say for example so that they can be in order. Would it be a case i add the following argument?                 <?php                        $categories=  get_categories('taxonomy=types&title_li=' 'orderby'  => 'name',); foreach ($categories as $category){ ?>      this is the full category query, is just putting it in the wrong order:               <?php  $categories=  get_categories('taxonomy=types&title_li='); foreach ($categories as $category){ ?>          <?php //print_r(get_term_link($category->slug, 'types')) ?>
<a href="<?php echo get_term_link($category->slug, 'types') ?>" class="<?php echo $category->category_nicename;?>" data-type="<?php echo $category->category_nicename;?>"><?php echo $category->name;?>


How to delete all posts, categories and tags from Wordpress database

I have WP website with over 40,000 posts. Now I'll like to delete all posts, categories and tags. So All content and related meta. All I want to keep is static files. Is there a easy way to do this through database? Some query to drop all relevant tables? Sorry, I am not good with db and code, so please give me detailed explanation or full query. Thanks a lot. Plugins or any other solution, don't work for me, I need mysql query.


Pagination for category slug returns 404 when page >= 2

I have a custom type and the slug is:               'rewrite' => array('slug' => 'blog/%blogs_tax%'),      And after `register_post_type()` I have a function to rewrite the slug variable. I works fine, but I have problems with pagination... When I try to access something like http://www.site.com/blog/job/page/2/ (job is the category), I receive 404. The pagination with simple slug from an another custom type Like : `'slug' => 'cases/'`) works fine... the problem happens only when I use a variable in the slug (%blogs_tax% or another). How to fix it? Thanks.


How do you keep your live and and testing server?

I have a live site and a testing server (XAMPP) that I built the site on originally before publishing it. Obviously, there are a number of things you need to do to migrate a site from one place to another. I was hoping to tap into collective experience to find out the best way of doing this, keeping fuss to a minimum. The obvious answer (to me, at least) is to keep a folder of files to merge into the XAMPP files for when it's built on the testing site and a folder of the same files but with production server info to apply when the site is uploaded. This is a bit messy and leads to mistakes. Is there a program out there that I've never come across or better way of doing this? (I've been auto-warned about the subjectivity of this question, I do hope it passes the community test!)


Built-in data validation function for URLs

I have a front-end form where people can submit their website URL. I'm actually verifying URLs in Wordpress with a PHP function and I would like to know if there is a built-in function that allows me to do this ? This is the function that I am actually using :               function validateURL($URL) {         $v = "/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i";         return (bool)preg_match($v, $URL);     }


Getting the Facebook/Twitter avatar for Jetpack comment

When using Jetpack comments a user can sign in using Facebook or Twitter. The avatar that a user uses is shown in the Jetpack comment box. However, when a uses has submitted his/her comment and I want to use `get_avatar` there is no avatar returned. Which is not that weird because there is no user created and the e-mail has no gravatar associated. How should I retreive the Facebook/Twitter avatar? Is there such a function somewhere in Jetpack?


How to highlight all current categories when viewing a single post?

When viewing a single post, the `wp_list_categories` function already _marks_ the current category of this particular post by assigning the `current-cat` CSS class. If the post is mapped to multiple categories, however, only the first category (hierarchically ordered) is marked. How can I assign the `current-cat` class to **all** categories of the post?


How To Disable Comments On New Page

I am writing a plugin that upon activation, it creates a few new pages. On these pages, I want to disable the comments option. I am adding the new pages via the code below:               $page['post_type']     = 'page';     $page['post_status']   = 'publish';     $page['post_author']   = 1;     $page['post_parent']   = 0;     $page['post_title']    = 'Test Page';     $page['post_content']  = 'this is a test.  i want to disable the discussion option.';     $pageid = wp_insert_post($page);      In the WordPress codex, I do not see any option/property/meta to disable the Discussion section of a page/post. Does anyone know how?


Custom posts not paginating on archive page and returning 404

I'm trying desperately to get the pagination on my custom post type archive page to work, but I keep getting a 404 error whenever I click on `<?php next_posts_link('« Older Entries') ?>` for p2 of results. Here's my situation:   * I've created a file called 'archive-bvdirectory.php' for my custom post type 'bvdirectory' (see how I've set it up in my functions.php below) and 'single-bvdirectory.php' for viewing single custom posts, both of which I can view fine.   * I _have deleted_ a page called 'directory' I created permanently as I read this can cause problems with WP's rewrite rules (the URL would be the same, so that makes sense)   * I have refreshed my permalinks ad infinitum and it changes nothing. Can anyone see a problem with my code or suggest something for me to try? Thanks for your time, Osu **CTP and taxonomies are set up like this:**               function osu_bv_company() {              // Create Directory custom post type         register_post_type(             'bvdirectory',             array(                 'label'                 => __( 'Directory' ),                 'public'                => true,                 'has_archive'           => 'directory',                 'show_ui'               => true,                 'query_var'             => true,                 'supports'              => array(                     'title',                     'editor',                     'author',                     'excerpt',                     'post-thumbnails',                     'custom-fields',                     'revisions',                     'page-attributes',                     'thumbnail'                     // 'trackbacks',                     // 'comments'                 ),                 'rewrite' => array('slug'=>'directory')             )         );              // Create Industry taxonomy         $bvindustrylabels = array(             'name'                      => 'Industry',             'singular_name'             => 'Industry',             'search_items'              => 'Search industries',             'all_items'                 => 'All industries',             'parent_item'               => 'Parent industry',             'edit_item'                 => 'Edit industry',             'update_item'               => 'Update industry',             'add_new_item'              => 'Add new industry',             'new_item_name'             => 'New industry name',             'choose_from_most_used'     => 'Choose from most used industries'         );         register_taxonomy(             'bvindustry',             'bvdirectory',             array(                 'hierarchical' => true,                 'labels' => $bvindustrylabels,                 'sort' => true,                 'args' => array('orderby' => 'term_order'),                 'rewrite' => array('slug' => 'industry')             )         );         // Create Company Size taxonomy         $bvcosizelabels = array(             'name'                      => 'Company size',             'singular_name'             => 'Company size',             'search_items'              => 'Search company sizes',             'all_items'                 => 'All company sizes',             'parent_item'               => 'Parent company size',             'edit_item'                 => 'Edit company size',             'update_item'               => 'Update company size',             'add_new_item'              => 'Add new company size',             'new_item_name'             => 'New company name',             'choose_from_most_used'     => 'Choose from most used company sizes'         );         register_taxonomy(             'bvsize',             'bvdirectory',             array(                 'hierarchical' => true,                 'labels' => $bvcosizelabels,                 'sort' => true,                 'args' => array('orderby' => 'term_order'),                 'rewrite' => array('slug' => 'size')             )         );     }     add_action('init', 'osu_bv_company');      **I have the following arguments set for my loop in archive-bvdirectory.php**               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array(         // General args         'post_type'             =>  'bvdirectory',         'posts_per_page'        =>  2,         'orderby'               =>  'title', // set this in form         'order'                 =>  'ASC', // Set this in form         'paged'                 =>  $paged       );          // Filter posts     query_posts($args);


plugin: alter "crunching...." text, reject the upload, and other logic

I am new to wordpress, but a customer wants one of my scripts converted into a wordpress plugin. The basic idea of the script is when a file is uploaded with a specific filetype, then start decoding it (private In-company filetype) Now, while it is being processed, is there a way to edit the "crunching...." text to display status of the decoding? Also, if the decode fails, then it CANT BE UPLOADED... is there a way to reject the file and stop the upload process? code:               add_action('wp_handle_upload', 'filetype_check');          function filetype_check($results) {         if ($results['type'] == "D3m58") {             Process($results['file']);             $result2 = wordingcheck(textdecode($decodedtext);             if ($result2 != "") {                 echo "upload failed, following reasons: <br>\n" . $result2;                 die();             }         }     }      The text should be placed inside the loading bar instead of the current `Crunching`. Instead of `die()`, I want the upload to abort. > ![This is what I got](http://img35.imageshack.us/img35/8174/y0lf.png)


How can I  Add class attribute to the html element in NextGEN gallery plugin

i want to access to some html `Li` element in my NextGEN gallery by jquery like this site so i need to add Css Classes How i can do this ? sorry for my bad English


Uploading DB to server from local is not matching the post dates

I just created a custom WP CMS and am having trouble with the custom post maintaining the correct order on the front-end. In the back end the date order is correct but is not being reflected on the front-end in the same order. When I download the DB to my local machine, the order is right but once on the server, it shows up differently?


Change admin language based on user (in single-site)

I'm trying to make a small plugin to install in some sites of a german client. I can make my way around WordPress in german, but would be easier if it was in english. There's a plugin that manages this (WP Native Dashboard) and albeit it does it wonderfully, it's too heavy weight to what I need. The client don't need this, I do.   Tried to emulate it to no avail... It stores a database option to check for swapping instead of `$current_user`. But I didn't get the logic for this to work. So, I'm trying to adapt this solution given by toscho, but looks like I'm not making the hooks in the correct points of WordPress process. The question is: what bit is missing _(or I'm messing)_ in the following code?               <?php     /*     Plugin Name: Set User Locale     Plugin URI: http://wordpress.stackexchange.com/q/53326/12615     Description: changes the admin language according to user_login     Version: 1.0     Author: wordpress-stackexchange     */          class Wpse53326_ChangeLocaleOnDemand     {              public function __construct()         {                    add_action('admin_init', array(&$this, 'on_init'));             add_filter( 'locale', array(&$this, 'on_change_language') );         }              public function on_init()         {         }              public function on_change_language( $locale )         {             global $current_user;                         // this prints the current user_login without problems              // global $firephp;              // $firephp->log($current_user->data->user_login,'user_login');                  //  the following works for backend/frontend             // but if I try this conditional, it don't: if (is_admin() && 'the_user_login' == $current_user->data->user_login)             if( is_admin() )             {                 return 'en_US';                      }             return $locale;         }     }          $wpse53326_ChangeLocaleOnDemand_instance = new Wpse53326_ChangeLocaleOnDemand();


WP Cron job every 1st and 15th of the month

Trying to set up custom schedules for WP Cron, knowing that they use an interval is it even possible to set up a cron job for every first of the month? As well as every fifteenth. This is what I have so far:               private function cron_schedules( $schedules ) {              $midnight = strtotime( "midnight", current_time( 'timestamp' ) );         $first = strtotime( 'first day of this month', $midnight );         $fifteenth = $first + (7 * 24 * 60 * 60) * 2;              $schedules['1st'] = array(             'interval'  => $first,             'display'   => __('1st of every month'),         );              $schedules['15th'] = array(             'interval'  => $fifteenth,             'display'   => __('15th of every month'),         );              $schedules['weekly'] = array(             'interval'  => ( 7 * 24 * 60 * 60 ),             'display'   => __('Weekly'),         );              $schedules['biweekly'] = array(             'interval'  => ( 7 * 24 * 60 * 60 ) * 2,             'display'   => __('Biweekly'),         );              return $schedules;          }


Create posts on user registration

How can I create let say 3 posts after the user finish the registration ? The ideal outcome would be to create 3 posts using the user as the author of the posts and with some pre-defined values. (post title and slug) The post title and slug would be created from info that the user will provide on the registration form. An example: User registers and provide Name, Surname, Email (all fields are mandatory) Three posts are created and the user will be the author of each post. Each post will have in the title and slug info from the registration form   * 1- Jon Doe Bio | jon-doe-bio   * 2- Jon Doe Portfolio | Jon-doe-portfolio   * 3- Jon Doe Contact | jon-doe-contact *In the example above it seems unnecessary to have the ability to edit the slug but there will be posts with words like: in, is, at, and, that will be removed otherwise. Also note that the "pre-defined values would be: Bio, Portfolio and Contact. It would be close to the "welcome" posts created by wordpress after install. Any idea of how to ? I know I need to use `wp_insert_post( $my_post );` and probably `add_action('user_register', 'some_function');` but I don't know how to create 3 posts in one shot using `wp_insert_post( $my_post );` and how to trigger that after the user finish the registration process. Any idea how to accomplish this ? Thanks in advance.


Target all images that are not the first attachment

I'm querying image attachments on a template I'm writing.   For a layout purpose, I'd like to apply a css class to all the images that are not the first.   Here is the code I'm currently working on, I'm stuck with the last if statement. But my php knowledge is very shallow, hope someone can help me writing this.               <?php $args = array( 'post_type' => 'attachment',                 'numberposts' => -1,                 'post_status' => null,                 'post_parent' => $post->ID );              $attachments = get_posts($args);             if ($attachments) {                     foreach ( $attachments as $attachment ) {                             echo the_attachment_link( $attachment->ID , 'full' );                             echo $img_count > 1 ? 'rel="'.$post->ID.'"' : '';                             // OK all my post attached images are visible.                      }             }                         //if image is not the first one then add class="fantome"                         if ( $attachments != $first_attachment ) {                             echo '<a class="fantome">';                              }             ?>


Adding a navigation page state to individual blog and portfolio pages

I'm using a Woo Themes template (Simplicity) for a client's web site. I'm using the portfolio page as the profile pages (Our Trainers). Also have a blog category in the main nav. How do I get the individual "portfolio" and blog pages to set the nav current page (.current_page_item)?


Not able to put link on featured image

I have one front slider and I am just showing featured image within front slider, but not able to put link of post on featured image in WordPress.               <img src="<?php echo $thumb_small;?>" alt="<?php the_title();?>">      this is code by which featured image is showing in front slider and I tried this code for put link on image..               <a href="<?php the_permalink(); ?>"><img src="<?php echo $thumb_small;?>" alt="<?php the_title();?>"> not working..      please help me...


Custom Field box history

I entered a test value ("hhhhhhhhhhhhhhhhhhhh") in my custom field box at some point, and now it always appears in the drop down when I am trying to select a value. Is there some way to get rid of this? ![enter image description here](http://i.stack.imgur.com/Cxycp.png)


How to add custom css file in theme?

Some themes ask you not to edit the style.css file, instead use custom.css file. If you write code on custom.css, it will overwrite the same element style in style.css. I think this is done in order to prevent the loss of user styles on theme update, is it so? **How this works?** Do they already include custom.css file in their theme? But how this file is included in the theme so that he theme look for style in custom.css first? Thanks.


/wp-admin/install.php redirecting to 123-reg

This is my first time installing wordpress via FTP, and the first time to an existing host and domain (I normally use EvoHosting, since it's automatic) I've gotten to the stage where I'm heading to /wp-admin/install.php, but it's redirecting to the host - 123-reg.co.uk I'm trying to figure out where I went wrong. I've installed MySQL, but not made any tables (the admin panel I've been given requires a number fields, and cell types to be specified) I'm not entirely sure if I've got the config file correct either though. I was never given a password or db name when I installed it with the admin panel, so I've just been using the password I had to access that.               // Actual username/password removed!     define('DB_NAME', 'example.com');         define('DB_USER', 'user');          define('DB_PASSWORD', 'pass');     define('DB_HOST', 'localhost');      Any help would be really useful here - I'm sorry that I'm so noobish at this, but you have to start somewhere ^^"


Do not show on homepage functions.php code needed

I'm using a plugin called Float Left Right Advertising however I don't want to work on the homepage. I tried adding this code into the functions.php but it doesn't work:               add_action( 'float_left_right_advertising' );           function float_left_right_advertising() {        if ( is_home() ) {          wp_deregister_script( 'float-left-right-advertising' );       }      Can someone please help me with this?


I have a table I created, how do I make a form for a user to filter the data?

I have created a table, I now need to filter the data from that table when someone selects options from a form. Whats a good way to do that?


What can cause JavaScript and CSS files to be minified?

On one of my client's site, I see that my plugin's JS and CSS files are minified. Trying to identify what causes the files to minify, I tried to deactivate all plugins (except mine), and changing the theme to TwentyEleven. However, the files were still minified. What else could cause the files to be minified?


One of my pages uses the archive.php template only. Why?

I created a page and experimented with Custom Templates. Suddenly I noticed that this page started using the archive.php template and no matter which Custom Template I assigned to it, it continues using the archive template. What could be the reason for this? ## Edit I noticed something interesting. I have a Custom Post Template that has the exact same slug as the page described above. I made another CPT and a page with the same slug and got the same effect. If I change the page slug it starts using the assigned Custom Template. This behaviour seems kind of convenient but why is WP behaving like this? Is it documented anywhere? I'd would be very interesting to read.


the_content returns blank when adding SEO details

I am using the Thesis theme and wanted a custom style for my pages. So I created a custom template while using thesis hooks and functions where applicable. I am doing this with a solution similar to the method described here so other contributors can use the themes in their pages as well. I am getting the post's content by using the function the_content(). While this works normally and returns the contents of the pages, if I specify the SEO details (meta title, keywords, description etc), the_content() returns a blank. Why should adding meta details to a page affect the_content like this? Would appreciate if someone can help me out with this. Thanks.


Change wp_mail SMTP settings for each E-Mail

I want to send mails using `wp_mail` function. I have multiple SMTP accounts login details. I want to send some mail using Account A and some using Account B. How can I send mails with different accounts? I saw `phpmailer_init` but it cannot be changed once set.


WordPress 302 Redirect to Holding Page

Once again struggling with htaccess. I've successfully redirected the home page to my holding page with the following rule but it's not applying to child pages for some reason (mydomain.com/child-page).               # MAINTENANCE-PAGE REDIRECT     <IfModule mod_rewrite.c>      RewriteEngine on      RewriteCond %{REQUEST_URI} !/holding [NC]      RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|eot|svg|ttf|woff|css) [NC]      RewriteRule ^(.*)$ /holding [R=302,L]     </IfModule>      What am I doing wrong? I know it must be to do with the '^(.*)$' bit but I can;t seem to find the correct syntax.


Show Woocommerce minicart widget in checkout page sidebar? And, how to make this update secure by overriding widget?

Before asking question here I want to tell that I have already asked the question in stackoverflow and wordpress forum but have not got any answer. So finally I came here. I have installed the woocommerce plugin in my wordpress 3.5.2. Everything is fine with woocommerce. I have made a folder called woocommerce and have pasted all the files inside the woocommerce template files inside my template folder. But there is something that I am totally stuck on. In the woocommerce checkout page I want to show cart totals in sidebar. But it is not showing there. In other pages it is working fine. So can someone kindly tell me what wrong here? Any help and suggestions will be really appreciated. Thanks Update Here is the screenshot for the woocommerce cart widget in sidebar which can be shown in all pages except the checkout page. ![enter image description here](http://i.stack.imgur.com/M7VI0.png) Edit:   Additional, how to make this change secure from updates?


How to add more custom fields in user meta table simultaneously

I am working on a task in which i have to submit some records to user_meta table at form submitting. Actually it is related to employee data and i just want to add records in user meta table. I am doing with this code.               if(isset($_POST['submit']))     {         if($_POST['user_login'])         {                     $user['user_login']=$_POST['user_login'];                     $user['user_pass']=md5($_POST['user_login']);                     $user['user_pass']=md5($_POST['user_login']);         }         if($_POST['email']){    $user['user_email']=$wpdb->escape($_POST['email']); }         if($_POST['url']){  $user['user_url'] = $_POST['url'];  }         if ($mes == '')         {             $flag = 1;             if ($flag == 1 && $message == '')             {                 if ($wpdb->insert("wp_users", $user))                 {                         if($_POST['status'] == 'inactive')                         {                                     $member_type = 'pending';                                     $capabilities = 'a:1:{s:7:"'.$member_type.'";b:1;}';                                     $meta_user['capabilities'] = $capabilities;                               }                         elseif($_POST['status'] == 'active')                         {                                 $member_type = 'employee';                                 $capabilities = 'a:1:{s:8:"'.$member_type.'";b:1;}';                                 $meta_user['capabilities'] = $capabilities;                          }                          $customer['company_id']=$company_id;                     $customer['user_id']=mysql_insert_id();                     $customer['owner']='N';                          $metauser1['user_id'] = mysql_insert_id();                     $metauser1['meta_key'] = 'member_type';                     $metauser1['meta_value'] = 'employee';                          $metauser2['user_id'] = mysql_insert_id();                     $metauser2['meta_key'] = 'nickname';                     $metauser2['meta_value'] = $user['user_login'];                          $metauser3['user_id'] = mysql_insert_id();                     $metauser3['meta_key'] = 'capabilities';                     $metauser3['meta_value'] = $meta_user['capabilities'];                          if( $wpdb->insert("wp_company_user", $customer)   && $wpdb->insert("wp_usermeta", $metauser1) && $wpdb->insert("wp_usermeta", $metauser2)&& $wpdb->insert("wp_usermeta", $metauser3))                     {                         $_SESSION['mes']="Record has been inserted successfully.";                          exit;                     }                 }                    else                 {                     $message="Record could not be inserted.";                 }             }                 }         else         {             $message = $mes;         }     }      I know this is not an efficient way to do this, there should be another way to insert custom meta key and meta values in user meta table. How can i make my code efficient please tell me. Please let me know if any code is broken.


Display unused categories in dropdown

I have created a front end post with a form and I would like to have several categories for the user to choose between. But the problem is that the dropdown category only show those categories that are in use. I need it to show all categories even if they are not in use. The code I'm using is following:               wp_dropdown_categories(   'show_option_none=Kategori&tab_index=4&taxo. nomy=register_vote_category' );


wp_handle_upload Image sizes

What's the simplest way of getting `wp_handle_upload` To either change the size of the image it is uploading, or to get WordPress to generate the 3 sized images like it does in "crunching" when adding new image in the media library? I've seen some very complex solutions and really I want something much leaner! The best solution would be to get WordPress to automatically generate the thumbnail etc..


How to let users sort list of categories?

In my homepage, I have listed all of categories, under which their posts, are listed like this:               Category 1           post 1           post 2           post 3     Category 2           post 4           post 5           post 6     Category 3           post 7           post 8           post 9      I want to let registered users, sort the categories as they want, for example like this:               Category 2           post 4           post 5           post 6     Category 1           post 1           post 2           post 3     Category 3           post 7           post 8           post 9      And want it to be:   1. **per registered user** , not one setting for all usaers the same   2. **on a widget** on the sidebar   3. **Drag and Drop** sortable list What do I have?   1. I think the 2 and 3 are not so hard. I can search for How to Write Simple Wordpress Widgets for the 2 and implement jQuery Sortable library for the 3. I just dont know how to implement the 1?  Any suggestions, ideas?


Order posts (across the whole site) by metadata date

My custom 'Home' page is set to sort my custom posts via the custom date field with this (updated to be custom named) code in functions.php:               // sort order for home page     add_action('wp', 'wwgo_check_page');     function wwgo_check_page () {     if (is_page()) {         add_filter('get_previous_post_sort', 'sort_it');         add_filter('get_next_post_sort', 'sort_it');         add_filter('posts_orderby', 'sort_it' );         add_filter('posts_join', 'join_it' );         add_filter('posts_where', 'where_it' );              function sort_it () {             global $wpdb;                  return " $wpdb->postmeta.meta_value ASC ";         }              function join_it( $join ) {             global $wpdb;                  $join .= " LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) ";                return $join;         }              function where_it( $where ) {             global $wpdb;             $where .= "AND $wpdb->postmeta.meta_key = 'deadline' ";                return $where;         }     }                    }      Which is dandy and simple. Now. I want this to work across the whole site. I want posts on archive pages, categories etc to be sorted first by the custom date field. Any ideas? I have tried changing the '`if`' to `is_archive()` but that had no effect. I tried `<! is_single()>` too. _I'm sure it should be something simple. But I'm new to php and thus clueless._ Here is the site, where you can see the home page is nicely sorted, but if you click 'poetry' (the only one with a few posts), sorting doesn't work. Any suggestions will be met with much joy. Thank You Kindly.


Good website screenshot plugin

I'm looking for a good plugin I can integrate in my template to show screenshots. Today I am using Wordpress Simple Website Screenshot, but it's too unstable. I post a lot of posts per day and my problem is that it doesn't load all the screenshots. You have to reload several times before it shows. This is not acceptable for me. One solution could be to store the screenshots locally to make it more stable. Do you have any suggestions how to make this as stable as possible? Link to example post: http://bit.ly/jjO4z1 (with bit.ly because of google searches on the site)


Choose options via url

I wonder if it's possible to preselect options when creating new post via url. My goal is to bookmark links when i want to create post with specific options such as category and not to have to select them each time. Thanks


Best Practise on embedding code on Wordpress?

I have two blog sites. One hosted with Wordpress.com, one self-hosted with Wordpress.org We are a technical company, and a number of our blog posts will be about HTML, Javascript, .NET, etc. and we would like to embed code snippets within our posts. We have about 20 authors on each blog, and from experience, I need to make inserting code snippets as easy and user friendly as possible. * * * **Wordpress.org**   I saw, for Wordpress.org, this article.   From what I understand, when writing with the HTML editor, if you apply the tags `<code> some code</code>` then this preserves the formatting.   - Its ok. But the major downfall, is ease of use. For example, compare it to stack exchange text editor - there is no need to switch to HTML view and write tags, you use the 'Code Sample' button. I know there are a heap of plugins out there.   Is there a general consensus on the best way to embed code in wordpress.org posts? > My requirements are for it to be as easy as it is with Stack Exchange. * * * **Wordpress.com**   It appears I can also use the code tags with wp.com.   I guess the advanatage of telling my users to use this approach, would mean there would not be any confusion with authors who contribute to both blogs. I was currently using the 'preformatted' text format from the extended toolbar (kitchen sink).   I assume there are no other options?


List child terms and posts in the current term

With this code parent term page lists all the child terms and the child term page lists all of the posts in current term, and the single page lists a big flat list of terms(hierarchical). Now, The parent term page is fine. When it's child term page, i want to list all child terms( not showing with this code ) + the posts in current term( showing ). And when it's single post, i want to list the same as child term page.                       $term = get_queried_object();             $tax = 'ntp_package_type';             $parents = $term->parent;             $term_id = $term->term_id;                  if($parents == 0){                 wp_list_categories( array (                                 'taxonomy'  => 'ntp_package_type',                                 'pad_counts'=> 0,                                 'title_li'  => '',                                 'child_of'  => $term_id,                                 )                 );             }             elseif (is_tax($tax, $term->name)){                      $args = array(                         'post_type' => 'ntp_package',                         $tax => $term->name,                 );                 $wp_query = new WP_Query($args);                 if( $wp_query->have_posts() ):                 while ( $wp_query->have_posts() ) : $wp_query->the_post();                 echo "
".$post->post_title."
";                 endwhile;                 endif;                  }             elseif (is_single()){                  }      It is for a sidebar sub nav. is it a right way to do? I'd really appreciate any help.


jQuery Validate wp_editor

I have a form, and in the form, I use               <?php wp_editor('', 'user_submitted_progress', $settings = array('textarea_name' => 'user_submitted_progress')); ?>      to generate a TinyMCE, rather than a simple `textarea`. The problem is that I can't get the wp_editor to be validated by jQuery Validation. Here is my code for jQuery Validation               $(document).ready(function() {         $("#user_submitted_post").validate({                  errorPlacement: function(error, element) {},                  debug: false,             rules: {                 user_submitted_title: {required: true},                 user_submitted_progress: {required: true},                 user_submitted_goals: {required: true},                 user_submitted_categories: {required: true},                 user_submitted_tags: {required: true},             },                  invalidHandler: function(form, validator) {                 var errors = validator.numberOfInvalids();                 if (errors) {                     $("#error-message").show().text("Please make sure that all required fields have been filled out.");                 } else {                     $("#error-message").hide();                 }             },                  submitHandler: function(form) {                 tinyMCE.triggerSave();                 var serialized = $(form).serialize();                 console.log(serialized);                 $(form).ajaxSubmit();             }              })     })      Here is my form:               <?php if (is_user_logged_in()) { ?>

              <form id="user_submitted_post" action="" method="POST" enctype="multipart/form-data">
Title
             <input type="text" id="user_submitted_title" name="user_submitted_title" value="">
Please provide detailed information about the long-term goals of your project, as well as your current project progress. Feel free to format your text using boldness, italics, lists, and block quotes. Simply click on the formatting option you'd like to use and start typing. When you no longer need the format you have selected, hit enter to go to the next line, and click on the active format button to end formatting.

Project Progress
             <?php wp_editor('', 'user_submitted_progress', $settings = array('textarea_name' => 'user_submitted_progress', 'media_buttons' => false, 'quicktags' => false, 'textarea_rows' => 15, 'editor_css' => '', 'tinymce' => add_filter("mce_buttons", "base_extended_editor_mce_buttons", 0), add_filter("mce_buttons_2", "base_extended_editor_mce_buttons_2", 0)) ); ?>
Project Goals
             <?php wp_editor('', 'user_submitted_goals', $settings = array('textarea_name' => 'user_submitted_goals', 'media_buttons' => false, 'quicktags' => false, 'textarea_rows' => 15, 'tinymce' => add_filter("mce_buttons", "base_extended_editor_mce_buttons", 0), add_filter("mce_buttons_2", "base_extended_editor_mce_buttons_2", 0)) ); ?>
Category
             <?php wp_dropdown_categories($args = array('selected' => Uncategorized, 'orderby' => 'name', 'hide_empty' => 0, 'hierarchical' => 1, 'id' => 'user_submitted_categories', 'name' => 'user_submitted_categories')); ?>
Tags

Separate tags with commas.
             <input type="text" id="user_submitted_tags" name="user_submitted_tags" value="">
Video

Copy and paste links from Youtube and Vimeo in the field below
             <textarea id="user_submitted_video" name="user_submitted_video"></textarea>
Audio

Copy and paste links from Soundcloud in the field below
             <textarea id="user_submitted_audio" name="user_submitted_audio"></textarea>
Images
             <input type="file" name="upload_attachment[]" multiple="multiple">                  <?php wp_nonce_field('post_nonce', 'post_nonce_field'); ?>                  <button type="submit" name="submitbutton" id="submitbutton">Submit</button>              </form>          <?php } else { ?>              <?php echo 'Sorry, but you need to be logged in to see that. You can          <?php echo wp_login_url( get_permalink() ); ?>         <?php echo '" title="Login">login here'; ?>          <?php } ?>      How do I get `.validate` to validate the text that the user types in the wp_editor? Don't mind the crazy long array for the wp_editor. I just put all of the css in that array, because I'm still just testing all of this in the Twenty Twelve theme. Any help is appreciated.


Show image exactly defined to a width

I have a photoblog displaying posts as image galleries having width 500px and some posts as single image of width 900px. For posts with 900px width images, I made `category HQ`. Posts with 500px width image galleries display fine. But those posts having single image doesn't display image of width 900px width instead 584px. E.g. Post content for 900px width image:               <img class="alignnone size-full wp-image-15735" alt="Camping in the Rocky Mountains " src="http://abc.com/wp-content/uploads/2013/05/Camping-in-the-Rocky-Mountains.jpg" width="900" height="700" />      Getting image info in browser shows 584px width. On further inspection, I came to know that there is a `$content_width variable` in `functions.php` set to 584px. I can't change it as I read it is for oEmbeds. How to get this 900px width image to show as 900px width?


Display external RSS feed on pages

i'm working on a website that is built on WordPress & the Genesis Framework. I'm looking to display an RSS feed From Feedstich within WordPress pages in the middle of the content. What is my best bet of doing this, is there a plugin that can use shortcodes or is there a way I can use php in pages to display them?


Displaying a widget only on long posts (over X characters)

I'm looking to display a standard wordpress widget only on posts that are over X amount of characters in length (or another method that can roughly calculate the height of of a post.) I am looking to include some additional advertising in the sidebar of my sites posts that are very long and thus have empty sidebar space. On shorter posts this is not necessary to display this large additional advert as then otherwise the sidebar would be longer than the main content body and cause issues with layout. Does anybody know the best solution to achieve this? I understand it may not be a common thing to ask, but if it's a simple enough solution it could be worth while to implement on the site. Thanks to anyone who can offer some assistance.


Custom booking form field not saving

I am trying to follow this debugging tutorial on adding custom booking form fields - Link My intention is to add a field, which is required, that is saved amongst the other user data when they register to an event. So, should they book an event again in future, the custom field will already be filled in, like the forename, surname etc... So far I have added my custom field to this file - event/wp- content/plugins/events-manager/templates/forms/bookingform/booking-fields.php               <p>     <label for='user_practice'><?php _e('Practice','dbem') ?></label>     <input type="text" name="user_practice" id="user_practice" class="input" value="<?php if(!empty($_REQUEST['user_practice'])) echo esc_attr($_REQUEST['user_practice']); ?>"  />     </p>      Which is outside the if statement that includes the name, phone and email:               <?php if( !is_user_logged_in() && apply_filters('em_booking_form_show_register_form',true) ): ?>          <?php endif; ?>      Half way down the support page (link above), Marcus, the plugin's author says to use the 'em_booking_validate' function. The only issue is, I'm not sure how or where to use it! I added this to the bottom of my bookings-field page, but I've tried submitted the form and the custom data hasn't followed:               <?php if( ! empty( $_REQUEST['user_practice'] ) ){             $EM_Booking->booking_meta['registration']['user_practice'] = wp_kses( $_REQUEST['user_practice'], array() );         } ?>      Any guidance / support would be appreciated.


Converting static website to wordpress

I have a static website http://www.powersolutionindia.com/ which i want to add blog functionality. There are approximate 10 static html pages in this website, just i want to add seamless blog to this website in wordpress. I want to convert design in wordpress, then create all pages in wordpress or if wordpress allows static content. Then i want navigation is populated by wordpress so when i add few more page i have to just click pages->add page and it will show in navigation. There is a javascript image scroller which i want to serve if possible by some post type or any other means, so that if i post 10 images in this image scroller, and turn off 5 of them, i can do that. Is all this possible in wordpress, dose it affect seo? I get befitted by converting to wordpress as this website is getting top ranking in google for few keyword? I have knowledge of wordpress, php html css, i can convert html css to wordpress blog layout theme, just i can't figure out how i serve these static pages.


automatically add new post type to its menu list

In case of menus that contain items other than pages, such as custom post types, posts, posts of a certain category, etc. How can I make wordpress to automatically (programatically) add a new item to the menu when that new item is just created? I don't want users to manually add this new item in Appearance -> Menus ... Should I use the fallback_cb of wp_nav_menu()? I need to use that for a custom post type and for posts of category:restaurant for example. I am also interested in being able to highlight the current visited item. Thanks in advance.


wp_insert_user not creating account correctly when ID is manually set

So, I'm trying to create a new user account with `wp_insert_user` based on credentials I receive from a Facebook user profile. I want the new user account ID to equal the Facebook account ID (ex: 1352348133). If I set the `ID` parameter as per the Wordpress wp_insert_user reference page the user account is not created in `wp_users` as I would expect, however all the relevant meta data IS inserted in the `wp_usermeta` table. If I remove the `ID` parameter from the array I pass to `wp_insert_user` it creates the new record in `wp_users` as it would normally. I was expecting to get a return error but it actually returns the newly created user ID on success. Here is an example of the code I'm passing:               $insert_user = wp_insert_user(array(         'ID'              => 1352348133,         'user_login'      => 'jdizzle',         'user_nicename'   => 'jdizzle',         'user_url'        => 'https://www.facebook.com/jdizzle',         'first_name'      => 'Jared',         'last_name'       => 'Eitnier',         'display_name'    => 'Jared Eitnier',         'nickname'        => 'jdizzle',         'user_registered' => date('Y-m-d H:i:s'),         'role'            => 'customer'     ));      and the return value of               1352348133      I thought maybe the `auto_increment` on the `ID` field in `wp_users` might affect something but disabling that had no effect. Typecasting as an `int` had no effect. Length of the int isn't an issue.


Listing subpages title and content and styling the first iteration differently

So for now, every iteration looks the same and it's been a while since I dealt with php so could you help me?                  <?php     $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');     $count = 0;     foreach($pages as $page)     {         $content = $page->post_content;         if(!$content)             continue;         if($count >= 2)             break;         $count++;         $content = apply_filters('the_content', $content);     ?>         <div id="<?php echo $page->post_title ?>">
<?php echo $page->post_title ?>
         <?php echo $content ?>
     <?php     }       ?>      I've look there and there and found that I coud Use something like this               <?php foreach ($pages as $page) : start_wp(); ?>         <?php if ($i == 1) : ?>      //first iteration        <?php else : ?>     //the rest


Create custom page from custom rewrite

I want to know how to create a custom page with a custom URL route, but I only found how to define a custom URL and custom route (rewrite URL) to any post- type. The problem is that I don't want a custom page for a post type. I only want to create a page that is rendered when the URL is entered. Something like this:               http://mydomain.com/services      What I did on a plugin I'm creating is this:               function geofarma_add_rewrite_rule($rewrite){         $rewrite->rules['services/'] = 'index.php?services=yes';     }          function geofarma_register_query_vars($vars){         $vars[] = 'services';         return $vars;     }          function geofarma_url_rewrites_template(){         if(get_query_var('services')){             add_filter('template_include', function(){                 return get_template_directory() . '/geofarma-rest-services.php';             });         }     }          add_action('generate_rewrite_rules','geofarma_add_rewrite_rule');     add_filter('query_vars', 'geofarma_register_query_vars');     add_action('template_redirect', 'geofarma_json_template_redirects');      But when I go to the URL,I get the **not found page**. Is something wrong with my code?


Ajax Contact form plugin

I am facing strange problem .I am building ajax contact form plugin.My problem When I add jquery script in theme footer there is no problem at all everything works fine. But if I add same script from plugin directory it does not work any more.My coding to add script .Please note that if ace.js is added in footer in script tag it works Here is the source https://www.dropbox.com/s/8m64xzueohppuxd/ajax_contactform.zip               add_action( 'wp_enqueue_scripts','webangon_ajax_contact');      function webangon_ajax_contact() {     wp_enqueue_script('ajcontact', plugins_url("/inc/ace.js", __FILE__),array(jquery));}      The form section                   <form method="post" id="mailinglist" action="">

     <input type="text" name="mailinglistname" id="mailinglistname" placeholder="John Doe" />
     <input type="text" name="mailinglistemail" id="mailinglistemail" placeholder="johndoe@hotmail.com" />
     <textarea name="mailinglistcomment" id="mailinglistcomment" cols="58" rows="5" tabindex="4" placeholder="Do you develope websites for FREE?"></textarea>
     <input type="submit" name="submit" class="read-more" id="mailinglistsubmit" value="Send" /><img src="<?php bloginfo('template_directory'); ?>/image/89.gif" alt="" class="ajaxsave" style="display: none;" />     </form>      The jquery part ace.js               jQuery(document).ready(function(){     jQuery("#mailinglist").submit(function()    {         if(jQuery("#mailinglistname").val()=="") {             jQuery("#mailinglist #message").text("Please enter your name.");             return false;         }                if(jQuery("#mailinglistemail").val()=="") {             jQuery("#mailinglist #message").text("Please enter your email address.");             return false;         } else {             var email = jQuery('#mailinglistemail').val();             var name = jQuery('#mailinglistname').val();             var comment = jQuery('#mailinglistcomment').val();             if(email.indexOf("@") == -1 || email.indexOf(".") == -1) {                 jQuery("#mailinglist #message").text("Please enter a valid email address.");                 return false;             } else {                 var data = {                     action: 'join_mailinglist',                     email: email,                     name:name,                     comment:comment,                 };                 jQuery("#mailinglistsubmit").hide();                 jQuery(".ajaxsave").show();                 jQuery.post("<?php echo admin_url('admin-ajax.php'); ?>", data,                 function(response){                     jQuery(".ajaxsave").hide();                     jQuery("#mailinglistsubmit").show();                     jQuery("#mailinglist #message").html(response);                 });                      return false;             }         }           });      }); Finally ajax admin part               add_action('wp_ajax_join_mailinglist', 'join_mailinglist_callback');     add_action('wp_ajax_nopriv_join_mailinglist', 'join_mailinglist_callback');     function join_mailinglist_callback() {     $email = $_POST['email'];     $name = $_POST['name'];     $comment = $_POST['comment'];     $emailTo = "raisulangon@hotmail.com";     $body = "Name: $name Email: $email Comment: $comment";     if(wp_mail($emailTo, $name,$body)){     echo "
Enquiry has been sent successfully
";     }     else     {     echo "
Please Try Again
";     }     die();     }


Override default password nag in Wordpress

For some reason my default password nag is playing up on a big multi-user site I've setup. Pretty sure it's got to do with the New User Approve and Gravity Forms User Rego combo that I'm using. Anyway, problem is I need to hack the core WP code every time I upgrade. The wp-admin/includes/user.php file has the 'default password nag' function... so I just change this to the wording I want. But of course it doesn't stick and needs to be done every upgrade! Big hassle.               add_action('admin_notices', 'default_password_nag');     function default_password_nag() {     global $pagenow;     if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') )          return;          echo '
';     echo '
';     echo '' . __('Notice:') . ' ';     _e('You’re using the auto-generated password for your account. Would you like to change it to something easier to remember?');     echo '

';     printf( '' . __('Yes, take me to my profile page') . ' | ', get_edit_profile_url( get_current_user_id() ) . '#password' );     printf( '' . __('No thanks, do not remind me again') . '', '?default_password_nag=0' );     echo '

';     }      Each time I change it to this, which works a treat:               add_action('admin_notices', 'default_password_nag');          function default_password_nag() {     global $pagenow;     if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') )          return;          echo '
';     echo '
Visit your ';     printf( '' . __('profile page') . ' to update your password any time. ', admin_url('profile.php') . '#password' );     echo '

';        }      But I want a permanent fix. Any advice will be appreciated :)


Trying to code a simple plugin, infinite loop?

I am at a standstill. I have checked over my code so many times. The code just shows up about 4 or 5 times on the Settings --> Plugin page and then breaks the browser. I am just trying to make a text box that can be modified as needed and echoed out on the font-page.php. I am including this functions.php file from my main plugin file:               <?php          // Add admin page to WP Settings menu     function grizzly_quotes_add_options() {         add_options_page( 'Site Quotes', 'Site Quotes', 'manage_options', 'site_quotes', 'site_quotes_output_settings' );     }          // Add Javascript     function add_grizzly_scripts() {          wp_enqueue_script( 'responsiveslidesjs',  plugins_url( 'assets/js/responsiveslides.min.js' , __FILE__ ) );         wp_enqueue_script( 'themejs',  plugins_url( 'assets/js/theme.js' , __FILE__ ) );     }          // Add stylesheets     function add_grizzly_stylesheets() {         wp_enqueue_style( 'responsiveslidescss', plugins_url( 'assets/css/responsiveslides.css' , __FILE__ ) );     }               // Add section for settings section to admin panel plugin page     function site_quotes_api_init() {         // Add settings section to WP admin plugin page         add_settings_section(             'site_quotes_settings_section',             'Main Settings',             'site_quotes_main_create_description',             'site_quotes_plugin'         );         add_settings_field(             'sometext',             'Some text!',             'site_quotes_output_settings',             'site_quotes_plugin',             'site_quotes_settings_section'         );         register_setting( 'settings-group', 'site_quotes_plugin_settings_arraykey', 'site_quotes_validate' );     }          // Sanitize and validate data     function site_quotes_validate($input) {         $options = get_option('site_quotes_plugin_settings_arraykey');         $options['sometext'] = trim($input['sometext']);         return $options;     }          // Output section description     function site_quotes_main_create_description() {          echo '
This is where you add your quote!
';     }               // Output the actual form     function site_quotes_output_settings() {         ?>
         <form method="post" action="options.php">             <?php             // Makes the $options_group             settings_fields( 'settings-group' );             // Make the $page             do_settings_sections( 'site_quotes_plugin' );             ?>             <?php submit_button('Save Changes'); ?>         </form>
         <?php     }          function site_quotes_main_create_input() {         $options = get_option('site_quotes_plugin_settings_arraykey');         ?><input type="text" name="site_quotes_plugin_settings_arraykey[sometext]" value="<?php echo $options['sometext']; ?>" /><?php     }          //           // Add to hook     add_action( 'admin_menu', 'grizzly_quotes_add_options' );     add_action( 'admin_init', 'site_quotes_api_init' );     add_action( 'init', 'add_grizzly_scripts' );     add_action( 'init', 'add_grizzly_stylesheets' );


Custom Search not working

Can any Wordpress Guru figure out why my custom search form just reloads the page when submitted? I'm trying to create a custom search that uses two dropdowns only (no text input). The first dropdown lists custom post types, the second lists the "location" taxonomy. This is my code so far (submitted on POC for easier reading: http://paste.ofcode.org/WSyw4ZdeLweEicQQFj9aPG Any help will be GREATLY appreciated!! Thanks :)