title: Hook H1 Into Custom Front Page

text:
The site i'm refering to is Safety Warehouse. It is currently running on a Genesis theme, with the `front-page.php` displaying a grid loop of the custom post type. I want to add an H1 (or at least a header tag) to use before the content. How can I do this? My Front-page.php               <?php     /**      * The custom portfolio post type archive template      */          /** Force full width content layout */     add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );          /** Remove the breadcrumb navigation */     remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );          /** Remove the post info function */     remove_action( 'genesis_before_post_title', 'genesis_post_info' );          /** Remove the post content */     remove_action( 'genesis_post_content', 'genesis_do_post_content' );          /** Remove the post image */     remove_action( 'genesis_post_content', 'genesis_do_post_image' );          /** Add the featured image after post title */     add_action( 'genesis_post_title', 'executive_portfolio_grid' );     function executive_portfolio_grid() {         if ( has_post_thumbnail() ){             echo '
';             echo '';             echo get_the_post_thumbnail($thumbnail->ID, 'portfolio' );             echo '';             echo '
';         }     }          /** Remove the post meta function */     remove_action( 'genesis_after_post_content', 'genesis_post_meta' );          genesis();


title: Limiting the WordPress feed to only a certain limit of characters

text: I have a WordPress installation that sometimes uses long and lengthy posts delimited by the `<!--more-->` tag. However on my RSS feeds, the entire post is shown. Is there a way, aside from custom tags, to delimit how much is shown in a WordPress Feed or just show enough until the "More" tag?


title: Problem importing posts (get_categories is empty)

