title: gravity forms jQuery.load into modal

text: I have a gravity forms contact form which resides on a page, but what I want is a site wide link, that will open up that form and display it in a modal, on the fly. One way to go about this would be to just insert the form into the markup on the template side, so that it already exists on each page. But that means that there's a whole lot of markup and gf scripts being loaded that dont for the most part need to be there. So I threw together some js that grabs the form markup from the page and inserts it into the DOM, loads the scripts and then I then display the results in a twitter bootstrap modal. The presentation side of things works as expected - but the none of the js conditional logic etc are getting applied. I know the js is loading as Im feeding the status of each script into console.log - and Im getting "200" and no errors. But its like the scripts can't see the form, or isn't being instantiated properly. To test the js end I also tried loading the resources manually into the head via:               <?php gravity_form_enqueue_scripts(1, true); ?>      But that doesn't work either. Below is the js Im using, anyone have any ideas how to get this to spark life into the form? Is there a callback I should be using?   Many thanks in advance - ben               jQuery(document).ready(function(){     // load contact form with ajax     jQuery(".contact_btn").click(function(){         jQuery.ajaxSetup ({ cache:false });         var ajax_load = "<img height='50px' width='50px' src='/assets/img/medloading.gif' class='tr_spinner' alt='loading...' style='align:center, top:50%' />";         var loadUrl = "/contact-3/";         // load the scripts dynamically         jQuery.when(             jQuery.getScript("/plugins/gravityforms/js/gravityforms.js?ver=1.7.6", function(data, textStatus, jqxhr) {console.log(jqxhr.status);}), // console logs to get confirmation that its loaded             jQuery.getScript("/plugins/gravityforms/js/conditional_logic.js?ver=1.7.6", function(data, textStatus, jqxhr) {console.log(jqxhr.status);}),             jQuery.getScript("/plugins/gravityforms/js/datepicker.js?ver=1.7.6", function(data, textStatus, jqxhr) {console.log(jqxhr.status);}),             jQuery.getScript("/plugins/gravityforms/js/jquery.textareaCounter.plugin.js?ver=1.7.6", function(data, textStatus, jqxhr) {console.log(jqxhr.status);}),             jQuery.getScript("/plugins/gravityforms/js/jquery.maskedinput-1.3.min.js?ver=1.7.6", function(data, textStatus, jqxhr) {console.log(jqxhr.status);})         ).then(function(){         // insert the content into the DOM         jQuery("#contact-form .modal-body").html(ajax_load).load(loadUrl + " .entry-content");         // load it in the modal         jQuery("#contact-form").modal({ keyboard: false, show: true, backdrop: true });         });         // hijack the <a> link         return false;     });     });


title: wordpress option page data from select form is not saving to database

text:
I am going to create a wordpress plugin with a option page and I have created a two page called index.php and options.php and in index.php I have written the following code to create default options value and to add or update option.               <?php         function sis_stt_check_WP_ver(){             $options_array = array(                 'youtube_username' => 'sayful',                  'account_type' => 'none',                  'facebook_username' => 'anik',              );             if ( get_option( 'sis_stt_options' ) !== false ) {                 update_option( 'sis_stt_options', $options_array );             }else{                 add_option( 'sis_stt_options', $options_array );             }         }         register_activation_hook( __FILE__, 'sis_stt_check_WP_ver' );          ?>      I also write the following code to registers our options to be updated and to add an admin page.               <?php         // This function registers our options to be updated.         add_action('admin_init', 'sis_stt_register_settings');              function sis_stt_register_settings(){                  register_setting( 'sis_stt_plugin_options', 'sis_stt_options','sis_stt_validate_data');              }              // add the admin options page              add_action('admin_menu', 'sis_stt_add_menu');              function sis_stt_add_menu(){                 add_options_page( 'sis stt demo', 'sis stt demo', 'manage_options', 'plugin-folder/options.php');              }          ?>      In options.php file I have written the following code to display my option. When I install plugin it show default data in option page but when I change data only the first two fields data save but the data selected from select field does not save at all. What can I do and how can I fix this bug. Help me someone please.

WordPress Standard Coding
     <form method="post" action="options.php">         <?php $options = get_option( 'sis_stt_options' ); ?>              <?php settings_fields('sis_stt_plugin_options'); ?>         <?php do_settings_sections( 'sis_stt_plugin_options' ); ?>

                            <?php _e('YouTube Username') ?>             	                            <input type="text" name="sis_stt_options[youtube_username]" id="youtube_username_input" value="<?php esc_attr_e($options['youtube_username']); ?>" class="" placeholder="Scroll to top">

                            <?php _e('Facebook Username') ?>             	                            <input type="text" name="sis_stt_options[facebook_username]" id="facebook_username" value="<?php esc_attr_e($options['facebook_username']); ?>" class="" placeholder="Scroll to top">

                            <?php _e('Select Account Type') ?>             	                              <select name="sis_stt_options[account_type]">                    <option value="slide" <?php selected( $options['account_type'], 'slide' ); ?>>Slide</option>                    <option value="social" <?php selected( $options['account_type'], 'social' ); ?>>Social</option>                    <option value="none" <?php selected( $options['account_type'], 'none' ); ?>>None</option>                </select>

<input type="submit" value="<?php _e('Save Changes') ?>" class="button button-primary" id="submit" name="submit">
       </form>


title: jQuery UI styles conflicting with TinyMCE dialog

text: I'm using jQuery UI for a few custom controls on the page edit screen and I've noticed that the styling of the jQuery UI dialogs are conflicting with the TinyMCE dialog. Specifically the buttons and title area look especially bad. I've looked through the jQuery UI css to see what could be removed to avoid any conflicts and they're spread pretty much throughout the whole stylesheet. Is there a way to run both together without conflicting?


title: error messages in dashboard login

text: I have included the following into my wp-config.php file:               define( 'FORCE_SSL_LOGIN', true );     define( 'FORCE_SSL_ADMIN', true);      But getting these error messages at the login screen for my WP dashboard: Notice: Constant FORCE_SSL_LOGIN already defined in D:\xampp\htdocs\wordpress01\wp-config.php on line 102 Notice: Constant FORCE_SSL_ADMIN already defined in D:\xampp\htdocs\wordpress01\wp-config.php on line 103 Kindly explain why I am getting these error messages and how I can rectify the situation to force ssl login.


title: SQL Database Lost

text: I lost my database and when they restored the files, I had two files in a database directory that I assume are the data for my database. How do I recover my database using these two files. wp_options.MYI and wp_options.MYD Thanks


title: wordpress user profile page

text: in my web site I have some authors. I would that clicking on authors name, a page is opened with his contact details. How can I do? Thanks a lot


title: Rewrite all article pictures to link to file

text: I got a wordpress blog with thousands of articles. The problem: I want to use a lightbox plugin(http://wordpress.org/plugins/fancybox-for-wordpress/) but in order to work the pictures in an article have to link to the file. At the moment all pictures link to the attachment page. I already changed image_default_link_type to file, but that only applies to new articles of course. What's the best way to solve this problem?


title: Is there a way to embed a Google Docs form in a page without using plugins?

text: I'm currently running a Wordpress blog. It's part of a school blog, so unfortunately, I don't have the permissions to install any plugins. I've got a "contact form" set up as a Google Docs form. Right now, I have a page linking to the form. Is there any way that I can embed it directly in the page without having to install a plugin?


I have some strange error or may be I do not have the skills to tackle this issue. I am building a plugin for Multisite. When is use `is_admin()`, my plugin works fine but when I use `is_super_admin` it shows me this error `Fatal error: Call to undefined function wp_get_current_user()`. I did my search but could not be able to find any solution. My Code is this               if(!is_super_admin()){         add_action('widgets_init','my_unregister_widdget');         function my_unregister_widgets() {             unregister_widget( 'WP_Widget_Pages' );             unregister_widget( 'WP_Widget_Calendar' );         }     }      I saw this question  but it's not helping me.


title: What is the best way to achieve unique Member functionality?

text: im a developer that is somewhat new to wordpress. I have a client that is a wedding planner and wants to create a basic membership (paid) site where women can join and create checklists, budgets, seating charts ect for their wedding. All of this will be private to only them and used as a way to manage their wedding. My question: Is there a good way utilizing existing plugins (or a combination of them) to create a membership system where users can generate unique, private content. It seems plugins like Wishlist member are only for selling gneral courses or content that is not user specific. Is buddypress what im looking for? Or am i better off building this from scratch? Any suggestions are welcome. Thanks!!


title: Executing Javascript When a Widget is Added in the Backend

text: I have widgets that have javascript controls attached to them. If the widget is present when the widget admin page loads, the controls work correctly. When I add a new widget, they do not work correctly, I get the markup, but no javascript events take effect. If I save the new widget, when the form reloads, the controls are created correctly and now work. Refreshing the page also fixes the issue, but only for existing widgets. New widgets have this issue still. Specifically I'm running selectize on select inputs at these points:   * document ready   * Ajaxcomplete I've verified that my code is run on each event as desired, but the results are not as expected. Here is a test plugin that demonstrates the issue: https://gist.github.com/Tarendai/8466299 You'll see I have a counter that increases with every select element it finds that it can convert. Notes:   * When the widget page loads, I can see the counter increasing in the JS console as expected   * When I add a new widget, the code is run, however, it fails to find any select elements it can run on, as demonstrated by found.length being 0. This should not be the case, as every new widget of that type should have a select element   * select elements have a class to identify them, this class is removed once the selectize library is applied to prevent duplication and re-processing on existing widgets.   * Prior to using selectize, I used Select2, which had the same issue   * Commenting out the AJAX code, I would expect new widgets to have a standard select input. They do not. I don't know why this is the case So how do I make the selectize control work without telling the user to refresh/click save prior to making changes?


title: Allow user to manually set crop area of default/custom image sizes on upload

text: I'm looking for a plugin that allows the user to define where the image will be cropped for a given thumbnail size. For example, the user uploads an image, a screen comes up with the image and a selection box, and asks her to move/resize the image within the selection for size 'medium'. I've found two plugins that allow the user to do this after the thumbnail has been uploaded: Post Thumbnail Editor and Crop-Thumnails. Either of these might work, but does anyone know of a plugin that will ask for this on upload? Thanks!


title: How to get the post excerpt using post object?

text: I'm trying to show post excerpt as in navigation. I'm trying this in plugin, does it make any sense? i don't know. I used `$nex_obj = get_adjacent_post(false, '', true);` for next post and it returns post object when i try to show the post excerpt using `$nex_obj->post_title` as in. This doesn't work out. So i tried `echo $excerpt = apply_filters('get_the_excerpt', $nex_obj ->post_excerpt);` but this throws error `Fatal error: Maximum function nesting level of '100' reached, aborting!` Is this correct or wrong? I'm trying this in localhost. So finally i tried loop to get the excerpt based on the id Default loop               $id=$nex_obj->ID;              if (have_posts()) :            while (have_posts()) :         if($id==get_the_ID()){             the_excerpt();         }            endwhile;         endif;      The above loop keep on running the browser and making it unresponsive. I think i'm doing this in wrong way, i heard i shouldn't use default loop. So skipped this and tried another query loop without any argument as i don't need any filter on particular post                    query_posts($args);         // The Loop     $id=$nex_obj->ID;             while (have_posts()) : the_post();              if ($id== get_the_ID()) {               echo $excerpt = get_the_excerpt();                      }         endwhile;              // Reset Query          wp_reset_query();      How to get excerpt of post with post ID or something ? All i have is post Object


title: Custom jQuery plugin not working

text: I'm trying to use this addon: http://trentrichardson.com/examples/timepicker/ to make it possible to edit a post date and time in the frontend before submitting it. I'm registering my scripts like this:               function theme_name_scripts() {             wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');          //TIMEPICKER     wp_enqueue_style( 'timepicker', get_stylesheet_directory_uri() . '/js/timepicker/jquery-ui-timepicker-addon.css' );     wp_enqueue_script('timepicker', get_stylesheet_directory_uri() . '/js/timepicker/jquery-ui-timepicker-addon.js', array('jquery', 'jquery-ui-core', 'jquery-ui-slider', 'jqueryui-datepicker', ), '1.4.3' );          wp_enqueue_script('modernizr');          //LEAFLET     wp_enqueue_style( 'leaflet', get_stylesheet_directory_uri() . '/js/leaflet/leaflet.css' );     wp_enqueue_script('leaflet', get_stylesheet_directory_uri() . '/js/leaflet/leaflet.js' );     }          add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );      Integrated datepicker is working fine, but as I want to use the timepicker as well I get this error message:               TypeError: jQuery(...).datetimepicker is not a function      So I was wondering what causes this error. Is it maybe, because the addon uses $ instead of jQuery? http://trentrichardson.com/examples/timepicker/jquery-ui-timepicker-addon.js


title: SQL Query in WordPress - Getting Impossible WHERE error

text: I don't get any result in the SQL query below. I am trying to find user_id of users with custom usermeta fields.               SELECT         DISTINCT user_id         FROM wp_usermeta         WHERE (             (                 (meta_key='user_school_subjects' AND meta_value LIKE '%history%')                 OR (meta_key='user_professional_courses' AND meta_value LIKE '%history%')                 OR (meta_key='user_language_tutoring' AND meta_value LIKE '%history%')                 OR (meta_key='user_music_tutoring' AND meta_value LIKE '%history%')             )             AND (meta_key='user_gender' AND meta_value='male')         )      When I run the query in SQL PHPMYADMIN, I get an error -> **Impossible WHERE Query** What's wrong with the query? Please help me fix the error in the above query. UPDATE: Here is the full search query being built using a form.               global $wpdb;              $user_ids = array();         $user_query = null;              if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) ) {             $s = $_REQUEST['search'];             $user_query .= "((meta_key='first_name' AND meta_value LIKE '%".$s."%') OR (meta_key='last_name' AND meta_value LIKE '%".$s."%') OR (meta_key='display_name' AND meta_value LIKE '%".$s."%') OR (meta_key='user_nicename' AND meta_value LIKE '%".$s."%') OR (meta_key='user_login' AND meta_value LIKE '%".$s."%'))";         }              if (isset($_REQUEST['email']) && !empty($_REQUEST['email']) ) {             $s = $_REQUEST['email'];             if ($user_query) {             $user_query .= " AND (meta_key='user_email' AND meta_value='".$s."')";             } else {             $user_query .= "(meta_key='user_email' AND meta_value='".$s."')";             }         }              if (isset($_REQUEST['subject']) && $_REQUEST['subject'] !='' ) {             $s = $_REQUEST['subject'];             if ($user_query) {             $user_query .= " AND ((meta_key='user_school_subjects' AND meta_value LIKE '%".$s."%')";             $user_query .= " OR (meta_key='user_professional_courses' AND meta_value LIKE '%".$s."%')";             $user_query .= " OR (meta_key='user_language_tutoring' AND meta_value LIKE '%".$s."%')";             $user_query .= " OR (meta_key='user_music_tutoring' AND meta_value LIKE '%".$s."%'))";             } else {             $user_query .= "((meta_key='user_school_subjects' AND meta_value LIKE '%".$s."%')";             $user_query .= " OR (meta_key='user_professional_courses' AND meta_value LIKE '%".$s."%')";             $user_query .= " OR (meta_key='user_language_tutoring' AND meta_value LIKE '%".$s."%')";             $user_query .= " OR (meta_key='user_music_tutoring' AND meta_value LIKE '%".$s."%'))";             }         }              if (isset($_REQUEST['location']) && $_REQUEST['location'] !='' ) {             $s = $_REQUEST['location'];             if ($user_query) {             $user_query .= " AND ((meta_key='user_address' AND meta_value LIKE '%".$s."%')";             $user_query .= " OR (meta_key='user_zipcode' AND meta_value LIKE '%".$s."%'))";             } else {             $user_query .= "((meta_key='user_address' AND meta_value LIKE '%".$s."%')";             $user_query .= " OR (meta_key='user_zipcode' AND meta_value LIKE '%".$s."%'))";             }              }              if (isset($_REQUEST['gender']) && !empty($_REQUEST['gender']) ) {             if ( $_REQUEST['gender'] != '') {                 $s = $_REQUEST['gender'];                 if ($user_query) {                 $user_query .= " AND (meta_key='user_gender' AND meta_value='".$s."')";                 } else {                 $user_query .= "(meta_key='user_gender' AND meta_value='".$s."')";                 }             }         }              if (isset($_REQUEST['status']) && !empty($_REQUEST['status']) ) {             if ( $_REQUEST['status'] == 'active') {                 $s = $_REQUEST['status'];                 if ($user_query) {                 $user_query .= " AND ( (meta_key='user_membership' AND meta_value='active')";                 $user_query .= " OR (meta_key='user_availability' AND meta_value='available'))";                 } else {                 $user_query .= "((meta_key='user_membership' AND meta_value='active')";                 $user_query .= " OR (meta_key='user_availability' AND meta_value='available'))";                 }             }             elseif ( $_REQUEST['status'] == 'inactive') {                 $s = $_REQUEST['status'];                 if ($user_query) {                 $user_query .= " AND ((meta_key='user_membership' AND meta_value='".$s."')";                 $user_query .= " OR (meta_key='user_availability' AND meta_value='unavailable'))";                 } else {                 $user_query .= "((meta_key='user_membership' AND meta_value='".$s."')";                 $user_query .= " OR (meta_key='user_availability' AND meta_value='unavailable'))";                 }             }         }              if (isset($_REQUEST['nationality']) && $_REQUEST['nationality']!='any' ) {             $s = $_REQUEST['nationality'];             if ($user_query) {             $user_query .= "AND (meta_key='user_nationality' AND meta_value='".$s."')";             } else {             $user_query .= "(meta_key='user_nationality' AND meta_value='".$s."')";             }         }                   if (!empty($user_query)) {             $wp_users = $wpdb->get_results("SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE ($user_query)"); }      EDIT: You can find the answer here: http://stackoverflow.com/questions/3735176/compex-mysql-left-join-using- multiple-entries-from-meta-tables


title: Can Wordpress resize BMP files?

text: Interesting situation i just ran into. I have a site I am developing in which I have defined specific image sizes I want created whenever a new image is uploaded. Currently lets just say that I defined a specific thumbnail size of 75x75 and a medium sized image of 150x150 pixels. Assuming we proceed to upload a new image using the built in media uploader we would expect that Wordpress will automatically upload and store the original image along with any additional images sizes which I have specified in my functions.php file (in this case the 75x75 and 150x150 pixel images). First of all, the above illustrated example is indeed working perfectly and I am very happy with the results. What I have noticed though is that **when you pick a bmp file** to upload the automatic resizing does not take place. My objective here is to figure out who else might have noticed this issue while attempting to find a solution for this problem. I need to ensure that even when a large bmp file is uploaded that the code               the_post_thumbnail( array(50,50), 'class=alignleft' );      will show the 50x50 pixel image. Just in case anyone is interested, I have confirmed this issue is specifically related to bmp image by taking the original bmp image and saving it as a jpg and png file through photoshop and then using the wordpress media manager to upload the same files converted by photoshop... In both cases I noticed that after uploading each converted file the exact same images WERE correctly being resized. I should also point out that when a bmp file image was uploaded the actual upload of that file DID take place however in the media manager only the original (full size) image was available to insert into posts and checking the media upload folder also only showed a single image. Any guidance, help or diagnosis is greatly appreciated!


title: Creating Secondary Menu - all steps required?

text:
I am using retro hipster theme and have been able to add secondary menu with details. I've read regarding adding array in functions.php and then calling both nav in the header.php. However one menu is displayed vertically above primary menu and other header details. How do I get it where I want it - which is secondary menu above the header and vertical and static - it is shopping cart menu for woocommerce. I want it sticky so always viewed. Also I assume that CSS is needed to be added for the secondary menu? functions.php               register_nav_menus( array(       'primary' => __( 'Primary Menu', 'mytheme' ),
       'secondary' => __( 'Secondary Menu', 'mytheme' ),
     ) );      In the header.php -- is it added in a specific location?               <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>     <?php wp_nav_menu( array( 'theme_location' => 'secondary' ) ); ?>


