title: Can't Set Featured Image

text: I have installed the MarketPress plugin from WPMU. I have an ongoing issue with featured images. When I try to set the featured image (in any post) it continually hangs on saving. My problem is that I can't set the product image. In Chrome, when I use the `ctrl` \+ `shift` \+ `J` to bring up the console and then try to set the image, I get a 404 not found for this specific snippet in `admin-ajax.php`:               POST http://www.salonoasis.biz/wp-admin/admin-ajax.php 404 (Not Found) jquery.min.js:4     send jquery.min.js:4     f.extend.ajax jquery.min.js:4     f.(anonymous function) jquery.min.js:4     WPSetAsThumbnail set-post-thumbnail.js:1     onclick      The rest of the script runs fine. I have increased the memory limit to 128M and my server provider (I am a reseller) has white listed the domain in mod_security. I have cleared my browser cache. I still have the problem!


title: How would I put the multi image upload plugin only on one particular page or template

text: The 'page' part sets the image upload to show on all pages. I want it to only show on one specific page or selected template.               public function __construct()         {             $this->post_types = array('page');     //limit meta box to certain post types             add_action('add_meta_boxes', array($this, 'add_meta_box'));             add_action('save_post', array($this, 'save'));             add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));         }


title: force login loophole

text: I want to restrict access to my wordpress site to allow registered users only. I have tried the following plugins:   * Require-login   * Authenticator   * WP-lock All of them have the same problem: After seeing the login page, you can easily retype the URL in the browser address bar to bypass the login screen and access the home page directly, without needing to login. Only the home page can be accessed in this way. Clicking on any menus, will take you back to the login screen. I suspect there is a problem with my site, not the plugins. I have the following active plugins:   * Advanced Custom Fields   * Akismet   * Analytics360   * Custom Post Templates   * Custom Post Type UI   * Disqus Comment System   * Duplicator   * Easy Tweet Embed   * Email This Page   * Google Analytics   * Gravity Forms   * HotSpots   * List category posts   * Mini twitter feed   * Peter's Login Redirect   * Select Q&A - WordPress Questions and Answers Plugin    * Raw HTML   * Relevanssi   * Revision Control   * Swiftype Search   * ThreeWP Activity Monitor   * Usernoise Pro   * W3 Total Cache   * WP-Lock   * WPML Multilingual CMS Any help would be much appreciated, thanks.


title: How can I replace content on site generated from plugin without changing plugin

text: I downloaded a login form but I'd like to change its content without actually changing the plugin files so that it won't cause problems when updating later on. How can this be done?


title: Get User Login Data (date, time... )

text: I did my best looking for information about this subject. Your guidance is appreciated. My goal is to perform some actions based on the number of user logins on my website per month and login days consecutivity. How can I get a specific user Login Data (date, time... ) using wordpress functions? If not what are the tables and fields to adress using SQL queries to get such infromation from database? Or I should maybe create and manage my own user meta data using hooks on `wp_login` action? Thank you very much.


title: Automatically email daily archive

text: Is it possible to automatically email the daily archive.php page as an html email newsletter? For example, at 4am every weekday WordPress would send an email of the 2011/04/25/ page. Any input is greatly appreciated!


title: How to remove set_post_thumbnail_size() in child themes?

text:
I'm really stuck on this - this follows on from this post: How to override parent functions in child themes I can't figure out how to override Twenty Ten's set_post_thumbnail_size() function. I've put my code below for the other overrides I'm doing, but nothing happens when I add this to my function twentyten_child_theme_setup():               set_post_thumbnail_size( array(100,100) , array("class" => "alignleft post_thumbnail"), true );      I'm inserting the thumbnail in my loop like this:               <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) {     the_post_thumbnail(array(100,100), array("class" => "alignleft post_thumbnail"));     } else { ?>     <img src="<?php echo bloginfo('stylesheet_directory'); ?>/images/thumb-default.jpg" alt="thumb-default" width="100" height="100" />     <?php } ?>      Here's my function below - can anyone help me override this pesky function? Thanks, osu               function twentyten_child_theme_setup() {              // OVERRIDE SIDEBAR GENERATION!         function osu_twentyten_widgets_init() {             // Siedbar 1, located on LHS sidebar             register_sidebar( array(                 'name' => __( 'Primary Widget Area', 'twentyten-child' ),                 'id' => 'primary-widget-area',                 'description' => __( 'The primary widget area where the navigation goes', 'twentyten-child' ),                 'before_widget' => '
',                 'after_widget' => '
',                 'before_title' => '
',                 'after_title' => '
',             ) );             // Area 2, located on RHS sidebar             register_sidebar( array(                 'name' => __( 'Secondary Widget Area', 'twentyten-child' ),                 'id' => 'secondary-widget-area',                 'description' => __( 'The secondary widget area', 'twentyten-child' ),                 'before_widget' => '
',                 'after_widget' => '
',                 'before_title' => '
',                 'after_title' => '
',             ) );         }         /* Deregister sidebar in parent */         remove_action( 'widgets_init', 'twentyten_widgets_init' );         /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */         add_action( 'widgets_init', 'osu_twentyten_widgets_init' );              // OVERRIDE EXCERPT READ MORE LINK         function osu_readon_link() {             return ' ' . __( 'Read More', 'twentyten-child' ) . '';         }         // Function to override         function osu_twentyten_custom_excerpt_more( $output ) {             if ( has_excerpt() && ! is_attachment() ) {                 $output .= osu_readon_link();             }             return $output;         }         remove_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );         add_filter( 'get_the_excerpt', 'osu_twentyten_custom_excerpt_more' );          }     /* IMPORTANT: Run the code for parent function overrides (involving hooks and filters) after theme setup! */     add_action( 'after_setup_theme', 'twentyten_child_theme_setup' );


title: Automatic image renaming based on title

text: Is there a plugin or a "hack" that can help me do this? I have spent hours try to figure this out so I would greatly appreciate nay help. I have WP 3.1 running php5 Thanks! eg.: **postitle_image-ID.jpg**


title: Category links including all posts

text:
Really rusty on the wordpress front. I am using custom permalinks `/%category%/%postname%/` as well as the `WP No Category Base` plugin, so my urls look like this: http://www.url.com/parent_category/child_category/ I only have an index.php set up at the moment, with the most basic loop possible:               <?php if (have_posts()) : ?>          <?php query_posts(); ?>     <?php while (have_posts()) : the_post(); ?>
        <?php the_title(); ?>
        <?php the_content(); ?>
          <?php endwhile; ?>         <?php else: ?>        <?php endif;?>        The problem is, all posts are coming through, instead of just the posts in the category represented by the url. I didn't think I needed a custom query, because the link that took me to the particular url should have been carried across. What am I missing?


title: Get permalink for a post from inside Wordpress and route to a related site

text: I built a mobile version of a wordpress site and added some PHP code in the wordpress index.php file to detect mobile users and HTTP-redirects them to m.website.com ( _which is not a wordpress installation. This PHP standalone mobile site scrapes the wp site for posts and displays them_ ). All works well, and every request to the full site goes to m.website.com instead. The only problem is that my team leader wants me to redirect website.com/2011/04/13/post-title to m.website.com/2011/04/13/post-title for mobile users. And to do this, **my redirection script only needs to know the permalink of the page that index.php is trying to route to**. The mobile site's index.php will handle the permalink once it receives it. N.B. Currently, if you visit m.website.com/2011/04/13/post-title it displays properly. I only need to know how to trap the permalink from inside wordpress and feed it to my mobile redirection code. **EDIT:** Thanks to Tom J Nowell's comment below, I am ready to move the redirection script to whatever file it is at which Wordpress figures out the permalink, and not index.php any longer. So that once the permalink is known, a redirection to `m.website.com/router.php?path=2011/04/13/post-title` can be done, which becomes `m.website.com/2011/04/13/post-title` via htaccess. Thanks


title: Category specific themes?

text: My client wants to implement a special appearance to each of our category pages. Kind of like child themes... she wants to shift the background image, change a few graphics, and tweak the colors according to which category the user is visiting (horror, romance, etc). Is there a reasonable way to do this besides creating a different template for each page with imported CSS styles? Or is that really the only path to accomplish this? **UPDATE:** The answers below are all great. For our purposes, the easiest thing to do was to use the category specific classes provided by "body_class()" to override current styles. Thanks!


title: How to relate one custom post type to another custom post type

text: I am coding an exam plugin with following flow:   1. Subject Categories (custom taxonomy)   2. Exams (custom post type) related to subject categories (custom taxonomy)   3. MCQ's (custom post type) related to exam (custom post type) On Adding New MCQ I need to relate it with exams but exams is a post type not taxonomy. How can it be managed?


title: How to save attachment data?

text: So I have this plugin which associates images from the media upload modal to taxonomy terms via `/wp-admin/edit-tags.php`. The current version is in the branch named "button". Basically, I've swapped out the "Insert in Post" button (input type="submit") with a custom "Add Thumbnail to Taxonomy" (span element) which calls an ajax script which creates an association between attachment and term. All of this works well. The part that I cannot figure out is how to save information when a user makes changes to the attachment data (title, caption, etc.). While it's not really necessary for the plugin to do this ... more than a handful of users have requested this. And it makes sense to do because WordPress will do this when inserting into post content using the "Insert in Post" button. I've been through the javascript and I don't believe that the request is being sent asynchronously. The only thing that comes to mind is that because the "Insert in Post" button is an actual submit button, WordPress is submitting the modal form in the background while it is closed for the user. I've tried to implement similar functionality in my plugin by changing the span to a submit input, but this does no good at all. Firebug reports a 404 for my custom Ajax request and the modal does not close. This is really odd to me because the image still gets associated with the term. Any help or suggestions would be greatly appreciated here!


title: Publish all network posts to the primary site

text: Any posts published on another network site should be visible on the MainDomain.com. Sitetags works fine, but does not update itself. Any idea how how to make an auto update on the primary site? Thanks Jean