text: I want to import posts through an RSS plugin and events through a calendar plugin, and then have these plugins set the category for these imported posts. Then, using a hook (see code below), I want to read the category and use that information to set the correct language of the post for the transposh plugin. My hook responds to save_post just fine, but then is unable to detect the category of the post using get_category (wp_get_post_terms also doesn't work). In the code below, $categories is always empty, and thus the script ends. If I echo the result of get_category to my error_log I get "Array", and if I use print_r I get "1". What's weird is that if I do anything with an imported post afterwards, for instance move it to thrash, then the hook will successfully complete and set the language. Also, if I use the hook for publish_post (instead of save_post), then the hook does work for imported RSS posts, but not for imported .ics events (the hook never gets called, probably plugin issue).    Any ideas why I have this problem, and how to fix it? I hope someone can help out, I'm totally stuck. Thanks! :)                  add_action('save_post', 'on_save_post', 20);     function on_save_post($post_id) {     $categories;     if (get_post_type($post_id) === 'ai1ec_event') {         $categories = wp_get_post_terms($post_id, 'events_categories');     } else {         $categories = get_the_category($post_id);     }          if (empty($categories)) {         return;     }     $name = $categories[0]->name;     $lang = category_to_language_code($name);     // throw new Exception("Save => " . $name . " | " . $lang . " | " . serialize($categories));     update_post_meta($post_id, 'tp_language', $lang);     }      (I left out the code for "category_to_language_code", because that part of the hook is working just fine)


title: Woocommerce personalizable products

text: I'm trying to add to text fields near the add to cart button for users to be able to personalize their products with specific text. The way I did it was using a filter               function add_cart_item_data($cart_item_meta, $product_id)     {         $cart_item_meta['field1'] = $_GET['field1'];         $cart_item_meta['field2'] = $_GET['field2'];              return $cart_item_meta;     }     add_filter('woocommerce_get_item_data', 'add_cart_item_data' ,10, 2);      Then on the cart page template I try to `var_dump($_product)` but I can't see field1 and field2. Can you guys tell me what am I doing wrong? Am I inserting the data in a proper way? How should I display the fields in the cart loop? Thank you


title: add_cap only adding the first two in array

text: After numerous days of trying to track down a problem in code, it turns out that the add_cap is only taking the first two in an array. The first one (editor) will only add delete_others_pages and delete_others_posts to the database. If I use the second method of repeating add_cap then I can get all of the capabilities into the database. Can someone look at this code and see what is wrong? Why would only the first two items in the array go into the database?                       if( $new_roles == 'editor' ) {                      $user = new WP_User( $user_id );                      $user->add_cap(                     'delete_others_pages','delete_others_posts','delete_pages','delete_posts','delete_private_pages','delete_private_posts','delete_published_pages','delete_published_posts','edit_others_pages','edit_others_posts','edit_pages','edit_posts','edit_private_pages','edit_private_posts','edit_published_pages','edit_published_posts','manage_categories','manage_links','moderate_comments','publish_pages','publish_posts','read','read_private_pages','read_private_posts');                  }                  elseif( $new_roles == 'author' ) {                      $user_id = $XF->visitor->get('user_id');                      $user = new WP_User( $user_id );                      $user->add_cap(                     'delete_posts', 'delete_published_posts'                 );                      $user->add_cap(                     'edit_posts', 'edit_published_posts'                 );                      $user->add_cap(                     'publish_posts', 'read', 'upload_files'                 );                      $user->add_cap(                     'upload_files'                 );                  }      UPDATE CODE to place complete function: Adds arrays now so my initial question is answered but they are added to the wrong users.               public static function set_user_roles( &$classObj, $user_group_id, $secondary_group_ids ) {         /**          * Function set_user_roles(&$classObj, $user_group_id, $secondary_group_ids)          *           * This function sets the current user role based on the secondary group          */         global $XF, $wp_roles;         $user_groups = explode( ',', $secondary_group_ids );         $user_groups[] = $user_group_id;              /**          * Loop through the user_roles and find the WP role equivalent for each          */         $user_roles = array();         foreach( $user_groups as $user_group ) {             $user_roles[] = $XF->options['xf_user_role'][$user_group];                  /**              * wp_die( 'This is the role:' . var_dump( $XF->options['xf_user_role'] ) );              *               * Returns:              *              * array(7) { [3]=> string(13) "administrator" [4]=> string(6) "author" [2]=> string(10) "subscriber" [1]=> string(10) "subscriber" [5]=> string(6) "author" [7]=> string(11) "contributor" [6]=> string(6) "editor" }              */                  /**              * wp_die( var_dump( $XF->options['xf_user_role'][$user_group] ) );               *              * Returns for user Ellie who has secondary group related to author              * string(6) "author"              *               * Returns Albert who has secondary group set to editor              * string(6) "editor"              *              * Returns Pascal who has secondary group related to contributor              * string(11) "contributor"              *              * Returns Gracie NO secondary group for registered members.              * NULL              *                         */                       $new_roles =  $XF->options['xf_user_role'][$user_group];                  if( $new_roles == '' || $new_roles == null) {                      $user_id = $XF->visitor->get('user_id');                      $caps = array( 'read' );                      $user = new WP_User( $user_id );                      foreach ( $caps as $cap ) {                          $user->add_cap( $cap );                       }                 break;                  }                  elseif( $new_roles == 'subscriber' ) {                      $user_id = $XF->visitor->get('user_id');                      $caps = array( 'read' );                      $user = new WP_User( $user_id );                      foreach ( $caps as $cap ) {                          $user->add_cap( $cap );                       }                 break;                  }                  elseif( $new_roles == 'contributor' ) {                      $user_id = $XF->visitor->get('user_id');                      $caps= array( 'delete_posts', 'edit_posts', 'read' );                      $user = new WP_User( $user_id );                      foreach ( $caps as $cap ) {                          $user->add_cap( $cap );                       }                 break;                  }                  elseif( $new_roles == 'author' ) {                                $user_id = $XF->visitor->get('user_id');                      $caps = array(                     'delete_posts', 'delete_published_posts','edit_posts', 'edit_published_posts','publish_posts', 'read', 'upload_files','upload_files'                     );                      $user = new WP_User( $user_id );                      foreach ( $caps as $cap ) {                          $user->add_cap( $cap );                       }                 break;                  }                             elseif( $new_roles == 'editor' ) {                      $user_id = $XF->visitor->get('user_id');                      $caps = array (                      'delete_others_pages','delete_others_posts','delete_pages','delete_post','delete_private_pages','delete_private_posts','delete_published_pages','delete_published_posts','edit_others_pages','edit_others_posts','edit_pages','edit_posts', 'edit_private_pages','edit_private_posts','edit_published_pages','edit_published_posts','manage_categories','manage_links','moderate_comments','publish_pages','publish_posts','read','read_private_pages','read_private_posts'                 );                      $user = new WP_User( $user_id );                      foreach ( $caps as $cap ) {                          $user->add_cap( $cap );                       }                 break;                  }                  elseif( $new_roles == 'administrator' ) {                      $user_id = $XF->visitor->get('user_id');                      $caps = array (                      'activate_plugins', 'delete_others_pages','delete_others_posts','delete_pages','delete_plugins','delete_posts','delete_private_pages','delete_private_posts','delete_published_pages','delete_published_posts','edit_dashboard','edit_files','edit_others_pages','edit_others_posts','edit_pages','edit_posts','edit_private_pages','edit_private_posts','edit_published_pages','edit_published_posts','edit_theme_options','export','import','list_users','manage_categories','manage_links','manage_options','moderate_comments','promote_users','publish_pages','publish_posts','read_private_pages','read_private_posts','read','remove_users','switch_themes','upload_files','create_product'                 );                      $user = new WP_User( $user_id );                      foreach ( $caps as $cap ) {                          $user->add_cap( $cap );                       }                 break;                  }                   }          }      Update: Capabilities are being added but now all accounts are getting admin capabilities. This is now asked: Editor and contributor roles not correct after adding function


title: How to load whole Wordpress pages dynamically with AJAX/jQuery like this following website?

text: This website: http://www.ericpaulsnowden.com (The website is done in Wordpress). Loads pages and posts dynamically with AJAX/jQuery. Does anybody know how to do this?


title: Problem in replacing the_content with the_excerpt()

text: I want to add **read more** to a blog. For that I need to replace the function `the_content()`. I found it in the loop file and replaced it with `the_excerpt()` but still posts are being shown of full length. Please help out. **EDIT:** Here is the site. The read more is added now(I replaced all the occurences of the_content with the_excerpt). It gave rise to a new problem. All the links on the page are not working correctly. Please have a look.


title: Allow user to set custom order to a list of custom taxonomies?

text: I have a custom category checkbox on each individual bio attorney page that shows what practice areas these attorneys are involved in. Currently I have them sorting alphabetically. I am wondering if there is anyway to allow each attorney to set their own custom order when selecting their practice areas. Here is a screenshot of the post: https://www.dropbox.com/s/1si99a5elkmdwbr/Screen%20Shot%202013-02-14%20at%2011.50.02%20AM%20copy.png UPDATE: For those interested I figured it out. I added this to my functions.php:               function set_the_terms_in_order ( $terms, $id, $taxonomy ) {     $terms = wp_cache_get( $id, "{$taxonomy}_relationships_sorted" );     if ( false === $terms ) {         $terms = wp_get_object_terms( $id, $taxonomy, array( 'orderby' => 'term_order' ) );         wp_cache_add($id, $terms, $taxonomy . '_relationships_sorted');     }     return $terms;     }     add_filter( 'get_the_terms', 'set_the_terms_in_order' , 10, 4 );          function do_the_terms_in_order () {         global $wp_taxonomies;  //fixed missing semicolon         // the following relates to tags, but you can add more lines like this for any taxonomy         $wp_taxonomies['post_tag']->sort = true;         $wp_taxonomies['post_tag']->args = array( 'orderby' => 'term_order' );         }     add_action( 'init', 'do_the_terms_in_order');      then when I register my taxonomy I set:               'hierarchical' => false,             'orderby' => 'term_order'      CREDIT: http://wordpress.kdari.net/2011/07/listing-tags-in-custom-order.html


How can items be programatically removed from Woocommerce shopping cart without refreshing the page - ie using AJAX?


title: How to automatically and randomly reorder custom post type?

text: Is there a plugin available? Or suggestions on how to achieve re-ordering automatically and randomly custom post type?


title: Block direct url enter

text: I want to block / disable direct url entering into address bar. Is it possible in wordpress? Actually I have created custom login, profile and other pages so don't want to allow user to go through wp-admin and I want to block all direct url entering.


title: Wordpress Drag n Drop Uploader - Single File Only

text: I have a system in place to allow users to upload files, once they have done this they are thrown into a plugin to allow them to perform various cropping (on the main image and the configured thumbnails). My problem is that if I upload multiple files it causes issues as the user can only work on one file at a time. Is there anyway that I can restrict the drag and drop uploader to only accept one file upload at a time? I know that there is the option of the old HTML uploader which does one at a time, but I would prefer to retain the drag and drop option. Thx Richard


title: How to create dynamic menu from HTML

text:
I tried creating a dynamic menu from HTML, I registered menu in function name is main menu, Here is the HTML code that display the main menu-

             <a class="sprite" href="<?php echo esc_url( home_url( '/' ) ); ?>">              <a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <img src="<?php bloginfo('template_directory') ?>/images/home.png" width="57" height="52"  class="home"/>
Home

About Us

Privacy Policy

Disclaimer

SiteMap

Contact Us

Aquaponics

AquaCulture

Hydroponics

Do-It-Yourself Aquaponics

Fish & Plants for Aquaponics


title: Modified home page query does not yield expected results

text:
Yesterday i asked how it would be best to load all existing pages and their content on front page - to create single page layout. (Single page theme) From the info on that page i created my own pre_get_posts hook in functions.php:               function show_all_pages_on_index( $query ) {         if ( (is_front_page() || is_home()) && $query->is_main_query() ) {             $query->set('post_type', 'page');             $query->set('parent', '0');             $query->set('post_status', 'publish');             $query->set('orderby', 'menu_order');             $query->set('order', 'ASC');         }     }     add_action( 'pre_get_posts', 'show_all_pages_on_index' );      If i put echo in the condition there it gets printed out, so i guess the hook works. but this snippet in index.php still only prints out the initial blogpost that gets created with wordpress install: index.php:               $myposts = get_posts();     foreach( $myposts as $post ) :  setup_postdata($post);              echo "
". the_title()."
";          endforeach;      wp_reset_postdata();      HTML:               http://localhost/hello-world/Hello world!

      Edit - to show what worked in my case as single page layouyt: functions.php:               function show_all_pages_on_index( $query ) {         if ( (is_front_page() || is_home()) && $query->is_main_query() ) {             $query->set('post_type', 'page');             $query->set('post_parent', 0);             $query->set('post_status', 'publish');             $query->set('orderby', 'menu_order');             $query->set('order', 'ASC');         }     }     add_action( 'pre_get_posts', 'show_all_pages_on_index' );      index.php:               while ( have_posts() ) {         the_post();         get_template_part( 'content', 'page' );     }      From there on wordpress'own tempate logic takes over using content-page.php or content.php, which pretty much means you can create different templates for subpages but you need to create them so that they actually fit into single page layout. Thanks to everybody who contributed:)


title: Display link with current user's username in it in Custom Menu

text: I'd like to add a link to BuddyPress' My Favourite Topics in a Custom Menu. Is there a way to use the current logged in user's username in the link? I mean like the `%category%` in the permalinks.


title: get an attachment's media tags or check if it has a media tag?

text: Is there a way i can get media_tags assigned to an attachment (by id)? And/or check if an attachment has a media_tag? Not sure if i'm missing something but there seems to be very little support for doing this? any help appreciated, Dc


title: My custom widget won't stay in the widget area after I refresh the widget page

text:
As the title says, i've been developing a simple image rollover widget, now that I'm almost done, the widget won't stay in the sidebar areas after I drag and drop it in and refersh the page, any idea what's going on?               <?php     /**      * Plugin Name: Rollover Widget      * Description: A widget that creates a rollover image effect with a hyperlink.      * Version: 0.1      * Author: Zak Elas      * Author URI: http://dot.com      */               add_action( 'widgets_init', 'my_widget' );               function my_widget() {         register_widget( 'MY_Widget' );     }          class MY_Widget extends WP_Widget {              function MY_Widget() {             $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that creates a rollover image effect with a hyperlink. ', 'example') );                  $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'Rollover Widget' );                  $this->WP_Widget( 'example-widget', __('Rollover Widget', 'example'), $widget_ops, $control_ops );         }              function widget( $args, $instance ) {             extract( $args );                  //Our variables from the widget settings.             $link =  $instance['link'] ;             $image = $instance['image'];             $rollover_image = $instance['rollover_image'];                  echo $before_widget;                  // Display the widget link                   echo $before_link . $link . $after_link;                  //Display the name                         echo '

';                        echo $after_widget;         }              //Update the widget               function update( $new_instance, $old_instance ) {             $instance = $old_instance;                  //Strip tags from link and name to remove HTML              $instance['link'] = strip_tags($new_instance['link']);             $instance['image'] =  strip_tags($new_instance['image']);             $instance['rollover_image'] = strip_tags( $new_instance['rollover_image']);                  return $instance;         }                   function form( $instance ) {                  //Set up some default widget settings.             $defaults = array( 'link' => __('Example', 'example'), 'image' => __('/images/editorial.png', 'example') , 'rollover_image' => __('/images/editorial.png', 'example') );             $instance = wp_parse_args( (array) $instance, $defaults ); ?>
                 <label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e('link', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" value="<?php echo $instance['link']; ?>" style="width:100%;" />

                 <label for="<?php echo $this->get_field_id( 'image' ); ?>"><?php _e('image', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'image' ); ?>" name="<?php echo $this->get_field_name( 'image' ); ?>" value="<?php echo $instance['image']; ?>" style="width:100%;" />

                 <label for="<?php echo $this->get_field_id( 'rollover_image' ); ?>"><?php _e('rollover_image:', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'rollover_image' ); ?>" name="<?php echo $this->get_field_name( 'rollover_image' ); ?>" value="<?php echo $instance['rollover_image']; ?>" style="width:100%;" />
                        <?php         }     }          ?>


title: Import Wordpress xml file larger than 8mb

text: I'm trying to import a xml file (from a previous wordpress theme) into a new wordpress theme. The problem is that the xml file is 46mb much bigger than the wordpress 8mb limit. Anyone have any advice/recommendations on how to import this file? Thanks apagey


title: wp_redirect does not work

text: I have a problem with `wp_redirect` which does seem to redirect. It's a full url that is on the current website. I need to put `exit();` after `wp_redirect` for it to redirect. Is this normal? Redirect is in an `init` action btw.


title: Media attachment date and post date

text: I have just migrated a massive site (2500+ users, 5000+ posts/images) to Wordpress using custom code. Basically every post has one image and that image is attached to the post as the featured image, and all images show on the Media Library. I have also managed to keep the original submission date for every post (which is the same date each image was uploaded) and to save every image under the corresponding /wp-content/uploads/[year]/[month] folder. So far so good. Hoever... all those image files and all entries on the Media Library, show the migration date (Nov 2011) instead of the original file creation/post creation date (variable from 2003 to 2009). This makes it very difficult to find which image belongs to a certain post, as image creation date information was lost. So I need to update the dates of all Media Library entries and image file creation (same thing?), to the date of the post they are attached to. Any idea what's the best way to go about it? Any help would be truly appreciated.


title: Cant edit profile from frontend

text: Hope you can assist. **Background:** I have a multisite config. Users need to be able to update their profile from the frontend, via their profile page, which is something like, `http://example.com/forum/user/fred@example.com` thanks to bbpress. However only Super-Admins can edit their profile. There is a little edit link next to their name but if they are not super-admins then it does not work. How can I fix this? Thanks in advance


title: Error messages & can't reach admin after upgrading to 3.4.1 WordPress

text: My hosting company upgraded their php, so my site was getting all sorts of error messages. So, I make a backup of all my content, deleted the wp-admin, wp-includes and loose files in html, then uploaded 3.4.1 of WordPress. I got a bunch of errors at that point, so via FTP I went into my plugins folder and renamed them. That caused most of the messages to go away. Now, I'm left with just two errors. On the front page, I get this error, even though the page loads successfully: Strict Standards: Redefining already defined constructor for class WP_Widget in /nfs/c05/h04/mnt/73941/domains/feltbeats.com/html/wp-includes/widgets.php on line 93 When I go to wp-admin however, the page does NOT load and I see only this: Strict Standards: Redefining already defined constructor for class WP_Widget in /nfs/c05/h04/mnt/73941/domains/feltbeats.com/html/wp-includes/widgets.php on line 93 Warning: Cannot modify header information - headers already sent by (output started at /nfs/c05/h04/mnt/73941/domains/feltbeats.com/html/wp- includes/widgets.php:93) in /nfs/c05/h04/mnt/73941/domains/feltbeats.com/html/wp-includes/pluggable.php on line 881 I was actually just on the phone with my hosting company, and he very kindly looked at this for about an hour. He was focusing on it being an actual bug in 3.4.1 - but it seems the fact that the admin doesn't load would have been noticed. =) So I assume it is something in my set up. But since I deleted most files, I can't see what it would be. I had a custom functions.php file in my theme, but I tried deleting it and also the php in it. Any help or just pointing me in the right direction would help. Thank you!


title: How can one update a theme on a live site without interruption?

text: So i have a WordPress-based site with a custom Genesis child theme. Once the site goes live, we are obviously going to need to make changes periodically to the child theme's code — modifying CSS and similar. These are the problems i've run into:   1. I don't have shell or FTP access, so i can't just replace the files on the server (they wanted to use one of those dedicated WordPress hosting providers for security and ease of maintenance).   2. It's not possible to upgrade an active theme 'in place' when using the Web-based Upload functionality (you can only do this with themes installed via WordPress's repository thing).   3. To get around the above limitation, i thought maybe i'll just put the git revision hash or whatever in the theme name each time i build the zip file, which will make WordPress see it as a separate theme, and then i can just switch from the old one to the new one. This does work, except that it causes WordPress to reset some of its settings (in particular, which menu is set as the 'Navigation Bar'). To be clear, i am NOT asking how i can test/see changes before making them in production (i have a development server), my issue is specifically with the mechanism of making the change. Given my circumstances, is there any way to do this without causing interruption / having to make configuration changes each time we update?


