Custom Registration Form with Validation

I am trying to create a custom modal registration form, but I'm experiencing difficulties with validating the form. Basically what I have managed to do was to use CSS3 to validate the fields based on the `pattern="..."` or`required` markup used in the `<input>` tags. This validation covers simple stuff like checking for password's min. chars and email address syntax. However, what's missing, and very important, is a way for the form to check back with the database to see if the email address a new user wants to register with, is already registered with the website...and if so trigger `<i class="icon-attention invalid"></i>` to display and if possible make the submit button disabled.

Sign up for a new account
                 <form enctype="multipart/form-data" method="post" class="frm-show-form " id="form_registration">
                   <input type="hidden" name="frm_action" value="create">                   <input type="hidden" name="form_id" value="10">                   <input type="hidden" name="form_key" value="registration">
                      <input type="text" id="field_first_name" class="input" name="item_meta[85]" value="" placeholder="First Name" required>

                      <input type="text" id="field_last_name" class="input" name="item_meta[86]" value="" placeholder="Last Name" required>

                      <input type="email" id="field_email_address" class="input" name="item_meta[87]" value="" placeholder="Email" required>

                      <input type="password" id="field_password" class="input" name="item_meta[88]" value="" placeholder="Password" pattern=".{6,}" required>
                  <input type="hidden" id="field_r5tog4" name="item_meta[89]" value="" />                  <input type="hidden" name="item_key" value="" />                  <input type="hidden" name="frm_register[username]" value="-1" />                  <input type="hidden" name="frm_register[email]" value="87" />
                <input type="submit" value="Register" formnovalidate="formnovalidate" class="button-full">                </form>

      Is there some PHP script that can be used to help with validation here, or is the entire form wrong? I've tried testing it and user registration works but if the email is taken, the page just refreshes without registering anything. If it is a valid new email being used, registration works.


How to register a post type so I have archive page, but don't have single pages?

I think the question is straight forward. I want to have archive page, but want the single pages gone. Is there a way with custom post type options?


Filter posts with meta_query NOT IN where value has multiple values

I would like to use a `meta_key` to store multiple values in that key. Thereafter, I would like to filter away posts that do not contain a specific value in the key. In other words, just show posts that do not contain a specific value. This, however, does not seem to be possible. I am writing this question here to see if anyone has come to the same conclusion or if I am just missing something. Here is the code I have used:               // The values in key "_no_interest" are: 1,2,3     add_action( 'pre_get_posts', 'custom_pre_query' );     function custom_pre_query( $query ) {         if( $query->is_main_query() && !is_admin() && $query->is_post_type_archive( 'my_custom_post_type' ) ) {             $meta_query = array(                 array(                     'key'       => '_no_interest',                     'value'     => '3',                     'compare'   => 'NOT IN'                 )             );             $query->set( 'meta_query', $meta_query );             $query->set( 'posts_per_page', -1 );             $query->set( 'post_status', 'publish' );             $query->set( 'orderby', 'date' );            }     }      This will not work and neither will it if I use the `'!='` operator. However, if I set compare to be equal to `'IN'` or `'='`, then it will work. Can anybody confirm this or am I missing something here?


Adding a custom image upload size and making it selected by default?

How can I add a custom image upload size with a width of 550px and make it selected by default in the Add Media page? Currently, there are 4 sizes available: `Thumbnail`, `Medium`, `Large` and `Full Size`. The `Full Size` option is selected by default. Anyone knows a working solution to this?


Translate theme only

I think I'll lose my hair over this... Here's my situation:   * I have a WP MU running on my server   * I have several sites in english Now I want to add a blog in a different language under the same WP install, which will be using a twentyfourteen child theme, but I want everything else to stay in english. I downloaded both the global WP and 2014 translations. I've tried to put one or both of these into my functions.php:               add_action('after_setup_theme', 'my_theme_setup');     function my_theme_setup(){         load_theme_textdomain( 'nwnsablog', get_template_directory() . '/languages');     }          add_filter( 'locale', 'my_theme_localized' );     function my_theme_localized( $locale )     {         return 'sk_SK';     }      I put these files: `sk_SK.mo, sk_SK.po, [themename]-sk_SK.po, [themename]-sk_SK.mo` into the `languages` folder in my theme root. I also put the first two into the `languages` folder inside `wp-content`. At this point, it's still all in english. If I change the `define('WPLANG', 'sk_SK');` line in wp-config, most of the strings are translated, but it also translates them outside the theme, which I don't want. I could get to a point where a different part of strings was translated (I'm guessing they were theme specific), but I can't reproduce that. Anyway, it wouldn't be very useful, as it's only a halfway translation. Anyone can help?


How do I paginate search results for custom post types?

I have a Custom Post Type called "cars" that stores several custom fields along with the standard Title/Description fields. I need users to be able to search through the CPT based on the custom fields matching the user's criteria. I figured that part out and it works, but the problem is pagination. I figured out how to paginate the CPT based on code I found on Google, and it works, but once you leave page 1, you no longer have the search data submitted with the form. I just need to know how I should store this or pass it along. In regular PHP I would just use a session to store the data, but I've been told not to do that with Wordpress. So, what is the best option? I've been told Transients are the WP version of sessions, but I'm not sure how to efficiently use them for this and how to keep them separate for each user. I'm not asking for anyone to write this for me -- I just need some help understanding the best concept for this.


jQuery does not work in widget backend

I created a widget which should use jQuery for switching between two views and implement the jQuery UI date picker. I was wondering why my jQuery code does not work as I noticed that the date picker isn't working either. The console neither throws errors nor warnings. This is my code inside the widget class:               function form($instance) {         wp_enqueue_script('jquery-datepicker', get_bloginfo('template_url').'/styles/jquery-ui-1.10.4.custom.min', array('jquery', 'jquery-ui-core'));         wp_enqueue_style('jquery.ui.theme', get_bloginfo('template_url').'/styles/jquery-ui.css');     }      Is there any known issue? Or do I have to take something into account? **EDIT** And this is in a main backend script:               $(document).ready(function() {         $('#widget-so_calendar_excerpt-range_from').each(function() {             console.log(this);             $(this).datepicker({dateFormat: 'dd.mm.yyyy'});         });     });      Something quite strange is going on here. When I reload the admin panel, every time the console log changes. It looks like this (each line one page reload):               [Log] <input class="widefat hasDatepicker" id="widget-so_calendar_excerpt-range_from" name="widget-so_calendar_excerpt[range_from]" type="text"> (backend.js, line 28)     [Log] input#widget-so_calendar_excerpt-range_from.widefat (backend.js, line 28)     [Log] <input class="widefat hasDatepicker" id="widget-so_calendar_excerpt-range_from" name="widget-so_calendar_excerpt[range_from]" type="text"> (backend.js, line 28)     [Log] input#widget-so_calendar_excerpt-range_from.widefat (backend.js, line 28)     [Log] <input class="widefat hasDatepicker" id="widget-so_calendar_excerpt-range_from" name="widget-so_calendar_excerpt[range_from]" type="text"> (backend.js, line 28)     [Log] input#widget-so_calendar_excerpt-range_from.widefat (backend.js, line 28)      In the DOM, the new class `hasDatepicker` never get's added.


Change admin logout URL

