title: Why is this custom post type defaulting to archive.php?

text: Working with a plugin (SermonManager) and noticed that, for the custom type defined here (wpfc_sermon), the default archive.php page is being used to render the content _instead_ of the archive-wpfc_sermon.php ... and I'd like to know why and how to fix? Here is the relevant code:               <?php     /*      * Creation of Sermon Post Types and Taxonomies      * Also all meta boxes      */          // Determine the correct slug name based on options     function generate_wpfc_slug($slug_name = NULL) {         $sermon_settings = get_option('wpfc_options');         $archive_slug = $sermon_settings['archive_slug'];         if(empty($archive_slug)) {             $archive_slug = 'sermons';         }              if (!isset($slug_name)) {             return array ('slug' => $archive_slug, 'with_front' => false);         }              if (isset($sermon_settings['common_base_slug']) == '1') {             return array ('slug' => $archive_slug."/".$slug_name, 'with_front' => false);         } else {             return array ('slug' => $slug_name, 'with_front' => false);         }     }           // Create sermon Custom Post Type     add_action('init', 'create_wpfc_sermon_types');     function create_wpfc_sermon_types() {            $labels = array(         'name'                  => __( 'Sermons',                   'sermon-manager' ),         'singular_name'         => __( 'Sermon',                    'sermon-manager' ),         'add_new'               => __( 'Add New',                   'sermon-manager' ),         'add_new_item'          => __( 'Add New Sermon',            'sermon-manager' ),         'edit_item'             => __( 'Edit Sermon',               'sermon-manager' ),         'new_item'              => __( 'New Sermon',                'sermon-manager' ),         'view_item'             => __( 'View Sermon',               'sermon-manager' ),         'search_items'          => __( 'Search Sermons',            'sermon-manager' ),         'not_found'             => __( 'No sermons found',          'sermon-manager' ),         'not_found_in_trash'    => __( 'No sermons found in Trash', 'sermon-manager' ),         'menu_name'             => __( 'Sermons',                   'sermon-manager' ),       );            $args = array(         'labels'                => $labels,         'public'                => true,         'publicly_queryable'    => true,         'show_ui'               => true,         'show_in_menu'          => true,         'query_var'             => true,         'menu_icon'             => SM_PLUGIN_URL.'includes/img/book-open-bookmark.png',         'capability_type'       => 'post',         'has_archive'           => true,         'rewrite'               => generate_wpfc_slug(),         'hierarchical'          => false,         'supports'              => array( 'title', 'comments', 'thumbnail', 'entry-views' )       );        register_post_type('wpfc_sermon',$args);     }          //create new taxonomies: preachers, sermon series, bible books & topics     add_action( 'init', 'create_wpfc_sermon_taxonomies', 0 );     function create_wpfc_sermon_taxonomies() {          //Preachers     $labels = array(             'name'                          => __( 'Preachers',                                 'sermon-manager' ),         'singular_name'                 => __( 'Preacher',                                  'sermon-manager' ),         'menu_name'                     => __( 'Preachers',                                 'sermon-manager' ),         'search_items'                  => __( 'Search preachers',                          'sermon-manager' ),         'popular_items'                 => __( 'Most frequent preachers',                   'sermon-manager' ),         'all_items'                     => __( 'All preachers',                             'sermon-manager' ),         'edit_item'                     => __( 'Edit preachers',                            'sermon-manager' ),         'update_item'                   => __( 'Update preachers',                          'sermon-manager' ),         'add_new_item'                  => __( 'Add new preacher',                          'sermon-manager' ),         'new_item_name'                 => __( 'New preacher name',                         'sermon-manager' ),         'separate_items_with_commas'    => __( 'Separate multiple preachers with commas',   'sermon-manager' ),         'add_or_remove_items'           => __( 'Add or remove preachers',                   'sermon-manager' ),         'choose_from_most_used'         => __( 'Choose from most frequent preachers',       'sermon-manager' ),         'parent_item'                   => null,         'parent_item_colon'             => null,     );          register_taxonomy('wpfc_preacher','wpfc_sermon', array(         'hierarchical'  => false,         'labels'        => $labels,         'show_ui'       => true,         'query_var'     => true,         'rewrite'       => generate_wpfc_slug('preacher'),     ));          //Sermon Series     $labels = array(             'name'                          => __( 'Sermon Series',                         'sermon-manager' ),         'singular_name'                 => __( 'Sermon Series',                         'sermon-manager' ),         'menu_name'                     => __( 'Sermon Series',                         'sermon-manager' ),         'search_items'                  => __( 'Search sermon series',                  'sermon-manager' ),         'popular_items'                 => __( 'Most frequent sermon series',           'sermon-manager' ),         'all_items'                     => __( 'All sermon series',                     'sermon-manager' ),         'edit_item'                     => __( 'Edit sermon series',                    'sermon-manager' ),         'update_item'                   => __( 'Update sermon series',                  'sermon-manager' ),         'add_new_item'                  => __( 'Add new sermon series',                 'sermon-manager' ),         'new_item_name'                 => __( 'New sermon series name',                'sermon-manager' ),         'separate_items_with_commas'    => __( 'Separate sermon series with commas',    'sermon-manager' ),         'add_or_remove_items'           => __( 'Add or remove sermon series',           'sermon-manager' ),         'choose_from_most_used'         => __( 'Choose from most used sermon series',   'sermon-manager' ),         'parent_item'                   => null,         'parent_item_colon'             => null,     );          register_taxonomy('wpfc_sermon_series','wpfc_sermon', array(         'hierarchical'  => false,         'labels'        => $labels,         'show_ui'       => true,         'query_var'     => true,         'rewrite'       => generate_wpfc_slug('series'),     ));          //Sermon Topics     $labels = array(             'name'                          => __( 'Sermon Topics',                         'sermon-manager' ),         'singular_name'                 => __( 'Sermon Topics',                         'sermon-manager' ),         'menu_name'                     => __( 'Sermon Topics',                         'sermon-manager' ),         'search_items'                  => __( 'Search sermon topics',                  'sermon-manager' ),         'popular_items'                 => __( 'Most popular sermon topics',            'sermon-manager' ),         'all_items'                     => __( 'All sermon topics',                     'sermon-manager' ),         'edit_item'                     => __( 'Edit sermon topic',                     'sermon-manager' ),         'update_item'                   => __( 'Update sermon topic',                   'sermon-manager' ),         'add_new_item'                  => __( 'Add new sermon topic',                  'sermon-manager' ),         'new_item_name'                 => __( 'New sermon topic',                      'sermon-manager' ),         'separate_items_with_commas'    => __( 'Separate sermon topics with commas',    'sermon-manager' ),         'add_or_remove_items'           => __( 'Add or remove sermon topics',           'sermon-manager' ),         'choose_from_most_used'         => __( 'Choose from most used sermon topics',   'sermon-manager' ),         'parent_item'                   => null,         'parent_item_colon'             => null,     );          register_taxonomy('wpfc_sermon_topics','wpfc_sermon', array(         'hierarchical'  => false,         'labels'        => $labels,         'show_ui'       => true,         'query_var'     => true,         'rewrite'       => generate_wpfc_slug('topics'),     ));          //Books of the Bible     $labels = array(             'name'                          => __( 'Book of the Bible',                         'sermon-manager' ),         'singular_name'                 => __( 'Book of the Bible',                         'sermon-manager' ),         'menu_name'                     => __( 'Book of the Bible',                         'sermon-manager' ),         'search_items'                  => __( 'Search books of the Bible',                 'sermon-manager' ),         'popular_items'                 => __( 'Most popular books of the Bible',           'sermon-manager' ),         'all_items'                     => __( 'All books of the Bible',                    'sermon-manager' ),         'edit_item'                     => __( 'Edit book of the Bible',                    'sermon-manager' ),         'update_item'                   => __( 'Update book of the Bible',                  'sermon-manager' ),         'add_new_item'                  => __( 'Add new books of the Bible',                'sermon-manager' ),         'new_item_name'                 => __( 'New book of the Bible',                     'sermon-manager' ),         'separate_items_with_commas'    => __( 'Separate books of the Bible with commas',   'sermon-manager' ),         'add_or_remove_items'           => __( 'Add or remove books of the Bible',          'sermon-manager' ),         'choose_from_most_used'         => __( 'Choose from most used books of the Bible',  'sermon-manager' ),         'parent_item'                   => null,         'parent_item_colon'             => null,     );          register_taxonomy('wpfc_bible_book','wpfc_sermon', array(         'hierarchical'  => false,         'labels'        => $labels,         'show_ui'       => true,         'query_var'     => true,         'rewrite'       => generate_wpfc_slug('book'),     ));          //Service Type     $labels = array(             'name'                          => __( 'Service Type',                          'sermon-manager' ),         'singular_name'                 => __( 'Service Type',                          'sermon-manager' ),         'menu_name'                     => __( 'Service Type',                          'sermon-manager' ),         'search_items'                  => __( 'Search service types',                  'sermon-manager' ),         'popular_items'                 => __( 'Most popular service types',            'sermon-manager' ),         'all_items'                     => __( 'All service types',                     'sermon-manager' ),         'edit_item'                     => __( 'Edit service type',                     'sermon-manager' ),         'update_item'                   => __( 'Update service type',                   'sermon-manager' ),         'add_new_item'                  => __( 'Add new service types',                 'sermon-manager' ),         'new_item_name'                 => __( 'New Service Type',                      'sermon-manager' ),         'separate_items_with_commas'    => __( 'Separate service types with commas',    'sermon-manager' ),         'add_or_remove_items'           => __( 'Add or remove service types',           'sermon-manager' ),         'choose_from_most_used'         => __( 'Choose from most used service types',   'sermon-manager' ),         'parent_item'                   => null,         'parent_item_colon'             => null,     );          register_taxonomy('wpfc_service_type','wpfc_sermon', array(         'hierarchical'  => false,         'labels'        => $labels,         'show_ui'       => true,         'query_var'     => true,         'rewrite'       => generate_wpfc_slug('service-type'),     ));     }          // Initialize the metabox class.     add_action( 'init', 'initialize_wpfc_sermon_meta_boxes', 9999 );     function initialize_wpfc_sermon_meta_boxes() {         require_once plugin_dir_path( __FILE__ ) . '/meta-box/init.php';         }          add_filter( 'wpfc_meta_boxes', 'wpfc_sermon_metaboxes' );     // Define the metabox and field configurations.     function wpfc_sermon_metaboxes( array $meta_boxes ) {              $meta_boxes[] = array(             'id'         => 'wpfc_sermon_details',             'title'      => __('Sermon Details', 'sermon-manager'),             'pages'      => array( 'wpfc_sermon', ), // Post type             'context'    => 'normal',             'priority'   => 'high',             'show_names' => true, // Show field names on the left             'fields'     => array(                 array(                     'name' => __('Date', 'sermon-manager'),                     'desc' => __('Enter the date the sermon was given. NOTE: Each sermon must have a date!', 'sermon-manager'),                     'id'   => 'sermon_date',                     'type' => 'text_date_timestamp',                 ),                 array(                     'name'    => __('Service Type', 'sermon-manager'),                     'desc'    => __('Select the type of service. Modify service types in Sermons -> Service Types.', 'sermon-manager'),                     'id'      => 'wpfc_service_type_select',                     'type'    => 'taxonomy_select',                     'taxonomy' => 'wpfc_service_type',                 ),                 array(                     'name' => __('Main Bible Passage', 'sermon-manager'),                     'desc' => __('Enter the Bible passage with the full book names,e.g. "John 3:16-18".', 'sermon-manager'),                     'id'   => 'bible_passage',                     'type' => 'text',                 ),                 array(                     'name' => __('Description', 'sermon-manager'),                     'desc' => __('Type a brief description about this sermon, an outline, or a full manuscript', 'sermon-manager'),                     'id'   => 'sermon_description',                     'type' => 'wysiwyg',                     'options' => array( 'textarea_rows' => 7, 'media_buttons' => false,),                 ),             ),         );              $meta_boxes[] = array(             'id'         => 'wpfc_sermon_files',             'title'      => __('Sermon Files', 'sermon-manager'),             'pages'      => array( 'wpfc_sermon', ), // Post type             'context'    => 'normal',             'priority'   => 'high',             'show_names' => true, // Show field names on the left             'fields'     => array(                 array(                     'name' => __('Location of MP3', 'sermon-manager'),                     'desc' => __('Upload an audio file or enter an URL.', 'sermon-manager'),                     'id'   => 'sermon_audio',                     'type' => 'file',                 ),                 /* just testing for duration and file size fields _wpfc_sermon_duration & _wpfc_sermon_size                 array(                     'name' => __('MP3 Duration', 'sermon-manager'),                     'desc' => __('Length in minutes (will be automatically determined by Sermon Manager when you save)', 'sermon-manager'),                     'id'   => '_wpfc_sermon_duration',                     'type' => 'text',                 ),                 array(                     'name' => __('MP3 File size', 'sermon-manager'),                     'desc' => __('File size in bytes (will be automatically determined by Sermon Manager when you save)', 'sermon-manager'),                     'id'   => '_wpfc_sermon_size',                     'type' => 'text',                 ),*/                 array(                     'name' => __('Video Embed Code', 'sermon-manager'),                     'desc' => __('Paste your embed code for Vimeo, Youtube, or other service here', 'sermon-manager'),                     'id'   => 'sermon_video',                     'type' => 'textarea',                 ),                 array(                     'name' => __('Sermon Notes', 'sermon-manager'),                     'desc' => __('Upload a pdf file or enter an URL.', 'sermon-manager'),                     'id'   => 'sermon_notes',                     'type' => 'file',                 ),             ),         );              return $meta_boxes;     }          /**      * Get podcast file info on save and store in custom fields.      * Using meta boxes validation filter.      * Added by T Hyde 9 Oct 2013      *      * @param $new      * @param $post_id      * @param $field      * @return $new unchanged      */     function wpfc_sermon_audio_validate( $new, $post_id, $field ) {              // only for sermon audio         if ( $field['id'] != 'sermon_audio' )             return $new;              $current = get_post_meta($post_id, 'sermon_audio', 'true');         $currentsize = get_post_meta($post_id, '_wpfc_sermon_size', 'true');              // only grab if different (getting data from dropbox can be a bit slow)         if ( $new != '' && ( $new != $current || empty($currentsize) ) ) {                  // get file data             $size =  wpfc_get_filesize( $new );             $duration = wpfc_mp3_duration( $new );                  // store in hidden custom fields             update_post_meta( $post_id, '_wpfc_sermon_duration', $duration );             update_post_meta( $post_id, '_wpfc_sermon_size', $size );              } elseif ($new == '') {                  // clean up if file removed             delete_post_meta( $post_id, '_wpfc_sermon_duration');             delete_post_meta( $post_id, '_wpfc_sermon_size' );              }              return $new;     }     add_filter('wpfc_validate_file','wpfc_sermon_audio_validate', 10, 3);          //Remove service type box (since we already have a method for selecting it)     function remove_service_type_taxonomy() {         $custom_taxonomy_slug = 'wpfc_service_type';         $custom_post_type = 'wpfc_sermon';         remove_meta_box('tagsdiv-wpfc_service_type', 'wpfc_sermon', 'side' );     }     add_action( 'admin_menu', 'remove_service_type_taxonomy' );          //add filter to insure the text Sermon, or sermon, is displayed when user updates a sermon     add_filter('post_updated_messages', 'wpfc_sermon_updated_messages');     function wpfc_sermon_updated_messages( $messages ) {       global $post, $post_ID;            $messages['wpfc_sermon'] = array(         0 => '', // Unused. Messages start at index 1.         1 => sprintf( __('Sermon updated. View sermon', 'sermon-manager'), esc_url( get_permalink($post_ID) ) ),         2 => __('Custom field updated.', 'sermon-manager'),         3 => __('Custom field deleted.', 'sermon-manager'),         4 => __('Sermon updated.', 'sermon-manager'),         /* translators: %s: date and time of the revision */         5 => isset($_GET['revision']) ? sprintf( __('Sermon restored to revision from %s', 'sermon-manager'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,         6 => sprintf( __('Sermon published. View sermon', 'sermon-manager'), esc_url( get_permalink($post_ID) ) ),         7 => __('Sermon saved.', 'sermon-manager'),         8 => sprintf( __('Sermon submitted. Preview sermon', 'sermon-manager'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),         9 => sprintf( __('Sermon scheduled for: %1$s. Preview sermon', 'sermon-manager'),           // translators: Publish box date format, see http://php.net/date           date_i18n( __( 'M j, Y @ G:i', 'sermon-manager' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),         10 => sprintf( __('Sermon draft updated. Preview sermon', 'sermon-manager'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),       );            return $messages;     }          // TO DO: Add more help information     //display contextual help for Sermons     //add_action( 'contextual_help', 'add_wpfc_sermon_help_text', 10, 3 );               //create custom columns when listing sermon details in the Admin     add_action("manage_posts_custom_column", "wpfc_sermon_columns");     add_filter("manage_edit-wpfc_sermon_columns", "wpfc_sermon_edit_columns");          function wpfc_sermon_edit_columns($columns) {         $columns = array(             "cb" => "<input type=\"checkbox\" />",             "title" => __('Sermon Title', 'sermon-manager'),             "preacher" => __('Preacher', 'sermon-manager'),             "series" => __('Sermon Series', 'sermon-manager'),             "topics" => __('Topics', 'sermon-manager'),             "views" => __('Views', 'sermon-manager'),         );         return $columns;     }          function wpfc_sermon_columns($column){         global $post;              switch ($column){             case "preacher":                 echo get_the_term_list($post->ID, 'wpfc_preacher', '', ', ','');                 break;             case "series":                 echo get_the_term_list($post->ID, 'wpfc_sermon_series', '', ', ','');                 break;             case "topics":                 echo get_the_term_list($post->ID, 'wpfc_sermon_topics', '', ', ','');                 break;             case "views":                 echo wpfc_entry_views_get( array( 'post_id' => $post->ID ) );                 break;                   }     }               // Custom taxonomy terms dropdown function     function wpfc_get_term_dropdown($taxonomy) {         $terms = get_terms($taxonomy);         foreach ($terms as $term) {             $term_slug = $term->slug;             $current_preacher = get_query_var('wpfc_preacher');             $current_series = get_query_var('wpfc_sermon_series');             $current_topic = get_query_var('wpfc_sermon_topics');             $current_book = get_query_var('wpfc_bible_book');             if($term_slug == $current_preacher || $term_slug == $current_series || $term_slug == $current_topic || $term_slug == $current_book) {                 echo '<option value="'.$term->slug.'" selected>'.$term->name.'</option>';             } else {                 echo '<option value="'.$term->slug.'">'.$term->name.'</option>';             }         }     }           /*     Taxonomy Short Description     http://wordpress.mfields.org/plugins/taxonomy-short-description/     Shortens the description shown in the administration panels for all categories, tags and custom taxonomies.     V: 1.3.1     Copyright 2011  Michael Fields  michael@mfields.org          This program is free software; you can redistribute it and/or modify     it under the terms of the GNU General Public License version 2 as published by     the Free Software Foundation.          Function names have been modified to prevent conflicts.     */          // Actions.     function wpfc_taxonomy_short_description_actions() {         $taxonomies = get_taxonomies();         foreach ( $taxonomies as $taxonomy ) {             $config = get_taxonomy( $taxonomy );             if ( isset( $config->show_ui ) && true == $config->show_ui ) {                 add_action( 'manage_' . $taxonomy . '_custom_column', 'wpfc_taxonomy_short_description_rows', 10, 3 );                 add_action( 'manage_edit-' . $taxonomy . '_columns',  'wpfc_taxonomy_short_description_columns' );                 add_filter( 'manage_edit-' . $taxonomy . '_sortable_columns', 'wpfc_taxonomy_short_description_columns' );             }         }     }     add_action( 'admin_init', 'wpfc_taxonomy_short_description_actions' );               // Term Columns.     // Remove the default "Description" column. Add a custom "Short Description" column.     function wpfc_taxonomy_short_description_columns( $columns ) {         $position = 0;         $iterator = 1;         foreach( $columns as $column => $display_name ) {             if ( 'name' == $column ) {                 $position = $iterator;             }             $iterator++;         }         if ( 0 < $position ) {             /* Store all columns up to and including "Name". */             $before = $columns;             array_splice( $before, $position );                  /* All of the other columns are stored in $after. */             $after  = $columns;             $after = array_diff ( $columns, $before );                  /* Prepend a custom column for the short description. */             $after = array_reverse( $after, true );             $after['mfields_short_description'] = $after['description'];             $after = array_reverse( $after, true );                  /* Remove the original description column. */             unset( $after['description'] );                  /* Join all columns back together. */             $columns = $before + $after;         }         return $columns;     }               // Term Rows. - Display the shortened description in each row's custom column.     function wpfc_taxonomy_short_description_rows( $string, $column_name, $term ) {         if ( 'mfields_short_description' == $column_name ) {             global $taxonomy;             $string = term_description( $term, $taxonomy );             $string = wpfc_taxonomy_short_description_shorten( $string, apply_filters( 'mfields_taxonomy_short_description_length', 130 ) );         }         return $string;     }          // Shorten a string to a given length.     function wpfc_taxonomy_short_description_shorten( $string, $max_length = 23, $append = '…', $encoding = 'utf8' ) {              /* Sanitize $string. */         $string = strip_tags( $string );         $string = trim( $string );         $string = html_entity_decode( $string, ENT_QUOTES, 'UTF-8' );         $string = rtrim( $string, '-' );              /* Sanitize $max_length */         if ( 0 == abs( (int) $max_length ) ) {             $max_length = 23;         }              /* Return early if the php "mbstring" extension is not installed. */         if ( ! function_exists( 'mb_substr' ) ) {             $length = strlen( $string );             if ( $length > $max_length ) {                 return substr_replace( $string, $append, $max_length );             }             return $string;         }              /* Count how many characters are in the string. */         $length = strlen( utf8_decode( $string ) );              /* String is longer than max-length. It needs to be shortened. */         if ( $length > $max_length ) {                  /* Shorten the string to max-length */             $short = mb_substr( $string, 0, $max_length, $encoding );                  /*              * A word has been cut in half during shortening.              * If the shortened string contains more than one word              * the last word in the string will be removed.              */             if ( 0 !== mb_strpos( $string, $short . ' ', 0, $encoding ) ) {                 $pos = mb_strrpos( $short, ' ', $encoding );                 if ( false !== $pos ) {                     $short = mb_substr( $short, 0, $pos, $encoding );                 }             }                  /* Append shortened string with the value of $append preceeded by a non-breaking space. */             $string = $short . ' ' . $append;         }              return $string;     }     ?>