title: How do I get WooCommerce to automatically recreate pages?

text: I had to uninstall WooCommerce plugin (I deleted the tables it created as well) and now I reinstalled the plugin and I doesn't automatically recreate the WooCommerce Pages. Am I stuck having to manually create the pages myself? Is there a way to have it automatically regenerate the pages?


title: add widgets to dashboard for easy access for clients?

text: I have a widget created:               if ( function_exists('register_sidebar') )       register_sidebar(array(         'name' => 'Featured Video',         'before_widget' => '',         'after_widget' => '',         'before_title' => '',         'after_title' => '',       ));      All is good, I was just wondering if it was possible to show this widget on the dashboard so the client can easily change the contents when needed. I just want my client to have easier access to it. If it's not possible, no big deal.


title: Deleting old posts

text: I have around 30 old posts that I want to delete on my blog. Can I just delete them permanently or should I worry about the "errors" I will get on my google webmasters tools and redirect them somehow?


title: What is the purpose of this line of code in wp_trim_excerpt?

text: Can someone please explain what the purpose of this code is:               $text = str_replace(']]>', ']]>', $text);      I'm referring to a line of code inside wp_trim_excerpt(), but I've seen something very similar in some other wp functions as well. On the surface, I would say it's not doing anything at all, but I have to give the wordpress developers more credit than that, so I'm sure there's a reason for this. I've looked into the php manual for str_replace to see if there is some special return value but everything is as I would expect. Is this some sort of ninja data validation technique?


title: Counting number of identical meta keys

text: Im looking to count how many meta keys exist within a post, because each time a specific user action happens, a new meta key is created with a date in it. I have this, which does not return anything (I'm looking for a number)...                       ...     $post_title = $row->post_title;             $id = $row->ID;          $post_count = $wpdb->get_var("                     SELECT COUNT(DISTINCT $wpdb->postmeta.meta_key) FROM $wpdb->posts                     LEFT JOIN $wpdb->postmeta                      WHERE $wpdb->posts.post_type = 'things'                     AND $wpdb->postmeta.meta_key = 'dates'                      AND post_id = $id                     ");                  echo $post_title . ' (' . $post_count . ')' . "\n";         }      Similarly, I'd like to count the number of meta keys in total related to a custom post, any help on either of these would be greatly appreciated!


title: How to disable sidebar only in bbPress and not WordPress?

text: I am trying to integrate bbPress with WordPress, and the only thing in my way (for now) is the sidebar. How do I disable sidebar in bbPress? I know that one way is to manually remove or comment out `<?php get_sidebar)(); ?>` in all bbPress template files. But I would like to know if there a way that will allow me to quickly allow me to turn it on or off — like adding some code in functions.php etc. Thanks.


title: CPT archive as home page

text: I am very new to WP coding. I am working for a University where each faculty has been allocated a CPT. We would like it so that the CPT archive looks the same as the main site. I have created the archive-post-type.php file but am at a total loss from there. From what I have seen in other questions is that the homepage is key? I have this `                                   /*                          * Include the post format-specific template for the content. If you want to                          * use this in a child theme, then include a file called called content-___.php                          * (where ___ is the post format) and that will be used instead.                          */                         get_template_part( 'content-fbe', get_post_format() );                          endwhile;                     // Previous/next page navigation.                     twentyfourteen_paging_nav();                      else :                     // If no content, include the "No posts found" template.                     get_template_part( 'content', 'none' );                      endif;             ?>`      Any help would be really appreciated.


title: using update_user_meta in form to set and get custom meta

text:
I have a template where a user will set some custom meta values via a form on the front end of my site. I call this form via a function in my functions.php file. Currently when the text inputs are filled out and I hit submit, the values save to the database like expected, however I don't see the values submitted on the page until I hit refresh on my browser. But when I do that I then see the values the user set but the values get stripped from the database, (hitting refresh again on my browser will default back to no values be set). Not sure I have this setup correctly? Here is the code from my template:
Your Values
     Value 1: <?php if(!$new_high) { echo 'Not Set'; } else { echo '$' . $new_high; } ?>     Value 2: <?php if(!$new_medium) { echo 'Not Set'; } else { echo '$' . $new_medium; } ?>     Value 3: <?php if(!$new_low) { echo 'Not Set'; } else { echo '$' . $new_low; } ?>      Then I call the function in the template that has the form: `<?php my_form_function(); ?>` In my functions file I have this which houses the form and updates the user_meta:               function my_form_function() {     global $current_user;     ?>     <form name="setPrices" action="" method="POST">          <fieldset>     Value 3:     <input type="text" id="lowPrice" name="lowPrice" value="<?php echo $_POST['lowPrice']; ?>" />     </fieldset>          <fieldset>     Value 2:     <input type="text" id="mediumPrice" name="mediumPrice" value="<?php echo $_POST['mediumPrice']; ?>" />     </fieldset>          <fieldset>     Value 1:     <input type="text" id="highPrice" name="highPrice" value="<?php echo $_POST['highPrice']; ?>" />     </fieldset>          <button type="submit">Save</button>     </form>          <?php     $low_price = $_POST['lowPrice'];     $medium_price = $_POST['mediumPrice'];     $high_price = $_POST['highPrice'];          update_user_meta( $current_user->ID, '_low_price', $low_price);      update_user_meta( $current_user->ID, '_medium_price', $medium_price);     update_user_meta( $current_user->ID, '_high_price', $high_price);          }      So just to make sure I haven't confused anyone, The above does work (kinda) and when the form is submitted the values save to the database as expected. But I don't see the values in my template until I refresh the page, and once I do that the values reset to nothing. I know my problem is how/where I have update_user_meta


title: Post sharing email button with post excerpt

text: How can I have a button by which one can send post link and first 30 words of the article via email. I found some plugins which only send post permalinks not post excerpt. Thanks in advance.


title: How to have post permalinks redirect to index.php with parameters for loading the content via AJAX?

text: That question is a bit of a mouthful, so allow me to elaborate: I'm using Wordpress as the CMS for a portfolio (each project is a post in the same category, 'work'). I'm displaying the posts using AJAX. So, when a user comes to the main site (index.php), they can click on a link to the project, and the post content loads in a div on index.php. I'm using the History API to track their progress so they can use the back button. All of that's working. Pretty simple. The part I'm struggling with is how to handle users who navigate directly to a project "page" using a permalink URL. Right now, the permalink URLs are "pretty" (mysite.com/projectname). Her's what I want to happen when a user enters one of these URLs in the address bar: 1) Load index.php. 2) Trigger the javascript which displays the desired post/project. 3) The URL in the address bar remains the same (mysite.com/projectname). Step 2 seems straightforward, I'm just having trouble getting to a state where I have index.php loaded with parameters that tell me which post to load. I've tried a few techniques, but they all involve altering the URL in a way that doesn't match the pretty URL the user entered in the first place. I did try using the History API to alter the URL, but of course this pushes a state to the History, which is no bueno. Does anyone have experience setting up a Wordpress site with similar navigation? Look forward to hearing from you.


title: Custom Posts and Posts - next_post_link and previous_post_link not working together

text:
I have regular posts and one custom post type ('SS13') pulled in together on the same page. When you click through to the 'single' page for each the next_post_link and previous_post link only work within their post group (regular posts or 'SS13'). I can't find a solution so that next/previous work across all the posts. CPT is used for organisational purposes in the admin section.               <?php /* Start loop */ ?>             <?php while (have_posts()) : the_post(); ?>
                     <article <?php post_class('standard') ?> id="post-<?php the_ID(); ?>">

                                 <?php if(get_field('standard_banner_image')){ ?>                                 <img src="<?php the_field('standard_banner_image'); ?>" alt="Banner Image" />                                 <?php } ?>