My site is using a short vanity URL. This is working across all of the custom theme pages. The only problem is when I logout in the admin it redirects to the long URL, which then 404s. My General Settings (which I can't change) are: WordPress address (URL): The long URL Site address (URL): The short URL Looks like the logout link is generated from wp-includes/general-template.php, but I hate to edit core, non-theme, WordPress files. Any ideas how to solve this logout 404 problem is greatly appreciated.


How to hide custom fields added by a plugin?

I want to hide unnecessary custom fields added by the plugin "All in one seo" to the Post Edit screen. To do this I added the following code to functions.php:               function my_remove_meta_boxes() {       remove_meta_box('aiosp_noindex_wrapper', 'post', 'normal');       remove_meta_box('aiosp_nofollow_wrapper', 'post', 'normal');       remove_meta_box('aiosp_noodp_wrapper', 'post', 'normal');       remove_meta_box('aiosp_noydir_wrapper', 'post', 'normal');       remove_meta_box('aiosp_disable_wrapper', 'post', 'normal');       remove_meta_box('aiosp_disable_analytics_wrapper','post', 'normal');     }     add_action( 'add_meta_boxes_post', 'my_remove_meta_boxes', 10, 2 );      But this doesn't work as expected. The `$id` parameters given to `remove_meta_box` functions above are taken from id attributes of the html div elements of the corresponding custom fields. For example:

     ...
      **Update** Following the instructions by bueltge, here is a solution using jquery: Put the following function into functions.php:               function remove_all_in_one_seo_fields() {         $screen = get_current_screen();         if ( $screen->parent_file != "edit.php" )             return;              wp_enqueue_script( 'custom', get_template_directory_uri() . '/js/custom.js', array(), null, true );     }     add_action( 'admin_footer', 'remove_all_in_one_seo_fields', 10, 2 );      Here is js/custom.js file:               ( function( $ ) {         // hide "all in one seo" fields         ( function() {             $('#aiosp_noindex_wrapper').remove();             $('#aiosp_nofollow_wrapper').remove();             $('#aiosp_noodp_wrapper').remove();             $('#aiosp_noydir_wrapper').remove();             $('#aiosp_disable_wrapper').remove();             $('#aiosp_disable_analytics_wrapper').remove();         } )();     })( jQuery );


Edit a custom admin page

I have created a custom admin menu page with: `add_menu_page` This page uploads a form to the wp_options table in the database.   Basic save with `update_option` like:               function addressbook_save (){     if(isset($_POST['Submit'])) {     // get the option     $customer = get_option( 'customer' );     // add new data to the option     $customer[] = $_POST['customer'];     // save it back to the db     update_option( 'customer', $customer );     }      I also show the data from that form on the same page with a foreach-loop. Here comes the problem:   I want to be able to create a button that let's me eddit the uploaded data. Maybe I'm just working on this to long to understand why I can't get this to work


Blocking Plugin Css to load custom in template directory

What is the most popular method to stop/block a plugin from loading their css styles ( located in the plugin directory) so that I can use the custom copy I made (located in my template directory). I ask this because I have one css document ( complied using sass,scss and grunt) that a visitor of my website loads. I want to add the plugin css to that document ( and to use the sass variable functions). Many thanks.


Can change twentytwelve_entry_meta "by-author" links?

In the Twenty twelve theme, the `twentytwelve_entry_meta()` function shows "by-author" links (i.e., the ones that have the title "View all posts by xxxx") by using `user_nicename`. So when a "difficult" admin username is chosen, that link can look something like:               John Smith      Is there any way to change that `twentytwelve_entry_meta()` function, and keep the link to the author's other posts, but use something other than the "user_nicename" in the body of the link? E.g.:               John Smith      **update** : My (slightly altered from default) `twentytwelve_entry_meta()` function:               function twentytwelve_entry_meta() {     // Translators: used between list items, there is a space after the comma.     $categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );          // Translators: used between list items, there is a space after the comma.     $tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );          $date = sprintf( '<time class="entry-date" datetime="%3$s">%4$s</time>',     esc_url( get_permalink() ),     esc_attr( get_the_time() ),     esc_attr( get_the_date( 'c' ) ),     esc_html( get_the_date() )     );          $author = sprintf( '%3$s',     esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),     esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),     get_the_author()     );          // Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.     if ( $tag_list ) {     $utility_text = __( 'Posted on %3$s by %4$s', 'twentytwelve' );     } elseif ( $categories_list ) {     $utility_text = __( 'Posted on %3$s by %4$s', 'twentytwelve' );     } else {     $utility_text = __( 'Posted on %3$s by %4$s', 'twentytwelve' );     }          printf(     $utility_text,     $categories_list,     $tag_list,     $date,     $author     );     }      The rewrite function from the apparently duplicated question:               // add our custom rewrite rules for author archives     add_action('author_rewrite_rules', 'my_author_rewrite_rules');          function my_author_rewrite_rules() {     $author_rules['author/([0-9]+)/?$'] = 'index.php?author=$matches[1]';     $author_rules['author/([0-9]+)/page/?([0-9]{1,})/?$'] = 'index.php?author=$matches[1]&paged=$matches[2]';     $author_rules['author/([0-9]+)/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?author=$matches[1]&feed=$matches[2]';     $author_rules['author/([0-9]+)/feed/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?author=$matches[1]&feed=$matches[2]';     return $author_rules;     }      After this I re-saved permalinks. Following this, the author URL hasn't changed; furthermore, clicking the URL now returns a 404. Not sure if I have to further modify the `twentytwelve_entry_meta()` function after adding the `my_author_rewrite_rules()` function ?


preselected custom fields in custom post type

I have a custom post type called "stock" and each post is going to have a stock_id, stock_name, stock_description and stock_available fields,...I would like to have defaults for these fields so the user doesn't have to load them on each new item. Is there a way?


Make plugin uninstalable on older versions of WordPress

So, if a plugin should not ever be installed on an older version of WordPress, whats the best way to go about it? What I normally do is something like this:               if ( ! function_exists( 'get_post_format' ) ) {         $error_handler = set_error_handler( 'my_plugin_die' );         trigger_error( '', E_USER_ERROR );     }          function my_plugin_die( $errno, $errstr, $errfile, $errline ) {         global $wp_version;         exit( 'This plugin requires WordPress version 3.0 or greater. You are currently using version ' . $wp_version . '. Please upgrade to the latest version of WordPress before installing this plugin.' );     }      I place this straight in the plugin file - outside of any class. It seems to work well in all of my testing, but seems rather harsh. Is there any chance of a plugin having this code will ever be activated? How to you deal with situations like this? There seems to be absolutely no documentation on this kind of thing.


Display custom posts randomly in custom taxonomy archive

I'm trying to get a random output in the taxonomy archive for my custom taxonomy "areas" I have the taxonomy-areas.php in which I have a standard loop. This one displays the posts from 3 custom-post-types: Hotels Pubs Restaurants As soon as I try to get them randomly with               <?php query_posts("orderby=rand"); ?>      it stops working, and starts to display standard posts as in index.php. I've tryed to add parameters to query posts, but it degenerates the loop, that doesn't displays anymore the right archive for the taxonomy of course. How can I fix it? I would like to avoid to create a taxonomy-aree-$term.php for each and every single area I'm going to define in my custom-taxonomy...! After some attempts I've tried with this one,               <?php query_posts("posts_per_page=24&orderby=rand&areas=north-east"); ?>      and tried to make it dynamic within the current taxonomy with this:               <?php query_posts("posts_per_page=24&orderby=rand&areas=$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->slug;"); ?>      But with a blank output. Thanks and best regards.


add_post_meta to repeatable metabox from frontend

I'm creating new post from wordpress frontnend. I have managed to create post using `wp_insert_post` & added single metabox values using `add_post_meta` successfully. but I'm unable to set values of repeatable metabox fields from front end. Those repeatable fields have keys as follow :               edd_variable_prices[0][name]      edd_variable_prices[1][name]     edd_variable_prices[2][name]     edd_variable_prices[3][name]     & so on...      I'm using `add_post_meta($pid, 'edd_variable_prices[0][name]', 'Some Price', true);` to enter their values but it didn't work. How to add repeatable metabox values from frontend ?


Multiple Domain Names - One WP Install (non-Multisite) - Default Each Domain name to Category Archive

Use case is somewhat simple - here goes:   1. Five people share a single wordpress install - not multi-user    2. Each person blogs and puts their posts in a their own unique category   3. Each person has their own domain name   4. All domain names are pointed or parked to same WP install folder   5. Each person's domain name only shows the posts from their category, i.e.     * http://blogger1.com would return category archive of Blogger1's posts,      * http://blogger2.com would return category archive of Blogger2's posts,     * etc.   6. Google friendly indexing for each domain name    7. Prefer rewrite solution rather than redirect but redirect is acceptable   8. A"master" account would be able to post or edit any of the bloggers posts via the "main" domain login.    9. Bonus - if this could be extended to custom post types Environment   1. One installation of latest version of WP (not multi-user)   2. Pretty Permalinks    3. Cpanel - to set up domain parking    4. No subdomains   5. Access to `.htaccess`   6. Access to `functions.php`


How to make certain content of the post noindex and no follow. not entire post?

in my woocomemrce website i am trying to embade faqs which are generated using a short cut code . these faqs are common for all products which may lead to serious duplicate content issue . how to make only the faqs content to noindex and make the remaining part of the product like description and photos under follow and index ?


How do I change the language of only the login page?

My wordpress blog is set up as `de_DE`. This means that my login page is also displayed in `de_DE`. I would like to **only** have the login page in `en_US`. So, **How would I programmatically change a single page's language?** **Note** : I have WPML but I don't wish to use it, I only want to change one page on the whole site.


how would i create a password protected some pages using one common password?

i have created 5 pages.but home page and one sub pages viewing public pages, other three pages set password protect using one common password. if i enter password three password protect will be viewed. but now support every page set individual password. how would do common password?


How can a wordpress plugin generate pages without posts?

I would like to hidde all posts in a wordpress home page, so I need to remove `loop_start` or `the_post`. I tried the `remove_action` function, but this does not remove posts. Any ideas how a plugin can generate empty pages?


Custom Post Type Permalink / Rewrite not working immediately

Hitting a brick wall with the following: I have:   * 1 custom post type called `cpt_community`   * 1 custom taxonomy called `tax_community` If I set `'rewrite' => true` in my CPT registration, then permalinks to an entry for this CPT are of the form of `http://<domain>/cpt_community/test_item/`, and I get a 404 when browsing to it. If I set `'rewrite' => false`, then permalinks are `http://<domain>/?cpt_community=test_item/`, and this works fine. So, I'm obviously doing something wrong/stupid - the question is, what? [Update]   * After every change I'm flushing rules by going to Settings > Permalinks (and saving)   * After leaving everything alone for an hour, things have started working correctly - so why the delay?  * * * **Code** CPT Registration               function community_post_type() {       $labels = array('name'  => 'Community');             $args = array(           'labels' => $labels,           'public' => true,           'publicly_queryable' => true,           'show_ui' => true,           'show_in_menu' => true,           'query_var' => true,           'rewrite' => false,           'capability_type' => 'post',           'has_archive' => true,           'hierarchical' => false,           'menu_position' => null,           'has_archive' => true,           'supports' => array('title','editor','excerpt','custom-fields','comments','revisions','thumbnail','author','page-attributes')        );             register_post_type('cpt_community', $args);     }       add_action( 'init', 'community_post_type' );      Custom Taxonomy Registration               function community_tax_type() {       register_taxonomy(         'tax_community',         'cpt_community',          array( 'hierarchical' => false,            'label' => 'Community Content Type',            'show_ui' => true,'query_var' => true,            'rewrite' => true,            'singular_label' => 'Community Content Type',            'capabilities' => array('assign_terms' => 'edit_community_tags')            )        );        # allow roles to add community taxonomy tags to a community CPT        $roles = array("subscriber","contributor","author","editor","administrator");             foreach ($roles as $role_name) {          $role = get_role($role_name);          $role->add_cap("edit_community_tags");        }        }     add_action( 'init', 'community_tax_type' );


How do I add a widget from an Android phone?

Currently my only internet access is via my phone, and I need to add a widget to a Wordpress site. This requires dragging and dropping the widget to the sidebar, which I cannot do via the web browser on the device. Is there some way to get around this?


Wordpress Pagination Not Working - Always Showing First Pages Content

I am working on a website where I have a blog but I also have a custom post type to allow me to drop in some videos. I would like to use pagination so that if there are more then 9 videos displayed, then pagination occurs. The first part of this works. The videos are indeed limited to 9 per page and the pagination correctly shows up at the bottom. However when I click on the link for the second page, even though the URL changes, the first pages videos are displayed. For my 'normal' blog posts, pagination is working exactly as intended. This is the current code that I am using for my custom post type:               <?php if ( have_posts() ) : ?>     <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('post_type=videos&posts_per_page=9&paged=$paged'); ?>              <?php /* Start the Loop */ ?>         <?php while ( have_posts() ) : the_post(); ?>      Any help would be greatly appreciated.


"Preview Changes" giving 404

Post Preview works fine, but after a post has already been published and changing the content and "previewing changes" before updating it again, it gives a 404. I think I've found out why this is happening, but not sure how to fix it. the url for the 404 is this: news/article/sdf- gsdfg/?preview=true&preview_id=3480&preview_nonce=1259e265ea&post_format=standard but removing the post_format from the url to make the url for the 404 is this: news/article/sdf-gsdfg/?preview=true&preview_id=3480&preview_nonce=1259e265ea does not give a 404 and shows the changes. I have no idea why this is happening or how to fix it. Other posts that I've seen don't even have the post_format string in the url. Any help is appreciated, thanks.


How to edit posts with the new wp_editor api?

I am using bbPress 2x and modified the plugin to use the new wp_editor in place of the textarea for adding new topics and replies. This part works beautifully. Where I am stuck is when a person clicks edit for a topic or a reply. The post content is not showing up in the editor. I'm probably just missing something really stupid, and hoping someone can chime in on how to fix this last piece. Here is what I am using: `               $tabindex = bbp_get_tab_index();     $settings = array(         'wpautop' => true,         'media_buttons' => true,         'editor_class' => 'tumble',         'tabindex' => $tabindex     );                              wp_editor( '', 'bbp_topic_content', $settings ); ` thanks **EDIT** Just got an answer to my question, and it works great Thanks go out to: http://soderlind.no/archives/2011/09/25/front-end-editor-in- wordpress-3-3/#comment-207831 `               $post = get_post($post_id, 'OBJECT');     wp_editor(esc_html($post->post_content), 'textarea01', $settings); `


How to list Tags using get_tags in an html table?

Any suggestions on the simplest way to display tags using get_tags in an html table (4 columns across) ? Example:   Tag 1 | Tag2 | Tag 3 | Tag 4   Tag 5 | Tag 6 | Tag 7 | Tag 8 I'm using the following code to display tags, I found it in codex.:                     $tags = get_tags();     $html = '
';     foreach ($tags as $tag){         $tag_link = get_tag_link($tag->term_id);              $html .= "name} Tag' class='{$tag->slug}'>";         $html .= "{$tag->name}";     }     $html .= '
';     echo $html;


Default timezone hardcoded as UTC?

While debugging a plugin I was writing, I noticed that on line 36 of wp- settings.php, the default timezone is hardcoded to UTC with a call to the date_default_set_timezone() function. This means any call to the PHP date/time functions will work with UTC as the local time. Can someone please explain to me why this is a sane design choice by the Wordpress team? I understand if they want to store and manipulate times internally as UTC, but wouldn't a better alternative be to explicitly switch to a "UTC mode" when they need to do such logic? Assuming you know to set your server's php.ini's timezone setting, this hardcoded UTC basically invalidates php.net's description of the date() function: > date — Format a _local_ time/date Which strikes me as a bad thing, no?


How the mu-plugins Folder Works in a Multisite Installation?

I'm a little confused about when I should be placing plugin files into mu- plugins. I know it's Must-Use plugins and I know that they are automatically enabled. In the network setting, though, does this force the plugin file to be enabled in all child blogs? Makes sense that it would, so is that the only time I should put a plugin file THERE in a network? When I want the plugin code to be run in each child blog? For example, if I wanted to automatically set a new thumbnail size, should I do this there? Or are there other examples. And what about network activate?


Getting the Product object in a custom loop

I am currently building a Theme for a site that is using `WooCommerce` to provide a shop to Customers. I have just started on it, and I am currently working on the Product Category pages. I have hit a road block trying to fetch the Product object. I have read that using the variable `global $product` should return the WC_Project object, but when I do `the_post(); var_dump($product)`, `NULL` is returned. I tried to then create a Product object by doing `the_post(); $product = new WC_Product(get_the_ID())`, but when I did the `var_dump($product)` on that, it gave me general information about the product (`post_name`, `post_description`, etc), but nothing further than if I called `get_post()`. Can someone tell me what I have missed please?


register_nav_menus, then create menus programatically

I have a `register_nav_menus` call in my theme's functions.php:               //register nav menu and footer nav.     register_nav_menus(         array(             'main-nav'   => 'Main Navigation',             'footer-nav' => 'Footer Navigation'         )     );      This works fine, but I'd like to take the extra step of programatically creating a menu and assigning it to 'main-nav', set to automatically add new pages. This theme is being used as a starting point for a wordpress install, so I'd like to include this functionality to save a little bit of time on the repetitive tasks such as manually creating these menus via appearance -> menus. Does anyone know how to do this?


Remove comment section from new page

I am taking over a wordpress website at work. All of the pages currently do not have a 'Leave a Reply' comment section. When I make a new page, this section exists on the new page. How do I remove it? As far as I can see all of the options as far as the page goes are the same. I have already tried to uncheck 'Allow people to post comments on new articles' but it didn't do anything


wp_localize_script not create variable in head section

I try to make an ajax function in wordpress and I enqueued my script and declared my variables like this in `functions.php`:               function my_enqueue_scripts() {         wp_enqueue_script(             'load_post',              get_template_directory_uri() . '/js/load_post.js',              array( 'jquery' ),              '1.0',              1         );         wp_localize_script(              'load_post',              'wp_ajax',             array(                  'url' => admin_url( 'admin-ajax.php' ),                  'nonce' => wp_create_nonce( 'ajax_nonce' )             )         );     }     add_action('wp_enqueue_scripts', 'my_enqueue_scripts');      load_post.js :               jQuery(document).ready(function($) {               jQuery('#next-container').click(function($) {                  var $container = jQuery('#isotope-container');             var IDs = [];             jQuery(".element").each(function($){ IDs.push(this.id); });                  jQuery('#next-container').html('loading');                  jQuery.ajax({                 type: 'POST',                 url: wp_ajax.url,                 dataType: 'html',                 data: {  action: 'load_post',                            ajax_nonce: wp_ajax.nonce,                          post_ids: IDs,                         },  //{'post_ids[]': IDs },                 success: function(data) {                         jQuery('#next-container').html('');                          $container.isotope( 'insert', $(data));                          }             })         })     })      However in my `load_post.js` I can't get `wp_ajax` variable. I don't see any variable added in the head section of my source code in google chrome or IE. Where comes from my problem? Do I miss something?


pre_get_posts action doesn't work

I'm trying to load only two types of posts ( 'news' and 'reviews' ) in `home page` using `pre_get_posts`:               // Load Home Page Posts( reviews and news )     function search_home_posts( $query ) {         if( $query->is_home() && $query->is_main_query() && !is_admin() ) {             $query->set( 'post_type', array( 'reviews', 'news' ) );         }     }     add_action( 'pre_get_posts', 'search_home_posts' );      But it doesn't seem to do nothing, since all post types and pages are shown in the `home page`. Any idea of what is happening?


post var problem with shortcode loop

I have a function to display the children of the page in the sidebar php file using wp_list_pages:               global $post; ?>
             <?php if($post->post_parent)             $children = wp_list_pages("sort_column=menu_order&title_li=&child_of=".$post->post_parent."&echo=0"); else             $children = wp_list_pages("sort_column=menu_order&title_li=&child_of=".$post->ID."&echo=0");             if ($children) { ?>
             <?php echo $children; ?>
      I have also created a shortcode that shows a custom post type using query posts:               function casestudy_shortcode()         {         extract(shortcode_atts(array(                 'type' => 'case_studies',                 'limit' => '1',                 'case' => '',                 'size' => 'small'                 ),$atts));                           //The Query             query_posts('post_type='.$type.'&showposts='.$limit.'&p='.$case);                  //The Loop            if ( have_posts() ) : while ( have_posts() ) : the_post();                        //return sb_post_image('100','100');                     //the_post_thumbnail('portfolio');                      return  "
".get_the_title()."" . get_the_excerpt() ."
";;                        endwhile; else:         endif;                       wp_reset_query();                          }         add_shortcode('casestudy', 'casestudy_shortcode');      The problem I have is that when the shortcode is in a page it makes the sub pages not show up. I assume it is overriding the $post variable. I have tried using wp_query and get_posts for the shortcode but i get the same result. Is there a way around this?


Adding a category at even positions on main loop with modified pagination

I have different categories showing over main loop. I want to add a specific category post at even positions of main loop. Example current post list with categories: cat1 cat1 cat1 cat1   required: cat1 catA cat1 catA cat1 catA cat1 catA I am using this to skip present category post, but couldn't add the desired category post into its place.               <?php if($wp_query->current_post%2==1 && in_category('cat1')) continue; ?>      Being amateur with wp my knowledge is limited. How can I do it? **UPDATE:** My logic is to use two loops on index.php, one with category and another excluding that category as this:                               <?php for($y=0;$y<5;$y++) { ?>                     <?php $off_num = ($paged-1)*5+$y; ?>                     <?php if(is_home()) query_posts("posts_per_page=1&cat=-1&offset=$off_num"); ?>                     <?php while ( have_posts() ) : the_post(); ?>                     <?php get_template_part( 'content', get_post_format() ); ?>                                      <?php endwhile; ?>                          <?php if(is_home()) query_posts("posts_per_page=1&cat=-1,-10&offset=$off_num"); ?>                     <?php while ( have_posts() ) : the_post(); ?>                     <?php get_template_part( 'content', get_post_format() ); ?>                                      <?php endwhile; }?>      Altogether this code shows 10 posts, do I need to add `wp_reset_query` or any other function like this? My Pagination too got messed up. Earlier their used to be 577 pages and now after this code, there are 2350 pages and those after 577 give 404 error. How change I remove above problems?


Using a number for limiting registering or banning on multisite

I want to ban people or limit registering on unique national ID (You can think it as 11 digit number). Is there any plugin or a code snippet you know? Site will based on MultiSite + BuddyPress. **Update:** I am not looking for IP ban. You can think it like phone number.. And every user must have 1 unique phone number and i need to ban that phone number if need. (Sorry for bad english)


WordPress book for graphic designers?

Is there a good WordPress book intended for graphic designers? I've started working with a friend in an arrangement where he designs a site and I build it in WordPress. This works great since I have the design sense of a blind monkey. He would like to learn more about WordPress and how best to design for it. I'm familiar with several good WordPress books, but most of them are intended for designer/developers. I'm looking for something that will serve as a guideline, offering suggestions for design conventions that are well suited to WordPress. Are there any such books? If there's not a book specifically aimed at designers, which other book would you suggest?


Close a wordpress blog - keep site as it is but prevent hacks

Last summer I created a travelling-blog on my webspace to document my journey. Now the journey is over and I won't put any new posts in this blog. I also don't whish to have any new comments. How can I close the blog (to make in invulnerable to external hacks, even if I don't install any new upgrades) but keep all posts, comments, pictures, etc. as they are? What I found is   * https://github.com/megumiteam/staticpress (however, although the resulting static page contains all the blogged content, the design is really messed up.)   * https://github.com/aral/wordpress-migration-tools (I couldn't try this one, because it is written in python and I don't know any python.) ~~Is one of them recommendable?~~ Is there another way to prevent all interactions with the page, so there's no need to take care about wordpress (or plugin) updates, while still keeping the site secure?


Script to get a list of all images that are detached?

In my functions.php, I have a need to list all images in the uploads folder which are not currently attached to a post in the WP database. It appears that every time an image is uploaded to the WP uploads folder (via FTP or via Media Manager), a records gets inserted in the WP database, right? How can I obtain a list of all images that are not currently attached to any post?


How to splice in wp_links links into the loop?

I want to create a loop where 2 or 3 items from my blogroll are spliced in like this:               <loop>         <post1>         <post2>         <blogroll1>         <post3>         <blogroll3>             </loop>      I'll be using images and excerpts for the loop, and the goal is to get the `wp_links` links to display EXACTLY like the `wp_posts`, so if I can actually splice in the links to the `$post` variable somehow and loop over them AS IF they were posts, that would be great. Getting the posts via `get_bookmarks` is easy, but how would I fake WP into thinking they're `$posts` and how would I splice them into the `$post` object?


Best Practices for Creating and Handling Forms with Plugins?

I'm writing a plugin that creates and handles a simple form. This has been my approach sofar, but it's turned out to have some major flaws: 1) On plugin activation, create a blank page for the form at mysite.com/form, and another blank page to process the form at mysite.com/processform. (They need to be separate pages with distinct URLs so that submissions can be tracked via google analytics. Otherwise, I'd just do all this via AJAX. I know, I know... not my decision.) 2) On the "wp" action, check to see what page we're on. 2a) If it's my form page, add a "the_content" filter to render the form (it needs some dynamic hidden elements like a nonce, which is why I didn't just include the form markup when I created the form page originally). 2b) If it's my processform page, add a "the_content" filter to process the POST and render any feedback. The major problem is with my POST handling. I'm hooking it to the "the_content" filter (because I need it to supply feedback), but this filter is sometimes run multiple times during a page load, causing the POST to be handled multiple times. I've included what I have below, but I can't help thinking I'm completely on the wrong track with my approach. How would you create and handle a form with your plugin if you needed it to hit a success URL (ie. not via AJAX)? My code:               <?php              // On activation, create the blank pages         function my_form_install() {                  // CREATE THE FORM PAGE             $page_markup = '';                  $arr_page_options = array(                 'post_status' => 'publish',                 'post_type' => 'page',                 'post_author' => 1,                 'post_title' => 'Form',                 'post_content' => $page_markup,                 'comment_status' => 'closed'             );                  // CREATE THE FORM PROCESSING/SUCCESS PAGE             $success_page_markup = '';                  $arr_success_page_options = array(                 'post_status' => 'publish',                 'post_type' => 'page',                 'post_author' => 1,                 'post_title' => 'Form Process',                 'post_content' => $success_page_markup,                 'comment_status' => 'closed'             );              }         register_activation_hook(__FILE__,'my_form_install');                   // On the wp action, check to see if this is one of our pages. If so, add our filters.         function check_current_page($obj_wp) {                  if(isset($obj_wp->query_vars["pagename"])) {                 $page_name = $obj_wp->query_vars["pagename"];                      switch($page_name) {                          case "form":                         add_filter('the_content', 'my_render_form');                         break;                          case "form-process":                         add_filter('the_content', 'my_process_form');                         break;                      }                     }              }         add_action('wp', 'check_current_page');              // Function to render the form         function my_render_form($page_markup) {                       $page_markup .= '<form method="post" action="/form-process">             <input type="text" name="some_input_field" />             <input type="submit" value="submit" />             </form>';                  return $page_markup;              }              // Function to process the form         function my_process_form($page_markup) {                  if($_POST) {                      // Do the form processing. This would involve many possible returns,                  // but I've just included one to simplify thigns.                 $page_markup .= 'Your form has been processed.';                  }                  return $page_markup;              }          ?>


Putting Text in the Search Box. eg- "Search My Site"

I would like to add some text in my blank search box for my blog. My Blog: www.bornsquishy.com Current searchform.php code:               <form method="get" id="searchform" action="<?php bloginfo('home'); ?>">         <input type="text" value="<?php the_search_query(); ?>" name="s">        <input type="submit" value="Go">     </form>      I'm sure it's a simple fix, but I no absolutely nothing about php. EDIT - Here's how I solved the problem:               <form method="get" id="searchform" action="<?php bloginfo('home'); ?>">        <input type="text" placeholder="Search My Site" value="<?php the_search_query(); ?>" name="s">        <input type="submit" value="Go">     </form>


Duplicate Posts using Feedwordpress

Feedwordpress has an issue with creating duplicate posts. This duplication does not happen predictably, however, so it is hard to debug it. I need to be able to reproduce duplicating posts before I can go any further. Has anyone been able to reproduce duplicate posts when a feed is updated using feedwordpress? If so, what steps did you follow to force a duplicate of a post to be created during an update to the feed? As an additional note, I do know that the GUID database field is not set in the duplicate post. This is one of the ways I am able to distinguish duplicates from the original. There could be 5 duplicates, all of which have no GUID set, but only one original with the GUID set.


Why is print_r returning $classObj->userObj in several places on site

I'm trying to learn how to interpret results from print_r for a bridge plugin I'm developing. **Background** My first issue was setting editor capabilities receiving administrator capabilities. While working on it, I realized that only the first two capabilities in the array were being added. This is now fixed. However, **Moving Forward** I've now started to go back and look at the calls being made and inserting in wp_die, var_dump, and print_r in places to see if the results are as expected. Now comes the question. **The results are not as expected and maybe someone can explain why**. **The Code** A file includes the function get_userdata( $user_id ). Within this file, there is a check for is_numeric, empty, and if !$user_id return false. Next, if !$user then to call a class which a method called fillUserData. The fillUserData is as follows:                   public static function fillUserData($visitor, $classObj, $user_id) {         if( $user_id != 0 ) {                  global $XF;                  $userModel = $XF->getModelFromCache('XenForo_Model_User');                  $user = $userModel->getUserById($user_id, array('join' => XenForo_Model_User::FETCH_USER_FULL));                  $classObj->userObj = $user;                      echo '<pre>';                 echo $user_id;                 print_r( $classObj->userObj[username] );                 echo '</pre>';                 //die();                  if( $user_id == $visitor->get('user_id') ) {                           // doing stuff                      return $classObj;                  } else {                      // doing stuff                      return $classObj;                  }         }               // return false;         echo 'This is a mess';          }         At this point I'm confused. I was expecting only one array returned. But several are returned within the theme (including default themes, etc). This first one shows at the top left of the theme and is absolutely the one I expected. [Update: To clarify, this array is definitely for the currently logged in user]                   Array     (     [user_id] => 3     [username] => Albert     [email] => albert@tuxreports.com     [gender] =>      [custom_title] =>      [language_id] => 1     [style_id] => 0     [timezone] => Europe/London     [visible] => 1      This next one is above the first post done by a different user. This totally is not what I was expecting. [Update: This array shows even when no one is logged into the site]                   Array     (     [user_id] => 1     [username] => LPH     [email] => lph@tuxreports.com     [gender] =>      [custom_title] =>      [language_id] => 1     [style_id] => 0     [timezone] => Europe/London     [visible] => 1     [user_group_id] => 2      These arrays are being returned above another post done by a different user .... and not what I expected since there is a if `( $user_id != 0 )` conditional. If I go into a single page then the print_r shows for that author of the post and not the user I'm logged in as ... **My question are:** Am I using $classObj->userObj = $user wrong? Why is the author of WordPress blog posts showing in a print_r when $user conditional suggests it should not? Hopefully that is enough information for someone to explain to me why this is not working as expected. My knowledge is very weak (at best). Of course, if I should not be calling the class within a pluggable function then please suggest a better method. Thank you!


Return function only on certain pages

I'd like this function to only return on certain pages. How might i do that?               // Retreats Accordion     function retreats_accordion() {       ?>
          <?php             global $post;             $c = 0;             $class = '';             $args = array( 'posts_per_page' => 6, 'post_type'=> 'slide', 'slideshow'=> 'retreats');             $myposts = get_posts( $args );             foreach( $myposts as $post ) :  setup_postdata($post);             $c++;             if( $c == 6 ) $class .= ' last'; ?>             <a href="<?php echo get_post_meta($post->ID, "slide_url_value", true); ?>">                 <?php the_post_thumbnail('quickfinder'); ?>                          <div class="slide<?php echo $class;?>" style="width:200px;">
<?php the_title(); ?>
                 <?php the_content(); ?>
          <?php endforeach; ?>
                      <?php      }          add_action('nktframework_abovecontent', 'retreats_accordion', 10);      I've tried adding this to the function but it doesn't seem to work.               if( is_page(107) )         return;


Links to plugin files not resolving

Has anyone seen an issue where links to plugin files can't be resolved and results in 404 errors? For example, I have a plugin that drops a page template into the active theme directory, and this template file references a reset.css file. The reset.css file is found in the /wp-contet/plugins/[plugin-name]/templates folder. Everything is fine until you create a new page with the template and then view the page; the layout is wrong. When viewing the source, I see that the link to the reset.css file is correct (http://site.com/wp-content/plugins/plugin- name/templates/reset.css), but when I put that URL in the browser it results in a "page not found" error. I've tried deactivating other plugins, checked permissions, and turned on the debug log, but so far nothing has helped. Any ideas? o


How to switch between the Primary Menus programmatically?

Lets say i created 2 Different Primary Menus (in the Appearance > Menu .. section). Then in the (Theme Location > Primary Navigation) Section, i can set 1 Menu to be activated. So how can i switch between these Primary Menus at the runtime (Programmatically from the Frontend .. WITH A BUTTON CLICK or something) ?


How to retrieve a value via get_option when the option_value is stored in a multi-dimensional array?

I'm trying to determine how to retrieve custom values from wp_options when the values are stored in a single options array. For example, I've got the following data in wp_options for option_value where option_name = "my_category_fields_option". The i:n value represents the category id of the category that holds the custom "my_title" data] a:2:{i:10;a:1:{s:8:"my_title";s:48:"Iced Tea: A Great Choice for Cooling Refreshment";}i:20;a:1:{s:8:"my_title";s:30:"Black Tea is Good for the Soul";}} How would I retrieve the value for "my_title" (which should be "Hello World") when I'm viewing the category archive page for this category?


Filter any HTTP request URI?

I want to filter any HTTP request URI done through the HTTP API. Use cases:   1. The WordPress update check goes to http://api.wordpress.org/core/version-check/1.6/, but https://api.wordpress.org/core/version-check/1.6/ works too, and I want to use this always.    2. The new WordPress file is taken from http://wordpress.org/wordpress-3.4.2.zip, but https://wordpress.org/wordpress-3.4.2.zip works too.   3. Sometimes I want to debug requests and redirect those temporary to a custom domain on my local server.   4. Some plugins make requests to other servers, and I want to replace these requests when the external server goes down. The update requests are the most important ones for now, because there is still the unfixed bug 16778 (more information), and HTTPS requests lower the risk of a Man-in-the-middle attack. I have searched thoroughly, I have studied the core code … but ended up like Nacin two years ago: > I thought for sure you could filter the URL of an HTTP request, but now I > can't find one. What did I miss? Did I? :)


Is it possible to create relational metabox values in a custom post?

I have a custom post type (`'Model'`) for a sports modelling agency, and it requires the model to enter sports they are competent at, and also rank their ability from 1 to 5. For example, given the information: `Model: Joe Soap.   Football: 4.   Archery: 2` I would store this in the custom_post_type `'model'` with the fields: `Model Name: Joe Soap.   Sports: Football, Archery (taxonomy).   Rank: 4, 2. ` How do I associate `4` with `Football` and `2` with `Archery` using a metabox, where different models may have different sports in their lists ?


What is the difference between the "wp_footer" and "get_footer" actions?

I am working on developing a plugin, and I am trying to add a line of text to the bottom of the page, I see there are two actions that seems reasonable, `wp_footer()` and `get_footer()`. wp_footer sounds like it may more suited towards code that needs to go at the very end of the page (like JavaScript files), but get_footer didn't have any documentation on its wordpress codex page. Which should I use for something like this?


Why does this check to see if user is authorized to edit a post fail for all but super admins?

I'm trying to determine if a piece of content can be edited by a user. I would like all roles contributor and above to be authorized by a single check. Here's my code:                   if( empty( $post_id ) || !current_user_can('edit_post', $post_id) ) { return; }      Unfortunately, the only users that don't get the `return` are super admins. Any idea why?


add custom class to wp_nav_menu using filter hook nav_menu_css_class

I have a custom post type in my wordpress theme. I want to add a custom class to the nav menu for the pages created in that custom post type. I read that you can use a filter hook: "nav_menu_css_class", but my php chops are pretty limited. How do I set up that filter hook to apply only to my custom post type pages in the nav menu and give them a custom class?


Disqus: Get recent 5 comments

is it possible to get recent 5 comments of a specific disqus-account without using the (aweful) plugin? I want to put them into a content-slider and don't find any bit of API for that! Thaanks!


Get Current Custom Taxonomy ID by Post ID

If I know the current post id that i have in the variable $pid I use $terms = get_the_terms($pid, 'custom_category'); How do I get just the term id/term_taxonomy_id if I var_dump $terms I see what I want...but I have no idea how the heck to return just the id, not an array, just the id. Bare in mind...I less than 1/2 know what I'm doing...just face rolling keyboard to get what I want...but learning more everyday. Cheers, Brian


migrate comments from old database to new database

i recently created a new wp site with some of the same content from my old wp site. is there a way to migrate comments from my old database to me new database? i tried importing old the wp_comments table into my new db via phpmysql. they did import and appeared in my wp admin, but they weren't associated with the correct posts and categories. looking at the .sql file i'm guessing that this didn't work because the old comments all have different comment_post_IDs from my new db. is there a way around this or another way to migrate the old comments? thanks!


Trigger scheduled cron events upon logged-in user visit

I am building an entirely private site where only the wp-login.php page can be viewed by non-logged-in users. After an entire day of debugging I've come to realize that non-logged-in user visits are what trigger wp_cron scheduled actions. Even though none of the documentation suggests this, and neither did I even find anything about this when reading the core code, my testing is very consistent in showing this result. My question is: **how can I fire cron jobs created with wp_schedule_event on a site that does not allow non-user visitors?** * * * -EDIT-  It turns out that my privatizing script was causing the issue because I was loading on the "init" action hook. Checking for is_logged_in on "parse_request" kept the site secure while still allowing cron to run. The issue was that wp_cron runs on "init" also.


Options page for widget

I started developing a plugin which only required a few options. But over time the number of settings grew, and I want to move most of them to a separate page. I've seen quite a few tutorials about options pages and about widgets, but I couldn't find one that explained how to create an options page for a particular widget. How can this be achieved ? I intend to keep only a couple of settings that would affect individual instances, and the rest would be global, and on the options page.


Multiple pages on one with different HTML

I am a bit confused on how this may be achieved. I have a website that I have coded already with static HTML/CSS and I am trying to incorporate it into wordpress. The challenge though is that the website is single page index.html file with 4 "sections". I want each section to be a page that can be accessed by anyone to edit the content at a later date. I have figured out how to get the page to loop out my four pages through other stackoverflow resources, however the challenge I am facing is the HTML markup. Is there a way to make each section loop out different HTML for that given section? Each section is formatted differently. For example, section one may have 4 divs, while section three has one div and it is a different ID. The current loop only will loop out the same kind of HTML. I've read about custom fields which I plan to incorporate for specific parts of the sections, but from a wider scope, I can't figure out how to get different HTML markup for each section first.               <?php $pages = get_pages();       foreach ($pages as $page_data) {       $content = apply_filters('the_content', $page_data->post_content);       $title = $page_data->post_title;     $slug = $page_data->post_name;          echo "
";     echo "
$title
";     echo $content;     echo "
";     }     ?>


How to speed up a wordpress function with multiple loops?

![enter image description here](http://i.stack.imgur.com/laOV6.jpg) I am a PHP novice and wrote this function. It is an alphabetical navigation which shows only the letter that have posts in both that letter and the currently filtered "genero" taxonomy term. I use multiple taxonomy queries to find "artistas" posts that, for example, are tagged as both "rock" and "funk". The function works perfectly and outputs exactly what I want it to, but... The multiple loops are really lagging the load time and, being the n00b that I am, am uncertain of how to optimize the function. Any pointers or guidance would be **VERY** much appreciated. If you want I can trade time for time (i write some mean CSS) :) thank you!               <?php         function bam_artist_alfa() {                 $taxonomy = 'alfa';                   $uri = my_url();                 $home = 'http://buenosairesmusic.com/';                      // save the terms that have posts in an array as a transient                 if ( false === ( $alphabet = get_transient( 'bam_archive_alphabet' ) ) ) {                     // It wasn't there, so regenerate the data and save the transient                     $terms = get_terms($taxonomy);                          $alphabet = array();                     if($terms){                         foreach ($terms as $term){                             $alphabet[] = $term->slug;                         }                     }                     set_transient( 'bam_archive_alphabet', $alphabet );                 }                       if(strstr($uri, '/artista/') ) {                     $uri = str_replace('/artista/','/?alfa=', $uri);                     $uri = substr_replace($uri ,"",-1);                 }                      $all_link = removeqsvar($uri, 'alfa');                 $last = $all_link[strlen($all_link)-1];                       if($last == '?') $all_link = substr_replace($all_link ,"",-1);                      if($all_link == $home)                      $all_link = $home.'artistas';                      if( isset($_GET) && isset($_GET['alfa']) ) {                     $is_alfa = (!is_tax('alfa') && !$_GET['alfa'] ? false : true );                 } else {                     $is_alfa = (!is_tax('alfa') ? false : true );                 }                      $all_current = ($is_alfa == true ? null : ' bg1 round-res' );                       ?>
                             <li class="all-link<?php echo $all_current; ?>">                             <?php if(!$is_alfa) { echo 'A–Z'; } else { ?>                                      <a href="<?php echo $all_link; ?>">A–Z                             <?php }?>
         <?php             $query = $_SERVER['QUERY_STRING'];             $genre = null;             $orden = (isset($_GET) && isset($_GET['orden']) ? '&orden=fecha' : null);                  if( strstr($uri,'/genero/') ) {                 $genre = str_replace('/genero/','/?genero=', $uri);                 $genre = substr_replace($uri ,"",-1);                 $genre = explode('/',$genre);                 $genre = end($genre);             } elseif( isset($_GET) && isset($_GET['genero']) ) {                 $genre = $_GET['genero'];             }                  if(!empty($genre)) {                 $spaces = strpos($genre,' ');                 $genre = ($spaces === false ? $genre : explode(' ', $genre) );             }                  function has_artists($i, $genre) {                      if(empty($genre)) {                     $termquery['tax_query'] = array(                         array(                             'taxonomy' => 'alfa',                             'terms' => $i,                             'field' => 'slug',                         ),                     );                          $termquery['post_type'] = 'artistas';                 } else {                     $alfaquery[] = array(                         'taxonomy' => 'alfa',                         'terms' => $i,                         'field' => 'slug',                     );                          if(is_array($genre)) {                         $genres[] = array(                             'taxonomy' => 'genero',                             'terms' => $genre,                             'field' => 'slug',                             'operator' => 'AND'                         );                           } else {                         $genres[] = array(                             'taxonomy' => 'genero',                             'terms' => $genre,                             'field' => 'slug',                               );                     }                     $termquery['tax_query'] = array_merge($genres, $alfaquery);                     $termquery['tax_query']['relation'] = "AND";                     $termquery['post_type'] = 'artistas';                 }                      $has_artists = get_posts($termquery);                      if($has_artists) {                     return true;                 } else {                     return false;                 }             }                  foreach(range('a', 'z') as $i) :                       $current = ($i == get_query_var($taxonomy)) ? "bg1 round-res" : "menu-item";                      if(empty($genre)) {                     $link = $home.'?alfa='.$i.$orden;                 } else {                     $genrestring = (is_array($genre) ? implode('+',$genre) : $genrestring = $genre );                     $link = $home.'?alfa='.$i.'&genero='.$genrestring.$orden;                 }                      if ( has_artists($i,$genre) && $i != get_query_var($taxonomy) ){          ?>                                  <li class="<?php echo $current; ?>">                                 <?php printf('%s', $link, strtoupper($i) ) ?>
             <?php } else { ?>                                  <li class="<?php echo $current;  if($i != get_query_var($taxonomy)) {echo ' empty';} ?>">                                 <?php echo strtoupper($i); ?>
             <?php                  }                 endforeach;             ?>
         <?php } ?>


Echo author ID in author.php

This is probably a super simple question. But how do I echo the ID of a user on author.php? I've tried               the_author_meta('ID')      But it didn't seem to want to work. I want to echo it at the end of a URL, for example; http:///www.domain.com/author/sampleauthor-id Obviously, where "id" is that particular author's ID Any ideas?


Get wordpress stored cookies for custom login

I've created a custom login box. I'm using `wp_signon()` method. Everything works well. Also i have a Remember me checkbox so i can remember user credentials next time. I know i can do it my own way of handling cookies but i want know is there any wordpress builtin method to get cookies. This is my code so far:               $creds['user_login'] = $user_login;     $creds['user_password'] = $user_pass;     $creds['remember'] = ($remember_me === "true") ? true : false;          $user = wp_signon( $creds, false );      I can see `auth` cookies on Firebug Cookies tab but they are appended with hashes. How can i decrypt them or any safer method to get cookies. I've also seen in `utils.js` and there are some methods to get and set cookies but it only gets plain text cookies. (Correct me if iam wrong). Simply i want the data that Wordpress has stored in the cookies when logged in. After logout and return to my login box it can fill my login box with username and password (Like wordpress default login page).


Login from Mobile Phone

I use the "Member Access" Plugin to restrict the content of my Blog to registered users only. This works from a PC with no problem. But if I want to login from my Android Phone the login page always displays no matter if I input correct credentials or not. I don't get logged in. I deactivated all other plugins and used the TwentyEleven Theme. How can I login from a mobile device?


which action to hook to in order to perform post-publish action

I have some functionality I've written in order to post the title and link for the post to twitter whenever a post is published. I'm wondering which wp function to hook this to? save_post has no real reference documentation. Basically I just want to run an action when a post is successfully published. Thanks very much.


Tag-post relationship problem

tag is not working in wordpress like it is supposed to. When I add tag to a custom post type it shows up in tags list and the relationship can be seen in the `term_relationships` table and the tags are seen in the posts when I edit the page.But the post count for tag remains zero and the link of the tag does not give me the posts related to the tags.For example               mysite.com/tag/mytags      does not give me the posts related to this tag. I have tried this manually as in i have used these also wp_insert_term and wp_set_post_term and the problem is same. this problem is only when I use custom post type.But when I use post type:post.This works perfectly.Is there somethig that I am missing? Thanks in advance


Can i merge 2 new WP_Query($variable) 's?

I am running a multisite network and i have setup a sql query that uses swith_to_blog(); and queries the posts. Is there a way that i can declare the query inside a new WP_Query and actually merge that query with another? Basically if i do this:               $number1 = new WP_Query($multisitequery);      Can i merge it with:               $number2 = new WP_Query($normalquery);      `$normalquery` holds settings like pagination, per page, excerpt, title etc... on a portfolio shortcode. I would like it to include queried posts from my new `$multisite` query. Can this be achieved? Just wanting to save me from creating a whole new shortcode setup lol Many thanks in advance. Rory _**EDIT========_** What i have is:               $portfolio = array();     $portfolio = $settings;      Further down my portfolio function "after all the $settings['options']" i have:               $portfolio_query = new WP_Query( $portfolio );      the `$portfolio_query` uses a loop on a page template. I want to add an extra query into this like so:               global $wpdb, $blog_id, $post;          $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM wp_blogs ORDER BY blog_id" ) );          $globalcontainer = array();          foreach ($blogs as $blog){             switch_to_blog($blog->blog_id);             $globalquery = query_posts($args);             $globalcontainer = array_merge( $globalcontainer, $globalquery );             restore_current_blog();     }      where i assume that `$globalcontainer` would be the array to merge into the `wp_query();`. So taking onboard what you have replied with, in theory i could simply:               $mergedqueryargs = array_merge($portfolio , $globalcontainer);     $portfolio_query = new WP_query($mergedqueryargs);      Would that be correct? Second, regarding the array_merge array key overwrite..... How would i go about stopping an overwrite?


How to filter the role selector?

I know that roles in WordPress are not hierarchical, but I'm wondering if there is any type of capability to "assign users to roles". All I can see if being able to add users or not. The real kicker here is, I've used Justin Tadlock's Members plugin to create a new role, called "Clients" which removes all the stuff they should either not need to see, or shouldn't be able to control - which works great.   But, if I give them the ability to create a new user, they can also choose my "super admin" role, which can see everything. So, in a way, they kinda cheat the system a little bit. Is there anyway to "hide" a certain role from showing up in what a user can set a new user/edit a user to? Or, possibly remove the role identifier from the add/edit user screen based on their role?   I know it sounds a bit off of what WordPress is mean to do for user permissions, but from an administrative stand-point, it sounds useful - at least in my head ;) Thanks!


wp_nav_menu: show menu only if one exists, otherwise show nothing

I'm trying to use wp_nav_menu to only display a menu if one exists, otherwise, display nothing. If I delete the menu, it will output a list of the pages. My functions.php file contains:               if (function_exists('register_nav_menus')) {     register_nav_menus (     array('main_nav' => 'Main Navigation Menu'));}      How can I use wp_nav_menu to only display a menu if one exists, otherwise show nothing?


Convert javascript running xml files to wordpress platform

I have a website I want to convert over to the wordpress platform. On the existing site I use some javascript to pull in images and text from xml files. Can I still get this to work in a wordpress template? Website: http://www.icdesign.co.nz/index.php


Get template part vs locate template function

I'm in single.php where I'm trying to get related-posts.php template. The problem is that when using get template part the related-posts.php isn't getting custom taxonomy name from single.php in `wp_Query`. The solution is getting the wp post terms once again in related-posts.php in order to use `get_template_part`. But technically it shouldn't be required since parent (single.php) is already having it. But when I use locate template function it works fine. I feel that this method would be slower than `get_template_part`. What should I do?


get category name in admin screen

I want to get the name of the category that I am editing posts in. So I have this code that I found here                function add_custom_submenus() {       global $submenu, $post;       $submenu['edit.php'][] = array(     __('Back'), // menu title     'edit_posts', // menu cap     'edit.php?category_name=' . $category_name // menu link       );     }      My link shows great. I know the page that I need to go back to. I am just having trouble finding the name of the page. The admin screen shows                edit.php?category_name=band-member      band-member is the name of the category that I am editing posts in. So I was trying to create a link back to the band-member posts page. I can't figure out the php to get the name of the category of the current post that I am editing.


Querying two taxonomies

I've got two taxonomies: "type of guide", and "tools". They look something like this: **Type of guide**               - Article     - Video     - Cheat sheet      **Tool** — Learning Management System   * Quiz Tool              - Hide a grades column (article)     - Creating a Gradebook (article)     - Long Answer Question Steps (article)     - Matching Questions (article)     - True or False (article)          - Using the Quiz Tool (video)          - Using the Quiz Tool (cheat sheet)        * Notifications tool   * Grades Tool The screenshot outlines the problem perfectly: I need to limit that tax-query to include only items that are tagged with "Quiz Tool". Screen: http://cl.ly/0t3J143q0A1X2w2y2X2n I'm trying to do it with a tax_query, with an AND relation:               $args = array(             'tax_query' => array(                 'relation' => 'AND',                  array(                     'taxonomy' => 'guide-type',                     'field' => 'slug',                     'terms' => 'video'                 ),                 array(                     'taxonomy' => 'tool',                     'field' => 'slug',                     'terms' => what do I put here to get the current tool (Quiz tool)?                      )             )         );         $query = new WP_Query( $args );      But I just can't figure out how to limit to only list items that are tagged with "Quiz Tool". Note the, "what do I put here" part. Help appreciated. UPDATE: It just occurred to me that I don't have to query both taxonomies, instead exit the tax_query and use a 'get_the_category()' as part of the $args:               // The Query         $args = array(             'tax_query' => array(                 array(                     'taxonomy' => 'guide-type',                     'field' => 'slug',                     'terms' => 'self-paced '                 )             ),              'category_name' => get_the_category()      Something like that? Any ideas how I could limit that 'category_name' to be the current one I'm looking at (Quiz Tool). Terry


Wordpress installed in subdirectory - Apache serves 404s

I am developing a series of sites (for multi language purposes) installed with one instance of Wordpress in the server root, then further instances in country-code subdirectories. So there are installs at the following example URLs:               http://example.com     http://example.com/en     http://example.com/fr      etc. The root directory install has a theme to deal with language detection and forwarding to relevant sub directory, as well as various other redirection functions. The problem is that when trying to access a "pretty" permalink on one of the sub-installs, eg http://example.com/en/page-name, Apache intercepts and serves a 404 before the subdirectory install gets a chance to decipher and redirect the permalink. The odd thing is that on my localhost dev setup (MAMP), this setup works fine and these links resolve to the correct pages on the subdirectory WPs. This site is on AWS running Amazon Linux AMI release 2014.03. I suppose the question is essentially, is it possible to stop Apache trying to deal with 404s within certain subdirectories and leave this entirely to WP, or, some way of changing one of the .htaccess files to achieve similar. The suggestion at http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre- existing_subdirectory_install won't work due to WP also being installed in root. Thanks.


Plural Category Base Slug On Category Archive Page

I've got a little problem with the category base slugs. Say I have got a category called 'Resources', with the category slug set to 'resource'. So any post in the category resource will appear with this kind of permalink: example.com/resource/test-post I have set the base category slug to be just the category slug. Hence, the category archive for the 'resource' category is like this: example.com/resource/ However, I want the category archive slug to be in plural form like this: example.com/resources/ Any way to achieve this? I have found nothing re. this problem on Google...


How to include stylesheet in custom admin using parent_slug

Using this code from codex:               function my_enqueue($hook) {     if( 'edit.php' != $hook )         return;     wp_enqueue_script( 'my_custom_script', plugins_url('/myscript.js', __FILE__) );     }     add_action( 'admin_enqueue_scripts', 'my_enqueue' );      this will add a custom stylesheet into wp-admin on the edit page, how can we change this so that we can use a slug from a custom admin options page which has submenus, is there a way we can use the parent menu item slug? [b]EDIT[/b]: This is how i have adapted the above code:               function auctionwp_custom_admin_style($hook) {     if( 'edit.php' != $hook )         return;     wp_enqueue_style( 'my_custom_script',  get_bloginfo( 'stylesheet_directory' ) .  '/css/custom_style.css', false, '1.0.0' );     }     add_action( 'admin_enqueue_scripts', 'auctionwp_custom_admin_style' );      what im now trying to do is change the if statement to use parent menu slug rather than edit.php thanks


Modifying the HTML Output of Inserted Images

I've used Wordpress for years. Whenever I would add an image to an article, I manually would write out all of the HTML for every image. I also used an image lightbox plugin called Highslide for people to enlarge my thumbnails. An example thumbnail that links to a larger image looks like this in my manual HTML:                     But now I've installed the latest version of Wordpress and see how easy it is to add images directly into the article without having to write any HTML out at all. The output I get is this:                     What I would like to do is modify Wordpress to add the rel="highslide" and class="highslide" automatically to the link whenever I insert a linked image so that the highslide plugin works. I guess the final result would look like this:                     I've looked through the core files but can't figure out where Wordpress generates the HTML when it inserts images. So does anyone know how to modify Wordpress to add these two attributes? I would really appreciate your help! :) Thank you!


get_userdata() not working in my plugin

i am using **get_userdata()** function in my plugin but it is not showing any values, it is showing blank result. I am able to see the value present in phpmyadmin. I am using it in a plugin **add_action('user_register','user_sf_lead')** , but it is showing any value in my code.               $user_info = get_userdata($user_id);     'Name' => $user_info->ID,     'First_Name__c' => $user_info->first_name,      I am able to get id value using **$user_info->ID** but no values for **$user_info->first_name** i getting all values of table **users** but no values from table **usermeta** I tried all possible function get_current_user_id, get_user_by, wp_get_current_user but nothing works. Below is my code               add_action( 'profile_update', 'user_sf_lead');     add_action('user_register','user_sf_lead');          // Function to store User profile in Salesforce     function user_sf_lead($user_id){          $SOAP_CLIENT_BASEDIR = plugin_dir_path(__FILE__).'Force.com-Toolkit-for-PHP/soapclient/';     require_once ($SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');     require_once ($SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');     require_once ('Force.com-Toolkit-for-PHP/Samples/userAuth.php');          $user_info = get_userdata($user_id);     echo "*****".$current_user->usertype;          try {       $mySforceConnection = new SforcePartnerClient();       $mySoapClient = $mySforceConnection->createConnection($SOAP_CLIENT_BASEDIR.'/partner.wsdl.xml');       $mylogin = $mySforceConnection->login("username", "password");            echo "*****".$user_info->usertype;       $fields = array (         'Name' => $user_info->ID,         'First_Name__c' => $user_info->first_name,         'Email__c' => $user_info->user_email,         'Last_Name__c' => $user_info->last_name,         'Description__c' => $current_user->usertype,         'User_Name__c' => $user_info->user_login,       );            $sObject = new SObject();       $sObject->fields = $fields;       $sObject->type = 'Capability__c';            echo "**** Creating the following:\r\n";       $upsertResponse = $mySforceConnection->upsert("name", array ($sObject));       //print_r($upsertResponse);           $ids = array();       foreach ($createResponse as $createResult) {         print_r($createResult);         array_push($ids, $createResult->id);       }          } catch (Exception $e) {         echo $mySforceConnection->getLastRequest();         echo $e->faultstring;          }      But whenever i am updating user record in wordpress , i am able to get all values. But i need them for the first when user register. **I am Using this code in my custom plugin**. Any solution??


How to add the author search in the default wordpress search?

I would like to include the author search in the default WordPress search. Is there any way of doing this? right know it retrieves all the posts with the permalinks and author names. same way i need the authors search. is it possible?


Include a file that has a function in it

I am using `include 'filename.php'` to load a php file into a template file, simply because the original PHP template file was getting huge and I wanted to split up the sections into different files for easy reference later. Include works great until I try to use a function inside the included file, then it stops working. I searched around the web and it seems like since the included file is run on the remote server (is that right?) it does not pick up my function from functions.php as if it were running normally. What is the correct way to do this? It seems I shouldn't use `include` and maybe should be using something else? Simplified code example: HTML:               <div id="section">         <?php include 'codesnippet.php'; ?>     </div>      codesnippet.php:               <ul>         <li>         <?php the_title(); ?>         </li>     </ul>      When any function is inside the included file, I get the error that the stream cannot be opened when trying to include it. The same type of error you would get if you mis-typed the filename in the include function.


Any idea on how to fix this error when forcing SSL on a certain page?

I'm in the process of forcing a few pages with forms to use SSL. After setting up the SSL, I opened up the console and begin debugging the errors. I ended up installing WordPress HTTPS plugin and force SSL in each specific pages. It did help fix a few errors except one.               [blocked] The page at 'https://www.yourdomain.com/something/' was loaded over HTTPS,      but ran insecure content from 'http://www.yourdomain.com/?mcsf_action=main_css&ver=3.8':              this content should also be loaded over HTTPS.      I'm bummed out after a few hours and research trying to get rid of the last error. The Style Sheet is from the Mail Chimp plugin. I'm also generating another error when I try to submit the Mail Chimp form:               XMLHttpRequest cannot load http://www.yourdomain.com/.      No 'Access-Control-Allow-Origin' header is present on the requested resource.      Origin 'https://www.yourdomain.com' is therefore not allowed access.       Besides these errors, in the general settings, the WordPress/Site URL is set to http://www.yourdomain.com (dummy url). If anyone could please help me, It would be greatly appreciated.


Using nonce external of WP Admin

All, I've got two wordpress pages. One wordpress page displays a form to do some registration stuff for the website. The second wordpress page actually processes the data and inserts it into a custom MySQL table that I have. I'd like to use the nonce functionality inherit to Wordpress. The user doesn't have to be a Wordpress admin or have any type of permissions to be able to do it. Can anyone give me an example or show me how to do this outside of the WP Admin in a Wordpress page? Thanks for any advice in advance!


Advanced Custom Fields: wp_get_attachment_url not working, attachment page says "Missing Attachment"

I used Advanced Custom Fields to add a file upload field to a custom post type. I have the following code in the template for this custom post type:               $file = get_field('file');     echo wp_get_attachment_url($file['id']);      But this doesn't display anything. I have verified that $file['id'] is the correct value (and have even tried hardcoding that value as the argument to `wp_get_attachment_url()`). If I use `get_attachment_link()` instead, it does output a URL. But if I then go to that URL, the resulting page says "Missing Attachment".


Is altering a default WordPress database table update safe?

I want to add some table columns to the `wp_terms` table. Is it safe to use the `dbDelta` function with a modified `CREATE`-MySQL query for this? Or will I run into problems in the long turn? Is it update safe? As a database rookie I hope someone with more experience can help me out here. ## Background For a plugin I'm currently working on, I need to add some metadata to a taxonomy term. The first thing is an ordering number and the second is the type of the term. Both are used to sort the posts in the frontend. In the WordPress codex I've found the action hooks `{taxonomy}_add_form_fields` and `{taxonomy}_edit_form_fields` for this, but unfortunately these saves the metadata in the `wp_options` table as a serialized array. It's probably possible to use the `WHERE REGEXP` syntax to query the correct option, but this seems slow and a bit hackish. Performance matters in the project (A ton of posts assigned to a ton of taxonomy terms) and therefore I'm looking for a way to sort and order the resultset directly on the database layer. Thanks in advance Roman


Customising rewrite rules for CPT single post URL to work as paged URL

I've got a CPT called `Service` registered as following:               $args = array(         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,         'has_archive' => false,         'rewrite' => array('slug' => 'services', 'with_front' => false),         'query_var' => true,         'capability_type' => 'post',         'hierarchical' => false,         'show_in_nav_menus' => false,         'menu_position' => 20,         'supports' => array(           'title'           'editor',           'thumbnail',           'author',           'revisions'         )     );     register_post_type('service', $args);      I have a page called "Services" that has got a custom template assigned to it that displays all of the services with their permalinks of type `services/copywriting` (where 'copywriting' is the name of the Service). So far so good. I've got another CPT called `Case Study`. Now, the `Case Studies` are connected to `Services` posts via Posts 2 Posts plugin. I'm trying to do the following: to use a single `Service` post URL of type `/services/copywriting` to display all `Case Studies` associated with that `Service`. For that purpose I've added the template redirect rule as following: so that instead of `single.php` template the `archive.php` template will be displayed.               add_action("template_redirect", 'template_redirect');     function template_redirect(){         global $wp, $wp_query;              // if Service CPT and it's a single page URL then redirect to archive.php template         if($wp->query_vars["post_type"] == "service" && is_single()){             include(TEMPLATEPATH . '/archive.php');                 exit; //thanks to @kaiser's comment         }     }      In the `archive.php` template I've got:   * a custom SQL that gets all the `Case Studies` associated with current `Service` (that I determine by looking at the URL `services/copywriting` where 'copywriting' is the current service).   * a function that creates links for pagination of type `services/copywriting/page/<page_num>` However, those links of type `services/copywriting/page/<page_num>` don't work and they always get redirected to the single `Service` URL link `services/copywriting`. Is there something I can add to re-write rules or filters or something to make the paged links work in that manner? So that `services/copywriting/page/2` will work and would be directed to `archive.php` template where my custom SQL will kick in and display the correct `Case Studies`. Do I have to have a dedicated template rather than `archive.php`? I would really appreciate any tips and help! Many thanks, Dasha    **EDIT** I've installed Rewrite Analyzer plugin. And the test for `services/copywriting/page/2` matched the following pattern:               services/([^/]+)/page/?([0-9]{1,})/?$       with the following substitution:               service: copywriting     paged: 2      I've no idea what it means though :(    **EDIT 2** OK, I've tried adding a rewrite rule as following in the `functions.php`:               add_action('init', 'my_rewrite_add_rewrites');     function my_rewrite_add_rewrites(){              //rewrite rule for Service single post, make it work as paged         add_rewrite_rule(             '^services/(.+?)/?(page/([0-9]+))?/?$',             'index.php?post_type=service&service=$matches[1]&paged=$matches[3]',             'top'         );     }      I've flushed the rewrite rules. However, when I go to URL of type `services/copywriting/page/2` it always just displays the URL without the page bit `services/copywriting/`. I can't figure out what's wrong. Is my regexp wrong or the `index.php` construction or both? I would really appreciate any help!


Multisite installation combining subdomains and subdirectories

I need to create a complex WordPress-powered set up, which I would like to run from a single code base. My setup is complicated by a number of factors. First of all I already have software running the site's homepage, so I cannot install WordPress in the root of the domain.               example.com // <- site powered by a non-WordPress engine      To this, I would like to add a multisite installation running in a sub- directory structure:               example.com/multisite/      // <- multi-site installation of WordPress     example.com/multisite/site1     example.com/multisite/site2     (...)      So far, this is easily done. The complexity arises when I want to also power some sub-domains with this WordPress installation:               site3.example.com   // <- subdomain sites I would also like to power with WordPress     site4.example.com     (...)      I would be grateful if anyone could tell me if this is possible or not. If it is possible, have you managed to get something like this up and running? What's the right way to go about this? Are additional plugins helpful? I will appreciate any help.


Content over 10,000 characters won't display with the_content()

A friend of mine just noticed that their site wasn't displaying pages that had a lot of content. For some reason they are just blank, and if he removes some content from the page it will display again. The 10,000 character mark seems to be the threshold - anything above and it goes blank. I played with his templates and noticed that the content would be displayed if I used `echo get_the_content()` rather than `the_content()`, but then he loses the auto-formatting. Has anyone run into this issue before? I've googled around and searched this site but haven't been able to find anything. Thanks in advance for any light you can shed on this!


get_option('sticky_posts') returns stickies that are in trash

The value of get_option('sticky_posts') includes those that are in the trash. How can I get a value minus stickies that are in the trash?               var $stickies = count(get_option('sticky_posts'));


How to show a popular post in wordpress in last 24 hours?

I have the query_post on my codes. This will display the popular post of all time. But I want to dispaly the popular post in past 24 hours. How do I do that?               <?php query_posts('orderby=comment_count&order=DESC&paged=' . get_query_var('paged'));?>      I have seen many answer here related to this topic, But not exactly this code. Following is my full code.               <?php     /*     Template Name: try     */     ?>     <?php get_header(); ?>

Blog Archieves

             <?php if ( ! dynamic_sidebar( 'Alert' ) ) : ?>                              <?php endif ?>
                <?php query_posts('showposts=15&orderby=comment_count&order=DESC&paged=' . get_query_var('paged'));?>       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

                         <?php if(has_post_thumbnail()) :?>
                                 <?php the_post_thumbnail(); ?>
                         <?php endif; ?>
                          <?php the_excerpt(); ?>

                            <a href="<?php the_permalink(); ?>"><?php the_title(); ?>

                             <?php the_category(', ') ?>

                            <?php echo get_the_date(); ?>at<?php echo get_the_time(); ?>
                      <?php if(function_exists(kkLikeButton())){kkLikeButton();}?>

                     <?php endwhile; else: ?>

<?php _e('There has been an error.'); ?>

<?php _e('We apologize for any inconvenience, please hit back on your browser or use the search form below.'); ?>
                 <?php get_search_form(); /* outputs the default Wordpress search form */ ?>
             <?php endif; ?>

<?php next_posts_link('« Older Entries') ?>

<?php previous_posts_link('Newer Entries »') ?>

     <?php get_sidebar(); ?>     <?php get_footer(); ?>


How to retrive the text : No movie by this actor

Hy, im building a cinema site, in movie page i have a Custom Field that link's the actor page, when i add a movie and i link the actor, on the actor page i get the movie, now the problem is how can i add in this code the text "No movie by this actor", if no movie is selected i want to retrive automate That Text. To retrive the movies i have this code.               <?php      //create new loop query for films by this actor     $movies = $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'distributie' AND meta_value LIKE '%".get_the_ID()."%'");     $the_query = new WP_Query( array( 'post__in' => $movies) );               // The Loop     while ( $the_query->have_posts() ) : $the_query->the_post();         echo '
';         ?>         <img class="actor-img" src="/scripts/timthumb.php?src=<?php the_field('img'); ?>&h=110&w=75&zc=1" alt="<?php the_title(); ?>"  title="<?php the_title(); ?>"/>              <?php the_title();         echo '
';     endwhile;          // Reset Post Data     wp_reset_postdata();     ?>      Anny help would be apreciate. Thanks in advance!


How to choose email recipient in Contact Form 7 based on address state input in form and save to database

Using Contact Form 7 **Situation** When a visitor fills out a form on the website, they enter:   * Name   * Email   * Phone   * Address (Street, City, State, Zip Code)   * Message I need to save this information to the database for future reference and I need to send an email to a central email address and to a specific email address, which changes depending upon the state of the visitor. Basically, salespeople have territories and contacts from the website need to be sent to the main website email address as well as the person in charge of the territory. Not all states have an assigned salesperson. **Steps Taken** I installed Contact Form DB to save all submissions to the database. I am using the method described on the Contact Form 7 website to select the recipient - Selectable Recipient with Pipes. I am using the state name as the selectable dropdown and the salesperson's email address following the pipe.               [select* state      "Alabama|john@example.com"     "Alaska"     "Arizona|john@example.com"     "Arkansas|mary@example.com"     "California|mary@example.com"     "Colorado"     ]      I set up CF7's "Mail" to send to the website's central email address and to the salesperson's email address who operates in the selected state.               central@example.com,[state]      **The Problems** When a visitor selects a state that has an assigned salesperson, the salesperson's email address is entered into the database, not the state. When a visitor selects a state name that does not have a designated salesperson, the state name is entered into the database, but no email is sent. I also tried setting up "Mail" to send to `central@example.com` and "Mail (2)" to send to `[state]` (salesperson's email address), however no email was sent to `central@example.com` when an email address was not provided for the state name in the dropdown. Lastly, I tried entering the state name in this format - `"Alaska|"`. In this case, nothing was entered into the database for `state` and no email was sent. I tested this using both of the "Mail" options listed above. **The Solution?** Now, I understand, I can simply enter `central@example.com` for all state names without a designated salesperson - and that's fine. The problem with this - the email address is still entered into the database for `state`. I imagine I need a way to take the state name ([_raw_state]) and pass it into a hidden CF7 field, so it can be saved to the database, but I cannot seem to figure out how.


Correct check for any admin page with editor

I have read the codex, but found it a bit incomplete. I like to load stuff only on pages where the post editor is visible. This should include custom post types and everything. I am a bit insure about the `get_current_screen()` Object. When to use `base`, `parent_base` ... Would this be the right check? Tested it on pages and posts and seem to be working. Just asking because I am curious if I could to this better.               $screen = get_current_screen();          if ( 'post' == $screen->base || 'page' == $screen->base ) {     // Load stuff     }