title: Appearance->Editor not visible

text: I'm noticing that the `editor` is not visible from past few weeks. It's working fine on my other WordPress sites but in one site it's not visible. I tried changing theme and deactivating plugins but that didn't work. Also my wp-config.php file doesn't have `define('DISALLOW_FILE_EDIT', true);`.


title: Too many login attempts

text: Since a week or two I keep receiving the following automatic email message sent from my WordPress website, and I'd like to know if it indicates any security hole and if there's anything I can do to stop it : "A host, 79.148.238.85(you can check the host at http://ip- adress.com/ip_tracer/79.148.238.85) has been locked out of the WordPress site at http://my_site.com until Friday, February 22nd, 2013 at 9:41:54 am UTC due to too many login attempts. You may login to the site to manually release the lock if necessary."


title: Multiple WYSIWYG Editor on save redirecting to wp-admin/post.php (Which is page not found)

text: Hi i'm using custom post types with multiple WYSIWYG fields, on click of update it's redirecting me to wp-admin/post.php (no page found). After making multiple attempts my server blocked my ip and sent me the reason below,               Kindly check the logs and above path with your developer and take necessary action to avoid this in future.           Logs:      ------     [Tue Jan 28 10:46:37 2014] [error] [client 27.7.33.30] Match of "rx ((?:submit(?:\\\\+| )?(request)?(?:\\\\+| )?>+|<<(?:\\\\+| )remove|(?:sign ?in|log ?     (?:in|out)|next|modifier|envoyer|add|continue|weiter|account|results|select)?(?:\\\\+| )?>+)$|^< ?\\\\??(?: |\\\\+)?xml|^<samlp|^>> ?$)" against "ARGS:wpcf[sponsors]" required.     [data "/post.php"] [severity "CRITICAL"] [hostname "site.com"] [uri "/wp-admin/post.php"]      did anyone know what's the issue is ?