<?php next_post_link('%link', 'Next Post: %title', 'FALSE'); ?>&nbsp |  <?php previous_post_link('%link', 'Previous Post: %title',  'FALSE'); ?>

                  <?php endwhile; // End the loop ?>      Any help would be great. Thank You.


title: Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?

text:
Ok so here's the question how do i stop js from running twice on the widget.php page? I am creating a ajax loaded custom image selector from a domain on the same server as the current site. I want the user to be able to pick an image and populate the fields below with the href to the image description, the title of the image and the image src in it's self, this then posts the results on the front end in the sidebar. I have registered a custom widget inside of my functions.php, the widget has custom js inside it the code is as follows:               /*     *     *Ajax loaded gallery for sidebar     *Note this will not work cross browser.     *     *     */     /**      * Plugin Name: A gallery Widget      * Description: A widget that displays an ajax loaded gallery.      * Version: 0.1      */          add_action( 'widgets_init', 'my_widget' );          function my_widget() {       register_widget( 'MY_Widget' );     }          class MY_Widget extends WP_Widget {            function MY_Widget() {         $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that displays the chosen gallery images and link from lundhs ', 'example') );              $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' );              $this->WP_Widget( 'example-widget', __('Reference Projects', 'example'), $widget_ops, $control_ops );       }            function widget( $args, $instance ) {         extract( $args );              //Our variables from the widget settings.         $titlewidget = apply_filters('widget_title', $instance['titlewidget'] );         $introtext = $instance['introtext'];         $title = $instance['title'];         $name = $instance['name'];         $img = $instance['img'];         $show_info = isset( $instance['show_info'] ) ? $instance['show_info'] : false;              echo $before_widget;          ?>     <?php     if($titlewidget)       ?>
<?php echo $titlewidget;?>
     <?php     if($introtext)     ?>
 <?php echo $introtext; ?>

     <?php     //display gallery img     if ( $img)       ?>     <a class="columns four" href="<?php echo $name; ?>">          <img class="imggallery" src="<?php echo $img; ?>">                 <?php       // Display the gallery name and link         if ( $title )           ?>          <a class="columns eight imggallery_link" href="<?php echo $name; ?>"><?php echo $title; ?>
          <?php         echo $after_widget;       }            //Update the widget             function update( $new_instance, $old_instance ) {         $instance = $old_instance;              //Strip tags from title and name to remove HTML         $instance['titlewidget'] = strip_tags( $new_instance['titlewidget'] );         $instance['introtext'] = strip_tags( $new_instance['introtext'] );         $instance['title'] = strip_tags( $new_instance['title'] );         $instance['name'] = strip_tags( $new_instance['name'] );         $instance['show_info'] = $new_instance['show_info'];         $instance['img'] = $new_instance['img'];              return $instance;       }            function form( $instance ) {              //Set up some default widget settings.         $defaults = array( 'title' => __('Example', 'example'), 'introtext' => __('introtext', 'example'), 'titlewidget' => __('Reference Project', 'example'), 'img' => __('img', 'example'), 'name' => __('link goes here', 'example'), 'show_info' => true );         $instance = wp_parse_args( (array) $instance, $defaults ); ?>
Gallery selector for Lundhs

         <label for="<?php echo $this->get_field_id( 'titlewidget' ); ?>"><?php _e('Widget Title:', 'example'); ?>           <input type="text" class="titlewidget" name="<?php echo $this->get_field_name( 'titlewidget' ); ?>" value="<?php echo $instance['titlewidget']; ?>" style="width:100%;" />

         <label for="<?php echo $this->get_field_id( 'introtext' ); ?>"><?php _e('Intro text:', 'example'); ?>           <input type="text" class="introtext" name="<?php echo $this->get_field_name( 'introtext' ); ?>" value="<?php echo $instance['introtext']; ?>" style="width:100%;" />

First Pick your images

Your current front end projects

