title: Remove images from get_the_excerpt

text:
I'm using a custom function to create a shortcode that displays the latest blog post on the home page of a template. But I'm trying to NOT have it display any images. I know I can use the Advanced Excerpt plugin to have it remove images, but the issue is that it will also remove images from the index.php feed which I want to keep which is using `the_excerpt()` in the template. Here's my custom function that creates the shortcode:               function my_recent_news()     {       global $post;       $html = "";       $my_query = new WP_Query( array(            'post_type' => 'post',            'posts_per_page' => 4       ));            if( $my_query->have_posts() ) : while( $my_query->have_posts() ) : $my_query->the_post();                 $html .= "
            " . get_the_date() . "
" . get_the_title() . "
            " . get_the_excerpt() . "
            ";       endwhile;             endif;            wp_reset_query();            return $html;          }          add_shortcode( 'news', 'my_recent_news' );      I've posted something about this before: get excerpt without images but the solution was to use the Advanced Excerpt plugin, but for this I am trying to use the excerpt on the home and the blog feed page but I want to preserve the `img` markup on the blog feed and remove the img tag from the custom shortcode. I've tried to used just `the_excerpt()` in that custom shortcode function, but that just seems to break the whole function and display some really odd stuff. I'm not too sure if I need to have a filter somewhere to strip that out or what. I'm also not sure that if I do need a filter, where that would go? Before the loop, after the loop, or does it need it's own constructed argument?


title: Custom Post Type content isn't shown

text: My problem is to display the content of custom post types. The Dashboard- preview shows the right content (/vita/vita-test/), but I can't see it at the homepage ( /vita/ ). It displays the content of index.php Why isn't found „vita-test“? My permalink is /%post_id%/%postname%/ my post type $args               'rewrite' => array("slug" => "vita"),     'show_in_nav_menus' => true      I also use               query_posts('post_type=vita&post_status=publish');     if ( have_posts() ) : while ( have_posts() ) : the_post();       Do you have an idea where my mistake is? Thanks so much!


title: wp_trash_post function to only apply to posts, not pages!

text: I have the following function that deducts at point when a post is removed. But when I remove a page, the wp_trash_post is also called.               // Remove 1 point if their post get removed     function deletePointFromUser($post_id) {     $post = get_post($post_id);     $authorid = $post->post_author;     $currentQPointNumber = get_user_meta($authorid, 'points', true);     // Delete 1 to the current Point Score     update_user_meta($authorid, 'points', $currentQPointNumber-1);       }     add_action('wp_trash_post', 'deletePointFromUser');      Is there a way to restrict this function to only apply to posts and not pages?


title: Layout Builder.

text: I recently bought a theme from Theme forest called Enfold: http://www.kriesi.at/themedemo/?theme=enfold The pages have an "Advanced layout" building that lets you build you content how you need. I found some plugins like http://wordpress.org/plugins/page- layout-builder/ that are similar, ie, based on modules like accordion, tab, header, icon list etc that you can use to mold your content. I am really really curious how one would go about creating your own layout builder. IE, is it just an api/interface for shortcodes? I could not find any resources/tutorials so any help in the right direction is appreciated.


title: Custom pagination for custom post types (by names)

text: I have two custom post types that deal with people's names. Right now, in browsing views, it just lists them all alphabetically and the pagination breaks them down by numbers, which isn't terribly helpful when you're trying to find a specific person. Specifically, I've been asked to create pagination links for people that look like this:   * A-G    * H-M    * N-Q    * R-Q My problem - I can't figure out how I can query the custom post types by the first letter of one field. Then, I'm not sure how I can go about creating the pagination in this way. Does anybody have any suggestions? Thank you!


title: WP Admin Bar shown at the bottom

text: Suddenly, while I was working, the admin bar (that by default appears at the top) has appeared on the bottom of the page and it is unstyled, it is simply a list of links one below the other. I've checked both header.php and footer.php and all seems to be at the right place (wp_head() and wo_footer()). I'm using the last stable version of WordPress (3.1.3). What could be the problem? Thanks


title: Older entries link within category page

text: I am building a custom wp theme and I have a category called 'blog'. On here I have all of my posts displaying from the category 'blog' and a link at the bottom that says older entries. When i click the link it goes to 404. The URL is                http://localhost:8888/blog/page/2/      As you can see it's putting the category /blog/ in the url causing a 404. If I remove 'blog' from here it goes back to the home page. and then does show older posts but i need it to stay on the category page and show older posts. It's driving me crazy!


title: Add custom menu item type

text: Is there a way to add custom menu type to the menu editor? I know I can add items dynamically with the `wp_get_nav_menu_items` filter, but I would like to have the position of those items configurable.


title: How to prevent duplicate posts with wp_insert_post on single.php?

text: I'm getting a really strange bug (WP 3.1.3). My goal is to have users create a new post simply by landing on a single post. In order to make that happen, I have the following code in my single.php:                   <?php         //-- Set up post values         $myPost = array(             'post_status' => 'publish',             'post_type' => 'post',             'post_author' => 2,             'post_title' => 'e3i8ir',             'comment_status' => 'closed',             'ping_status' => 'closed',             'post_category' => array(24),         );              //-- Create the new post         $newPostID = wp_insert_post($myPost);              ?>      By all rights, this should just insert one record, right? When I use this function, however, it creates TWO posts, exactly alike. Looking at the page, the_content only displays once, so it's not like the page is displaying multiple times (and therefore causing two wp_insert_post calls). Does anyone have any ideas what would cause this? Thanks in advance, --eric


title: Return HTML Template Page with PHP Function

text: I want to create a form that I can use a shortcode to insert into my site. It would be really nice if I could create the HTML part in a seperate file and then insert it with a PHP shortcode (to seperate the logic of the page from the mechanics of making it into a shortcode). How could I do this? ## -- Update -- This is what I've done: I have two files. One called 'profiletemplate.php' and one called 'scodes'. They are both part of a plugin that I am making for my site with an init.php that initializes them. Here is their content: **init.php**               <?php     require_once(dirname(__FILE__).'/pages/scodes.php');     ?>      **scodes.php**               function jf_testcode() {         include dirname(__FILE__) . 'profiletemplate.php';     }          add_shortcode('testfield', 'jf_testcode');      **profiletemplate.php**               <?php // Template for my form shortcode ?>     <form>     Testing     </form>      I then use the [testfield] shortcode on a page in my site. ## Update 2 So this method is working, but it isn't inserting the HTML where the shortcode is called. Instead it is just inserting the content at the top of the page (like if I said 'echo 'Testing'' instead of 'return 'Testing'' in a function.


title: Create and style menu

text: I have been assigned with the task to create a menu that can be added or removed from wordpress admin. Right now the menu is hard coded into the templates. But I want to use default menu function `wp_nav_menu` and the menu should look exactly like before. But trying for the whole day i cannot figure how to make the menu using wp_nav_menu and look exactly like the menu item currently having in this site. I can make the menu using wp_nav_menu but the menu is looking like a mess and not like this.


title: Plugin: Google Analytics for Dashboard error - Timestamp is too far from current time

text: Has anyone used the **Google Analytics for Dashboard** plugin? I've installed it successfully, but whenever I try to link it to my Google Account using the Start Login Process button, I keep getting a weird message that goes like:               Timestamp is too far from current time: <a Unix timestamp here>      I'm using WordPress 3.1.3. Any ideas what's happening here? Thanks,   m^e


title: Without using wordpress cms Is it possible to signup from my html page

text: Is there any method to signup to **wordpress** site from my html page. So that the registered user details must fairly added to database table. I mean the action must be **similar** to the **process how we generally signup to wordpress cms**. Thank you.


title: Pasting code into WordPress post - LFs being eaten