title: PHP echo stripping formatting in Advanced Custom Fields

text:
Using Advanced Custom Fields in Wordpress, I have the following code:               if(the_sub_field('company_name')) {              echo 'Company name:';         echo '
' . the_sub_field('company_name') . '
';     }      When the page renders though, the company name renders (the_sub_field) but the **Company name:** does not. This has also happened in a number of other places in my code when I echo some html out. Is there a reason for this? Does it have to do with ACF? Many thanks **EDIT:** Even if I try it like this the _Company name:_ is stripped compltely:                   <?php if(the_sub_field('company_name')) { ?>             Company name:
<?php the_sub_field('company_name') ?>
;         <?php } ?>      **EDIT:** Placing the Company Name: outside of the IF statement works, but I would like for it to be inside the IF statement as I want it to render out only if that statement is true of course.               <?php              echo 'Company name:';          if(the_sub_field('company_name')) {             echo '
' . the_sub_field('company_name') . '
';         }     ?>


title: Single template will not show sidebar/bottom-nav and footer

text: Im using the blankslate template theme and have a sidebar which i would like to use throughout the website. On my sidebar on the homepage i have a widget called latest posts with the latest post snippet and a read-more link. When this is clicked, the user should be able to view the single post on a new page with the header, footer, bottom/top nav and sidebar. At the moment the sidebar/footer and bottom nav are missing. I have deactivated the widget and used Wordpress original and this still does not work (so i know its not a sidebar widget bug). If i move the footer or sidebar tags up in the template say next to the header they show but the post is below so i know its something to do with the single post function? Here is my index template below:               <?php get_header(); ?>     <?php get_template_part( 'nav', 'above' ); ?>     <?php while ( have_posts() ) : the_post() ?>     <?php get_template_part( 'entry' ); ?>     <?php get_sidebar(); ?>     <?php endwhile; ?>     <?php get_template_part( 'nav', 'below' ); ?>     <?php get_footer(); ?>      Which i want the single page template to be like but instead of all the posts the single post... The single post template i have so far is:               <?php get_header(); ?>     <?php get_template_part( 'nav', 'above-single' ); ?>     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>     <?php get_template_part( 'entry' ); ?>     <?php get_sidebar(); ?>     <?php endwhile; endif; ?>     <?php get_template_part( 'nav', 'below-single' ); ?>     <?php get_footer(); ?>      I have moved everything about and still no luck. If anyone could give me any guidance i'd appriciate it. Thanks. Update: I've just realised my tool bar goes when i also access this page - not sure if this will help towards my query.


title: How can I get archives for specific category without category_base in the url?

text: I'm using this code to get archives for a specific category:               function extend_date_archives_add_rewrite_rules($wp_rewrite){         $rules = array();         $structures = array(             $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_date_permastruct(),             $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_month_permastruct(),             $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_year_permastruct(),         );         foreach( $structures as $s ){             $rules += $wp_rewrite->generate_rewrite_rules($s);         }         $wp_rewrite->rules = $rules + $wp_rewrite->rules;     }     add_action('generate_rewrite_rules', 'extend_date_archives_add_rewrite_rules');      It works fine and I get an URL like: example.com/category_base/category_name/date/YYYY/MM The problem is that I would like to have an URL without the category_base: example.com/category_name/date/YYYY/MM If I use a plugin to delete de "category_base" (like WP no category base) or simply I use "str_replace" to delete the "category_base", I get a 404 error page in all pages and single pages. What can I do? Thanks. **Added notes:** If I use:               function extend_date_archives_flush_rewrite_rules(){         global $wp_rewrite;         $wp_rewrite->flush_rules();     }     add_action('init', 'extend_date_archives_flush_rewrite_rules');     function extend_date_archives_add_rewrite_rules($wp_rewrite){         $rules = array();         $structures = array(             $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_date_permastruct(),             $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_month_permastruct(),             $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_year_permastruct(),         );         foreach( $structures as $s ){             $rules += $wp_rewrite->generate_rewrite_rules($s);         }         $wp_rewrite->rules = $rules + $wp_rewrite->rules;     }     add_action('generate_rewrite_rules', 'extend_date_archives_add_rewrite_rules');      example.com/category_name/YYYY works fine, but single and pages go to 404 page. But If I only use:               function extend_date_archives_add_rewrite_rules($wp_rewrite){             $rules = array();             $structures = array(                 $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_date_permastruct(),                 $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_month_permastruct(),                 $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_year_permastruct(),             );             foreach( $structures as $s ){                 $rules += $wp_rewrite->generate_rewrite_rules($s);             }             $wp_rewrite->rules = $rules + $wp_rewrite->rules;         }         add_action('generate_rewrite_rules', 'extend_date_archives_add_rewrite_rules');      Then all single and pages work fine, but example.com/category_name/YYYY goes to 404. Any idea? I refresh permalinks, and I continue with the problem :(


title: WP Query to set post thumbnail for existing old posts

text: I found this PHP code that will set the first attached image as the post thumbnail. http://wordpress.stackexchange.com/a/23768 Is it possible to loop through old posts that have attachments using WP_Query() to set the post thumbnail for old posts? If the post has more than 1 attachement, I'd like to set the first attachment as the post thumbnail. I'd like to do this only once to get everything up to date, then I can incorporate the PHP code from the answer above to modify new posts going forward. As requested, here is the code from the aforementioned linked answer.               function myprefix_main_image() {     $attachments = get_children( 'post_parent='.$post->ID.'&post_type=attachment&post_mime_type=image&order=desc' );     if( $attachments ) {         $keys = array_reverse( $attachments );         set_post_thumbnail( $post->ID, $keys[0]->ID );     };       }


title: Why the slideshow is not shown in my theme?

text:
I am pretty new in WordPress theme developing and I have the following problem. I am trying to create a WordPress theme that used **BootStrap** CSS framework based on this BootStrap demo static website (I have the entire source of this site because it is a downlodable tutorial): http://www.html.it/guide/img/bootstrap/demo/home.html This is my **custom WP theme** : http://onofri.org/WP_BootStrap/ So I have create a basic WP theme and as first stage I want to insert the **slideshow** of the previous demo page in the **header.php** file of my WP theme, so this is my **header.php** code:               DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">     <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>          <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />     <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>     <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />               <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />          <?php wp_head(); ?>

                <img src="<?php bloginfo('template_url'); ?>/assets/img/flexslider/flex-1.jpg"/>

                        Lorem ipsum
                        sit dolor
                        adipiscing elitur

                <img src="<?php bloginfo('template_url'); ?>/assets/img/flexslider/flex-2.jpg"/>

                        Lorem ipsum
                        sit dolor
                        adipiscing elitur

                <img src="<?php bloginfo('template_url'); ?>/assets/img/flexslider/flex-3.jpg"/>

                        Lorem ipsum
                        sit dolor
                        adipiscing elitur

<a href="<?php echo get_settings('home'); ?>"><?php bloginfo('name'); ?>

<?php bloginfo('description'); ?>

      As you can see I have simply take the ****block of the static demo website and I have put it at the beginning of my **header.php** file. Ok, my WordPress theme is configured to use the BootStrap CSS and the **flexslider.css** and also the **style2.css** file that represent what in the demo website is the **stili-custom.css** (my custom CSS settings that is loaded at last to ovverride the definied properties) As you can see the problem is that at the beginning of my theme the slide show not appear and I have no idea about this issue. Why? Can you help me to solve this problem? UPGRADE 1: In the **functions.php** I put to load all the JavaScripts:               /* Function automatically executed by the hook 'load_java_scripts':      * 1) Load all my JavaScripts      */     function load_java_scripts() {         // Load JQuery:         wp_enqueue_script('jquery');         // Load bootstrap.min.js:         wp_enqueue_script('bootstrap.min-js', get_template_directory_uri() . '/assets/bootstrap/js/bootstrap.min.js', array('jquery'), 'v3.0.3', true);         // Load FlexSlider JavaScript         wp_enqueue_script('flexSlider-js', get_template_directory_uri() . '/assets/plugins/flexslider/jquery.flexslider.js', array('jquery'), 'v2.1', true);         // Load FancyBox:         wp_enqueue_script('fancy-js', get_template_directory_uri() . '/assets/plugins/fancybox/jquery.fancybox.pack.js', array('jquery'), 'v2.1.5', true);         // Load scripts.js:         wp_enqueue_script('fancy-js', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery'), '1.0', true);     }     add_action('wp_enqueue_scripts', 'load_java_scripts');      Tnx Andrea


title: Remove Share This option from the home page

text: I have installed the Share this (http://sharethis.com/) plugin in the site http://mytabletguru.com. Now the issue is that it is showing the share button on homepage also. Plz help me to remove it.


title: Category Posts Code

text:
You may find my `index.php` code below. I'm trying to get posts from categories.               <?php get_header();      $style = gplab_get_option('home_display');     if (isset($_GET['style'])) {         $style = $_GET['style'];     }?>
     <?php     if ( gplab_get_option('breaking_enable') ) {         echo gplab_breaking();     } ?>
     <?php if ( gplab_get_option('slider_enable') ) { ?>
             <?php echo gplab_flexslider(); ?>
     <?php }      if($style == 'custom'){      echo gplab_box_cat();     } elseif($style == 'blog') {         $getPosts = new WP_Query();         $getPosts->query("paged=$paged"); ?>
          <?php if ($getPosts->have_posts()) : while ($getPosts->have_posts()) : $getPosts->the_post();              $metaID = $post->ID; $meta = get_post_meta($post->ID,'gplab_post_meta',TRUE); ?>                 <div id="post-<?php the_ID(); ?>" <?php post_class('page'); ?>>

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

<?php _e('Written on ', 'gplab'); the_time('F j, Y'); _e(', by ', 'gplab'); the_author_posts_link(); ?>

                             <?php echo gplab_thumbnail('post'); ?>

                             <?php the_excerpt(__('Read more', 'gplab'));?>

<?php comments_popup_link(__('No Comments', 'gplab'), '1 ' . __('Comment', 'gplab'), '% ' . __('Comments', 'gplab')); ?>

<?php _e('Categories: ', 'gplab'); the_category(', ') ?>

         <?php endwhile; endif; ?>
<?php          if (function_exists("pagination")) {             pagination($getPosts->max_num_pages);         } ?>     <?php } elseif($style == '' || $style == 'box'){?>
 <?php         global $paged;         if(empty($paged)) $paged = 1;              $news_counter_1 = 0;         $two_counter_1 = 0;         $two_counter_2 = 0;         $gPosts = new WP_Query();         $gPosts->query("paged=$paged");         if ($gPosts->have_posts()) : while ($gPosts->have_posts()) : $gPosts->the_post(); $two_counter_1 ++ ;             $metaID = $post->ID;              if($two_counter_1 % 2 != 0) : ?>
 <?php          elseif ($two_counter_1 % 2 == 0): ?>
 <?php          endif; ?>

                         <?php echo gplab_thumbnail('box'); ?>                                <?php if(gplab_get_meta($metaID ,'post_format') == 'review'){ ?>
<img src="<?php echo GPLABIMG . '/stars/star' . gplab_get_meta($metaID ,'overall_rating') . '.png'?>" alt="<?php echo gplab_get_meta($metaID ,'overall_rating'); ?>"/>
                         <?php } elseif(gplab_get_meta($metaID ,'post_format') == '' || gplab_get_meta($metaID ,'post_format') == 'default') { ?>                         <?php } else { ?>
<img src="<?php echo GPLABIMG . '/' . gplab_get_meta($metaID ,'post_format') . '.png'?>" alt="<?php echo gplab_get_meta($metaID ,'post_format'); ?>"/>
                         <?php } ?>
<?php echo gplab_getcomment_count(get_the_ID(), 'index');?>

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

                                     <?php //the_excerpt();                                     gplab_excerpt_box(); //275 260?>

<?php the_time('F j, Y'); _e(' at ', 'gplab'); the_time(); ?>

<?php _e('Category:', 'gplab'); ?> <?php echo gplab_getCategory(get_the_ID());?>

                                 <a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><?php _e('Read More', 'gplab'); ?>

               <?php endwhile; else:?>

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

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

 <?php         wp_reset_query(); ?>
 <?php         if (function_exists("pagination")) {             pagination($gPosts->max_num_pages);         }      } ?>
      What should I change to get posts from categories?


title: Custom Fields - How can I remove the publish option for certain users

text: I am trying to set updates to `Pending` vs. `Publish` for a new role I created called **"members"**. Is there a way to remove just the `Publish` option for these users? None of the user plugins I have tried work. They will set it to `Pending` for new posts, but not for editing the post. I need it for editing.


title: Can't seem to get this CSS to work...any ideas why?

text: I may be missing something really simple here, but I am trying to style the background to my disqus comments to a white color (like the blog post content area) but for some reason the background of the site is still overriding my styling. I have no idea why. Here is my styles.css...Does any one see what's going on? (Here is a single post where you can see the background is white, although my css should be making it white, unless I'm doing something wrong. http://noahsdad.com/fox-4-interview-noah/ )               /*       Theme Name: Standard-Child-Theme-1     Description: Standard is a meticulously designed and coded theme for professional blogging. It adapts to mobile devices and individual posts can be styled distinctly for words, images, quotes, links, videos, or statuses. It includes a light and dark style sheet and precision, zero-config SEO techniques are built-in. Visitors will love it. Search engines will love it. And you will love it.     Author: 8BIT     Template: Standard     */          @import url("../Standard/style.css");          .dsq-full-comment { color: #F5F5F5 !important; }          #subscribe_dock input[type="submit"] { padding: 5px 2px; font-size:11px; }          /* Social Icons For Top Right Graphic */     #text-25    {position:relative;}     #social         {background:url(http://noahsdad.com/wp-content/uploads/2012/02/down-syndrome-blogs-noahs-dad.jpg) no-repeat; height:300px; width:300px; position:relative;}     .social_icon        {height:32px; width:32px; display:inline-block;}     .social_trans       {height:32px; width:32px;}     #social_dock        {position:absolute; top:70px; left:8px;}     #social_dock a *    {border:0;}     #subscribe_dock     {position:absolute; bottom:-5px; left:8px;}     #social #facebook   {background:url(http://noahsdad.com/wp-content/uploads/2012/02/social-sprite-2.png) no-repeat;}     #social #twitter    {background:url(http://noahsdad.com/wp-content/uploads/2012/02/social-sprite-2.png) no-repeat -32px 0px;}     #social #youtube    {background:url(http://noahsdad.com/wp-content/uploads/2012/02/social-sprite-2.png) no-repeat -64px 0px;}     #social #rss        {background:url(http://noahsdad.com/wp-content/uploads/2012/02/social-sprite-2.png) no-repeat -96px 0px;}     #social #pintrest   {background:url(http://noahsdad.com/wp-content/uploads/2012/02/social-sprite-2.png) no-repeat -128px 0px;}     #social #googleplus {background:url(http://noahsdad.com/wp-content/uploads/2012/02/social-sprite-2.png) no-repeat -160px 0px;}          /* Needed In Order To Get Social Icons To Show Up Correctly */     div.social_icon img {background: none;}


title: How to remove a class from a post_image div?

text:
So for a post i know how to remove a class by using               function remove_class( $classes ) {                 $classes = array_diff($classes, array('hentry'));                return $classes;     }          add_filter('post_class', 'remove_class');      But i need to remove a particular class from a child div of the post div, i.e. a div with class="post_image mb30 blur icon" and i like to remove blur. It turns out the WP theme in use, adds the class by:                   function content_thumbnail_masonry($args = array()) {      global $post;      $args['width'] = '768';      $args['height'] = '';      $args['crop'] = false;      $args['class'] = 'post_image mb15';      if (get_post_format() == 'quote') {      $args['show'] = false;      } elseif (get_post_format() == 'link') {      $args['show'] = false;      }      return $args; }      I also tried this:               function remove_css_please( $content ) {         global $post;          $postid = $post->ID;         if( $postid==5709) {         echo 'yes for this one';         $content = str_replace('
','
', $content);         }          return $content;     }     add_filter('the_content', 'remove_css_please');      But the preg_replace doesn't work, the echo did show up. i like to remove the a href tag as well


title: How to display data from custom fields I created?

text: I created an options page to ad gigs as custom posts in my theme. This is in my functions.php                   $config = array(         'id' => 'gigs-info',         'title' => 'Gig Info',         'pages' => array('gig'),         'context' => 'normal',          'priority' => 'high',          'fields' => array(),          'local_images' => false,         'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).     );     $my_meta = new AT_Meta_Box($config);          //Add fields to your meta box     $my_meta->addText($prefix.'where',array('name'=> 'Where is the Gig '));     $my_meta->addDate($prefix.'when',array('name'=> 'When is the Gig '));     $my_meta->addTime($prefix.'start_time',array('name'=> 'When Does it Start '));     $my_meta->addTime($prefix.'end_time',array('name'=> 'When Does it End '));     $my_meta->addText($prefix.'with_who',array('name'=> 'With Who is the Gig '));     $my_meta->addTextarea($prefix.'words',array('name'=> 'A few words on the gig '));     $my_meta->Finish();     }      How do I display the content of these various fields in my index.php? I currently have this...                      <?php     $args2 = array         (             'post_type' => 'gig',             'numberposts' => -1         );         $prefix = "_gig";         $gigs = get_post($args2);      foreach ($gigs as $gig)      {     echo get_post_meta($gig->ID, $prefix.'where', true);       }     ?>


title: Facebook plugin shows existing comments

text: Installed the official facebook plugin and seems to be working. The problem is that existing comments are still visible (with default style) above facebook comments form. My `comments.php` is empty now and I see this. (Sorry about greek text, no time to change it). I emptied it because I know there is no merge possible, so moving to the fb-comments only era on this site. Is there a way to completely remove the existing comments, or at least style them and move them after fb ones? I see no option in the backoffice of the plugin. ![enter image description here](http://i.stack.imgur.com/07EFQ.png)


title: How to use a different database to list and manage comments in the backend

text: I need to make Wordpress use another database (not the one specified in wp- config site-wide) on the "Comments" admin backend. I then must be able to edit, approve, delete etc. comments as usual. The database server I am going to connect to has been setup to accept external connections. I have a couple of ideas how to approach this:   1. from wp-config.php: have an if block to change the database connection strings if user is viewing comments page. However this doesn't sound good to me, I assume this may create a lot of unnecessary database connections if user goes back and forth to the comments page.   1. modify wp-admin files: create an instance of wpdb and tell Wordpress to use it for comment administration.  However, I can't find the .php files that get the comments from the database (so I can change the database where they do it). Have been looking at edit- comments.php->class-wp-comments-list-table.php->class-wp-list-table.php (down to base class), but I can't see the bit that talks to the database.   1. Any hooks available to tap into and change the database? (doubt it) Many thanks in advance.


title: Split Blog Into Two Sections?

text: Alright, so this is my vision for a website I am currently looking to relaunch... As of right now, my site's blog consists of posts in the form of products linking to Amazon via WP Zon Builder (plugin). Now I am looking to open the blog up to others who are interested in writing content for the site. Is there a way to split my blog up into two sections, like the following: • original posts • new posts Basically I don't want my original posts taking over the site, especially since there are over 400 of them. In a way, I kind of want to archive them and have the focus of the site be the new blog posts being submitted by my authors/users. I'm thinking of a possible workaround. Is there some kind of plugin that can split my blog up by users? I can assign all the current posts to an individual user account, thus making room for the new users. Hopefully this isn't confusing. Any help is much appreciated!


title: AJAX: Wordpress filters inside $html do not work as intended

text:
I am sending HTML content through some AJAX magic and while everything is working as I wish, the output gives something along those lines in the page:               "http://permalink.comtitle"      It's as if all the html tags ( and
 there) were discarded. Here's the PHP part in functions.php where I give $html its value:               if ($query->have_posts()){              while ($query->have_posts()){                  $query->the_post();                 $html = '
' . the_title() . '
';             }         }         echo $html;      jQuery part (I give only the part where I send the data to the target since everything else work as intended):               success:function(data){                     $('#actu_ajax').html(data);                 }      **Edit:** As a side note, if I remove the filters the html tags are back there. I am surely missing something easy to spot...


title: Redirect function inside a Shortcode

text: I am developing a free plugin for connection a external support system to WordPress to be able to authenticate users on WordPress. For this, currently from the external system, the user is sent to WordPress's login page with this at the end               ?action=freshdesk-remote-login      My plugin then checks if the user is logged into WP, if not it shows the login form and after successful login, redirects them back to the 3rd party site. The redirect is done using something like this: `wp_redirect( $sso_url );` Now this works well, but I plan to offer a shortcode which could be added to a page the user chooses. Now once a user goes to this page, if they are logged in, they should be forwarded to the 3rd party site, if not, then to the login page. Is there a way you could suggest wp_redirect to work inside a shortcode?


title: How to Change Loop to Order Posts by Views (using wp-postviews plugin)

text: I hope somebody would be kind enough to help. I currently have a page that orders all of the posts by comment count, but I want to change the loop to order the posts by view count. I have installed the 'wp-postviews.1.50' plugin and have got it to display the number of views on each post, so I know that side of it is working, now I just need the loop code changed to order by most views, is this possible? This is the how the number of views is called out:               <?php $views = get_post_meta($post->ID, 'views', true); ?><?php echo $views; ?>      And here is the loop I need changed:               <?php $posts_per_page = get_query_var('posts_per_page'); ?>     <?php $paged = intval(get_query_var('paged')); ?>     <?php $paged = ($paged) ? $paged : 1; ?>     <?php $args = array(     'posts_per_page' => $posts_per_page,     'paged' => $paged,     'more' => $more = 0,     'orderby' => 'comment_count',     'order' => 'DESC',     ); ?>     <?php query_posts($args); ?>     <?php if (have_posts()) : while (have_posts()) : the_post() ;?>     <div <?php post_class() ?> id="post-<?php the_ID(); ?>">      Thanks in advance for any help with this. I'm using WordPress 3.0.4.


title: How can I disable parent menu item links?

text: I don't want to have the parent menu items of my site's nav menus linking to a separate page. For one thing I don't want to have a superfluous page. For another these links hobble site navigation for mobile users who can't "hover" over a link (to bring up the child items). The best solution would be to disable the parent menu item links. But how do I do that, especially now that with WordPress 3.5 the Disable Parent Menu Item plugin has stopped working? One possible solution is here.


title: HTML content filtered on blog page

text: On my blog page where my all post are listed all formating is filtered and the post text is in a paragraph tag with all other formatting HTML tags removed. It works fine on the posts single page. How can I fix it and allow my posts to be visible till "more break" with all formatting.


title: update_meta_user difference in i:1 and b:1, how to write b:1

text: This code leads to wp_cababilities being written to the database but with an i:1 in front.               if( $new_roles === 'administrator' ) {         $capabilities = array ("administrator",'activate_plugins','delete_others_pages','delete_others_posts','delete_pages','delete_plugins','delete_posts','delete_private_pages','delete_private_posts','delete_published_pages','delete_published_posts','edit_dashboard','edit_files','edit_others_pages','edit_others_posts','edit_pages','edit_posts','edit_private_pages','edit_private_posts','edit_published_pages','edit_published_posts','edit_theme_options','export','import','list_users','manage_categories','manage_links','manage_options','moderate_comments','promote_users','publish_pages','publish_posts','read_private_pages','read_private_posts','read','remove_users','switch_themes','upload_files','create_product');         $user->set_role('administrator');         update_user_meta( $user_id, 'wp_capabilities', $capabilities );         update_user_meta( $user_id, 'wp_user_level', 10 );     }      This is what is placed in the database:               a:39:i:0;s:13:"administrator";i:1;s:16:"activate_plugins";i:2;s:19:"delete_others_pages";i:3;s:19:"delete_others_posts";i:4;s:12:"delete_pages";i:5;s:14:"delete_plugins";i:6;s:12:"delete_posts";i:7;s:20:"delete_private_pages";i:8;s:20:"delete_private_posts";i:9;s:22:"delete_published_pages";i:10;s:22:"delete_published_posts";i:11;s:14:"edit_dashboard";i:12;s:10:"edit_files";i:13;s:17:"edit_others_pages";i:14;s:17:"edit_others_posts";i:15;s:10:"edit_pages";i:16;s:10:"edit_posts";i:17;s:18:"edit_private_pages";i:18;s:18:"edit_private_posts";i:19;s:20:"edit_published_pages";i:20;s:20:"edit_published_posts";i:21;s:18:"edit_theme_options";i:22;s:6:"export";i:23;s:6:"import";i:24;s:10:"list_users";i:25;s:17:"manage_categories";i:26;s:12:"manage_links";i:27;s:14:"manage_options";i:28;s:17:"moderate_comments";i:29;s:13:"promote_users";i:30;s:13:"publish_pages";i:31;s:13:"publish_posts";i:32;s:18:"read_private_pages";i:33;s:18:"read_private_posts";i:34;s:4:"read";i:35;s:12:"remove_users";i:36;s:13:"switch_themes";i:37;s:12:"upload_files";i:38;s:14:"create_product";}      These capabilities do not work for that user. A simple copy/paste of the following into the database **gives the user the capabilities**               a:27:{s:13:"administrator";b:1;s:12:"delete_posts";b:1;s:22:"delete_published_posts";b:1;s:10:"edit_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:4:"read";b:1;s:12:"upload_files";b:1;s:19:"delete_others_pages";b:1;s:19:"delete_others_posts";b:1;s:12:"delete_pages";b:1;s:11:"delete_post";b:1;s:20:"delete_private_pages";b:1;s:20:"delete_private_posts";b:1;s:22:"delete_published_pages";b:1;s:17:"edit_others_pages";b:1;s:17:"edit_others_posts";b:1;s:10:"edit_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"edit_private_posts";b:1;s:20:"edit_published_pages";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:17:"moderate_comments";b:1;s:13:"publish_pages";b:1;s:18:"read_private_pages";b:1;s:18:"read_private_posts";b:1;}      **What is the difference between the i:1 and b:1 ? How can I get the update_meta_user to add the b:1?** I cannot find a document but curious if this is i for integer and b for boolean. In which case, how can I get this code to update the wp_cabailities database field?


title: Taxonomy term page being linked a post from another custom post type?

text: I am building a Wordpress website which consists of 3 different custom post types (using post type UI) and also a number of different custom fields using the ACF plugin. I am getting a really weird issue where it has come to setting up a taxonomy terms page. Before I get into the specifics I will give a brief overview of my post structure. Post types:   * solutions   * need-advice   * case-studies Taxonomies (all attached to the case-studies post type):   * need-advice    * sector    * service Now, one of the key pages of the website is called 'Businesses we help'. This page is essentially a list of the terms relating to the _sector_ taxonomy. Sometimes they will have a related case study, other times they will be empty. I've got this page working as intended. The issues I am having are all related to `taxonomy-sector.php` I am trying to get the desired custom fields to appear onto this page. For example if I try the following code               <?php global $post; echo $post->post_name; ?>      It returns the name of a post relating to the _need-advice_ post type. This is the same if I echo the post ID on the `taxonomy-sector.php` page, it returns the ID of a need-advice post. Could this be because a Taxonomy shares the same name of a post type? I know there is nothing too specific with this at the moment but can anyone advise if they have heard of anything like this happening before? If I try changing the ID of the need-advice post directly in the database, the ID being returned on the taxonomy terms page also changes to the new ID, as if they are linked together.


title: Remove_filter ('the_content', 'wpautop') is not working

text: I've tried disabling WP's auto-paragraph thingy using `remove_filter ('the_content', 'wpautop');` but I am still getting my stuff wrapped in automatic `<p>` tags... What am I doing wrong? Its at the bottom of a functions file. Its not in functions.php, but in a file that functions.php includes (and putting it in functions.php doesn't change the behaviour at all). Update: `var_dump( $wp_filter['the_content'] );` outputs `NULL`. How can I test why this filter isn't being run?


title: Getting Catategory / Taxonomy Description on Non-archive Pages

text: Can you pull in the description of a custom tax on pages other than the taxonomy-(custom-tax).php i.e on the home page you want to show the description of a custom tax. This works on the aforementioned archive page but nowhere else:               <?php echo term_description( '', get_query_var( 'taxonomy' ) ); ?>      Many thanks for any help.


title: Attachment doesn't display post_parent gallery in multisite

text: I am working on multisite in a subfolder. I create a post with image linked to "attachment page" and not to a "media file". If the post has one single attachment and if i click to this image (image.php):               $metadata = wp_get_attachment_metadata();      works fine, and so i can go to post_parent. If the post has a gallery, metadata return only link to post (title of the image) and not to post_parent. For example:                 <?php echo get_the_title( $post->post_parent ) ?>      works in image.php only if the post has one image. If the post has a gallery, post_parent display only the title of the attachment, and doesn't display title of post_parent. Code of metadata in image.php is the default code:               <?php                                      $metadata = wp_get_attachment_metadata();                                 printf( __( 'Published  <time class="entry-date" datetime="%1$s">%2$s</time> at %4$s × %5$s in %8$s.', 'twentytwelve' ),                                     esc_attr( get_the_date( 'c' ) ),                                     esc_html( get_the_date() ),                                     esc_url( wp_get_attachment_url() ),                                     $metadata['width'],                                     $metadata['height'],                                     esc_url( get_permalink( $post->post_parent ) ),                                     esc_attr( strip_tags( get_the_title( $post->post_parent ) ) ),                                     get_the_title( $post->post_parent )                                 );                             ?>      Why this happens? I suppose it depends by the installation and configuration of multisite. There is a solution?


title: Inserting image into meta box row using jQuery - always adds to first row

text:
I'm having a problem with inserting images into a custom post type meta box. I have a button that adds a row to the DIV and you click on the **Select Image** button to use the WordPress media selector. However, if you create two rows and try and select the images, the first one works fine but the second one is inserted in the row where you first added the image. Here's the code...               add_action( 'admin_init', 'init_bb_meta' );          function init_bb_meta()     {         add_meta_box( 'bb_room_images_meta_box',             'Room Images',             'display_bb_room_images_meta_box',             'resort_rooms', 'advanced', 'default'         );     }          function display_bb_room_images_meta_box( $room )     {         ?>

         <button type="button" id="add_room_image_button">Add New</button>         <input type="hidden" name="BB_PLUGIN_URL" id="BB_PLUGIN_URL" value="<?= BB_PLUGIN_URL ?>" />         <?php     }      Javascript:               jQuery('#add_room_image_button').click(function()     {         var BB_PLUGIN_URL = jQuery('#BB_PLUGIN_URL').val();              var new_row = '
' +             '
Image
' +             '
' +             '
Name<input type="text" name="bb_img_title[]" class="widefat bb_img_title" maxlength="50" value="" />
' +             '

' +             '
<button type="button" class="upload_image_button">Select Image</button>' +             '<input type="hidden" name="bb_img_url[]" class="bb_img_url" value="' + BB_PLUGIN_URL + 'images/no_photo_room_slider.jpg" />
' +             '
' +             '
';         jQuery('#bb_room_img_list').append(new_row);     });          var file_frame;          jQuery('.upload_image_button').live('click', function( event )     {         event.preventDefault();         var image_url = jQuery(this).parent('.bb_half').find('.bb_img_url');         var image_href = jQuery(this).closest('.bb_room_img_form').find('.bb_img_display');              // If the media frame already exists, reopen it.         if ( file_frame )         {             file_frame.open();             return;         }              // Create the media frame.         file_frame = wp.media.frames.file_frame = wp.media(         {             title: jQuery( this ).data( 'uploader_title' ),             button: {                 text: jQuery( this ).data( 'uploader_button_text' ),                 },                 multiple: false  // Set to true to allow multiple files to be selected         });              // When an image is selected, run a callback.         file_frame.on( 'select', function()         {             // We set multiple to false so only get one image from the uploader             attachment = file_frame.state().get('selection').first().toJSON();                  // Do something with attachment.id and/or attachment.url here             image_href.css('border', '2px solid red');             jQuery(this).css('border', '2px solid red');             jQuery(this).closest('.bb_room_img_form').css('border', '2px solid red');                  image_url.val(attachment.url);             image_href.attr('src', attachment.url);         });              // Finally, open the modal         file_frame.open();     });      I think the popup image select window is causing an issue. Any ideas on how to fix. Thanks


title: How can I get an XML export of my 1K+ posts WordPress instance?

text: I'd like to export my database to XML because the import script to my new blog already supports getting data from that. A database backup or wordpress clone is not that useful in this case. The problem is that using the builtin export button times out after 90 seconds. I have ssh access to the server and am not afraid to use it :) I don't really know php but I can muddle around with help. Given Problem: Create a cron job to export posts to a WordPress XML file on server I think that the export_wp function might be what I want, I just don't know what to do with that...


title: dropdown does not work

text: I have the page http://www.supersprox.eu/invoicewithtabs/. When I click "Show filter" button an area with several dropdowns appear. The problem is I can not select values of the first row of dropdowns. When I click, for example, first "Field name" dropdown a list with values do not appear, although HTML-code of the page shows that there are values in that dropdown with `id='fiedname00'`(values are Invoice, Stamping, Part number, Quantity etc.). But I can not change the initial value that was set when page loaded. But when I press "Add condition" button that add new portion of dropdowns, these new dropdowns allow to change their values. Why this happens? On local computer, without WordPress everything works fine, but on WordPress site there is an issue described. I am using WordPress 3.9.2.                   <select id="fieldname00" onchange="populatedropdown('0')">         <option>Invoice</option>         <option>Stamping</option>         <option>Part number</option>         <option>Quantity</option>         <option>Order number</option>         <option>Anodal</option>         <option>LILS</option>         </select>


title: How to display variable prices by default in woocommerce?

text: I would like to display the variable price by default in the "from price tab" in the single product page. and not have the from price. Its confusing to the shopper to see a "from" price then below it a price for each variation, that changes once a variation is chosen. **see attached image** So instead of having to sets of price fields I want to display only one where its a single or variable product. ![enter image description here](http://i.stack.imgur.com/sK1oc.png)


title: Can I divide the pages into categories?

text: I wanto know if I can divide the pages into categories? Going into the Wp administration panel I can see that I can create some categories for the posts but it seems to me that I can't do it for the pages. Why? What am I missing? Tnx


title: Nextgen Gallery: Fast Function To Retrieve Single Thumbnail From Gallery

text: Does anyone have a better (faster) function to retrieve a single thumbnail image from a nextgen gallery? The following functions fetches the entire gallery stdObject - is there a more direct approach if I don't want to deal with objects? Would you recommend a simple database call? I need the post ID, title and permalink               function getImagesLink($postid=0, $size='thumbnail')         {           global $post;            $sortie = 0;                       $postid = get_the_ID();                       if(class_exists('nggdb'))             {               //retrouver la galerie liée au post               $gal_id = getGalleryFromPost($postid);               //var_dump($gal_id);               if(intval($gal_id))               {                 $picturelist = nggdb::get_gallery($gal_id, 'pid', 'ASC');                 if($picturelist && count($picturelist) > 0)                 {                   $thumb = current($picturelist);                   foreach($picturelist as $image){                              $sortie = $image->thumbURL;                         }                                        }               }      return $sortie;                      }


title: How do I get only a certain number of images from a post (minus the featured image)?

text:
I have the following code (see below) that lists all attached images from a post. I'm trying to alter this code to only list the first five images, and also to exclude the featured image from the list. Any help is certainly appreciated. Thanks in advance.

         <?php                $args = array(            'post_type' => 'attachment',            'numberposts' => -1,            'post_status' => null,            'post_parent' => $post->ID           );                $attachments = get_posts( $args );              if ( $attachments ) {                 foreach ( $attachments as $attachment ) {                    echo '
';                    echo wp_get_attachment_image( $attachment->ID, 'thumbnail' );                    echo '
';                   }              }         ?>


title: Determine Term depth

text: I'm looking to be able to find the depth of a term within it's hierarchical tree.               Produce     -- Vegetables     ---- Carrot     ---- Onion     ---- Celery     -- Fruit     ---- Apple     ------ HoneyCrisp     ----Orange      Produce is level 0 (or 1), Fruit is level 1, Apple is 3, HoneyCrisp is 4, etc. Ideal usage is `$depth = get_term_depth( $term_id );`. Anyone have experience with this? I essentially want a different rendering depending on depth on a term archive page.


title: make a pagination that show posts by date

text: i dont know if this is right question or not . but what i want to do is that , i need to create a pagination that show posts by date . i know the regular pagination is like this first-page - 22 - 23 - 24 ... last-page but i need some thing like this . 2009 - 2010[jul,apri,feb] - 2011[agus,oct] - 2012[nov,dec] - 2013[jan,agus,jul] . when i click on each year , then i should see the month that the admin have post any thing on that month .![like this image](http://i.stack.imgur.com/jN9Us.png) i hope you get what i mean .


title: No Authors for custom post type

text: I am trying to implement custom post type in Wordpress. plugin: **Advanced Custom Fields**                   register_post_type('acf', array(             'labels' => $labels,             'public' => false,             'show_ui' => true,             '_builtin' =>  false,             'capability_type' => 'page',             'hierarchical' => true,             'rewrite' => false,             'query_var' => "acf",             'supports' => array(                 'title',             ),             'show_in_menu'  => false,         ));      However, my another plugin, which displays only user's content (posts, pages, media...) is disabling also the metaboxes created by this plugin. This is the code of the small plugin which displays user's stuff (thanks goes to another post and person)               function content_for_current_author($query) {          if($query->is_admin) {         global $user_ID;         $query->set('author',  $user_ID);     }     return $query;     }     add_filter('pre_get_posts', 'content_for_current_author');      Users now can't see metaboxes which I created as admin on the website.


I see the message when trying to access wp admin at localhost: Fatal error: Call to undefined function reset_mbstring_encoding() in Z:\home\localhost\www\k-gayduk.ru\wp-includes\class-http.php on line 251 I suspected plugins, however, nothing has changed when turned all of them off. Any thoughts?


title: Modify Redux Framework Options in Child Theme

text:
I have a wordpress theme that I am modifying the look and feel by making a child theme. The parent theme I am using uses the redux framework. Im a bit new to using filters and hooks, but I want to add/modify a section on the options page. I found a function to add sections through the child theme but I don't know how to use it. When I include the code in my child-theme functions.php I get an error saying it can't be re-defined. This is the example it shows in the options.php file. Can anyone help explain how to use this function or point me to some concise explanations on how it should be used. Thanks!               /*      *      * Custom function for filtering the sections array. Good for child themes to override or add to the sections.      * Simply include this function in the child themes functions.php file.      *      * NOTE: the defined constansts for URLs, and directories will NOT be available at this point in a child theme,      * so you must use get_template_directory_uri() if you want to use any of the built in icons      *      */     function add_another_section($sections){         //$sections = array();         $sections[] = array(             'title' => __('A Section added by hook', AZ_THEME_NAME),             'desc' => __('
This is a section created by adding a filter to the sections array. Can be used by child themes to add/remove sections from the options.
', AZ_THEME_NAME),             'icon' => 'paper-clip',             'icon_class' => 'icon-large',             // Leave this as a blank section, no options just some intro text set above.             'fields' => array()         );              return $sections;     }     //add_filter('redux-opts-sections-twenty_eleven', 'add_another_section');


title: Is it possible to checkout a beta version of WordPress via github?

text: I know how to check out current versions of WordPress using via `git fetch --tags` but I only see current and past versions, not betas. Is it possible to get access to betas through github?


title: AZ Directory category

text: Hi i would like to create an A to Z index of category of 3 rows. How would i go about in doing this? Example: ABCDEFG... A   title of category started with the letter A B title of category started with the letter B C title of category started with the letter C D title of category started with the letter D E title of category started with the letter E F title of category started with the letter F G title of category started with the letter G etc...


title:
How to force TinyMCE in WordPress to replace newlines with
 tags and not with

text: TinyMCE editor inserts `<p> </p>` instead of `<br>` tags when I press enter in my text for a new line. How to force TinyMCE in WP to replace newlines with `<br>` and not `<p> </p>`?


title: adding multiple custom columns to users.php

text: I'm trying to add two columns to the users.php file. I'm not sure how to add both $total_time_display and $logged_in_amount_display. How could I return both values? Here is my code:               add_filter('manage_users_columns', 'freeman_add_user_minutes_column');     function freeman_add_user_minutes_column($columns) {         $columns['total_time'] = 'Total Minutes';         $columns['logged_in_amount'] = 'Number of Logins';         return $columns;     }          add_action('manage_users_custom_column',  'freeman_show_user_minutes_column_content', 10, 3);     function freeman_show_user_minutes_column_content($value, $column_name, $user_id) {         $user = get_userdata( $user_id );         if ( 'total_time' == $column_name )             $total_time_display = ($user->total_time);             return $total_time_display;         if ( 'logged_in_amount' == $column_name )             $logged_in_amount_display = ($user->logged_in_amount);             return $logged_in_amount_display;         return $value;     }


title: Wordpress javascript call functions?

text: wordpress runs jquery in noconflicts mode which means that you either need to write your JS code using the jQuery function call               $(document).ready(       function($) {         $("html").niceScroll();       }     );      (The above like codes problem , I want to know where they should be rightly placed,) The above code calls for nicescroll.js file which i have en queued like this:               function your_enqueue(){       wp_enqueue_script(' name ', get_template_directory_uri(). '/nicescroll.js' , array('jquery')), '1.0', false);     }     add_action('wp_enqueue_scripts', 'your_enqueue');      What is "your_enqueue here does? Most importantly, just don't only correct enqueue code but also to tell where the jquery call functions will be placed to call nicescroll.js. Thanks


title: wp_query pagination links producing 404

text:
I've searched thousands of related posts and can't seem to get the pagination to work on this loop. As soon as i click next page i get a 404               //get the search term     if (!empty($_GET["s"])){     $s = $_GET["s"];          //the search form will have an input value of "Search..." if nothing has been selected. We need to clear      if ($s=="Search..."){         $s='';     }     }          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $limit = 10;          $args = array(         //the user inputed search term         's' => $s,         'post_type' => 'schools',            'posts_per_page' => 5,         'paged' => $paged,         //we use tax_query here to query the schools custom taxonomy.          'tax_query' => array(             'relation' => 'AND',             array(                 //name of school categories (custom taxonomy)                 'taxonomy' => 'school_category',                 //we are going to search by matching category ids                 'field' => 'id',                 //the array we created that contains all the category ids to be searched                 'terms' => $category_and,                 //we want to make sure only posts in all of the categories selected are shown.                 'operator' => 'AND'             ),             array(                 //name of school categories (custom taxonomy)                 'taxonomy' => 'school_moi',                 //we are going to search by matching category ids                 'field' => 'id',                 //the array we created that contains all the category ids to be searched                 'terms' => $category_MOI,                 //we want to make sure only posts in all of the categories selected are shown.                 'operator' => 'AND'             ),             array(                 //name of school categories (custom taxonomy)                 'taxonomy' => 'school_curriculum',                 //we are going to search by matching category ids                 'field' => 'id',                 //the array we created that contains all the category ids to be searched                 'terms' => $category_cur,                 //we want to make sure only posts in all of the categories selected are shown.                 'operator' => 'AND'             )              )          );          //The new query with our arguements     $wp_query = new WP_Query( $args );          woo_loop_before();          if ($wp_query->have_posts()) { $count = 0;          $title_before = '
';     $title_after = '
';          //echo $title_before . sprintf( __( 'Search results for "%s"', 'woothemes' ), get_search_query() ) . $title_after;             ?>

          <?php         //Make sure the search results take into account the categories chosen on the seach bar              while ($wp_query->have_posts()) {$wp_query->the_post(); $count++;                  if (get_option('woo_woo_tumblog_switch') == 'true') { $is_tumblog = woo_tumblog_test(); } else { $is_tumblog = false; }                  woo_get_template_part( 'content', 'search' );              } // End WHILE Loop                        next_posts_link('« Next');         previous_posts_link('Previous »');              //wp_reset_postdata();            } else {     get_template_part( 'content', 'noposts' );       } // End IF Statement                 woo_loop_after();      I have the **blog pages show at most option** set to 1. Help would be really appreciated! Thanks


title: Qtranslate Vs Theme My login

text: am facing a problem with Qtranslate and Theme my login plugin my default language is Ar, when i go to Edit Profile in English Lang, and i update my profile, its redirect me to the Arabic Language, example : my current url is :   websitename.com/your-profile/?lang=en After Updating Post : websitename.com/your-profile/?updated=true it should be   websitename.com/your-profile/?updated=true&lang=en ( If En)   websitename.com/your-profile/?updated=true&lang=ar ( If Ar) i tried lot of solutions online, but i can't find any solution work with me i tried this Patch and isn't working too :/ i need a code, plugin modification to detect language from Current URL and keep it after redirect.( i don't mind manual modification for the plugin ) i tried this solutions and none get worked :               <input type="hidden" value="<?php if(isset($_GET['lang']) && $_GET['lang']=="ar") echo "ar";else echo "en";?>" name="lang" id="lang"/>      so the output of my form is                 <form id="your-profile" action="/your-profile/" method="post">     <input type="hidden" value="en" name="lang" id="lang"/>     <input type="hidden" id="_wpnonce" name="_wpnonce" value="6982ecbbe4" />     <input type="hidden" name="_wp_http_referer" value="/your-profile/" />      I guess the problem is here it should be /your-profile/?lang=ar or ?lang=en


title: Why is Wordpress custom post type not showing in admin panel?

text: Every time I create a custom post type, the label never shows on the left admin panel, However, they do show when you click on manage post type.. Not sure what is going on.


title: How to disable (get rid of) home page main loop entirely?

text: I'm using a custom theme, the index page doesn't depend on the main loop for home (which by default get the latest 10 posts for example). How can I get rid of the home loop entirely, so the index doesn't request any additional data from the database?


title: How to add terms (without deleting others)

text: I have a form on my site that allows signed in users tag products from the front-end of the site in a basic form. I am using Woocommerce as the commerce platform. Woocommerce uses Custom Post Types to register its products. Product tags is a taxonomy (product_tag) Woocommerce uses for tagging products. I am using wp_set_object_terms to insert the terms the users submit. Problem is when they submit new "tags" it overwrites any existing "Tags" and replaces with their new ones. I just need a way for the form to add their tags and keep the existing tags of the product (post). here is what I have:               if (is_user_logged_in()) {                   if(isset($_POST['submitted']) && isset($_POST['post_nonce_field']) && wp_verify_nonce($_POST['post_nonce_field'], 'post_nonce')) {                   //Tagging         wp_set_object_terms( $post->ID, explode( ',', $_POST['postTags'] ), 'product_tag' );          }          ?>     <form name="primaryTagForm" action="#" id="primaryTagForm" method="POST" enctype="multipart/form-data" >         <fieldset class="tags">             <label for="post_tags">Tags:</label>             <input type="text" value="" tabindex="35" name="postTags" id="postTags" />         </fieldset>              <fieldset>             <input type="hidden" name="submitted" id="submitted" value="true" />             <?php wp_nonce_field( 'post_nonce', 'post_nonce_field' ); ?>             <button class="button" type="submit"><?php _e('Tag Product', 'framework') ?></button>         </fieldset>     </form>


title: Creating a WordPress admin page without a menu for a plugin

text: I am writing a plugin, that will list a number of entries from a custom set of tables. I added the main page for the plugin using the following WordPress functions:               // Add menu and pages to WordPress admin area     add_action('admin_menu', 'myplugin_create_top_level_menu');          function myplugin_create_top_level_menu() {         add_menu_page('MyPlugin', 'MyPlugin', 'manage_options', 'myplugin-top-level-admin-menu');         add_submenu_page('myplugin-top-level-admin-menu', 'MyPlugin Admin Page', 'Admin Page', 'manage_options', 'myplugin-top-level-admin-menu', 'myplugin_admin_page');     }          function myplugin_admin_page {         // Code to display the admin page for my plugin (both php and html code)         // This includes the following seudo code (in php)         foreach ($results_from_db as $result) {             // CODE TO DISPLAY RESULTS IN AN HTML TABLE *** I NEED HELP HERE ***         }     }      Now, if you read the above code closely, you note that there is a comment that states **'I NEED HELP HERE'** ; here are more details: I know how to display everything on the the admin page that I created. The admin page will read from the custom tables, and display results as HTML table rows. I only need to link each row to a page, lets call it **'Entry Details Page'**. The idea is, for each row in the HTML table, there will be a link, and when I click on that link, it will take me to another page that displays more details about that row. I was thinking of using add_submenu_page as described here, but honestly I did not understand how to use it and how to include it in my code. I tried something like this but I think it is wrong:               function myplugin_admin_page {         // Code to display the admin page for my plugin (both php and html code)         // This includes the following seudo code (in php)         foreach ($results_from_db as $result) {             // CODE TO DISPLAY RESULTS IN AN HTML TABLE *** I NEED HELP HERE ***                  // The following line of code is incorrect, but to show you the idea             echo 'View';              }     }          myplugin_details_page () {         // Code to display the details page     }      Now, the two problems I am facing are:   1. How to add the details page correctly (it is clear that what I am doing above in the second code snippet is incorrect)?   2. How to include params in the details page (I need to pass a row id to view the details)? I think I am really close to solving the problem, however I could not find enough documentation to finish it, so please help, and I really really thank you. Cheers.


title: Sorting posts by first letter of the last word in title

text: I have a CPT called `author` that has a first name and a last name as title. To alphabetically sort these posts by surname I use this filter:               function posts_orderby_lastname ($orderby_statement)      {       $orderby_statement = "RIGHT(post_title, LOCATE(' ', REVERSE(post_title)) - 1) DESC";         return $orderby_statement;     }      Works fine except for the few authors who have a nickname (only one word). Those are returned together first, then all the "normal" authors with first and last names come afterwards in alphabetical order. How to make it work with all authors including those with a one-word nickname?


title: How to create a Custom Meta Box with Name/Value Admin User Input Fields?

text:
I have researched many tutorials on how to create/add Custom Meta Boxes using the `add_meta_box()` Wordpress function. I can not find any example where the finished Meta Box has the option for an Admin User to input both **key/value** pairs like Custom_Fields? EDIT: Removed plugin link URL as not enough rep points: I want to add this capability to my own Custom Meta Boxes and to the WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress plugin's Meta Box fields. To clarify, I want to create a Meta Box that Admin Users can add Name and Value to - like is shown in this image taken from the WP's own Custom Fields Meta Box : ![enter image description here](http://i.stack.imgur.com/EJnQK.jpg) Edit 19.06.14: My understanding of `Custom Fields` was incorrect, when querying on the front end:                       printf( '
%s
', var_export( get_post_meta($post->ID,"my_custom_filed_key"), true ) );      I see that `my_custom_field_key` produces an index array:               array (     0 => 'val  1',     1 => 'val  2',     2 => 'val  3',     )      I suppose what I am trying to achieve is an associative array?               array (     'my key name 1' => 'my val 1',     'my key name 2' => 'my val 2',     'my key name 3' => 'my val 3',     )      Here is the `add_meta_box` function part of my code:               function my_meta_boxes($post) {             add_meta_box(                 'my_meta',          // Unique ID                 esc_html__( 'Reviews', 'example' ), // Title                 'my_meta_box',  // Callback function                 'my-post',          // Admin page (or post type)                 'side',               // Context                 'default'             // Priority             );      }          /* Display the post meta box. */     function my_meta_box() {              wp_nonce_field( basename( __FILE__ ), 'my_post_nonce' );                   $meta = get_post_custom($post->ID);             $meta['my_meta'] = maybe_unserialize($meta['my_meta'][0]);             ?>

                     <textarea style="width:90%;" rows="1" name="my_meta[]"> <?php echo $meta['my_meta'][0] ?></textarea>

                     <textarea style="width:90%;" rows="1" name="my_meta[]"> <?php echo $meta['my_meta'][1] ?></textarea>

                     <textarea style="width:90%;" rows="1" name="my_meta[]"> <?php echo $meta['my_meta'][2] ?></textarea>

     <?php }      I am wondering if the `add_meta_box` $callbacks_args would help me here, but I am yet to full understand it? Thank you.


title: PHP help get_template_directory + PHP include

text: Sorry my PHP skills are lacking. I want to use a php include in WP but I'd like to get the file path with `<?php get_template_directory(); ?>` I can't figure out how that would look. My non WP file looks like this:               <?php include 'inc/social.php'; ?>      Basically I don't know how to string two PHP commands together `get_template_directory` \+ include.


title: Sidebar widget to show popular post not working?

text:
This is the code to display popular post on front end, however the problem is the data is not saving from the back end. Like i want to show only 3 popular posts on front-end so i select the option 3 but its not saving. However when i pass the static value for `$popularpostcount` then this code works `echo $this->popularPosts($popularpostcount);` so i believe the problem is only saving the selected option. I am new to plugin development so please let me know what mistake i am making while the development.               <?php     /*     Plugin Name: Popular Post Widget     Plugin URI: http://demo.test.com     Author: Swapnesh Kumar Sinha     Description: This is a plugin to show popular posts in sidebar as a widget.     Version: 1.0     Author URI: http://swapneshsinha.wordpress.com     */                    class PopularPostWidget extends WP_Widget {          public function __construct() {         //Widget actual processes         $widget_options = array( 'Description' => 'Show Popular Posts' );         parent::__construct( 'PopularPostWidget', 'Popular Post Widget', $widget_options);      }          public function form( $instance ) {         //outputs the options form on admin     $instance = wp_parse_args( (array) $instance, array( 'popularpostcount' => '' ) );     $popularpostcount = $instance['popularpostcount'];       echo $popularpostcount;     echo "Number of post to show ";      echo "<select name='popularpostcount' id='popularpostcount'>";         for( $i =1; $i<=5; $i++ )         {             if ( $i == $instance['popularpostcount'] )             echo "<option value='".$i."' selected>".$i."</option>";             else             echo "<option value='".$i."'>".$i."</option>";         }      echo "</select>";     }          public function update( $new_instance, $old_instance ) {         //processes widget options to be saved         $instance = $old_instance;         $instance['popularpostcount'] = $new_instance['popularpostcount'];         return $instance;     }          public function widget( $args ,  $instance ) {         //outputs the content of widget         extract($args);         $popularpostcount = apply_filters('widget_title', $instance['popularpostcount']);         echo  "
Most Popular Posts
";         echo  "
";         echo $this->popularPosts($popularpostcount);         echo  "
";     }               public function popularPosts($num)     {          global $wpdb;              $posts = $wpdb->get_results("SELECT comment_count, ID, post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , $num");              foreach ($posts as $post) {             setup_postdata($post);             $id = $post->ID;             $title = $post->post_title;             $count = $post->comment_count;                  if ($count != 0) {                 $popular .= '
';                 $popular .= '' . $title.' '." - ".$count;                 $popular .= '
';             }         }         return $popular;     }               }          add_action( 'widgets_init' , create_function('', 'register_widget( "popularpostwidget" );' ) );


title: Adding custom cron_schedule prior to wp_schedule_event

text: I am trying to add a custom `cron_schedule` interval inside a plugin and then use that custom interval to schedule a cron event when the plugin is activated. It seems that the custom interval is not available though when the activate code is executed. Using any of the default intervals adds the scheduled event, but if I try to use the custom one, it doesn't get added. The custom interval is indeed added (I can see it by echoing `wp_get_schedules`) but isn't available when I try to add the scheduled event on activation. My problem seems to be fairly identical to this one: Using wp_cron with custom time interval and the register activation hook But, I've already tried removing underscores from my hooks and the event is still not scheduled using the custom interval. All the default intervals work, though. Any thoughts on how I can get this to work?               private function __construct() {       // Add custom cron schedule       add_filter( 'cron_schedules', array($this, 'add_custom_cron_schedule' ));     }          public function add_custom_cron_schedule( $schedules ) {       $schedules['minute'] = array(         'interval' => 60,         'display' => __( 'Every Minute', $this->plugin_slug )       );            return $schedules;     }          // Called from register_activation_hook, this doesn't get added     // when using 'minute', but will work if using a WP default like 'daily'     public static function single_activate() {        wp_schedule_event( time(), 'minute', 'cronFunction' );     }