Reference project one

         <img class="gallery_one" src="<?php echo $instance['img']; ?>" />

           <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'example'); ?>           <input type="text" class="title" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />

           <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e('The link:', 'example'); ?>           <input type="text" class="link" id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" value="<?php echo $instance['name']; ?>" style="width:100%;" />
              //img Input.
           <label for="<?php echo $this->get_field_id( 'img' ); ?>"><?php _e('The Link to the image:', 'example'); ?>           <input type="text" class="img" id="<?php echo $this->get_field_id( 'img' ); ?>" name="<?php echo $this->get_field_name( 'img' ); ?>" value="<?php echo $instance['img']; ?>" style="width:100%;" />

     Add new project

       <?php       }     }      the problem arises because this js runs twice adding the additional input boxes twice when '.addNew' is clicked.                   (function($) {             var addDiv = jQuery('.addinput');             var i = jQuery('.addinput p').size() + 1;              jQuery('.addNew').live('click', function() {             jQuery.append('
<input type="text" class="p_new' + i +'" size="40" name="p_new_' + i +'" value="" placeholder="I am New" />Remove
');             i + 1;                  return false;         });              jQuery('.remNew').live('click', function() {               if( i > 1 ) {               jQuery(this).parents('p').remove();               i - 1;               }         return false;         });     }(jQuery));      the latter code runs twice once in the inactive widgets on the left and once in the active widget in the sidebar. How do i go about forcing the JS to run only in the currently active widget. Moving the js to a separate .js file and enqueing really isn't an option for me because i am going to have to use php values inside the php to populate and retrive the values in the next step of this build. Any help is appreciated. Chris // **UPDATE** // Right i think the function i'm looking for is `is_active_widget()` (codex) but I just can't seem to get it to work it still runs the js twice even if i set $skip_inactive to true.   so far I've tried this:                   //start gallery widget          add_action( 'widgets_init', 'my_widget' );          function my_widget() {       register_widget( 'MY_Widget' );     }          class MY_Widget extends WP_Widget {            function MY_Widget() {              $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that displays the chosen gallery images and link from lundhs ', 'example') );              $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' );              $this->WP_Widget( 'example-widget', __('Reference Projects', 'example'), $widget_ops, $control_ops );       }                 function widget( $args, $instance ) {              extract( $args );              //Our variables from the widget settings.         $titlewidget = apply_filters('widget_title', $instance['titlewidget'] );         $introtext = $instance['introtext'];         $title = $instance['title'];         $name = $instance['name'];         $img = $instance['img'];         $show_info = isset( $instance['show_info'] ) ? $instance['show_info'] : false;              echo $before_widget;          ?>     <?php      if($titlewidget)       ?>
<?php echo $titlewidget;?>
     <?php      if($introtext)     ?>
 <?php echo $introtext; ?>

     <?php      //display gallery img     if ( $img)       ?>     <a class="columns four" href="<?php echo $name; ?>">          <img class="imggallery" src="<?php echo $img; ?>">                 <?php       // Display the gallery name and link          if ( $title )           ?>          <a class="columns eight imggallery_link" href="<?php echo $name; ?>"><?php echo $title; ?>
          <?php             echo $after_widget;       }            //Update the widget             function update( $new_instance, $old_instance ) {         $instance = $old_instance;              //Strip tags from title and name to remove HTML          $instance['titlewidget'] = strip_tags( $new_instance['titlewidget'] );         $instance['introtext'] = strip_tags( $new_instance['introtext'] );         $instance['title'] = strip_tags( $new_instance['title'] );         $instance['name'] = strip_tags( $new_instance['name'] );         $instance['show_info'] = $new_instance['show_info'];         $instance['img'] = $new_instance['img'];                   return $instance;       }                 function form( $instance ) {      if ( is_active_widget( false, false, $this->id_base, true ) ) {?>                      <?php     }             else {          ?>                   <?php       }              //Set up some default widget settings.         $defaults = array( 'title' => __('Example', 'example'), 'introtext' => __('introtext', 'example'), 'titlewidget' => __('Reference Project', 'example'), 'img' => __('img', 'example'), 'name' => __('link goes here', 'example'), 'show_info' => true );         $instance = wp_parse_args( (array) $instance, $defaults );          wp_localize_script( 'some_handle', 'object_name', $instance );         ?>
Gallery selector for Lundhs

         <label for="<?php echo $this->get_field_id( 'titlewidget' ); ?>"><?php _e('Widget Title:', 'example'); ?>           <input type="text" class="titlewidget" name="<?php echo $this->get_field_name( 'titlewidget' ); ?>" value="<?php echo $instance['titlewidget']; ?>" style="width:100%;" />

         <label for="<?php echo $this->get_field_id( 'introtext' ); ?>"><?php _e('Intro text:', 'example'); ?>           <input type="text" class="introtext" name="<?php echo $this->get_field_name( 'introtext' ); ?>" value="<?php echo $instance['introtext']; ?>" style="width:100%;" />

First Pick your images

Your current front end projects

Reference project 1

         <img class="gallery_one" src="<?php echo $instance['img']; ?>" />

           <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'example'); ?>           <input type="text" class="title" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />

           <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e('The link:', 'example'); ?>           <input type="text" class="link" id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" value="<?php echo $instance['name']; ?>" style="width:100%;" />
              //img Input.
           <label for="<?php echo $this->get_field_id( 'img' ); ?>"><?php _e('The Link to the image:', 'example'); ?>           <input type="text" class="img" id="<?php echo $this->get_field_id( 'img' ); ?>" name="<?php echo $this->get_field_name( 'img' ); ?>" value="<?php echo $instance['img']; ?>" style="width:100%;" />

     Add new project

       <?php       }     }      I have also tried moving it into the `class MY_Widget extends WP_Widget { }` then adding the `add_action`. Like so:                   class MY_Widget extends WP_Widget {            function MY_Widget() {         $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that displays the chosen gallery images and link from lundhs ', 'example') );              $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' );              $this->WP_Widget( 'example-widget', __('Reference Projects', 'example'), $widget_ops, $control_ops );       }       add_action('widgets_init', 'jsadd');       function jsadd(){           if ( is_active_widget( false, false, 'MY_Widget', true ) ) {?>                          <?php     }             else {          ?>                   <?php       }            }      but still no luck. DOes anybody know what i'm doing wrong here?


title: How do I write this shortcode?

text:
I have this shortcode, I would like to write in a better and clean way:               function webhosting_products_shortcode( $atts, $content = null) {         $content='
Eburnie Hosting vous offre:
'                 . '

'                 . '
Hébergement Web
'                 . '

'                 . '
Hébergement Web

'                 . '

Hébergement Email
'                 . '

'                 . '
Hébergement Email

'                 . '

Conception de Sites
'                 . '

'                 . '
Conception de Sites

'                 . '

Certificat SSL
'                 . '

'                 . '
Certificat SSL

'                 . '

Programme Revendeur
'                 . '

'                 . '
Programme Revendeur
'                 . '

';              return $content;            }     add_shortcode('webhosting', 'webhosting_products_shortcode');      The shortcode [webhosting] is working, but I don´t think it´s the right way to achieve it. Thanks.


title: Wordpress: How to use post_class() in an echo

text:
I am working on a foreach loop in Wordpress and want to add 'post_class()' to a div within it. Currently the code looks like this:               if ( is_array( $posts ) && !empty( $posts ) ) {              echo '
';         foreach ( $posts as $post ) {             echo '
';                 echo '
';                     echo   '
';                      echo        '
'. tribe_get_event_taxonomy() .'
';                     echo    '
';                 echo '
';             echo '
';         }         echo '
';     }      The 'post_class()' function is breaking the div it is in and calling the classes as if they were content in the page. Any ideas?


title: How to sync with plugins update after I have done manual optimizations?

text: I have several WordPress running plugins on my site and as per suggestions of wordpress performance optimizations I am planning to do the optimizations on plugins myself. However, that will mean that I will have to modify existing plugins codes. Now, as WordPress plugins release frequent updates, the updates will wipe out my manual changes. How can I keep sync between these? That means, how can I get updated plugin and keep my manual changes as well?


title: Custom query to get post names beginning with a digit

text: I'm implementing an A-Z index for a custom post type. I've got my links printing out the page and the query working for the letters. However, the numbers are tripping me up because I don't want them to work quite the same. I want the first link to read '0-9' and clicking it to show all posts that start with a number. I think a wildcard is the answer, but it's not working the way I expect. Here's my function from my `functions.php`:               function test_first_letter( $sql ){       global $wpdb;       $first_letter = get_query_var( 'first_letter' );       if( $first_letter ){        if( $first_letter == 'num') :          $sql .= $wpdb->prepare( " AND $wpdb->posts.post_name LIKE %s ", '5%');        else:          $sql .= $wpdb->prepare( " AND $wpdb->posts.post_name LIKE %s ", $first_letter.'%' );        endif;       }       return $sql;     }     add_action( 'posts_where', 'test_first_letter' );      If the `$first_letter` query param is equal to 'num', then I want the query to look for all `post_names` starting with numbers `0-9`. However, this doesn't work:               $sql .= $wpdb->prepare( " AND $wpdb->posts.post_name LIKE %s ", '[0-9]*');      How can I get all posts where the post_name starts with any digit, 0-9?


title: Appengine - Wordpress authentication through google ID?

text: I am planning to migrate my website to Google appengine. I wanted to know that if I do migrate then will my users necessarily need to login using the googleID/openID or can I maintain the default wordpress login. An additional linked quesiton: I would prefer to force users to login using google account only. I am currently using social login plugin to implement the same. Does appengine provide other options to force wordpress authentication only through google IDs? Thanks


title: Displaying ACF image from within another plugin

text:
I'm trying to call an image from a custom field made with Advanced Custom Fields but can't seem to get it working. The code below is in a PHP file within another plugin. The idea is that clicking on the title (H3) it will show the 'zoom' image in a pop-up lightbox.               if( 'show' == $values['title'] ){         $item .= '
';         $feat_img = wp_get_attachment_image_src(get_field('zoom'), 'full');         $item .= '';         $item .= apply_filters('the_title',$thepost['post_title']);         $item .= '';         $item .= '
';     }      The href tag shows empty on the front end and selecting between `image object`, `image url` and `image ID` doesn't make a difference. Perhaps I need to try and call ACF scripts before this plugins script? If so, how do I go about doing that?


title: How to make comments work for a post loaded per Ajax?

text:
I am currently loading a single post using ajax. While the post loading works ok, I cannot get the comments to load. Here is my code: My javascript to load the post:                     The javascript goes through functions.php this way:               function implement_posts()     {         //<?php         get_template_part( 'loop', 'single' );         die();     }      Now here is the code where I actually load my post content:               <?php         $linkid = "p=".$_POST["postid"];         $posti = new WP_Query($linkid);         $posti->the_post();         echo "Time: ";         the_time('F jS, Y');         echo "
";         the_category(', ');         echo "
";         the_title();         echo "
";         the_content();         echo "
";         comment_form();         ?>
         <?php if (have_comments()) {         echo "Comments ok";         }         else         {             echo "No comments";         }         ?>      Now, even for posts having comments I am getting "No comments" displayed. Everything else works correctly. Can anyone help me out? Thank you.


title: Unable to override pluggable function wp_mail

text: A couple of days ago, my wordpress blog hosted on openshift suddenly stopped sending me mails and notifications. Until now I'd never bothered how wordpress handled mail sending since they always worked. Now, after going through codex, etc I came to know that wordpress handles this by calling the wp_mail(), then @mail() php function which ultimately calls the unix sendmail. Since I don't want to depend on sendmail/openshift, I decided to override the wp_mail pluggable function in my custom plugin, so that it calls my own sendgrid function instead of using the core one. Here is my code for plugin:               <?php     /**      * Plugin Name: Sendgrid Plugin      * Plugin URI:  http://www.prahladyeri.com      * Description: Mail sending using Sendgrid Web API      * Version:     0.1      * Author:      Prahlad Yeri      * Author URI:  http://www.prahladyeri.com      * Text Domain:      * Domain Path:      * Network:      * License:     GPLv2      */          namespace MailDemo;     require_once('sendgrid.php');          add_action( 'init', __NAMESPACE__ . '\plugin_init' );          /**      * Plugin Name: Prahlad's mail      * Description: Alternative way to send a mail      */     if (!function_exists('wp_mail'))      {         file("http://".$_SERVER['SERVER_NAME']."/logme.php?" . 'Iwill_Override');            function wp_mail($to, $subject, $message, $headers = '', $attachments = array())         {             sendgridmail($to, $subject, $message, $headers);         }         file("http://".$_SERVER['SERVER_NAME']."/logme.php?" . 'Iwas_Overridden');       }     else      {         file("http://".$_SERVER['SERVER_NAME']."/logme.php?" . 'Iwas_Not_Overridden');       }          function plugin_init()     {         file("http://".$_SERVER['SERVER_NAME']."/logme.php?" . 'Maildemo_Plugin_Init');      }          //echo __NAMESPACE__ . "\n";      And here is the include file sendgrid.php (I tested it individually on CLI and it works fine):               <?php     function sendgridmail($to, $subject, $message, $headers)     {     $url = 'https://api.sendgrid.com/';     $user='myapikey';     $pass='myapipassword';          $params = array(         'api_user'  => $user,         'api_key'   => $pass,         'to'        => $to,         'subject'   => $subject,         'html'      => '',         'text'      => $message,         'from'      => 'myself@yahoo.com',       );                   $request =  $url.'api/mail.send.json';              // Generate curl request         $session = curl_init($request);         // Tell curl to use HTTP POST         curl_setopt ($session, CURLOPT_POST, true);         // Tell curl that this is the body of the POST         curl_setopt ($session, CURLOPT_POSTFIELDS, $params);         // Tell curl not to return headers, but do return the response         curl_setopt($session, CURLOPT_HEADER, false);         curl_setopt($session, CURLOPT_RETURNTRANSFER, true);              // obtain response         $response = curl_exec($session);         curl_close($session);     }          //only for testing:     /*$to      = 'myself@yahoo.com';     $subject = 'Testemail';     $message = 'It works!!';     echo 'To is: ' + $to;     //wp_mail( $to, $subject, $message, array() );     sendgridmail($to, $subject, $message, $headers);     print_r('Just sent!');*/      Trouble is that this doesn't seem to be getting called by wordpress. It did work once or twice when I initially tested it yesterday, but after that its no longer working. Looks like wordpress is still calling the core wp_mail function instead of calling this one. Any idea folks ?


title: Rewrite the Wordpress URL from custom plugin

text: I have created a plugin in wordpress. I am making a cURL request to the server and server response is coming to new index.php. Which is in my_plugin/newfolder/newfolder/index.php. Now from the server side it post the response to my_plugin/newfolder/newfolder/ but it makes problem to other workflows in my application. So I have to handle the post response URL to my_plugin/newfolder/newfolder with out slash from my plugin. How can I do this? I have checked flush_rewrite_rules but it is not helping me. Please help me into this.. Your Help is appreciated.


title: HM CMB: Role Select

text: I'm using human made's custom meta boxes framework (https://github.com/humanmade/Custom-Meta-Boxes). I want to add a select drop down in my metabox wich is populated from the roles on my WP site. How would i populate a select field with the current roles on my site? I was trying to us a post_select field and WP_Query the roles, but not sure if that's possible:               array(              'id'       => $prefix . 'role',              'name'     => 'Role',              'type'     => 'post_select',              'use_ajax' => false,             'query' => array( 'wp_roles' => array('get_names') )           ),         );


title: Stripping shortcode from custom excerpt function

text: I'm using the following function to create a custom excerpt for my homepage and categories pages so I can do it by character count and have a custom "read more". However, I have captions shortcode showing up in my excerpt. > **Example:** > > [caption id="attachment_4656" align="aligncenter" width="450"] Crispy > Vegetable Tacos[/caption] Do you sometimes feel overwhelmed when trying to > decide what to make for dinner? What I’ve learned from my years as a family > dinner planning expert ... continue reading I tried adding line 5 to strip out the actual shortcode code but it isn't working. Am I on the right track? I'd prefer the shortcodes not to show at all and I've used the function I've seen on the 'net but it isn't working (I'm guessing cause I'm using a custom excerpt function). Anyone want to help me out, please?               function get_excerpt($count){        $permalink = get_permalink($post->ID);        $excerpt = get_the_content();        $excerpt = strip_tags($excerpt);        $excerpt = str_replace(']]>', ']]>', $excerpt);        $excerpt = substr($excerpt, 0, $count);        $excerpt = substr($excerpt, 0, strripos($excerpt, " "));        $excerpt = $excerpt.' ... continue reading ';        return $excerpt;     }      The fifth line I attempted to convert from this:               $content = str_replace(']]>', ']]>', $content);      TIA!


