Using WP Ajax and jQuery to process multiple forms on the same page?

I'm using the following to make ajax calls:               wp_enqueue_script( 'my-ajax-request', TAF_PLUGIN_URL . 'js/ajaxcf.js', array( 'jquery' ) );      wp_localize_script( 'my-ajax-request', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'postid' => get_the_ID(),  ) );\      And in my javascript file i have a fairly simple code snippet:               jQuery(document).ready(function($) {         jQuery('.submit').click(function(){             var str = $("#ajaxForms").serialize();             var data = {                 action: 'myajax-submit',                 serialize: str,             };                  jQuery.post(MyAjax.ajaxurl, data,  function(response) {                 alert(response);             });             return false;            });     });      And for my html i have:               <form id="ajaxForms">         <label for="fname">First Name:</label>         <input id="postID" name="postID" value="First Name" type="text"  />         <input id="submit_button" class="submit" value="Send" type="button" />     </form>      Everything seems to be working smoothly however i would like to process multiple forms on the same page, say for example the homepage has five posts, each of these posts will have my form (html code above). I'm getting conflicts when more than one form is displayed, this is due to the jquery, for example the click function has a class of .submit or the .serialize() has the same ID as the rest. How would i use the jQuery with unique identifiers for each form so conflicts won't happen? I hope i made this clear. Kind Regards


URL path for wordpress categories

If I have a file called category-sound.php which corresponds to a category in a taxonomy called campaigns for a custom post type called awareness campaigns. what is the url path for this page? website.com/sound ? website.com/campaign/sound ?


How to determine wordpress base path when wordpress core is not loaded

I have a command line script for maintaining a wordpress plugin and have to determine the wordpress base path to be able to load the wordpress core. I could just assume the script is several levels under the base path. But if I want to reuse the code and I have another similar script that needs to determine the wordpress base path I would have to adjust the level depth. This is error prone. _edit:_ `ABSPATH` can't be used since it is not defined in the command line script. In fact its value is necessary to be able to load the wordpress core and which will define it. So how do I determine the wordpress base path when the wordpress environment is not loaded yet? **Similar question:** What is the best way to get directory path for wp- config.php?


Query custom post type in custom taxonomy loop

I've got three products (called "Kits") and each kit contains several items. The "items" are a custom post type which are linked to each kit via a relationship field. Each item has a custom taxonomy attached to it ("departments"). The departments have no direct link to the products (or "kits"), except via the items. When I display the products, I want to loop through each term found in "departments". Then, have a nested `<ul>` that lists each item that is found in the current department AND in the current product. I've got the department names print out in a `<ul>` which is perfect. But then I'm trying to query the CPT "item" and loop through the posts associated with the current "department". When I print_r the items, it says that I'm in the right department, but returns no data about the items. Any idea how I can actually access the title of the item custom post type? Also, this is a link to the array that's being returned by print_r($items)               <div class="items" id="details<?php the_ID(); ?>">           <?php $departments = get_terms( 'departments', 'orderby=count&hide_empty=0' ); ?>
                 <?php foreach ($departments as $department): ?>
                      <?php $dept = ($department->name) ?>                     <?php echo $dept ?>                     <?php $args = array(                         'post_type' => 'item',                         'tax_query' => array(                             array(                                 'taxonomy' => 'departments',                                 'terms' => $dept                             )                         )                     );?>                     <?php $items = new WP_Query( $args ); ?>                     <?php                          echo "
";                         print_r($items);                         echo "
";?>
                     <?php while ( $items->have_posts() ) : $items->the_post(); ?>
<?php the_title(); ?>
                       <?php endwhile; ?>

                 <?php endforeach ?>


Custom excerpt showing first paragraph (with HTML formatting)