title: is_home() and is_single() Not Working as Expected with Custom Post Types?

text: ( **Moderators note:** Was originally titled: _"Custom post type problem?"_ ) I'm having some problems with custom post types where everything is working great except for the sidebars. Here is some code from my `sidebar.php`:               <?php       if (is_home()) {         dynamic_sidebar('frontpage-sidebar');       }       if (is_single()) {         dynamic_sidebar('single-post-sidebar');       }       ....     ?>      Normally this works ok except for when I open a single page to check post `'frontpage-sidebar'` is not loading as the `'single-post-sidebar'` is loading instead. Where is the problem? Here is the code for my custom post type:               $labels = array(       'name' => _x('Tools', 'post type general name'),       'singular_name' => _x('Tool', 'post type singular name'),       'add_new' => _x('Add New', 'Tool'),       'add_new_item' => __('Add New Tool'),       'edit_item' => __('Edit Tool'),       'new_item' => __('New Tool'),       'view_item' => __('View Tool'),       'search_items' => __('Search Tools'),       'not_found' => __('No Tools found'),       'not_found_in_trash' => __('No Tools found in Trash'),       'parent_item_colon' => ''     );     $args = array(       'labels' => $labels,       'public' => true,       'publicly_queryable' => true,       'show_ui' => true,       'query_var' => true,       'rewrite' => true,       'capability_type' => 'post',       'hierarchical' => false,       'menu_position' => 2,       'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments','page-attributes') // 'not sure that post can have page-attributes ????'     );     register_post_type('tools', $args);      How do I load different sidebars on different pages when using custom post types instead of ordinary posts? Thanks.