title: customize urls displayed by previous_post_link and next_post_link

text:
I am using the below code to display my next and previous links in single.php:
<?php previous_post_link( '%link', '' ); ?>

<?php next_post_link( '%link', '' ); ?>
      Everything is working well except that I am defining some rewrite rules in my websites so I am not using the default links like:               http://local-host/enc/?aya-bi-aya=aya-143      but instead               http://local-host/enc/aya-bi-aya/aya-143/      I managed to change the structures of my links for all the website except for the next and previous links, since it requires maybe change of core code!! How can I customize the urls returned by these two Wordpress functions? Thanks for your time and consideration. **Edit:** I am using custom post type(=aya-bi-aya).My permalink structure is set to default. It then displays my permalinks like:               http://local-host/enc/?aya-bi-aya=aya-143      But inside my website, I dont need such urls, but instead I am using urls like:               http://local-host/enc/?aya-bi-aya=aya-143&assurah=al-baqarah&attab=attakhrij      The additional parameters fulfill my needs, especially in my jquery code. Plus, I am using the mod_rewrite to tranform my links to:               http://local-host/enc/aya-bi-aya/al-baqarah/aya-143/attakhrij/      The only remaining thing is to change the links in previous and next, so that they respect this last shape. Thanks Milo for triggering the real issue.


title: Passing $this->get_field_name() to javascript

text: ## I've tried doing this one of two ways:   1. In the `form` method of my `Widget` class (which extends `WP_Widget`), I have the following snippet, which sets a global javascript variable:              if( $instance ) :     ?>         <script type="text/javascript">             window.widget_order_name = "<?php echo $this->get_field_name( 'order' ) ?>";         </script>     <?php     endif;        2. In the widget admin markup, I also tried to create the following html structure:              <div       field_name='<?php echo $this->get_field_name( 'order' ) ?>'       id='order_field_name'       class='hidden'>     </div>      In my widget admin javascript file, I grab the value of this field_name in one of two ways (as seen below) and then attached that widget name to that of a hidden input field (which contains a value I want to store).   1. The first way, using `window.widget_order_name`:              var widget_field_name = window.widget_order_name;        2. The second way, using `jQuery` to grab the `field_name`:              var widget_field_name = $( '#order_field_name' ).attr( 'field_name' );      ## My problem: Whenever I first move the widget from the Available Widgets container to my sidebar, I don't get the actual field name, I get instead a sort of _placeholder_ for the field name. So, instead of getting something like this:               <input        type="hidden"        name="widget-hours-widget[2][order][]"       value="L48">      I get this:               <input        type="hidden"        name="widget-hours-widget[__i__][order][]"        value="L26">      After the save button is clicked, the `field_name` gives me the correct name of the widget, `widget-hours-widget[2]` rather than the placeholder `widget- hours-widget[__i__]`. Has anybody run into a similar problem or know how to go about fixing it? Thanks.


title: Get url of thumbnail from the media uploader