Can somebody help me how to show the full first paragraph of the post, including all used tags (no stripping)? My code:               function new_excerpt_more() {       global $post;       return '…

' . 'Read more' . '
';     }     add_filter('excerpt_more', 'new_excerpt_more');      It is basically only closing the excerpt paragraph and adding read more link. Thank you


Commenting out in HTML editor breaks template

There is a certain section of HTML that I need to comment out within the HTML editor in Wordpress. But when I do so, it breaks the HTML. After looking at the source code, I noticed that it converts the ending comment of this:               -->      To this:               –>      Anyone know how to go about commenting out HTML code within the editor without it converting it to that character?


Overriding wp_get_archives() apply_filters()

I have Googled for a while and I am not sure how is the best way to do this. In `wp-includes/general-template.php` I am looking at the function `wp_get_archives()` which has this line of code in: `$where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );` What I want to do is have: `$where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' OR post_type = 'events' AND post_status = 'publish'", $r );` However I am not sure how to hook into this filter and override it in functions.php Any advice appreciated. Thanks, Ian


Custom Taxonomy - Tags Metabox is showing instead of Categories

So I have a weird thing going on. Usually by default when you create taxonomies a categories metabox is made automatically (right?). For some reason that's not showing up but Tags metabox is showing up instead and I have no idea why. I disabled all my plugins but it didn't seem to help. What could cause this. MY Custom Post Type               function CPT_init(){         // Products CPT          register_post_type('product', array(             'labels'            =>  array(                 'name'          =>      __('Products'),                 'singular_name' =>      __('Product'),                 'all_items'     =>      __('View Products'),                 'add_new'       =>      __('New Product'),                 'add_new_item'  =>      __('New Product'),                 'edit_item'     =>      __('Edit Product'),                 'view_item'     =>      __('View Product'),                 'search_items'  =>      __('Search Products'),                 'no_found'      =>      __('No Products Found'),                 'not_found_in_trash' => __('No Products in Trash')                                     ),             'public'            =>  true,             'publicly_queryable'=>  true,             'show_ui'           =>  true,              'query_var'         =>  true,             'show_in_nav_menus' =>  false,             'capability_type'   =>  'post',             'hierarchical'      =>  false,             'menu_position'     =>  21,             'supports'          =>  array('title','editor', 'thumbnail'),             'has_archive'       =>  true         ));     }     add_action('init', 'CPT_init');      My Taxonomy               function product_category_taxonomy() {     $labels = array(             'name'              => __( 'Product Categories' ),             'singular_name'     => __( 'Product Category' ),             'search_items'      => __( 'Search Product Categories' ),             'all_items'         => __( 'All Product Categories' ),             'parent_item'       => __( 'Parent Product Category' ),             'parent_item_colon' => __( 'Parent Product Category:' ),             'edit_item'         => __( 'Edit Product Category' ),              'update_item'       => __( 'Update Product Category' ),             'add_new_item'      => __( 'Add New Product Category' ),             'new_item_name'     => __( 'New Product Category' ),             'menu_name'         => __( 'Product Categories' ),         );          $args = array(             'labels'            => $labels,             'public'            =>  true,             'show_in_nav_menus' =>  false,             'has_archive'       =>  true,             'rewrite'           =>  array('slug' => '/products', 'with_front' => true),         );         register_taxonomy( 'protax', 'product', $args );     }     add_action( 'init', 'product_category_taxonomy');      Pretty standard stuff. What's causing tags to show up in the place of my categories metabox? The tags metaboxes are named the same as my Taxonomy 'name' field. So it probably has something to do with my taxonomy. I tried to remove public and tried to turn `show_tagcloud` to false. Didn't really do anything.


Change post title during post saving process

My theme and Qtranslate plugin have a conflict and cause many issues on my website's post titles. I cannot trace what causes the issue and I thought that I could handle the title saving myself instead. I would like to be able to change post title that wordpress uses when saving a post from backend. How can I do that?


What is causing this error? "Warning: Invalid argument"

I need urgent help figuring this out please - I've been working on a WordPress theme locally without problems, and now that I've uploaded it to the live server I'm getting this error: > **Warning: Invalid argument supplied for foreach() in > /homepages/42/d357924500/htdocs/wp-includes/post.php on line 1011** The corresponding code is related to the `register_post_type` function:               foreach ( $args->taxonomies as $taxonomy ) {             register_taxonomy_for_object_type( $taxonomy, $post_type );         }      Could this be because of an error in my `register_post_type` or `register_taxonomy` code? The error shows both on the front-end and the admin side (also displays in widget option boxes when I try to update widgets - the changes don't save). I don't really know much about PHP yet (still learning), but I know just enough to manage a few WordPress customisations. Both WordPress installations use version 3.1. Any help on this issue is very appreciated. -- UPDATE -- I tried creating a new term for my custom taxonomy of "type", and I got this error in a red error box: > * ***Warning: Invalid argument supplied for foreach() in > /homepages/42/d357924500/htdocs/wp-includes/post.php on line 1011** > > **Warning: Cannot modify header information - headers already sent by > (output started at /homepages/42/d357924500/htdocs/wp- > includes/post.php:1011) in /homepages/42/d357924500/htdocs/wp- > includes/class-wp-ajax-response.php on line 129** > > **Administration** > > **administration0]]>Administration** > > **administration0]]>**** The taxonomy term was obviously not saved.


How to get the user description with get_users?

I'm using this piece of code to list users and their information. The problem I'm having is that the description isn't showing. Obviously it's because the description lays under "user_meta" and not "users". But how would I solve that?               <?php         $blogusers = get_users('include=2,3,4,5,6,7,8');         foreach ($blogusers as $user) {             echo '
'             . get_avatar($user->ID, 120) .             '
'             . $user->display_name .             '
'             . $user->user_email .             '
'             . $user->user_description .             '
';         }     ?>


How to not allow custom roles to edit published custom post types?

I have a WP site with a custom role (revisor) and a custom post type (events). What I would like to do is allow my revisors to add new events, but not edit existing. I'm already using the Members plugin, and i have 'edit_published_events' unchecked in it, but the users can still edit the events. I think the problem is that I have another CPT that I want to let them edit (called listings), so I can't fully restrict 'edit_posts' in the capabilities. Any ideas on how I can just remove the option for editing a published CPT? I did see a post about removing the 'edit' option that appears when you hover over the post's name in the list, but clicking on the post still lets you edit... Thanks!!!


Switch between Visual and HTML tab freely

So this question has been raised many times under different flags, however I'd like to present a unified thread for an ultimate solution to this issue. In WordPress, by default, when switching back and forth between the HTML and Visual editors in TinyMCE, certain tags are stripped out of content, and other weird functionality occurs. Two known workarounds for writing more efficient HTML code are using removing the wp_auto_p function using filters, and installing TinyMCE Advanced & enabling the "stop removing p & br tags" option. This only works so well, unfortunately. Take, for instance, the following example:
How does it work?

In order to use jQuery Easy Columns, you must install it as you would any other jQuery plugin.  First, download the zip file using the button above.  After downloading the file, extract it to a location of your choice, and move the extracted folder to your server using your favorite FTP client.  After moving the plugin to your server (and of course calling the jQuery source into your document), call it in on your site using the following snippet of code:

     <script type="text/javascript" src="/path/to/jquery.easycolumns.js"></script>
      If I type this code into the HTML editor, with both options listed above already enabled, then when I switch between the two different editors, nothing happens, which is expected. Unfortunately, when saving, the code automatically converts to this:
How does it work?

In order to use jQuery Easy Columns, you must install it as you would any other jQuery plugin.  First, download the zip file using the button above.  After downloading the file, extract it to a location of your choice, and move the extracted folder to your server using your favorite FTP client.  After moving the plugin to your server (and of course calling the jQuery source into your document), call it in on your site using the following snippet of code:

      As you can see, all entities inside the pre tag are converted back into actual HTML characters. Then, if I save this same post again, I get something like the following:
How does it work?

In order to use jQuery Easy Columns, you must install it as you would any other jQuery plugin.  First, download the zip file using the button above.  After downloading the file, extract it to a location of your choice, and move the extracted folder to your server using your favorite FTP client.  After moving the plugin to your server (and of course calling the jQuery source into your document), call it in on your site using the following snippet of code:

      Note that Wordpress will actually inject br tags into the post. Needless to say, when this post has been updated a few times, when viewing it on the frontend, the display is nowhere near the intended display. The only way I've seemed to get rid of all of the added "formatting functionality" has been to disable the Visual editor through my profile. This is a fine solution for me, considering I'm a professional web developer. For my clients, this solution is far from elegant. My clients will, for the most part, be using the visual editor. A lot of my clients aren't very tech savvy, and sometimes need me to fix their posts when the layout breaks. This limits me to using the visual editor, as I can't change to the HTML editor without fear of breaking the layout. Mainly, (and I think there's a large community that could benefit from this answer), what explicit steps can I follow to ensure the following:   1. A post can be edited from the Visual or HTML editor.   2. A post's content is not modified in any way when switching between the two tabs.   3. When saving a post from the HTML editor, no extra content is added.   4. When saving a post from the HTML editor, no entities are converted.   5. BONUS: When saving a post from the HTML editor, any code (HTML for example) that's wrapped inside a pre tag and not already converted to entities will be automatically converted to entities. Essentially, if we can create the aforementioned behavior in TinyMCE through the use of a third party plugin, we can quell all other questions regarding false formatting through the use of TinyMCE. I feel that many people could benefit from this. It just seems logical that there is a certain functionality one would expect from a WYSIWIG editor, and this goes against it. According to all logic and reason, Wordpress' built in formatting functions are pretty useless with their current setup. It seems to me that if they want to use these formatting options, their best bet would be to enable one editor or the other, not both. AND PLEASE: Don't answer this thread with workarounds and downloads for other WYSIWIG editors that 'fix' the problem. This is an underlying problem (although not truly a bug) with the Wordpress core that needs to be corrected. **EDIT** : Alright, I've been working on this and I'm thinking reverse engineering will be the best way to solve this issue. So for right now, I've disabled wpautop (which just for clarity is a function that hooks into "the_content" filter to add p and br tags _before the text is displayed_ , not when the text is saved. I think there exists some confusion as to how this function operates. wpautop isn't responsible for the changes you see happening when you switch between editor tabs. That's something entirely different. Anyway, I've disabled wpautop, as is good practice when you use the HTML editor. From that point, I disabled the visual editor to start first with the html entity errors that are present when saving a post. Thanks to the help of one C. Bavota, I found a snippet to convert any tags in the HTML editor to their equivalent entities before displaying them on the front end of the site (credit: http://bavotasan.com/2012/convert-pre-tag-contents-to-html-entities- in-wordpress/).               #add_filter( 'the_content', 'pre_content_filter', 0 );     /**      * Converts pre tag contents to HTML entities       *      * This function is attached to the 'the_content' filter hook.      *      * @author c.bavota      */          function pre_content_filter( $content ) {             return preg_replace_callback( '|
(.*)</pre|isU' , 'convert_pre_entities', $content );     }               function convert_pre_entities( $matches ) {             return str_replace( $matches[1], htmlentities($matches[1] ), $matches[0] );     }          add_filter( 'the_content', 'pre_content_filter', 10, 2 );       This effectively eliminates issues with Wordpress converting all entities into tags upon save by circumventing it. Now, you can use the HTML editor, and write standard code in between "pre" tags without doing the entity conversion yourself. This takes care of all of the issues with entity conversion in Wordpress, and makes sure everything displays correctly on the front end. Now, we need to figure out what to hook into to modify the behavior experienced when clicking back and forth between tabs. Right now, it would appear that when moving from the HTML to the visual tab, the contents of the HTML tab are interpreted by javascript or something to try to provide a live update of what the content should look like. This causes the tags (which are displayed in non entity form in the HTML tab) to be processed instead of displayed. Then, when switching back to the HTML tab, it would appear that TinyMCE passes the current data along. This means when you switch back, you lose your HTML structure. We need to figure out a way to tell TinyMCE to convert everything in pre tags to it's equivalent entities before loading it into the window (essentially the backend version of what we did on the frontend but with tinymce and javascript instead of php and hooks), so that it's displayed instead of processed. Suggestions? **EDIT 2** : After some more research, converting the entities in the pre tag when they are displayed works fine for content within the pre tag, but say I have a blog post with a line like this: "Next, we need to add this line to our HTML file:
Hello, World!
" Looking at this line, you can tell that the code is supposed to be displayed on the site, and not parsed, however when the post is saved, these entities get decoded on the next post edit load, and on every subsequent save they are saved as raw html tags, which causes them to be parsed on the front end. The only solution I can think of so far would be to write in similar code for the "code" tag as I'm using for the pre, and then just wrap small one liners in the "code" tag, and large chunks in the "pre" tag. Anybody have any other ideas?


Add Class according to the order of appearance

My loop returns five posts and the HTML should look like this..

 ...

 ...

 ...

 ...

 ...

      And, I need to programmatically add classes to them according to the order of appearance, something like this..

 ...

 ...

 ...

 ...

 ...

      Here is the code I am using to create the loop:               function custom_top_products() {         $args = array (                     'post_type' => 'products',                     'post_status' => 'publish',                     'orderby' => 'comment_count',                     'posts_per_page' => 5                 );             $posts = new WP_Query( $args );                  ?>

Top 5 Products

             <?php                 if ( $posts->have_posts() ) {                     while ( $posts->have_posts() ) {                     $posts->the_post();                 ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>
                           <?php                                } else {                     echo '
Sorry, No Popular Products Found
';                 }                 wp_reset_postdata();             ?>

                   <?php     }      Please help


Theme comment callback results nothing

I made theme and now im finally editing the look of wp_list_comments. I made function, wrote callback link to arguments and tried it. It returns nothing - only elements hard coded in comments.php are displayed (that are just bones for that list...) Ive tried very much ways and nothing worked; comments.php: `wp_list_comments(array('callback'=>'ksgcomcall')); ?>` functions.php:               <?php      function ksgcomcall($comment, $args, $depth){         $GLOBALS['comment'] = $comment;              ?>         <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">             <article id="comment-<?php comment_ID(); ?>" class="comment">
<?php comment_text(); ?>

<?php echo "Comment authors age: ".get_comment_meta( $comment->comment_ID, 'age', true ); ?>

                     <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply ↓', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>

         <?php     }     ?> - its just copy of example from codex..      Can anybody help me, please?


Add media browser tab for CPT

I created a CPT "Gallery" and wanted to create a new tab in the media browser. For now I added a tab and created a function for it's content:               jw_gallery_media_tabs($tabs) {         return array_merge($tabs, array('jw_gallery' => 'Insert Gallery'));     }     add_filter('media_upload_tabs', 'jw_gallery_media_tabs');          jw_gallery_media_tab_content() {         media_upload_header();              // PRINT INFORMATIONS HERE         // mimic the default image tabs         // HTML structure and CSS styles     }     add_action('media_upload_jw_gallery', 'jw_gallery_media_tab_content');      I now have the correct HTML structure and copied the right styles from my web inspector. Now I would need to let the created cells be _selectable_ and do something when the "insert" button is clicked. Is there any undocumented or documented API to do stuff like that?


Check the Comment in Reply or Normal State

I'm currently working with custom comment meta, and I have some custom additional field such as rating etc, when user write a comment ( not comment reply ) I want to show the rating field, but when it's on reply comment state I want to remove this field. Is there a build in conditional function to check whether it's in a reply state or not? or any other way to achieve what I want?


Redirect to Page URL for non-members

My membership plug in won't let me re-direct custom post type archive / taxonomy URLs to a non-member page if the user requesting access is not logged in or not a member. So, I am trying a hack to check if user is Level A, B, C etc and if not the template page redirects to a no access page. I'm using the code below to check for access levels. What would be the best way to insert a page redirect?               <?php           if(mgm_user_is(array('level1','level2' ))) {          echo 'REDIRECT TO NON-MEMBER PAGE';          } else {     echo 'GIVES ACCESS TO PAGE SEARCHED FOR';     } ?>


User info in the admin sidebar

I think nobody has yet think of this, hope someone can help me. Im trying to add a user info pannel in de admin sidebar, right at the top. Just like the wp-admin-bar-my-account in the admin bar, just to make the backoffice look very pro for editors and authors.   I think I could add it somewhere else and inserting it righ where I want with some java script. I could use some help here since I been searching for a way to do this for weeks.


How can I whitelist only specific shortcodes for processing in text widgets?

I know that I can use the following filters to enable processing of shortcodes in Text Widgets:               add_filter( 'widget_text', 'shortcode_unautop');     add_filter( 'widget_text', 'do_shortcode');      How can I only whitelist a few specific shortcodes for processing, but not just process every shortcode?


Header Link function not working. Problem with bloginfo()

I'm writing a function to make all of my header images link to their respective home pages. I wrote this function:                   function get_category_location(){         $header = get_category_header();         $home = bloginfo('url');              if ($header == 'wth') {             $location = $home . "/wth/" ;         }              else if ($header == 'campus' || $header == 'tech') {             $location = get_category_link();         }              else {$location = $home;}              return $location;          }      so when you click a header in the wth section of our site $header should equal 'wth' and $home should equal 'http://dev.reesenews.org' and so location should be set to 'http://dev.reesenews.org/wth/' as far as I can tell $header and $home are correct.


Wordpress plugin updates / set file as immutable to prevent certain files from changing?

I'm wondering--what is the best way to prevent a file (say, a custom CSS file associated with a plugin) from being overwritten during the update process? Would setting the file's status as immutable do the trick, or would this just cause an error during update? What is the best way to go about doing this?


Wordpress Error Missing Argument

I've just started recieving the following error on my WP site, when I publish a page update: Missing argument 2 for wpdb::prepare(), called in /home/greenfin/public_html/wp-content/plugins/auto-image-field/auto-image- field.php on line 98 and defined in/home/greenfin/public_html/wp-includes/wp- db.php on line 992 The page still publishes correctly but I have to back/forward out of the error screen to see anything. I'm concerned it may cause ongoing issues. Any ideas on how to update?


$wpdb->prepare error after Wordpress update

> **Possible Duplicate:**   >  $wpdb->prepare() warning in WordPress 3.5 Im facing with a error after updated Wordpress to 3.5, Im aware of error but I cant fix it. This is code:                $wpdb->prepare("INSERT INTO $orders_table ( theme_name, user_id, order_status, order_verified, order_date, order_payment_method, order_ip  )VALUES ( %s,  %d,  %d,  %d,  %s,  %s, %s)",$theme_name, $user_id, $order_status, $order_verified, $date_now, $order_payment_method, $ip)          $wpdb->prepare("SELECT COUNT(*) FROM $orders_table where theme_name='$theme_name' && order_verified = '1';")          $wpdb->prepare("SELECT COUNT(*) FROM $orders_table where theme_name='$theme_name' && order_verified = '1' && DAY(order_date) = '$fa_today' && MONTH(order_date) = '$fa_this_month' && YEAR(order_date) = '$fa_this_year';")      Can someone please update code above? Thanks


WPDB Prepare error

I have just taken hosting on for a clients WP site and I am stumped with a WP error The site originally ran on 3.2 but I am upgrading to 3.9 and the client has an error on their them caused by a WPDB->prepare function. The code:               $gallery_path = $wpdb->get_var($wpdb->prepare("SELECT path FROM wp_ngg_gallery WHERE gid='" . $image->galleryid . "'"));      How Can I modify this to work in 3.9 with no errors, I found this article on how to do it but I am a little stumped


Add description to custom text widget and display the 5 recent post titles

I just started coding and working as an intern for a company. My boss asked me to create a custom text widget for practice in making word press widgets. The problem I am running into is I have no idea where to add in a description so it will show up on the widget dashboard. It just keeps displaying the title. Something else I would love some help with is that my boss then wants me to add functionality to display the 5 most recent post titles (all categories) and I also do not know how to do that. I will post the code I have now below. Any input will greatly help my web design education. Thanks!                   <?php     /*     Plugin Name: Kevins Textbox     Plugin URI:      Description: A text widget created by Kevin Ullyott for practice in creating widgets     Author: Kevin Ullyott     Version: 1.0     Author URI: http://modmacro.com/     */               class kevintext extends WP_Widget {              public function __construct() {             parent::WP_Widget(false, $name='Kevins Textbox');             array('description' => __('A text widget created by Kevin Ullyott for practice in creating widgets') );         }                   public function widget( $args, $instance ) {                       extract( $args );                  $headline = $instance['headline'];                   $text = $instance['text'];                                  echo $before_widget;                  echo $before_title;                  echo "
$headline
";                  echo $after_title;                  echo "
$text
";                  echo $after_widget;                   }              public function update( $new_instance, $old_instance ) {             $instance = array();             $instance['headline'] = ( $new_instance['headline'] );             $instance['text'] = ( $new_instance['text'] );             return $instance;         }                   public function form( $instance ) {                  $headline = $instance[ 'headline' ];             $text = $instance[ 'text' ];                  ?>
             <label for="<?php echo $this->get_field_id( 'headline' ); ?>"><?php _e( 'Headline:' ); ?>              <input class="widefat" id="<?php echo $this->get_field_id( 'headline' ); ?>" name="<?php echo $this->get_field_name( 'headline' ); ?>" type="text" value="<?php echo esc_attr( $headline ); ?>" />

             <label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Text:' ); ?>              <input class="widefat" id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" type="text" value="<?php echo esc_attr( $text ); ?>" />
                       <?php          }     }          add_action( 'widgets_init', create_function('', 'return register_widget("kevintext");') );               ?>


Divide loop into several columns based on post custom field and enable infinite scrolling

How can I divide WP loop into several columns based on post custom field and enable invinite scrolling? Below is the desired output markup based on Twitter Bootstrap framework.

Post Title

Post Title

Post Title

Post Title

Post Title

Post Title

      You may see the example at Mashable.


How avoid WP editor to change <br/> by

Ok this is an old question and i may receive classical answers :   * use soft key    I can't, i also use JIG and it makes the soft key invalid when i use it to make the text slightly downard to feet with my image. Wich is precisly why i need to use br as it works good to make that. And by the way even if it would work the editor is erasing the soft key spacing as soon as i come back to edit my text. I got something else to do than constantly add soft key jumps each time i want to edit.   * disabble wpautop    Well i was on that path but it has been told to me that i shouldn't. "Disabling autop for this is probably a bad idea, as it makes many more changes in how the editor content is processed, changes that most likely the poster will like to still take effect". Wich is right. Basically i would like to be free to use < br/> in wordpress. Thanks a lot by advance for your help. Edit : Oh!!! I came here to edit my post, i added < br/> to get my lines under "use soft key" and "disabble wpautop", then i saved, then i opened edition again, and gosh !!! It keeps my < br/>s !!! So this is possible ! How ?


Assign uploaded file to user

I'm developing a project in which I need to give the logged in user (editors) the option to "give" that uploaded file (media) to a specific user. In other words, i want to add an additional field in the media upload page, a drop-down list containing all users by name, so the user (editor) may change the owner of that file to the selected user. Any help will be welcome. Thanks. EDIT: Sorry for being such a newbie in wp, but I have no 'clear' idea of how to accomplish this. I haven't found any line of code for adding custom fields or editing the media upload form, I also searched here in the forums with no avail. :/ Anything regarding adding custom fields to media upload form would help a lot. EDIT2: I actually found this trick, but it didn't work: http://bavotasan.com/2012/add-a-copyright-field-to-the-media-uploader-in- wordpress/ EDIT3: Ok, I've done a little more research on this, and all I have so far is a submenu "Add file" that leads to a page containing the file upload form, but I don't know how to make it actually 'post' the form data onto the database. Some code I added to my theme's functions.php:               add_action( 'admin_menu', 'my_add_menus' );          function my_add_menus() {         add_media_page('Add file Test', 'Add file test', 'upload_files', 'add-doc', 'my_add_doc');     }          function my_add_doc() {         echo '<form id="featured_upload" method="post" action="#" enctype="multipart/form-data">';         echo '<input type="file" name="my_image_upload" id="my_image_upload"  multiple="false" />';         echo '<input type="hidden" name="post_id" id="post_id" value="55" />';         echo "<?php wp_nonce_field( 'my_image_upload', 'my_image_upload_nonce' ); ?>";         echo '<input id="submit_my_image_upload" name="submit_my_image_upload" type="submit" value="Upload" />';         echo '</form>';     }      But nothing happens.


Wordpress plugin, listing posts in admin and having correct title/selected value

I'm making a plugin that is used to display a single post in a widget area. I can get the front end working just fine, but in the Admin area (Widgets page and customizer) I'm having some issues. I have a dropdown select list that displays all the posts in the site, so the user can spin through the list and choose which one they need to display. This all works, but I can't figure out how to make the select list "stick" at the selected post when the page is refreshed, it just goes back to the first post on the list. Also am having some problems with the title output, on the Widgets page it actually displays the post title (as it should) but on the customizer page it actually displays the post ID number and I can't figure out why. Any help you can over would be greatly appreciated. Code is below. Thanks!               function update($new_instance, $old_instance) {         $instance = $old_instance;         $instance['title'] = strip_tags(stripslashes($new_instance['title']));         return $instance;     }          function form($instance) {         $instance = wp_parse_args( (array) $instance, array('title'=>'') );         $title = htmlspecialchars($instance['title']);         $bat = get_the_title($title);          echo ' <input class="hidden" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $bat . '" />';         ?><select name="<?php echo $this->get_field_name('title'); ?>" id="<?php echo $this->get_field_id('title'); ?>" class="widefat">         <?php global $post;         $args = array( 'numberposts' => -1, 'post_type' => array ( 'post', 'page','review'));         $posts = get_posts($args);         foreach( $posts as $post ) : setup_postdata($post); ?>             <option value="<? echo $post->ID; ?>"<?php selected( $instance['title'], '<?php  the_title(); ?>' ); ?>><?php the_title(); ?></option>         <?php endforeach;          ?></select><?php     }


Media Gallery doesn't show (using WP-Read Only)

I've created a page and added a media gallery to it, but the media gallery doesn't display. I think it may be related to my using WP Read-Only, which stores all my images on S3 (because I'm on Heroku). WP-Read Only doesn't run into any identifiable issues-- I can upload and crop just fine. So maybe it's not the cause of the media gallery not showing. Here's the shortcode output: `[gallery ids="54,55"]` Here's the HTML in the content div on the media page:

Media

      I'm using WordPress 3.5.2. The only plugin other than WP Read-Only I have installed is Akismet. **Update:** I dug into the `gallery_shortcode` function in wp_includes/media.php, and the issue is that `get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );` is returning an empty array so it returns nothing:               if ( empty($attachments) )         return '';


Custom post types or not custom post types?

I currently have a webside called storelocator.no.   Here you can search for a brand, and you can see what stores sells this brand.   Clicking a store, you will see what brands this store has. Currently I am using custom database for this. But now that WP has custom post types, I'm considering if I should create a custom post type for a store and one custom post type for a brand. I still have to make the connection between store and brand -> A store can have many brands, a brand can be in many stores. I also have to connect certain users up to a store or brand (store owner or brand owner), så that they can maintain infromation. Normal users can also sign up, so that they can add extra stores / labels into the system. Currently I have over 7.000 brands registered, and I will in due time have mane stores in the system. My questions is this: Should I stick to custom tables? Or should I take advantage of WP Custom post types? Would the site be slower using custom post types if I have several thousands entries? Oh, another thing. A user is never backend in WP to register data., Everything is done from front end.


MySql Query for Wordpress

I need to count the number of value 1 from wp_ul_locked on wp_usermeta i try this code               $wpdb->get_var("SELECT COUNT(*) WHERE 'meta_key' LIKE 'wp_ul_locked'");      or `$wpdb->get_var("SELECT COUNT(*) FROM $wpdb->usermeta WHERE meta_key = '1'")`; or               $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->usermeta LIKE 'wp_ul_locked' WHERE meta_value = '1'");      but return empty or error ![example of table](http://i.stack.imgur.com/LEVhh.png) Where is my error?


How to intercept already localized scripts

If a plugin uses some script (prominent example: jQuery UI Datepicker), but you're not happy with how the script renders the output, then there're two possibilities: ## 1. Unregister the script > Add your own version So first you'd need to check the handle, then find the priority and the hook (`wp_enqueue_scripts`, `login_enqueue_scripts`, etc.) ... you know the drill. ## 2. Change the jQuery plugin parameters Normally - if the plugin isn't crap - it pushes through the parameters from PHP to JS using               wp_localize_script( $handle, $object_name, array(          // data     );      Now this is a smart way of adding your data to a JS script, **but** ... it's not filterable by default. Neither `WP_Scripts` nor `WP_Dependencies` offers _any_ filter users can later utilize > **Question:** How can we filter the arguments/parameters that are moved from > PHP to Javascript using `wp_localize_script`?


renew plugin advanced search

I'm use advanced search plugin in my site. http://www.zirona.com/software/wordpress-advanced-search/ now I'm upgrade site and advanced search not worked! :( creator plugin not update for wordpress 3 how to updated this plugin for wordpress 3? any similar plugin or code? thank you


how to query posts by category and tag?

I am trying to show a list of posts that are related to category X and tag Y. I've tried the following code:               $args = array(         'posts_per_page' => 4,         'tag_id' => $tag_id,         'cat' => $cat_id,     );     query_posts($args);      but it doesn't work correctly and returns all the posts in the co\ategory. Would love to hear any insight you might have


INSERT in table row fatal error

I just discovered this wonderful message board :-) Hopefully someone can help me with a Wordpress issue I can't figure out.. I added a hook to my plugin file to insert the post id of the immediate posts I publish, in a table named "post_votes" - used to keep track of up & down votes for posts.               function post_votes($post_ID)  {       $wpdb->insert( $wpdb->prefix . 'post_votes', array( 'post_id' => $post_ID ) );         return $post_ID;     }          add_action ( 'publish_post', 'post_votes' );      so the code above should add a post id in the post_id row (in post_votes table).. however I get, > Fatal error: Call to a member function insert() on a non-object for               $wpdb->insert( $wpdb->prefix . 'post_votes', array( 'post_id' => $post_ID ) );


How to debug WordPress correctly?

I'm using a few plugins and UpThemes framework on my new website and if I turn on Wp Debug I can see that there are a few errors related to Deprecated functions (but website is working). What I would like to know is if there is a plugin, a software or a pray (lol) that I can use to know exactly where the deprecated code is so I'll be able to use the new one. Which is the plugin/software that you use to debug your plugins, themes?


How to add a custom form to a plugin's setting page

I have a settings page for a plugin which I created using this function:               function vsp_create_menu() {              add_menu_page( 'Visitors Statistics', 'Visitors Statistics', 'manage_options', 'vsp_settings_page', 'vsp_settings_page_function', plugins_url( '/images/icon.png', __FILE__ ) );          }       That created a plugin setting page. In the settings page I am displaying some data. Instead of displaying all the data at once, I want to paginate my data, using the $_GET global variable. So, in my SQL query, the last part would be soemthing like               LIMIT $_GET['offset'], 10      So that would display 10 posts offset from whatever the GET is. My question is how do I populate the $_GET. Because I'm not to familiar with WordPress plugin creation, I thought it would be like this...               <form id='vsp_pagination' action='<?php echo $_SERVER['PHP_SELF']; ?>' method='GET'>      But that doesn't work. When the user clicks on the submit button in the form, it take the user to               http://example.com/wp-admin/admin.php?      Basically, can anyone help me with getting some data in the _GET so I can use that data to manipulate my query? Is there a better way to do what I'm trying to do?


Undefined property: WP_Query::$post

I am working on some rather elaborate comparisons between metadata and having a bit of trouble correctly referring to results from my query. The first query to establish `$team_is_home` works fine but as soon as I try to capture the ID of the posts where the `$team_is_home`it goes a bit haywire and I get warnings saying: "Undefined property: WP_Query::$post "               $args = array(            'post_type' => 'match_report',            'post_status' => 'publish',            'meta_query' => array(                array(                      'key' => 'report_home-select',                      'value' => $team_id,                      'compare' => '=',                ),            )                                            );              $hometeams = new WP_Query($args);                $team_is_home =  $hometeams->found_posts;         $scorehome = get_post_meta($hometeams->post->ID, 'report_homescore');       How should I be reffering to `$hometeams->post->ID` to avoid getting this warning?


Exclude 2 in 3 terms of A Taxonomy from all Archives

I have read this post: Include and Exclude Taxonomies From Archives & Feeds Using 'pre_get_posts' And then I have used that function to my theme. My Taxonomy (tinh-trang) had 3 term: 19,20,21 And I want to exclude all post have terms id: 19, 21 when visitor go to any archives. But I have nothing changed?               add_filter('pre_get_posts','change_archive_loop');          function change_archive_loop( $query ) {         $choduyet = intval(get_option('zen-id_cho_duyet')); // Get term ID 1 from theme option         $baocao = intval(get_option('zen-id_bao_cao')); // Get term ID 2 from theme option         if ( $query->is_tax( 'tinh-trang' ) && $query->is_main_query() ) {             $terms = array($choduyet, $baocao);             $query->set( 'post_type', array( 'post' ) );             $query->set( 'tax_query', array(                 'relation' => 'OR',                 array(                     'taxonomy' => 'tinh-trang',                     'field' => 'id',                     'operator' => 'NOT IN',                     'terms' => $terms                 )             ) );         }              return $query;     }


Moving Wordpress from live to local server

I have a wordpress install that I have been working on and now I want develop the install on my local server. I have downloaded all of the site files and added it to my local server directory. I also exported the live database and import into the local install's database. The only credentials that I changed for the database are the: database name [new name], database user [root], database password [no password], database server [localhost]. After making these changes to the wp-config.php and load the site it loads the home page correctly, but...all of the other pages are still referencing the live site's url. I attempted to fix this by defining the wp_home and wp_siteurl to 'local/sitefolder'               define('WP_HOME', 'localhost/sitefolder');     define('WP_SITEURL', 'localhost/sitefolder');      After doing this I access the site, but now the css isn't being applied. This alone is weird because when checking the reference url for the css it's the correct path, but with firebug it shows that the document couldn't be found. I also notice that all the urls add the defined url to the urls...For example, the homepage's link should be 'localhost/sitefolder' but after defining the urls it is now 'localhost/sitefolder/localhost/sitefolder.' I went into the database and searched for any reference to the live urls and replaced them with local path, but that didn't fix it. I was wondering if maybe I had to define the absolute path of the local server. Can someone please tell me how to fix this? I have been trying to fix the problems for 4 days now with no success. Thanks for any helpful feedback.


Can't change permalink url after hitting 'ok' and 'update'

I am trying to change some of the titles of my posts and their respective permalinks. After I edit the title and permalink and click 'ok', the permalink appears to have changed temporarily. However, when I click 'update', the permalink changes back to what it was originally. Is there anything that may be preventing the change that I might have overlooked?


add_post_meta -- not working

I am trying to insert data into wp_post and wp_postmeta tables but it seems like i am doing something wrong. Here is my code:               $post_data = array(                                         'post_title' => $data[0],                                         'post_content' => $data[1],                                         'post_status' => 'publish',                                         'post_type' => 'product'                                     );                                          $id = wp_insert_post($post_data);                                     add_post_meta($id, '_stock', $data[6]);                                     add_post_meta($id, '_price', $data[7]);      The post is inserted as it should but when i check the postmeta table no values had been inserted. I also tried the update_post_meta but still doesn't work. Any suggestions?


MySQL database migration to WordPress

I have a MySQL database established for a web application I have been working on in a non WordPress database. This database has many tables with pre- populated rows for foreign keys etc. which took a long while to input. I am trying to figure out how I can bring these tables into the WordPress database intact. Also I am wondering how when I have done this I could give the table names a prefix to denote them as separate to the WordPress core tables. I have also created the processforms.php file where I have used the mysqli prepare and bind param method to prevent SQL injections, is there any benefit to recoding this using the $wpdb prepare method? Any help you could offer with this would be really appreciated. Thanks Anthony Edit... I have now migrated the tables with new prefix using the PHPMyAdmin copy table function, any help on the other question regarding $wpdb would be appreciated. I am basically wondering if the $wpdb method gives any security advantages over the method I have used noted above. Thanks Anthony


Export and import all Plugin options

Actually I am developing a new free plugin for Wordpress partially based on this plugin FrameWork: Sunrise framewok, each option's name will start like this:               my_plugin_      So everytime i need to echo and option i simply write:               echo get_option('my_plugin_option_example')       And everything is working as expected. Now I would like to create an import/export page (and this isn't the problem, I have already managed how to create the new tab). What I can't understand is how to add this funcionality as (for what I know) this function:               get_alloptions()      is deprecated. I became aware of this function here: wpNettuts And now I am afraid that it will become useless soon. Is there anyone who has a solution for this problem?


How come the images arent loading properly?

The images on our wordpress site recently stopped loading. All you see is a broken image box like such.. www.theloftycsei.org. Any assistance in remedying the issue would be greatly appreciated as we are a charity and hiring a developer is slightly out of our means at the current time..


How to fix the amount of comments displayed for each post?

I've received an old wordpress 2.8 and successfully upgraded to WP3.2.1. I've just discovered that the amount of comments displayed in the WP Admin 's list of posts is wrong. Would you know how i could fix that by, perhaps, running a clever SQL update query in the database, that would fetch the real number of comments associated to a post and update the post row accordingly?


send user to first page of results when reposting to page?

I have a custom template with a drop-down that filters posts by category. I do it by making the form post to the page itself and then catching the argument and using it in a query (see code below). Here's the bummer: if you navigate to page 2 (for example) and **then** use the filter, the URL still contains the `/page/2/` bit, and you can sometimes end up with zero posts visible if there are less than a page's worth of results, since the new results all on page 1 and you're stuck on page 2. Tried unsetting the paged variable, to no avail. How can I send the user back to first page every time they use the filter?               <form action="" method="POST">         <fieldset>             <select id="food-type" name="food_type" class="selectBox">                 <option value="0">Select One:</option>                 <option value="meat">Meat</option>                 <option value="salads">Salads</option>                 <option value="vegetarian-entrees">Vegetarian Entrees</option>             </select>             <button type="submit" class="search">Search</button>         </fieldset>     </form>      I process its contents as follows:               global $post;     global $query_string;          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;          $args = array(         'post_status'      => 'publish',         'post_type'        => 'recipe',         'suppress_filters' => false,         'paged'   => $paged     );          if(isset($_POST['select_food_type']) && !empty($_POST['select_food_type']) ) {         $args['food_type'] = $_POST['select_food_type'];         unset($args['paged']);     }     query_posts($args);


Default Gallery Edit/Template Editable?

I quite like the default WordPress Gallery, but i dont like how it plonks the images as thumbnails, with a link to the larger image. Is there anyway to make it display the images not in a thumbnail link, just as either the full size image or one chosen from the media uploader? Also in a an li list? So simply looks like the following..

      Or no chance and tough, thats how the gallery works? Thanks for any advice :)


$wpdb->get_var not returning a result

I launched mysql and confirmed this query returns a result:               mysql> SELECT * FROM wp_posts WHERE post_parent = 68 AND post_type = 'attachment' AND post_name = 'side-logo-auto2' LIMIT 1;     1 row in set (0.00 sec)      In my template, I attempt same thing:               <?php if ( have_posts() ) : while ( have_posts() ) : the_post();              //$wpdb->posts is wp_posts table         //$post->ID is current post of post_type page,          //that is associated with page of this template              global $wpdb;         $image = $wpdb->get_var(             $wpdb->prepare(                 "SELECT * FROM $wpdb->posts                  WHERE post_parent = %d                  AND post_type = %s                  AND post_name = %s                  LIMIT 1                 ",                 $post->ID,                 'attachment',                 'side-logo-auto2'             )         );         echo "The image id is {$image->ID}";         echo wp_get_attachment_image($image->ID);          endwhile; endif; ?>       $post->ID returns 68. Yet, the value assigned to $image is not the record, but rather null.


Issue with first top post display order

Here i am trying to display top 6 post recent added post.But the problem is that first top post not displaying code is displaying top 6 post from top 2nd post except the top 1st post. Bellow is sample which i have used to display sticky and post.
     <?php     **//To display sticky on top**      $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;     $sticky= get_option( 'sticky_posts' );          $args = array(         'cat' =>255,         'ignore_sticky_posts' => 1,        'post__not_in' => $sticky,        //'paged' => $paged,         showposts=>6          );     $recent= new WP_Query( $args);     **//End sticky**     **//Display top 6 post**     while($recent->have_posts()) : $recent->the_post();           $postvariable++;          if ($postvariable == 1) {      ?>
[widget id="text-8"]
  //short code  to display sticky news     <?php       } else { ?>

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

     <?php     }          ?>         <?php endwhile; ?>      //End display top 6 post
      You can see this bellow snap top first not displaying in the news.after the top post there is one another news which is i have set as sticky.Actually i want to display that 1 st top post to to 5 post after sticky news. ![post](http://i.stack.imgur.com/ar73V.png) you can check my output of current code which is ignoring the first top post. ![top post](http://i.stack.imgur.com/kyuD7.png)


Using save_post to replace the post's title

I am using custom posts, and in these, I don't a need for the title. This causes Wordpress to set the titles of my posts to "Auto Draft". I'd like to change the title's value to something else, computed from other fields in my post. How do I go about doing that using save_post or some other means?


Trying to add cat_ID to array for showing an image for specific Category

So OK....I might be way of but here goes. Im using a plugin that gives the post a Featured Image if its not set. So Im trying to make it that depending on in which category the post is in the Featured Image should correspond to the category. So this is the code om trying to mend.               <?php get_the_image( array( 'meta_key' => 'feature_img', 'size' => 'medium', 'width' => '300', 'height' => '170', 'image_class' => 'feature', 'default_image' => 'http://www...../uploads/img_cat_' . $category->cat_ID . '.jpg' ) ); ?>      Its the " ' . $category->cat_ID . ' " code Im not sure about . I want the JPG displayed img_cat_4.jpg if the post belongs to Cat nr 4 etc. Any takers?


audio link produces black box

In chrome and firefox (and maybe others) the audio link does not render a media controller. E.g.               [audio http://example.com/wp/wp-content/uploads/2011/09/file.mp3]      In Chrome, view page source show this code in place:

         <audio id="wp_mep_1" preload="none">         <object width="400" height="30" type="application/x-shockwave-flash" data="http://example.com/wp/wp-content/plugins/media-element-html5-video-and-audio-player/mediaelement/flashmediaelement.swf">             <param name="movie" value="http://example.com/wp/wp-content/plugins/media-element-html5-video-and-audio-player/mediaelement/flashmediaelement.swf">             <param name="flashvars" value="controls=true&file=">                     </object>            </audio>

      UPDATE: In the JS console I note an error:               mediaelement-and-player.min.js:36     Uncaught TypeError: Cannot read property 'url' of undefined


Exclude category from foreach loop

How can I exclude one category from this loop wher I list my custom type projects by year ?               <?php foreach(posts_by_year() as $year => $posts) : ?>
<?php echo $year; ?>

         <?php foreach($posts as $post) : setup_postdata($post); ?>
             <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
         <?php endforeach; ?>

     <?php endforeach; ?>      update, the function :               function posts_by_year() {       // array to use for results       $years = array();            // get posts from WP       $posts = get_posts(array(         'numberposts' => -1,         'orderby' => 'post_date',         'order' => 'ASC',         'post_type' => 'project',         'post_status' => 'publish',         'category' => -27       ));            // loop through posts, populating $years arrays       foreach($posts as $post) {         $years[date('Y', strtotime($post->post_date))][] = $post;       }            // reverse sort by year       krsort($years);       return $years;     }


How can I create blog specific database table in multisite?

I am creating a plugin, that supposed to work on WP multisite yesterday. I've installed WP multisite on my server. While testing I found out that `register_activation_hook` created 1 table on the main blog only, while I have 2 more blogs. Here is how I create the tables now:               global $wpdb;     require_once(ABSPATH . 'wp-admin/includes/upgrade.php');     $table_name = $wpdb->prefix . "pm_services";     $table = "CREATE TABLE $table_name (       ID bigint(20) NOT NULL AUTO_INCREMENT,       service_id bigint(20) NOT NULL,       name varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,       UNIQUE KEY cuunique (`ID`)       );";     dbDelta($table);      Is there a way to creating this table for every blog on the network upon activation ?


Can I install plugins manually on WP.com?

If I have a paid blog at wordpress.com, can I install plugins manually on it? Or must I have my own wordpress installation? Thanks!


How to show only parents subpages of current page item in vertical menu?

I just can't find a way to make it possible to show only current parent items down to current page item in a vertical menu the "wordpress way". What I want to achieve is the following dynamic structure, if I visit Page 3.2.2.2: Page 1 Page 2 **Page 3** Page 4   * Page 3.1   * **Page 3.2**     * Page 3.2.1     * **Page 3.2.2**       * Page 3.2.2.1       * **Page 3.2.2.2**         * Page 3.2.2.2.1         * Page 3.2.2.2.2       * Page 3.2.2.3     * Page 3.2.3   * Page 3.3   * Page 3.4   * Page 3.5 So, only submenus for **Page 3.2.2.2** 's parents and it's own (if it has a submenu) will be listed, even if Page 3.4 or Page 3.2.3 also has submenus.


Custom fields driven site. I want to make a visual editor driven page template. How?

My company had a website developed that is entirely driven by custom fields. We're now discovering that we didn't anticipate the need for pages with custom layouts, the kinds that can be made on case by case basis in the visual editor. I have access to the site's page templates, but they all reference the custom fields. When I strip out the custom fields in a template, it doesn't retrive the content I entered in the visual editor. I'm sure i'm missing something fundamental, but i'm not making any progress. Example of one template:               <?php     /*     Template Name: News & Events POST     */           get_header();?>

                     <?php wp_nav_menu( array( 'container' => false, 'menu' => 'left_news'  , 'menu_id' =>'nav',  ) ); ?>

                     <?php $box1=get_post_custom_values('box1'); echo $box1[0];?>

             <?php $box2=get_post_custom_values('box2'); echo $box2[0];?>

             <?php $box3=get_post_custom_values('box3'); echo $box3[0];?>

          <?php get_footer();?>


Add a Span Around a Product Title in WooCommerce

I'm customizing a custom theme to use WooCommerce. One of the issues I've run into is adding a span tag around a product title on the single product page. I've figured out how to add a filter to the `the_title` method but unfortunately that method is used in other places like in the product image alt tag (which breaks it). Is there a way to specify to only modify `the_title` when it is printing the main title to the page instead of being used elsewhere like an image attribute? Here's what I have so far:               function my_product_title($title, $id)     {         if(in_the_loop() && is_product())         {             return 'FooBar';         }         return $title;     }     add_filter( 'the_title', 'my_product_title', 5);      Shouldn't there be a way to hook up to the `woocommerce_product_title` filter? I've tried to do so unsuccesfully. In the mean time I know I can modify the single-product/title.php template file but I would rather achieve this with hooks & actions.


Yet another get_posts() in explicitly defined order problem

I am creating a 'loop' that needs to display _pages_ (not posts) in a defined order of ids. What I did till now is:               <?php     $ids = array(434, 814, 3660, 3235, 99, 1002, etc.);          add_filter('posts_orderby', 'enforce_specific_order');          function enforce_specific_order($orderby) {         global $wpdb;         $ids_as_text = join(",",$ids);         return "FIND_IN_SET(".$wpdb->posts.".ID, '".$ids_as_text."') ASC";     }          global $post;     $args = array( 'posts_per_page' => 20, 'post_type' => 'page', 'post__in' => $ids );     $myposts = get_posts( $args );     foreach( $myposts as $post ) :  setup_postdata($post); ?>
<?php the_title(); ?>
          <?php endforeach; remove_filter( current_filter(), __FUNCTION__ ); wp_reset_postdata(); ?>      I can see the pages titles correctly displayed but not in the order I am expecting based on the `$ids`. Any idea?


Archive page for custom post type and custom taxonomy

I've made a custom post type `book` and a custom taxonomy `book_category`. I've been trying to create an archive page where the books belonging to a particular category can be viewed. So far I've only been able to get an archive page of all the books by creating an archive-book.php file to customize the view. What should be the next step from here ? My preferred url should be of the form: `mysite.com/books/[slug of book_category]` My understanding is that some kind of URL rewrite rule has to be in place, but I'm not sure how to do that. Any help would appreciated, thanks. The custom post type was registered in the following way:               register_post_type( 'book',         array(             'labels' => array(                 'name' => __( 'Books' ),                 'singular_name' => __( 'Book' ),                 'menu_name' => __('Books'),                 'all_items' => __('All books')             ),         'public' => true,         'has_archive' => true,         'taxonomies' => array('book_category', 'book_author'),         'supports' => array( 'title', 'comments', 'excerpt', 'custom-fields', 'thumbnail', 'editor' ),         'rewrite' => true,         )     );      To register the custom taxonomy :               register_taxonomy(         'book_category',         'book',         array(             'label' => __( 'Book Categries' ),             'labels' => array(                 'name' => 'Book Categries',                 'singular_name' => 'Book Categry',                 ),             'public' => true,             'show_ui' => true,             'rewrite' => array( 'slug' => 'book_category' ),             'capabilities' => array(                 'assign_terms' => 'edit_guides',                 'edit_terms' => 'publish_guides'             ),             'meta_box_cb' => 'show_book_category_ui'         )     );      Edit: I managed to make the url change by following Milo's advice. But the taxonomy- book_category.php then becomes useless. Trying to rename it to taxonomy- books.php did not work. What should be the name of this file now ?


TinyMCE Add media and fullscreen buttons not working

I am using twentytwelve theme and I have a custom form where I am using TinyMCE for the content with the following code provided by wordpress: `wp_editor( $content, $editor_id );` The buttons for adding media and fullscreen mode are not working. They do work inside the admin however. Do i need to insert some kind of additional file inside my form page to make them work? I found this post: Add Media + Quick Edit buttons not working However, it does not provide a solution. Thank you.


Pass variable to hook. Its possible?

I have this hook created to retrieve user password when he register or update his pass. I dont want my client to touch wordpress core so i was planning to use a hook in wp-includes/user.php All this come from this other post as i cant find any other better solution MY problem is that the hook is being called but variables are empty.               function encrypt_password_function($pass, $id){         global $wpdb;         $encrypted=sha1($pass);         $wpdb->query($wpdb->prepare("UPDATE wp_users SET iphone_pass = %s WHERE ID = %d",array($encrypted, '10')));     }               function encrypt_password() {         do_action('encrypt_password');     }     add_action('encrypt_password', 'encrypt_password_function', 1);


WordPress Errors after Host Migration

Total WordPress newb here, you guys. I recently moved WordPress files from BlueHost to GoDaddy. All was well on BlueHost. I moved the following files to GoDaddy.   * wp-content   * wp-admin   * wp-include   * All root files including wp-config.php Most of the site appears to work, however `wp-admin` is hosed. There is also an error on each of the public facing WordPress pages. Here are the errors I am receiving: > **WP-Admin error**   >  **Warning:** `call_user_func_array()` expects parameter 1 to be a valid > callback, function '`ssjp_Init`' not found or invalid function name in > `/file directory/public_html/wp-includes/plugin.php` on line 429   >  **Warning:** Cannot modify header information - headers already sent by > (output started at `/file diectory/public_html/wp-includes/plugin.php:429`) > in `/file directory/public_html/wp-includes/pluggable.php` on line 896 The WordPress codex forum suggests it is an issue with encoding, special characters or a lack of `?>` at the end of these files. I have tried to fix all of this with no avail. I have also quadruppled checked the `wp-config.php` file for errors. Any suggestions would be awesome!


WordPress folder ownership issues

Hi I set up wordpress on a VPS and I'm running into two problems:   1. Either WordPress asks for ftp details in order to update plugins or delete them or   1. Through FTP I cannot delete files as I get a permission denied error. Problem 1 is solved by running: sudo chown -R www-data public_html Problem 2 is solved by running: sudo chown -R myusername public_html Solving one problem creates the other apparently. I want to be able to login with my user to ftp and modify anything, while I also want wordpress to be able to update plugins and such things. Am I doing something wrong?


How to apply a patch?

I found a patch I want here:   http://core.trac.wordpress.org/ticket/17763 I can see the _diff_ , but what do I do now? How can I get that code into my Wordpress? Do I have to copy it manually? Is there anywhere to download it from?


How to get ONLY the URL of the image that show_media_header returns?

I need to use it as a background image but this is killing me because:               show_media_header()      would print               http://url/of/the/header      How can I just retrieve the value? So I can print it just like I need it?


Getting thousands of spam comments

I am seeing that in the last 2 months blocked spam comments in Akismet have jumped from around 8k to more than 100k in each of the last two months. Is there any way to stop them being posted in the first place?


Calling function from within functions.php returns unwanted value

I am trying to customize the output of the [gallery] shortcode to include comment count by this plugin: Facebook Comments for WordPress plugin I found a function by Zack Austin (shown below) that retrieves the number of comments from the Facebook Graph. Furthermore, I found a piece of code by t31os (also shown below) that allows me to customize the output of the [gallery] shortcode. So therefore, I am trying to incorporate the Facebook comment count function into the customizable gallery code. Now, when I insert both pieces of code into my functions.php and call the function from one of my other page templates (`<?php echo fb_comment_count(); ?>`), it works fine. However, when I try calling the function from within functions.php, I get a "0" no matter how many comments there are. I have tried debugging to check the value of $post inside the fb_comment_count function and it generates the following: `id = 818 id = 818 id = 818 id = 818 id = 818 id = 818 id = 818 id = 818` This is wrong since each of those ids should be different for each of the attachment pages the image is on. 818 is the id of the entire gallery page itself. I suppose this is why I keep getting "0" for the comment count since the gallery page (id 818) itself has no comments. To give a better idea of what I'm trying to do, here is a template for the gallery page. Each of those images are linked to their respective attachment pages. The white box with the number inside is the comment count. ![gallery](http://i.stack.imgur.com/pZZ1z.jpg) If anybody can help me figure out how to retrieve the correct comment count for each of the images in the gallery, I'd be very grateful. Thank you. Here is the fb_comment_count function by Zack Austin.               // FB Comment Count (by Zack Austin)     function fb_comment_count($link = 'link') {       global $post;       $url = 'https://graph.facebook.com/';       $posturl = get_permalink($post->ID);       $url .= $posturl;            $filecontent = wp_remote_retrieve_body(wp_remote_get($url, array('sslverify'=>false)));       $json = json_decode($filecontent);       $count = $json->comments;       if ($count == 0 || !isset($count)) {         $count = 0;       }            $comments = $count;       if ($count == 1) {         $comments .= '';       }       elseif ($count == 0) {         $comments = '0';       }       elseif ($count > 1) {         $comments .= '';       }       if ($link == 'nolink') {         return $comments;       }       else {         return 'post_title.'">'.$comments.'';       }     }      And here is the custom gallery code where I'm calling the fb_comment_count function above (about 22 lines from the bottom). Both the code below and the code above are in my functions.php file.               // Custom Gallery     add_filter( 'post_gallery', 'my_post_gallery', 10, 2 );     function my_post_gallery( $output, $attr) {         global $post, $wp_locale;              static $instance = 0;         $instance++;              // We're trusting author input, so let's at least make sure it looks like a valid orderby statement         if ( isset( $attr['orderby'] ) ) {             $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );             if ( !$attr['orderby'] )                 unset( $attr['orderby'] );         }              extract(shortcode_atts(array(             'order'      => 'ASC',             'orderby'    => 'menu_order ID',             'id'         => $post->ID,             'itemtag'    => 'dl',             'icontag'    => 'dt',             'captiontag' => 'dd',             'columns'    => 3,             'size'       => 'thumbnail',             'include'    => '',             'exclude'    => ''         ), $attr));              $id = intval($id);         if ( 'RAND' == $order )             $orderby = 'none';              if ( !empty($include) ) {             $include = preg_replace( '/[^0-9,]+/', '', $include );             $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );                  $attachments = array();             foreach ( $_attachments as $key => $val ) {                 $attachments[$val->ID] = $_attachments[$key];             }         } elseif ( !empty($exclude) ) {             $exclude = preg_replace( '/[^0-9,]+/', '', $exclude );             $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );         } else {             $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );         }              if ( empty($attachments) )             return '';              if ( is_feed() ) {             $output = "\n";             foreach ( $attachments as $att_id => $attachment )                 $output .= wp_get_attachment_link($att_id, $size, true) . "\n";             return $output;         }              $itemtag = tag_escape($itemtag);         $captiontag = tag_escape($captiontag);         $columns = intval($columns);         $itemwidth = $columns > 0 ? floor(100/$columns) : 100;         $float = is_rtl() ? 'right' : 'left';              $selector = "gallery-{$instance}";              $output = apply_filters('gallery_style', "
");              $i = 0;         foreach ( $attachments as $id => $attachment ) {             $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);                  $output .= "<{$itemtag} class='gallery-item'>";             $output .= "". fb_comment_count() ."";             $output .= "                 <{$icontag} class='gallery-icon'>                     $link                 </{$icontag}>";             if ( $captiontag && trim($attachment->post_excerpt) ) {                 $output .= "                     <{$captiontag} class='gallery-caption'>                     " . wptexturize($attachment->post_excerpt) . "                     </{$captiontag}>";             }             $output .= "</{$itemtag}>";             if ( $columns > 0 && ++$i % $columns == 0 )                 $output .= '
';         }              $output .= "

\n";              return $output;     }


Pages redirected to attachment post

## THE SETUP I'm using WordPress 3.4.2 with Magic Fields 2 plugin. Using MagicFields2, I've added a custom field to the builtin 'page' post type. This field is called 'section_header' (which is basically just an attachment post type). My permalink structure is `/%category%/%postname%/`. ## THE PROBLEM Sometimes, when I try to view a page with a 'section_header' set, I get redirected to a post for the attachment instead of the post that I'm trying to view. I've noticed that the page and the attachment have the same title when this happens. It seems that the attachment is somehow getting a permalink that is superceding the permalink of the page. ## A WORKAROUND I can make the page display if I can the permalink of the page. Changing the title of the attachment in the Media Library does NOT seem to change the permalink of the attachment. ## AN IDEAL SOLUTION My ideal solution would let me change the permalink of the attachment instead. How can I accomplish this? Thanks!


Hook only specific post type

with this function I change the title of my posts in the posts type 'alternatives'. My problem is that Wordpress changes all my titles now. Does anyone know how I can set this for the specific custom post type only?               // Change alternatives title     function alternatives_title( $title, $post_id ) {         if( get_post_type( $post_id ) == 'alternatives' ) {             $title = $title . ' alternative';            }          return $title;     }     add_filter( 'the_title', 'alternatives_title' );     add_filter( 'get_the_title', 'alternatives_title' );


Load posts into sidebar and paginate via ajax?

Is it possible to paginate, or load the next / previous posts in the sidebar without messing with the entire page pagination? Such as AJAX? Right now I'm querying custom post type posts to load the latest 2 posts, and need to load the next or previous in it's place. Any Ideas? * * * EDIT: I tried Bainternet's suggestion but still can't get it to work. I put this in my sidebar exactly as shown:               <?php $args = array('posts_per_page' => 1);     $sidebar = new WP_Query($args);      if ( $sidebar->have_posts() ) :          while ( $sidebar->have_posts() ) : $sidebar->the_post(); ?>
                 <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>
              <?php endwhile;       endif; ?>                           <input type="hidden" name="offset" id="offset" value="1">         <input type="submit" name="more" id="more" value="Get more links">                        And this in my functions:               add_action('wp_ajax_nopriv_more_links', 'my_AJAX_more_links_function');          function my_AJAX_more_links_function(){     check_ajax_referer('more_links');     $success_response = new WP_Ajax_Response();     $args = array('posts_per_page' => 1 , 'offset' => $_POST['offset']);     $sidebar = new WP_Query($args);     if ( $sidebar->have_posts() ){           while ( $sidebar->have_posts() ) {             $sidebar->the_post();              $out .= '
';             $out .= ''.the_title().'
';         }         $success_response->add(array(                     'what' => 'has',                     'data' => array('html' => $out, 'offset' => $_POST['offset'])         ));     }else{         $out = __('Sorry but No more!');         $success_response->add(array(                     'what' => 'none',                     'data' => $out                 ));     }     $success_response->send();           exit;        }     add_action('wp_head','add_scripts_121');     function add_scripts_121(){     wp_enqueue_script('wp-ajax-response');     }


Can / should a widget plugin define its own Widget Area?

1. Should a plugin be able to add a widget area above the_content? (Without requiring template/theme changes.)   2. What would be the best way to do this? Doubts: widgets typically echo output to the screen; the_content filter examples always return $content. The code below does something but seems flawed: testing indicated that shortcodes were not being parsed so I added do_shortcode.               function insert_above_content_widget($content) {          if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Above Content') ) :      endif;          echo do_shortcode($content);          }          add_filter( 'the_content', 'insert_above_content_widget' );      Seems like it would be a useful thing to be able to do but this approach doesn't feel right somehow. Anyone see any problems?


how to use shortinit in wordpress

I want to load a minimal resources in Wordpress because the server that I'm working on is very slow. I tried defining short init in the `wp-config` file:               define('SHORTINIT', true);      But then I got this error:               Fatal error: Call to a member function main() on a non-object in /somepath/functions.php on line 790      So I tried adding this line on the uppermost portion of the plugin that I'm working with:               require_once(ABSPATH . 'wp-includes/load.php');      But it didn't work. I tried putting it on the uppermost part of the plugin instead:               <?php if ( ! defined( 'ABSPATH' ) ) exit;     /*     Plugin Name: someplugin     */     define('SHORTINIT', true);      But I get the following:               Notice: Constant SHORTINIT already defined in /someplugin/someplugin.php on line 9      Any ideas how to do this properly?


Does dbDelta delete columns as well?

I created a table using the dbDelta function and then removed a few columns and added a few. The new columns did get created but the old columns did not get deleted from the table. Is there a different way I am supposed to delete columns from the table ?


Language translation on a fresh english installation

i need to translate an english wordpress installation to italian language,but i would like to mantain both languages en/english, so the user can choose which to turn on fron the frontend side. I need italian as default language and english for choice, i would like to know if is it possible to have them without re-installing the wp, and how to do that? Does i need to translate some file manually? or some plugin extension could help me? Definitely i would like Italian language for Backend, and Eng/Ita (choose) for frontend side. I Installed a third parties theme, don't know if this could help on translation :/ Any suggestion appriaciated, thanks.


Accessing Subdirectories in WordPress Install

I have scripts that are in a subdirectory of my WordPress install folder. They are on the same level as the /wp-content/ and /wp-admin/ folders. I'm running them as form processing but I've got the site set to permalinks with a post structure (http://www.example.com/testcategory/testpost). My assumption is that I can't access the script files (I get a 404 error; an example would be like http://www.example.com/quform/test.php) because the .htaccess rewrite is getting in the way of it and it thinks it's a page on the site but there's no content for it. I've tried to put an empty .htaccess file in the quform folder and then I tried to edit the code to turn the ReWrite Engine off but neither of those worked. I've searched around but none of the questions on here, though similar, have provided an answer for what I'm looking for. Is there a way to create an exception for certain subdirectories in the .htaccess file? ## EDIT Here is my .htaccess info               # BEGIN WordPress     <IfModule mod_suphp.c>       suPHP_ConfigPath /home/millerme/etc/     </IfModule>     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      ## EDIT So I was able to fix it but I still don't know what was causing it. Basically if I deleted a folder of file that was already on the server and then recreated it exactly as it was, it then was recognized by the server and I was able to access it. The original files had file permissions of 775 so it wasn't a matter of file permissions being set incorrectly. This site was migrated from another server where I downloaded the files and moved them over, so I'm assuming something happening that process. Any ideas on what would have caused the issue?


How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?

Normally, a MySQL database can be exported and imported using these simple SSH commands: **Export:**               mysqldump -u USERNAME -p DATABASE_NAME > filename.sql      **Import:**               mysql -u USERNAME -p DATABASE_NAME < filename.sql      But it's not that simple when it comes to WordPress. From what I see, additional parameters need to mentioned, such as `\--add-drop-table` for instance. The WordPress Codex does provide some info, but it looks cluttered and not clear enough. It would be great if someone who uses command-line can share the proper commands to export and import a WordPress database, with some explanation (of any new parameters used). Also, are there any reasons why it wouldn't be advisable to use command-line when dealing with database, and instead go with a GUI like phpMyAdmin?


Create User using JSON API

I am using JSON API for get the post list from my App. I need to create user(Register new user) from App. May I know how to add new function to Wordpress JSON-API? Regards, Alex


How to display all posts on one page and then open them inside a modal window

I'm working with the WordPress Bootstrap theme. I want to show all the post listing with their featured image on my page and after clicking that image I want to open the post description into a modal window. How can I achieve it? I have a post-category named marble. I want to show all the posts related to this category on a single page and want open them inside a modal window. I think I should use this loop but I'm unable to do so.               <?php query_posts('posts_per_page=10'); ?>     <?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>          <?php endwhile; ?>     <?php endif; ?>


wp_list_bookmarks(); not displaying anything

Bizzarely, I can't get the `wp_list_bookmarks();` function (inside a page template) to render anything. Hope somebody can point out something obvious! Cheers. Here's my code:               <?php     /*     Template Name: Blogroll     */     ?>     <?php get_header(); ?>     <?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>

            <?php the_content(); ?>       <?php wp_list_bookmarks(); ?>
          <?php endwhile; ?>     <?php get_footer(); ?>


Meta Box Value not saving / populating?

Ok, I have a meta box setup now that populates with the all the registered post types. That part works fine. But, upon selecting an option in the dropdown list, and saving / updating, the value shows the first choice when the page reloads. Also, does anyone know if get_post_types can exclude specific post types? Here's my code:                   add_action( 'add_meta_boxes', 'cd_meta_box_add' );         function cd_meta_box_add()         {     add_meta_box( 'my-meta-box-id', 'My First Meta Box', 'cd_meta_box_cb', 'page', 'normal', 'high' );         }              function cd_meta_box_cb( $post )         {     $values = get_post_custom( $post->ID );     $selected = isset( $values['my_meta_box_select'] ) ? esc_attr( $values['my_meta_box_select'][0] ) : '';     wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );     ?>          <p>         <label for="my_meta_box_select">Post type: </label>         <select name="my_meta_box_select" id="my_meta_box_select">             <?php $post_types=get_post_types('', 'objects'); foreach ($post_types as $post_type): ?>             <option value="<?php echo esc_attr($post_type->name);?>"  <?php selected( $selected, '$post_type->name' ); ?>><?php echo esc_html($post_type->label); selected ?></option>             <?php endforeach; ?>         </select>     </p>                   <?php            }                   add_action( 'save_post', 'cd_meta_box_save' );         function cd_meta_box_save( $post_id )         {     // Bail if we're doing an auto save     if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;          // if our nonce isn't there, or we can't verify it, bail     if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;          // if our current user can't edit this post, bail     if( !current_user_can( 'edit_post', $post_id ) ) return;          // now we can actually save the data     $allowed = array(          'a' => array( // on allow a tags             'href' => array() // and those anchords can only have href attribute         )     );          // Probably a good idea to make sure your data is set          if( isset( $_POST['my_meta_box_select'] ) )         update_post_meta( $post_id, 'my_meta_box_select', esc_attr( $_POST['my_meta_box_select'] ) );              }


Allow different <span> tags in widget titles

How can I make widget titles allow HTML? I want to add icons from an iconfont to the titles like               Widget Title Here       I tried the following but it does not work at all...               function html_widget_title( $title ) {         $title = str_replace( '[', '<', $title );         $title = str_replace( '[/', '</', $title );              $title = str_replace( 's]', 'span>', $title );              return $title;     }     add_filter( 'widget_title', 'html_widget_title' );


WP-Snap too slow (caused by WP_Query?)

I have a website with 10.000 posts... WP Snap alphabetizes the posts and puts it out with WP_Query, but it is slow as hell, which is very frustrating. My question would be: what can I do about it? Is there any alternative to wp_query? Or is the cause of this problem something else?


Create keyboard shortcuts for HTML mode

I always use the HTML editor for writing all my post. So I always have manually typed all the tags such as "`<strong></strong>`" for bold... "`<i></i>"` for italics etc. I don't want to use the Visual Mode, as I use many plugins for which I have to type in shortcodes and many other personal reasons for using HTML mode only. I was wondering if I can create shortcuts for all the operation (in HTML editor) which otherwise are present in the Visual Mode.


Spacing within the excerpt

I am trying to find out how I can control how an excerpt is displayed using PHP. How do I get it to render the html spacing within the post instead of just showing one big paragraph.Hope that makes sense. Let me give you an example. So my client has syndicated post and at the top of each post he wants to include a hyperlink to the actual author . Then there needs to be a line break then the actual excerpt of the content under it. Currently the excerpt just shows everything as one paragraph. I have managed to enter some php code to render the hyperlink in the excerpt but stuck on how to not let the excerpt strip the spacing.


Insert to wp_footer if widget is found in the sidebar

I trying to insert a code into wp_footer whether the widget is present or not in the sidebar. How to avoid the unnecessary code in the footer? Add the code only if widget is present the sidebar.                class CustomWidget extends WP_Widget {             function CustomWidget() {           add_action( 'wp_footer', array($this,'footer'), 10, 1 );           }             function widget($args, $instance) { }             function update( $new_instance, $old_instance ) {}             function form($instance) {}             function footer {           $all_widgets = $this->get_settings();                foreach ($all_widgets as $key => $wpdcjqverticalmegamenu){                 $widget_id = $this->id_base . '-' . $key;                if(is_active_widget(false, $widget_id, $this->id_base)){                }                  }          }


Theme Customizer uploads image size issue

I've made an option to allow users to upload a custom background image to their site using the Customize theme section of wordpress but I'm having trouble uploading large (in pixels) images. An image 900px and 200kb works fine but when I try and upload something 4000px wide it just won't do it, even when the image is small in size (38kb) This seems to make not sense to me, I could understand it if there was a limit to size on the disk but I can't understand how the pixel size could make a difference! This is my code in case:               // This bit adds a custom image to the background     $wp_customize->add_section( 'background_image_section' , array(         'title'       => 'Background Image',         'priority'    => 30,         'description' => 'Upload a background image to replace the default background',     ) );          $wp_customize->add_setting( 'background_image',         array(             'default'      => '',             'transport'    => 'postMessage'         )      );          $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'background_image', array(         'label'    => 'Background Image',         'section'  => 'background_image_section',         'settings' => 'background_image',     ) ) );      I'm using 3.6.1 for this site


importing users where password is provided as md5 + much metadata

I have a spreadsheet that was provided to me of users to import to a new site I have built. I was provided with the password in MD5 hash form. I suspect if I insert this into the password field in the database, since it is MD5 it will still match their password when the user tries to login on the new system. Is this a correct assumption? I also have a large amount of metadata for each user that needs to be inserted. Because I want to insert the md5 string, and not the password text and the extra custom meta fields, I don't think I can use wp_insert_user. Does anybody have experience with this type of thing? I am thinking I will just do something directly in mysql, rather than hack up a WP plugin, any suggestions would be appreciated though.


Query Event Posts by Date

I am trying to query custom post type (Event) by the current date and the event's start and end date. I would like three options: current, upcoming and past. This is the code I am using, but it is not working correctly.                     $current = time();              switch ($print_type) {             case 'current':                 $meta_quer_args = array(             'relation'  =>   'AND',             array(                 'key'       =>   'event-start-date',                 'value'     =>   $current,                 'compare'   =>   '<=',                  ),             array(                         'key' => 'event-end-date',                         'value' => $current,                         'compare' => '>='                     )              );                  break;             case 'upcoming':                 $meta_quer_args = array(             'relation'  =>   'AND',             array(                 'key'       =>   'event-start-date',                 'value'     =>   date(),                 'compare'   =>   '>=',                  )         );                 break;             case 'past':                 $meta_quer_args = array(             'relation'  =>   'AND',             array(                 'key'       =>   'event-start-date',                 'value'     =>   date(),                 'compare'   =>   '<',                  )         );                 break;             default:                 $meta_quer_args = array(             'relation'  =>   'AND',             array(                 'key'       =>   'event-end-date',                 'value'     =>   date(),                 'compare'   =>   '>=',                  )         );                 break;         }          $query_args = array(         'post_type'             =>   'exhibitions',         'posts_per_page'        =>   -1,         'post_status'           =>   'publish',          'ignore_sticky_posts'   =>   true,         'meta_key'              =>   'event-start-date',         'orderby'               =>   'meta_value_num',         'order'                 =>   'DESC',         'meta_query'            =>   $meta_quer_args     );          $selected_events = new WP_Query( $query_args );