text: I'm sure this is an inappropriate question for this SE because it's not programming related AFAIK but maybe someone here has an idea. I've been posting code into my blog for years and have had no formatting concerns. Now all of a sudden, when I copy and paste code from whatever IDE I'm working in, the LFs are stripped out. I can't imagine what may have changed. Some additional troubleshooting info:   * I'm pasting into the visual editor, not the HTML editor (this is how I've always done it)   * pasting into a PRE section doesn't help   * the CR/LF information is in the clipboard (when I paste into Word for example, the LFs and tabs are preserved)   * pasting using Paste Text has the correct LFs but strips out tabs so that's not an option   * pasting using Paste from Word does the same   * I'm using the latest WP update (as of this time) WP 3.1.2   * I"m using TinyMCE, but have disabled it and that's had no effect; also WP-Syntax, no joy Can anyone suggest something else to look into to figure this out? It's killing me. I've re-read the section in the Codex just to be sure I'm not missing something obvious, but there's nothing that pops up. I've been pasting code into my blog (www.tomauger.com) for years and years now without any special plugins, just sticking it inside PRE tags and have never ever encountered this issue. What could have changed?


First, Here is the full error:               PHP Fatal error:  Call to undefined function download_url() in /path/to/wordpress/wp-admin/includes/media.php on line 562      I have also posted the related functions at the bottom of my question. I am modifying a script for my company's website which allows us to automate the retrieval and uploading of content from our content provider. Due to the way they organize their XML, I need to upload the images related to the articles separately from the main body of the articles. I tried using media_sideload_image() to do this, but I recieved the error: The function (media_sideload_image()) which calls download_url and results in the error:                PHP Fatal error:  Call to undefined function download_url() in /path/to/wordpress/wp-admin/includes/media.php on line 562      As can be seen, I successfully included media.php - and the rest of my script has already been implemented on to the site, and I have not run into any other issues with accessing Wordpress files. The error would appear to be with media.php itself - which I find unusual. Any ideas on how I can resolve this problem? Alternatively, if you know of another function I can use to do this, that would also be appreciated. By all means, if you require any more details on the issue just ask.               /**      * Download an image from the specified URL and attach it to a post.      *      * @since 2.6.0      *      * @param string $file The URL of the image to download      * @param int $post_id The post ID the media is to be associated with      * @param string $desc Optional. Description of the image      * @return string|WP_Error Populated HTML img tag on success      */     function media_sideload_image($file, $post_id, $desc = null) {         if ( ! empty($file) ) {             // Download file to temp location             $tmp = download_url( $file );                  // Set variables for storage             // fix file filename for query strings             preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $file, $matches);             $file_array['name'] = basename($matches[0]);             $file_array['tmp_name'] = $tmp;                  // If error storing temporarily, unlink             if ( is_wp_error( $tmp ) ) {                 @unlink($file_array['tmp_name']);                 $file_array['tmp_name'] = '';             }                  // do the validation and storage stuff             $id = media_handle_sideload( $file_array, $post_id, $desc );             // If error storing permanently, unlink             if ( is_wp_error($id) ) {                 @unlink($file_array['tmp_name']);                 return $id;             }                  $src = wp_get_attachment_url( $id );         }              // Finally check to make sure the file has been saved, then return the html         if ( ! empty($src) ) {             $alt = isset($desc) ? esc_attr($desc) : '';             $html = "<img src='$src' alt='$alt' />";             return $html;         }     }      The function where I call media_sideload_image() in my code:               //Upload the image if it exists, and return the post_id     function upload_image($post_id, $image_url) {         require_once('wp-admin/includes/media.php');         $image_url = 'http://admin.gkbusiness.com/gkbusiness/files/2011/04/LOGOGKMBUS1.jpg';         media_sideload_image($image_url, $post_id);         return $post_id;     }


title: How to create a wordpress template without using any page

text: I'm not sure WordPress was build for this, but this is what I'm trying to achieve:   * I want to make a specific URL inside wordpress accessible, for example `www.example.com/some-template` .   * This specific URL should be editable from a php file, part of an existing wordpress theme I'm working on, something like `some-template.php`)   * This is the tricky part: I don't want wordpress users to be able to see or use this template from the custom templates dropdown menu when editing a page. I don't want a specific page to exist in order for this to work. This template should work without any page (I'm not interested in creating a page and hiding it, or hiding the template). The reason I'm trying to do this, is that I want to have a specific template that pieces together a few pages and menus from wordpress and creates some kind of a 'custom view' which is pulled every few hours to another site. It's all part of a bigger picture (the details are not that important). While searching, I only found out that it's possible to create custom templates for at least one page, but then that page must exist in wordpress for the template to work. Does anyone have an idea of how to achieve this?


title: Author website URL

text: I've assigned a specific html page (let's call it an author bio page) to each user in the 'website' field within the user admin area. How do I get that URL to display within a single page post? I'm assuming that I'm to use $curauth->user_url but it returns a blank page.


title: Show how many images are attached to a post/page on compose page

text: On the front-end, I'm using a query to show all attachments attached to the current post. However, on the compose page, there's no way for a user to see how many images are attached without opening up the media gallery. I would like to add a meta box (or something) to display the current number of attached images – perhaps something like this: http://cl.ly/image/0a2q171v3y2u Is this possible? Thanks!


title: Code markup plugin like the .wordpress.com blogs offer?

text: The free wordpress blogs (those hosted at wordpress.com) have a build in code formatting plugin Is it possible to get this on private installs of wordpress? I've copied all my posts across but the code formatting feature doesn't work out of the box I'm primarily looking for Java syntax highlighting


title: Custom registration form in shortcode getting internal server error 500