title: How to cache json with wp-super cache

text: In a new project we are using wp-super-cache (the client's preferred plugin) to create the static html files for custom content types. But we are trying to figure out if everything is being cached properly. This is a 2 part question. 1) The theme we have created utilizes page templates to output json that is ingested via ajax calls. ie. if you hit the page: theurl.com/sample - you will get pure json. While there is a non-javascript version of every page and post, Ajax drives the front end of this theme. We have removed the header and footer in these files so that it is pure json, and we are trying to figure out how to determine if the json is being cached. In theory the data would be cached because it is technically a page served up by wordpress. But, how can we figure out if it is being cached? 2) We are using the json api plugin to serve up certain post data as well. http://wordpress.org/extend/plugins/json-api/ For this example, let's say we are utilizing the plugin's default method of output and hitting this page: my url.com/category/news?json=1 - Does anyone know how we can verify if this output is being cached? If it isn't being cached, what method would make this happen? There doesn't seem to be much information about this online, so in the spirit of creating compelling and optimized wordpress sites, help a brother out


title: Can I refresh the thumbnails programmatically?

text: I would like to be able to refresh the thumbnail cache programmatically, not sure where to hook it, but at present any design changes mean re-uploading loads of images!


title: Wordpress crop tool greyed out

text: The wordpress crop tool is greyed out for me in Firefox 3.6 (and IE7/8). I have disabled firefox add-ons and tried the solution here: http://wordpress.stackexchange.com/questions/1597/wordpress-image-editor-not- working-conflict But this hasn't resolved the issue. Anyone know how wordpress determines whether to enable the crop button? WP version is 3.0.1 thanks,


title: What do add_filters() and apply_filter() do?

text: I'm a bit confused as to why this isn't working - although it must be said I'm not that sure what `apply_filters()` and `add_filter` are doing, so any general tips would be great too! I want a query that brings up the five earlier posts on a single post page. I am sending the current post's date off, and want to apply a filter that filters out posts earlier than this.               function sw_filter_posts_before( $where = '', $date) {              $where .= " AND post_date < '" . $date . "'";         return $where;     }      How do I correctly apply this? Simply using add_filter or apply_filter before instantiating a new WP_Query object doesn't seem to work correctly. Thanks in advance! Edit: To go into things further, I would like to understand how to pass a variable into the filter, as I can't get $date to pass from another function. Here is said other function (it is an ajax call within wordpress, hence I start by getting the post ID for the current page through a $_POST variable):               function create_more_videos_sidebar() {              $id = $_POST['theID'];              $args = array(  'post_type'         =>  'videos',                         'posts_per_page'    =>  1,                         'p'             =>  $id                     );               $wp_query = new WP_Query($args);              while ($wp_query->have_posts()) : $wp_query->the_post(); $do_not_duplicate = $post->ID;                  $date = get_the_date('Y-m-d');              endwhile;              $args = array(  'post_type'         =>  'videos',                         'posts_per_page'    =>  5                     );               add_filter( 'posts_where', 'sw_filter_videos_before' ); //don't know how to pass $date                   $wp_query = new WP_Query($args);         remove_filter( 'posts_where', 'sw_filter_videos_before' );              //do loop stuff              $response = json_encode( array( 'result' => $result ) );              header( "Content-Type: application/json" );         echo $response;              exit;     }


title: is there an update_post_meta action

text: Are there any actions I can hook into for update_post_meta()? I don't see anything obvious in the source. Woocommerce lets you change the featured status of items via ajax from the edit screen. I am using a transient to store the featured items in lieu of querying them every time and I'm deleting that transient on the save_post hook, but it isn't getting fired because of the ajax function that directly updates the post meta. Worst case I can unhook woo's action and recreate it myself with the delete transient call, but I'm wondering if there is another hook i could use.


title: Call Current Category

text:
I'm using this in a file named category-portfolio.php which is for the archives page of my portfolio. I don't want to use cat= to specify a specific category. But when I don't use cat= it pulls up every post regardless of category. How do I make this code pull up only the current/relevant/portfolio category? Thanks a million!               <?php get_header(); ?>

               <?php     query_posts('posts_per_page=9&paged='.$paged);      if (have_posts()) :     ?>
     <?php while (have_posts()) : the_post(); ?>
     <a href="<?php the_permalink() ?>">               <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thmb-portfolio' ); } ?>               <?php the_title(); ?>
<?php my_excerpt('short'); ?>

          <?php endwhile; ?>               <?php if (function_exists("pagination")) {         pagination($additional_loop->max_num_pages);     } ?>
               <?php endif; ?>
     <?php get_sidebar(); ?>

     <?php get_footer(); ?>


title: How to make wp-signup.php a 1-step process

text: I'm developing a multisite for Real Estate agents. Wp-signup.php used the wrong page template from my theme (homepage instead of full width page template), so I took the meat and potatoes from wp-signup.php and created a page template out of it. Here's the result: [http://thewebrockstar.com/realestate/signup/][1] However now step 2 (after you hit Next) redirects away from my wp-signup page template to the original wp-signup.php. Is there a solution to this? I was thinking it would be easiest to make wp- signup.php a 1-step process (everything on a single page) instead of this: http://i.stack.imgur.com/PTP74.jpg


title: Control attachments menu order with jQuery Sortable

text: I've managed create a metabox that lets me upload and then fetch the images and then also been able to add jquery ui sortable to be able to sort the images, however I've no idea how to add actual functionality so that the sort order get saved. If someone has an idea how to achieve this or some tutorial that would be helpful, please share, I'm helplessly stuck here. Thanks.    Edit: Basically, what I need to know is how to tie jQuery sortable together with the functionality that handles the different attachments menu_order.


title: Duplicate settings of master blog to slave blogs in WP multi-site installation

text: Is there any smart way to set a site (blog) as a master, which settings are replicated to the rest of the sites in the network? There are plugins like this one: YD Network-wide WPML that attempt to accomplish this, but they don't support all settings.


title: Is there a capability for managing plugin options?

text: I have an Editor user that I want to let use a plugin's options without being an Administrator. I can use $user->add_cap but can't tell if any particular capability relates to the permission to edit plugin options. The plugin in question is Redirection, if that makes a difference.


title: Upload photos to WordPress via ftp w/ [gallery] shortcode?

text: Is there a way to upload photos to WordPress via FTP instead of uploading them one by one through the dashboard? Also, does WordPress' built in gallery allow commenting on each individual photo? If not, are there any simple gallery plugins out there that has this feature built-in?


title: In a foreach loop, how do I target the last item in the loop?

text:
I have the following code to do a foreach loop, I want to target the last item in the loop (e.g if it's looped over 3 events I want to target the 3rd event) to do something slightly different with the css. How would I do that?               <?php $pages = get_pages(array('child_of' => $post->ID, 'sort_column' => 'menu_order'));         foreach($pages as $post)         {         setup_postdata($post);         $fields = get_fields();     ?>
         <img class="event-thumbimage" src="<?php echo $fields->thumb_image; ?>" height="120" width="140" alt="<?php echo $fields->event_title; ?>" />
<?php echo $fields->event_title; ?>

             Location: <?php echo $fields->location; ?>
             Start: <?php echo $fields->start_date; ?> at <?php echo $fields->start_time; ?>             <?php $fields = get_acf(); if($fields->end_date != "") : ?>             , End: <?php echo $fields->end_date; ?> at <?php echo $fields->end_time; ?>             <?php else : ?>             <?php endif; ?>

<?php echo substr($fields->description,0,170) . "..."; ?>

<a class="read-more" href="<?php echo get_page_link($post->ID); ?>" title="Read more about: <?php echo $fields->event_title; ?>">Read more...

     <?php } wp_reset_query(); ?>


title: Where should I add the necessary code to add an extra attribute to the kses allowed tags array?

text: In trying to post an article on one of the new SE blogs, I came across the following problem. I'm listed as an _author_ which means that my abilities are somewhat restricted. In particular, I'm not allowed to post _arbitrary_ HTML, rather my entries are sent through the kses parser first. This seems a Good Thing in general (I don't want to be held responsible for the HTML!) but it interferes with one piece of the Markdown processor: quotes. I can't write:               > this is a quote      because the `>` gets escaped by the kses routines. Now, modifying the kses code to allow that through is tricky, and is the Wrong Solution (because it would make the `kses` parser knit too tightly to the Markdown one; actually, the Right Solution would be to validate the data _after_ it had been processed, but never mind ...). This isn't a big problem because, of course, I can just use the `<blockquote>...</blockquote>` tags directly. Only that turns off the Markdown processor inside it. Since we're using PHPMarkdownExtra (at least, tests seem to indicate that we are), I can use the `markdown="1"` fake attribute to turn on Markdown inside the blockquote. But this gets taken out by kses as it's not on the list of approved attributes! However, adding `markdown` to the list of approved attributes seems much easier than adding support for the `> quote` syntax; in particular there is an array `$allowedposttags` that holds this information so it would mean simply changing that array in an obvious way. But, and this is the question, where is the right place to do that modification? Clearly, modifying `kses.php` is the Last Resort. My _guess_ would be that the Right Place would be for the `markdown.php` file to do this modification (since that's the file that knows that Markdown is going to be used). But if I don't want to change anything that might be changed upstream, where should I put the required change? (When I say "I" in the above, I don't actually mean "me" since I want this to be changed on the SE blogs; so please explain it in language that Rebecca Chernoff can understand!)


title: Show last 2 image attachments from posts

text: How can i show the last 2 post attachments in my category template? I tried the following But i need to show the last 2 post image attachments if i have the following code               function show_all_thumbs() {         global $post;         $post = get_post($post);         /* image code */         $images =& get_children( 'post_type=attachment&post_mime_type=image&output=ARRAY_N&orderby=menu_order&order=ASC&post_parent='.$post->post_parent);         if($images){             foreach( $images as $imageID => $imagePost ){                 unset($the_b_img);                 $the_b_img = wp_get_attachment_image($imageID, 'thumbnail', false);                 $thumblist .= ''.$the_b_img.'';             }         }         return $thumblist;     }      to display then how can i limit the output of images displayed


title: register_sidebar fails when using a include within functions.php

text:
I have registered several sidebars via functions.php like this:               // Register sidebars     function register_widgets() {          // Main sidebar       register_sidebar( array(         'name' => __( 'Main Sidebar', 'Core' ),         'id' => 'main',         'description' => __( 'The main sidebar appears on the right on each page except the front page template and blog.', 'Core' ),         'before_widget' => '',         'after_widget' => '',         'before_title' => '
',         'after_title' => '
',       ) );     }     add_action( 'widgets_init', 'register_widgets' );      As I'm adding more than one sidebar, I'd like to move the code to an include. This is what I have now in functions.php:               // Load widgets     require_once("includes/widgets.php");      Now that I've moved the sidebar code from functions.php, my theme no longer displays any widget options via Appearance > Widgets. I can't see that I've made any errors. What have I done wrong?


title: Setting a title on a Custom Post Type that doesn't support titles

text: I have a CPT called "profile" that only supports the editor and thumbnail. Each user is limited to posting just 1 profile. I'm looking for a way to prefill the title and slug fields with the display name of the post author. As it is now, if I click on Publish, the post_status in the db is "Auto Draft" and the URL becomes "localhost/mytestsite/profile/auto-draft-1". It seems WP **needs** a title or else it won't be considered "Published". I've checked several questions already posted here and this one seems like the one I need. Custom Post Type with Custom Title But since I want the author's name and not values in a taxonomy or custom field, I don't know how to modify the code to reflect that. I see that get_the_author() needs to be in The Loop.


title: Posts to have category specific sidebars with the widgets

text: I'm using the Divi theme to build my website.My client wants News and Blog page on the same site, so I did this by using categories. My problem is how to achieve category(i.e News and Blog) specific sidebars? By default, posts uses the default sidebars. I set the default sidebar to my Blog page. I've installed the widget logic plugin also. Please help me to solve this scenario with the plugin.


title: Pinterest Chrome/Safari Extension not working on WordPress Site

text: I am working on a client WordPress website - http://simplyconvivial.com. For some reason the Pinterest Chrome/Safari extension is not pulling the images correctly on this site. When you click on the Pinterest button using the Chrome extension - it brings up the images but I am unable to select any of the images for pinning. Instead I see the little pencil edit button in the lower right hand corner.   * I have tried deleting old plugins and updated existing plugins.    * I have updated to the latest version of Chrome with still no luck.    * I have installed the jQuery Pin It plugin so that the "Pin It" button hovers over the image - which wasn't working before but now it is. I'm wondering if there is some code within the site that is causing the conflict. What could be causing this and how can I resolve this? Here are the plugins she has installed:   * Askimet   * eStore Order Management   * eStore Stylish Squeeze Form Addon   * extra Shortcode for WP eStore   * Google XML Sitemap   * Hello Bar   * Jetpack    * jQuery Pin It   * SendGrid   * Theme Check   * W3 Total Cache   * What Would Seth Godin Do   * WP Editorial Calendar   * WordPress SEO   * WP Affiliate Program   * WP eMember   * WP eStore Theme is custom-build theme.


title: 2nd post different layout

text:
As a designer I'm the ***hole who makes different layouts for posts to make a page more different. Due to this, I'm trying to create the following: ![enter image description here](http://i.stack.imgur.com/TP1Cf.png) This is the code I'm currently trying to fix. [EDIT] I've got the styles working, but now the content is being duplicated [/EDIT]               <?php     $query = new WP_Query( array( 'post_type' => array( 'innovation_lab' ) ) );               while ( $query->have_posts() ) : $query->the_post();     $i=0;         if ($i%3==0) echo '
              ';                echo '
                          ';                         echo '
'; the_title(); echo '

';                                                   foreach((get_the_category()) as $childcat) {                                         if (cat_is_ancestor_of(10, $childcat)) {                                         echo 'cat_ID).'" class="category small">';                                         echo $childcat->cat_name . '   /   ';                                         }}                           echo '