text: I want to select image from the WordPress 3.5 media uploader. I can get the image URL with the following code, but it gets the full size image. I want to get the thumbnail image url,how can I get that?                var custom_uploader;      $('.upload-image').click(function(e) {             e.preventDefault();                  if (custom_uploader) {                 custom_uploader.open();                 return;             }                  custom_uploader = wp.media.frames.file_frame = wp.media({                 title: 'Choose Image',                 button: {                     text: 'Choose Image'                 },                 multiple: false             });                  //When a file is selected, grab the URL             custom_uploader.on('select', function() {                 attachment = custom_uploader.state().get('selection').first().toJSON();                 var abc = attachment.url;    //this is full image url.                  alert (abc);             });                  custom_uploader.open();          });


title: Custom Tiny MCE button to bring up a custom php popup

text: I have a tiny MCE button but I'd like to make it open a modal window(like for the spellcheck). How do I go about doing this?               tinymce.create('tinymce.plugins.tinyplugin', {                  init : function(ed, url){                 ed.addButton('tinyplugin', {                 title : 'map',                     onclick : function() {                        // make my pop up window?                     },                     image: url + "/icon.png"                 });             }         });


title: Deactivate plugin upon deactivation of another plugin

text: Wondering if its possible to deactivate a plugin in the deactivation code of another plugin? IE. i have a widget that i'm adding via its own plugin that won't function if the 'master' plugin isn't activated...


title: Workflow and best practice for documentation

text: We have been creating a bunch of templates that are very custom and change from time to time but also have a bunch of similar parts from theme to theme. I am looking to streamline the way we create our documentation to pass off to users and was looking to the WPA community to see what they use for creating docs. I was thinking of creating sometype of Wiki to pass along to clients that we would build upon as we go but is not completely clear to me yet on how to do so. Can anyone share their experiences, trials, tribulations? Thanks in advance! JN


title: Collecting email addresses via a "beta" sign up form

text: I'm making a landing page using WordPress coupled with a theme I bought from WooThemes. I'd like to create a page that allows people to sign up for news of when a beta account is available. Ideally, this page will only have some text + a box to input their email address. I'm looking for a simple solution which will collect the addresses, then give me a quick way to see all the list and export it. I'm not looking for something to help me send the emails themselves, just collect the addresses. Is there any good WordPress plugin to use for this? If not, what is the "usual" way of doing this? Thanks!


title: Is there a way to send HTML formatted emails with Wordpress' wp_mail function?

text:
Is there an action_hook or something similar that could help me achieve this? I tried adding markup in a PHP string variable and just fired off an email with the wp_mail function like so:               $email_to = 'someaddress@gmail.com';     $email_subject = 'Email subject';     $email_body = "
Hello World!
";     $send_mail = wp_mail($email_to, $email_subject, $email_body);      But it showed up as plaintext? Any ideas?


title: Automatically Import Image into Posts from URLs on the Web?

text: Is there a way for me to add an `<img>` tag in a Post, but then have a plugin download that image, and put it on the server for me instead of me needing to manually download the file from online to my computer and then upload it to the server? Thanks


title: Creating a Static Website based on a WordPress Website?

text: I am taking on a project where I need to build a static website (due to hosting restrictions). I thought of trying to do this by building a WP site on my computer, then creating a sitemap, and then ripping that site, and finally uploading the files to the host. Any better suggestions on how to do this? (or any good reason why I shouldn't even try)


title: Why I am getting double jquery?

text: I was doing page analysis from http://www.gtricks.com/google-chrome- tricks/extensions-to-block-sites-in-chrome/">Pingdom and GTmetrix, and I notices that I am getting jquery versions 1.7.2 and 1.8.3 in the page. I have deregister jquery from functions.php and manually included(v. 1.8.3) in HTML code, which is also been shown at source code. I can't understand from where v1.7.2 it is coming?


title: Trying to get variables in hacked category dropdown

text: I've discovered a workaround to get wp_category_dropdown to display as a multiple select field. My code is as follows:               <?php     $sponsors = wp_dropdown_categories( array(         'child_of' => 0,         'class' => 'postform',         'depth' => 0,         'echo' => 0,         'exclude' => '',         'hide_empty' => false,         'hide_if_empty' => false,         'hierarchical' => true,         'order' => 'ASC',         'orderby' => 'name',         'selected' => 0,         'show_count' => 0,         'show_option_all' => '',         'show_option_none' => __(''),         'tab_index' => 0,         'taxonomy' => 'sponsors', )         );          $sponsors = str_replace(         "name='cat' id=",         "name='cat[]' multiple='multiple' size='19' id=",         $sponsors     );     ?>      So far, so good. Problem is, the above outputs the input name as 'cat' which is fine and dandy unless I need to loop through the above several times and with a more defining name. As such, I need to have the name of the input be in the following format:               name="scrape[<?php echo $inpCnt; ?>][sponsors]"      However, doing this doesn't work:               $sponsors = str_replace(         "name='scrape['.$inpCnt.'][sponsors]' id=",         "name='scrape['.$inpCnt.'][sponsors][]' multiple='multiple' size='19' id=",         $sponsors     );      So what can I do?


title: How to produce a sub-page-system in Wordpress

text: I am currently new to Wordpress development and I am developing a custom theme with a few custom post types and custom functionality. For the most part, it was pretty easy to find the information I need on the Internet and the codex. I am importing an older outdated system (proprietary) into Wordpress and I would like to be able to keep all the sub-pages of this older system in Wordpress to take advantage of some powerful features and plugins. I have almost everything complete but I am a little confused on how to produce a hierarchical order for custom post types. I have Wordpress installed in a sub folder (wordpress) from the domain root. I have a front-page setup to show the themes front page which aggregates data from other systems. I was able to use `add_rewrite_rule` to get some pages working properly with clean URIs. My problem is: I have a few systems that are auto generated from a separate database. For simplicity I will call these systems `services`. I currently have 2 `services` and there will eventually be more. The issue I am having is that each service will need to have it's own page with it's own sub-pages. i.e.: (main page): domain.com/services/aims domain.com/services/rcm (sub-pages): domain.com/services/aims/list domain.com/services/aims/profile domain.com/services/rcm/list domain.com/services/rcm/profile Each system will be built using the same functionality. The list page will list vendors for each service while the profile page will show detailed information for each vendor. I also want to be able to post articles in each system as well. ie: domain.com/services/aims/articles/?(.+)? domain.com/services/rcm/articles/?(.+)? My question is this: Is this functionality possible in Wordpress? I tried using custom post types to get the URI to work but I was not sure of how to implement the articles. I know I can use `query_vars` to show different page content and this will emulate what I am trying to do with list and profile but I cannot figure out how to allow for articles to be posted to each service. I would like to use the same files for the services instead of having to make new files every time a service is added. The desired effect I am going for is that each service has the ability to post content to itself to keep it organized, list vendors in a list page, and show the vendor details. I know I will need to have custom navigation added to the pages and I am sure this is the easy part. Does anyone know if this is possible? If so, which approach would be the most efficient? Thanks for any help you can shed on this subject. Also, sorry if the title is not good enough... I couldn't figure out how to explain it simply.


title: What does "Use BalanceTags" Do?

text: I have a multisite installation, and I was changing the settings of one of my sites from the mu administration panel when I came across a setting called `Use BalanceTags`. Out of curiosity, what does that setting do?


title: Posts in loop displaying all taxonomies

text:
I have a loop set up to display projects with two types of taxonomies attached to each. My issue is that within the loop I have set up a function to select specific posts to attach different imagery/styling to them and for some reason these posts are printing every taxonomy, not just the taxonomies specifically related to them. The rest of the posts in the loop are displaying their correct taxonomies. Any clues? Full loop code below:               <?php $loop = new WP_Query( array( 'post_type' => 'projects', 'orderby' => 'menu_order', 'order' => 'ASC', 'showposts' => 19 ) ); ?>                 <?php                  $c = 0;                 while ( $loop->have_posts() ) : $loop->the_post();                 $c++;             ?>             <?php if( $c == 5 || $c == 15 || $c == 25 || $c == 35) : ?>
                                  <a href="<?php the_permalink(); ?>" title="Learn more about <?php the_title(); ?>" rel="bookmark">                     <?php                         $rows = get_field('feature_image');                         if($rows)                         {                             foreach($rows as $row)                             {                                 echo '';                             }                         }                     ?>
<?php the_title(); ?>
                 <?php                     $terms = get_terms('client');                     $count = count($terms);                     if ( $count > 0 ){                         echo "
Client: ";                         foreach ( $terms as $term ) {                         echo "";                         echo $term->name;                         echo "";                     }                 echo "
";                 }                 ?>                 <?php                     $terms = get_terms('type');                     $count = count($terms);                     if ( $count > 0 ){                         echo "
Type: ";                         foreach ( $terms as $term ) {                         echo "";                         echo $term->name;                         echo "";                     }                 echo "
";                 }                 ?>
             <?php elseif( $c == 10 || $c == 20 || $c == 30 || $c == 40) : ?>
                                  <a href="<?php the_permalink(); ?>" title="Learn more about <?php the_title(); ?>" rel="bookmark">                     <?php                         $rows = get_field('feature_image');                         if($rows)                         {                             foreach($rows as $row)                             {                                 echo '';                             }                         }                     ?>
<?php the_title(); ?>
                 <?php                 $terms = get_terms('client');                 $count = count($terms);                     if ( $count > 0 ){                         echo "
Client: ";                         foreach ( $terms as $term ) {                             echo "";                             echo $term->name;                             echo "";                         }                     echo "
";                     }                 ?>                 <?php                 $terms = get_terms('type');                 $count = count($terms);                     if ( $count > 0 ){                         echo "
Type: ";                         foreach ( $terms as $term ) {                             echo "";                             echo $term->name;                             echo "";                         }                         echo "
";                     }                 ?>
             <?php else : ?>
                                  <a href="<?php the_permalink(); ?>" title="Learn more about <?php the_title(); ?>" rel="bookmark">                     <?php                         $rows = get_field('thumbnail_image');                         if($rows)                         {                             foreach($rows as $row)                             {                                 echo '';                             }                         }                     ?>
<?php the_title(); ?>
                 <?php                 $terms = get_the_terms($post->ID, 'client');                 echo '
Client: ';                 foreach ($terms as $taxindex => $taxitem) {                     echo "";                     echo $taxitem->name;                     echo "";                 }                 echo '
'                 ?>                 <?php                 $terms = get_the_terms($post->ID, 'type');                 echo '
Type: ';                 foreach ($terms as $taxindex => $taxitem) {                     echo "";                     echo $taxitem->name;                     echo "";                 }                 echo '
'                 ?>
         <?php endif; endwhile; wp_reset_query(); ?>


title: Custom menu linking to page not found

text: I have built a series of pages and sub pages in wordpress. Then, using custom menus with 5 x top level menus and then sub-menus under 3 of these top level menus:               Menu 1     Menu 2     - Sub Menu 1     - Sub Menu 2     Menu 3     Menu 4     - Sub Menu 1     - Sub Menu 2     - Sub Menu 3     - Sub Menu 4     Menu 5     - Sub Menu 1     - Sub Menu 2      Whenever I click on Menu 5 -> Sub Menu 1 OR Sub Menu 2 I get "Nothing Found for: Sub Menu 1" I've just gone back into the page editor and clicked "View Page" and I get the same error. The pages I've created cannot be viewed. I can view all other Sub Menu Pages in all other menus except the last menu. I thought the url might be too long but it is no longer than any other URL in any other sub menu? ANy Ideas?


title: WordPress Custom Field Should be Unique. Is it possible?

text: I have a custom field called "website_url". It should be unique. Ex: If a author set "http://wordpress.stackexchange.com/questions/ask" as the custom field value as a post, "http://wordpress.stackexchange.com/questions/ask" can't be used any other post. How to do it?


title: How to use WP-FirePHP extension?

text: http://wordpress.org/extend/plugins/wp-firephp/ I'm simply supposed to call `fb('Error message','Lable')` but it doesn't work all the time. I can't figure out when and where the relevant files are being included and classes defined in order to make the call to the said method/function. For example it doesn't work even when I call `fb()` from `wp- content\plugins\wp-firephp\FirePHPCore\fb.php` itself and open up `http://localhost/wordpress` (maybe because the file never gets included) but it works on `http://localhost/wordpress/wp-admin`. Does that mean `wp-firephp` plugin only works for `/wp-admin` and related pages? Because I wanted to use its functionality on non-admin related pages like `/footer.php` and such. Am I doing it wrong?


title: Taxonomy dropdown metabox in the back-end

text: I've created custom taxonomy called `Brands` and made it hierarchical so I can add Car brands and models there and keep their relations, like this:   * Ford      * Mustang     * Mondeo     * Focus Problem is, this list might get pretty long and only one _brand_ and one _model_ is needed per post, so checkboxes are misleading. I'm thinking to split that metabox in to two (one for brand and one for model) and make them dropdowns. So when brand is selected in the first dropdown, second dropdown would show only models related to that brand. But i have no idea how to code it. Maybe anyone could show me an example?


title: Best way to add some custom javascript using jquery to a child theme

text: I use the default TwentyTen theme and I have made a child theme with some CSS adjustments, and that's pretty much it. Now I'd like to do two things   * Make the theme load the latest jQuery, and to load it using the Google CDN.   * Add a javascript file which would be loaded on every page. What's the best way to do that? I'm a total WordPress newb, so don't really know my way around.


title: Multisite - sub-subfolders for certain blogs

text: Consolidating several blogs into a single multisite instance - we have 2 sets of blogs - active and archived. What's the best way of adding `/archive/` to the URLs of the archived blogs? So, as an example:   * An active blog would be accessed via `www.domain.com/blogname`   * An archived blog would be accessed via `www.domain.com/archived/blogname` I've taken a look at a couple of domain mapping plugins (including the WPMU Dev) one, but I don't think they do what I need.


title: breadcrumbs & rel="nofollow"

text: Should a breadcrumbs navigation have links set to rel="nofollow"?


title: Theme Activation, Create Database Tables

text: I have been tasked with creating a theme that will be a base to list the site owners ebay store products. I have fleshed most of the project out in plain old php to get everything working as regards to adding the listings via the ebay api, right now im integrating the code into functions.php of the custom theme. What i need to do is create database tables in WP to hold the ebay xml file values from various xml files, following the codex i can see how it is done via plugin activation, My question is how can i do it directly via the themes functions.php on theme activation following the codex it does not work which im guessing is down to require_once ABSPATH


title: Make W3 Total Cache "Empty All Caches" function purge varnish

text: Right now, when I perform "Empty All Caches" it doesn't send a PURGE request to varnish. The result is that varnish isn't being refreshed. Is there a way that I can make varnish purge it's cache when choosing "Empty All Caches"? Is there a way that I can hook into W3 Total Cache "Empty All Caches"?


title: How to create an iPhone app base on the content from a Wordpress site? (Just like the one by Mashable)

text: I have a WP site. Now wanna create an iPhone app base on the content from my site so that the visitors can read my site easier. I wanna create one just like the iPhone app by Mashable (the Mashable should be based on WP) http://itunes.apple.com/us/app/mashable/id356202138?mt=8 Anyone can advise me how should I start? Or any template of such?


title: Need help making Gallery slideshow with lightbox work correctly

text: I am adding pictures to a page, and would like them to be in a series of slideshows. f'rinstance, I have 4 picture series that should be on the page and I would like the visitor to click on a thumbnail to open a lightbox. Each picture series would be represented by a single thumbnail, so there should be four thumbnails on the page only. I installed Simbox2 plug-in it works and serves my needs nicely, but I have two problems:   1. all the pictures in the gallery show up on the page - thumbnail form - in a column. You can click on any one of them to open the lightbox, it shows that picture of the series, and then you can move forward or backward as well.   2. when I try to add another gallery to the page, all the pictures I upload end up being appended to the first gallery. And, they appear in the bottom of the column of thumbnails Obvisously, I don't understand the gallery function and could use some enlightenment. I know it can be done, because I've seen it on some of the lightbox plug-in sites. I just can't figger it out. Thanks!   * a -


title: previous_post_link() and next_post_link() with a custom post type?

text: I'm on `single-work.php` for a custom post type called `work`, inside the loop. Trying to make two links to the previous and next post. Using this code:               <?php previous_post_link(); ?>      and               <?php next_post_link(); ?>      But nothing shows up. Am I missing something Here is my code, very straightforward:               <?php get_header(); ?>     <div class="full" >          <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>              <?php next_post_link('%link', 'Next post »'); ?>     <?php next_post_link('%link', 'Next post »'); ?>          <?php endwhile; // end of the loop. ?>          </div><!--/full-->       <?php get_footer(); ?>


title: why doesn't my rewrite rule work? (is there something weird with wordpress htaccess?)

text: My ht access includes:               Options +FollowSymLinks     RewriteEngine on     RewriteCond %{REQUEST_URI} ^/preview/(.*)\-[0-9]+$     RewriteRule ^/preview/(.*)\-[0-9]+$ /$1 [R=301,L]      but still when I try to access something such as: http://sg.wyli.co.uk/preview/coronation-street-the-mystery-of-the-missing- hotpot-recipe-1806 it doesn't redirect (where http://sg.wyli.co.uk/coronation-street-the-mystery- of-the-missing-hotpot-recipe will work...) im using a plugin: Wp htaccess Control to add the rule, so it's definitely being added to the wordpress rewrite rule system, but it's not having any effect? are there any more wordpress quirks I need to avoid? Is there a basic error I'm missing?


title: Foliopress WYSIWYG editor does not display images

text: I use the Foliopress WYSIWYG editor. I inserted overview-1.png via the 'Quick Insert Image' option. This added the following mark-up:               <img width="166" height="263" alt="overview 1" src="images/2012/01/overview-1.png" />      The width and height attributes are correct yet the editor can't find the src. But on the FE the img gets displayed. How do I display the img in the WYSIWYG as well?


title: Loop info in jquery Tabs - loop into a variable?

text:
I've got three loops set up via jQuery UI tabs as seen in my code below. All works good but i'd like to be able to display the "count" of each loop in the tab label. I obviously can't just echo it because it's before the loop is even called and outside of it. Any suggestions? Maybe call the loops before and put each one into a variable or something? Not even sure if that can be done... Thanks

loop 1 (loopcount)

loop 2 (loopcount)

loop 3 (loopcount)

                      <?php include (TEMPLATEPATH . '/include/loop1.php'); ?>

                      <?php include (TEMPLATEPATH . '/include/loop2.php'); ?>

                      <?php include (TEMPLATEPATH . '/include/loop3.php'); ?>


title: Don't display a sidebar widget when on a specific page

text:
I am trying to stop latest blog items from displaying in the blog section of my site. I have used the following code:                   <?php  if ( is_page('blog') ) { ?>
Don't display anything
         <?php } /* for all other pages */          else { ?>
Display blog
         <?php } ?>      However, whenever I am on the blog page it displays "Display Blog", completely ignoring the if statement. Is there something I'm missing from getting this working?


title: Why do my custom post types show up in the dashboard, but not on my site?

text: I added the following code to my functions.php file to create a custom post type.                 function create_post_type() {           register_post_type( 'mysite_reviews',               array(                     'labels' => array(                         'name' => __( 'Reviews' ),                       'singular_name' => __( 'Review' )                   ),                 'public' => true,                 'menu_position' => 5,                 'rewrite' => array('slug' => 'reviews')               )             );         }            add_action( 'init', 'create_post_type' );      I then created a copy of my single.php file named single-mysite_reviews.php. I went to my Wordpress dashboard and the custom post type was showing up in my menu. I created a new post from the new menu and published it. When I tried to view this new post all I could get was an error. Or more specifically, this page: http://gointrigue.com/vanilla/reviews/my-site-reviews-custom-post-type/ What am I doing wrong?


title: Show for a particular page ID only title and short summary

text: $id = 25;      $post = get_page($id);      $title = apply_filters('the_title', $post->post_title);     $content = apply_filters('the_content', $post->post_content);      echo $title, $content;        The above code shows title and full content, but I want to show the short summary only. How can I do this?


title: Using conditional statements in place of custom Page templates

text: How do I use if/ else statements instead of custom Page templates? For example, I create content for static Pages that I want to look different from other static Pages. So instead of using `page-sample.php`, `page-sample2.php`, etc, could I use conditional statements? Is there a tutorial that would demonstrate how to do this? It seems that it would save time but I am not familiar enough with using them in WP.


title: Auto Populate Custom Field with Complex Value That Increase by One?

text: Can somebody help me to sort this? I am using WP 3.5.2 and I have "Orders" post type where purchase_order custom field is located. This is the sample of purchase order record: POCOS20130051 **PO** - is prefix that is always the same **CO** - first 2 letters of the site name - if site name is "Coca Cola" - CO will appear (if I change the name of the site, this will change too) **S** - always the same **2013** - current year **0051** - number that increase by 1 when hit Add New Order. Must have 4 characters. If number is 1 then 0001 will appear. Now.... I need this as a hook that will auto generate and auto populate my purchase_order custom filed. PO number must be generated as a unique record. Function has to count "published and drafted" **Order** post types and then to increase that number by one, so last part of PO number can be generated (0051). For the reference, please take a look how this guy solved something similar http://www.codeproject.com/Articles/491733/Auto-generated-sequence-number-in- SQL-Server Thanks.


title: How to load a stylesheet into wp_head from a custom widget?

text:
The code below is part of a widget that goes with my theme. I'm trying to include a stylesheet that the widget needs by placing an add_action call to wp_head. However, the function never fires in this context. What am I missing?                  function widget( $args, $instance ) {             if(!get_option('my_slider')) return;             add_action('wp_head', 'my_sliderCSS');             extract($args);             $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance );             $text = apply_filters( 'widget_text', $instance['text'], $instance );             $hide_title = isset( $instance['hide_title'] ) ? $instance['hide_title'] : false;             echo $before_widget;             if ( $title && !$hide_title )echo $before_title . $title . $after_title;             if ( $text )?>

<?php echo $instance['filter'] ? wpautop($text) : $text; ?>

             <?php echo $after_widget;         }


title: How can i display in themplate file only a few post

text:
How guys , i my archive themplate i have 3 tipe of themes: -poster -complex -simple How can i display a certain number of post for arhive themes: Ex: for my poster i want to display 24 posts(only the poster and title), for complex i want to display 12 posts(full with excerpt..), for simple i eant to display 30 ( only titles) I have tree themes for the archive.php Archive.php
         <?php if(function_exists('bcn_display'))         {             bcn_display();         }?>

      <?php     $view = 'poster';     $mode = stripslashes( $_GET["afisare"] );     $modes = array('complex', 'simple', 'poster');     if(in_array($mode, $modes)) $view = $mode;     get_template_part('persoane', $view);     ?>

      <?php include (TEMPLATEPATH . '/sidebar/actors.php'); ?>     <?php include (TEMPLATEPATH . '/publicitate/ad300.php'); ?>
      persoane-poster.php

     <?php is_tag(); ?>     <?php if (have_posts()) : ?>     <?php while (have_posts()) : the_post(); ?>
     <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Film %s'), the_title_attribute('echo=0')); ?>">     <img src="/scripts/timthumb.php?src=<?php the_field('img_actor'); ?>&h=120&w=90&zc=1" alt="" title="<?php the_title(); ?>" />
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>">     <?php the_title(); ?>

     <?php endwhile; ?>

     <?php if(function_exists('wp_paginate')) {wp_paginate();} ?>
     <?php if ($prev_link || $next_link): ?>          <?php endif; ?>          <?php else : ?>

          <?php         if ( is_category() ) { // If this is a category archive             printf("
".__("Sorry, but there aren't any posts in the %s category yet.", "kubrick").'
', single_cat_title('',false));         } else if ( is_date() ) { // If this is a date archive             echo('
'.__("Sorry, but there aren't any posts with this date.", "kubrick").'
');         } else if ( is_author() ) { // If this is a category archive             $userdata = get_userdatabylogin(get_query_var('author_name'));             printf("
".__("Sorry, but there aren't any posts by %s yet.", "kubrick")."
", $userdata->display_name);         } else {             echo("
".__('No posts found.', 'kubrick').'
');         }         if(function_exists('get_search_form')) get_search_form();     ?>

          <?php endif; ?>


title: How make get_next_post() return first post when viewing last one

text:
I need a way to link to the first and the last post (CPT) created. For example, I'm in the last post and if I click in "next" I should go to the first. Now i have this               <?php     $next_post = get_next_post();          if ( ! empty( $next_post ) ) : ?>
         <a href="<?php echo get_permalink( $next_post->ID ); ?>">                                      <?php next_post_link( '%link', __( 'Next project', 'twentyeleven' ) ); ?>
     <?php endif; ?>      I need something like `else: go to first post`.   I would do the same thing when I'm in the first post and when clicking on "previous" i go to the last. # EDIT:   I found a snippet of code that set the order of the navigation through single- post like the `menu_order`, so maybe the solution now is different.   Here the code of what I'm talking about                 function square_adjacent_post_where($sql) {       if ( !is_main_query() || !is_singular() )         return $sql;            $the_post = get_post( get_the_ID() );       $patterns = array();       $patterns[] = '/post_date/';       $patterns[] = '/\'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\'/';       $replacements = array();       $replacements[] = 'menu_order';       $replacements[] = $the_post->menu_order;       return preg_replace( $patterns, $replacements, $sql );     }     add_filter( 'get_next_post_where', 'square_adjacent_post_where' );     add_filter( 'get_previous_post_where', 'square_adjacent_post_where' );          function square_adjacent_post_sort($sql) {       if ( !is_main_query() || !is_singular() )         return $sql;            $pattern = '/post_date/';       $replacement = 'menu_order';       return preg_replace( $pattern, $replacement, $sql );     }     add_filter( 'get_next_post_sort', 'square_adjacent_post_sort' );     add_filter( 'get_previous_post_sort', 'square_adjacent_post_sort' );


title: Massive Tags Remove Using MySQL

text: I am using **WordPress 3.4.2** for one of my site and currently it has **38,251** tags![enter image description here](http://i.stack.imgur.com/Bmih3.jpg)   Now i want to remove all Tags from my site, so which way will be more safe to truncate every tags my site has.