text:
I created a custom registration form which works fine when used as a custom page template. I needed it as a shortcode so I created a shortcode using the function below               /* Custom shortcode */     function team_reg_form(){     require_once(ABSPATH . WPINC . '/registration.php');     global $wpdb, $user_ID;          echo '
';          //if the form is posted we need to validate     if ('POST' == $_SERVER['REQUEST_METHOD']) {        $user_login = $_POST['user_email'];        $user_email = $_POST['user_email'];             $billing_phone  = $_POST['billing_phone'];                //initialize a WP_Errror object        $errors = new WP_Error();             //email is required        if (  isset($user_email) && $user_email == '' )           $errors->add('email_required', __('The email field is required.'));        //email needs to be a valid email        if (  isset($user_email) && !is_email($user_email) )           $errors->add('email_invalid', __('The email is not valid.'));                if(!$errors->get_error_codes())            $errors = $user_id = wp_insert_user(array('user_login' => $user_login, 'user_email' => $user_email));               update_usermeta($user_id, 'billing_phone', $billing_phone);               //update_usermeta($user_id, 'first_name', $first_name);               update_usermeta( $user_id, 'first_name', $_POST['first_name'] );        //if we still do not have any errors it was a success        if (!is_wp_error($errors)) {             wp_redirect( 'https://example.com/'); exit;        }else{//output the errors           foreach($errors->errors as $code => $error)              echo '
'.$error[0].'
';        }     }     echo '<form name="registerform" id="registerform" action="'. the_permalink().'" method="post">
     '. _e('Name').'
     <input type="text" name="first_name" id="first_name" class="input" value="'. esc_attr(stripslashes($first_name)).'" tabindex="2" />

     '. _e('E-mail').'
     <input type="text" name="user_email" id="user_email" class="input" value="'. esc_attr(stripslashes($user_email)) .'" tabindex="2" />

     '. _e('Phone').'
     <input type="text" name="billing_phone" id="billing_phone" class="input" value="" tabindex="4" />
          '. do_action('register_form').'
     <input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="'. esc_attr_e('Register').'" tabindex="100" />
          </form>
';     }     add_shortcode('teamform', 'team_reg_form');


title: Best Practices for Video Uploads to Wordpress

text: I'm working on a theme and one of the features I'm quite happy with is the slider supports background videos. The problem is however, that Wordpress (although I think it's more a PHP issue) has a limit of 2MB on file uploads, and as you know, most videos are bigger than that. So I haven't got that much experience with themes, but what is the best practice in this situation? I guess users could use youtube and link to those videos, but that seems a bit drawn out. Any ideas are appreciated!


title: Combining the Edit Media Screen with the Links Manager?

text: Is there a way to somehow integrate the link manager into the media edit screen? So if a user uploads or replaces a media item, they can also add the media's attachment link to a link category from the same screen.


title: Alternatives to handle customizer settings

text: My theme JBST (https://github.com/bassjobsen/jamedo-bootstrap-start-theme) makes use of https://codex.wordpress.org/Theme_Customization_API. I need possibility to add some default settings to the customizer. I know `add_setting()` has the option to add an default value. Using this default value seems to give troubles for child themes to define it's own default settings. I found some kind of solution already: initialization of the customizer:                $wp_customize->add_setting( 'color', array(     'default'        => false     ) );      see also: https://core.trac.wordpress.org/ticket/26817 In my theme files:               $color = get_theme_mod( 'color',color);     if(!empty($color))         //check for empty cause there will be a fallbback         //fallback doesn't need the declaration below     {         echo 'color:               '.$color.';';     }      in functions.php of the parent theme:               function jbst_default_settings()     {     do_action('jbst_child_settings');     if(!defined('color'))define('color','#ED9C28');//default     }         in functions.php of the child theme:               add_action('jbst_child_settings','sample_jbst_child_settings');     function sample_jbst_child_settings()     {         define('color','red');//child theme's default     }         I wonder of someone could provide me a better / alternative solution?


title: Set a category for a page

text:
My current theme has a portfolio section where you can have an array items based on what category they are in. My problem is that I have several pages that I want to be in the portfolio section but can't add them there because you can't assign categories to individual pages only posts. Is there any method or plugin around this issue? This is some code that I believe calls the category in my portfolio.php:               <?php  if(is_category() && in_category($current_id) || post_is_in_descendant_category($current_id)){?>
<?php single_cat_title(); ?>

<a href="<?php echo get_category_link(get_option('boldy_portfolio'))?>">All projects
                 <?php                            $categories = get_categories('hide_empty=1&child_of='.$categs);                         foreach ($categories as $cat) {                         echo ('
cat_ID).'">'.$cat->cat_name.'
');                         }                     ?>
         <?php } ?>

                 <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<a href="<?php the_permalink() ?>"><?php the_title(); ?>
                             <a href="<?php echo get_thumb_urlfull($post) ?>" rel="prettyPhoto" title="<?php the_title();?>"><?php the_post_thumbnail(); ?>
<?php the_excerpt() ?>

                 <?php endwhile; ?>      Thanks Nick.


title: Add an alignment option for images

text: A rare event - I want to do something in WordPress but have no idea how to go about it and searching turns up literally nothing. When you're inserting an image into a post, you get alignment options: 'none', 'left', 'right', 'center'. These result in the image being inserted with a CSS class related to alignment, like 'alignleft', 'alignright' or 'aligncenter'. Great. What if my theme was a little more complex and I wanted to add a couple options here that, just like the core options, would just add a new CSS class to the inserted images? For example - a 'right margin' option that I could style with some fancy CSS to get some more complex layouts? Any pointers on where I might start?


title: Change taxonomy slug in database

text: I am using Events Calendar Pro and due to a bug multiple Venue taxonomies were created. For example, I have museum, museum-2, etc. I would like to delete the duplicates but assign the event associated with the duplicate venue to the 'main' venue. Is there a find/replace I can use that would do this for me? Other suggestions are welcome. Thank you.


title: How to Run a jQuery Script after a Javascript Script has Finished in WordPress

text: I've got javascript (a) and jQuery script (b). I need (b) to run after (a) has finished running. I need them to run sequentially. How do I do that? In wp_enqueue_script, I've made (b) dependent on (a), but it appears that (b) runs before (a) has finished processing. I'm trying to use the_maps_bounds, a variable I've put in the global scope. It gets set in (a) and used in (b). The problem is that (b) is trying to use the variable before it has been set. Any suggestions? Thank you.


title: Unable to delete a Category and Tag that share same slug

text: In my wordpress site I have a category (e.g Animals) with slug (anim) and a tag with name (Animals) with the same slug (anim). My problem is that I want to delete the category but keep the tag. However whenever I try to change any settings in the category, the tag changes as well (e.g when I change the category slug to anim-old the tag's slug changes as well). It seems to be something to do with the fact that they have the same slug wordpress thinks they're the same. Would there be any way (even in the database using sql) to unlink the category and tag so that I can delete the category?


title: Require featured image

text: I would like to require a featured image on a site I am developing. I tried the code here: Make featured image required and nothing happened - the JS showed up in the site header, but I could still save the post without a featured image, and never got an error message. There are several plugins that do this, such as Mandatory Field and WyPiekacz, but I need to do something more complicated... I have a custom meta box with radio buttons. I need to require a featured image only if a certain radio button is checked. I'm already requiring some other fields (category and some custom taxonomies) if certain radio buttons are checked, using jQuery validation. So I guess I can boil this down to two questions:   1. What's a good way to require a featured image?   2. How can I integrate that into some existing validation and require a featured image only if a radio button is selected? Question 1 is probably much easier to answer, and if someone can answer #1, then I can probably figure out #2 on my own.


title: How to Add a Custom Size for Thumbnails for WP - Gallery

text: I am using "Lightbox Plus" plugin to create lightbox image overlay on the top of thumbnail galley. Now my question is how I can set a size for Thumbnails without affecting on the lightbox image overlays. I mean when I try to set a scale for Thumbnails through wp-Gallery edit option it apply the size even to the overlays (I would like to keep the overlay size as big as possible but this function makes them small like Thumbnails size) I also see this line of code in codex:                  `get_the_post_thumbnail($id, array(100,100) ); // Other resolutions`      but I don't know how and where to use it. Thanks


title: Get post title by Alphabet

text:
I try to call this function to get a list of posts by alphabet. But for some reason i keep getting an error. Call to a member function get_col() on a non- object. What am i doing wrong?               {function get_post_by_alphabet($the_char){     $first_char = $the_char;          $postids=$wpdb->get_col($wpdb->prepare("     SELECT      ID     FROM        $wpdb->posts     WHERE       SUBSTR($wpdb->posts.post_title,1,1) = %s     ORDER BY    $wpdb->posts.post_title",$first_char));           if ($postids) {     $args=array(       'post__in' => $postids,       'post_status' => 'publish',       'posts_per_page' => -1,       'caller_get_posts'=> 1     );     $my_query = null;     $my_query = new WP_Query($args);     if( $my_query->have_posts() ) {      echo 'List of Posts Titles beginning with the letter '. $first_char;       while ($my_query->have_posts()) : $my_query->the_post();         echo '
<'.the_title().'
';       endwhile;     }     wp_reset_query();  // Restore global post data stomped by the_post().     }     }          get_post_by_alphabet('H');     }


title: Multilingual attachment links

text: I have a site that operates in English and French, and uses wp-document- revisions to manage file attachments connected to a custom post type. The function works flawlessly for English, but I am experiencing issues with French. The actual file (for example, 3a30c28481152795125279fc12f93e90.pdf) exists in the proper directory. And the post_meta record exists connecting the hashed filename and the French language post. But I cannot access the file directly with this filename, and the post-slug is not working. Any thoughts? Thanks


title: Nav Walker: Set ul id to current item's title

text:
I'm trying to assign an ID to a sub-menu `ul` that matches the associated items `li` in my nav-walker. Here's the output I'm looking for:

             Menu Item 1

Sub Item

Sub Item

Sub Item

      Here's the relevant code in my `walker`               class Roots_Nav_Walker extends Walker_Nav_Menu {            private $curItem;       private $curSectionItem;            function check_current($classes) {         return preg_match('/(current[-_])|active|dropdown/', $classes);       }            function start_lvl(&$output, $depth = 0, $args = array()) {         $this->curSectionItem = $this->curItem;         $output .= "\n
curItem->title."\">\n";         // $output .= var_dump($this->curItem); // Debug       }      The var_dump returns null and no output is added. Anything obvious I'm doing wrong?


title: post/page content

text: i am trying to insert a post/page into one of my themes files and it wont display shortcodes or php i have created a page called home in the wordpress admin-paned and inserted into my code the following:               <div id="home_page"> <!-- echos the content from the page "home" id:43 -->                 <?php $home_id = 43;                 $home_page = get_page( $home_id );                 ?>                   <?php echo $home_page->post_content; ?>         </div> <!-- end #home_page -->      and non of the shortcodes that i have in the page work. i installed a `php in post or page` and tried useing php and it doesnt work. when i insert               echo do_shortcode('[youtube_sc url=http://www.youtube.com/watch?v=Db3XGpt6nNU]');      directly into the code it works. does anyone know y this happens? thank you.


title: Custom Post Type 'hierarchical' Help!

text: Not quite sure why it's even available because I cannot find any documentation on how to make a custom post type hierarchical other than in the optional parameter 'hierarchical' => true....Can someone please give me a basic example of a hierarchical custom post type and the child custom post type? For example, if I wanted to create a custom post type of "Crayon Box" and a child custom post type of "Crayon", how would one do this? Again, I am more than willing to read through some documentation but there is absolutely nothing that I can find on this in the Wordpress Codex. **UPDATE:** I did read in one post where someone used post_parent but I am also unable to find documentation on this parameter...


title: Tabindex on text input immediately after WordPress title input

text: The following code adds a text input for a subtitle to the space directly below the title input, via the `edit_form_after_title` hook. However, when editing the title, pressing tab moves the cursor to the main post editor and I can't figure out what tabindex I should use (or some other method if available) in order to tab from the title to my subtitle input instead.               add_action( 'edit_form_after_title', 'add_input' );          function add_input(){              global $post;              $options = get_option( 'kia_subtitle_options' );              // only show input if the post type was not enabled in options         if ( isset ( $options['post_types'] ) && in_array( $post->post_type, $options[ 'post_types'] ) ) {                  //create the meta field (don't use a metabox, we have our own styling):             wp_nonce_field( plugin_basename( __FILE__ ), 'kia_subnonce' );                  //get the subtitle value (if set)             $sub = get_post_meta( get_the_ID(), 'kia_subtitle', true );                  // echo the inputfield with the value.             printf( '<input type="text" class="widefat" name="subtitle" placeholder="%s" value="%s" id="the_subtitle" tabindex="1"/>',                     __( 'Subtitle', 'kia-subtitle'   ),                      esc_attr($sub) );          }     }


title: How to target with css, admin elements according to user role level?

text: I am using plugins "Capability Manager Enhanced" and "Adminimize". Between these two I have been able to do much of what I want to do. There are still some elements I need to hide and have been able to target them with css. The problem is that these elements are hidden across all admin user levels. Is there something built in that distinguishes the different role levels in the admin? I would think the best way to do this would be to add a class to the body tag according to the role level at log-in -- such as "author" class if log-in role level is "author". If this is the best way I wouldn't know how to write the code to do this. I assume it would be a php addition to function.php. ???


title: How to translate "wrong password" message

text: I try to translate the "wrong password" response at system log in. I update wp-login.php, however I do not find there any handler for wrong password, wrong user. Maybe such generic tests are handled somewhere else? Thank you.


title: Ajax Not Working If The Handler is Located Outside Plugin Submenu Page Function

text: I am using wordpress ajax to trigger a submission. I located the submission code in the submenu page, because of it is have conflict with the function in plugin main page. The problem here is, I should placed the ajax handler in the submenu page function while it will not triggered if it is placed there. It always returning `0` if the handler is located in the submenu page function. I had added `nopriv` in the handler hook and also localize the javascript. The **Ajax example from Wordpress Codex** is also not working if I put it inside the submenu page function of my plugin. My question:   * How to make wordpress ajax working while its handler is placed inside submenu page function? Thanks in advance!


title: How to add a text widget during theme activation

text: I'm trying to add a text widget with the title and text set, to two custom sidebars in my custom theme. But, I can't find a clear walkthrough of how to do it. I've seen bits of code here and there, but nothing that clearly walks through the process of programatically adding the text widget to a sidebar. I've seen this but it revolves around a custom widget which is not what I'm trying to do. Edit: I have two sidebars - footer-left and footer-right. Here's what I have tried but it has not worked. So, can anyone tell me what I'm doing wrong?               update_option( 'sidebars_widgets',              array (              'footer-left' => array ( 0 => array( 'title' => 'Test1', 'text' => 'Test 1 Test')),              'footer-right' => array ( 0 => array( 'title' => 'Test2', 'text' => 'Test 2 Test')),              ) );


title: does a translation (i18n) have to start from an english PO?

text: i was wondering: it seems a translation must be a translation from english. I mean, the starting file is in english, then you do translations from that. But what if say, I'm Italian? So the base language is Italian and the others are translations from Italian? Because it's just this: i'd like to have the original PO file in italian and starting from there. What's teh way of doing it?


title: How to display the status of users (online - offline) in archive.php

text: I am using the code the user status How to check if a user (not current user) is logged in?. On page profile of the author it works well (thank you guys). But if I put on the archive page, at the bottom of the post, it does not work.   **`functions.php`**               add_action('wp', 'update_online_users_status');     function update_online_users_status(){              if(is_user_logged_in()){                  if(($logged_in_users = get_transient('users_online')) === false) $logged_in_users = array();                  $current_user = wp_get_current_user();             $current_user = $current_user->ID;               $current_time = current_time('timestamp');                  if(!isset($logged_in_users[$current_user]) || ($logged_in_users[$current_user] < ($current_time - (15 * 60)))){                 $logged_in_users[$current_user] = $current_time;                 set_transient('users_online', $logged_in_users, 30 * 60);             }          }     }      **`author.php`**               <?php     function is_user_online($user_id) {              // get the online users list         $logged_in_users = get_transient('users_online');              // online, if (s)he is in the list and last activity was less than 15   minutes ago         return isset($logged_in_users[$user_id]) && ($logged_in_users[$user_id] >     (current_time('timestamp') - (15 * 60)));        }          $passthis_id = $curauth->ID;     if(is_user_online($passthis_id)){echo 'User is online.';}     else {echo'User is not online.';}     ?>      > **EDIT** The OP wants to "display the status at the bottom of each post on > the archive page".


title: Sort Archive by Taxonomy

text: I have a site with Taxonomy for State (Eg Victoria, Qeensland ETC) this taxonomy is called listing_state. I also have a taxonomy called membership_type which can be Free or Paid. These 2 taxconomies are for a CPT of listings If I click on a taxonomy for State it brings the results as expected sorted by post date, how would I list the Paid Memberships before the Free memberships. I am using Genesis and Lifestyle theme Thanks Richard


title: Insert into db with foreach problem

text: I have no idea why this foreach it`s not running. When i post the article, only inserts once. Should make it at much as needed. Do you see any problem?               $array_produse = array();     for($i=1; $i<=8; $i++)     {         $gramaj = isset($_POST['image'.$i.'_gramaj']) ? $_POST['image'.$i.'_gramaj'] : '';         $pret = isset($_POST['image'.$i.'_pret']) ? $_POST['image'.$i.'_pret'] : '';              $array_produse[$i]['gramaj'] = $gramaj;         $array_produse[$i]['pret'] = $pret;         $array_produse[$i]['numar_produs'] = $i;     }          foreach($array_produse as $produs)     {        $wpdb->insert(             'produse',             array(                 'id' => $post_id,                 'pret' => $produs['pret'],                 'gramaj' => $produs['gramaj'],                 'numar_produs' => $produs['numar_produs']             ));     }


title: can i limit editing specific custom fields to certain roles?

text: i am writing a plugin that injects unescaped content (including javascript) into a post. i'm storing this content as a custom field, and am wondering if there are any built in ways to prevent users from editing specific custom fields.


title: Check is category parent with ids from the childs - get_term_children

text:
I have a hierarchical category list, like:               A (Parent Category)           - B (Child Category)      - C (Child Category)      - D (Child Category)          B (Parent Category)           - E (Child Category)      - F (Child Category)      And i will, that if the Parent Category has Children Categorys, that then the Parent Category have the ID'S also of the Child Categorys, like               <input id="parent_1(ID)" class="checkbox" type="checkbox" name="parent_1(ID)" checked="checked" onchange="toggle( 1 (ID of the Parent Category), Array( 4, 3 (Both ID's of the Child Categorys), 999 ) )">      So that when Parent Category is check, the child Categorys also checked. With the old function of Wordpress get_children_categories worked as expected, and java makes the rest with check the childrens by recognizing the id. But my Problem is, that the function get_children_categories is depraceted and with the new function get_term_children its not work. The old code looked so:               class Walker_Category extends Walker      {         var $tree_type = 'category';         var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');              function start_lvl($output, $depth, $args) {             if ( 'list' != $args['style'] )                 return $output;                  $indent = str_repeat("\t", $depth);             $output .= "$indent
\n";             return $output;         }     ....................          function start_el($output, $category, $depth, $args)         {             extract($args);             $cat_name = esc_attr($category->name);                  $cat_name = apply_filters( 'list_cats', $cat_name, $category );             $children = substr( get_category_children( $category->term_id, '', ', '), 0, -2 );     li><input type='checkbox' onchange='toggle( {$category->term_id}, Array( $children, 999 ) )'          .................      But when i changed the code like:               $children = get_term_children( (int) $category->term_id, $category);          "
<input type='checkbox' onchange='toggle( {$category->term_id}, Array( $children...      It gives only a 0 out. When i print_r than outputs arrays with the id's of the children categories, like:                $children = get_term_children( (int) $category->term_id, 'category');           $children = print_r( $children );      And the output is:                Array ( [0] => 3 [1] => 4 ) Array ( ) Array ( ) Array ( [0] => 6 ) Array ( )       Does anyone have any idea how I can release it? I'm already a few hours on it and come not forward with it. Or there may be another solution whereby the sub-categories are also checked. Thanks for the help ...


title: Conditional Statements

text: I have created Custom Post Type called - listing Also created custom taxonomy - listingcategories In listing categories, i have created two categories   1. music 2. features Now i want to create a conditional statement for music category I am trying this, but its not working               <?php global $post;     if (($post->post_type == 'listing') && is_category('music')) {      //statement     } ?>      Am i using it right **is_category()** ? Please Help. Thanks Rajiv


title: Redirect old query string urls to new SEO urls

text: I had urls like `example.com/?area=new-york`. `area` is a custom taxonomy. I had to change the urls to `example.com/new-york`. I want to do a 301 to new urls if previous urls are accessed. and I want Google to update its index. I have been trying to define a rewrite rule that can accomplish this but I failed. Help needed!


title: RSS feed request URL being corrupted

text: I have 2x websites. Website one has lots of user profile information and website two is used to reference this information, to avoid duplication of work. To achieve this, I use a custom RSS feed. However, the feed that I request is getting messed up somewhere, and I don't know where. The feed works if I go directly to it on website one (e.g. http://www.dynedrewett.com/feed/?person=natalie-cox). However, if I try and retrieve the feed from website two, the wrong data is returned. When a feed is requested, I log the `person` query variable so I can check what it is. When going directly to the feed (i.e. using the link above) the correct name is logged. However, when calling the feed from the second website, the incorrect name is logged. When I output the `$url` on the second website (the URL used to grab the feed), literally as I'm about to create the SimplePie object, it is correct. I then output the object and the correct feed URL is set. So somewhere between the SimplePie object creation on website two and the feed request on website one, the URL is getting messed with. But I don't know what could be causing it. I have searched every file in my theme, and none of them include the filter `request` (so no overriding of my other filter). Also I've deactivated every single plugin, and that also made no difference. Does anyone please have some suggestions for other things that I could check? Thanks. **How website one handles feed requests**               add_filter('request', 'feed_request');     function feed_request($qv){              if(isset($qv['feed']) && !isset($qv['post_type'])) :                  if(isset($_GET['person'])) : // Only specific staff (by ID) have been requested                      $qv['post_type'] = 'staff';                 $qv['post__in'] = get_staff_post__in_ids(explode(',', $_GET['person']));                 update_option('last_rss_person', explode(',', $_GET['person']));                  endif;              endif;              return $qv;          }          function get_staff_post__in_ids($names){              global $wpdb;              $query = stripslashes($wpdb->prepare('SELECT `%1$s`.`ID` FROM `%1$s` WHERE 1=1 AND `%1$s`.`post_name` IN (%2$s)', $wpdb->posts, '"'.join('","', $names).'"'));         $results = $wpdb->get_col($query);              $post__in = (!empty($results)) ? $results : array(0);              return $post__in;          }      **How website two requests a feed**               function fetch_person_feed($url){              echo '<pre>$url: '; print_r($url); echo '</pre>';              $feed = new SimplePie();         $feed->set_feed_url($url);         $feed->set_cache_class('WP_Feed_Cache');         $feed->set_file_class('WP_SimplePie_File');         //$feed->set_cache_duration(3600); // Set the cache to 1 hour (3600 seconds)         $feed->set_cache_duration(10); // Set the cache to 10 seconds (use olnly when testing)         do_action_ref_array('wp_feed_options', array(&$feed, $url));         $feed->init();         $feed->handle_content_type();              if($feed->error()) :             return new WP_Error('simplepie-error', $feed->error());         endif;              return $feed;          }


title: How do I remove unwanted pages like archive, search, etc.?

text: By default WordPress pushes out a whole array of pages I don’t want or need - archive, author, blog, monthly, recent posts, categories, comments, attachment, taxenomies, search, search results, and probably a few others I’ve missed. Most of the time I’m building regular broshure websites with no need for anything except a few fairly static pages. How do I get rid of all the other pages? Is there a plugin that will do this? Do I have to set up a dozen redirects in the .htaccess? I’ve tried searching, but all I find is how to hide parts of a page, or customise the sitemap to hide from searches. But I don't want those pages at all, so even entering the direct URL shouldn't work.


title: Is it possible to store visitors IPs in wp_postmeta table?

text: Or in any of the other 11 Wordpress tables. I also need to store: submission date, name, contact number in the same table. What approach would be best? A custom table or using a standard table?


title: Possible bug: update_user_meta is updating two unique meta entries

text:
On a CPT page I am checking to see if the user is logged in; if they are, I'm checking to see if they have a meta entry which is `'session-'` + the current page's stub. If they do, I increment the value by one. I thought this was all working fine, but I've just noticed that it's actually incrementing two separate user_meta fields. At the moment I have three CPT pages (let's call them Burt, Ernie & Ralph); if I refresh the page for **Burt** , it increments my user_meta field (`session-burt`) by 1, which is great; however it _also_ increments `session-ralph` by 1. I don't have the **Ralph** page open, and I'm echoing out everything I can think of to try and trace down the erroneous line of code, but I can't see _why_ it's doing it. It is incredibly annoying. Here's my code. Hopefully I'm just blind to something really obvious and it's not a WP bug.               $stub = $post->post_name;          $sessionKey = 'session-' . $stub;     $viewedKey = $stub . '-lastviewed';          $sessionViewsArray = get_user_meta($current_user->ID, $sessionKey);     $sessionViews = (int)$sessionViewsArray[0];          echo '
';     print_r($sessionViewsArray);     echo '
';          echo '
I think there are ' . $sessionViews . ' views
';          $lastViewedArray = get_user_meta($current_user->ID, $viewedKey);     $lastViewedTime = $lastViewedArray[0];          if ($lastViewedTime) {         $lastViewed = date('l jS F Y, g:ia', $lastViewedTime);     } else {         $lastViewed = 'First time - good luck!';     }          $newSessionViews = $sessionViews + 1;          update_user_meta($current_user->ID, $sessionKey, $newSessionViews);     update_user_meta($current_user->ID, $viewedKey, time());          echo '
I think I just updated ' . $sessionKey . '
';          ///     //  Now let's update the page views     ///          $pageViewsArray = get_post_meta($post->ID, 'totalviews');     $pageViews = (int)$pageViewsArray[0];          $pageViews += 1;          update_post_meta($post->ID, 'totalviews', $pageViews);      It's worth noting that it only seems to be the one `session-ralph` entry that is affected; the `ralph-lastviewed` entry doesn't get updated if I refresh the Burt page. Any help would be greatly appreciated! ## UPDATE: As per the _awesome_ answer from @dalbaeb below, my solution was to use the following hook: `remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);` ...which removed the `<link rel='next'...` and `<link rel='prev'...` tags from my header and immediately solved the issue.


title: Subdomain for main category, directories for subcategories

text: I explain clearly what I want to achieve :   I have here   Main category : Car   -Sub-category : Sports-Car   --Sub-category : Porsche   ---Post : Porsche-911-Turbo.html   I want URL to be this :   "car.mysite.com/sports-car/porsche/porsche-911-turbo.html"   How can I get this result with WordPress?   Thanks for all your answers.


title: Wordpress Ajax always returns a 404 error

text:
I just got this code from a tutorial. I can't seem to get it to work. HTML (home.php)                   <form name="myform" id="myform" action="" method="POST">                        Name             <input type="text" name="name" id="name" size="30" value=""/>
                      Email             <input type="text" name="email" id="email" size="30" value=""/>
                      <input type="submit" name="submit" value="Submit">         </form>

      PHP (function.php)                   function myform(){            echo "Form submitted successfully:
Your name is ".$_POST['name']." and your email is ".$_POST['email']."
";          }         add_action('wp_ajax_myform', 'myform');         add_action('wp_ajax_nopriv_myform', 'myform');      Javascript (header.php)


title: Display only the latest post

text: There seems to be something wrong with the logic of what I'm doing. I just want to display the latest post in a custom term. But instead I'm displaying every post for that term, even though I am using `posts_per_page => 1` I have a taxonomy called "twin" and the term "double portrait", I have 2 posts in a category called "celebrity", both with the term "double portrait". The code I have outputs in the right category fine, but as I say it's outputting for each post instead of just the one. Here's the code I'm using:                $post_type = 'post';            $taxonomies = get_object_taxonomies( (object) array( 'post_type' => $post_type ) );            foreach( $taxonomies as $taxonomy ) :               $terms = get_terms( $taxonomy );            foreach( $terms as $term ) :               $args = array(           'tax_query' => array(             array(               'taxonomy' => $taxonomy,               'field' => 'slug',               'terms' => $term->slug               )             ),           'posts_per_page' => 1,           'ignore_sticky_posts' => true,            'orderby' => 'modified',           );            $posts = new WP_Query( $args );            if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post();       if(in_category($str)) {         if(has_term('double portrait','twin')) {             echo the_excerpt();         }            }            endwhile; endif;            endforeach;            endforeach;


title: modify stylesheet of a particular page inside wp-admin

text: inside this path, are the listing of my wordpress pages.               /wp-admin/edit.php?post_type=page&orderby=title&order=asc      i want to remove the default `<table>` design of the page and create my own style. how do i go and modify that particular page. Does this function `add_action()` still applicable? only to a particular page? or should i modify the `edit.php` directly?


title: Select posts with any post_type from database?

text: I'm trying to select all rows from the database regardless of post type, however when suppressing post_type WP_Query only gets rows with `post_type = "post"` is there a way to suppress the post_type filter (or select all post types)?               // This just selects post_type = "posts"     $args = array(      'post_status' => 'publish',      'posts_per_page' => -1,      'ignore_sticky_posts' => true,     );     $qry = new WP_Query( $args );


title: Sorting by tag or category

text: Here's the scenario: A user clicks on a tag which takes them to a list of all those posts with that tag. There are hundreds of posts, so the user needs a way to filter these. Here's the question: How would you build a drop down that a user can select to filter by category while on the tag page. Filter all Yellow tags by Color category for instance. Also the reverse would be useful. Searching the Color category and filtering by the tag Yellow.


title: Using tax_query reverses my post_type argument in a custom WP_Query

text: I'm using a custom query to pull some posts from a custom post type. I'm having problems with it so I used print_r on my WP_Query object and I found something strange.               my query has these arguments:     'post_type' => 'event'         ,'tax_query' => array(                     array(                         'taxonomy' => 'event-categories'                         ,'field' => 'id'                         ,'terms' => 72                         ,'operator' => 'IN'                     )         )         ,'order' => 'ASC'     );     $query = new WP_Query( $args );      and when I remove the tax_query portion I get all my posts, but when I include it I get none. I'm positive I have more than one post with the taxonomy ID of 72. When I look at my print_r($query) with the post type in, I see this:               WP_Query Object     (     [query_vars] => Array         (             [post_type] => Array                 (                     [0] => media_player                     [1] => ada_slides                     [2] => closings                     [3] => staff                     [4] => post                     [5] => page                 )      All of my post types are listed except for the one I wanted, event. If I take out tax_query from my args, it looks like this:               WP_Query Object     (     [query_vars] => Array         (             [post_type] => event             [order] => ASC      ...and so on Also, if I change my operator to NOT IN, it searches the correct post type but excludes the category I want to search for. Why would using a tax_query argument seemingly invalidate my post_type argument and instead include all post types but the one I wanted?


title: Stuck with conflicting loops on page template

text:
I'm really new to WordPress and having a problem with my page template and a sidebar loop. I made a block that displays posts in a category in the sidebar, it also displays a custom field below the title of each post and the code looks like this:               <?php $published = get_post_meta( $post->ID, 'article_Details', true ); ?>

Recent Articles
         <?php              $catquery = new WP_Query( 'cat=2&posts_per_page=6' );              while($catquery->have_posts()) : $catquery->the_post();         ?>         <a class="listing" href="<?php the_permalink() ?>"><?php the_title(); ?>
<?php echo $published[0]['publication-details']; ?>
              <?php endwhile; ?>

      It gets displayed properly on single posts, categories and homepage but for every **page** on the site where it should be, it breaks, only the first item in the block gets displayed without the custom field and the foooter of the site never appears. The template I use for my pages looks like this:               <?php get_header(); ?>
         <?php while (have_posts()) : the_post(); ?>              <article <?php post_class(); ?>>
<?php the_title(); ?>

                      <?php the_content(); ?>

          <?php endwhile; ?>          <?php get_sidebar(); ?>          <?php get_footer(); ?>      I'm not sure what the issue is, I've tried changing several things to fix the code in both the page template and the sidebar template without any luck so far.


title: Add existing user as administrator

text: I run several wordpress sites that I created. A friend has asked me to help admin his existing site. So we want to add my userid as admin to his site. However, User | Add User allows addition of a 'brand new user' with new password, email ets. I would much prefer not to have another wordpress user account to remember. Can I not add my existing userid as admin to my friend's site?


title: Send a confirmation of user role upgrade conditionally

text: I'm using this snippet of code to send a confirmation email to user's when their account is upgraded to a new user role.               function user_role_update( $user_id, $new_role ) {         $site_url = get_bloginfo('wpurl');         $user_info = get_userdata( $user_id );         $to = $user_info->user_email;         $subject = "Role changed: ".$site_url."";         $message = "Hello " .$user_info->display_name . " your role has changed on ".$site_url.", congratulations you are now an " . $new_role;         wp_mail($to, $subject, $message);     }     add_action( 'set_user_role', 'user_role_update', 10, 2);      This sends an email whether the account has been upgraded or downgraded which doesn't give me the flexibility of sending a different message for a downgrade. I have two situations where this is used.   1. When a user is upgraded from "contributor" to "author".    2. When an "author" is downgraded to "contributor". How can I use conditions to send a different email for each of these events?


title: Error when trying to logout

text: This problem was reported on the WP forum a month ago: Error when trying to logout. Whenever you logout, you get (Chrome): > **This webpage is not available.** > > The webpage at http://my.site.com/blog/wp- > login.php?action=logout&_wpnonce=2d5b319c49 might be temporarily down or it > may have moved permanently to a new web address. > > More information on this error Below is the original error message > > Error 101 (net::ERR_CONNECTION_RESET): Unknown error. I've had this problem since at least 3.0.2 and it's still there with 3.0.4. My host is IPOWER. I was wondering if anyone here has seen this problem, and even more importantly, has a solution. Thanks. A little more information:   1. I get the same connection reset error with FireFox and IE.    2. The Apache access log shows the following (I don't have access to the error logs): [22/Jan/2011:00:01:39 -0500] "GET /blog/wp- login.php?action=logout&_wpnonce=2d5b319c49 HTTP/1.0" **302** 212 "http://my.site.com/blog/wp-admin/" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.237 Safari/534.10" The temporary redirect to /blog/wp-admin/ seems to make sense -- after logging out you go back to the login page.


title: How to implement three forms(like contact form) in wordpress

text: I am working on wordpress site.I need here to implement a form that is manageable from admin mean that admin can add field as requirement.Right now I am using `fast and secure form plugin` by default that plug-in provide four form.But each form having its own `submit` button I dont want this Actually client need form that divide in three part mean that when filled form first there should be `next` button on clicking next button it goes to `second form` after filled second form there should also be `next` button after click this it goes to third form taht contain `submit` button.All the form fields should be manageable throught admin. Mean admin can add or delete any field as requirment Please provide me suggestion I shall be thankful to u all Thanks Shalu


title: Choopy Video Playback in a popup using Artiss Youtube Embed

text: I'm using Artiss Youtube Embed to embed youtube videos on my site which works great because it allows me to control all the parameters for the video player. My issue is that when the video has choppy playback when it's playing in a popup window. I allow users to click on thumbnails on the homepage and then I use SimpleModal Jquery plugin to popup the video from the post. I tested a video from youtube using their iframe embed code and it worked perfectly. So something with this plugin is causing the choppy playback which only occurs in the popup. It works normally on a single post page. Any idea what might be causing that?


title: Display Data's metabox in page

text: I created a metabox has a textarea in page admin, So after validating the data is saved, but it's not displayed in the page (theme) I hope I explain well my problem. here is my code :               <?php                    add_action('add_meta_boxes','dar_meta_create');          function dar_meta_create()     {         add_meta_box(               'dar_meta', // $id               'metabox dardar', // $title                'dar_meta_function', // $callback               'page', // $page               'normal', // $context               'high');     }          // callback          function dar_meta_function($post)     {         wp_nonce_field(basename(__FILE__), 'dar_nonce');                   // get value of text area         $shortcode = get_post_meta($post->ID,'_shortcode',true);         echo          '<textarea name="_shortcode" id="_shortcode">'.wp_kses_post($shortcode).'</textarea>';     }          // save meta box                    function dar_meta_save($id,$post)     {          // check the autosave         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)               return $id;               if (             'page' == $post->post_type             && current_user_can('edit_page', $id)             && wp_verify_nonce($_POST['dar_nonce'], basename(__FILE__))             && isset($_POST['_shortcode'])         ) update_post_meta($id, '_shortcode', strip_tags($_POST['_shortcode']));               }     add_action('save_post','dar_meta_save');      And Thanks.


title: add a class when login

text: i add this code in `index.php`. `<div class="Div1"></div>`. then write some css(absolution position) to the `Div1`. so when i login in my wordpress. the admin nav will push down some spaces to the site body. so the conetent shows unnormal. now, i want to add a `class` to `<div class="Div1">` when logins. is there a way to get this.


title: Wordpress 3 - how are passwords stored and how do I compare to them?

text: For reasons I can't go into right now, I'm creating a form that will allow users to change their passwords for Wordpress by entering their current password and then entering the new password. I want to do a databse lookup to see if the password they entered was the correct one already stored in the DB. However, in WP the passwords are encrypted somehow, so doing a simple SQL comparison on this column wont work. I tried using `md5()` on the password for the lookup but it doesn't seem to work either. Here's my sql: `SELECT ID, user_pass FROM wp_users WHERE ID = '$current_user->ID' AND user_pass = 'md5($currentpassword)' LIMIT 1` You can ignore most of this, but what I need to know is how I can do a comparison against the user_pass column? I've tested this method above and it results in 0 rows returned - with or without the `md5()` Please help! Much appreciated. Michael.


title: What should I use - Taxonomies, custom fields, Post Type?

text: I've setup a traveling/photography blog. I want to have different post types: Traveling, Hotel Reviews, etc. For the traveling post, I want to add unique data like: City, Weather (for the current time for that day), Geotag meta data (long. and lat.). etc. I am new to custom taxonomies, custom post types and custom fields. For example, I don't know when I should use custom taxonomies and when to use custom fields. There are many plugins out there that I thought buying, here are two of them: http://codecanyon.net/item/easy-custom-content-types-for-wordpress/234182 http://www.dev4press.com/plugins/gd-taxonomies-tools/features/ What I want to achieve: 1) Add a city for a custom post type (choose from a list of cities using a drop down list of the cities that I've added to a list) and also attach an image of the city to the bottom of my post. 2) Choose a weather and use an icon to show the user the current weather for that day of shooting 3) Have a URL like: http://mydomain.com/city-name http://mydomain.com/city-name/post-name.html As city-name would be the taxonomy - but what if I have several taxonomies, how can I build my permalink structure to maintain that structure? 4) Optimization & speed - From what I've read, I need to use a numerical value as the first element in my permalink structure in order to minimize stress on my WordPress DB and also to prevent WordPress from creating verbose rules. Does that imply to taxonomies in the URL too? There are many questions that I don't have answer for. I am very confused with all the plugins and information out there any really need help from you guys. Thanks in advance.


title: Great blogs site resources/tutorial for Wordpress Developers?

text: I sometimes learn a few tricks from wordpress blog tutorial sites and its great that some of the people in this field , share what they know about working around with coding around wordpress. Im just wondering do some of you know blog sites that are catering quality wordpress tutorial posts (like working around in the API, theme development , plugin development , articles) . I know.... there are thousands of them, so I wanted to know if you have list of the best sites so far you know that do this. Probably the sites you bookmarked and visit regularly. any suggestions will be cool


title: Select first child/subpage item in wp list pages

text:
This question is following on from a question I posted previously, Ok, the html code that I'm trying to output is the same as the previous question - here: The current outputted html is this:

About Us

Child of About

Grandchild of About

Talk to us

      Here is the code I'm using in header.php to generate the html/menu items:

           <?php         // Query the database for all top-level page IDs, and store them in the $menuPages array under the [ID] sub-array         $menuPages = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_parent=0 AND post_type='page' AND post_status='publish' ORDER BY menu_order ASC");              // For each element in the $menuPages array, get the value from the [ID]-subarray to create the top-level menu and it's children         foreach($menuPages as $menuItem){             $menuItemTitle = get_the_title($menuItem->ID);                       $menuItemClass = strtolower(trim($menuItemTitle));                               $menuItemClass = preg_replace('/[^a-z0-9-]/', '-', $menuItemClass);             $menuItemClass = preg_replace('/-+/', "-", $menuItemClass);                          $menuItemPermalink = get_permalink($menuItem->ID);                 if (isset($menuItemTitle) && $menuItemTitle != 'Home'){                                      _e('
'.PHP_EOL);                     _e(''.$menuItemTitle.''.PHP_EOL);                      // Run wp_list_pages to fetch any children, and put the HTML
 list results into $menuItemChildren as a string                     $menuItemChildren = wp_list_pages('title_li=&echo=0&sort_column=menu_order&child_of='.$menuItem->ID);                                             $menuItemChildren = preg_replace('%
%U', '', $menuItemChildren);                     $menuItemChildren = str_replace('
', '', $menuItemChildren);                     $menuItemChildren = str_replace('<a', '
<a', $menuItemChildren);                     $menuItemChildren = str_replace('', '
', $menuItemChildren);                     $menuItemChildren = str_replace('
', '', $menuItemChildren);                     $menuItemChildren = str_replace('
', '', $menuItemChildren);                                  // If results were returned, $menuItemChildren is now a string with HTML in it, so create a drop-down and echo out the HTML                     if($menuItemChildren){                                               _e('
'.PHP_EOL);                         _e('
'.PHP_EOL);                         _e('
'.PHP_EOL);                                _e('
'.PHP_EOL);                         echo '
' .$menuItemChildren. '
' . PHP_EOL;                         _e('
'.PHP_EOL);                         _e('
'.PHP_EOL);                         _e('
'.PHP_EOL);                         _e('
'.PHP_EOL);                                            }                     _e('
'.PHP_EOL);                             }             }         ?>

      I know this is probably a really bad way of doing this, but it seems to do most of the job ok. The only thing outstanding now is changing the child items/subpages on level/depth 1 from "dd's" to "dt's", leaving any pages below as dd's. I guess I need some code that takes the first item/child and gives it "dt" tags, then everything else "dd" tags, but I can't for the life of me figure it out. Hope this makes sense and any help greatly appreciated, S. (And I have looked at the Walker class method : ( )


title: Changing Oembed max width based type of page

text: How do i change/filter the oembed max width settings (as set by ) admin -> media -> settings -> "Maximum embed size" before the oembed code gets executed. For example on the index pages i want it to be 540, but ona single page, i'd like to be 880?


title: Search page for custom post type

text: I am new to wordpress and a beginner coder, and i was searching around the net, found solutions but still does not work. I have custom post type named `dlm_download`, and my custom search template not working I added the following to my `functions.php` file - the code is from this answer by @Ronald.               function template_chooser($template)     {       global $wp_query;       $post_type = get_query_var('post_type');       if( $wp_query->is_search && $post_type == 'dlm_download' )       {         return locate_template('archive-download.php');       }       return $template;     }     add_filter('template_include', 'template_chooser');      Created the `archive-download.php` and when i preform my custom search, i get the url like this `mysite.com/?dlm_download=699` nothing happens i just get redirected to my home page. Could please someone tell what i am doing wrong?


title: FTP files directly to Media Library wp-content\uploads

text: I would like to use an automated process to replicate a non-WordPress file folder in \wp-content\uploads\ and have the files automatically registered in the Media Library. I could use such a process to upload the files, then register them using Add From Server (http://wordpress.org/plugins/add-from-server/) or the similar Media From FTP. But that seems like excessive human input. LR/Blog (http://www.photographers-toolbox.com/products/lrblog.php) appears to be able to save to WP and register the files at the same time. How can this be done with any files using a command line?


title: Content disappearing from layout builder after updating the page

text: i have been developing a website (http://www.estero.co.nz). firstly i am really happy with wordpress which made our lives easier for developing websites. i have already built two site using wordpress, but for the first time i am having a issue. i have been working in building estero site after getting to start third page using layout builder, the moment i click update the content gets disappeared. i have to complete the site before my event gets started in 15 days, but somehow this issue is not letting me do so. kindly suggest the solution. Site URL- http://www.estero.co.nz theme- enfold WordPress 3.9.2 thanks


title: "coming soon" placeholder blog posts?

text:
I have a page set up with six posts per page with two rows of three posts. If I only have one post up, I would like the other five to have "placeholder images" letting the viewers know that more posts are coming. Kind of like this: ![enter image description here](http://i.stack.imgur.com/UMBZB.jpg) I would create the placeholder images to put in there. Here is how my blog is set up. Pretty basic. Has anybody ever done anything like this before?
              <?php if ( have_posts() ) : ?>                  <?php while ( have_posts() ) : the_post(); ?>                  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                     <?php the_title( sprintf( '
', esc_url( get_permalink() ) ), '
' ); ?>                     <?php mobile_mix_posted_on(); ?>
                      <?php if ( '' != get_the_post_thumbnail() ) {                     the_post_thumbnail();                 } ?>
                  <?php endwhile; ?>                  <?php mobile_mix_paging_nav(); ?>              <?php else : ?>                  <?php get_template_part( 'content', 'none' ); ?>              <?php endif; ?>


title: Hardcoding and WordPress Performance

text: On the WordPress Optimization/Performance page it suggests hardcoding static variables rather than referencing them through WordPress functions. I think I get the rationale behind that. But what about doing something like the following:               function foobar() {              global $post;              $post_ID = $post->ID;              $site_url = site_url();              // Use $post_ID and $site_url multiple times throughout the function          }      Is this better performance than explicitly calling `$post->ID` and `site_url()` each time you'd want to reference them? Or does it not make a difference?


title: Woocommerce custom product loop not display all product on the homepage

text: This is the code I use to display the products on the home page.               <ul class="products">     <?php         $arg1 = array(             'post_type' => 'product',             'posts_per_page' => 8         );         $loop = new WP_Query( $arg1 );         if ( $loop->have_posts() ) {             while ( $loop->have_posts() ) : $loop->the_post();                 wc_get_template_part( 'content', 'product' );             endwhile;         } else {             echo __( 'No products found' );         }         wp_reset_postdata();     ?>     </ul>      But I have only seen 1 product instead of the specified 8. If you change the English language, and the 0th. Do you have any ideas as to why? I use the template roots. Here is the url: http://www.granitnagyker.hu


title: How to split my uploaded media into directories?

text: I am reading the documentation of WordPress Media Library and it seems to me that it doesn't allow me to split my uploaded media into directories. Is it true? Why this choice? How can I implement that?


title: $wpdb sort order

text: $meta_key1 = 'first_meta';     $meta_key2 = 'second_meta';          $postids = $wpdb->get_col( $wpdb->prepare(      "     SELECT      key1.post_id     FROM        $wpdb->postmeta key1     INNER JOIN  $wpdb->postmeta key2                 ON key2.post_id = key1.post_id                 AND key2.meta_key = %s     WHERE       key1.meta_key = %s AND key1.meta_value <= 250     ORDER BY    key2.meta_value+(0) DESC     ",     $meta_key2,     $meta_key1     ) );       Why this code give me result oredered by `first_meta`, when I need (and suppose to get) order posts by `second_meta`? What I do wrong? I copied this sample from Example 4 - $wpdb - Codex -- and changed only a single line.


title: Multiple domains for with a single instal

text: I have to create a new project that is multi regional. I need to change the website url depending on the user IP address. On my project, we will have three different domains:   * Our main site: www.mysite.com   * Our uk domain: www.mysite.co.uk   * Our Australian domain: www.mysite.com.au This project, has to be managed by only one **site installation** Here is what I was thinking:   1. Modify the htaccess file of the two "extend" domains (co.uk and com.au) to redirect users to my main one: www.mysite.com Here is my htaccess redirection on both of my "extend" domains (co.uk and com.au) Redirect 301 / http://www.mysite.com/   2. On my single Wordpress instal where the site will be (.com), I will get users Ip addresses To it, I used the geoiploc library (working perfectly)   3. If the user has an Uk or an AU Ip, I will redirect him to the according url. Here is my issue: I tried to modify the url inside the function.php according to the IP detection like this. update_option('siteurl','http://www.mysite.co.uk'); update_option('home','http://www.mysite.co.uk'); Redirections are working (can review links modification on the page). However, since I have done my "extend" domains redirections, I will always display the .com website. So how can I avoid this problem? Note: I found that I can use the multiple domains with analytics plug-in that will be very helpful. However, this plug-in requires "DNS settings". **Does my "extend" domains htaccess modification is enough?** Here is my plug-in set-up on my .com website:   * Domain 1: www.mysite.co.uk    * Wordpress address (URL): www.mysite.com    * Blog address (URL): www.mysite.com   * Domain 2: www.mysite.com.au   * Wordpress address (URL): www.mysite.com.au   * Blog address (URL): www.mysite.com.au Note: Latter I will add a drop down list to allow users domains swapping (.com, .co.uk, .con.au) Any help will be appreciated, cheers!


title: Users moderate own comments

text: Im putting together a portfolio site and have come across something that i would like to implement, but im unsure of how i can set around doing it. Basically as the site stands now (in development) the user never has (or will have) to access wp-admin to change any of their details, they can do that via a user-profile page. Each user has a portfolio/bio page with a comments form at the bottom, what im wanting to do is make it so that any comments left on this bio page are moderated by that pages owner, ie perfect solution would be: 1) Bio page owner is notified via email that they have a new comment. 2) Bio page owner logs in and goes to user-profile page to review and then accept/decline comment, upon accepting it is then published. Anyone have any previous experience in this, or know of a working site/plugin that i could take a look at, or just any general advice on what im trying to do. Best regards


title: Get new post meta data when (custom) post is saved

text: When I save my post (custom post type: project) I want to get the meta data for a specific key that I just inserted. Based on the value of that key I insert a product in WooCommerce. What happens is that I get the **past** value for the meta key, instead of the **current/new** one. Here's the code I use:               function shortened($post_id){             $key_verkoop_ja_nee = "kaart_verkoop";        //$value_verkoop_ja_nee = get_post_meta($post_id, $key_verkoop_ja_nee, TRUE);        //$value_verkoop_ja_nee = $GLOBALS["wp_object_cache"]->cache["post_meta"][$post_id][$key_verkoop_ja_nee][0];        //$value_verkoop_ja_nee = $_REQUEST[$key_verkoop_ja_nee];        $value_verkoop_ja_nee = $_POST[$key_verkoop_ja_nee];             if($value_verkoop_ja_nee == "Yes"){            //Do a lot of stuf        }     }          add_action( 'save_post_project', 'shortened', 999 );      $_POST and $_REQUEST don't return any value at all, get_post_meta and the $GLOBALS return the past value. I tried edit_post instead of save_post, in/decreased the importance (999) and used global $post in the function. Nothing works. Any idea how the get the new inserted meta value? Thanks a lot!


title: What is the purpose of the "Hello Dolly" plugin?

text: Why was this plugin packaged by default? I know `Akismet` prevents SPAM but `Hello Dolly` does nothing. Can someone please explain what the use is of the `Hello Dolly plugin?


title: Cleanup Body_Class

text: Currently, when I use `body_class()` it generates a bunch of crap that I don't need. What I'd like to do is have the following:               homepage: class='blog page-home'     single:   class='blog page-single'     author:   class='blog page-author'     category  class='blog page-category'      Should I even use an add_filter for body_class? Or just create my own function?


title: Wordpress Ajax Getting Response "Null"

text: I am trying to get ID of post on HOME page .So far my coding is               wp_enqueue_script( 'my-ajax-request', get_stylesheet_directory_uri() . '/js/ajax.js', array( 'jquery' ) );     wp_localize_script( 'my-ajax-request', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );     add_action('wp_ajax_nopriv_ajax_request', 'ajax_handle_request');     add_action('wp_ajax_ajax_request', 'ajax_handle_request');               function ajax_handle_request(){     $postID = $_POST['id'];     if (isset($_POST['id'])){         $post_id = $_POST['id'];     }else{         $post_id = "";     }          global $post;     $post = get_post($postID);          $response = array(          'sucess' => true,          'post' => $post,         'id' => $postID ,      );          // generate the response     print json_encode($response);          // IMPORTANT: don't forget to "exit"     exit;     }      And My jquery               jQuery(document).ready(function($) {     $('h1.entry-title a').click(function(event) {         event.preventDefault();     var id = $(this).data('id');          $.ajax({       type: 'POST',       url: MyAjax.ajaxurl,       data: {'action' : 'ajax_request', 'id': id},       dataType: 'json',       success: function(data) {         alert(data['post']);       }     });               return false;     });     });      But I am getting alert Null instead of getting the id of post.


title: Multisite - Redirect All Users to Subsite Home Page on Subsite Login

text: I have a WordPress multisite network and would like to redirect all users who log into a subsite to the subsite's home page. I have found many plugins and functions.php code that redirect to the main site for the network, but I have been unable to find a solution that will redirect users to a subsite's home page, thus bypassing the dashboard for the subsite. Ideally, the solution would redirect all roles (administrator through subscriber). Any guidance would be most appreciated! Thanks, Mike


title: wp_insert_category() setting the 'cat_ID' gives not array error

text: I'm writing a plugin that automatically creates a bunch of stuff ie categories and child categories. But when I use the following code to create the categories: (from wp codex)               //Create Post Categories     $my_cat = array(         'cat_ID' => 1146,         'cat_name' => 'Newcastle Community News & Views',          'category_description' => '',          'category_nicename' => 'news',          'category_parent' => '',         'taxonomy' => 'category'     );     $my_cat_id = wp_insert_category($my_cat);      It gives me the following error. > >     Warning: array_merge() [function.array-merge]: Argument #1 is not an > array in /home/newcastl/public_html/wp-includes/taxonomy.php on line 2535 >   With the id in '' isnt working either. I have to set the ID so I can refer to it when using sub-cats. Thanks!


title: Images in grid Twenty Eleven theme

text: I'm trying **to display images in grid such that 5 images in a row**. I put the code in `functions.php`:               add_filter('post_class','clear_left_four_class');     function clear_left_four_class( $classes ) {      global $wp_query;      if( $wp_query->current_post%5 == 0 ) $classes[] = 'clearleft';     return $classes;     }      and in style I put the code in `style.css`:               .hentry { width: 24%; margin-left: 1%; float: left; }     .clearleft { clear: left; margin: 0; }      but **currently it shows only 3 images in a row** I have already made reading as 5 posts


title: Horizontally paginate through sets of blog posts?

text: I have my posts set up like this: ![enter image description here](http://i.stack.imgur.com/toRZM.jpg) I would like users to scroll through the posts using the left and right arrows. So when users click on the right arrow, for example, the next six posts would slide into view horizontally. I know how to pull the main query of posts and set the posts per page to six, but how would I get those posts to work with the pagination?


title: Sort posts by multiple meta key values

text: I'm not new to wordpress, but I'm not very good at PHP. I hope someone can help me, since I already tried to search for a solution for over 5 hours with no luck. So I have an archive.php page where I want to to sort the posts by 3 meta keys. They all have numeric values. These are the names of the meta fields: "vorstellung-filmdatum" (The date), "vorstellung-uhrzeit-stunde" (The hour) and "vorstellung-uhrzeit-minute" (The Minute). At this moment I'm using the following code, but it only sorts by the last meta-key ("vorstellung-uhrzeit-minute" in this case).               global $wp_query;     $args = array_merge( $wp_query->query, array( 'posts_per_page' => 12, 'meta_key' => 'vorstellung-filmdatum', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_key' => 'vorstellung-uhrzeit-stunde', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_key' => 'vorstellung-uhrzeit-minute', 'orderby' => 'meta_value_num', 'order' => 'ASC', ) );     query_posts( $args );     while (have_posts()) : the_post(); ?>      How can I change this to be sorted by all three meta keys? I want it to sort the posts like this: -- Date 1 --- Hour 1 ------ Minute 1 ------ Minute 2 --- Hour 2 ------ Minute 1 ------ Minute 2 -- Date 2 --- Hour 1 ------ Minute 1 etc. Can someone help me?


title: Need plugins and themes from clients site

text: I need to grab a clients themes and plugins to migrate their website to our servers. I tried using All In One Migration but it didnt work and caused some errors. Now I am going to do a fresh install of Wordpress. I can get the database with the Migrate DB tool but have no idea how to get the themes or plugins. I obviously don't have access to FTP or hosting because the current hoster does not want to provide that information to make it easy for us to get the files. Any suggestions on plugins or methods to get the site files so I can migrate?


title: Post format alternative?

text: The client wants to attach one of several "formats" (publication, briefing, press release etc.) to a post. It seems unnecessary to create custom post types as they all have the same fields. As post formats cannot be extended, would you recommend a custom taxonomy in this case?


title: Prevent reload confirmation after AJAX save

text: I am saving information in the admin panel via ajax. The problem I'm running in to is the "Are you sure you want to navigate away from this page" popup appear, even though everything has been saved. Is there any way to flag the page as saved?


title: Enable comments for post with comments meta box removed

text: I have created a custom post type in a plugin for a site I'm working on. I'm allowing users assigned a custom role to add/edit/delete the custom post type. I would like to give these users as little functionality as possible in the admin beyond posting. So I've used `remove_meta_box` to remove a few panels on the conversation post edit screen for these users via a plugin. One of the meta boxes I've disabled is commentsstatusdiv which includes the form elements for comment status and trackbacks. It seems that if the comments status form element is missing, the `comment_status` field gets set to off. I'd like to default comments on for the post type and prevent users in this role from changing the comments setting. But when the users save the post comment status is set to off. I can force a setting with the `wp_insert_post_data` filter. But I don't want to override for admins. I'd like admins to have control. How do I force comments status to be on by default and prevent users of a specific role from changing it while still allowing admins to turn them on/off?


title: why there are so many posts whoes post_type is revision? will these records waste too much database space?

text: from the following data we may know there are only 30 records which are meaningful, and there are 92 records of revision post_type which can not be shown on the blog. so will these records waste too much database space? is it recommended to save such kind of revisions? (btw, i may edit my blog oftenly)               mysql> select count(*),post_type, post_status from wp_137_posts group by post_type, post_status;     +----------+-----------+-------------+     | count(*) | post_type | post_status |     +----------+-----------+-------------+     |        1 | page      | publish     |     |        2 | post      | auto-draft  |     // also, should i delete this record?     |       30 | post      | publish     |     |       92 | revision  | inherit     |     +----------+-----------+-------------+     4 rows in set (0.24 sec)


title: Saving data to database and exporting to excel

text: I'm creating a form in a blog for users to register their emails so I can send a newsletter later but I don't want to use any newsletter plugin for that. I'd like to save the emails and than export them to something else like excel or a cvs file. Is there any plugin or any other solution to do that?


title: How to protect my blog?

text: I installed "registered users only" plugin which works perfectly... BUT if I type in url for some of my attachemnts /wp-content/uploads/2011/.... I can easily download everything even if I'm not logged in? How should I redirect users to login page if they try to download my content directly?


title: Do you have to have command line access to use Subversion with Wordpress?

text: My group does not have command line access to the machine that is running our WordPress instance. However, we would still like to install/update using Subversion. Is this possible? Also, does Subversion need to be on the same machine?