';                 echo excerpt(60);                 echo '
';                     echo '';                    echo '
Lees meer

';                                   the_post_thumbnail('', array('class' => 'pull-right img-responsive img-samenvatting'));                                   echo '

';                             if ($i%3==2) echo '                        ';                echo '

';                     the_post_thumbnail('', array('class' => 'pull-right img-responsive img-samenvatting'));                echo '

                          ';                         echo '
'; the_title(); echo '

';                                                   foreach((get_the_category()) as $childcat) {                                         if (cat_is_ancestor_of(10, $childcat)) {                                         echo 'cat_ID).'" class="category small">';                                         echo $childcat->cat_name . '   /   ';                                         }}                           echo '

';                 echo excerpt(60);                 echo '
';                     echo '';                    echo '
Lees meer

';                   if ($i%3==3) echo '
';                    $i++;     endwhile;               ?>      PS: Please don't judge my PHP..


title: Page template for blog not working

text: So I have a general template called home.php for displaying all blog posts. All fine. No I've wanted to add the same thing with sidebar, so I've copied it, added sidebar, called home-sidebar.php, added the comments... all fine. I've went to backend, pages, chose the template and nothing. Still the same. It seems like no matter what I do I can not change the template for a page that displays all posts (the blog). In other pages it works fine. What is going on? And don't send me to hierarchy pages - I've got one printed out right in front of me.


title: Change gravity forms confirmation redirect query string to include entry id

text: I need to somehow insert the entry id from a Gravity Forms submission into a redirect confirmation. My problem is, that when attempting to create a confirmation via the admin interface, I _can_ insert the entry id into a hidden field, but it doesn't exist until after everything fires, rendering my query string blank (although the others do still work). I was thinking that by hooking into `gform_confirmation`, I would have access by grabbing the confirmation before it happened and changing it on the fly but that doesn't seem to be working either. Here's what I currently have entered into my **functions.php** :               add_action("gform_confirmation", "custom_confirm", 10, 4);     function custom_confirm($confirmation, $form, $lead, $is_ajax){              $url = $confirmation . "&rma" . $lead['id'];              $confirmation = array('redirect' => $url);          }      As you can see, I'm simply trying to tack on "&rma=[ _entry-id_ ]" although I'm not sure `$lead['id']` is even the right variable I need to be accessing. Also not sure if the last assignment is changing the URL in the proper way. TL;DR: I need to change the confirmation redirect to include the entry ID and I'm wondering if it's even possible.


title: Advantages and disadvantages of using automatic-feed-links

text: What are the **advantages** and **disadvantages** of using `add_theme_support('automatic-feed-links')` in my `functions.php` file?


title: Warning: spl_autoload() [function.spl-autoload] (Term Menu Order)

text: I'm developing a site and found this error on top of every page of the site:               Warning: spl_autoload() [function.spl-autoload]: Unable to access k35r0vc.class.php in /home/stopecom/public_html/wp-content/plugins/term-menu-order/term-menu-order.php on line 42          Warning: spl_autoload() [function.spl-autoload]: Unable to access k35r0vc.class.php in /home/stopecom/public_html/wp-content/plugins/term-menu-order/term-menu-order.php on line 42          Warning: spl_autoload() [function.spl-autoload]: Unable to access k35r0vc.class.php in /home/stopecom/public_html/wp-content/plugins/term-menu-order/term-menu-order.php on line 42          Warning: spl_autoload() [function.spl-autoload]: Unable to access k35r0vc.class.php in /home/stopecom/public_html/wp-content/plugins/term-menu-order/term-menu-order.php on line 42          Warning: spl_autoload() [function.spl-autoload]: Unable to access videopress.class.php in /home/stopecom/public_html/wp-content/plugins/term-menu-order/term-menu-order.php on line 42          Warning: spl_autoload() [function.spl-autoload]: Unable to access polldaddyshortcode.class.php in /home/stopecom/public_html/wp-content/plugins/term-menu-order/term-menu-order.php on line 42          Warning: spl_autoload() [function.spl-autoload]: Unable to access vaultpress.class.php in /home/stopecom/public_html/wp-content/plugins/term-menu-order/term-menu-order.php on line 42          Warning: spl_autoload() [function.spl-autoload]: Unable to access k35r0vc.class.php in /home/stopecom/public_html/wp-content/plugins/term-menu-order/term-menu-order.php on line 42          Warning: spl_autoload() [function.spl-autoload]: Unable to access k35r0vc.class.php in /home/stopecom/public_html/wp-content/plugins/term-menu-order/term-menu-order.php on line 42          Warning: spl_autoload() [function.spl-autoload]: Unable to access wp_user_search.class.php in /home/stopecom/public_html/wp-content/plugins/term-menu-order/term-menu-order.php on line 42      It only happens in live server though. When I tried it on localhost, there is no problem there. I realize it's a problem caused by a plugin, Term Menu Order. I've been trying to look for more information regarding `spl_autoload`, I also have tried to consult the author via support forum. However I hardly can deduct anything from my search results, and because the author's last reply was almost a year ago, I'm starting to get pessimistic. Why is it happening only in live servers, and is there any way to fix this?