title: Save Changes function after table is sorted using jquery

text: I have a simple table, and the jquery works great for sorting. The fields drags an drops perfectly, and updates then and their. Also of course the data in the fields are saved in a array. The data in the fields saves after clicking "save changes" button but NOT the sort order. The sort order returns to its previous state. example: 1(bb) 2(tom) 3(fred) TO 1(tom) 2(bb) 3(fred) then clicks "save changes" after clicking "save changes" it returns to its previous state which is 1(bb) 2(tom) 3(fred) the sort order does NOT save only the values. what other function i am suppose to add, to make this work? The jquery works, it does its job of sorting, but for WordPress to understand that it was sorted another way, what do I do?


title: site admin for subscribers

text: I want a very basic page for my subscribers to change their passwords and profile. No Wordpress news etc. Is is possible to strip the admin section of subscribers and leave the absolutely bare minimals? Thank you.


title: Exclude subscriber users from user list

text: I want to exclude Subscribers from a user list. My code is:               $users = $wpdb->get_results( "SELECT display_name FROM $wpdb->users ORDER BY display_name ASC" );      How can I change that so subscribers are excluded from the list? I also looked at the get_users function in codex but it did not have an exclude by role parameter. Edit: Or another way would be to get the results filtered by capability (one that subscribers doesn't have).


title: Add update notification bubble to admin menu item?

text:
I have re-worded this to make more sense. Ok, I have a plugin that uses a remote service that check for updates, much like default WordPress plugins, in this case it just checks an XML file. I want to show a menu bubble like this ![enter image description here](http://i.stack.imgur.com/rZZiu.png) when an update is available. It can show just a "1" or text like "alert", it doesn't matter. Since my plugin uses an options page (using `add_options_page`) the plugin settings show up under the default "Settings" submenu. I think I need to add the following CSS to get the bubble to show up,               1      and tie into the global `$submenu`. The problem is I cannot use a hard-coded array value for the menu since each site will have different values. So I cannot use `$submenu[80][10] .= <span class='update-plugins count-1' title='title'><span class='update-count'>1</span></span>` How can I find my plugins submenu value, do I have to loop through the array and match the string values? Also even when I hard-coded the values I could not get the bubble to show up.               //adding plugin to menu     add_action('admin_menu', 'sec_plugin_checker');          function sec_plugin_checker() {       add_options_page(' Plugin Checker', 'Plugin Check', 'activate_plugins',        'sec_plugin_check', 'sec_checker');               // the conditional where I want the bubble to appear          if (!empty($matches)){          echo "Match found !
";              global $submenu;         foreach( $submenu as $item ) {              $item[41][20] = sprintf( __( 'Updates %s', 'sec_plugin_checker' ),                       "                      1");                   }       }      and here is what a `var_dump($submenu);` looks like,               ["options-general.php"]=>     array(9){     ...          [41]=>         array(4) {           [0]=>           string(20) "Plugin Check"           [1]=>           string(16) "activate_plugins"           [2]=>           string(21) "sec_plugin_check"           [3]=>           string(23) " Plugin Checker"               ...                }


title: WordPress | WP_query with multiple category starting to show with a specific category

text:
How I can show a WP_query result posts starting to show a query by a specific taxonomy and than all the others? I have thought to a UNION in the query, but I would something with the WP_query loop. ex. category id 24                           global $query_string;                  $query_args = explode("&", $query_string); // collect all querystring var                 $search_query = array();                      foreach($query_args as $key => $string) {                         $query_split = explode("=", $string);                         $search_query[$query_split[0]] = urldecode($query_split[1]);                 } // foreach                      $search_query['cat']=urldecode('24'); // APPEND the category                 $query = new WP_Query($search_query);                      <?php if ( $query->have_posts() ) : ?>
<?php printf( __( 'Search Results for: %s', 'mb' ), '' . get_search_query() . '' ); ?>
                           <?php                           /* Run the loop for the search to output the results.                            * If you want to overload this in a child theme then include a file                            * called loop-search.php and that will be used instead.                            */                            //get_template_part( 'loop', 'search' );                            get_template_part( 'loop', 'catfirst' );                           ?>                         ...      thanks in advance, Gianluca


title: count number of all comments by a user on different (non-repeated) posts

text: I thank you in advance for your help. I am using Wordpress for about 2 years, but always avoiding SQL inside my scripts and looking for built-in functions to perform my goals. To count the comments submitted by a specific user with `$user->ID` as id, I didn't find a built-in way, so I am using:                global $wpdb;                  $count = $wpdb->get_var(               'SELECT COUNT( comment_id ) FROM '. $wpdb->comments .'               WHERE user_id = '.$user->ID.'               AND comment_approved = "1"               AND comment_type NOT IN ("pingback", "trackback" )'             );      Actually my goal is to count number of all comments by a user on different posts. In other words, if a user commented 2 or more times on the same post, then only increment the `$count` variable by one . Your help is appreciated.


title: Posts miss schedule, no notification (3.7.1)

text: I have a site running 3.7.1 where posts are sporadically failing to post on schedule. Unlike the "missed schedule" error that sometimes occurs, these misses don't generate any notification and the posts are not flagged in any way. In the posts that have failed to publish, reviewing the settings shows that WordPress shows that the posts are still set as "scheduled" despite having a date that is in the past. One thing that is unique to this site, compared to other WP sites that I've managed in the past: there are over two months (60+) of posts scheduled for the future at any given time. Other possible causes seem to be plugin related. I am running W3 Total Cache on the site. I have tweaked the settings extensively and disabled the plugin but I have still seen the error, so I am skeptical there. Has anyone else encountered an issue like this? p.s. I am currently testing the WP Missed Schedule Fix Failed Future Posts to see if that resolves the problem.


title: SQL select of users by metadata

text: Hi I'm trying to select users with a particular role only, using the following sql statement...               SELECT DISTINCT ID, u.user_login, u.user_nicename, u.user_email     FROM wp_users u, wp_usermeta m     WHERE m.meta_key = 'wp_capabilities'     AND m.meta_value LIKE '%supplier%'     ORDER BY u.user_registered      However, it reurns the whole table. What am I doing wrong? PS this needs to be a SQL select as I'm doing this in myphpadmin to export the data to csv. Thanks in advance!


title: copy attachment title to description and alt text

text: I have a blog with a lot (over 1000) images. Each image has a meaningful descriptive filename. Wordpress has title caption and description fields for images. What's the easiest way to batch process all images and copy the file name to the title alt description and caption fields. Also if I could update yoast seo fields too that would be great.


title: If has_term, load other theme

text: This is what I want to accomplish. I've created a taxonomy called `categorie` with the terms `app`, `web` and `branding`. When a project has the term app, I want to load another theme / blog. When a project has the term web or branding, I want to load `single.php`. The last one works just fine. This is my code so far               function load_single_template($template) {     $new_template = '';          if( is_single() ) {         global $post;              if( has_term('app', 'categorie', $post) ) {             $new_template = get_theme_roots('themeApp');         } else {             $new_template = locate_template(array('single.php' ));         }     }     return ('' != $new_template) ? $new_template : $template;      }      add_action('template_include', 'load_single_template');      So when a project has the term app, I want to load the theme `themeApp`. Any suggestions? Thanks in advance.


title: Submenu is missing when custom taxonomy page

text:
I have problem that my sub-menu is missing when I use (tried built in categories also) custom categories as menu items. Basically what I want: Menu item (wordpress page) -submenu item what is custom taxonomy   \--sub categories   \--sub categories   \--sub categories   -submenu item what is custom taxonomy   \--sub categories Now I can get the menu to work with Menus. What I want is that my submenu is open when I am inside sub categories page. Submenu item actually should open first sub category. I am using custom walker for my menu design and now I am thinking that is there something missing that it will close submenu when on custom taxonomy sub category page.               class submenu_Walker extends Walker_Nav_Menu {            function walk( $elements, $max_depth) {              global $wp_query;         $current_menu = (int) $wp_query->queried_object_id;              $tops = array(); // top level menu items         $subs = array(); // sub menu items              _wp_menu_item_classes_by_context($elements);              foreach ($elements as $element) {           if (0 == $element->menu_item_parent) {             $tops[] = $element;             if ($element->object_id == $current_menu) {               $current_parent = $element;             }           }           else           {             $subs[] = $element;                  if ($element->object_id == $current_menu) {               $current_child = $element;                  }           }         }              if (!$current_parent)                $current_parent = $this->get_current_parent_from_sub($elements, $current_child);              if ($current_parent) {           $real_subs = array();                foreach ($subs as $item) {             if ($item->menu_item_parent == $current_parent->db_id)               $real_subs[] = $item;           }         }              // show top level elements              $s = '
';              foreach ($tops as $item) {           $s .= $this->display_item($item);         }              $s .= "
";              // show sub menu items              if (sizeof($real_subs) > 0) {           $s .= "

";           foreach ($real_subs as $item) {             $s .= $this->display_item($item);           }           $s .= '

';         }         return $s;       }            // get the parent page when a sub page is the current page            function get_current_parent_from_sub($elements, $current_child) {              foreach ($elements as $element) {           if ($element->db_id == $current_child->menu_item_parent) {             return $element;           }         }         return false;       }            function display_item($item) {              $i = '';         $this->start_el( $i, $item, 0, array() );         $this->end_el( $i, $item, 0, array() );              return $i;            }     }


title: Generate aggregated feed from member blogs

text: I currently manage a multisite installation with 7 member blogs. We need to produce a combined RSS feed of news from all 7. Currently we use Feedwordpress to syndicate 6 blogs into blog number 7. This isn't working out because we're duplicating content in the db. Ideally I need a cached feed to reduce server load (the feed is subscribed to via high-traffic portals). What's the best way of doing this? I've considered Yahoo Pipes, but how about using Wordpress transients to cache a query across all member blogs, and somehow publishing this as RSS? JSON could be an option, but RSS is probably preferred.


title: Page doesn't load

text: I have following code, but my page doesn't load anymore. What is wrong?               require( plugin_dir_path( __FILE__ ) . 'menu.php');     require_once( plugin_dir_path( __FILE__ ) . 'getuser.php');          add_action( 'wp_enqueue_scripts', 'ffd_load_scripts' );          function ffd_load_scripts()     {         $myoption =  get_option( 'fixformdata_options' );         $myoptionValue = maybe_unserialize( $myoption );                $arguments = array();         for($i=1; $i<= $myoptionValue[fieldcount]; $i++)         {             $arguments['index'.$i] = $myoptionValue['id'.$i];         }              wp_register_script('ffd_js_script', WP_PLUGIN_URL.'/FixFormData/js/ffd_js_script.js', array('jquery'));         wp_localize_script('ffd_js_script', 'myAjax', merge_array(array(             'ajaxurl' => admin_url('admin-ajax.php'),             'idinfo' => $myoptionValue['idinfo']),$arguments)             );              wp_enqueue_script('jquery');         wp_enqueue_script('ffd_js_script', plugin_dir_url(__FILE__) . 'js/ffd_js_script.js');     }      Previously it worked fine, the problem is given by the $arguments I think. Tried some things but still have this issue. The problem is located in this part:               $arguments = array();         for($i=1; $i<= $myoptionValue[fieldcount]; $i++)         {             $arguments['index'.$i] = $myoptionValue['id'.$i];         }              wp_register_script('ffd_js_script', WP_PLUGIN_URL.'/FixFormData/js/ffd_js_script.js', array('jquery'));         wp_localize_script('ffd_js_script', 'myAjax', merge_array(array(             'ajaxurl' => admin_url('admin-ajax.php'),             'idinfo' => $myoptionValue['idinfo']),$arguments)             );      When I use this code, everything works fine, but I really need the iterator:               function ffd_load_scripts()     {         $myoption =  get_option( 'fixformdata_options' );         $myoptionValue = maybe_unserialize( $myoption );                /*$arguments = array();         for($i=1; $i<= $myoptionValue['fieldcount']; $i++)         {             $arguments['index'.$i] = $myoptionValue['id'.$i];         }*/              wp_register_script('ffd_js_script', WP_PLUGIN_URL.'/FixFormData/js/ffd_js_script.js', array('jquery'));         wp_localize_script('ffd_js_script', 'myAjax', array(                 'ajaxurl' => admin_url('admin-ajax.php'),                 'idinfo' => $myoptionValue['idinfo'],                 'index1' => $myoptionValue['id1'],                 'index2' => $myoptionValue['id2']                 )             );              wp_enqueue_script('jquery');         wp_enqueue_script('ffd_js_script', plugin_dir_url(__FILE__) . 'js/ffd_js_script.js');     }


title: Template for specific post of custom post type

text: I have the CPT "event". I have created single-event.php. I want one particular event to use a different template than single-event. I read elsewhere that this could be done by creating a single-event-[slug].php but I tried it and it does not work. WP uses single-event.php. (I can't find this in the WordPress documentation, so I'm thinking maybe I misunderstood?) Is there a way of doing this?


title: Remove rel="attachment wp-att-XX"

text: When you add an image with "Add media" to the WYSIWYG editor the link around the image automatically gets a rel="attachment wp-att-XX". I would like to remove this with a script - Can anyone help me? :)


title: Paginate Child Pages Content on Parent Page

text:
I am using the following code to display child page content on it's parent page. The code is working great, but it currently only shows the latest two child page posts, is there any way to display all of them and then add pagination to navigate through them?               <?php         $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');         $count = 0;         foreach($pages as $page) {             $content = $page->post_content;             if($count >= 2)                 break;             $count++;             $content = apply_filters('the_content', $content);             echo "
".$page->post_title."
";             echo "
".$content."
";         }     ?>      Thanks,   Josh


title: Upload images - Theme options

text:
I'm using this great [tuts+ tutorial][1] for creating theme options page. It works great for me be beause I need to change background images of divs via css. It works great with one image but I dont know how to make it work with 2 images? It would be a huge help if you can tell me what I'm doing wrong here? Thanks!                 <?php     function wptuts_get_default_options() {         $options = array();             $options[] = array('logo' => '');             $options[] = array('fav' => '');         return $options;     }               function wptuts_options_init() {          $wptuts_options = get_option( 'theme_wptuts_options' );               // Are our options saved in the DB?          if ( false === $wptuts_options ) {               // If not, we'll save our default options               $wptuts_options = wptuts_get_default_options();               add_option( 'theme_wptuts_options', $wptuts_options );          }               // In other case we don't need to update the DB     }     // Initialize Theme options     add_action( 'after_setup_theme', 'wptuts_options_init' );          function wptuts_options_setup() {         global $pagenow;         if ('media-upload.php' == $pagenow || 'async-upload.php' == $pagenow) {             // Now we'll replace the 'Insert into Post Button inside Thickbox'              add_filter( 'gettext', 'replace_thickbox_text' , 1, 2 );         }     }     add_action( 'admin_init', 'wptuts_options_setup' );          function replace_thickbox_text($translated_text, $text ) {           if ( 'Insert into Post' == $text ) {             $referer = strpos( wp_get_referer(), 'wptuts-settings' );             if ( $referer != '' ) {                 return __('I want this to be my Image!', 'wptuts' );             }         }              return $translated_text;     }          // Add "WPTuts Options" link to the "Appearance" menu     function wptuts_menu_options() {         //add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function);          add_theme_page('WPTuts Options', 'WPTuts Options', 'edit_theme_options', 'wptuts-settings', 'wptuts_admin_options_page');     }     // Load the Admin Options page     add_action('admin_menu', 'wptuts_menu_options');          function wptuts_admin_options_page() {         ?>

<?php _e( 'WPTuts Options', 'wptuts' ); ?>
                                       <?php settings_errors( 'wptuts-settings-errors' ); ?>                      <form id="form-wptuts-options" action="options.php" method="post" enctype="multipart/form-data">                          <?php                         settings_fields('theme_wptuts_options');                         do_settings_sections('wptuts');                     ?>
                         <input name="theme_wptuts_options[submit]" id="submit_options_form" type="submit" class="button-primary" value="<?php esc_attr_e('Save Settings', 'wptuts'); ?>" />                         <input name="theme_wptuts_options[reset]" type="submit" class="button-secondary" value="<?php esc_attr_e('Reset Defaults', 'wptuts'); ?>" />
                      </form>
         <?php     }          function wptuts_options_validate( $input ) {         $default_options = wptuts_get_default_options();         $valid_input = $default_options;              $wptuts_options = get_option('theme_wptuts_options');              $submit = ! empty($input['submit']) ? true : false;         $reset = ! empty($input['reset']) ? true : false;         $delete_logo = ! empty($input['delete_logo']) ? true : false;         $delete_fav = ! empty($input['delete_fav']) ? true : false;              foreach ( $wptuts_options   as $wptuts_options ) {               if ( $submit ) {                 if ( $wptuts_options['logo'] != $input['logo']  && $wptuts_options['logo'] != '' )                     delete_image( $wptuts_options['logo'] );                      $valid_input['logo'] = $input['logo'];             }             elseif ( $reset ) {                 delete_image( $wptuts_options['logo'] );                 $valid_input['logo'] = $default_options['logo'];             }             elseif ( $delete_logo ) {                 delete_image( $wptuts_options['logo'] );                 $valid_input['logo'] = '';             }             if ( $submit ) {                 if ( $wptuts_options['fav'] != $input['fav']  && $wptuts_options['fav'] != '' )                     delete_image( $wptuts_options['fav'] );                      $valid_input['fav'] = $input['fav'];             }             elseif ( $reset ) {                 delete_image( $wptuts_options['fav'] );                 $valid_input['fav'] = $default_options['fav'];             }             elseif ( $delete_fav ) {                 delete_image( $wptuts_options['fav'] );                 $valid_input['fav'] = '';             }              return $valid_input;     }          function delete_image( $image_url ) {         global $wpdb;              // We need to get the image's meta ID..         $query = "SELECT ID FROM wp_posts where guid = '" . esc_url($image_url) . "' AND post_type = 'attachment'";           $results = $wpdb -> get_results($query);              // And delete them (if more than one attachment is in the Library         foreach ( $results as $row ) {             wp_delete_attachment( $row -> ID );         }        }          /********************* JAVASCRIPT ******************************/     function wptuts_options_enqueue_scripts() {         wp_register_script( 'wptuts-upload', get_template_directory_uri() .'/wptuts-options/js/wptuts-upload.js', array('jquery','media-upload','thickbox') );                if ( 'appearance_page_wptuts-settings' == get_current_screen() -> id ) {             wp_enqueue_script('jquery');                  wp_enqueue_script('thickbox');             wp_enqueue_style('thickbox');                  wp_enqueue_script('media-upload');             wp_enqueue_script('wptuts-upload');              }          }     add_action('admin_enqueue_scripts', 'wptuts_options_enqueue_scripts');               function wptuts_options_settings_init() {         register_setting( 'theme_wptuts_options', 'theme_wptuts_options', 'wptuts_options_validate' );              // Add a form section for the Logo         add_settings_section('wptuts_settings_header', __( 'Logo Options', 'wptuts' ), 'wptuts_settings_header_text', 'wptuts');         // Add Logo uploader         add_settings_field('wptuts_setting_logo',  __( 'Logo', 'wptuts' ), 'wptuts_setting_logo', 'wptuts', 'wptuts_settings_header');         // Add Current Image Preview          add_settings_field('wptuts_setting_logo_preview',  __( 'Logo Preview', 'wptuts' ), 'wptuts_setting_logo_preview', 'wptuts', 'wptuts_settings_header');              // Add a form section for the fav         add_settings_section('wptuts_settings_header', __( 'fav Options', 'wptuts' ), 'wptuts_settings_header_text', 'wptuts');         // Add fav uploader         add_settings_field('wptuts_setting_fav',  __( 'fav', 'wptuts' ), 'wptuts_setting_fav', 'wptuts', 'wptuts_settings_header');         // Add Current Image Preview          add_settings_field('wptuts_setting_fav_preview',  __( 'fav Preview', 'wptuts' ), 'wptuts_setting_fav_preview', 'wptuts', 'wptuts_settings_header');           }     add_action( 'admin_init', 'wptuts_options_settings_init' );          function wptuts_setting_logo_preview() {         $wptuts_options = get_option( 'theme_wptuts_options' );  ?>
             <img style="max-width:100%;" src="<?php echo esc_url( $wptuts_options['logo'] ); ?>" />
         <?php     }          function wptuts_setting_fav_preview() {         $wptuts_options = get_option( 'theme_wptuts_options' );  ?>
             <img style="max-width:100%;" src="<?php echo esc_url( $wptuts_options['logo'] ); ?>" />
         <?php     }          function wptuts_settings_header_text() {         ?>
<?php _e( 'Manage Options for WpTuts Theme.', 'wptuts' ); ?>
         <?php     }          function wptuts_setting_logo() {         $wptuts_options = get_option( 'theme_wptuts_options' );         ?>             <input type="hidden" id="logo_url" name="theme_wptuts_options[logo]" value="<?php echo esc_url( $wptuts_options['logo'] ); ?>" />             <input id="upload_logo_button" type="button" class="button" value="<?php _e( 'Upload Logo', 'wptuts' ); ?>" />             <?php if ( '' != $wptuts_options['logo'] ): ?>                 <input id="delete_logo_button" name="theme_wptuts_options[delete_logo]" type="submit" class="button" value="<?php _e( 'Delete Logo', 'wptuts' ); ?>" />             <?php endif; ?>             <?php _e('Upload an image for the banner.', 'wptuts' ); ?>         <?php     }          function wptuts_setting_fav() {         $wptuts_options = get_option( 'theme_wptuts_options' );         ?>             <input type="hidden" id="fav_url" name="theme_wptuts_options[fav]" value="<?php echo esc_url( $wptuts_options['fav'] ); ?>" />             <input id="upload_fav_button" type="button" class="button" value="<?php _e( 'Upload fav', 'wptuts' ); ?>" />             <?php if ( '' != $wptuts_options['fav'] ): ?>                 <input id="delete_fav_button" name="theme_wptuts_options[delete_fav]" type="submit" class="button" value="<?php _e( 'Delete fav', 'wptuts' ); ?>" />             <?php endif; ?>             <?php _e('Upload an image for the banner.', 'wptuts' ); ?>         <?php     }               ?>


title: Custom fields PHP foreach loop

text:
In my theme, I am using some PHP to display custom field content. It checks if the fields are empty before displaying the content, because the_meta was showing titles for empty fields.
     <?php     $ck = get_post_custom_keys($post_id); //Array                  foreach ($ck as $k) {                  if (substr ($k, 0, 1) == '_')                  {   // skip keys starting with '_'                      continue;                  }                  $cv = get_post_custom_values($k, $post_id );  //Array                     foreach ($cv as $c) {                         if (empty ($c))                         {   // skip empty value                             continue;                         }                         $format_c = wpautop( $c, false );                         print_r ('');                         print_r ('
' . $k . '
');                         print_r ('
' . $format_c . '
');                         print_r ('');                     }                  }     ?>
      I would like to improve this so that the 'div.customfield-box' does not display unless there is content. I need to echo it inside the php, but where? The resulting html should look like:

Ingredients

Flour

Salt

Allergens

Wheat

      If there is no content, it should display nothing, not even the customfield- box.


title: How to insert Gallery shortcode to a meta box

text: When we create a Image Gallery from the Media Modal Box and click on "Insert Gallery" button, the gallery shortcode is added to the main text area. Is there a way to detect which Post Format is selected, and if its "Gallery" then is there a way to modify the action of the "Insert Gallery" button to add the shortcode to a meta box instead of the text area.


title: How to add a filter conditionally based on page related Conditional Tags

text:
I am developing a WordPress plugin and can't conditionally add filters based on the conditional tags. This is my code:               add_Action('init', 'determine_location');          function determine_location() {     $d = get_option('display_locations'); //this is a checkbox field in the plugins settings with 7 options         if (isset($d)) {             if ($d[0] == 'home') {                 if (is_home()) {                     add_filter('the_excerpt', 'insert_buttons_to_post_top');                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             } else if ($d == 'post' || $d == 'post') {                 if (is_single()) {                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             } else if ($d[0] == 'page' || $d == 'page' || $d == 'page') {                 if (is_page()) {                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             } else if ($d[0] == 'category' || $d[1] == 'category' || $d[2] == 'category' || $d[3] == 'category') {                 if (is_category()) {                     add_filter('the_excerpt', 'insert_buttons_to_post_top');                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             } else if ($d[0] == 'tag' || $d[1] == 'tag' || $d[2] == 'tag' || $d[3] == 'tag' || $d[4] == 'tag') {                 if (is_tag()) {                     add_filter('the_excerpt', 'insert_buttons_to_post_top');                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             } else if ($d[0] == 'archive' || $d[1] == 'archive' || $d[2] == 'archive' || $d[3] == 'archive' || $d[4] == 'archive' || $d[5] == 'archive') {                 if (is_archive()) {                     add_filter('the_excerpt', 'insert_buttons_to_post_top');                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             }         }      }               function insert_buttons_to_post_top(){        return "
Output
"     }      Currently this code shows no output. What is wrong here?


title: Pagination on archive.php page

text: I have an archive.php page with the following code:               <?php // Start your custom WP_query     $my_query = new WP_query();          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array('posts_per_page' ?> 1, 'paged' => $paged, 'category_name' => 'Casino Slots');     // Assign predefined $args to your query     $my_query->query($args);          // Run your normal loop     if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post();     ?>      Test      <?php endwhile;     else :     // do stuff for no results     endif;          wp_pagenavi();          // RESET THE QUERY     wp_reset_query();     ?>      and it displays the posts fine, but the pagination never shows?


title: Setting up robots.txt with Yoast's Seo plugin

text: I was looking for a decent robots.txt solution for my wordpress sites and after some searching I found Yoast's SEO plugin that provides a complete SEO solution including indexation. I set it up it to **not** index the following pages: search results, login and register pages, all admin pages, date-based archives and tag archives. However, when I looked at the source of those pages, I couldn't find any meta robots tag except in the login/register page. Is there another way to tell search engines what to index except robots meta and robots.txt? If not, where is the indication to these pages not being indexed? Thanks in advance


title: sanitize vimeo embed code?

text: I have a custom meta box with a textarea where users can drop in vimeo embed code. Should I sanitize this code before I update_post_meta, and, if so, how should I go about it? I don't want to strip out important information (like the iframe)...I just want to make sure nothing malicious is getting entered.


title: Unified login page for a Multisite/BuddyPress site

text: I use WordPress Multisite... and BuddyPress installed on the main site on mysite.com Practically I want users to be automatically redirected to the main site login page every time they try to login from any of the blogs/sites/subdomains. > *.mysite.com/login.php => mysite.com/login.php **Let me give some exemples:** site1.mysite.com/wp-login.php redirected to mysite.com/wp-login.php site2.mysite.com/wp-login.php redirected to mysite.com/wp-login.php xyzkw.mysite.com/wp-login.php redirected to mysite.com/wp-login.php ....................... _any future subdomain LOGIN PAGE - with no exceptions - will have to be redirected to mysite.com/wp-login.php_


title: Need to create a Theme demo site that features multiple themes

text: I would like to create a site like: http://demo2.woothemes.com/?name=sentient for my clients, so that they can see the range of themes I offer. I own many templates from different providers, and sending them to the providers will not help as there are quite a few and not all offer this functionality (not to mention that the UI can be confusing to my clients) I want the site to be super simple to use, and provide the ability at first to just switch themes on using a demo site (Wordpress site with content) Found this previous question about same subject, this plugin was offered there, but the solution is far from simple in that the all templates need to support some specific functionality (the theme switching widget) - this is not good enough. I'd appreciate any suggestions you may have (creating a site with an upper frame that switches sites below?) - problem is I have very little time to experiment on this, and am looking for someone with the knowledge who is willing to share.


title: How to create a specific frontend URL (not a Page) from a theme or plugin?

text: My theme implements an AJAX action that returns some dynamic content and needs some functions from the Wordpress environment. How can I construct a URL for the AJAX call in the most elegant and robust way? In particular, I see lots of themes and plugins directly linking to PHP files that are inside their directory tree, which in turn are totally different entry points from Wordpress's `index.php`, and then include this:               // INCLUDE WORDPRESS STUFF     define('WP_USE_THEMES', false);     include_once('../../../wp-load.php');      From an architecture perspective, this does not seem elegant to me (we create another entry point to the app), and it also breaks if I want to symlink the theme directory to some place else. I think WordPress doesn't implement a full-fledged router as the ones from typical Web frameworks, but is there a way to create specific (not custom posts, for instance) frontend URLs?


title: Rename filename to post title. Post Title not being fetched

text: function new_filename($filename, $filename_raw) {         global $post;         $post = add_post_meta( $post_id, wp_get_attachment_url($attachment_id));         $info = pathinfo($filename);         $ext  = empty($info['extension']) ? '' : '.' . $info['extension'];         $new = $post->post_title . '-mysitename' . $ext;         // the if is to make sure the script goes into an indefinate loop              if( $new != $filename_raw ) {             $new = sanitize_file_name( $new );         }         return $new;     }     add_filter('sanitize_file_name', 'new_filename', 10, 2);      Someone posted this function a while ago to rename filenames, I re-adjusted it a little bit but the problem is that the $post->post_title is not doing what it is supposed to do (meaning, not fetching the post title at all). Any ideas what could be going wrong here? (-mysitename is displayed in the filename though, thank god that works). So yeah, would really appreciate the help, been breaking my head over this for days. Thanks I'm using latest Wordpress version 3.9.2


title: How do you create a custom WPTouch theme?

text: I have WPTouch Pro installed and it does a great job at device detection as well as handling most blog posts. However, I want to make a mobile version of a homepage that doesn't have any blog posts. I know you can edit the css for a theme by making a child theme and editing it. Is this the preferred method to get WPTouch to show more content from the original page? That link is here: http://www.koolkatwebdesigns.com/wptouch-and-custom- templates/ Also, someone is using shortcodes; not sure if this works for content that WPTouch is already ignoring: http://www.renegadetechconsulting.com/tutorials/generate-mobile-specific- content-using-wptouch-pro-shortcodes Thanks in advance!


title: How to remove br and p tags from bbPress

text: bbPress is giving me a headache trying to figure out how to remove `<br>` and `<p>` tags from existing post in the database after an import. I have tried editing "formatting.php" but with no results except to hide all my forum posts for a day. Any suggestions?


title: Adjusting post width according to the image size

text: I am building a theme for a comic site. It seems some images are bigger than the post size. I need to resize the images according to the **Original Image size**. Can I achieve this through CSS? It doesn't matter if it extends the screen-size and scrolling window is shown.


title: /wp-login keeps loading. Weird code window.location

text: Some of my multi sites have got a weird code on the wp-login.php page. Its not all of them and yesterday was fine and now this is its there. window.location = 'http://www.mydomain.com/wp-login.php' I don't know where this script is coming from and where i can find it but it keeps loading my page and cant login to Wordpress.


title: How use %like% in sql statement wordpress

text: i use a **like** %text% statement in wordpress:               SELECT *  FROM location  WHERE name LIKE "%on" OR name LIKE "%on%"      i tried anything but it's not run:               $wpdb->get_results($wpdb -> prepare("SELECT *  FROM location  WHERE name LIKE %1s OR name LIKE %2s", '%'.like_escape('on'), '%'.like_escape('on').'%'), ARRAY_A);      please help me


title: WooCommerce Force Display of Base Country Order Addresses

text: It seems in recent versions of WooCommerce that the base country does not show on the order screens. Ex. we have 2 orders, one being from Australia and one from the United States. In the WooCommerce --> Orders screen the Australian order doesn't say Australia at the end of the order billing and shipping addresses (because our base location is Australia). The international orders do show the country though. How can that be fixed so that the base country is being shown in the formatted addresses still?


title: Automatically hide Widgets that would lengthen page

text: Something I've been dreaming about ever since I started using CMS's for making websites. I've settled on WP now, so hence I'm asking here. I conditionally hide widgets on certain pages that are very short, where the widgets extend the page too much, leaving lots of blank space in the main content area at the bottom. It would be much nicer to have a sidebar which dynamically hides widgets that would otherwise lengthen the page. As a bonus, maybe I could even prioritize which widgets to hide (as opposed to merely the bottom ones). Maybe it would be done by making the sidebar inherit its length from the main content, regardless of whether all the widgets then fit. Then something like CSS could be used to hide widgets that don't fit into the sidebar div?


title: How to get posts and comments amount per hour, per year and per month?

text: I have this snippet:               function count_user_comments_today( $uid ){         global $wpdb;         $today = date('Y-m-d');         $tomorrow = date('Y-m-d', time() + 86400);         $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d  AND comment_date >= %s  AND comment_date < %s ", $uid, $today, $tomorrow  ));         return $count;     }      But this get's the comments per day and that for a specific user. I want it to be generic, for the whole site and per hour, per year and per month.... Is this possible? Of course also the posts and not only the comments.


title: Using Ajax to autocomplete a form with data from db

text: I'm struggling to get the following:   1. User fills out personal number   2. Other input gets autocompleted with data from database As I have never made a plugin, help is greatly appreciated, my database knowledge is also not 'all that'. Thanks in advance.


title: Admin Subpages without Menu entry

text: I have added some pages to the WP-Adminmenu, with `add_menu_page` and `add_submenu_page`. The URLs for those pages look like `admin.php?page=my- plugin/admin/submenupage.php`. If I try to add a page now that has isnt registered to the menu and link to it with `<a href="?page=my- plugin/admin/add.php">` I'm getting a permissions error. Is there a way to add pages to the admin area without registering them to the menu?


title: Configuring multi-site with domain mapping

text: We have a client that runs 15 or so e-commerce and brochureware sites for his customers. What they want to do is add a WordPress blog to each of these sites, for example:               www.site1.com/blog     www.site2.com/blog     www.site3.com/blog     www.site4.com/blog      All of these sites reside on the same server (Windows 2008R2/IIS7.5 running PHP 5.3). Rather than have a separate install of WordPress in each `/blog` directory we'd like to map `/blog` as a virtual directory to a single install of WordPress located in a central admin site, i.e. `www.clientsdomainname.com`. The idea being to enable the multi-site feature on WordPress and manage all these site's content on one place on `clientsdomainname.com`. To try and get this working with the first blog site (`www.site1.com/blog`) I've   * Installed WordPress 3.6.1 on `www.clientsdomainname.com`   * Enabled the multi-site feature   * Mapped `site1.com`'s `/blog` as a virtual directory pointing to the physical root of `www.clientsdomainname.com` on the file system (making sure permissions are correct etc).   * Installed http://wordpress.org/plugins/wordpress-mu-domain-mapping/ and carried out the following:   * Set my server IP address in the domain mapping configuration as per step 3 in http://ottopress.com/2010/wordpress-3-0-multisite-domain-mapping-tutorial/   * Created a new site (`www.clientsdomainname.com/site1`) using the Network Admin bits   * Dropped into this site's dashboard and in Tools -> Domain mapping added: `http://www.site1.com` and set this as the primary domain for this site. Now when I browse to `http://www.site1.com/blog` things aren't quite right - CSS isn't being loaded and I get WordPress's default "This is somewhat embarrassing, isn’t it?" 404 page. If I view the page source, site URL's (such as for CSS) are being requested from `http://www.site1.com/` rather than `http://www.site1.com/blog` I'm now stuck and not sure how best to proceed with getting this to work. Is it possible to get my desired configuration work using the multi-site feature along with one of the domain mapping plugins e.g. https://premium.wpmudev.org/project/domain-mapping/ or http://wordpress.org/plugins/wordpress-mu-domain-mapping/ ? The following are the changes I made to the default `wp-config.php` file, everything else is stock:               /* That's all, stop editing! Happy blogging. */     define('MULTISITE', true);     define('SUBDOMAIN_INSTALL', false);     define('DOMAIN_CURRENT_SITE', 'clientsdomainname.com');     define('PATH_CURRENT_SITE', '/');     define('SITE_ID_CURRENT_SITE', 1);     define('BLOG_ID_CURRENT_SITE', 1);     define('SUNRISE', 'on');      These are the rewrite rules for the `clientsdomainname.com` where WordPress is installed (we use ISAPI_Rewrite3 which supports most Apache mod_rewrite directives):               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]     RewriteRule . index.php [L]


title: What does this mean: Object of class WP_Error could not be converted to string

text: When I click on preview a post, I get the following error: Catchable fatal error: Object of class WP_Error could not be converted to string in functions.php on line 288 The line 288 is as follows               echo get_category_parents($cat, TRUE, '' . $delimiter . '');      Any ideas on this please?


title: How to unregister a widget from a child theme

text: I was wondering if there was a way to unregister a widget that gets declared in the functions.php file of a parent theme from a child theme, I understand that the child's function.php file gets loaded first so I don't know how to unregister it when it hasn't been created yet. Thanks all in advance!


title: How to insert image and text from admin panel throughout my theme

text: I'd like to have an admin panel where I can upload an image and customize a line of text. Then use a shortcode throughout the theme to display the text/images. I'd also like this to be scalable so I can add more image upload/text inputs to this panel as I grow the site. I was using a tutorial that was showing how to insert a logo in a similar fashion that I was going to hack for my use, but following the tutorial doesn't seem to work in the current version of Wordpress.


title: 404 redirecting to home

text: I have a multisite network, and my theme has a custom `404.php`. On all the child sites this 404 handler is being correctly used, but on the primary site all 404s go back to the home page without touching my `404.php` at all. And for once, this isn't the fault of the Redirection plugin! The problem is still there when Redirection is turned off (network-wide _and_ on the specific site). The problem isn't occurring on my local copy of the same site, but I can't find any difference in the configuration or plugins that could be causing it.


title: WooCommerce & Caching

text: I have a div that displays the total amount of products the customer has in their cart, however this isn't updating as I have caching on (W3 Total Cache). Is there a workaround for this? Cheers, Steve


title: Reverse pagination issue

text: I installed the Default Sort Ascend plugin for Wordpress because I needed the opposite of how Wordpress displays its posts. It works awesome except for the pagination. Now the Previous and Next buttons are messed up, instead of getting the Next button on the first page I get the Previous. I want them to change, basically I want the Previous button to do what the Next should and vice versa. Also their location should change. This is the way how I think I can fix this. However I don't know where I can find these things and change them and I tried searching for different plugins and none seems to fix the problem. If you know of any of these please let me know. I hope this topic helps others as well. Thanks!


title: What is the Javascript event for an item being added to the cart in Woocommerce?

text: I can't seem to find this in the docs or through google. So basically I'm just looking for the Javascript event that fires when an item is added to the cart. ~~For some reason my default added to cart notification isn't working.~~ EDIT: So I'm thinking because I'm including the woocommerce.php file in my themes default folder as well as my woocommerce template overrides.


title: Enqueuing a script before anything else

text: I wondered if it was possible to change the order in which a script is enqueued. I ask this because I wish to include the HTML5 enabling script but it needs to be included before any styles. Is there any way to change the order? I could obviously hard code it into the themes header, but I would prefer to enqueue it. Thanks for any suggestions you may have.


title: Function to change meta value in database for each post

text: I have a meta key called 'prijs' in each post. The value of this meta key consist of numbers in the follow structure: 2,100.00 I want to remove the comma in the meta value to get this output: 2100.00 So, i created a function but it doesn't work:               add_action('wp_insert_post', 'deleteCommaDB');     function deleteCommaDB($postID){         $price_key = 'prijs';         $getPrice = get_post_meta($postID, $price_key, true);         $newPrice = str_replace(array(','), '', $getPrice);              update_post_meta($postID, $price_key, $newPrice);              return true;     }      I created the function `deleteCommaDB`. This function gets the post meta from the meta key 'prijs', and replaces the comma for nothing. This new value is saved in the variable $newPrice. Next thing to do, is update the post meta with the new value. What am i doing wrong?


title: How to add a rel attribute to images that contains their categories?

text: I've added categories to images, so that I can use them to filter images within a portfolio page. Now I'm thinking I need to add the rel attribute to each image that contains its assigned categories. Is this the right approach? If so, how do I add add rel with the applicable categories?


title: PHPlist & new posts notification?

text: I know there are plugins out there for integrating the user base & sign-up, but are there any for using PHPlist to automatically send out newsletters of new posts? I'm really trying to avoid a from-scratch solution here, though if nothing is 'ready made' I'd appreciate any pointers or head starts ;)


title: Building a Wordpress App

text: I construction of a administrative back office inside the wordpress theme for running our travel company, monitoring users, bookings and payments, it has come to my attention that it might be better served and more secure if such an area were in face a desktop application or offline webpage that connected to the internet inly to get the date. So how would one connect to wordpress from html/php pages sitting on the desktops of relevant computers? And is that a sensible idea or not? Many Thanks,


title: Audio Player for MP3 Files for Wordpress

text: I have a wordpress account. I am just using the free wordpress account which does not allow me to install any plugins. I have an mp3 file and I want it to appear as an audio player. There are many plugins like wpaudio but that only works if I have installed the wordpress on my server which I have not.


title: Understanding Permalinks on Custom Post Types

text: I hate to try to reinvent the wheel here, but none of the suggested post seem to work in answering my question. I am building a system for our 30 Under 30 honorees, which is basically setup as a portfolio of images. The types of post I am creating will be called "honorees", and the overall menu called "30 Under 30". The portfolio page that they are all displayed on, will be http://domain.com/30under30/ But for some reason the posts are created as http://domain.com/honoree/%honoree-name%/ **How do I change the my taxonomy follow menu name, as opposed to post type name?** The labels section of my code from functions.php is below                  function project_custom_init()       {         $labels = array(           'name' => _x('Honorees', 'post type general name'),           'singular_name' => _x('Honoree', 'post type singular name'),           'add_new' => _x('Add New', 'honoree'),           'add_new_item' => __('Add New Honoree'),           'edit_item' => __('Edit Honoree'),           'new_item' => __('New Honoree'),           'view_item' => __('View Honoree'),           'search_items' => __('Search Honorees'),           'not_found' =>  __('No honorees found'),           'not_found_in_trash' => __('No honorees found in Trash'),           'parent_item_colon' => '',           'menu_name' => '30 Under 30'         );        $args = array(           'labels' => $labels,           'public' => true,           'publicly_queryable' => true,           'show_ui' => true,           'show_in_menu' => true,           'query_var' => true,           'rewrite' => true,           'capability_type' => 'post',           'has_archive' => true,           'hierarchical' => false,           'menu_position' => null,           'supports' => array('title','editor','author','thumbnail','excerpt','comments')         );         // The following is the main step where we register the post.         register_post_type('honoree',$args);         // Initialize New Taxonomy Labels         $labels = array(           'name' => _x( 'Tags', 'taxonomy general name' ),           'singular_name' => _x( 'Tag', 'taxonomy singular name' ),           'search_items' =>  __( 'Search Types' ),           'all_items' => __( 'All Tags' ),           'parent_item' => __( 'Parent Tag' ),           'parent_item_colon' => __( 'Parent Tag:' ),           'edit_item' => __( 'Edit Tags' ),           'update_item' => __( 'Update Tag' ),           'add_new_item' => __( 'Add New Tag' ),           'new_item_name' => __( 'New Tag Name' ),         );           // Custom taxonomy for Honoree Tags           register_taxonomy('tagportfolio',array('honoree'), array(           'hierarchical' => true,           'labels' => $labels,           'show_ui' => true,           'query_var' => true,           'rewrite' => array( 'slug' => 'tag-portfolio' ),         ));        Any help would be appreciated. I'm trying my best to understand the code as I figure this out.


title: All subdomains redirecting to mainsite/wp-signup.php after multisite install

text: Need some help here. Have a WordPress 3.1 install at webtest.mysite.com and want multiple sub-domains at 1.webtest.mysite.com, 2.webtest.mysite.com, etc. After following all the instructions to the letter, every subdomain address redirects to the main install at webtest.mysite.com/wp-signup.php? Any ideas? .htaccess contents               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     # uploaded files     RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]     RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule . index.php [L]     # END WordPress     php_value upload_max_filesize 2000M     php_value post_max_size 2000M     php_value memory_limit 2000M     #php_flag display_errors on


title: Breadcrumbs - Exclude Child Categories

text: I am using this code in my functions.php file to display breadcrumbs on my web site..               function the_breadcrumb() {                 if (!is_home()) {                         echo '';                         echo 'Home';                         echo " Â» ";                         if (is_category() || is_single()) {                                 the_category('title_li=');                                 if (is_single()) {                                         echo " Â» ";                                         the_title();                                 }                         } elseif (is_page()) {                                 echo the_title();                         }                 }         }      I would like to know how to modify this so that only Parent categories are displayed? I have lots of posts that are assigned to multiple sub categories so the breadcrumb trail can get huge! Can anyone help?


title: How to make global post work with custom post type?

text: I was wondering to know if it's possible to use global posts with custom_types. I was working with this function:               global $post;      $myposts = get_posts('numberposts=4&offset=1& category=3,4');      foreach($myposts as $post) :          setup_postdata($post); ?>         <a href="<?php the_permalink() ?>" rel="bookmark" title="Visualizza <?php the_title(); ?>"><img src="<?php echo get_option('home'); ?>/wp-content/uploads/posthumb/<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>" alt="<?php the_title(); ?>" />     <?php endforeach;      As soon as I've moved the post from the standard articles type to a new custom post type, this stopped working. The category is still the same. Can I get it work again in any kind of way? Thank you very much for your reply.


title: Comment Function

text:
How would I make this Function display only the latest 5 comments?               function showLatestComments() {       global $wpdb;         $sql = "        SELECT DISTINCT comment_post_ID, comment_author, comment_date_gmt, comment_approved, SUBSTRING(comment_content,1,100) AS com_excerpt         FROM $wpdb->comments         WHERE comment_approved = '1'        ORDER BY comment_date_gmt DESC         LIMIT 5";        $comments = $wpdb->get_results($sql);        $output .= '
Latest student perspectives

';        foreach ($comments as $comment) {         $output .= '
'. $comment->comment_author . ' said : "' . strip_tags($comment->com_excerpt). '..."
';        }      $output .= '
';        echo $output;       }//end function


title: How can I organize/create an archive listing by Year and month

text: I thought this would be simpler using the basic widgets that WP provides but its not. I need to create   * 2012      * Decemeber     * November     * ...   * 2011      * December     * ... The month items would be links to that archive. Is this possible? I would prefer not to use a plugin but if thats the answer its ok.


title: Custom Post Type - List all attachments on Edit Screen

text: I'm currently building a custom post type in Wordpress and I need to be able to list all attachments inside the edit screen. I know how to do this on the front-end template, but anyone know the code to use or can be placed in the functions.php page for the custom post type? Essentially, what I'm trying to do is list all attachments in a checkbox list, then allow the editor to select them to associate with a custom field. Thanks! Troy


title: Search Form Based On Tutorial Not Working

text:
Ive based this on the twenty twelve theme, and copied a tutorial and built the following searchbox:-
<?php          printf(              __( 'Search Results for: %s', 'PCDConsulting' ),              '' . get_search_query() . ''          );          ?>
                    <?php /* Start the Loop */      if ( have_posts() )     {         while ( have_posts() )         {             the_post();              get_template_part( 'content', get_post_format() );          }     }     else     {     ?>

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

<?php                  _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.',                      'PCDConsulting'                  );                  ?>

     <?php     }      This is also my searchform:               <form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">                    <form id="searchform" method="get" action="<?php bloginfo('template_url'); ?>/MilkNHny/search.php">                         <input type="text" name="s" value="Search PCD" onblur="if(this.value == ''){ this.value = 'Search PCD'; this.style.color = '#BBB';}" onfocus="if(this.value == 'Search PCD'){ this.value = '';                this.style.color = '#000';}" style="color:#BBB;" placeholder="" /><input type="submit" value="Search" />                     </form>      Its not actually returning anything, please can someone advise if i have missed something? www.milknhny.co.uk/SofiaWork Thanks in advance Kirsty _**EDIT_** I copied both the search and results from the twentyeleven theme and i cant understand why its still not working :S               <?php get_header(); ?>     <?php get_sidebar('slider'); ?>

<?php echo get_the_title(); ?>
            <?php if ( have_posts() ) : ?>     <div class="maincontentwrap" id="post-<?php the_ID(); ?>">
<?php printf( __( 'Search Results for: %s', 'PCDConsulting' ), '' . get_search_query() . '' ); ?>
                                         <?php /* Start the Loop */ ?>             <?php while ( have_posts() ) : the_post(); ?>                 <?php get_template_part( 'content', get_post_format() ); ?>             <?php endwhile; ?>                        <?php else : ?>

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

<?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'PCDConsulting' ); ?>
                     <?php get_search_form(); ?>

              <?php endif; ?>
      Is there something im seriously missing here????


title: WordPress | WP_Query does not return anything with s=a

text: I have the following code:               $data = new WP_Query('s=a');      and the print_r returns the following data:               WP_Query Object     (         [query_vars] => Array             (                 [s] => a                 [error] =>                  [m] => 0                 [p] => 0                 [post_parent] =>                  [subpost] =>                  [subpost_id] =>                  [attachment] =>                  [attachment_id] => 0                 [name] =>                  [static] =>                  [pagename] =>                  [page_id] => 0                 [second] =>                  [minute] =>                  [hour] =>                  [day] => 0                 [monthnum] => 0                 [year] => 0                 [w] => 0                 [category_name] =>                  [tag] =>                  [cat] =>                  [tag_id] =>                  [author_name] =>                  [feed] =>                  [tb] =>                  [paged] => 0                 [comments_popup] =>                  [meta_key] =>                  [meta_value] =>                  [preview] =>                  [sentence] =>                  [fields] =>                  [menu_order] =>                  [category__in] => Array                     (                     )                      [category__not_in] => Array                     (                     )                      [category__and] => Array                     (                     )                      [post__in] => Array                     (                     )                      [post__not_in] => Array                     (                     )                      [tag__in] => Array                     (                     )                      [tag__not_in] => Array                     (                     )                      [tag__and] => Array                     (                     )                      [tag_slug__in] => Array                     (                     )                      [tag_slug__and] => Array                     (                     )                      [ignore_sticky_posts] =>                  [suppress_filters] =>                  [cache_results] => 1                 [update_post_term_cache] => 1                 [update_post_meta_cache] => 1                 [post_type] => any                 [posts_per_page] => 10                 [nopaging] =>                  [comments_per_page] => 50                 [no_found_rows] =>                  [search_terms] => Array                     (                         [0] => a                     )                      [order] => DESC             )              [tax_query] => WP_Tax_Query Object             (                 [queries] => Array                     (                     )                      [relation] => AND             )              [meta_query] => WP_Meta_Query Object             (                 [queries] => Array                     (                     )                      [relation] =>              )              [post_count] => 0         [current_post] => -1         [in_the_loop] =>          [comment_count] => 0         [current_comment] => -1         [found_posts] => 0         [max_num_pages] => 0         [max_num_comment_pages] => 0         [is_single] =>          [is_preview] =>          [is_page] =>          [is_archive] =>          [is_date] =>          [is_year] =>          [is_month] =>          [is_day] =>          [is_time] =>          [is_author] =>          [is_category] =>          [is_tag] =>          [is_tax] =>          [is_search] => 1         [is_feed] =>          [is_comment_feed] =>          [is_trackback] =>          [is_home] =>          [is_404] =>          [is_comments_popup] =>          [is_paged] =>          [is_admin] =>          [is_attachment] =>          [is_singular] =>          [is_robots] =>          [is_posts_page] =>          [is_post_type_archive] =>          [query_vars_hash] => 1015947de489d0153582586bded7c016         [query_vars_changed] =>          [thumbnails_cached] =>          [query] => Array             (                 [s] => a             )              [request] => SELECT * FROM wp_posts WHERE 1=2         [posts] => Array             (             )          )      What is wrong with this query and does not return any data ? Also take a look at the "request" where it is `SELECT * FROM wp_posts WHERE 1=2`


title: field of metabox is not visisible outside the function

text:
I have a metabox with two static fields and one more field I add in `ingredients_show_box` function. All three fields are visible by `$_POST` when I save data. But the two static fields are visible by metabox and I can update data via `foreach`, and third is not visible. It's not suitable as I would like to add a variable number of fields with unique field names for each post.               $food_box = array(     'id' => 'foodbox',     'title' => __('Ingredients details','splus'),     'page' => 'recipes',     'context' => 'normal',     'priority' => 'high',     'fields' => array(         array(             'name' => __('Ingredients','splus'),             'desc' => __('List all the ingredients','splus'),             'id' => 'tingred',             'type' => 'text',             'std' => ''         ),         array(             'name' => __('Tips','splus'),             'desc' => __('Tips for this recipe','splus'),             'id' => 'ttips',             'type' => 'text',             'std' => '1'         )     ));          add_action('admin_menu', 'mytheme_add_box');  // Add meta box     function mytheme_add_box() {     global $meta_box, $food_box;     add_meta_box($food_box['id'], $food_box['title'], 'ingredients_show_box', $food_box['page'], $food_box['context'], $food_box['priority']);}          function ingredients_show_box() {     global $food_box, $post, $arr;     echo '<input type="hidden" name="food_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; // Use nonce for verification          echo '
';     $arr = array ( 'name' => 'n11',          'desc' => 'n11',          'id' => 'n11',         'type' => 'text',        'std' => '464');          $food_box['fields'][] = $arr; // insert additional field          foreach ($food_box['fields'] as $field) {         // get current post meta data         $meta = get_post_meta($post->ID, $field['id'], true);         // populating the fields here     }     echo '
';}          add_action('save_post', 'mytheme_save_data');   // Save recipe post from meta box                    function mytheme_save_data($post_id) {     global $meta_box, $food_box;     global $wpdb;     //die( var_dump( $_POST, $_GET, $_REQUEST ) );          // UNFORTUNATELLY $foodbox does not include filed 'n11'     foreach ($food_box['fields'] as $field) {         $old = get_post_meta($post_id, $field['id'], true);         $new = $_POST[$field['id']];              if ($new && $new != $old) {             update_post_meta($post_id, $field['id'], $new);         } elseif ('' == $new && $old) {             delete_post_meta($post_id, $field['id'], $old);         }     }     $new = $_POST['n11']; // workaround and not suitable: $_POST has this field     update_post_meta($post_id, 'n11', $new);     }


title: Cannot access WP admin because plugin returns 204

text: I recently installed a plugin on my schools wordpress site that one of my friends wrote, that should pull the newest video from a youtube page and post it. If the video hasn't changed, he set up the plugin to return a `HTTP/1.0 204` code. However, this seems to have rendered the wp-admin unavailable, as when I try to access it, it seems the plugins are also loaded, and so I get a `204` header when I try to access the admin panel. Is there any way to circumvent the plugins loading or something similar so I can access the wp-admin panel to disable the plugin, or will I have to use phpMyAdmin to go in and manually disable all installed plugins in the `wp_options` table?


title: Using common slider in all sites

text: I have created one main site and 100 multi-sites. But, I am facing one issue. I want to use a common slider for all sites, meaning that I can control and edit from main site. How to update something on one site and relect the changes on all sites?


title: enqueue_script doesn't work with HTML5 blank theme

text: I am trying to enqueue a couple of js files using something like this code:               function scripts_function()      {         wp_register_script('mapbox', 'http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js');         wp_enqueue_script('mapbox');              wp_register_script('myscript', plugins_url( 'my-js-file.js' , __FILE__ ));         wp_enqueue_script('myscript');     }     add_action('wp_enqueue_scripts', 'scripts_function');      And this works fine, as long as i use the "twentytwelve" theme wich i used while creating this plugin I' working on. But now I want to implement it on the HTML5 blank theme wich i was thinking about using as a startpoint for my theme, but then this just stops working, doesnt enqueue my `my-js-file.js`, but the mapbox script hosted on cdnjs is included just fine. If i inspect the code in the browser, i can see that where the script tag for my js-file should be there is just a script tag with a src attribute without a value:               <script type="text/javascript" src></script>      If i do `print_r(plugins_url( 'my-js-file.js' , __FILE__ ));`, I get a path to my js file wich I can paste into the browser and that works fine. What is going on here?


title: Can this navigation be done easily in WordPress?

text: Can anyone please let me know if a dual navigation style is easily achievable or not possible. A WordPress developer I'm in touch with is telling me it's not. Basically, we would like the navigation to be via links at the top of the web page but also introduce a sub-navigation on the left side of the page. So if you were on the HOME section, you'd have 3 tabs on the left, breaking HOME down into 3 sub parts. If you clicked on another top link and went to section XYZ, the tabs on the left would vary to offer sub-sections of XYZ. I know it can obviously be done from a HTML point of view but the guy is saying it's not possible to do this and at the same time, keep the content editable within WordPress as Pages etc. I would like all the main pages and their sub content editable via WordPress CMS. Possible? Thanks ps: I would have added an attachment but not allowed as I'm a new user.


title: Strip a word from wp_list_categories

text: With the following code I am showing a list of sub categories:               <ul class="subcats-blog">              <?php             if ( is_category() ) {                 $current_cat = get_query_var('cat');                         wp_list_categories('&title_li=&child_of='.$current_cat);             }         ?>     </ul>      What I am trying to do is to strip the word 'news' from any list item. I figured that I can do it by the use of preg_replace, but the problem is my knowledge of php is very limited, and I'm not able to glue the two together. Any help would be greatly appreciated.


title: Custom tabs widget don't work in google chrome, is blocked, do not change the tabs. Why?

text:
Code is the problem or is a Google Chrome issue? **Here is the code:**               /*-----------------------------------------------------------------------------------*/     /*  Create the widget     /*-----------------------------------------------------------------------------------*/     add_action('widgets_init', 'bd_post_types_init');          function bd_post_types_init(){              register_widget('bd_post_types_widget');          }          /*-----------------------------------------------------------------------------------*/     /*  Widget class     /*-----------------------------------------------------------------------------------*/     class bd_post_types_widget extends WP_Widget {                   /*-----------------------------------------------------------------------------------*/         /*  Widget Setup         /*-----------------------------------------------------------------------------------*/         function bd_post_types_widget(){                  // Widget settings             $ops = array('classname' => 'post-types-widget', 'description' => __('Display any post type: recent or popular, as text link or thumbnail', THEME_NAME) );                  // Create the widget             $this->WP_Widget('post-types-widget', 'Post Types (All in one)', $ops);              }              /*-----------------------------------------------------------------------------------*/         /*  Display Widget         /*-----------------------------------------------------------------------------------*/         function widget($args, $instance){                  extract($args);                  $title = apply_filters('widget_title', $instance['title']);             $count = $instance['count'];                  echo $before_widget;             if (!empty($title)) echo $before_title . $title . $after_title;             bd_post_types_widget($count, $instance['post-type'], $instance['type'], $instance['display'], $instance['category']);             echo $after_widget;              }              /*-----------------------------------------------------------------------------------*/         /*  Update Widget         /*-----------------------------------------------------------------------------------*/         function update($new_instance, $old_instance){             $instance = $old_instance;                  $instance['title'] = $new_instance['title'];             $instance['count'] = $new_instance['count'];             $instance['type'] = $new_instance['type'];             $instance['post-type'] = $new_instance['post-type'];             $instance['display'] = $new_instance['display'];             $instance['category'] = $new_instance['category'];                  return $instance;         }              /*-----------------------------------------------------------------------------------*/         /*  Displays the widget settings controls on the widget panel         /*-----------------------------------------------------------------------------------*/         function form($instance){             global $BD_theme;                 // Set up some default widget settings                 $defaults = array('title' => 'Recent Post', 'post-type' => '', 'count' =>'5', 'type' => 'thumbnail', 'display' => 'recent', 'category' => 'all');                 $instance = wp_parse_args((array) $instance, $defaults);                      $post_types = '';                 if(isset($BD_theme->options['post-types']) && is_array($BD_theme->options['post-types']))                     $post_types = $BD_theme->options['post-types'];                  ?>
                 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', THEME_NAME); ?>:                 <input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>">

                 <label for="<?php echo $this->get_field_id('post-type'); ?>"><?php _e('Post Type', THEME_NAME ); ?>:
                 <select class="bd-cat-select" name="<?php echo $this->get_field_name('post-type'); ?>" id="<?php echo $this->get_field_id('post-type'); ?>">                     <option value="post" <?php if($instance['post-type']=='post') echo 'selected="selected"'; ?>>Post</option>                 <?php foreach($post_types as $k => $v):                      $name = $k;                               if(isset($v['name']))                         $name = $v['name'].'s';                          if(isset($v['menu-name']))                         $name = $v['menu-name'];                 ?>                     <option value="<?php echo $k; ?>" <?php if($instance['post-type']==$k) echo 'selected="selected"'; ?>><?php echo $name; ?></option>                 <?php endforeach ; ?>                      </select>

                 <label for="<?php echo $this->get_field_id('category'); ?>"><?php _e('Post Category (if post is selected)', THEME_NAME ); ?>:
                 <select  name="<?php echo $this->get_field_name('category'); ?>" id="<?php echo $this->get_field_id('category'); ?>">                     <?php                      $bd_categories = get_categories();                     $bd_categories_tab = array();                     foreach($bd_categories as $category){                         $bd_categories_tab['all'] = 'All';                         $bd_categories_tab[$category->cat_ID] = $category->name;                     }                           foreach($bd_categories_tab as $k => $v):?>                          <option value="<?php echo $k; ?>" <?php if($instance['category']==$k) echo 'selected="selected"'; ?>><?php echo $v; ?></option>                     <?php endforeach; ?>                           </select>                 <?php //debug($bd_categories_tab); ?>

                 <label for="<?php echo $this->get_field_id('display'); ?>"><?php _e('Display', THEME_NAME ); ?>:
                 <select name="<?php echo $this->get_field_name('display'); ?>" id="<?php echo $this->get_field_id('display'); ?>">                     <option <?php if($instance['display']=='recent') echo 'selected="selected"'; ?>><?php _e('recent', THEME_NAME ); ?></option>                     <option <?php if($instance['display']=='featured') echo 'selected="selected"'; ?>><?php _e('featured', THEME_NAME ); ?></option>                     <option <?php if($instance['display']=='popular') echo 'selected="selected"'; ?>><?php _e('popular', THEME_NAME ); ?></option>                 </select>

                 <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Number of post', THEME_NAME ); ?>:                 <input class="widefat" type="text" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" value="<?php echo $instance['count']; ?>">

                 <label for="<?php echo $this->get_field_id('type'); ?>"><?php _e('Type' ,THEME_NAME ); ?>:                 <select name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>">                     <option <?php if($instance['type']=='thumbnail') echo 'selected="selected"'; ?>><?php _e('thumbnail', THEME_NAME ); ?></option>                     <option <?php if($instance['type']=='text') echo 'selected="selected"'; ?>><?php _e('text', THEME_NAME ); ?></option>                     <?php if($BD_theme->options['video'] != array()): ?>                     <option <?php if($instance['type']=='video') echo 'selected="selected"'; ?> value="video"><?php _e('video (only for video post types)', THEME_NAME ); ?></option>                     <?php endif; ?>                      </select>
             <?php         }                    }              /*-----------------------------------------------------------------------------------*/         /*  Function         /*-----------------------------------------------------------------------------------*/         function bd_post_types_widget($count=5, $post_type, $type, $display, $category){             global $wpdb, $BD_theme, $post, $bd_ID;             $do_not_duplicate = array();             if(is_single())                 //echo $bd_ID;                 $do_not_duplicate[] = $bd_ID;                  $is_video = (in_array($post_type, $BD_theme->options['video'])) && ($post_type!='post');                  //$do_not_duplicate[] = $post->ID;             if($type!='text'){                 if($display=='recent'){                     $args = array(                          'post_type' => array($post_type) ,                         'posts_per_page' => $count,                         'meta_key'    => '_thumbnail_id',                         'post__not_in' => $do_not_duplicate                         );                      }elseif($display=='featured'){                     $args = array(                      'post_type' => array($post_type) ,                     'orderby' => 'post_date',                     'meta_key'    => '_thumbnail_id',                     'posts_per_page' => $count,                     'post__not_in' => $do_not_duplicate,                     'meta_query' => array(                                              array(                                                   'key'     => 'bd_featured',                                                   'value'   => 'on',                                                   'compare' => '='                                                   )                                              )                     );                      }elseif($display=='popular'){                          $args = array(                      'post_type' => array($post_type) ,                     'orderby' => 'comment_count',                     'meta_key'    => '_thumbnail_id',                     'order'    => 'DESC',                     'posts_per_page' => $count,                     'post__not_in' => $do_not_duplicate,                     );                 }             }else{                      if($display=='recent'){                     $args = array(                          'post_type' => array($post_type) ,                         'posts_per_page' => $count,                         'post__not_in' => $do_not_duplicate                              );                      }elseif($display=='featured'){                     $args = array(                      'post_type' => array($post_type) ,                     'orderby' => 'post_date',                     'posts_per_page' => $count,                     'post__not_in' => $do_not_duplicate,                     'meta_query' => array(                                              array(                                                   'key'     => 'bd_featured',                                                   'value'   => 'on',                                                   'compare' => '='                                                   )                                              )                     );                      }elseif($display=='popular'){                          $args = array(                      'post_type' => array($post_type) ,                     'orderby' => 'comment_count',                     'order'    => 'DESC',                     'posts_per_page' => $count,                     'post__not_in' => $do_not_duplicate,                     );                 }                  }                  if($post_type == 'post' && $category!='all'){                 $args['category__in'] = $category;             }                  $loop = new WP_Query($args);             if ( $type=='text'){                 echo "
";             }elseif ( $type=='thumbnail' || $type=='video'){                 echo '
';             }             while ($loop->have_posts()) : $loop->the_post();             ?>             <?php if ( $type=='video'): ?>                 <?php if($is_video): ?>

                             <?php echo get_post_meta($post->ID, '_format_video_embed', true); ?>
                         <a href="<?php the_permalink(); ?>" title="<?php _e('Permanent Link to', THEME_NAME); ?> <?php the_title(); ?>"><?php the_title(); ?>
                         <?php echo get_the_time('F d, 20y'); ?>
                      <?php else: ?>
                         <a href="<?php the_permalink(); ?>" class="widget-thumb-link">                             <?php the_post_thumbnail('mini', array('class' => 'frame', 'title' => "")); ?>                                                  <a href="<?php the_permalink(); ?>" title="<?php _e('Permanent Link to', THEME_NAME); ?> <?php the_title(); ?>"><?php the_title(); ?>
                         <?php echo get_the_time('F d, 20y'); ?>
                         <?php bd_comment_number(); ?>                         <?php if( get_post_meta($post->ID, 'bd_rating', true)!=''): ?>
                         <span class="small-star-<?php echo str_replace('.5', '-5', get_post_meta($post->ID, 'bd_rating', true)); ?>">                         <?php endif; ?>

                      <?php endif; ?>                      <?php elseif ( ($type=='thumbnail') ): ?>                     <?php if($is_video): ?>

                                 <a class="video-thumbnail-link" href="<?php the_permalink(); ?>">                                     <?php the_post_thumbnail('video-thumbnail-img', array('class' => '')); ?>                                                                                <a href="<?php the_permalink(); ?>" title="<?php _e('Permanent Link to', THEME_NAME); ?> <?php the_title(); ?>"><?php the_title(); ?>
                                 <?php echo get_the_time('F d, 20y'); ?>
                                 <?php bd_comment_number(); ?>

                          <?php else: ?>
                             <a href="<?php the_permalink(); ?>" class="widget-thumb-link">                                 <?php the_post_thumbnail('mini', array('class' => 'frame effect', 'title' => "")); ?>                                                          <a href="<?php the_permalink(); ?>" title="<?php _e('Permanent Link to', THEME_NAME); ?> <?php the_title(); ?>"><?php the_title(); ?>
                             <?php echo get_the_time('F d, 20y'); ?>
                             <?php bd_comment_number(); ?>                                  <?php if( get_post_meta($post->ID, 'bd_rating', true)!=''): ?>
                             <span class="small-star-<?php echo str_replace('.5', '-5', get_post_meta($post->ID, 'bd_rating', true)); ?>">                             <?php endif; ?>

                      <?php endif; ?>

                      <?php else: // if text ?>
                     <a href="<?php the_permalink(); ?>" class="hover">                         <?php echo get_the_title(); ?>
                 <?php endif; ?>              <?php             endwhile;             if ( $type=='text'){                 echo "
";             }else{                 echo '
';             }             ?>

<?php         }