title: Nuance in adding CPT and TAX to a submenu

text: I have a lot of CPT's and custom TAXs and decided to put them into a few submenus. That worked just fine. I'll explain how I did that in a moment but the problem is that when you choose a "new term" or a "new post" the Admin's sidebar menu loses track of being within a submenu and collapses the menu. This doesn't strictly matter as you can add the item and then reopen the admin menu but it's an irritant that I'd like to remove. To help explain my problem, I've included a few screen shots. Here's the Admin menu when I open it to my menu/submenu of "LG RefData / UOM": ![enter image description here](http://i.stack.imgur.com/HYT88.png) So far, all good. BTW, UOM is a a CPT (not a TAX). Now if I click on the "Add New" button at the top of the edit.php page then it brings up the page fine but the Admin menu collapses to look like this: ![enter image description here](http://i.stack.imgur.com/ujPnc.png) So that's the main problem but there is a small corollary which is related to how TAX's behave. In the original screen shot you saw a submenu called "UOM Context" which is a taxonomy. By default clicking on that immediately collapses the Admin menu but I have found a way around that (more on that in a sec) but my solution still leaves the menu looking like this when I click on the "UOM Context" link: ![enter image description here](http://i.stack.imgur.com/pB7HZ.png) Notice that while it's not collapsed it is not highlighting (aka, boldfacing) the submenu choice. So let me show you the code I used to set this up (although it is likely fairly standard code for people trying to do this). The first thing that happens from an execution perspective is the CPT's and TAX's are registered. The trick with the CPT's is to use the "show_in_menu" and set it to name of the menu page it will sit under:                       // Default args             array(                 'label'                 => $plural,                 'labels'                => $labels,                 'public'                => true,                 'show_ui'               => $this->show_menu,                 'show_in_menu'          => $this->show_in_menu,                 'supports'              => array( 'title', 'editor' , 'excerpt'),                 'show_in_nav_menus'     => true,                 'menu_icon'             => LG_FE_DIR . "/img/lg-admin.png",                 'menu_position'         => $this->get_menu_priority(),                 '_builtin'              => false,             ),      Note that this is not necessary for TAX's and in my experimenting it seems to have no effect so I have just left it off. The second step is the add_menu_page and add_submenu_page calls:               add_menu_page ("LG Ref Data", "LG Ref Data", "manage_options", LG_REFDATA_MENU, "LG_AdminMenuSystem::show_reference_menu", plugins_url ("/img/LG.png", __DIR__), 61.1);     add_submenu_page (LG_REFDATA_MENU,"UOMs","UOMs","manage_options",'edit.php?post_type=uoms');     add_submenu_page (LG_REFDATA_MENU,"UOM Context","UOM Context","manage_options",'edit-tags.php?taxonomy=uom-contexts&post_type=uoms');     array_push (self::$tax_correct, "uom-contexts");          Pretty standard stuff with the exception of the last line which is the beginning of my TAX Fix that I mentioned earlier (aka, stops the menu from collapsing when choosing a TAX item but doesn't stop it when adding a new item). Here's the actual code for the fix:               static public function tax_menu_correction ($parent_file) {         global $current_screen;         $taxonomy = $current_screen->taxonomy;         if ( in_array($taxonomy,self::$tax_correct) )             $parent_file = LG_REFDATA_MENU;         return $parent_file;     }      which is then called from the following hook:               add_action( 'parent_file' , 'LG_AdminMenuSystem::tax_menu_correction'); // helps to keep the menu selection on the menu when choosing a custom TAX       So that's it. Any and all help would be greatly appreciated.


title: Is there a way to delete images from Wordpress media library programmatically?

text: This is a follow-up of my question which did solve my problem, well, a little bit. I noticed that there are still images on my uploads folder but of different size. Is there a way to delete all traces of the image that I uploaded? It seems that `wp_delete_attachment` only deletes the image that is "attached" but not the other image sizes that Wordpress automatically created. I use this function to generate attachment IDs               function insert_attachment( $file_handler, $post_id, $setthumb='false' ) {              // check to make sure its a successful upload         if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();              require_once(ABSPATH . "wp-admin" . '/includes/image.php');         require_once(ABSPATH . "wp-admin" . '/includes/file.php');         require_once(ABSPATH . "wp-admin" . '/includes/media.php');              $attach_id = media_handle_upload( $file_handler, $post_id );              if ($setthumb) update_post_meta($post_id,'_thumbnail_id',$attach_id);              return $attach_id;       }      (I got that from: http://goldenapplesdesign.com/2010/07/03/front-end-file- uploads-in-wordpress/) I use this for a custom file upload in front-end and not the usual upload using the Media Library. This is for a site that requires user uploads. Any thoughts?


title: What is good W3 total database caching option?

text: I have a centOS VPS (Apach+Nginx). Right now I use APC for w3 total plugin cache (disk enhanced for page cache). I have less than 25MB database. I can see several w3tc, APC cache errors. I think the main issue is Zend optimizer. What is the good option for wordperss database cache (eAccelerator, XCache)? Error.               PHP Strict Standards:  Declaration of W3_Cache_Apc::delete() should be compatible with W3_Cache_Base::delete($key, $group = '') in /home/xxxxx/public_html/wp-content/plugins/w3-total-cache/lib/W3/Cache/Apc.php on line 189


title: Page content doesn't display when published but does when previewed as draft?

text: I have a page called ecommerce which is published. It's not private or password protected. When I view the page I only see the page title in the body none of the content. If I preview the published page nothing shows up only the title. If I set the status of the page to Draft and preview the page it'll display the content correctly. If I change the permalink slug it will display fine when published. I had a page before with this name trashed and permanently deleted it. It seems something might have got left over in the database?


title: How to create custom query by keyword in post title?

text: I need some help regarding Custom Query by keyword. I send a keyword to my page where I would like to list those posts which post_title contains the keyword I sent. Here comes my query as follows:               $q = 'SELECT guid, post_content, post_title, post_parent, post_type FROM wp_posts WHERE (post_title REGEXP '".$keyword."') AND post_type="attachment"';      How would it be possible to implement it into Wordpress and make it work? I have seen many snipets but it's really hard for me to make it work. I have found a code which seemed good, but the displaying part is missing, please see at the end of this question.               global $wpdb;     // If you use a custom search form     $keyword = sanitize_text_field( $_REQUEST['mykey'] );     // If you use default WordPress search form     // $keyword = get_search_query();     $keyword = "%{$keyword}%";     // Search in all custom fields     $post_ids_meta = $wpdb->get_col( $wpdb->prepare( "     SELECT DISTINCT post_id FROM {$wpdb->postmeta}     WHERE meta_value LIKE '%s'     ", $keyword ) );     // Search in post_title and post_content     $post_ids_post = $wpdb->get_col( $wpdb->prepare( "     SELECT DISTINCT ID FROM {$wpdb->posts}     WHERE post_title LIKE '%s'     OR post_content LIKE '%s'     ", $keyword, $keyword ) );     $post_ids = array_merge( $post_ids_meta, $post_ids_post );     // Query arguments     $args = array(     'post_type' => 'post',     'post_status' => 'publish',     'post__in' => $post_ids,     );     $query = new WP_Query( $args );     if ( $query->have_posts() ): while ( $query->have_posts() ) : $query->the_post();     // Do loop here     endwhile; endif;


title: How to prefill Wordpress registration with Social

text: I created custom registration process in wordpress with a lot of extra fields like first name, last name etc. I would like to make integration with facebook/linkedin so first name,last name,email, fields are be prefilled with facebook/ linkedin, but still users will need enter other fields to finish registaration. Is it possible to do something like that, or is there some plugin which is doing that?


title: How to Show Different Sidebars on Specific Pages?

text: I'm making a blog where only on specific pages I want to show different sidebar, I will add some widgets to those sidebar, which I don't want to show in default sidebar. I've found a coding method to do this, but I would like to use a plugin, and not edit code myself. I need to give the control of adding/removing sidebar/widgets in client hands. So is there any plug-in to do this easily?


title: apply custom where to the default $wp_query

text: I can read on the docs that if I need to perform a custom WHERE on WP_Query I need to do the following:               // Create a new filtering function that will add our where clause to the query     function filter_where( $where = '' ) {         // posts  30 to 60 days old         $where .= " AND post_date >= '" . date('Y-m-d', strtotime('-60 days')) . "'" . " AND post_date <= '" . date('Y-m-d', strtotime('-30 days')) . "'";         return $where;     }          add_filter( 'posts_where', 'filter_where' );     $query = new WP_Query( $query_string );     remove_filter( 'posts_where', 'filter_where' );      **BUT** what If I need to apply such a WHERE condition on the default query? I already have other conditions being applied during a `pre_get_posts`, something like this:               function homepage_load_posts($query) {       if ($query->is_home()) {         $params = querystring_var('filter');               $query->query_vars['post_type'] = array('blog_post', 'post', 'dossier');          $query->query_vars['posts_per_page'] = 12;               if ($params) {           $valid_categories = valid_categories($params['cat']);           $valid_formats    = valid_formats($params['format']);           $valid_post_types = valid_post_types($params['type']);                if ($valid_categories) $query->query_vars['cat'] = $valid_categories;            if ($valid_formats)    $query->query_vars['tax_query'] = $valid_formats;            if ($valid_post_types) $query->query_vars['post_type'] = $valid_post_types;              }       }     }          add_action('pre_get_posts', 'homepage_load_posts');


title: Merging two Custom Post Types into one

text: I am new to all this so my ignorance may get in the way. I inherited a WP Blog with Custom Post Types. There are 4 Custom Post Types, out of which 2, **Books** and **Magazines** , have the same fields: Custom_Post_Type_Name, Author, City, Address, Categories, Tags, Date. I need to merge these two Custom Post Types into one. More specifically, I need to merge **Books** into **Magazines** and rename this new merged Custom Post Type to **Publications**. Can someone please show me how to do this?


How can I disable/hide certain themes in multisite? I only want certain themes to be used for now.


title: Only show theme option if it option exists

text: I have a slideshow in a custom theme I am developing and I am using the UpThemes Framework, what I want to know is, is there a way and image will only display if it has been defined? For example, at the moment the max. number of images in the slideshow is 6, but if only 5 are uploaded the "alt" attribute displays for the 6th For those unfamiliar with the framework, this is the PHP tag I am using               <?php echo $up_options->slideshow6; ?>      I have done this with custom fields in the past but I can't for the life of me figure out how I did it.


title: How to define %category% for custom taxonomies?

text: So when you put %category% in the permalink structure that tag will be replaced with the path from the root category to the furthest subcategory, where, when placed in multiple categories, it will take the category order in account. So how is this possible for custom taxonomies? I came up with the following code: http://pastebin.com/pVyKzryS I was wondering if someone had a better way to accomplish the same?


title: Convert a Multisite Wordpress install into a Single site

text: Given a wordpress multisite network, with a main blog, and assuming all content has been moved on to that blog, how would one collapse the network back down into a standard wordpress non-network non-multisite install?


title: Override database config for WordPress multisite

text: Our team has run in to a problem working with WordPress 3 multisite. We usually work with a local copy of the site (localhost/testsite) but with the same database to keep all changes up to date. This works fine in a single install because you can override the database configs from PHP with:               define( 'URL', $path );       define( 'WP_HOME', $path );       define( 'WP_SITEURL', $path );       define( 'WP_CONTENT_URL', $path . '/wp-content' );        But this doesn't work on the multisite because of the extra tables (`wp_blogs`, `wp_site`) and they have the path to the blog in their settings. Does anyone know how to override these settings? I would like the site to run on domain **localhost** for our developers, **developerdomain.com** for our test servers and then **realdomain.com** when the site goes live. It feels kind of like overkill if we have to set up different databases for each of them and change the domain and path manually and then copy the post, blog and user data between the databases to do debugging and continue the development...


title: Sort posts by newest child while keeping hierarchy intact

text:
I have the following hierarchy within my wordpress posts (e.g.):               -> Post 1 (pubdate: 2011-01-01)      --> Post 5 (pubdate: 2011-01-02)       ---> Post 6 (pubdate: 2011-01-03)        ----> Post 7 (pubdate: 2011-01-04)          -> Post 2 (pubdate: 2011-03-01)      --> Post 8 (pubdate: 2011-03-02)          -> Post 3 (pubdate: 2011-02-01)      --> Post 9 (pubdate: 2011-02-02)       ---> Post 10 (pubdate: 2011-02-03)          -> Post 4 (pubdate: 2011-04-01)      What I now would like to achieve is to sort the parent posts by the publish date of the newest respective child post. The important thing is that the hierarchy should stay intact. This would lead to the following order in the example (from newest to oldest):               -> Post 4 (pubdate: 2011-04-01)          -> Post 2 (pubdate: 2011-03-01)      --> Post 8 (pubdate: 2011-03-02)          -> Post 3 (pubdate: 2011-02-01)      --> Post 9 (pubdate: 2011-02-02)       ---> Post 10 (pubdate: 2011-02-03)          -> Post 1 (pubdate: 2011-01-01)      --> Post 5 (pubdate: 2011-01-02)       ---> Post 6 (pubdate: 2011-01-03)        ----> Post 7 (pubdate: 2011-01-04)      Any idea how I can get this working? Thanks! **EDIT:** I added the following part based on the question of Rarst on how i retrieve the structure. I retrieve the posts with the following query:               $args = array(       'cat' => 7,       'post_type' => 'articles',        'orderby' => 'post_date',        'posts_per_page' => -1,        'order' => 'DESC'      );      $records = get_posts($args);     foreach($records as $post) {       get_template_part( 'index', 'article' );     } I then use this function to check how many parents an article has...               // count amount of parents of a post     function usr_count_children($cid) {       $childrenArray = count(get_pages("post_type=articles&child;_of=".$cid));       return $childrenArray;     } ...and add the returned number as css class to the html element of the article (which is then styled based on that). **EDIT 2:** Ok, that's what I've got so far:                   $parentPosts = get_posts(array(         'cat' => 7,          'post_type' => 'articles',         'post_status' => 'publish',         'post_parent' => 0,          'posts_per_page' => -1,         'orderby' => 'post_date',         'order' => 'DESC' ));          foreach ($parentPosts as $post){              echo "+ ".$post->post_title." ID: ".$post->ID."
";              // Look up newest child (query, sort by date, limit to one)         $newestChild = get_pages(array(             'child_of' => $post->ID,             'post_type' => 'articles',             'post_status' => 'publish',             'sort_column' => 'post_date',             'sort_order' => 'DESC',             'number' => 1 ));              foreach($newestChild as $child){             echo "– ".$child->post_title." ID: ".$child->ID."
";         }     }      I'm stuck with the second query (get newest child), it wont return any children unless I remove `'number' => 1`. I really tried a few things (like using WP_Query instead, I even tried raw SQL queries) but I can't get my head around it. Anyone?


title: query posts returns 10 records

text: I am using the following code to fetch records from a custom taxonomy.               if ($_GET['post_type'] == "developments"){ ?>                         <?php                          global $wp_query;                         $paged = $wp_query->query_vars['paged'];                              $development_args = array(                             'post_type' => $_GET['post_type'],                             'orderby' =>'title',                             'order' => 'ASC',                             'posts_per_page' => 14,                             'paged' => $paged,                              's' => $_GET['search_building_name'],                         );                         $development_args['meta_query'] = array(                             'relation'=>'AND',                             array(                                 'key' => 'total_units',                                 'type' => 'numeric',                                 'value' => $_GET['search_total_units'],                                 'compare' => $_GET['total_units_operator']                             ),                             array(                                 'key' => 'total_floors',                                 'type' => 'numeric',                                 'value' => $_GET['search_total_floors'],                                 'compare' => $_GET['total_floors_operator']                             ),                         );                         $development_args['tax_query'] = array(                             'relation' => 'AND',                             array(                                 'taxonomy' => 'type',                                 'field' => 'slug',                                 'terms' => $_GET['search_type'],                                 //'operator' => 'AND'                             ),                             array(                                 'taxonomy' => 'amenities',                                 'field' => 'slug',                                 'terms' => $_GET['search_amenities'],                                 'operator' => 'AND'                             ),                             array(                                 'taxonomy' => 'style',                                 'field' => 'slug',                                 'terms' => $_GET['search_style'],                                 'operator' => 'AND'                             ),                         );                         if ($_GET['search_neighborhood'] != 'any'){                         $development_args['tax_query'][] = array(                                 'taxonomy' => 'neighborhood',                                 'field' => 'slug',                                 'terms' => $_GET['search_neighborhood'],                             );                         }                         if ($_GET['search_developer'] != 'any'){                         $development_args['tax_query'][] = array(                                 'taxonomy' => 'developer',                                 'field' => 'slug',                                 'terms' => $_GET['search_developer'],                             );                         }                                                if ($_GET['search_architect'] != 'any'){                         $development_args['tax_query'][] = array(                                 'taxonomy' => 'architect',                                 'field' => 'slug',                                 'terms' => $_GET['search_architect'],                             );                         }                                                if ($_GET['search_delivered'] != 'any'){                         $development_args['tax_query'][] = array(                                 'taxonomy' => 'delivered',                                 'field' => 'slug',                                 'terms' => $_GET['search_delivered'],                             );                         }                                                     query_posts($development_args );                     }      $wp_query->post_count returns 10, even when the actual number of records is lot more. I have tried various solutions but none work for me. This question could be a duplicate but i am asking this again because even a few answers have worked for other people but none have given a good explanation. Thanks


Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php? I have a mu-functions.php file in the mu-plugins folder. One function calls a javascript file (`alerts.js`) located in `example.com/wp- content/mu-plugins/js/`. How can I target the mu-plugins folder in my function? Currently, I am using `get_site_url() . '/wp-content/mu- plugins/js/alerts.js',` Although not completely relevant to the question, this is the complete function used to call the javascript file:               function load_my_alerts(){           wp_register_script(              'my_alerts',              get_site_url() . '/wp-content/mu-plugins/js/alerts.js',              array( 'jquery' )         );         wp_enqueue_script( 'my_alerts' );     }     add_action('admin_enqueue_scripts', 'load_my_alerts');


title: What possible reasons can cause my plugin not to be listed in the plugin search in the back-end of wordpress installs?

text: our plugin is listed on wordpress.org but it can't be found if you go in the backend of a WP install and search for it under Plugins -> Add New. Our plugin was delisted some time ago from wordpress.org but now it's listed again, why is it not appearing in search results? This is the body of the all-in-one-event-calendar.php file               <?php     /**      * Plugin Name: All-in-One Event Calendar by Timely      * Plugin URI: http://time.ly/      * Description: A calendar system with month, week, day, agenda views, upcoming events widget, color-coded categories, recurrence, and import/export of .ics feeds.      * Author: Timely      * Author URI: http://time.ly/      * Version: 1.10      */     @set_time_limit( 0 );     @ini_set( 'memory_limit',           '256M' );     @ini_set( 'max_input_time',         '-1' );          // ===============     // = Plugin Name =     // ===============     define( 'AI1EC_PLUGIN_NAME',        'all-in-one-event-calendar' );          // ===================     // = Plugin Basename =     // ===================     define( 'AI1EC_PLUGIN_BASENAME',    plugin_basename( __FILE__ ) );          // ==================     // = Plugin Version =     // ==================     define( 'AI1EC_VERSION',            '1.10' );          // ====================     // = Database Version =     // ====================     define( 'AI1EC_DB_VERSION',         109 );          // ==========================     // = Bundled themes version =     // ==========================     define( 'AI1EC_THEMES_VERSION',     8 );          // ================     // = Cron Version =     // ================     define( 'AI1EC_CRON_VERSION',       104 );     define( 'AI1EC_N_CRON_VERSION',     103 );     define( 'AI1EC_N_CRON_FREQ',        'daily' );     define( 'AI1EC_UPDATES_URL',        'http://time.ly/plugin/standard/latest' );          // ===============     // = Plugin Path =     // ===============     define( 'AI1EC_PATH',               dirname( __FILE__ ) );          // ===================     // = CSS Folder name =     // ===================     define( 'AI1EC_CSS_FOLDER',         'css' );          // ==================     // = JS Folder name =     // ==================     define( 'AI1EC_JS_FOLDER',          'js' );          // =====================     // = Image folder name =     // =====================     define( 'AI1EC_IMG_FOLDER',         'img' );          // ============     // = Lib Path =     // ============     define( 'AI1EC_LIB_PATH',           AI1EC_PATH . '/lib' );          // =================     // = Language Path =     // =================     define( 'AI1EC_LANGUAGE_PATH',      AI1EC_PLUGIN_NAME . '/language' );          // ============     // = App Path =     // ============     define( 'AI1EC_APP_PATH',           AI1EC_PATH . '/app' );          // ===================     // = Controller Path =     // ===================     define( 'AI1EC_CONTROLLER_PATH',    AI1EC_APP_PATH . '/controller' );          // ==============     // = Model Path =     // ==============     define( 'AI1EC_MODEL_PATH',         AI1EC_APP_PATH . '/model' );          // =============     // = View Path =     // =============     define( 'AI1EC_VIEW_PATH',          AI1EC_APP_PATH . '/view' );          // ====================     // = Admin Theme Path =     // ====================     define( 'AI1EC_ADMIN_THEME_PATH',   AI1EC_VIEW_PATH . '/admin' );          // ==================     // = Admin theme CSS path =     // ==================     define( 'AI1EC_ADMIN_THEME_CSS_PATH', AI1EC_ADMIN_THEME_PATH . '/' . AI1EC_CSS_FOLDER );          // =======================     // = Admin theme JS path =     // =======================     define( 'AI1EC_ADMIN_THEME_JS_PATH', AI1EC_ADMIN_THEME_PATH . '/' . AI1EC_JS_FOLDER );          // ========================     // = Admin theme IMG path =     // ========================     define( 'AI1EC_ADMIN_THEME_IMG_PATH', AI1EC_ADMIN_THEME_PATH . '/' . AI1EC_IMG_FOLDER );          // ===============     // = Helper Path =     // ===============     define( 'AI1EC_HELPER_PATH',        AI1EC_APP_PATH . '/helper' );          // ==================     // = Exception Path =     // ==================     define( 'AI1EC_EXCEPTION_PATH',     AI1EC_APP_PATH . '/exception' );          // ==============     // = Plugin Url =     // ==============     define( 'AI1EC_URL',                plugins_url( '', __FILE__ ) );          // ==============     // = Images URL =     // ==============     define( 'AI1EC_IMAGE_URL',          AI1EC_URL . '/' . AI1EC_IMG_FOLDER );          // ===========     // = CSS URL =     // ===========     define( 'AI1EC_CSS_URL',            AI1EC_URL . '/' . AI1EC_CSS_FOLDER );          // ==========     // = JS URL =     // ==========     define( 'AI1EC_JS_URL',             AI1EC_URL . '/' . AI1EC_JS_FOLDER );          // ================     // = Admin JS URL =     // ================     define( 'AI1EC_ADMIN_THEME_JS_URL', AI1EC_URL . '/app/view/admin/' . AI1EC_JS_FOLDER );          // =================     // = Admin CSS URL =     // =================     define( 'AI1EC_ADMIN_THEME_CSS_URL', AI1EC_URL . '/app/view/admin/' . AI1EC_CSS_FOLDER );          // =================     // = Admin IMG URL =     // =================     define( 'AI1EC_ADMIN_THEME_IMG_URL', AI1EC_URL . '/app/view/admin/' . AI1EC_IMG_FOLDER );          // =============     // = POST TYPE =     // =============     define( 'AI1EC_POST_TYPE',          'ai1ec_event' );          // =====================================================     // = UPDATE THEMES PAGE BASE URL (wrap in admin_url()) =     // =====================================================     define( 'AI1EC_UPDATE_THEMES_BASE_URL', 'edit.php?post_type=' . AI1EC_POST_TYPE . '&page=' . AI1EC_PLUGIN_NAME . '-update-themes' );          // =====================================================     // = FEED SETTINGS PAGE BASE URL (wrap in admin_url()) =     // =====================================================     define( 'AI1EC_FEED_SETTINGS_BASE_URL', 'edit.php?post_type=' . AI1EC_POST_TYPE . '&page=' . AI1EC_PLUGIN_NAME . '-feeds' );          // ================================================     // = SETTINGS PAGE BASE URL (wrap in admin_url()) =     // ================================================     define( 'AI1EC_SETTINGS_BASE_URL',  'edit.php?post_type=' . AI1EC_POST_TYPE . '&page=' . AI1EC_PLUGIN_NAME . '-settings' );          // ======================     // = Default Theme Name =     // ======================     define( 'AI1EC_DEFAULT_THEME_NAME', 'vortex' );          // =============================     // = Default Theme folder name =     // =============================     define( 'AI1EC_THEMES_FOLDER',      'themes-ai1ec' );          // ========================     // = AI1EC Theme location =     // ========================     define( 'AI1EC_THEMES_ROOT',        WP_CONTENT_DIR . '/' . AI1EC_THEMES_FOLDER );          // ===================     // = AI1EC Theme URL =     // ===================     define( 'AI1EC_THEMES_URL',         WP_CONTENT_URL . '/' . AI1EC_THEMES_FOLDER );          // ======================     // = Default theme path =     // ======================     define( 'AI1EC_DEFAULT_THEME_PATH', AI1EC_THEMES_ROOT . '/' . AI1EC_DEFAULT_THEME_NAME );          // =====================     // = Default theme url =     // =====================     define( 'AI1EC_DEFAULT_THEME_URL',  AI1EC_THEMES_URL . '/' . AI1EC_DEFAULT_THEME_NAME );          // ======================================================     // = INSTALL THEMES PAGE BASE URL (wrap in admin_url()) =     // ======================================================     define( 'AI1EC_INSTALL_THEMES_BASE_URL', 'themes.php?page=' . AI1EC_PLUGIN_NAME . '-install-themes' );          // ================     // = RSS FEED URL =     // ================     define( 'AI1EC_RSS_FEED',           'http://time.ly/feed/' );          // ======================================     // = FAKE CATEGORY ID FOR CALENDAR PAGE =     // ======================================     define( 'AI1EC_FAKE_CATEGORY_ID',   -4113473042 ); // Numeric-only 1337-speak of AI1EC_CALENDAR - ID must be numeric          // ==============     // = SCRIPT URL =     // ==============     $ai1ec_script_url = get_option( 'home' ) . '/?plugin=' . AI1EC_PLUGIN_NAME;     define( 'AI1EC_SCRIPT_URL',         $ai1ec_script_url );          // ====================================================     // = Convert http:// to webcal:// in AI1EC_SCRIPT_URL =     // =  (webcal:// protocol does not support https://)  =     // ====================================================     $tmp = str_replace( 'http://', 'webcal://', AI1EC_SCRIPT_URL );          // ==============     // = EXPORT URL =     // ==============     define( 'AI1EC_EXPORT_URL',         $tmp . "&controller=ai1ec_exporter_controller&action=export_events&cb=" . rand() );          // ====================================     // = Include iCal parsers and helpers =     // ====================================     if( version_compare( PHP_VERSION, '5.3.0' ) >= 0 ) {         // Parser that requires PHP v5.3.0 or up         require_once( AI1EC_LIB_PATH . '/iCalcreator-2.14/iCalcreator.class.php' );     } else {         // Parser that works on PHP versions below 5.3.0         require_once( AI1EC_LIB_PATH . '/iCalcreator-2.10/iCalcreator.class.php' );         require_once( AI1EC_LIB_PATH . '/iCalcreator-2.10/iCalUtilityFunctions.class.php' );     }     require_once( AI1EC_LIB_PATH . '/SG_iCal.php' );     require_once( AI1EC_LIB_PATH . '/helpers/SG_iCal_Line.php' );     require_once( AI1EC_LIB_PATH . '/helpers/SG_iCal_Duration.php' );     require_once( AI1EC_LIB_PATH . '/helpers/SG_iCal_Freq.php' );     require_once( AI1EC_LIB_PATH . '/helpers/SG_iCal_Recurrence.php' );     require_once( AI1EC_LIB_PATH . '/helpers/SG_iCal_Parser.php' );     require_once( AI1EC_LIB_PATH . '/helpers/SG_iCal_Query.php' );     require_once( AI1EC_LIB_PATH . '/helpers/SG_iCal_Factory.php' );     // include our global functions     require_once( AI1EC_LIB_PATH . '/global-functions.php' );          // ===============================     // = The autoload function =     // ===============================     function ai1ec_autoload( $class_name )     {         // Convert class name to filename format.         $class_name = strtr( strtolower( $class_name ), '_', '-' );         $paths = array(             AI1EC_CONTROLLER_PATH,             AI1EC_MODEL_PATH,             AI1EC_HELPER_PATH,             AI1EC_EXCEPTION_PATH,             AI1EC_LIB_PATH,             AI1EC_VIEW_PATH,             AI1EC_ADMIN_THEME_PATH,             get_option( 'ai1ec_current_theme_path', AI1EC_DEFAULT_THEME_PATH ),             AI1EC_DEFAULT_THEME_PATH         );              // remove duplicates from the paths array         $paths = array_unique( $paths );              // Search each path for the class.         foreach( $paths as $path ) {             if( file_exists( "$path/class-$class_name.php" ) )                 require_once( "$path/class-$class_name.php" );         }     }     spl_autoload_register( 'ai1ec_autoload' );          // ===============================     // = Initialize and setup MODELS =     // ===============================     global $ai1ec_settings;          $ai1ec_settings = Ai1ec_Settings::get_instance();               // ================================     // = Initialize and setup HELPERS =     // ================================     global $ai1ec_view_helper,            $ai1ec_settings_helper,            $ai1ec_calendar_helper,            $ai1ec_app_helper,            $ai1ec_events_helper,            $ai1ec_importer_helper,            $ai1ec_exporter_helper;          $ai1ec_view_helper     = Ai1ec_View_Helper::get_instance();     $ai1ec_settings_helper = Ai1ec_Settings_Helper::get_instance();     $ai1ec_calendar_helper = Ai1ec_Calendar_Helper::get_instance();     $ai1ec_app_helper      = Ai1ec_App_Helper::get_instance();     $ai1ec_events_helper   = Ai1ec_Events_Helper::get_instance();     $ai1ec_importer_helper = Ai1ec_Importer_Helper::get_instance();     $ai1ec_exporter_helper = Ai1ec_Exporter_Helper::get_instance();          // ====================================     // = Initialize and setup CONTROLLERS =     // ====================================     global $ai1ec_app_controller,            $ai1ec_settings_controller,            $ai1ec_events_controller,            $ai1ec_calendar_controller,            $ai1ec_importer_controller,            $ai1ec_exporter_controller,            $ai1ec_themes_controller;          $ai1ec_settings_controller  = Ai1ec_Settings_Controller::get_instance();     $ai1ec_events_controller    = Ai1ec_Events_Controller::get_instance();     $ai1ec_calendar_controller  = Ai1ec_Calendar_Controller::get_instance();     $ai1ec_importer_controller  = Ai1ec_Importer_Controller::get_instance();     $ai1ec_exporter_controller  = Ai1ec_Exporter_Controller::get_instance();     $ai1ec_themes_controller    = Ai1ec_Themes_Controller::get_instance();          // ==========================================================================     // = All app initialization is done in Ai1ec_App_Controller::__construct(). =     // ==========================================================================     $ai1ec_app_controller      = Ai1ec_App_Controller::get_instance();


title: get multiple values from $_GET from multiple checkboxes

text:
I'm creating a form that loops through all the terms of a taxonomy. Multiple terms can be selected and they get passed in the url. I'm trying to get all the terms on another page but I'm only able to get the last one. I'm not sure if this is the best way to do this but if anyone can give me a tip as to what I'm doing wrong. First, here is the form                                       <form method="get" id="searchProperties" action="<?php echo home_url()?>/filter-2/?">                                 <?php                             $termsCounty = get_terms( 'County', array(                                   'hide_empty' => 0                                   ) );                             echo '
';                                 foreach ($termsCounty as $term) {                                     $termCounty = $term->name . 'PropertyFilter';                                     echo '
<input type="checkbox" name="t"  value="il_' . $term->name . '">' .$term->name. '
';                                 }                             echo '
';                                  ?><input type="submit" value="FILTER"/>                             </form>      And here is where the choices are accessed:               echo $term = $_GET['t'];      Any suggestions? Thanks in advance!


title: Sublime Video: Playlist which gets all attached videos

text: I searched a way to automatically load all attached videos in a custom post type as SublimeVideo playlist. After some time I got it working and here I'll share the code with everyone who is interested to do it the same way.


title: Eliminating the appearance of a specific custom field in a post

text: I would like to suppress the output of one of my custom fields. Is there a way to do this using the `<?php the_meta(); ?>`command?


title: Reproducing hierarchical list output from wp_list_categories, using get_categories()

text: I need more control over the category listing output, so I'm using get_categories (http://codex.wordpress.org/Function_Reference/get_categories), instead of wp_list_categories (http://codex.wordpress.org/Template_Tags/wp_list_categories). This function returns a flat array of objects ordered by a certain attribute. How can I build a hierarchical list from it like wp_list_categories() does?


title: Adding HTML to the Header, Screws up in IE7

text: Working on a site for a client: http://esteyprinting.jasinternetmarketing.com/ I added an HTML table to header.php to include the "Call us at..." and the social media icons. It renders fine in most browsers but IE7 screws up that table. I ran it through the W3C validator and that part of the code is fine. You can see what I mean by putting the above URL into: http://ipinfo.info/netrenderer/ Any ideas for how to solve the problem? Thanks! Jim


title: get_comments_number of depth-1 (Level 1) (1 post)

text: I selected only 2 levels of comment for my wordpress site. How can I display the number of comment of the first level ? (Depth-1)


title: Passing variables trough 2 pages

text: I am creating a plugin. In this plugin I have shortcodes that provide some logic and content for pages. This way I have created 'Page A' and 'Page B'. Both of the pages will redirect user to external page. The external page is not written by me and will not process any of my $_GET or $_POST values. Then this external page will redirect user back to my plugin 'Page C'. Now how to make 'Page C' know if the external page was reached from 'Page A' or 'Page B'? Normally I would use sessions, but I have read that wordpress does not support sessions. How can I do it then? HoGo


title: How to handle a "Error establishing a database connection"?

text: For a little project i am using WP by loading               require( '../site/wp-load.php');      When the local msyql server is running everything works great. But in certain situations the local mysql server isn't running or the password isn't correct and the Response Header reads `Error establishing a database connection` How can i catch this error and output a custom message as the frontend of this project looks like it's running ok?


title: Adding CSS to custom post type admin page causes error

text: I have this bit of code in my Meteor Slides plugin that loads a stylesheet on the admin pages of just the slides custom post type:                   add_action('admin_head', 'meteorslides_admin_css');          function meteorslides_admin_css() {              global $post_type;              if (($_GET['post_type'] == 'slide') || ($post_type == 'slide')) :                  echo "<link type='text/css' rel='stylesheet' href='" . plugins_url('/css/meteor-slides-admin.css', __FILE__) . "' />";              endif;          }      This code works fine and hasn't cause any issues, but in debug mode, it does cause this error that I'd like to resolve:               // Notice: Undefined index: post_type in C:\Program Files\xampp\htdocs\slides\wp-content\plugins\meteor-slides-1.3\meteor-slides-plugin.php on line 476      I haven't been able to fix this error, does anyone have any suggestions, or a different way to add a stylesheet to the admin pages of a certain post type?


title: Using page title as a link to term archive

text:
i want to do something like that (pay attention to line 4):               $term_link = get_term_link( $term, 'genre1' );     if( is_wp_error( $term_link ) )         continue;     echo '
***<?php the_title();?>***
';      but i dont sure how.


title: Advanced theme training?

text: I've read a few books on building WP themes and I certainly understand the basics. I would like to know read up on advanced topics like hooks, wp_rewrite and how functions.php should be structured. Can anyone recommend any good resources?


title: My Category is too big on the Menu what can i do?

text: Currently I have a small amount of 100 categories and my MENU goes crazy big and I would like to be able to do 2 things if possible:   * First category menu with limited amount categories sorted by hits   * Second category menu with limited amount of categories choose by myself Is there any simple way to acomplish this either manually editing part of the code but yet allowing me to render the category by the wordpress code instead of having to type each by hand or a plugin with already such features ? PS: I was trying to use the search for this but even using "Category Menu too big" there were so many unrelated answer that it was hard to find anything good to my case.


title: When to load auto-login code?

text: I'm using this (simplified) code to automatically login users via a plugin for a single sign-on system:               $user_info = get_userdatabylogin( $username );     $user_id = $user_info->ID;     wp_set_current_user( $user_id );     wp_set_auth_cookie( $user_id );     do_action( 'wp_login', $username );      Many code snippets that I've found online will bind this code to the `init` action. When using `init`, I'm having some trouble with the timing of elements loading on the page. For example, the user toolbar only appears on the second page load while the `Log In` meta link changes to `Logout` on the first. It seems that some elements are loading before the user session is setup. When should I load this code? Looking at http://codex.wordpress.org/Plugin_API/Action_Reference, is plugins_loaded the best time? Thanks, Mike


title: How to include external page to wordpress page?

text: I have one external page (`google_map.php`) which contain code to display google map information based on the selection criteria. And in the wordpress page I want to display the google map which is coded in `google_map.php`. I want to ask that how can I add `google_map.php` page in my wordpress page? Or other option, Can i directly add my `google_map.php` page code to the wordpress page? I don't want to use any plugin to support php code in the wordpress page like Exec-PHP plugin. Which is the better way?


title: How do I programmatically create new posts of a custom post type over the XML-RPC API?

text:
I would like to programmatically create posts of a custom post type with custom taxonomies over the XML-RPC API. This is what I have so far:               <?php          class XMLRPClientWordPress {              var $XMLRPCURL = "";         var $UserName = "";         var $PassWord = "";              // constructor         public function __construct($xmlrpcurl, $username, $password) {             $this->XMLRPCURL = $xmlrpcurl;             $this->UserName = $username;             $this->PassWord = $password;         }              function send_request($requestname, $params) {             $request = xmlrpc_encode_request($requestname, $params);             $ch = curl_init();             curl_setopt($ch, CURLOPT_POSTFIELDS, $request);             curl_setopt($ch, CURLOPT_URL, $this->XMLRPCURL);             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);             curl_setopt($ch, CURLOPT_TIMEOUT, 1);             $results = curl_exec($ch);             curl_close($ch);             return $results;         }         function create_post($title, $body, $category, $keywords = '', $encoding = 'UTF-8') {             $title = htmlentities($title, ENT_NOQUOTES, $encoding);             $keywords = htmlentities($keywords, ENT_NOQUOTES, $encoding);             $content = array(                 'title' => $title,                 'description' => $body,                 'mt_allow_comments' => 0, // 1 to allow comments                 'mt_allow_pings' => 0, // 1 to allow trackbacks                 'post_type' => 'post',                 'mt_keywords' => $keywords,                 'categories' => array($category)             );             $params = array(0, $this->UserName, $this->PassWord, $content, true);                  return $this->send_request('metaWeblog.newPost', $params);         }          }          $objXMLRPClientWordPress = new XMLRPClientWordPress("localhost/wordpress/xmlrpc.php", "admin", "abbas");          echo '
';     echo 'metaWeblog.newPost	';     echo '' . $objXMLRPClientWordPress->create_post('Hello WordPress XML-RPC', 'This is the content of post done via XML-RPC', '') . '	';     echo '
';     ?>


title: Broken thumbnails (sometimes) with TimThumb

text: Reinstalled theme with latest version of TimThumb (was previously effected by the vulnerability issue). Now most of my thumbnails work, but some do not. My theme relies on this plugin, so I'm not sure I have any other option but to use TimThumb, but this is pretty frustrating. The worse thing is that the bug is only effecting certain photos of mine but not the rest. Clicking on the broken thumbnail directs to the full size image, so the image itself is good, but no matter what I do, that thumbnail won't generate. I've tried renaming the files, re-exporting from the master .psd file to a jpg with a different name, changing the total size of the image, even changing the color space, and nothing can convince this plugin to create a thumbnail for certain of my photos. What the hell is going on? Any insight is appreciated. www.redtownphoto.com Checkout "Test" in my menu to see what I'm referring to. Thanks in advance for any help. I could sure use it. _update_ 2 complete galleries have now died on me suddenly and thumbnails are completely broken. It looks like this issue is worse than I thought.


title: Wordpress Landing Page Redirection Issue

text: This might be a basic issue but I did not know the keywords to search it with. I am working on a Wordpress site. The landing page has the following url: `http://www.abc.com/home/` But when I visit this url, the page is redirected to: `http://www.abc.com/` Although the template that loads on the url `http://www.abc.com/`, is the same which has to be loaded on the url `http://www.abc.com/home/`, but for some reasons I really want the `"/home/"` part. The url works fine for other pages. That is if I visit "Contact" page, correct url is loaded in the address bar "`http://www.abc.com/contact/`" This is the .htaccess file that I currently have:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress


title: Displaying an image's alt title and caption inside a fancybox window. Working, but showing the same alt and caption for each image

text: I've been at this for hours so maybe someone here can help :) Basically I have a fancybox gallery that loads images attached to a post. As you can see below, I want to echo either the image's caption or alt title into the fancybox window. Currently it works, but it only shows the alt and caption for **one** of the images, which looks to be the first. I can echo the alt title and caption of each image onto the page fine, but when it's used inside the fancybox window there's an issue. Anyone know why? Do I need to do some more looping or something? thanks for looking!


title: Wanted: PayPal plugin for Wordpress

text: i am currently searching for a wordpress plugin to integrate a paypal purchasing form conveniently to a blog. The goal is to have an order form where users have the option to either decide to order a product home or to purchase the product in digital and receive a tokenized downloadlink - of course after purchase approval from paypal. does anyone know a plugin for wordpress that does this job? many thanks!


title: Different rss feeds in a single dashboard widget

text:
I am using this snip of code to get rss feed on my dashboard as widget. It becomes problematic when it displays 5-6 different rss feeds which makes me run down deep. How can I add 6 different feeds in a single dashboard widget with scroll bar? Thanks                   add_action('wp_dashboard_setup', 'my_dashboard_widgets');     function my_dashboard_widgets() {          global $wp_meta_boxes;          // remove unnecessary widgets          // var_dump( $wp_meta_boxes['dashboard'] ); // use to get all the widget IDs          unset(               $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'],               $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'],               $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']          );          // add a custom dashboard widget          wp_add_dashboard_widget( 'dashboard_custom_feed', 'Latest News', 'dashboard_custom_feed_output' ); //add new RSS feed output     }     function dashboard_custom_feed_output() {          echo '
';          wp_widget_rss_output(array(               'url' => 'http://www.nytimes.com/feed',  //put your feed URL here               'items' => 4, //how many posts to show               'show_summary' => 1          ));          echo "
";     }


title: Pointing multiple subdomains at the same WordPress Installation

text: We have some branded subdomains for clients in our application. so client.ourdomain.com gets some minor customization to the look and feel. We are now creating some marketing pages and implementing WordPress as a CMS but we want to be able to keep the branding per subdomain. Basically we want client1.ourdomain.com to point to the same installation as www.ourdomain.com but the menus at least need to point to client1.ourdomain.com. The same would be true for client2.ourdomain.com, etc. The list of branded subdomains is a fixed list and approximately 20.


title: Call to undefined function add_action()

text: I created a Theme Options page where the user can edit some of the theme settings. Now I'm trying to save this options asynchronously but it seems I have some problems integrating the handler file into WP. The Theme Options is a simple admin page nested under Appearance. When pressing the save button:               <a id = "save-settings" href = "#" data-nonce = "<?php wp_create_nonce("sace_settings_nonce") ?>"><?php echo _('Save Settings') ?>      the following JS script is called:               function(){         jQuery.ajax({             type : 'POST',             url : themeRoot + 'framework/AsyncAction.php',             data: { action  : 'save_settings',                     name    : 'John',}             }).done(function(resp) {                 alert(resp);             });     },      The handler `.php` file contains:               <?php     include_once('SettingsController.php');     define ('SAVE_SETTINGS', 'save_settings');          add_action('wp_ajax_save_settings', 'save_settings');          function save_settings(){         global $controller;         $name = esc_attr($_POST['name']);         echo 'Hi, ' . $name;     }          ?>      Running this code throws the following error:               Fatal error: Call to undefined function add_action()      I also tryied:   1. hook the action on init -> same problem   2. remove the hook completely. This caused the undefined error to be thrown for `esc_attr()` It seems that I don't have access to any of the WP functions but I have no idea how to fix it. Thanks!


title: get_posts includes "auto drafts"?

text: I'm using get_posts to generate a list of posts.               $args = array(         'post_type'     => 'post',         'numberposts'       => -1,         'post_status'       => array('publish'),         'orderby'       => 'post_date',         'order'         => 'DESC',         'suppress_filters'  => false     );          $posts = get_posts( $args );      However, the list includes posts named _"Auto-Draft"_ , even though I do not include them in the `'post_status'` parameter. As far as I read those Auto- Drafts should be only existing for 7 days, but the posts that show up in the list are far older than 7 days. Anything I'm missing? Thanks!


title: Different Slugs depending on last page

text: is it possible to configure WordPress on some way that if i have a portfolio Item ( from my theme ) which will be opened from 2 different pages and w/o an URL jump so that www.xyz.com/brands/example and www.xyz.com/brands/ourbrands/example woud redrict to the same portfolio item, the current solution is that both woud redrict to www.xyz.com/portfolio/example, ofc i can change the "portfolio" slug to sth. different but that woudnt solve the problem since the URL woud still jump :/ Custom Post types is NOT an option. Hopefully someone can help me here :D Thanks in advance Manuel


title: Where's The Best Place to use Register_Shutdown_Function()?

text: I want to use Register Shutdown Function to track Fatal Errors, my question is, where's the best place to call this so it hits both WordPress, Plugin, and Theme Fatal Errors?


title: WP Rewrite Rules - insert custom rules

text: function rewriteRules() {             add_filter( 'rewrite_rules_array', array( $this, 'my_insert_rewrite_rules'));             add_filter( 'query_vars',array( $this, 'my_insert_query_vars'));             add_action( 'wp_loaded',array( $this, 'my_flush_rules'));         }         function my_flush_rules(){             $rules = get_option( 'rewrite_rules' );             if ( ! isset( $rules['curs-calificare-profesionala/(\s*)$-(\d*)$'] ) ) {                 global $wp_rewrite;                 $wp_rewrite->flush_rules();             }         }         function my_insert_rewrite_rules( $rules ) {             $newrules = array();             $newrules['curs-calificare-profesionala)/(\s*)$-(\d*)$'] = 'index.php?pagename=course&course=$matches[1]&cid=$matches[2]';             return $newrules + $rules;         }         function my_insert_query_vars( $vars ) {             array_push($vars, 'cid');             return $vars;         }              public static function courseDetailsUrl($name, $id ) {             $prefix = '/curs-calificare-profesionala/';             $url = $new_url = sanitize_title( $name );             $suffix = '-'.$id;             return $prefix . $url . $suffix;         }      what i want: http://domain.ro/curs-formare-profesioanal/curs-masaj-17 -> index.php?pagename=course&course=curs-masaj&cid=17. I can declare course.php in my theme for this URL? Please help!!!


title: Which hook if user profile information is updated?

text: I'm looking for the hook that fires when a user's information are updated. Specifically, I want to update a post with the value of a custom profile field (in my example `info`) everytime that user's profile is updated. I tried the `profile_update` hook, but it doesn't seem to fire:               add_action( 'profile_update', 'add_info_to_post' );     function add_info_to_post( $user_id ) {                  $info=get_user_meta($user_id,'info',true);                  //get all items of that user             $args=array(                     'author' => $user_id,                     'post_type' => 'item',             );                  $items=get_posts($args);                         foreach ($items as $item){             update_post_meta($item->ID,'user_info',$info);             }     }      Any suggestions how to make this work? EDIT: Maybe I should mention that I access the users' profile pages through the backend..


title: how can I create a calendar for a cpt, using get_calendar or other

text: I have a custom post type with its own date field. the date is setup for unix YYYY/mm/dd I need to create a simple month calendar that shows days that have a cpt on them. get_calendar works for posts but not a CPT.


title: How can I make my website with wordpress having on-spot editing feature as compared to concrete5 CMS?

text: I hope you were easily able to understand my situation through the question. 1.Do we have any theme or plugin for on-spot editing the post by people or by me after the blog post is posted? 2.If there isn't any theme or pluggin for such feature should I make plugin or theme independently for my website. 3.If both of the above fails,please give me a better option for some other kind of CMS as there are no many cms and I want to make my website with dynamic features. Please follow the link below and kindly suggest me one. http://en.wikipedia.org/wiki/List_of_content_management_systems


title: How to update records using $wpdb?

text: I am migrating non-wp database to Wordpress (for the first time in my life, and hopefully the last). As both new and old websites are multilingual, one of the tasks for me is to connect the articles with its translations. I am using WPML plugin for multi language support on Wordpress. This plugin creates a table, `wp_icl_translations` with the following structure:               element_id | trid       | language_code           | source_language_code     ---------------------------------------------------------------------------     (post id)  | (group id) | (of the translated post)| (of the original post)      `trid` is the id of the original post id and all translations of one original post have the same value for the `trid`. If the post is original, `trid` is the same as `element_id` which is the post id, and `source_language_code` is `NULL`. Couple of notes on the posts I have:   * Not all posts are translated to all the languages (I have 8 languages)   * There are posts that have only original entries in any language In the old database posts had `item_id` which was the same for all the translations of one article. When I migrated them, I added this `item_id` as `meta_value` for each posts. I did the same for the language code, so I was able to create a custom table where I would have a connection between post ids of the wordpress database and item_ids and language codes of old database. This custom table, `id_item_lid`, has the following structure:               id                           | item_id                     | lid     ---------------------------------------------------------------------------     post id assigned by wordress | old item_id                 | language code                                  | (translations share this id)|      So in short I need to update `trid` column of `wp_icl_translations` with the post ids of posts that share the same `item_id` in `id_item_lid` table. Here is the function I came up with:               function rkm_translation_update() {     global $wpdb;     $trans_row = $wpdb->get_row("SELECT * FROM id_item_lid", OBJECT, 0);     $id = $trans_row->id;     $item = $trans_row->item_id;     $lid = $trans_row->lid;          $trans_array = $wpdb->get_results("SELECT * FROM id_item_lid");     foreach ($trans_array as $trans) {         $id_new = $trans->id;         $item_new = $trans->item_id;         $lid_new = $trans->lid;         if ($item === $item_new) {             $wpdb->update('wp_icl_translations', array('trid' => $id, 'source_language_code' => $lid), array('element_id' => $id_new));         } else {             $id = $trans->id;             $item = $trans->item_id;             $lid = $trans->lid;         }     }     }          add_action( 'init', 'rkm_translation_update');      Idea behind it is to take the records of the first row, and compare it to the next. But, nothing happens. I am doing this kind of database manipulation for the first time, so I don't know where should I start with the debugging. Any help and direction is highly appreciated. If you need more info please do not hesitate to ask. Thanks!


title: Presetting the link of video attached to a Standard Post Format in a custom field

text: I am trying to create a function that presets the URL (of an attached video in a Standard Post Format) to a custom field when the post is created using a front-end form. (P.S.: All data inputted in the form correctly displays in the post editor) Thanks in advance. Here is my code below:               add_action( 'save_post', 'get_video_file' );     function get_video_file( $post_id ) {         if('post' != get_post_type())         return;         if ( $attachments = get_attached_media( 'video', $post->ID );         foreach ($attachments as $attachment) {             $meta_value = wp_get_attachment_url( $attachment->ID );             update_post_meta( $post_id, 'tm_video_file', $meta_value );         }             // To prevent an infinite loop             remove_action( 'save_post', 'get_video_file' );             wp_update_post($post);             add_action( 'save_post', 'get_video_file' );     }


title: Converting dreamweaver to WordPress

text: I created a WordPress site than needs a much needed facelift and I want to work with a designer who uses dreamweaver. We looked at tweaking my existing WordPress site but it would require coding expertise that neither of us have (for example we want each page to have a different header image and we don't want a top navigation menu on the home page). Is the best course of action for him to create the site entirely in dreamweaver and then hire someone else to convert it or export it back into WordPress? I would like to be able to update it myself once the conversion is complete. Thanks, Wendy


title: How to limit user to login only once per session

text: How can I use code to limit users from sharing there ids and password and login muliple times? what i want to do is not allow the user to login multiple times at the same time.


title: How to add a filter to get_the_author_meta?

text: I need to filter calls to get_the_author_meta() but I haven't been able to do it. I'm using a plugin which uses this function: get_the_author_meta('display_name', $p->uid)` I need to be able to filter this funcion and get the uid parameter. But I don't know how to do it. I've been trying to add a simple filter to the get_the_author_meta() function but I haven't been able to do it. This is what I'm trying now:               function get_the_author_meta_filter( $field = '', $user_id = false ) {         return "Johnn";     }     add_filter( 'get_the_author_meta', 'get_the_author_meta_filter' );      How can this be done?


title: remove <p> tags from the_content

text: I've got a post format of Image, and I am running into an issue where the image is being wrapped by a `<p>` tag. I want to get rid of that tag (specifically on the `single.php` version) of those post types. How can I get inside the formatting in a theme and remove the `<p>` tags, or create any format that I want for the output of this type of post, without affecting posts of a different post format?


title: how to exclude posts on current page from recent posts sidebar widget

text: I am using Wordpress 3.6. I would like to exclude posts on any given current page from appearing in the recent posts sidebar widget. I haven't been able to find a custom widget that has that option. I hope someone can help.


title: Create Child Taxonomies Automatically

text: Actually is not child taxonomies to auto create them without something triggering something, I'm looking for a solution for when a taxonomy is published some other taxonomies of my choice will be published under it making them child. Example I have artist like Eminem, Beyonce, Adelle etc... I want the artist to be the parent taxonomy and want things like Videos, Lyrics, and Album to be the child taxonomies.... So when i create a new taxonomy Like......               Beyonce (Parent Taxonomy) ------> Will be created manually             ---> Videos (Child Taxonomy)  Auto publish under Beyonce immediately the Beyonce is publish so this becomes Beyonce's child             ---> Lyrics (Child Taxonomy)     Auto publish under Beyonce immediately the Beyonce is publish so this becomes Beyonce's child             ---> Album (Child Taxonomy)   Auto publish under Beyonce immediately the Beyonce is publish so this becomes Beyonce's child      And it should do the same for any artist i publish, Charles i hope its clear now.... Thanks


title: export individual posts to text files or a single csv file

text: I'd like to export my blog posts to plain text files so I can version control and update them using emacs org-mode via the org2blog package. However, I'm unfamiliar with SQL and the wordpress database structure. I'm hoping to get ideas for a SQL script to export my posts where each post is stored to a file named "YYYY-MM-DD_Title-of-post.org" and where the files will look like:               #+POSTID: 1071     #+DATE: [2011-09-21 Wed 18:00]     #+OPTIONS: toc:nil num:nil todo:nil pri:nil tags:nil ^:nil TeX:nil      #+CATEGORY: cat1, cat2, cat3     #+TAGS: tag1, tag2, tag3     #+DESCRIPTION:      #+TITLE: Hello World     ### URL: http://...          BODY OF POST      The parts to be filled in is the DATE field, CATEGORY, TAGS, TITLE, URL, and BODY OF POST. I think it might be asking too much to have someone do all my work for me. So, alternatively, I'd be content with a SQL script that outputs those fields in a delimited file, say delimited by "|||" so I can write a script elsewhere to get what I want. Thanks for your help. Much appreciated!


title: Redirection Plugin: Redirect all URLs with a regular expression

text: I understand little about regular expressions, but I need to figure one out to use with the Redirection plugin which supports redirects with regular expressions. http://urbangiraffe.com/plugins/redirection/ What I need to do is redirect all urls in /oldsite/ to the domain root. That means any page in /oldsite/ like /oldsite/this-is-my-page.html, /oldsite/this- is-my-page-too.html, etc., needs to go to root via a regular expression. I can't get a 301 redirect rule to work in .htaccess for some reason; there may be a restriction at the host, so I need to use this plugin. It needs to be a regular expression in the format that the plugin understands. Some examples are in the docs for the plugin at that link above. The first field for a new redirection in the plugin takes the regular expression; the second field is the target URL. This doesn't work:               Source: /oldsite/*     Target: http://mydomain.com      Nor does this:               Source: ^oldsite/(.*)     Target: http://mydomain.com


title: How to include line-breaks in the_excerpt?

text: how can I include a line-break inside the_excerpt. I’ve modified the length and the more-button via my functions.php. I’m using teaser for every blog- entry and sometimes it looks a bit ugly, that there no line-breaks included.


title: Wrong category being displayed in URL

text: I'm a newbie to wordpress so please bear with me. I have two categories I'm using, basketball and baseball. I've only recently added the baseball category and if I add a new post with category baseball, in the URL, the post displays /basketball/post-name regardless of what I do. I've changed the permalinks settings and played with some plugins as well, and I've checked to make sure my SEO plugin isn't messing with these things. Thanks for any help.


title: wordpress threaded comments - customize nested ul / how child ul is displayd

text:
I just wasted 1 day trying to make wp threaded comments works... and I think I'm finally done!!!! except that it doesn't work properly - well it doesn't work the way I want ! :) Child comments get displayed inside the comment li - I don't like this behavior, I'd prefer wp to display it right below the parent comment li.               So by default wp handles it like this:
     comments parent here here

child comment reply :P

          Anyways, I want it displayed like this:

      Is this possible without modifying core wp files? Did wp developers leave options that enable customization of how child/nested comments are displayed? I'm including screen shot for better visual. http://i.stack.imgur.com/8PiJu.png


title: trying to add a author value in wp page links?

text:
function wp_link_pages_titled($args = '',$name,$author) {         $defaults = array(             'before' => '
' . __('Pages:'),              'after' => '
',             'link_before' => '',              'link_after' => '',             'echo' => 1         );              $r = wp_parse_args( $args, $defaults );         extract( $r, EXTR_SKIP );              global $page, $numpages, $multipage, $more, $pagenow, $pages;              $output = '';         if ( $multipage ) {             $output .= $before;             for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) {                 $part_content = $pages[$i-1];                 $has_part_title = strpos( $part_content, '' );                     $title = trim( str_replace( '' );                     $title2 = trim( str_replace( '      the original code which works for these tags                         function wp_link_pages_titled($args = '',$name) {         $defaults = array(             'before' => '
' . __('Pages:'),              'after' => '
',             'link_before' => '',              'link_after' => '',             'echo' => 1         );              $r = wp_parse_args( $args, $defaults );         extract( $r, EXTR_SKIP );              global $page, $numpages, $multipage, $more, $pagenow, $pages;              $output = '';         if ( $multipage ) {             $output .= $before;             for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) {                 $part_content = $pages[$i-1];                 $has_part_title = strpos( $part_content, '' );                     $title = trim( str_replace( '` tag?


title: Call a Simple JQuery from within Flash

text: This is hopefully really simple for someone but I'm a newbie and trying to learn how to connect to JQuery's on my site from an embedded Flash swf. I'm attempting to do a simple example first to test the connection between Flash and JQuery... I've embedded an swf onto my page. When I click my button in Flash I'd like it to connect to a JQuery function that produces a popup alert saying "hello world!" Here's my JQuery function (I need to name the function):               function helloWorld() {            alert('Hello World');      }      I have an eventlistener (which I tested and works) on my button within Flash which tries to call the following:               function AddToBasket(event:MouseEvent):void{     var alert:URLRequest = new URLRequest("javascript:helloWorld();");     navigateToURL(alert);     }      When I 'inspect element' in Chrome I can see the JQuery is there, but when I click my button no popup alert appears. I'm misunderstanding something pretty basic, any help would be appreciated!!! My Flash SWF is added to my Wordpress page using Kimili Flash Embed, which I've added to my WP page like this:               [kml_flashembed movie="http://www.example.co.uk/upload/ImageUploader.swf" allowscriptaccess="samedomain" height="500" width="728" /]      The following AS3 does produce the popup, but the whole point of the exercise is calling a JQuery outside of Flash:               function AddToBasket(event:MouseEvent):void{     var alert:URLRequest = new URLRequest("javascript:alert('Hello World!')"); //"javascript:helloWorld();"     navigateToURL(alert, "_self");     }      Thanks guys Dean


title: How to check if I'm on the last page of posts?

text: I want to display some text on the last page that isn't displayed on the other pages. For example, on category pages: url.com/category/categoryname/page/6 or last page of all posts listed on the homepage: url.com/page/9 How do I check if I'm on the last page? Thanks in advance.


title: WordPress MultiSite Won't Work on Google AppEngine

text: I'm receiving this error when trying to access network dashboard on app engine:               Warning: require(C:\Users\Jon\Documents\GitHub\kapx-wordpress\wp-admin\network): failed to open stream: Permission denied in C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\php\setup.php on line 106      I've added these handlers to no avail. Anybody else have any luck?               - url: /wp-admin/network/(.+)       script: wordpress/wp-admin/network/\1       secure: always          - url: /wp-admin/network/       script: wordpress/wp-admin/network/index.php       secure: always


title: How can I move/redirect single blog posts from one blog to another?

text: I see lots of answers about moving entire blogs, but here's my scenario: I have a few blogs with a lot of content. I'm no longer publishing new content on these sites. I'm now publishing on another (new) site. I don't want to migrate all of the content from the previous sites, but I'd like to move a few "greatest hits" posts. What's the best way to migrate a few single posts from one site to another? I'm thinking that for SEO purposes, it would make sense to have a redirect in place so that the posts currently receiving search traffic will pass that traffic onto the new site.


title: All my files are on my blog! I need sync solution

text: I uploaded all my files on my blog (self hosted). Now all my files (documents, photos, etc...) are somewhere in wp-content/upoads folder... Is there a way of having all my files in their folders (documents in docs folder, photos in photos, etc) but still have them available trough wordpress... Thanks


title: Automatically set posts to NoIndex depending on category?

text: I'd like all new posts with a specific category to automatically have NoIndex applied. There are various plugins - e.g. Wordpress SEO - which make it easier to manually select posts for NoIndex. But I can't find a way of automating the process.


title: DB connection error after copying a WordPress Multisite instance to a second location

text: Here's my setup. I have a Multisite instance running at http://example.com, and I want to do development and staging. Moving an existing Multisite instance of WP onto localhost is a nightmare, so I'm going to do dev on a staging location instead. I set up http://staging.example.com to point to the /public_html/staging/ directory of the hosting account, and copied all of the WP files from my root into the /staging/ directory. I also copied the database files (SQL dump, imported the tables into a new database), and changed the wp-config.php file to point to the new database. After running SQL to change the database records, I also change this one line in the wp-config.php file:               /** Turning on WordPress MU, new in 3.0 */     define( 'MULTISITE', true );     define( 'SUBDOMAIN_INSTALL', false );     $base = '/';     define( 'DOMAIN_CURRENT_SITE', 'example.com' ); // <- I change this line     define( 'PATH_CURRENT_SITE', '/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      Changed to:               define( 'DOMAIN_CURRENT_SITE', 'staging.example.com' ); // <- now changed      When I load up http://staging.example.com, I get... `Error establishing database connection`! I've checked and triple checked the username and password, made sure that the user has all privileges on the new staging database, and I've left the DBHOST as 'localhost' (although changing it to staging.example.com didn't help, either). Why would the database connection fail? Anyone? (Thanks for your help in advance.) _**NB:** http://example.com is working fine running on very similar db connection settings, just with a different database, so it's not an issue with the database server being down._


title: Is it possible to use Wordpress as an online portfolio for text content? What kind of theme would I look for?

text: I'm trying to build an online portfolio for a quantity of text content I've produced. I don't have to skills to design it myself or the money to pay someone, so I thought using a CMS with a free theme might be a possible way to solve my problem. Is it possible to use WP as a portfolio rather than a blog? (i.e. not have content appear date-stamped any in reverse chronological order?) If so, what kind of theme or other add-on would I look for? I'm looking for someone really simple, but sleek and polished looking. I could just put a bunch of *.txt files on an ftp server, but I'm looking for something that looks just a little better and more professional, while still being free. Thanks!


title: orderby in custom WP Query does not work

text: I have this query:                 $new = new WP_Query(array('post_type'=>'support','order'=>'DESC', 'meta_key'=>'post_views_count', 'orderby'=> 'meta_value_num', 'posts_per_page'=>'20'));      the result set is pulling the correct number of posts, from the custom post type `support` but the posts are not ordered by the meta_value. I cannot fathom why this is as the codex shows this is the correct way to order by a custom meta value?


title: Does Extending Multiple Nav_Menu_Walkers Allow Nested Menus?

text:
Essentially I'm trying to add multiple sub nav menus and I'm pretty close but I just can't seem to find the right tack to solve my problem ... I'm using a variation of a Stu Nichols CSS Menu ... Code explains better ;-) The relationship required to build this menu would have the top level elements as list-items, child-containers as divs and children and siblings {nth child} as uls ... So the structure would be the following ...
parent
child-container

item
              ...

item
              ...

item
              ...

      My current line of thought is to add an additional nav_menu_walker to build the sub-menu lists ... However, I'm not sure if I can pass multiple walker's as args to wp_nav_menu ... IE ... ASSERT                   $menu_params = array (          'theme_location'  => 'primary',     'menu'            => 'Main Menu',      'container'       => 'div',      'container_class' => 'nav',      'container_id'    => FALSE,     'menu_class'      => FALSE,      'menu_id'         => FALSE,     'echo'            => TRUE,     'fallback_cb'     => 'wp_page_menu',     'before'          => FALSE,     'after'           => FALSE,     'link_before'     => FALSE,     'link_after'      => FALSE,     'items_wrap'      => "\n\t" . '
%3$s
' . "\n",     'depth'           => 0,     'walker'          => new Top_Nav_Menu_Walker()              );          echo "\t\t
\n\t\t\t";          wp_nav_menu( $menu_params );          echo "\t\t
\n";          }      To obtain the parent -> child-container relationship I've simply added div and ul to the start_lvl function ... Here's where I'm having issues determining how I can create multiple siblings ...               function start_lvl( &$output, $depth = 0, $args = array()) {              $indent = str_repeat("\t", $depth);              $output .=  "\n$indent
\n";         $output .=  "\n$indent
\n";     }        In order to add classes to the top level anchor elements I have a custom walker. In the start_el function I've injected classes for the anchor items based on the parent class.               function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {         global $wp_query;         $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';              $class_names = $value = '';              $classes = empty( $item->classes ) ? array() : (array) $item->classes;         $classes[] = 'menu-item-' . $item->ID;              $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );         $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';              $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );         $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';              /* inject some anchor classes */              if(  $this->$depth == 0) {             if ( in_array( 'two', $item->classes ) || in_array( 'three', $item->classes )) {                 $item->class = 'oneCol fly';             }             if ( in_array( 'four', $item->classes )) {                 $item->class = 'twoCol fly';             }         };              $output .= $indent . '
';            $output .= in_array( 'sub_nav_h4', $item->classes ) ? "\n" . $indent . "
\n" : '';              $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';              /*  This 'should' always be true as WP doesn't support anchor classes    */              $attributes .= ! empty( $item->class    )       ?   ' class="'  . esc_attr( $item->class            ) . '"' : '';              $item_output = $args->before;         $item_output .= '';         $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;         $item_output .= '';         $item_output .= $args->after;              $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );     }      Here's the navigation structure I'm trying to achieve ...

One

Two

Egestas Sed

Consequat Leo

Lacinia & Blandit

Interdum

Pellentesque Velit

Lacinia & Blandit

Interdum

Donec non Fringilla

Fusce Ullamcorper

Facilisis

Tristique

Donec

Sapien

Purus

Congue

Mattis

Integer nec Diam

Morbi Eget Pharetra

Nulla & Orci

Eget Sapien Sodales

Aenean

Velit Ligula

Maecenas

Three

Egestas Sed

Consequat Leo

Pellentesque Velit

Lacinia & Blandit

Interdum

Donec non Fringilla

Fusce Ullamcorper

Facilisis

Tristique

Donec

Sapien

Purus

Congue

Mattis

Integer nec Diam

Morbi Eget Pharetra

Nulla & Orci

Eget Sapien Sodales

Aenean

Velit Ligula

Maecenas

Four

Ut vel Cursus

Maecenas imperdiet

Congue Metus

Vitae Luctus

Purus Pellentesque

Pellentesque Sed

Felis Nunc

Morbi Placerat Luctus

Ut & Eleifend

Feugiat Euismod

Tempus Condi

Five

Six

Seven


title: Media gallery - inserting full size images without link

text: I want to use built-in WP media gallery. I'm trying to simply add images in one - horizontal line. I want images with original size and without any link. I'm trying to add/edit some code into wp-admin/includes/media.php but I can't get it ;/ I know I have to use size="full" and columns="0" but how to add this with shortcode as default? And I have no idea how to get rid of links under images? Am I looking in good file? If no - point me to right direction please ;)


title: Backbone is breaking the media uploader

text: Greets, when using backbone in a plugin of mine the media uploader on the post edit page stops working properly. The uplaod button doesn't work anymore and the drag and drop functionality doesnt work. I managed to narrow it down to backbone being the culprit which I include like so:               wp_register_script(          'superchart-wizard',          plugins_url('/scripts/js/wizard.min.js', dirname(__FILE__)),          array(             ...             'backbone',             ...         )     );     wp_enqueue_script('superchart-wizard');      You can easily see the problem for yourself by installing the SuperCharts plugin here. Any help would be much appreciated!


title: Can I force WordPress to use <i> instead of <em>?

text: For example,               Did you know that hot was used to mean "sexually attractive" as long ago as 1450? (Though it seems that in earlier use, it more commonly meant "sexually attracted".)      The second use of `<em>` in the above is correct: I want to _emphasise_ the suffix _-ed_. However, the first use is incorrect. I want to use italic type to indicate the "use/mention distinction". This is the proper preserve of the `<i>` tag. But WordPress autoconverts `<i>` to `<em>`. Is there any way to get around this?


title: Duplicate posts showing up in loop using infinite scroll

text: I'm experiencing an odd issue using Infinite Scroll for the `WP_Query` loop on my homepage. Half the time when the second page fires, I'm getting a few duplicate posts showing up in the second set. I can't find a pattern for why this is happening so I'm looking for a better way to tell the infinite scroll script which posts to get. Here's what we're looking at.                  <?php          global $wp_query;          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;          $args = array(             'meta_key' => 'hotness',             'orderby' => 'meta_value_num',             'order' => 'DESC',             'cat' => -1,             'posts_per_page' => 40,             'post_type' => array( 'post','fod_videos','fod_music','fod_articles', 'fod_albums'  ),             'paged' => $paged          );         $wp_query = new WP_Query( $args );         while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>          <?php get_template_part( 'loop', 'contents' ); ?>         <?php endwhile; ?>     <?php if ( $wp_query->max_num_pages > 1 ) : ?>      <div class="infinitescroll">        <?php next_posts_link( __( 'Load more posts' ) ); ?>      </div>     <script type="text/javascript">     var href = 'first';     $(document).ready(function() {         $('#boxes').infinitescroll({             loading: {               finished: undefined,               finishedMsg: '',               img: '',               msgText: '',               speed: 'fast',               start: undefined             },             navSelector: '.infinitescroll',             nextSelector: '.infinitescroll a',             itemSelector: '#boxes .box',             debug: false         }, function(arrayOfNewElems) {            var $newElems = $( arrayOfNewElems ).css({opacity: 0});            $newElems.imagesLoaded(function(){             $newElems.animate({opacity: 1});             $('#boxes').masonry('appended', $newElems, true);             if(href != $('.infinitescroll a').attr('href')) {                 href = $('.infinitescroll a').attr('href');             }           });         });     });     </script>     <?php endif; ?>      Any ideas what the culprit is here or a better way to do this? UPDATE: Looking at the source and clicking on the link to page 2 shows the duplicates in it really isn't anything to do with the script as it my `pagination` is off for some reason. It seems like removing                       'meta_key' => 'hotness',             'orderby' => 'meta_value_num',             'order' => 'DESC',      it paginates correctly("seems"). So I'm thinking maybe sorting by the meta key isn't being recognized by pagination? The problem seems to be when the pages break at posts that have the 'hotness' value of 0. Not sure why.


title: What's the simplest way to backup my WordPress database?

text: I have WordPress installed on my server for my blog. I back up all the files from the server on a schedule. But this is just the files--not the database. Ideally, I'd like to automatically save a database dump on the server periodically so that it gets backed up along with all the files. What's the simplest way to do this?


title: Database connection close

text: Is there any method to close connection similar to `mysql_close()` for `$wpdb` in WordPress? Is it not necessary to close connection for global `$wpdb`?


title: Wrong post_type argument passed to the query when using a custom post type

text: I'm trying to obtain a structure like this               1) Posts -> /%category%/articles/%postname%/     2) CPT   -> /%category%/CPT/%postname%/      But although I am able to see the right URL in the address bar, the page return a "404 error". Digging this down I noticed that the query that WP sends is not correct               SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND wp_posts.post_name = 'win' AND wp_posts.post_type = 'post'  ORDER BY wp_posts.post_date DESC      The post_type argument should be - in my case - qualifications as this is the name of the CPT. Does anybody know how to fix this? Is there any relationship with the add_permstruct function? Thanks Andrea


title: Add unique ID number to end of permalink

text: I'm building a membership based website that will use custom post types to store data. I came across a problem which is if two users happen to create a post using the same exact name, WordPress would add -2, to one of the users posts. I'd like to keep permalinks on and have a unique ID added to the end of the permalink so that the URL's appear as example.com/postname-XXX, where XXX is a unique ID. I thought about using the post ID, but if a user is submitting from a form which is creating the custom post types am I able to insert the post ID before the post or permalink are set and if so how? If this isn't possible what is another method to add a unique ID to the permalink from the form? Thanks


title: Loop not showing first post

text:
I've set up the following loop on a page, but it is missing out the first post. Does anyone know why this might be?
       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
           <a href="<?php esc_url( the_permalink() ); ?>">             <?php the_post_thumbnail('thumbnail'); ?>

<?php the_title(); ?>

View project

         <?php endwhile; ?>
       <?php bones_page_navi(); ?>       <?php endif; ?>


title: Add content depending on page loaded

text: I would like to add some code depending on which page the users are.                 <?php      $arr = array(2506, 2516,2512,2513,2509,2515,2510,2508,2514,2511,2507);     if (in_array(the_ID(),$arr)){         if ($_SESSION['logged'] != 'true'){             echo '<script>document.location.href="./connexion";</script>'; //Not logged so good bye !         }     }      ?>      I know my that it's not quite accurate but can you check it out ? Any clue on how to make this ?


title: Is this a wordpress bug? get_comment_link auto shoots when user visits his dashboard

text: If user is **editor** , this function auto-shoots when user visits his dashboard! How is this possible? This function should only work when user successfully posts comment, so what is happening? could be wordpress bug?               function redirect_after_comment($location)     {          //This should run only when comment is confirmed. But for user level Editor, this function auto shoots!          }     add_filter('get_comment_link','redirect_after_comment');        1. User role is EDITOR   2. user logins, goes to dashboard.   3. Anything inside this function runs. For example return...


title: template_redirect not being called when using ajax

text: Usually I hook all my custom plugins code with the `template_redirect` hook but one of the issue I encountered is it does not work for the ajax call. So if I want to target both standard calls and ajax call what hook should I use? Is `wp_loaded` a good choice?


title: two menus show different menu based on what menuitem is selected on menu1

text: Iv got two menus:   menu1 with three menuitems.   menu2 which is based on which menuitem I selected in menu1 Like this: **menu1** menu2 menu3   **Home** Tax Company Aboutus menu1 **menu2** menu3   **Home** Posts News et menu1 menu2 **menu3**   **Home** Test1 Test2 et How can I make this?   Thanks


title: Use same Wordpress Users on a different site

text: I have WP installed on my main domain, `mywebsite.com`. I have a subdomain, `sub.mywebsite.com`, on which I want to utilize the same users from `mywebsite.com`. I have a multisite set up but I don't have a WP installation on my subdomain. I know I can get the user data from the WP database, but I want to get the logged-in user. For example, if user `x` is logged in to `mywebsite.com`, I want to be able to get that username on `sub.mywebsite.com`. However, if the user is not logged on, I want to prompt a log on. I tried using cookies with JavaScript, but I can't access the `wp_logged_in` cookie from the subdomain; I can only access it on the main domain. So, how can I access the logged in username (for the user browsing the website)?


title: wp_schedule_single_event function not working

text: I am testing the wp_schedule_single_event function and it is currently not working on my upgraded version of wordpress. It looks like the event is being scheduled but the code in my hook is never executed. Any help with this matter would be greatly appreciated Here is example code I put in my themes function.php:               var_dump(get_option('test_action_option'));     if(isset($_GET['begintest'])){         update_option('test_action_option', 'Scheduled: ' . $_GET['begintest']);         wp_clear_scheduled_hook( 'event_test_action'); // clear anything else in the system         wp_schedule_single_event( time() + 10, 'event_test_action');     }          add_action('event_test_action', 'event_test_action');     function event_test_action(){         update_option('test_action_option', 'Ran');     }


title: How can I manually combine all my javascript files to speed up my website?

text: I purchased a theme that uses 30 separate internal javascript files and 6 external (google maps) javascript files. Some of them are part of wordpress core, of course. What's the correct approach to de register these scripts; recombined them to reduce page requests; and speed up the site? For the external sites can I just combine those files and load them as one locally from my server? If you'd like to take a look, please check out http://findafarmersmarket.org. Please be patient it takes about 15 to 20 seconds to load because of the google maps integration. Ultimately I'm trying to speed up the site and page tool sites tell me this is one of my biggest issues.


title: Change the template when the user is not logged in using page_template filter (it does not work)

text: I want to print other template when the user is not logged in. I use this code:               function restrict_access_to_unlogged_users($template) {         global $post, $pagename;         $new_template = get_stylesheet_directory() . '/need-login.php';         return $new_template;     }     add_filter( 'page_template', 'restrict_access_to_unlogged_users', 20 );      I have got a template file called "need-login.php" in my child theme folder, however, my webpage prints a big blank in the screen. What Am I doing bad? Regards.


title: 3.5 media.editor: what is the event listener for choosing an image?

text: What is the event listener for selecting an image in the media.editor javascript. I am attempting to add a multiple image selector to a custom plugin, and I need to show the user what images they have selected, before actually hitting the 'Select' button or the 'Insert' button. I have the media.editor configured like this:               file_frame = wp.media.frames.file_frame = wp.media({         title: $(this).data('uploader_title'),         button: {             text: $(this).data('uploader_button_text')         },         multiple: true,         library:{type:'image'}     });      Setting multiple to true doesn't seem to do anything different than setting it to false. In other words before the user goes to insert the images, what is the event callback that will listen to whether or not an image is checked for selection? The 'select' event is not it. Is there an API for the media.editor script?


title: WP Multisite with Domain Mapping : Preventing User Access to Dashboard

text: I have a theme being used by a sub-folder multisite and a domain-mapped multi site. E.g. mywpsite.com/site1 mywpsite.com/site2 www.site2.com (leads to the above) I have this snippet of code in my functions.php file               function my_wp_admin_ban(){     if( !current_user_can('activate_plugins') ){     wp_redirect( get_bloginfo('url') );     exit;     }     }          add_action('admin_init','my_wp_admin_ban');      This successfully prevents members of site1 from access the admin (wp-admin) dashboard area. This code does not, however, seem to work for site2. Instead, those users are shown a "You do not have sufficient permissions to access this page." error message. Tried everything I can think of including different ways of doing the same thing I.e. How to redirect non admins to homepage if trying to view mysite.com/wp-admin/? and How do I remove dashboard access from specific user roles? What can I do to ensure all users (non admin) of the multisite are redirected away from the dashboard area?