title: List only categories i specify

text: Ok, so this site's navigation is built up from Categories. However, my client wants specific grouping of the navigation items, ie.               x     y     z     ----     1     2     ----     3     4     ----     6      There is no conceivable way to group these logically. So i think my best bet is to just do something like `echo WpCat('x')` and `echo WpCat('4')` i know this isnt the code but the general idea is how can i only echo certain category names as and when i need to? Thanks


title: How do I remove a word from a url in Wordpress using .htaccess?

text: In the site I'm building there is a post-type called "Focus". Since they need to url to be like `www.mysite.com/focus/page-post-name` I have the post type slug as "focus". Of course the archive page is `www.mysite.com/focus` this is causing an issue since I need a specific page to be an archive page. Metaboxes are used to build and add settings to pages. I can't just create a page called "Focus" since that is reserved by the post-type. My idea is to create a page called "Our Focus" resulting a URL of `www.mysite.com/our-focus`. I'd like to just remove the "our-" from that url to make it appear that the archive is being used. I've tried setting has_archive to false but that just reverts to using the archive.php page.


title: Highlighting top level link when viewing one of it's sub-pages, which are not linked in the menu

text: I have a page that is not linked in my custom menu. This page has a parent page, which is linked in the custom menu. If I go to the "not-linked" page, I want to to highlight it's parent page link in the menu. I use WordPress 3.0 and there is a possibility to create a custom menu (drag- and-drop - _Appearance_ > _Menus_ ). The custom menu uses a list for menu styling and I would like to add a class to the parent Page link within the `<li>`. I also have pages with two, and top level parents.


title: Has anyone used the wordpress plugin w3-total-cache on a Dreamhost VPS successfully?

text: I was encouraged by Dreamhost to go with FCGI, XCache and w3 total cache. But I'm not sure what the optimal settings are, especially re: the Object and Database cache. Any suggestions? Also, I can't get this error message to go away: `Recently an error occurred while creating the CSS / JS minify cache` Nor can I get log files to show up...


title: Get author posts count after excluding a category

text: I want to display the posts count of each author, but posts that are in some categories should be excluded from the count. I tried doing this with `count_user_posts( $user->ID )`, but this function doesn't have any category excluding options. My second approach was to do this by querying the posts table with mySQL's `COUNT` function, but the category IDs are not stored in that table, so I can´t exclude categories this way. Now, before I do some weird and less performant `JOIN` querys, I hope someone can show me a better way how to do this.


title: Album listing in NGG with gallery open on click of album on same page

text: I am using NextGen gallery plugin. Now I want a listing of albums and on click of album that album name should be in bold letters (active) and whichever album is active, gallery of that album should be displayed in that page. In short I want a structure like this...               Gallery of album 1 ................. ****album1****                                          album2                                          album3      If _album 2_ is clicked then gallery should be of album 2. How can I do that?


title: Trim Post Content on Home Page

text: Whenever I try out a new theme, I select it depending upon preview, which shows latest posts on Home Page, having only trimmed content with featured image and not all long post content. However, when I install the theme on my test system, the preview shows full length content, instead of the preview. How can I solve this problem?


title: WordPress.org API - Get plugin authors favorite plugins

text: There have been some recent additions to the WordPress.org plugin repository. Most notably the changes to the plugin page and the author profile page which now shows an authors favorite plugins. I want to create a sidebar widget plugin that shows a plugin authors favorites. I know how to use the API to get plugin stats and have also read DD32's API Docs but I don't believe docs exist on profiles or if a profile API even exists. I attempted to use `wp_remote_get` and I am able to get the body html from the profile page but haven't attempted to try and parse it yet as it seems a way to messy way of going about it. It would be great if I could get the profile in XML or json. Are there any methods that I'm missing or does a profile API exist? ### Edit: ~~Ok I have a beta version up on github using the SimpleHTML Dom parser. I don't think I will be able to get the star ratings but I'm pretty happy with the results as a first go without an API.~~ WordPress.org does not allow content scraping and will ban you (via @otto). So this is a no go until a public API is released.


title: search form to query textarea within plugin settings

text: I have a form, input text and search button, on the front-end of my site, that pops up when users select 'purchase', this all works great.                <form action="[not sure what goes here]" >     <label>Enter Your Text:</label>     <input type="text" name="values_to_search" value" " />     <input type="submit" value="search"/>     </form>      I would like to be able to insert a bunch of values, comma separated, into textarea field inside a plugin. and search them...with the above form... I have two queries here: 1. what should the action value be in the frontend form? 2. how to search within textarea field of the plugin?


title: How to Modify this $wpdb query to accept an array of post statuses

text: I'm using this function from this accepted answer, which gets all values for a custom field key (cross-post). How could it be modified to allow an array of post statuses?               function get_meta_values( $key = '', $type = 'post', $status = 'publish' ) {         global $wpdb;              if( empty( $key ) )         return;              $r = $wpdb->get_col( $wpdb->prepare( "             SELECT pm.meta_value FROM {$wpdb->postmeta} pm             LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id             WHERE pm.meta_key = '%s'              AND p.post_status = '%s'              AND p.post_type = '%s'         ", $key, $status, $type ) );              return $r;     }      eg something like this (doesn't work)               function get_meta_values( $key = '', $type = 'post', $status = array( 'publish', 'draft' ) ) {         global $wpdb;              if( empty( $key ) )         return;              $r = $wpdb->get_col( $wpdb->prepare( "             SELECT pm.meta_value FROM {$wpdb->postmeta} pm             LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id             WHERE pm.meta_key = '%s'              AND p.post_status = '%s'              AND p.post_type = '%s'         ", $key, $status, $type ) );              return $r;     }


title: How to change the language of the 'Reset Password' page

text: I have a WooCommerce powered WordPress website. In this website a user can login to order products, basic WooCommerce functionality. The site is translated using qTranslate. I can translate everything, except the 'Reset password' page. The basic website is in English. When a customer visits the website in French, then requests a new password, he is redirected to the WordPress page but in English. Is there a possibility I can alter this (e.g. using a querystring, calling an hook, ...)? Thanks in advance!


title: Integrate plugins s2Member with MailChimp

text: i follow the tutorial at http://www.mysecondmillion.com/s2member-install- setup-mailchimp/ configured as what its said, but still not get the s2Member subscriber added to mailchimp list. I've set mailchimp API configuration , and check the option to subscribe at form registration,. Im using s2member as membership system to unlock downlad page area. when user register, the sign-up/registration form is showed from s2Member label form,, not mailchimp. is that why my subscribers doesn't added to mailchimp list? if i have to show mailchimp subscription/registration form, then how i connect it with my s2member registration and still get level restriction access?


title: Add field to post form

text: I have read this tutorial to create forms da compilare per inserire delle schede di Film in un sito, fin quì ok. Ora vorrei fare in modo che quando scrivo una news con Wordpress, possa avere la possibilità di scegliere quale delle schede create linkare e/o mostrare sotto la notizia che ho scritto... I read this tutorial to create custom forms to insert films in a database. Now I want that when I write a post in wordpress, I can quickly link the forms below the news. **CUSTOM FORM**   Image   Film title: Hercules   Release Date: xx/xx/xx **NEWS**   _Here the text of my news_ _Here the custom form link associated to the the post_


title: Display a specific dynamic sidebar widgets on a specific page

text:
I have had a wordpress site handed off to me halfway through completion. It's been at least a year since I last used wordpress and there are a lot of things I'm finding different. The way I am used to displaying different content on different pages is to create page templates for each page that needs unique content. I am trying to display a different sidebar on one particular page than on the rest of the site. What I would have done a year ago is make a page template for this page and make a new sidebar file and then include the sidebar file in the page template. I've found that this doesn't work. The main culprits I can see are `loop.php` & `loop-page.php`, which were non-existent in the stripped down theme that I would typically use when building a site long ago. However, it appears that whoever had their hands on this thing before me has copied the 'twenty ten' theme and made changes to it under a new name. I've registered a new dynamic sidebar in the theme's `functions.php` and I can see it in the Widgets section of the Dashboard and add widgets to it. I can't for the love of god get it to display on the page I want it to though. I've tried the following: 1.) Given the page a custom template `template_news.php` and placed the following where the sidebar should be called:               include ('sidebar-news.php');      The `sidebar-news.php` filed containing code I copied from `sidebar.php` with the "News" sidebar id that I listed in `functions.php`:               <?php if ( is_active_sidebar( 'sidebar-news' ) ) : ?>

             <?php dynamic_sidebar( 'sidebar-news' ); ?>

          <?php endif; ?>      The page template is applied to the correct page. 2.) Gone into `page.php` and changed:               <?php get_sidebar(); ?>      to:               <?php           if(is_page('18')) {        include ('sidebar-news.php');     }     else {                      get_sidebar();      } ?>      I've also checked several times to make sure the page ID is correct and tried using the slug name instead but to no avail. 3.) Tried the previous in `loop-page.php` 4.) Placed the following conditional statement in `sidebar.php`:               <?php     if ( is_active_sidebar( 'sidebar-news' ) && is_page('18') ) : ?>

         <?php dynamic_sidebar( 'sidebar-news' ); ?>

     <?php endif; ?>      Also after doing some research and finding out that the proper way to extend or change the functionality of a theme is to create a child theme, I attempted to do that, but it caused some things to break that I don't have the time to try and fix. I've found that the default 'sidebar.php` is being called and displayed on the page, however, even though my conditional statement with the page ID is present, it's not displaying the custom sidebar widgets. I also cannot seem to find how the default sidebar is being called on the page because removing `get_sidebar();` altogether on my custom template `template_news.php` , `page.php` , or `loop-page.php` doesn't seem to do anything. Please can someone let me in on how to add this sidebar to the page.


title: "pre_get_posts" firing on every query

text: How can I change arguments for the main query only, and not affect other queries?               add_filter('pre_get_posts', 'custom_post_count');     function custom_post_count($query){       $query->set('posts_per_page', 5);       return $query;     };      Because this action is called inside the get_posts method of WP_Query, this code will alter the _posts_per_page_ argument for all loops, not just the main, so passing this argument to WP_Query is useless...


title: favicon now showing up

text: I have wordpress installed in the /home directory on my server, so it was set up that you would have to go to www.mywordpress.com/home to see my wordpress and just going to www.mywordpress.com would take you to a different homepage. Well, I went into my setting and change the Site Url so to www.mywordpress.com so that my wordpress would be my homepage. Today, I tried to setup a favicon and it only works if the url is www.mywordpress.com/home/whatever even if you try going to www.mywordpress.com/whatever. If the /home isnt in there the favicon doesn't show up. I have the code pasted in my header.php template Thanks!


title: How to activate/deactivate menu tab and keep the same id?

text: I have a problem here and i cant find/think of any solution yet. I want to have a menu button that can be activated/deactivated and still keep the same id so the CSS will still be applied. Is there any plugin or a way to do that ? I allready managed to create the page and add it to menu and then remove it. That works but the problem is that "special" button i want is supposed to be another color and I cant find any solution for that because the id keeps changing.


title: Need help building a filter to edit the output of "image_send_to_editor"

text: What I'm trying to do is edit the output of `image_send_to_editor` so that i can make the anchor that wraps around the image have a specific **class** & **rel**. I plan to basically make each image that gets inserted into a post become fancybox capable without having to be in a gallery or using a plugin. Heres what I have thus far but I need help filling in the blanks...               <?php     add_filter( 'image_send_to_editor', 'fancy_capable', 10, 7);     function fancy_capable($html, $id, $alt, $title, $align, $url, $size ) {     // not sure what to do here???     return "$html";     }     ?>


title: What data sanitzation function should be used to store entire source code of webpage?

text: What is the best _data santization_ function to use when the entire source code of a webpage (head, body elements, etc) are going to be stored in a post meta field? In other words, which function will encode the most html tags while avoiding dropped data?


title: Can I hook into get_avatar to supply a hash instead of an email?

text: I'm writing a plugin to PPK encrypt non-public comment data as a second line of defence against crackers (one of my sites was recently compromised, so I have been rather spurred into action!). To achieve this, I am writing a meta comment value containing the encrypted email/IP for each comment, and once everything has been tested, the admin will be able to click a button and safely null the plaintext email/IP fields. Unfortunately this means that Gravatars will stop working, since this requires a plaintext email field. So, I believe I can register on the `get_avatar` filter, but as far as I can tell I'll need to replicate all of the `get_avatar()` function in pluggable.php. Obviously that would means any subsequent core updates to this function will have to be manually patched into my copy, which is rather inelegant. Or is there something I may have missed in which I can supply a MD5 hash and get all the other goodness in core Gravatar functionality automatically? I do love WP, but the dev docs are a touch on the sparse side for this `:)` If that's not possible, I might try to ask the core team if they would consider adding a new filter. I should think blogs wanting to store personal data only for a limited time would appreciate a way of still being able to use Gravatars on much older comments.


title: How to get a query variable?

text: I have added a query variable with the following function:               function add_my_query_var() {         global $wp;         $wp->add_query_var('myvar1');     }     add_filter('init', 'add_my_query_var');      Now on a specific page (author)`example.com/author/admin/myvar1`, `$wp_query` returns:               WP_Query Object     (         [query] => Array             (                 [author_name] => admin                 [myvar1] =>              )              [query_vars] => Array             (      So I can see that the variable is set. However since it is empty, I cannot use following condition to check:               if ( get_query_var('myvar1') ) {         echo "is set";     }      What is other way to check if the `myvar1` exists or not? I cannot use `$_GET` because of permalinks. Edit: Here's the code to rewrite the URL:               add_rewrite_rule('author/([^/]+)/myvar1/?$', 'index.php?author_name=$matches[1]&myvar1=$matches[2]', 'top');


title: White pages on sub domains after server transfer

text: I recently just moved servers with a multisite install and kept the same domain. I can access all the backend features and logins for each subdomain but when trying to visit each subdomain site, it just loads a blank white page. I have setup wildcard subdomains in cpanel and checked the wp options and wp config. Has anyone else ever had this issue when migrating servers?


title: Is there a way to overwrite a filter used in canonical.php?

text: I am trying to replace the base functionality of the wp_signup_location to something custom. I realized that in canonical.php is where the filter is defined. Is there a way to redefine `apply_filters('wp_signup_location', network_site_url( 'wp-signup.php'));` such as adding the same filter in functions.php so that I can redirect this to somewhere else before canonical is processed? For example, I want to define this to go to `apply_filters('wp_signup_location', 'my_custom_file.php');` without needing to edit canonical (purely bad practice). Basically I want to define the signup location.


title: adding more fields to the comments form including image upload

text: I want to be able to add more fields to the comment form including a date field and a multiple image upload field. I have found a few links showing how it might be possible to add more text fields but how would i allow uploading of multiple photos? When using this contact form the user will be logged in. Ideally I would like to upload the image and have it resized as using WordPress uploader but is this possible as it is on the front end? i do use Gravity Forms but as far as I am aware currently it is not possible to use this with comments? any help will be greatly appreciated thanks


title: Disable collapse of admin meta boxes

text: I have been attempting to disable the ability to collapse admin meta boxes. By the looks of it WordPress creates this functionality in postbox.js /wp- admin/js/ but I have been unable to find a hook or suitable JavaScript to overwrite the built in functions. This is a some test code I am working with:               jQuery('.postbox h3, .postbox .handlediv, .hndle').bind('click', function(e) {              e.preventDefault();         return false;          });      Any thoughts on how this could be achieved?


title: Category template to show different categories based on parent

text: Ok so i've got categories like setup like this.               Products        Category A            Sub Category 1            Sub Category 2        Category B        Category C      What i need is to have the Products category page showing the main Categories (A,B,C). The main Category pages (A,B,C) showing their sub Categories (1,2). Then the Sub Categories (1,2) showing my custom post type i.e the actual products. I want to avoid using a category-slug.php template because when someone adds a new category i want it to show automatically on the correct page, based on what the parent is. I thought about using a category.php template but i don't know if this is possible from one template or what code i would need. The first category pages (Products) will only display the main Categories (A,B,C). It won't be showing any posts just a list of category links in the main section. So i can style them so they are like big buttons on the page. The same will be for Category A,B,C. Show the sub categories. The last category page (sub category 1,2) will show my custom post type (the actual products) in some sort of list. This page won't show any other categories just the Products in the main section. Any help on how i can achieve this would be appreciated. Thanks UPDATE: I've managed to get the category template to show the right categories. It seems to be working but i've not tested it properly yet. The problem i now have is displaying my custom post types on the deepest level categories. So it will show things like the custom post type title, thumbnail, maybe an excerpt. Here's the code i'm using.               <?php // list child categories     $cat_id = get_query_var('cat');          $catlist = wp_list_categories('depth=1&hide_empty=0&echo=0&orderby=id&title_li=&child_of=' . $cat_id);          if ($catlist) {     echo $catlist;     } else {     echo "Please don't print No categories";     } ?>      Currently on the deepest level category page it just displays 'No Categories'. I need to get that page showing my custom post types that belong to that category.


title: Is There a Way to Completely Turn Off Pingbacks/Trackbacks?

text: There is the option to turn off trackbacks/pingbacks under `Settings > Discussion`. But I'd like remove the `X-Pingback` header WordPress sends and completely remove the the `trackback` endpoint. Is there a way to do this?


title: Create scroll of custom post types

text: I would like to create an area on an HTML homepage (HTML site that contains WP pages) that presents through an iframe or other, the titles of all posts for one custom post type. Any ideas would be greatly appreciated.


title: Problems converting pages to posts

text: I have recently set up a new blog and started writing some articles for it. The problem is that i started writing a page instead of a post. I realized this before publishing so I copied all of the content to a new post and deleted the unpublished page. After publishing the post I started having problems. The published post doesn't show as it should. The only thing I see is a small version of the main image. I downloaded and installed a plugin that allows me to convert pages to posts and vica versa. After converting the post to a page it started to appear as it should. When converting it back to a post I have the same problem. I deleted all revisions and drafts just to make sure but the problem persists. My permalinks are fine. Any idea on why it is doing this?


title: Implement If-ElseIf-Else-EndIf with short codes

text: _I have very little experience with WordPress and PHP, so I apologize in advance for syntax problems._ I'd like to know if it's possible to implement If/Else logic as short codes. Something like:               [if] Version: IF [elseif] Version: ELSEIF [else] Version: ELSE [/if]     // OR...     [if] Version: IF [if branch="elseif"] Version: ELSEIF [if branch="else"] Version: ELSE [/if]      If you want more background into why I would want to do such an idiotic thing, see the referenced post on SO. Parse CFML tags in PHP


title: Remove hovercard for only certian gravatars

text: I am using the Extended Gravatar plugin by Reza Moallemi and it works great. However, on my about page I have a large gravatar to show the author. I would like to know if there is a class I can add to not show the hovercard. Or php that can be added to get_avatar('$email') I could just not include the plugin on the about page but I'm thinking there is an easier way to fix this.


title: How to make entries of Gravity Forms available in the public front-end?

text: I want to make entries of the Gravity Forms available for the public in the front-end. I read in a forum post that this is possible with some specific free add-on for Gravity Forms. But I couldn't find it. Do you know the name of that add-on or do you know an easy to implement method to achieve this?


title: Query posts from category based on a filter most favorited

text: I have one question. I need to query posts from category based on the filter most favorited ( http://pastie.org/2751114 ) which is placed in custom_sort.php to my index.php page This is how the posts from categories are called ( http://pastie.org/2751131 ) in index.php. Is there any way to get the posts from category based on the most favorited filter? Thank You so very much in advance :D


title: Custom formatting

text: After some advice to get pointed in the right direction. I am knocking together a site for a friend who isn't the most technical minded so want to make the process easy and of course Wordpress offers that. However I want to layout the pages a particular way such as http://www.apple.com/ipad/overview/ where content goes left right left right sort of thing with the image aligned alongside. I know this is probably possible using the editor however I want to make it easier and controlled in its format. I was thinking possibly someway of having say a parent page with child pages under it essentially being pulled into the parent page instead of their own page themselves. Then with each page in the loop just alternating between left and right format. This doesnt offer lots of control to the person editing the site but keeps it simple. That was my best idea of handling it. Is there another way that is better or is there an issue with the way I suggest like how sitemaps would be handled or dupicate content issues etc. Should I even be looking at custom post types? I just think that by using the children pages to handle it then they can attach a image via the featured post thumbnail image and alternate its positioning. Thanks for any advice and pointers its greatly appreciated.


title: Last x Posted Categories?

text: Is there a widget available that will list the latest x categories according to posting date, essentially providing a list of the most recently active topics?


title: Multiple loop for "featured" items returns wrong posts

text:
I have a page template where I first am getting the contents of the page, as input in the admin tool, then a loop of posts of a custom post type. I need to split this loop up into the 2 newest posts ("featured") and then a second loop of all the remaining posts. I am trying to use code from the WP Codex, from this page but the second loop is pulling the **contents of the page** , not the **rest of the first loop**. What did I screw up?                             <?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>

<?php the_content(); ?>
             <?php endwhile; ?>             <? wp_reset_query(); ?>
             <?php                        $args = array( 'post_type' => 'onourradar', 'posts_per_page' => 2, 'orderby' => 'menu_order', 'order' => 'ASC'  );                 $my_query = new WP_Query($args);                 while ($my_query->have_posts()) : $my_query->the_post();                 $do_not_duplicate[] = $post->ID;                 //$event_date = get_post_meta($post->ID, 'event_date', true);                  //$clean_date = date('F j Y',strtotime($event_date));              ?>
                     <?php the_post_thumbnail( 'thumb', array('class' => 'featured-image') ); ?>
<a href="<?php the_permalink(); ?>"><?php the_title();?>

<?php the_field('teaser'); ?>

<?php the_excerpt(); ?>

                  <?php endwhile;  ?>                    <?php if (have_posts()) : while (have_posts()) : the_post();                if (in_array($post->ID, $do_not_duplicate)) continue;             ?>
<a href="<?php the_permalink(); ?>"><?php the_title();?>
             <?php endwhile; endif; ?>      EDIT: This second loop seems to work, not sure if this is the proper way. Suggestions appreciated:                <?                 $args = array( 'post_type' => 'onourradar', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'post__not_in' => $do_not_duplicate );                 $my_query = new WP_Query($args);                 while ($my_query->have_posts()) : $my_query->the_post();             ?>


title: How to use is_admin in page content?

text:
I'm trying to add a "Click here to edit this page" button in some Wordpress pages. This button should only appear if the user is admin, this is the code that should appear if the user is admin:               if ( current_user_can( 'manage_options' ) ) {

To edit this page CLICK HERE

          } else {         return false;     }      This code outputs this: ![Code Output](http://i.stack.imgur.com/TOmE0.jpg)


title: Comments view limited to 20 results - any way to increase to 50 or 100?

text: Each day I manually delete the spam posted on my blog. The comments view allows a maximum of 20 comments in the view. When I have 200 spam entries - I need to click through 10 times to get rid of it all. Is there a way I can view 50 or 100 comments in the wordpress admin window at a time?


title: Modifying Footnote Plugin for Descriptive Title Attributes

text: I've been struggling for a couple hours now to get this working... Hopefully someone here can help me. I just started using the wp-footnotes plugin, and I'm trying to set the title attribute on backlinks to "Return to footnote # in the text." where # = the footnote number. Below is what I tried, putting the $id_num variable in the title attribute, but it ends up just displaying as the number of footnotes that exist. You can see this at my development site on the first post. Thank you so much in advance for any help. It's quite a bit, so I'll paste the code in at the end:                   // Display identifiers               foreach ($identifiers as $key => $value) {             $id_id = "identifier_".$key."_".$post->ID;             $id_num = ($style == 'decimal') ? $value['use_footnote']+$start_number : $this->convert_num($value['use_footnote']+$start_number, $style, count($footnotes));                  $id_replace = $this->current_options['pre_identifier'].''.$id_num.''.$this->current_options['post_identifier'];             if ($this->current_options['superscript']) $id_replace = ''.$id_replace.'';         }              // Display footnotes         if ($display) {             $start = ($start_number != 1) ? 'start="'.$start_number.'" ' : '';                      if ($style == 'symbol') {                     $data = $data . '' . $this->convert_num($key+$start_number, $style, count($footnotes)) . ' ';                 }                 $data = $data.$value['text'];                 if (!is_feed()){                     foreach($value['identifiers'] as $identifier){                         $data = $data.$this->current_options['pre_backlink'].'     ID) : '' ).'#identifier_'.$identifier.'_'.$post->ID.'" class="backlink"     title="Return to footnote '.$id_num.' in the text.">↩'     .$this->current_options['post_backlink'];                     }              return $data;     }


title: Pagination on custom post type not working

text: I'm having a hard time getting pagination to work with my custom post type query. The standard "previous_posts_link()" and "next_posts_link();" aren't working. And through a bit of testing, I've noticed neither "get_query_var('page')" or "get_query_var('paged')" are working. Also, adding "/page/2/", "/2/", or "/?page=2" isn't finding a page. Any suggestions?               if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } else if ( get_query_var('page') ) {$paged = get_query_var('page'); } else {$paged = 1; }          $args = array('post_type' => 'directory',     'posts_per_page' => 2,     'paged' => $paged     );          $my_query = new WP_Query($args);          while ($my_query->have_posts()) {         $my_query->the_post();         // do stuff     }     previous_posts_link();     next_posts_link();


title: Wordpress slug issue with non-latin characters

text: I'm using permalinks in WP as: `domain.com/category/post_name` The issue is that post names have non-latin characters such as _chinese, hebrew, and arabic_. So it encodes them to something like: `%20%18%6b%20` therefore it counts every symbol's character as an actual character, ending up with 3x times more length that it truncates some very short slugs. How to fix that? Or how to extend the length limit at least? I've tried to extend the length of the database field "post_name" from 200 to 500, But it's still truncating short.


title: Post ID wrong in Functions.php

text: I am trying to execute the following code inside my functions.php to change the title of my wordpress blog.               function filter_pagetitle($url) {                  global $wp_query;                  $the_post_id = $wp_query->post->ID;             $the_post_data = get_post($the_post_id);                  return $the_post_data->post_title;     }          add_filter('wp_title', 'filter_pagetitle');      However, $the_post_id always comes back as the same one, and never changes to the ID of the post that I am viewing? What am I doing wrong?


title: Display facebook comments made on site

text: Im using facebook comments for wordpress, now i would like to display the recent comment using the widget but its getting an error Fatal error: Cannot use string offset as an array in .. Is there other way to fetch the comments made from the posts and display them?


title: How to use author's avatar as Facebook post preview image when a single post is shared

text: I want to use the post author's avatar if available as the post preview image for Facebook shared posts. If that is not available next would be a featured image and then a default image as a fallback. Is there a plugin or function that can achieve this? The Yoast SEO plugin and many others can insert a default image, but I have not been able to find one that can pull the image from the author's avatar. *note, I am also using Simple Local Avatars for users that do not have avatars associated with their email


title: Use two different post_per_page limits with infinite scroll

text: I have one loop on my homepage that I use infinite scroll to paginate. To keep the load time of the homepage down, I want to load a smaller initial amount than when the infinite scroll is triggered for the first time. So on page load I want 10 posts loaded and then every trigger after that I want the post_per_page to equal 25. Is that possible? Im using Infinite Scroll Jquery plugin. Not the wordpress version. I use this script after the loop to trigger the infinite scroll.               <div class="infinitescroll">     <?php next_posts_link( __( 'Load more posts', 'imbalance2' ) ); ?>     </div>          <script type="text/javascript">      // Infinite Scroll      var href = 'first';      $(document).ready(function() {     $('#boxes').infinitescroll({         navSelector : '.infinitescroll',         nextSelector : '.infinitescroll a',         itemSelector : '#boxes .box',         loadingImg : '<?php echo get_bloginfo('stylesheet_directory') ?>/images/loading.gif',         loadingText : 'Loading...',         donetext : 'No more pages to load.',         debug : false     }, function(arrayOfNewElems) {         $('#boxes').masonry('appended', $(arrayOfNewElems));         if (href != $('.infinitescroll a').attr('href'))         {             href = $('.infinitescroll a').attr('href');         }     });      });     </script>


title: Show Custom Menu Name in Wordpress 3

text: Is there a way to display the name of a custom menu in the frontend? I can't use the widget title because of the usage of many languages.


title: BuddyPress Component Slug 404

text: I have created a custom component using the latest skeleton framework that needs to have its URLs as part of the current group. I have accomplished this is in my component's setup_nav() function, but when I try to access the URL I get a 404 error. I have been trying to solve this issue all morning with no luck. Could someone kindly point me in the right direction? Here is my component's setup_nav method:               function setup_nav()     {             $link = trailingslashit(bp_get_root_domain().'/'.bp_get_groups_root_slug().'/'.bp_get_current_group_slug().'/'.bp_get_announcements_slug());             $slug = bp_get_announcements_slug();                  $main_nav = array('name'                => __('Announcements', 'bp-announcements'),                               'slug'                => bp_get_current_group_slug(),                               'position'            => -1,                               'screen_function'     => 'bp_announcements_screen_list',                               'default_subnav_slug' => 'all');             $sub_nav[] = array('name'            =>  __('All Announcements', 'bp-announcements'),                                'slug'            => 'all',                                'parent_url'      => $link,                                'parent_slug'     => bp_get_current_group_slug(),                                'screen_function' => 'bp_announcements_screen_list',                                'position'        => 10);     }


title: Open post within Foundation 3 Reveal

text: I'm trying to open a post within a reveal modal (F3). I solved initially by placing the reveal code within the loop of my custom post type. Thinks were good but I faced a couple of issues. Since it's within the main loop, when page loads, it will load all the modals for each one of my custom post types, which is not very good from a performance standpoint. My code is basically: `<a id="more" href="#myModal-<? the_ID(); ?>" data-reveal-id="<? the_ID(); ?>">Details</a>` for the trigger and `<div id="<? the_ID(); ?>" class="reveal-modal medium">` within the loop. Also, I'm placing Foundation's Orbit for slideshows within that modal box. The issue is that it initiates on one of them only. I know this is because the implementation is not good and Orbit slideshow can't be initialised so many times. Does anyone have tried to implement this but instead having the modal code within the main loop, have it call the single template to show as it's content? Any other technique will be appreciated.


title: Does anyone know a plugin that turns a 'post' into an html newsletter?

text: I know you could just grab the code or some such. But I'm trying to figure out a way to easily implement this for a client. All my googling has just turned up signup forms, not anything for actually sending out a post. To summarise what I'm after: I want the client to be able to create a post, use the built in text editor for formatting etc, maybe attach a picture and so on. So that they can have the complete newsletter archive online. Then I want a way for them to be able to send it out. Either by exporting the html code (via a template), or linking it direct to mailchimp or some such. Has anyone had to do something similar? Or do you have any idea of a plugin I should be checking out? If it's not out there I'm not against trying to write a plugin for this (though I'm not sure how I'd start that yet)... but thought it best to check first. Thanks


title: featured image inside post

text: I want the featured image of a post to display not only in the blog list view, but also inside the post (when i press "Read More..."). How do i do that? I pasted this               if ( has_post_thumbnail() ) {       the_post_thumbnail('full');     }       in single.php just before the_post();. It looks like this:               while (have_posts()) {         if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.           the_post_thumbnail('full');         }          the_post();         get_template_part('content', 'single');     }      But the image shows up, above the title. How do i make it show after the title, just like in the blog list view?


title: Does a wordpress plugin (not a membership one) exist for selling access to some webpages?

text: I am looking for a wordpress plugin in order to sell the access of some webpages on my website. I mean I am not looking for a "membership" plugin. I mean the user has to pay in order to view the page. The user also has to pay again, if he wants to view a second paid page. And he has to paid a third time if he wants to see a third paid page, etc. If he logouts, then he should be able to login later to the website and then to have again access to the pages that he paid for. I have looked so many plugins that I start wondering if what I want exist ? I mean I have looked at s2member, Paid Membership Pro, etc. But this is all about "Membership": you have to create 1 specific "Membership Level" for each page you want to sell ! What about if you have 1000 pages and you want that the access to each of those pages costs 20EUR ? If any of you have an idea.. (even if i have to paid to get the plugin). Thanks a lot.


title: In wordpress how to sent different email separetly when i click on different email ids

text: I am using contact form 7 as a plugin in wordpress but i dont know how to sent different email separetly when i click on different email ids


title: I want to add a gallery to a post but I don't want it displayed in the content?

text: I want my user to able to add a gallery to a post and then run a conditional like:               <? php     if (strpos($post - > post_content, '[gallery') !== false) {         echo do_shortcode('[gallery]');     } else {         the_post_thumbnail();     } ?>      But using wordpress' stock gallery and adding it to a post also shows the gallery inside the content. **I have a 2 column layout, the right column has`the_content()` but I want the left column to display the gallery if it has one.** How do I go about making this work?


I have a plugin and I am creating a css file in wp_content. I used this:               $this->content_dir = WP_CONTENT_DIR . "/some_folder";          $path = $this->content_dir . 'options.css';     $css='some string';     global $wp_filesystem;      if(!$wp_filesystem->put_contents( $path, $css, 0644) ) {         return __('Failed to create css file');     }      However I get this error: Fatal error: Call to a member function put_contents() on a non-object var_dump($css) return string. Does put_contents write to an exisiting file or does it create a file like file_put_contents does? I am looking for an equivalent of this:               if(!file_put_contents($path, $css)){         return __('Failed to create css file');     };      Thank you!


title: Plugin programming: Uploading a file to a specific folder

text:
I’m trying to develop a wordpress plugin for my dorm for different administration purposes. One of the functions should be to upload meeting summaries into a folder named “referater” in the root of the server/wordpress installation. I have had an implementation which worked, but it called another php page to upload, and I want to post the information to the same page. It inserts the data into the database, but the file is nowhere to be found. And I know I should be using mysqli but the hosting provider does not support it. This is the code (and I know it is not so well-written, some of it I have borrowed from an earlier volunteer at the dorm; but at first I just want I to work and afterwards I can optimize it):
                         <?php if(!isset($_POST['var_uploaded-referat'])){ ?>
Upload referat
         Navngivningen af bestyrelses referaterne er ligegyldig, dog skal det være pdf-filer.
         Filerne bliver automatisk navngivet som "åååå-mm-dd Referat".pdf (uden " " selvfølgelig), når de bliver uploadet til serveren.
         Så hvis datoen for mødet var 5/6 2013, så bliver referat filens navn 2013-06-05 Referat.pdf.
                       <form action="<?php echo htmlentities($_SERVER['REQUEST_URI']); ?>" method="post" enctype="multipart/form-data">
<?php _e("Dag: " ); ?><select size="1" name="dag">                 <option value="01">01</option>                 <option value="02">02</option>                 <option value="03">03</option>                 <option value="04">04</option>                 <option value="05">05</option>                 <option value="06">06</option>                 <option value="07">07</option>                 <option value="08">08</option>                 <option value="09">09</option>                 <option value="10">10</option>                 <option value="11">11</option>                 <option value="12">12</option>                 <option value="13">13</option>                 <option value="14">14</option>                 <option value="15">15</option>                 <option value="16">16</option>                 <option value="17">17</option>                 <option value="18">18</option>                 <option value="19">19</option>                 <option value="20">20</option>                 <option value="21">21</option>                 <option value="22">22</option>                 <option value="23">23</option>                 <option value="24">24</option>                 <option value="25">25</option>                 <option value="26">26</option>                 <option value="27">27</option>                 <option value="28">28</option>                 <option value="29">29</option>                 <option value="30">30</option>                 <option value="31">31</option>             </select>

<?php _e("Måned: " ); ?><select size="1" name="maaned">                 <option value="01">Januar</option>                 <option value="02">Februar</option>                 <option value="03">Marts</option>                 <option value="04">April</option>                 <option value="05">Maj</option>                 <option value="06">Juni</option>                 <option value="07">Juli</option>                 <option value="08">August</option>                 <option value="09">September</option>                 <option value="10">Oktober</option>                 <option value="11">November</option>                 <option value="12">December</option>             </select>

<?php _e("År: " ); ?><select size="1" name="aar">                 <option value="2008">2008</option>                 <option value="2009">2009</option>                 <option value="2010">2010</option>                 <option value="2011">2011</option>                 <option value="2012">2012</option>                 <option value="2013">2013</option>                 <option value="2014">2014</option>                 <option value="2015">2015</option>                 <option value="2016">2016</option>                 <option value="2017">2017</option>                 <option value="2018">2018</option>                 <option value="2019">2019</option>             </select>
                               Sti til referat:
             <input type="file" name="file" id="file">
             <input type="submit" name="var_uploaded-referat" value="Submit">         </form>                         <?php         } elseif (isset($_POST['var_uploaded-referat'])) {                       // Connects to the database             $db=mysql_connect("<server>", "<username>", "<password>")or die("cannot connect");             mysql_select_db("akdtu_dk", $db)or die("cannot select DB");                  $date = "$_POST[aar]-$_POST[maaned]-$_POST[dag]";             $filnavn = $_FILES["file"]["name"];                  $allowedExts = array("pdf");             $extension = end(explode(".", $_FILES["file"]["name"]));             if (($_FILES["file"]["type"] == "application/pdf") && ($_FILES["file"]["size"] < 20000000) && in_array($extension, $allowedExts)){                 if ($_FILES["file"]["error"] > 0){                     echo "Return Code: " . $_FILES["file"]["error"] . "
";                 }                 else{                     echo "Upload: " . $_FILES["file"]["name"] . "
";                     echo "Type: " . $_FILES["file"]["type"] . "
";                     echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB
";                     echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
";                          if (file_exists("../../referater/" . $_FILES["file"]["name"])){                         echo $_FILES["file"]["name"] . " already exists. ";                     } else {                         $directory = "../../referater/";                         $newFileName = "$_POST[aar]-$_POST[maaned]-$_POST[dag] Referat.pdf";                         $target = $directory . $newFileName;                          move_uploaded_file($_FILES["file"]["tmp_name"],"$target");                         echo '
Referat uploaded
';                         echo "Stored in: " . "../../referater/" . $_FILES["file"]["name"];                         echo '
';                         echo "$_SERVER[REQUEST_URI]";                              // SQL insertion/query                         $sql="INSERT INTO ak_refbest (dato,filnavn)"."VALUES ('$date','$newFileName')";                         mysql_query($sql);                     }                 }             } else {                 echo "Invalid file";             }         } else {             echo '
Fejl ved upload af referat
';             echo 'Prøv igen, hvis problemet fortsætter kontakt netgruppen på xxx@xxx.dk';         }     ?>