title: How to display a custom built field on wordpress default gallery

text: I created a custom field for the media I can upload on my wordpress website, by adding this code to functions.php:               /**     * Adding a "Copyright" field to the media uploader $form_fields array     */     function add_copyright_field_to_media_uploader( $form_fields, $post ) {     $form_fields['copyright_field'] = array(         'label' => __('Copyright'),         'value' => get_post_meta( $post->ID, '_custom_copyright', true ),     );     return $form_fields;     }     add_filter( 'attachment_fields_to_edit', 'add_copyright_field_to_media_uploader', null, 2 );          /**     * Save our new "Copyright" field     */     function add_copyright_field_to_media_uploader_save( $post, $attachment ) {     if ( ! empty( $attachment['copyright_field'] ) )          update_post_meta( $post['ID'], '_custom_copyright', $attachment['copyright_field'] );     else         delete_post_meta( $post['ID'], '_custom_copyright' );     return $post;     }     add_filter( 'attachment_fields_to_save', 'add_copyright_field_to_media_uploader_save', null, 2 );               /**     * Display our new "Copyright" field     */     function get_featured_image_copyright( $attachment_id = null ) {     $attachment_id = ( empty( $attachment_id ) ) ? get_post_thumbnail_id() : (int) $attachment_id;     if ( $attachment_id )         return get_post_meta( $attachment_id, '_custom_copyright', true );     }      So this is really good, I now have a field "Copyright" that I can fill when i upload new images on my blog. And I can display this copyright information on my template using:               "<?php echo get_featured_image_copyright(); ?>"      But now I'd like to display this copyright field on the wordpress default gallery. Currently the default gallery only output the caption on the title of the media. Indeed, this is how the default gallery look like on a wordpress post: ![This is how the default gallery look like on a wordpress post](http://i.stack.imgur.com/sI0iY.jpg) and this is how the image look like when I click on it: ![this is how the image look like when I click on it](http://i.stack.imgur.com/mloX6.jpg) Now I'd like to add the copyright data on the gallery output, both on the general view of the gallery and on the single image view. I'd like to thank you in advance for your help. Marc


title: Order posts of a custom post type by the event date using FT Calendar Plugin

text: I am using the FT Calendar Plugin. My question is how can I order posts of a custom post type by the event calendar date? So for instance I have a CPT named "Events" and for each event post a calendar date is added. Problem is that the page that lists the event posts doesn't order the posts by event calendar date, but the standard wordpress ordering. Is there a way to order them in my query instead by the FT Calendar event date? The data for the event dates are stored in their own table "rfw_ftcalendar_events".               id | calendar_id | post_parent | start_datetime      | end_datetime          1  | 2           | 210         | 2013-04-05 15:00:00 | 2013-04-05 16:00:00


title: Anyway to specify what should appear in <title> in .php file?

text: Is there anyway I can set what text should appear in the tags before get_header() is called in my .php files that are inside my theme's directory?


title: Need a functions that adds (adm)/(mod) if current user is admin/moderator right after their username

text: When a moderator/admin leaves a comment I want them to stand out and not be like any other comment. I have this piece of code so far but I dont think will do any good               <?php $current_user_is_a_mod = current_user_can( 'edit_others_posts' );if ( $current_user_is_a_mod ) echo '(mod)'; ?>


title: Single Featured Image Repeating

text:
I am attempting to create a listing of Blog Posts by Date(Month) and show the featured image for each.

Posts for <?php echo get_the_date('F, Y'); ?>

                     <?php // The loop ?>                     <?php if ( have_posts() ) {                         while ( have_posts() ) {                             if ( has_post_thumbnail() ) {                                 echo "
";                                     the_post_thumbnail();                                     echo '
' . get_post(get_post_thumbnail_id())->post_excerpt . '
';                                 echo "
";                             }                             the_post();                             the_content();                             echo "
";                             echo "
";                                 the_date('','Article posted on ', '.');                             echo "
";                             echo "
";                         } // end while                     } // end if ?>      My code above is showing each individual blog post. However, the very first thumbnail image is then posted for each blog post. So regardless of what thumbnail I pick for the post, all of them show the same image as the first one loaded. So it looks like this -               > Image 1     > My Post     > Post date     > Image 1 again     > My next post     > next post date      Why am I having repeating thumbnail images?


title: Pagination not working

text:
I am using the following code for pagination but its not working .Please help me out and tell that what is it that i am doing wrong
                     <?php $paged= (get_query_var('paged' )) ? get_query_var('paged'):1; ?>                    <?php $args = array( 'post_type'=>'events',                                  'posts_per_page' => 2 ,                                  'paged'=>$paged                                );                                 $loop = new WP_Query( $args );                   if($loop->have_posts()):while ( $loop->have_posts() ) : $loop->the_post();                      $count=0;             ?>                           <div class="row event-list  my-events <?php echo $type[0]->name; ?> ">

<?php the_title( ); ?>

                                   <img src="<?php echo IMAGES; ?>/share.png" class="img-responsive" alt="" />

                                                    <?php get_sidebar('share'); ?>

                     <?php  endwhile; ?>                            <?php endif; ?>

<?php previous_posts_link( '← Newer posts' ); ?>

<?php next_posts_link( 'Older posts → ' ); ?>


title: Make a menu link in Admin link to frontpage editor?

text: I have a page set up as my Frontpage. I'd like to have a link under the pages menu in the admin that says something along the lines of 'Edit Frontpage', which redirects to the editor or this specific page. This is linked from the 'welcome widget' using the following code:               <?php printf( '' . __( 'Edit your front page' ) . '', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?>      But I cannot figure out how to use the "add_menu_page" in combination with the code above. Could somebody point me in the right direction?


title: Override the default number of posts to show for a single loop?

text: Is is possible to override the set # of blog posts to show per page (as defined under Reading Settings in the WordPress admin)? I want to make it so a custom loop that I am using will show an unlimited number.


title: Advanced SELECT query with condtional statements

text: I am having trouble understanding the proper way to write an advanced select query. I have the following the code here.               if (!empty($_GET['3321body_type'])) {         $bt = $_GET['3321body_type'];         $bt_sql = "AND m1.meta_key = 'body_type' AND m1.meta_value = '$bt'";     }     else $bt_sql = '';     if (!empty($_GET['3321Make'])) {        $make = $_GET['3321Make'];         $make_sql = "AND m3.meta_key = 'Make' AND m3.meta_value = '$make'";     }      else $make_sql = '';            if (!empty($_GET['3321Model'])) {             $model = $_GET['3321Model'];         $model_sql = "AND m4.meta_key = 'Model' AND m4.meta_value = '$model'";         }        else $model_sql = '';       if (!empty($_GET['3321Year'])) {       $year = $_GET['3321Year'];       $year_sql = " AND m2.meta_key = 'Year' AND m2.meta_key = 'Year' AND          m2.meta_value       BETWEEN '$year' AND '9999'";            }       else $year_sql = '';         global $wpdb;         $wpdb->show_errors = true;          $querystr = "     SELECT * FROM wp_posts     LEFT JOIN wp_postmeta m0 on (wp_posts.ID = m0.post_id)      LEFT JOIN wp_postmeta m1 on (wp_posts.ID = m1.post_id)      LEFT JOIN wp_postmeta m2 on (wp_posts.ID = m2.post_id)      LEFT JOIN wp_postmeta m3 on (wp_posts.ID = m3.post_id)      LEFT JOIN wp_postmeta m4 on (wp_posts.ID = m4.post_id)      WHERE wp_posts.ID = m0.post_ID     " . $bt_sql . "     " . $make_sql . "     " . $model_sql . "     " . $year_sql . "     ";          $search = $wpdb->get_results($querystr, OBJECT);     foreach($search as $post) {     setup_postdata($post);      If I write it out like this               SELECT * FROM wp_posts     LEFT JOIN wp_postmeta m0 on (wp_posts.ID = m0.post_id)      LEFT JOIN wp_postmeta m1 on (wp_posts.ID = m1.post_id)      LEFT JOIN wp_postmeta m2 on (wp_posts.ID = m2.post_id)      LEFT JOIN wp_postmeta m3 on (wp_posts.ID = m3.post_id)      LEFT JOIN wp_postmeta m4 on (wp_posts.ID = m4.post_id)      WHERE wp_posts.ID = m0.post_ID     AND m1.meta_key = 'body_type' AND m1.meta_value = 'Sedan'     AND m3.meta_key = 'Make' AND m3.meta_value = 'Acura'     AND m4.meta_key = 'Model' AND m4.meta_value = 'CL'     AND m2.meta_key = 'Year' AND m2.meta_key = 'Year' AND m2.meta_value BETWEEN '$year' AND '9999'      It shows up just fine. But When I add in the conditional statements in my first block of code. it appears the JOIN is not working properly because it returns duplicate rows. Can anyone show me the proper way to write this statement to make the search query dynamic? Also an example of how to work wpdb->prepare into the works.


title: Does anyone have the Custom Post Permalinks plugin from John P. Bloch?

text: Can you upload it somewhere or send to my email?


title: How to make a plugin appear only to a certain role of user?

text: I'm using a plugin called "Team Result", to create team results and things like that. It appeared on the dashboard for admin(me). As you can see in this print screen(http://img138.imageshack.us/img138/239/22c22a7c37d1480f90c5163.png), is the last option in the menu of the dashboard. I want to create a user role to work with this plugin, I know how to create roles and that, my question is, how can I atribute this capacity to a user role. Thanks in advance.


title: Displaying custom post type listing

text: The following function enables a single custom post type template from a plugin:               function ch4_br_template_include( $template_path ) {                if ( get_post_type() == 'book_reviews' ) {                    if ( is_single() ) {                        // checks if the file exists in the theme first,                        // otherwise serve the file from the plugin                        if ( $theme_file = locate_template( array                            ( 'single-book_reviews.php' ) ) ) {                            $template_path = $theme_file;                        } else {                            $template_path = plugin_dir_path( __FILE__ ) .                                '/single-book_reviews.php';     } }     }                return $template_path;            }      What is the equivalent for displaying a list of my custom post types? I want to have a separate template for displaying a table of, in my case 'resellers', at mysite/resellers. Here is my custom post type:               public function wps_reseller_cpt() {             $labels = array(                 'name'               => _x( 'WPS Resellers', 'post type general name' ),                 'singular_name'      => _x( 'WPS Reseller', 'post type singular name' ),                 'add_new'            => _x( 'Add New', 'book' ),                 'add_new_item'       => __( 'Add New Reseller' ),                 'edit_item'          => __( 'Edit Reseller' ),                 'new_item'           => __( 'New Reseller' ),                 'all_items'          => __( 'All Resellers' ),                 'view_item'          => __( 'View Reseller' ),                 'search_items'       => __( 'Search Resellers' ),                 'not_found'          => __( 'No resellers found' ),                 'not_found_in_trash' => __( 'No Reseller found in the Trash' ),                 'parent_item_colon'  => '',                 'menu_name'          => 'Resellers'             );             $args = array(                 'labels'        => $labels,                 'description'   => 'Holds our resellers and reseller specific data',                 'public'        => true,                 'menu_position' => 50,                 'supports'      => array( 'title', 'editor','image', 'thumbnail', 'custom-fields' ),                 'rewrite' => array('slug' => 'resellers'),                 'has_archive'   => true,             );             register_post_type( 'wps-reseller', $args );         }


title: Adding two submenus to a menu

text: I have a menu(ads) that contains 2 submenus(view and manage). I want that both menu item redirect to different pages, but my 1st submenu(view) is directing to the main menu page.![Both ads menu and view submenu redirecting to same page ](http://i.stack.imgur.com/AYj3K.jpg)


title: Archive.php, and post_is_in_descendant_category

text:
I've got a small issue with my archive.php. I was trying to set up an If statement that displays a certain category and sub categories with a different layout & sidebar based on my theme options. I've placed a small bit of code in the start of my archive.php in order to set these options based on if the post is in category 'nytt' or is a sub cat of nytt (ID 49). It works like a charm, if the category listing in part of NYTT or a sub cat, but now, all other categories don't display, the page won't load further than the header. And for the life of me I can't figure out why. I'm staring at this code like it holds a secret which it won't give up..               <?php     get_header();          $subtitle=get_opt("_posts_subtitle");     $slider='none';     if ( in_category( 'nytt' ) || post_is_in_descendant_category( 49 ) ) {         $layout='left';     $sidebar ='teacher-training';     }     else {      $layout = get_opt('_blog_layout');     $sidebar = get_opt('_blog_sidebar');     }          include(TEMPLATEPATH . '/includes/page-header.php');          ?>          <div id="content-container" class="content-gradient <?php echo $layoutclass; ?> ">     <div id="<?php echo $content_id; ?>"><?php          if(have_posts()){     while(have_posts()){         the_post();         global $more;         $more = 0;          include(TEMPLATEPATH . '/includes/post-template.php');            }           print_pagination();           }else{     echo ('No posts available');     }          ?>
     <?php      if($layout!='full'){      print_sidebar($sidebar);     }     ?>

     <?php     get_footer();     ?>      Also I understand that I could be using the category.php to accomplish this as well, but as my theme was using archive.php by default I decided to use this instead. I've declared the [post_is_in_descendant_category] (http://codex.wordpress.org/Function_Reference/in_category#Testing_if_a_post_is_in_a_descendant_category)! function in my child themes functions.php. Any help would be uber appreciated. Thanks for your time and expertise!


title: Question about how global $wp_admin_bar works

text: So, I ran into an interesting issue while adding some admin menu bar links today. When adding links to a parent menu using something like: `               // Add the parent menu     $wp_admin_bar->add_menu( array(             'title' => 'Testing MENU',             'href' => false,             'id' => 'parent_id'         ));                              // Add the child menu     $wp_admin_bar->add_menu( array(                 'title' => 'My Child Label',                 'href' => '#',                 'parent' => 'parent_id'         ));      ` The above code works great and as expected. But what if I wanted, for whatever reason, to add a second child menu item like this: `               // Add another child menu     $wp_admin_bar->add_menu( array(                 'title' => 'My Child Label *',                 'href' => '#',                 'parent' => 'parent_id'         ));      ` This will not work. The last menu item overrides the first. I understand that you would want to prevent duplicate titles in an admin menu, but this is technically NOT a duplicate title. To get it to work, I must add a non-special character (a-z,A-Z,0-9) to the end like this: `               // Add another child menu     $wp_admin_bar->add_menu( array(                 'title' => 'My Child Label *1',                 'href' => '#',                 'parent' => 'parent_id'         ));      ` It appears that the logic checking for duplicate labels is stripping any non- alphanumeric characters from the end of the title and then comparing that. Does anyone have any insight as to why this is? I can't think of any reason to not take the entire title into consideration. Any thoughts?


title: Pass boolean value in shortcode

text: In WordPress shortcodes, how can I pass boolean attributes?   Both of `[shortcode boolean_attribute="true"]` or `[shortcode boolean_attribute=true]` are giving string values. EDIT There would be no problem for users who know what they're doing if I use the trick which was commented by @brasofilo. But some users will get lost if they give an attribute `false` value and receive `true` value. So is there any other solution?


title: Pull Tags But Not as Links

text: I'm trying to take a list of tags and list them on the page but without linking to their archive page. At the moment I'm doing this:               <?php     global $wp_query;     $postid = $wp_query->post->ID;     echo get_the_term_list( $post->ID, 'visits', 'Visits ', ', ', ' ' );     wp_reset_query();     ?>      Thanks


title: How to use an array of categories as a dropdown?

text: I need to use an array of existing categories as a dropdown option value then use the selected category ID. More exactly, I try to make a custom module to display the latest posts form selected category using Visual Composer plugin tutorial. I tried to use `wp_dropdown_categories` in the follwoing code but I get some errors and nothing works:                       array(             'param_name'    => 'category_id',             'type'          => 'dropdown',             'value'         => wp_dropdown_categories, // here I'm stuck             'heading'       => __('Category filter:', 'overmax'),             'description'   => '',             'holder'        => 'div',             'class'         => ''             ),      Thanks


title: In a url where Category Id is wrong It is showing wrong it is going to the page not found page

text: In my one project I am using old 2.8.4 version of word press. So If In url wrong category name is there then it is going to the page 404 page not found. But I want that still it should go to the archive page only. In latest version of wordpress it is like that only. It is going to category page if i specify wrong category name then also. So why it is not the case with old version what should do to go on the same page weather right category is there or wrong category is there.


title: deactivated_plugin hook: get the name of the plugin

text: I would like that every time any plugin previously activated, a function from my plugin be called, returning (at least) the name of the plugin, or something that allows to identify it (file name?). I figured i could use the action hook "deactivated_plugin" but i'm wondering what information from the desactivated plugin is actually available?


title: Change order of custom columns for edit panels

text: When you register a custom column like so:               //Register thumbnail column for au-gallery type     add_filter('manage_edit-au-gallery_columns', 'thumbnail_column');     function thumbnail_column($columns) {     $columns['thumbnail'] = 'Thumbnail';     return $columns;     }      by default it appears as the last one on the right. How can I change the order? What if I want to show the above column as the first one or the second one? Thank you in advance


title: Check if SEO plugin installed

text: Is there any way to check whether the user has an SEO plugin installed, so as if they do not I can insert my metas etc.


title: Getting Post ID from slug during init

text: I am trying to add a url rewrite rule that finds any posts that are connected to the current post (using Posts 2 Posts by scribu). It's tied into the WP Query object, so all I have to do is pass another variable "connected" => $post_id and it works. This is my rule that I am working with, but I don't have the post_id as a part of my url, so I can't get that via regex. `add_rewrite_rule("cleats/([^/]+)/news", "index.php?tag=\$matches[1]", 'top');` What really needs to happen if this is going to work is that I need to get the id based on the post slug via get_posts, but that seems like overkill to happen on every single init. Am I going down the right path, or is this not worth it? * * * What I want to happen is show only related news articles. For instance, I have a Manchester United page (custom post type of club) at /clubs/manchester- united. I want /clubs/manchester-united/news to show a listing of blog articles that are connected to that post. The way I am storing that information is with Posts 2 Posts, linking posts directly to that custom post. That keeps me from having to doubly maintain a list of tags that exactly match the custom post types that I have. Where the query string for returning tags is as simple as ?tag=manchester- united, it works a little differently in my case. What I need is ?connected=45, where 45 is the post->ID of manchester-united. The regex in the rewrite rule above returns the slug "manchester-united", but that isn't enough information for my query. What I need to do is get the post->ID based on the "manchester-united" slug. Is that hopefully a little clearer?


title: Multiple users – only allow them to manage their own terms for custom taxonomy when logged in

text: How can I allow each user to manage their own terms for a custom taxonomy when logged in on edit-tags page? user will only show & manage terms that only created by him not others for a custom taxonomy. But Admin and editor can manage all. How can I do that? Any help will be appreciated. Thanks.


title: How to add image on top of header logo in child theme?

text: How do i add an image (icon that will link to photographer's page) on top of my logo   that is already part of my theme, into the child theme functions code, so that it will be saved if i ever upgrade the theme?   I don't know how to use widgets to achieve this nor have I found a suitable plugin.   I currently have it hacked into the parent theme's header file.


title: echo the_modified_date('j/M/Y') in after_title

text:
I want to add a "last updated date" in a span inside a specific widget here's my function so far               function add_front_sidebar(){     register_sidebar( array(         'name' => 'Front Sidebar',         'id' => 'front-sidebar',         'before_widget' => '
',         'after_widget' => '
',         'before_title' => '
',         'after_title' => 'Last Updated: ' .  the_modified_date('j/M/Y') . '
'     ) );     } add_action('widgets_init', 'add_front_sidebar');      I have two issues: 1. I can't get the_modified_date to echo out 2. Is there away to target the corrected Last Updated: ' . the_modified_date('j/M/Y') . ' to only appear in a certain widget, in this case the widget title is What's New Thanks


title: comment reply by email

text: Is it possible that the admin replies to a comment by email, replying to the notification message he receives about the comment? And for a whatever user if the subscribe to comments plugin is installed? In other words, I'm asking if the feature described in section "Comment reply via email" on page http://en.support.wordpress.com/comment-notification-email/ is available for a self hosting blog.


title: Customizing WordPress Admin - How to Change the Avatar size

text: I am in the process of customizing the back-end of WordPress for a new product that we will be releasing. I am trying to figure out what the best way is to update the avatar size that shows up in the adminbar, in the top right corner. I'm trying to set the image size 30px x 30px instead of the default 16px. Does any one have a way that I can do this with out updating the core WordPress files? I'm trying to keep WordPress future proof. Currently I am making all my updates to the admin panel design using a plugin and some js. Any help would be greatly appreciated.   * Daniel


title: custom post types missing ADD NEW

text: Having a bit of fun with custom post types. I use http://generatewp.com/ to generate the following custom post type to record partner organisation records. Things working:   * custom post type appears on admin menu   * categories and tags on both of them (i may delete them later by clearing taxonomies) What I can't figure out is why the "Add New" menu item is not appearing ... maybe because it's friday and it's been a long week but I cannot see what i'm missing Anyone?               /* Add Support for CEP Partner records */          if ( ! function_exists('Partners') ) {          // Register Custom Post Type     function Partners() {              $labels = array(             'name'                => _x( 'Partners', 'Post Type General Name', 'cep' ),             'singular_name'       => _x( 'Partner', 'Post Type Singular Name', 'cep' ),             'menu_name'           => __( 'Partner', 'cep' ),             'parent_item_colon'   => __( 'Parent Partner', 'cep' ),             'all_items'           => __( 'Partners', 'cep' ),             'view_item'           => __( 'View Partner', 'cep' ),             'add_new_item'        => __( 'Add New Partner', 'cep' ),             'add_new'             => __( 'New Partner', 'cep' ),             'edit_item'           => __( 'Edit Partner', 'cep' ),             'update_item'         => __( 'Update Partner', 'cep' ),             'search_items'        => __( 'Search Partner', 'cep' ),             'not_found'           => __( 'No Partners found', 'cep' ),             'not_found_in_trash'  => __( 'No Partners found in Trash', 'cep' ),         );         $rewrite = array(             'slug'                => 'cep-partners',             'with_front'          => true,             'pages'               => true,             'feeds'               => true,         );         $capabilities = array(             'edit_post'           => 'edit_partner',             'read_post'           => 'read_post',             'delete_post'         => 'delete_partner',             'edit_posts'          => 'edit_partners',             'edit_others_posts'   => 'edit_others_partners',             'publish_posts'       => 'publish_partners',             'read_private_posts'  => 'read_private_partners',         );         $args = array(             'label'               => __( 'partners', 'cep' ),             'description'         => __( 'CEP Partner Organisations', 'cep' ),             'labels'              => $labels,             'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'post-formats', ),             'taxonomies'          => array( 'category', 'post_tag' ),             'hierarchical'        => false,             'public'              => true,             'show_ui'             => true,             'show_in_menu'        => true,             'show_in_nav_menus'   => true,             'show_in_admin_bar'   => true,             'menu_position'       => 5,             'menu_icon'           => '',             'can_export'          => true,             'has_archive'         => true,             'exclude_from_search' => false,             'publicly_queryable'  => true,             'query_var'           => 'partners',             'rewrite'             => $rewrite,             'capabilities'        => $capabilities,         );         register_post_type( 'partners', $args );          }          // Hook into the 'init' action     add_action( 'init', 'Partners', 0 );          }


title: How can I set up a completely separate (not multisite) Wordpress installation as a subdirectory of an existing Wordpress blog?

text: I currently have a Wordpress multisite network running at `http://www.mysite.com` and rooted in `/var/www/html`. I need to set up a completely separate, single-site Wordpress installation accessible via `http://www.mysite.com/intranet` and rooted in `/var/www/html/vhosts/intranet/html`. It will use a separate database, a separate set of plugins and themes, etc. I'm aware that this is not the best of ideas, but it's what the client wants. How can I achieve this setup?


title: Receive 2 different XML feeds analyze data and use info to create new post?

text: I am receiving information from 2 different xml data feeds, I want my site to analyze that information and create a separate new post with the analyzed information. Looking for a plugin or a way to program this, just need a direction to go to complete this on a WordPress site.


title: Buddypress registration page hangs

text: Installed fresh set of wordpress and buddypress. Enabled user registration. Trying to register user. But the page hangs and if seen in Network tab of chrome, the status shown is pending waiting for the response from the server. But in wp_users, this user record is created successfully. The only issue is, the page hangs and takes the user to no where. Is this supposed to be an issue with buddypress / some settings that I am missing? This is the issue in IE, Firefox & chrome (that I tried) Below are the environment details Wordpress version 3.6 Buddypress version 1.8.1 Wamp server Any kind of help / suggestion is appreciated.


title: jQuery does not work on WordPress editor

text: I've added some content to WP's editor, however the new content does not respond to the click behaviour. Here's how I've added the content: `add_filter( 'default_content', 'custom_editor_content' );` Then created my function `custom_editor_content`:               function custom_editor_content( $content )      {          $content = '          <button id="test">Add</button>          ...';          echo $content;          }      The content is displayed within the editor ok, but it doesn't respond to the jQuery that's being loaded like: `add_action( 'admin_menu', array( $this, 'fnEnqueueAdminScripts' ) );` The js loads ok, so does the content, but I cannot understand why the click function doesn't work. Here's my js:               $( "#test" ).click(function() {              alert( "Test" );          });      Other snippets of js in the same file does work. The problem seems to be with the click function. The content is not generated dynamically so I don't think is a question of using `on` such as               $("#test").on("click", function() {              alert("test");          });      Any ideas of what I've done wrong?


title: Hiding Media Source Links

text: I inserted an image onto my page from my WordPress media (Add Media -> Media Library -> Link To = None). However, when I right click on the page to view the source, I noticed the address to my media. How do I hide this address? I think its a security risk that the folder in which my WordPress site lives in (my_renamed_wordpress_directory) is so easily visible. How do I hide this? When I added the image, I selected `Link To: None`. Any assistance will be appreciated. Thanks.


title: Display posts from multiple user roles

text: I have created a custom loop to show only admin posts, but now I would like it to display posts from both admins and contributors. Any help is GREATLY appreciated! Here is what I have so far:               echo "<div class='post_wrap " . $infinite . "'>";     $users_query = new WP_User_Query( array(                                              'role' =>  'administrator',                                                  'orderby' => 'display_name'                                             ) );     $site_admins = array();     $results = $users_query->get_results();     foreach($results as $user) {         $site_admins[] = $user->ID;     }          $admins = implode(',',$site_admins);     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;      query_posts(array('post_type' => 'post', 'author' => $admins, 'paged' => $paged, 'posts_per_page' => 10));     while (have_posts()) : the_post();


title: Add new "Insert Into Post" button with another function

text: Problem: Add a hook that automatically adds a **short tag** to video attachments when inserted from the Media Library (video) tab: **Update:** This works under the 'Media Library' tab — and doesn't break image inserts etc.:               add_filter('media_send_to_editor', 'my_filter_iste', 20, 3);          function my_filter_iste($html, $id, $caption, $title, $align, $url, $size, $alt) {         $attachment = get_post($id); //fetching attachment by $id passed through              $mime_type = $attachment->post_mime_type; //getting the mime-type         if (substr($mime_type, 0, 5) == 'video') { //checking mime-type             $src = wp_get_attachment_url( $id );             $html = '[video src="'.$src.'"]';           }         return $html; // return new $html     }      Inserts something like this: [video src="path/to/video/sample.mp4"] If you feel you can clean up the code, by any means, show us. Thanks @wyrfel


title: How to get post ID with hooks publish_post, new_to_publish, etc

text: I have two plugins, one uses the function wp_insert_post(), the other has a code like this:               add_action('future_to_publish', 'myFunc', 10, 1);     add_action('new_to_publish', 'myFunc', 10, 1);     add_action('draft_to_publish', 'myFunc', 10, 1);          function myFunc( $postID ) {          }      When the first plugin runs wp_insert_post(), $postID is always empty. If I use the hook "publish_post" and press update then $postID does have a value, so what I am doing wrong?


title: Current class on admin menu using add_submenu_page()

text: I am working on creating an administration menu within WordPress for a plugin. I have successfully registered the menu using add_menu_page() and it shows in the sidebar as expected. I have also added a couple of sections within the menu using add_submenu_page(). It appears that WordPress (running 3.05) is not correctly indicating which menu item should be activated as "current". When I add a test page to the main Dashboard menu this is what I see: http://dl.dropbox.com/u/3019972/wp-screen1.png As you can see the current page is visually correct within the menu and is given a class of "current". However on my own menu it looks like this: http://dl.dropbox.com/u/3019972/wp-screen2.png In this example I would expect "Dashboard" to be highlighted. Is this simply a WordPress bug? or do I need to provide special code to make this work within my own menu? **Updated with code examples** The code I am using for adding and creating menus looks like this:               add_action('admin_menu','my_admin_menu');          function my_admin_menu() {          // this test works as expected     // add_submenu_page( 'index.php', 'test', 'test', 'read', 'admin.php?page=plugin-dashboard','my_pluggin_dashboard' );          // my main menu menu         add_menu_page(__('My Plugin', 'myplugin'),__('My Plugin', 'myplugin'), 'edit_posts','admin.php?page=plugin-dashboard','my_plugin_dashboard','icon');          // dashboard submenu - this fails to highlight with current     add_submenu_page('admin.php?page=plugin-dashboard', __('Dashboard','myplugin'), __('Dashboard','myplugin'), 'edit_posts', 'admin.php?page=plugin-dashboard', 'my_plugin_dashboard' );          // settings submenu - this fails to highlight with current     add_submenu_page('admin.php?page=plugin-dashboard', __('Settings','myplugin'), __('Settings','myplugin'), 'manage_options', 'admin.php?page=my-plugin-settings', 'my_plugin_settings' );          }      I have commented the code that works and the code that does not behave as I expect. Thanks for your comments.


title: setup_postdata() does not seem to be working?

text:
I am not sure why but I have used `get_posts()` to query for some data. Then I used `setup_postdata()` ... I think its used so that I can use functions like `the_permalink()` etc with the new post data?               <?php foreach ($childPosts as $cp) : setup_postdata($cp); ?>          <article <?php post_class() ?> id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>"><?php the_title(); ?>
       <?php if (has_post_thumbnail()) : ?>       <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(($hasOutputNotFeaturedDiv) ? 'thumb-small' : null) ?>       <?php endif; ?>       <?php the_excerpt(); ?>
<a href="<?php the_permalink() ?>">Read more ...
       <?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>
          <?php endforeach; ?>      but it appears that only `the_excerpt` contains the new post data value, why is that? I find that if I use `echo get_the_permalink($cp)` it works ok. But I think the shorter version will be better


title: Separate steps in Wordpress post editor

text: Take a look at this: ![enter image description here](http://i.stack.imgur.com/SXopz.png) Sure, I'm not looking for that great thing. What I'm really looking for, is a simple tool, that make the writer able to add steps to its post (separate the steps of the tutorial that he's is writing). It can be a plugin, or a PHP trick or something else. Do you have any idea?


title: Have h2 tag not show up if there are no blog posts

text:
On our current site we have different company profiles. Some companies have blog posts that display on their profile and some don't. Their is an h2 tag above posts that is in the page template then the code to bring in the posts. The code looks like this.
Recent Blog Articles
      then                echo get_related_author_posts();      I am trying to find a way so that if their are no posts for the company the h2 tag will not show up. The code in the functions file is               function get_related_author_posts() {         global $authordata, $post;              $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );              $output = '
';         foreach ( $authors_posts as $authors_post ) {             $output .= '
ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '
';         }         $output .= '
';              return $output;     }


title: Autogenerated Title for Custom post type loses title when trashed/deleted

text: I am generating title for a custom post type using the following code. It takes the $fname, $mname, and $lname values and generates a title based on the post. This works fine for custom post creation and editing and updating. Everything works and behaves as expected, but when i delete this custom post, it loses its title and shows in the trash as "No Title". Is there a way to retain the title with this method ?               add_filter('wp_insert_post_data', 'auto_generate_name_title');     function auto_generate_name_title($data){       if( $post->post_type != 'person' ) {           return $data;       } else {           ... process to get custom field/meta values           //GET CUSTOM FIELD VALUES AND ASSIGN           $fullname = $fullslug = $fname . $mname . $lname;                $slug     = wp_unique_post_slug(sanitize_title($fullslug), $post->ID, $post->post_status, $post->post_type, $post->post_parent);                $data['post_title'] = $fullslug;                $data['post_name']  = $slug;                return $data;       } }


title: How to get source of custom meta image?

text: I'm working on a CPT (custom post type) page template and would like to get the source of custom meta image. For post_thumbnail's this is rather easy using `wp_get_attachment_image_src()`, but if I `var_dump( $post->ID )` I don't see a value for my custom meta attachment image source. So how can I get the ID of my custom-meta-image to get it's source? Thanks :) UPDATE This is what I got going.               <?php $portfolio_image_one = get_post_meta( $post->ID, '_cmb_portfolio_image_one', true ); ?>     <?php $portfolio_image_two = get_post_meta( $post->ID, '_cmb_portfolio_image_two', true ); ?>     <?php $portfolio_image_three = get_post_meta( $post->ID, '_cmb_portfolio_image_three', true ); ?>          <?php if ( has_post_thumbnail() ) {     $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large'); ?>     <a class="featured-image" href="<?php echo $large_image_url[0] ?>" title="' . <?php the_title_attribute('echo=0') ?> . '">     <?php the_post_thumbnail('medium', array('class' => 'img-polaroid')); ?>     </a>     <?php } ?>      Basically, I would like to get the ID for my post_meta images in a similar way to the thumbnail approach.


title: Wordpress + Buddpyress - troubleshooting server overloading

text: I have a Wordpress+Buddypress installation which is regularly going down - the number of HTTPD on the server and the server CPU load both peak suddenly and the server fails to recover. A restart of the web service is required. > **I'm looking for troubleshooting advice.** Edit: Moved from the comment in here to make the goal clear. I'm not getting any useful information out of the error log, even when enabling debug mode in Wordpress. I have tidied up a lot of sloppy code in plugins and themes which were throwing PHP notices, to no effect. I have defined ERRORLOGFILE to log MU errors, but nothing has been logged there as yet. I have tried using Debug Bar for Wordpress with SQL logging enabled, but this has not shown anything useful - as far as I can see it does not log db transactions to file, and the Debug Bar only shows db queries for one site at a time. We have over 3000 sites running in this installation. Other information: we are using WP Super Cache, using mod_rewrite. I have noticed quite a few errors in the error log to do with Wordpress trying to add or remove cache files which don't exist. I don't know if this is normal, or relevant. Wordpress and Buddypress are the most recent versions as of writing: 3.5.1 / 1.6.4 I am looking for more tips in pinpointing the cause of the issue. I have started gradually disabling recently activated plugins, but this is not going to be practical for all plugins on the live site. Any ideas? Thanks.


title: Adding range to wp_link_pages();

text: I have some very long posts, some have more than 50 pages() and when using wp_link_pages it give me 50 internal post links, clearly this isn't usable. How can I add a range to the wp_link_pages function? The output should look like this: ...45* _6_ *78... **UPDATE 10/1/2012** : I've got the logic for adding the range but now I need to figure out how to add it to the existing wp_link_pages function? Here is the example function:               function limitPagination(){         $displayPages = 5;         $firstPage = 1;         $lastPage = $numpages > 5;              while($numpages > $displayPages){             if(($pageNow > $firstPage +2) && ($pageNow < $lastPage - 2)){                     echo (($pageNow - 2).($pageNow - 1).$pageNow.($pageNow + 1).($pageNow + 2));             }         }     }


title: Allowed memory size exhausted problem

text: This seems to be a weird problem. The exact error is this:               Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 337608 bytes) in ...      It only hangs the dashboard. The other part of website has no problem. The file name where the error happens is different at different time and I can't reproduce the error as I want. Most probable reason of this error is activating plugin. So, I tried to activate all plugins one by one and the error occurred. I thought that plugin was the culprit. So to work in dashboard, I changed the name of the plugin via FTP and Dashboard was back. Then I renamed the plugin folder to its original name and activated the plugin again to reproduce the error. But this time it activated without any problem. I tried activating, deactivating other plugins and the same thing happened again with another plugin. After renaming the plugin folder, the error wasn't gone this time. Instead, it showed the error was in `\wp-includes\functions.php` and when I reloaded `\wp-includes\theme.php`. After I reloaded again, it worked and Dashboard was back. So, the problem is I can't seem to locate the origin of the problem. Does anyone have any idea?


title: Tags not appearing in "Add New Post" Page

text: I'm working on a mag website. I'm using `Tags` to group some content. For this I have added all the required tags from the **Tags** section under **Posts**. But When I go to `Posts -> Add New`, the Tags panel displays nothing. ![enter image description here](http://i.stack.imgur.com/F6Lku.png)


title: Pagination error Wordpress multiple loop

text: I have multiple loops using `wp_query()` in WordPress. I want to show the posts from first loop first (post per page=10), and if there are no posts from first loop show, then show the second loop. For example, if I only have 8 posts from first loop, the second loop should show 2 posts. The loop is working properly, but I can't solve the post per page issue. How can I do this? I also need pagination for the remaining posts.               $args = array(                     'post_type'         => 'event',                     'event-categories'  => 'featured',                     'orderby'           =>  'meta_value_num',                      'order'             =>  'ASC',                  );          $loop = new WP_Query( $args );     $args1 = array(                 'post_type'         => 'event',                 'event-categories'  => 'abc'                 'orderby'            =>  'meta_value_num',                   'order'             =>  'ASC',                  );          $loop1 = new WP_Query( $args1);


title: List custom taxonomy terms

text: I am trying to display all of the terms for a custom taxonomy(`characters`), the taxonomy is related to a custom post type(`books`). What I would like to do is display all of the terms for `characters`, so say for instance I have two `books`, and I add three `characters` to each `book`, I would like all six characters to display. I would only like to get the names, not links, or in list form, if I could get a set of objects or an array that would be preferable. Thank you.


title: Some questions about WPMU

text: I just activated wordpress multisite in my site. I have few questions. 1) WPMU and wordpress multisite both are same? 2) I created a network in my site. I created like site1.mydomain.com, site2.mydomain.com etc. Is it possible to make my subdomains posts summary appear in my main domain? 3) Is it possible to make users access all subdomains with single registration? Thanks


title: Custom User Role

text: I know how to add custom user roles, but how can i make it so that when a user with, lets say a role with 'DJ', they come to the dashboard AND ONLY GET TO SEE:   * Users > Your Profile    * custom menu DJ Housekeeping Panel and not see any other menu items.


title: Passing global variable from header.php to functions.php

text:
Situation: Is header.php file where is code: `if(is_single()){ global $my_global_var; $my_global_var == true; }` Is functions.php file where is code: `global $my_global_var; if($my_global_var == true) { echo "OK"; }` But this is not working, what im doing wrong? In sidebar all is fine. Fixed 0.2: Must be:                   add_filter('the_content','simple_img_tag_search');         function simple_img_tag_search($content){         if(is_single()){             $MYCODE = "
My code
";             $paragraphs = explode( '
', $content, 2 );             $first_paragraph = $paragraphs[0];             return str_replace($first_paragraph.'
',$first_paragraph.'
'.$MYCODE,$content);         }}


title: How to get category slug link? ( include parent categories)

text: for example, if main category slug is **cars** ;   sub-category slug is: **Ford** ; how to get the permalink of **Ford** , including its parent categories' slug?   ( `get_category_link()` returns `mysite.com/?cat=19` type of link, but i want `mysite.com/cars/ford` )


title: Retrieve/get current image from Nextgen gallery db

text: I thought that I can do it using the database where the idea was to get the image from the ngg_gallery_pictures table, where the browser URL is equal to URL of the image in the table. Then I will get only one image and that's also what I want. Probably I have some mistake here since I don't have a lot of knowlednge in sql but I would like to find the solution for it anyway.. Please let me know what you think and if you can include the code for mysql, it will be great (it is really short from examples that I saw) Many thanks!


title: How to order different custom post type in category or tag template page?

text: I have 3 differents custom post type : "Projet", "Notice" and "Disque". I want them to appear in a specific order when they are listed in the _category_ or the _tag_ template page. Like that : # 1 - Notice # 2 - Projet # 3 - Disque I've tried to catch te query string and use 3 different loops with WP_Query with no results.               <?php $my_notices_query = new WP_Query($query_string.'&post_type=notices&posts_per_page=1'); // only notices… ?>      <?php while ($my_notices_query->have_posts()) : $my_notices_query->the_post(); ?>      the query allways show all the cpt with no restriction. Thks for your help. BR


title: Add custom PHP and HTML to the_content()

text:
I am developing a wordpress website on the thematic framework. In my child theme i have made a full width page template called resources.php In this page template i have written custom php code which displays various custom fields related to posts of a particular category. For Example :

     <?php query_posts(array ( 'category_name' => 'research'   ,  'posts_per_page' => '-1' , 'order'=>'ASC')  ); ?>     <?php while (have_posts()) : the_post(); ?>     <li class="<?php foreach((get_the_category()) as $category) { echo $category->category_nicename; echo" ";} ?> resourcelist">     <?php the_field('document_title') ;?> <?php the_field('document_date'); ?>  <?php foreach((get_the_tags()) as $tag) { echo $tag->name; echo" "; } ?>     <?php the_field('document_description') ;?>     <a title="download" target="_blank" href="<?php the_field('document_path'); ?>">
                 <?php endwhile; ?>

      Now what i want to do is restrict this page to only users who have registered . I have a plugin which takes care of this for eg: page restrict What page restrict does is it replaces whatever gets called via the page's wisiwyg editor `the_content()` with the message "you need to login". The page gets blocked however my php code does execute as its a part of the page template. I am trying to find out a way to add all my php code to `the_content();` so that the output also gets replaced with the message. I came across this article which gave me the following code.                       <?php             function demo_function( $content ) {                      $someHtml = '
';                 $someHtml .= 'some text or code goes here';                 $someHtml .= '
';                      $filteredcontent = $someHtml . $content;                      return $filteredcontent;             }             add_filter( 'the_content', 'demo_function' );     //the loop goes here             the_content();         ?>      What this code does is that it adds the above HTML within the_content(); So, the next time i block the page, even the above content gets blocked. I exactly want that to happen but with my php code not this HTML. I am really close to cracking this but because of the above syntax appends the html to the variable, I cant append so many lines of my php code via that method. Please help me. If you have any questions feel free to ask.


title: Upgrade to 3.1 - Fatal error: Call to undefined function wp_cache_get()

text: I just upgraded to 3.1, and after refreshing I get the following error: > **Fatal error** : Call to undefined function wp_cache_get() in > **/public_html/blog/wp-includes/functions.php** on line **336** A quick google search led me to this post on WordPress support forum, however I tried disabling all plugins as suggested, and I'm using TwentyTen as my only theme. I also set `define('WP_CACHE', false)` in the config, didn't help... Any ideas before I attempt to roll everything back? Any ideas?


title: Edits to plugin not taking effect

text: I want to make some edits to a plugin that I've downloaded. I used the Plugin Editor, but the changes did not show up. I tried refreshing, logging out/back in, and deactivating/activating the plugin. I gave up on that route and decided to:   * deactivate/delete the plugin via the admin page   * delete the plugin folder via FTP to make sure there were no remaining files   * make the desired edits to my local copy   * upload the folder to the site via FTP   * activate plugin I verified that the new, edited file is up on the server, but the changes still do not show up. I am guessing there is some sort of caching going on, but I don't know where to begin to clear it. Other info that may be helpful:   * The URL of the page that I am trying to update is .../wp-admin/admin.php?page=dlm_addnew   * The plugin is Download Monitor and the file I updated is uploader.php   * I have no caching plugins and no wp-content/cache folder    * My site has cPanel, phpMyAdmin, etc. Thank you for your time!


title: How to create a child/addon plugin

text: This is a spin of: how to create child WordPress plugin I am using a plugin that I use and like a lot, but there is a feature that I need and it seems like the author is busy with life. I am a PHP developer so I could hard code my feature to his plugin, but this way on the next update I will not be able to update without loosing my changes. I have seen that there are some plugins out there that are addons/child to other plugins and they will not work unless you have the main/mother plugin installed. So my question is what is best to do in this situation? What steps I should take to make sure that after updating the main plugin my child plugin will still work?


title: Update term count using a callback function

text: With the wp_update_term_count_now, how can I use the update_count_callback to specify my own count. I need to include counts from another database that the current database category is able to display. The current categories may not have any posts in them, but are able to be viewed showing posts from the same category in another database. Im not entirely sure how to pass the call back to the wp_update_term_count_now nor what is should contain - does it just need a new count?


title: Incude comments in search

text: Is there a code snippet I can add to my functions.php, etc., that will include comments in the search (without plugin)?


title: using custom fields on content.php file of my theme

text: is there any error in following code? when i use following code in content.php file of my theme, then nothing is displayed on blog, it seems there is some error. and when i comment folowing code everything gets back to normal.               <?php if (empty(get_custom_field_value("signature",""))) : ?>         —         <?php the_category( '<span>/</span>' ); ?>           <?php endif; ?>      here is `get_custom_field_value` function:               function get_custom_field_value($szKey, $prefix = '', $bPrint = false) {         global $post;         $szValue = get_post_meta($post->ID, $szKey, true);         if ( $bPrint == false ) return (empty($szValue) ? "" : $prefix . $szValue); else echo (empty($szValue) ? $szValue : $prefix . $szValue);     }


title: Get previously visited page ID

text: I would like to get the ID (or permalink) of the page the visitor visited just before visiting the current page - in other words the ID of the last page in the browser history. Can this be done? Any idea how to do it?


title: Hide / Show Custom field depending of the page ID (Magic Field 2)

text: I use Magic Field 2 to display custome field on my page ! However, I would like to be able to hide several field depending on the page ID... I do not want to use custom post type because my website rely on basic page. Any idea on how I could do that ? Using javascript perhaps ? I can't figure out, which hook I should use. Thanks in advance for your time and patience. Cheers, Jk_


title: How can I limit functionality in one version of a plugin?

text: I am busy writing a plugin with a free version and a paid, Pro version. For our initial release of both versions, I want to keep things as simple as possible, so I would rather defer using a strategy of a very extensible free version, with hooks implemented in a Pro version; I will give this direction some attention for later releases. My next avenue is to simply have two completely separate builds that include some core, shared components, and some components specific to the Pro or Free versions. The purpose of my question here is to try and gather some advice on my third angle, that of using checks in code that only perform actions etc. if a certain version is running, i.e. if the client calling core services is Free or Pro. What should I be looking at to attempt this avenue of feature limiting?


title: Can't get image size set with set_post_thumbnail_size() function

text: I have a problem with set_post_thumbnail_size() function, which seems it doesn't work. Or at least it doesn't work correctly. I have set a thumbnail size 75x75px in WordPress settings under the media section and have also set another thumbnail size in the functions.php using:               set_post_thumbnail_size(80, 80, true);      How are these two settings supposed to work? I believe the one that I set in the function.php (80x80px) should override the other in the media settings. Am I correct? This is not the case though. Both sizes of the image exist in my uploads folder and what is worst I can't get the one I set with set_post_thumbnail_size() no matter what. When I call               the_post_thumbnail($id, 'thumbnail');      I get the one set in the media settings and not the one I set in my theme's functions.php. How can I get the other? **UPDATE:** It seems I messed up 'thumbnail' and 'post-thumbnail'. In media settings I can set the thumbnail size, which is another image size as 'medium' and 'large'. Using set_post_thumbnail_size() I can set the post-thumbnail (aka featured image) size. Sorry for the mess and thanks for the answers.


title: How to prevent certain usernames from being registered?

text: How can i prevent or blacklist a list of usernames that i don't want users to register with? And can I add a message if they try to register with one of those names that says 'this username has been reserved' Is this possible?


title: update_option is not saving an array, but saving the string 'Array'

text: I have come across quite an odd problem when using the `update_option` function, and I am sure that I've tried everything I can think of to get it working, but unfortunately it isn't. I'm using AJAX to submit a form (using the popular method described here) in the backend, on a custom options page. Everything is working, except for the `update_option` part. I just don't understand, is there an issue with using that function in an AJAX function callback?                   public function vmAddApp() {             parse_str( stripslashes( $_POST[ 'data' ] ), $data );             $nonce = $_POST[ 'nonce' ];             $app_info = $data[ 'vm_fbconnect' ];             $option = get_option( 'vm_fbconnect', array() );                  $appId = $data[ 'vm_fbconnect' ][ 'appId' ];             $secret = $data[ 'vm_fbconnect' ][ 'secret' ];                  $app_response = wp_remote_get( 'https://graph.facebook.com/' . $appId );             $response_body = json_decode( $app_response[ 'body' ] );             $app_name = $response_body->name;                  $new_app = array(                 'name' => $app_name,                 'id' => $appId,                 'secret' => $secret             );             $option[ 'apps' ][] = $new_app;             $data = update_option( 'vm_fbconnect', $option );                  // UPDATE:             // If I put either:             // $data = $option;  // <- this returns the option correctly, see below             // or             // $data = get_option( 'vm_fbconnect', array() );  // <- this returns 'Array' as a string             // But regardless, both SAVE 'Array' as the option's value..                  header( "content-type: application/json" );             $response = array( 'data' => $data );             echo json_encode( $response ); // <- this is how I'm getting the response in the JS console             exit;         }      **Edit 1:** Debugging (I updated the code above, see comments) This is what I get when I return the modified option from inside the function: ![enter image description here](http://i.stack.imgur.com/8CsvI.png) This is what I get when I use `get_option` again. ![ajax](http://i.stack.imgur.com/8PaHK.png) After the option has been saved and I am done with the form, sometimes I will go right into the page currently displayed and do `die( var_dump( get_option( 'vm_fbconnect', array() ) );` and it says just `string(5) 'Array'`. Also, I'm always careful to reset the option before trying each time, and careful to make sure I commented out the `delete_option` function when trying again! :)


title: Wordpress database error: [Query was empty] - using $wpdb->prepare()

text: I have edited my question, I'm now getting the error about checking my MySQL settings. I changed the $sql_dvalues variable to an array with the values instead of comma spaced values and now it is saying the following: > **WordPress database error:** [You have an error in your SQL syntax; check > the manual that corresponds to your MySQL server version for the right > syntax to use near '' at line 3] > >> INSERT INTO wp_efpd_gmaps ( time, name, address, description, title ) VALUES ( '2011-10-30 08:48:32', 'test', 'tedst', 'tedst', 'tedst' ), The reason I'm using `$wpdb->prepare()` is because I read this page: http://codex.wordpress.org/Class_Reference/wpdb under the headline `Protect Queries Against SQL Injection Attacks` but maybe I read wrong and don't need to use that? I'm not sure, some advice would be appreciated. * * * # Older notes & code: I have set up a way to add stuff into a WP database a little simpler and without having to know SQL, and I'm running into a problem. The query code outputs fine (see code below, `die($str);`) but whenever I try to actually test it by adding some data it gives me the following error: > **WordPress database error:** [Query was empty] It was working at one point but not inserting any data, and giving me a different error telling me to check my MySQL settings or something on what to use after ", I don't really remember what that said but I want to fix this problem first. Here's my function in my class called `Efpd2`               public function efpd_prepare_db($data=array(),$table_name) {         global $wpdb;         $table_name = $wpdb->prefix.$table_name;              $datenow = date('Y\-m\-d H\:i\:s');              $sql_values = 'time, ';         $sql_cvalues = '%s, ';         $sql_dvalues = array($datenow);         $int=0; $dcount = count($data);         foreach($data as $dat){             $int++;             $sql_values .= $dat['name'];             if($int!=$dcount){                 $sql_values .= ", ";             }             $sql_cvalue .= $dat['type'];             switch($dat['type']){                 case 'txt': $sql_cvalues .= '%s'; break;                 case 'num': $sql_cvalues .= '%d'; break;                 case 'float': $sql_cvalues .= '%f'; break;                 default: die('Error writing to database, wrong value type. Use \'num\', \'float\' or \'txt\'.');             }             if($int!=$dcount){                 $sql_cvalues .= ", ";             }             array_push($sql_dvalues,$dat['value']);         }              $str = "          INSERT INTO $table_name         ( $sql_values )         VALUES ( $sql_cvalues ),         $sql_dvalues         ";         // For debugging, use this:  die($str);         //die($str);              $wpdb->show_errors();         $wpdb->query( $wpdb->prepare(              "                 INSERT INTO $table_name                 ( $sql_values )                 VALUES ( $sql_cvalues ),             ",             $sql_dvalues         ) );     }      And the code I'm using to add the data:               function add_sample_data(){              $efpd = Efpd2::efpd_prepare_db(         array(             0 => array(                 'name' => 'name', // Name of the variable inside the table                 'value' => 'test', // Value to add                 'type' => 'txt' // Type of data to be added ('num' = %d, 'txt' = %s, 'float' = %f). See $wpdb->prepare() documentation on codex.wordpress.org             ),             1 => array(                 'name' => 'address',                 'value' => 'tedst',                 'type' => 'txt'             ),             2 => array(                 'name' => 'description',                 'value' => 'tedst',                 'type' => 'txt'             ),             3 => array(                 'name' => 'title',                 'value' => 'tedst',                 'type' => 'txt'             )         ),         'efpd_gmaps'); // Table to add data to         unset($efpd);     }     add_action('init','add_sample_data');      And this is what is sent out when using `die($str);` in `Efpd2::efpd_prepare_db()`: > INSERT INTO wp_efpd_gmaps ( time, name, address, description, title ) VALUES > ( %s, %s, %s, %s, %s ), '2011-10-30 07:27:53', 'test', 'tedst', 'tedst', > 'tedst'


title: Dynamic iCal generator outside/inside wordpress

text: So following on from this post: http://stackoverflow.com/q/1463480/1086990 I was wondering how exactly it would work integrating it into Wordpress. I have a custom post type setup, and so far I have tried both linking to a "ical.php" with the above link code (and changing the title into `the_title()` and the dates into GMT versions of my `date(..)` code). None work, because it can find the `get_post_custom_values()` which is obvious since not in WP loop, or a WP associated file. Next I tried adding the `headers` into the `header.php` WP file, and adding a `if(is_singular("event"))`, but the headers auto download. If I can stop the auto download then I'm ace, otherwise I come here for help! Is there any reasonable way that is dynamically able to be populated via WP and **only** download when the link is clicked, not automatically? _I would host everything, but the events are going to be so often, that making and hosting would be a waste_ **also** is there maybe a href generator like Google Calendar that would automatically work? * * * **EDIT (My working code):** **Custom Taxonomy Loop**               <form action="<?php echo get_feed_link('calendar-event'); ?>" method="post">         <input hidden="hidden" name="eventID" value="<?php the_ID(); ?>">         <button title="Add to iCal" type="submit" name="iCalForm">iCal</button>     </form>      **iCal.php** I included this into the `functions.php` via a `require()`.               <?php //Event ICAL feed     class SH_Event_ICAL_Export  {              public function load() { add_feed('calendar-event', array(__CLASS__,'export_events')); }              // Creates an ICAL file of events in the database         public function export_events(){                   //Give the iCal export a filename             $filename = urlencode( 'event-ical-' . date('Y-m-d') . '.ics' );                  //Collect output              ob_start();                  // File header             header("Content-Description: File Transfer");             header("Content-Disposition: attachment; filename=".$filename);             header("Content-type: text/calendar");             header("Pragma: 0");             header("Expires: 0");     ?>     BEGIN:VCALENDAR     VERSION:2.0     PRODID:-//<?php echo get_bloginfo('name'); ?> //NONSGML Events //EN     CALSCALE:GREGORIAN     X-WR-CALNAME:<?php echo get_bloginfo('name');?>: Events     <?php // Query for events              if(isset($_POST['iCalForm'])) {             $post_ID = $_POST['eventID'];             $events = new WP_Query(array(                 'p' => $post_ID,                 'post_type' => 'event'  //Or whatever the name of your post type is             ));              if($events->have_posts()) : while($events->have_posts()) : $events->the_post();             $uid = get_the_ID(); // Universal unique ID             $dtstamp = date_i18n('Ymd\THis\Z',time(), true); // Date stamp for now.             $created_date = get_post_time('Ymd\THis\Z', true, get_the_ID() ); // Time event created             // Other pieces of "get_post_custom_values()" that make up for the StartDate, EndDate, EventOrganiser, Location, etc.             // I also had a DeadlineDate which I included into the BEGIN:VALARM             // Other notes I found while trying to figure this out was for All-Day events, you just need the date("Ymd"), assuming that Apple iCal is your main focus, and not Outlook, or others which I haven't tested :]     ?>     BEGIN:VEVENT     CREATED:<?php echo $created_date;?>          UID:<?php echo $uid;?>          DTEND;VALUE=DATE:<?php echo $end_date; ?>          TRANSP:OPAQUE     SUMMARY:<?php echo $organiser; ?>          DTSTART;VALUE=DATE:<?php echo $start_date ; ?>          DTSTAMP:<?php echo $dtstamp;?>          LOCATION:<?php echo $location;?>          ORGANIZER:<?php echo $organiser;?>          URL;VALUE=URI:<?php echo "http://".$url; ?>          BEGIN:VALARM     ACTION:DISPLAY     TRIGGER;VALUE=DATE-TIME:<?php echo $dLine; ?>          DESCRIPTION:Closing submission day of films for <?php echo $organiser; ?>! Enter quickly!     END:VALARM     END:VEVENT     <?php endwhile; endif; } ?>     END:VCALENDAR     <?php //Collect output and echo          $eventsical = ob_get_contents();         ob_end_clean();         echo $eventsical;         exit();         }             } // end class     SH_Event_ICAL_Export::load();     ?>      Hope this serves well to whoever needs it, as it is a fantastic piece of work, so again thanks Stephen Harris who helped more than the question, and additionally without suggesting I use his plugin.


title: Ajax and WP_Query/tax_query parameter

text:
After doing some extensive research, I've exhausted all my options and decided to actually ask a question here. I'm trying to get a filtered set of posts through AJAX using WP_Query and the tax_query parameter. I currently have one custom post type called "Vocabulary Terms" and two custom taxonomies called "vocabulary categories" and "difficulty level". Essentially what I want users to do is select a category, then a difficulty level and load any of the posts that are tagged with each. Below are my php functions and js. It seems I can filter by Vocabulary Terms but the second I attempt to pass anything into tax_query, it fails. Any ideas? ajax-game-functions.php               function get_game_difficulty() {          // Nonce check     $nonce = $_REQUEST['nonce'];     if (!wp_verify_nonce($nonce, 'ajax_scripts_nonce')) die(__('Busted.'));          global $wpdb;     global $wp_query;     global $post;     global $terms;               $html = "";     $success = false;     $gameCategory = $_REQUEST['gameCategory'];     $gameDifficulty = $_REQUEST['gameDifficulty'];          $html .= '
Listen and repeat each word you hear until you feel comfortable pronouncing each word.
';     $html .= $gameCategory;     $html .= $gameDifficulty;          $html .= '
';     $args = array(         'numberposts' => 5,         'post_type' => 'vocabulary_terms',         'tax_query' => array(             array(                 'taxonomy' => 'vocabulary_categories',                 'field' => 'slug',                 'terms' => $gameCategory             )         )     );     $myposts = get_posts( $args );     foreach( $myposts as $post ) :  setup_postdata($post);         $title = get_the_title();         $html .= '
'.$title.'
';     endforeach;     $html .= '
';          // Build the response...     $success = true;     $response = json_encode(array(         'success' => $success,         'html' => $html     ));          // Construct and send the response     header("content-type: application/json");     echo $response;     exit;     }     add_action('wp_ajax_nopriv_get_game_difficulty', 'get_game_difficulty' );     add_action('wp_ajax_get_game_difficulty', 'get_game_difficulty' );      ajax-game-scripts.js               $(document).on('click', '#vocabulary-games a.difficulty-level', function() {     //$('#vocabulary-games a.difficulty-level').click(function(){     // Store category slug in variable          var vocab_difficulty = $(this).attr('data-difficulty');     var vocab_cat = $(this).attr('data-category');          // post data to function     $.post(ajax_scripts.ajaxurl, {         dataType: "jsonp",         action: 'get_game_difficulty',         nonce: ajax_scripts.nonce,         gameDifficulty: vocab_difficulty,         gameCategory: vocab_cat       }, function(response) {         if (response.success===true) {           $('#vocabulary-games').children().fadeOut('slow',function(){             //$('#vocabulary-categories').children().hide(1,function(){               $('#vocabulary-games').append().html(response.html);             //});           });         } else {           alert('!');           // Bad Response message         }     });       }); // end click


title: WordPress' ALL post count info on its dashboard does not match phpMyAdmin's ALL post count!

text: While phpmyadmin's wp_posts table reports something like this               Showing rows 0 - 29 (10,223 total, Query took 0.0022 sec)     SQL query:     SELECT * FROM  `wp_posts` LIMIT 0 , 30      Wordpress's dashboard reports               All (10,222) | Published (10,222)     Search Posts:  10,222 items « ‹  of 512 › »       As you can see, there is a disconnect here... 10,222 != 10,223 Does anyone know why WordPress reports 1 less then the actual all post count?


title: If I use Apache & ngnix together will I have fewer problems?

text: I have a VPS set-up and because it had limited RAM I set it up to run nginx instead of apache. But although performance has been reasonable, I've had problems with things like multi-site rules and plugins complaining. I was wondering if I used Apache and Nginx together, with nginx serving static files, apache php would I get both performance and compatibility? I am thinking of setting up my VPS in a similiar manner to the 2nd answer to this question: What is the best caching option for WordPress multi-site on non-shared hosting?


title: How to Explode a Textarea Field and Echo each line separately, wrapped with HTML

text: Need to take an advanced custom field textarea and display it in my template by breaking out each line separately. I want to wrap each line of the textarea with HTML, like an `<li>`. I've tried the following, but it's just not working:               if (isset($instruction_textarea)){         $arry=explode( "\r\n", $instruction_textarea );     }     for ($i = 0; $i <= count($arry); $i++){         echo (trim($arry[$i])+"<br/>");     }


title: How to upload image with simple form?

text: I writing plugin in my profile page and i want to create upload via 'Browse' button and 'Dir' field that will upload and return image url.And i don't want to use media-upload. I used to read Set Featured Image Front Frontend Form? and I don't understand code Help me solve this problem?


title: If Query In Sidebar

text:
I'm trying to create a query that IF there is a value in the 'FeaturedQuote' custom field, then this shows

“<?php         global $wp_query;         $postid = $wp_query->post->ID;         echo get_post_meta($postid, 'FeaturedQuote', true);         wp_reset_query();         ?>     ”

      IF NOT, this shows:               <img src="<?php         global $wp_query;         $postid = $wp_query->post->ID;         echo get_post_meta($postid, 'InsertFullImg', true);         wp_reset_query();         ?>">      I cant get it right! Thanks


title: Pirobox Gallery from single image link

text:
I need to have the post thumbnail image link to a gallery of post attachements displayed using pirobox. This is the code i use:                <?php if(has_post_thumbnail()){?>
      <a href="<?php echo wp_get_attachment_url( get_post_thumbnail_id() )?>" class="pirobox_gall" title="<?php the_title(); ?>" rel="gallery">      <?php the_post_thumbnail('single'); ?>
<?php }?>            <?php         $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image' ) );         foreach ( $attachments as $attachment_id => $attachment ) {         echo '<a href="';         echo '' . wp_get_attachment_url( $attachment_id ) . '" class="pirobox_gall" title="<?php the_title(); ?>" rel="gallery">';         echo '';          } ?>      I'm getting the post thumbnail image (first in attachements) repeated five or more times in the pirobox slideshow - see here: http://anarita.me/protocolar/portfolios/inauguracao-do-cinema-city-alvalade/ -, and can't understand why. Can someone help me? Thank you, Ana Rita


title: Mysql query and order meta value

text: I made a mysql query to WordPress like this:               $querystr = "         SELECT $wpdb->posts.*         FROM $wpdb->posts, $wpdb->postmeta         WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id         AND $wpdb->postmeta.meta_key = 'where'         AND $wpdb->postmeta.meta_value = 'london'         LIMIT 0,50  ";          $pageposts = $wpdb->get_results($querystr, OBJECT);      In this way i can grab all posts with `meta_key = "where"` and `meta_value = london` The problem is that I've also got another `meta_key`, `"date"` and a `meta_value` that contains the real date like `"05-06-2013"`, `"06-06-2013"`, etc. How can I query all posts with meta `"where" = "london"` and order by date using the data contain in meta `"date" = "xx-xx-xxxx"` ?


title: Fetching more posts in Wordpress via AJAX

text: What's the best way to fetch the next page in post archives and other lists like search results? This question has been asked many times already, but the answers not good enough for me. So far, I've found two ways of doing it.   1. Using an AJAX request to the standard URL (like `example.com/category/mycat/page/2`). This is done using the `$.load` function of JQuery which strips the result leaving only the contents of some block with the specified id. I believe this is inefficient both for the client (because unnecessary content is loaded and processed) and for the server (because such a request processes menus, widgets, etc., that are not needed).   2. With a custom ajax handler using the `add_action` function. The big problem with this option is that the handler is not universal! It circumvents the normal query parsing, creating a custom `WP_Query` object instead. Clearly, this is not the way. I am considering the following:   1. Register a query variable that would make the template display the page in JSON format and make a request like so: `example.com/category/mycat/page/2?showjson=true`. In the theme check for this variable and adjust output accordingly.   2. Get `query_vars` and using `wp_localize_script` pass them to the script. Then make the AJAX call with these variables and handle them appropriately. (Basically, this would be a beefed-up version of option 2 above). Then maybe there is some other way of doing this? _ADDED:_ Making a custom handler could be potentially used to improve performance, as not all of Wordpress needs to be loaded.


title: Custom post content to display in a normal post?

text: Is it possible to display custom post content in a normal Wordpress post? For example I have created a custom post type called Games Database, it is populated with game boxart, title, genre, platform, publisher, developer, review score and release date. Now when I create a new (normal) wordpress post I want to be able to select a game from a drop down menu that the post relates to, for instance if I'm writing a post about Mario Galaxy 2 I would want to select that game from my database and then when I view the post on the website I want to be able to see a widget display with all of the games details. Is it possible to do this?


title: retrieve custom image sizes from media uploader javascript object

text: I am attempting to get the custom image sizes that I've created using `add_image_size` to return in the javascript object. I know how to include them in the dropdown, but I don't want / need that. The current object returns the defaults (full, large, medium, and thumbnail) in an array, but none of the custom sizes. Here is the code I am using to set the uploader instance               jQuery('input.guide-logo-upload').on('click', function( event ){              event.preventDefault();              // 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 // force single file         });              // run the callback when selected         file_frame.on( 'select', function() {                  // make sure to only deal with the first item             attachment = file_frame.state().get('selection').first().toJSON();                  // WHERE ARE MY CUSTOM SIZES             console.log(attachment);                  // Populate the field with the URL and show a preview below it             jQuery('input#g-logo').val( attachment.url );             jQuery('input#g-logo-id').val( attachment.id );                  jQuery('p.logo-description').after( '' );             jQuery('p.logo-description').after( '' );              });              // Finally, open the modal         file_frame.open();     });


title: Get object terms with no children?

text: Others have asked how to only get parent terms, but I need to get the deepest term for the post of a specific taxonomy. Is there a way I can only get terms where the number of children = 0?


title: Update references to pictures on website after moving to new URL

text: I moved my wordpress website to a new URL on the same server and managed to update most DB entries with the Velvet `Blues Update URLs` plugin. But the paths to my pictures, which are being used by the theme were not updated. Now the website can't load them anymore. The pictures' URLs still point to the old place. Is there tool, which can fix that, so I don't have to search for all entries in the DB by myself?


title: Single post navigation Previous post link shows up but Next post link doesn't

text:
I'm desperating with this odd issue related to Previous and Next post link. I have this single-name.php which is called by this condition in single.php:               <?php     if (in_category('mob')) {       include (TEMPLATEPATH . '/single-mob.php');     } else {       include (TEMPLATEPATH . '/single-others.php');     }    ?>      single-mob.php contains the following:               <?php get_header('projs'); ?>
          <?php if (have_posts()) : ?>               <?php while (have_posts()) : the_post(); ?>                   <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                     <?php the_title(); ?>

                     <?php if (function_exists('camera_meta_slideshow')) {                         $meta_camera = get_post_custom( $post->ID );                     if(isset($meta_camera['camera_meta_slideshow'])){                         echo camera_meta_slideshow($meta_camera['camera_meta_slideshow'][0]);                                 }                             }                         ?>

                             apply to:

                             <?php $ooutart = get_field('lig_proj', $post_object->ID); ?>
                                 <a href="<?php echo get_permalink($ooutroartigo->ID); ?>"><?php echo get_the_title($ooutroartigo->ID); ?>

              <?php endwhile; ?>
          <?php previous_post_link('%link', 'Previous post in category', TRUE); ?>                 <?php next_post_link('%link', 'Next post in category', TRUE); ?>
              <?php endif; ?>

                 <?php get_template_part( 'page', 'office' ); ?>

     <?php get_footer(); ?>      My question here is why the "Previous post in category" link appears and not the "Next post in category". I have 10 posts, limited the post per page in settings to 1 - I don't think this has anything to do with it... The camera_meta_slideshow is related to Camera Plugin (this calls a slideshow) and get_field is related to Advanced Costume Fields Plugin. The only thing I can do is to go to previous posts, even in the middle of the post counts. Thank you for the help you can give here. Best regards, H.


title: Problems to disable the comments for my statics pages

text: I am pretty new in WordPress world (I came from Joomla). I am developing a mainly static website using WP (because maybe in the future I will have some dynamic behavior and because WP is pretty light) So I have some statics pages that make up my site. The problem is that I can not disable comments on these pages, infact if you go here: http://onofri.org/example/ you can say that there is enabled the **Leave a Reply** I am go into the WP administration panel and go into: **Settings ---> Discussion** and here I have disable all the checks box (including **Allow people to post comments on new articles** ) Why I can't disable it? What have I to do? Tnx Andrea


title: Different template of products for specific category. WooCommerce

text: For example i have category coffee machines, and one template for coffee machine single product template, but for category coffee i want to have different single-product.php template, how to implement this? i haven't access to this post http://www.woothemes.com/support-forum/?viewtopic=83667 but it have similar question, with pages and categories in WordPress it simple, but how to do it in woocommerce?


title: User Roles: How to hide a plugin from showing in WP-Admin?

text: I would like to be able to hide a few plugins from showing in the WP-Admin for users who do not have a specific user role as I do not want those users to be able to edit the settings. Do I have to do this on a per-plugin basis?


title: How to use WP_rewrite?

text: I need to add the following rewrite commend to WordPress `.htaccess` file:               RewriteRule ^read/([0-9]+)/?$ /read/?u=$1 [QSA,L]      How to do this by a function? i.e., how to do it by use wp_rewrite in `function.php`?


title: Query a range of pages by menu_order

text:
I'm trying to figure out how to do the following type of query: I want to return up to 12 posts (0 thru 11) by page/menu_order. If there are more than 12 posts, but only 5 pages have an order assigned only return those 5 pages. Initially, I thought I'd start by using WP Query and try to do something with offset, but it's a bit beyond my comprehension.               function wu_t3_topnav() {     global $post;          // WP_Query arguments     $args = array (         'post_parent'       => 0,         'post_type'                 => 'page',         'post_status'              => 'publish',         'posts_per_page'       =>  '12',         'order'                     => 'ASC',         'orderby'                   => 'menu_order',     );          // The Query     $query = new WP_Query( $args );          // The Loop     if ( $query->have_posts() ) {         while ( $query->have_posts() ) {             $query->the_post();                  $menutitle = get_post_meta( $post->ID,     '_cmb_wu_menutitle', true );                  ?>
<a href="<?php echo get_permalink(); ?>">                 <?php                 if ($menutitle != '') {                     echo "$menutitle";                 } elseif ($menutitle = '') {                     // echo "Blank";                 } else { ?>                     <?php echo get_the_title(); ?>                 <?php }                 ?>
              <?php }          } else {         // Do Something     }          // Restore original Post Data     wp_reset_postdata();          }


title: WordPress – site with 2 stylesheets and more…

text: I’m building a site that is broken up into two views (or sections): **College** and **Corporate**.   » See it here When the **College** tab is active, the site will use **college-styles.css** (orange background)   When the **Corporate** tab is active, the site will use **corporate- styles.css** (blue background) Some pages are global (content is the same for `college/corporate`) Some pages are specific (content is different for `college/corporate`) So there will be one navigation set up for college and one for corporate Also, ideally the pages/links will be as follows:   * `/college/why-us`   * `/college/who-are-we`   * `/college/how-we-do-it`   * `/college/our-work`   * `/college/our-blog`   * `/college/connect`   * `/corporate/why-us`   * `/corporate/who-are-we`   * `/corporate/how-we-do-it`   * `/corporate/our-work`   * `/corporate/our-blog`   * `/corporate/connect` What is the best way to handle this? I remember a few years back where it was popular for sites to have two stylesheets (usually a light and dark version) and allow the user to select one. But I need more than just a style switcher, I need to load a whole new page and navigation. Also, ideally there would be a way to not have to create duplicate pages for the ones that are “global”. ### Global pages   * `who-we-are`   * `how-we-do-it`   * `our-blog`   * `connect` ### Specific pages   * `why-us-college`   * `why-us-corporate`   * `our-work-college`   * `our-work-corporate` One way that was suggested was to create a blank college page and a blank corporate page and then make a college version of every page (`why-us- colloge`, `who-we-are-college`, etc.), a corporate version of every page and make them child pages of college/corporate. But I don’t really want a separate blog for both, nor a separate connect page for both. Thoughts, ideas? Any help/input would be greatly appreciated.


title: /wp-admin/post.php shows 404 template on submit

text: When I publish or save a post, I see the 404 error page from my template. This happens with posts and WooCommerce products. I'm using the Twenty Twelve theme, and I have the following plugins activated: WooCommerce, Limit Login Attempts, Google Analyticator. I just installed Wordpress yesterday.


title: Page template is accessing the incorrect posts?

text:
Hi I'm attempting to create my own custom template that will have a format like this:               <?php get_header(); ?>

     <?php get_footer(); ?>      Right now I'm using `<?php the_content(); ?>` and instead of pulling the page content, it's pulling a specific post from my post list. I'm not quite sure why this is happening. UPDATE: The code below was located in a widget that was being processed just before the Wordpress loop took effect in my template. I didn't reset my query using `wp_reset_query();` so Wordpress displayed only a single post.                   <?php query_posts('p=63'); ?>         <?php while (have_posts()) : the_post(); ?>         <?php the_content(); ?>         <?php endwhile;?>


title: How to list users by custom field?

text: I have a custom user field in the standard database, called `company`. I want to output on to a page the usermeta info only of users whose `company` matches `Widgets Inc` ... How do I do that? What I'd really like to be able to do is avoid putting this in a page template and instead create a shortcode to list user info, with functionality to limit by field attribute - ie. `{listusers company="Widgets Inc"}` But I don't know how to do that.


title: add_filter for where statment issue

text: I am trying to get start and end dates for posts filtered, and I found the documentation for the 'posts_where' filter, I am just testing it so far, but when ever I add the filter, it seems to pull in the loop data for the main navigation (i.e. from wp_nav_menu()) I added:               <?php remove_filter('posts_where', 'uc_filter_where'); ?>          <?php wp_nav_menu(array('sort_column' => 'menu_order', 'menu_class' => 'nav', 'theme_location' => 'primary-menu')); ?>      in an attempt to clear out the where filter for the posts, but no such luck. Anyone explain to me what I am doing wrong.


title: How to get Post ID with the Add Filter Function

text: I'm writing a plugin and am trying to figure out how to add data to the end of a post based on some Custom Meta Information. So i've done this so far:               add_filter('the_content', 'AppendMeta');      And here is the "AppendMeta" function               AppendMeta($content) {         echo $content; // Echo out post content         $PersonName = get_post_meta($post->ID, 'PersonName', true);         echo 'Person: ' . $PersonName;     }      That code works if I replace $post->ID with the id of the post, but I need it to work based on the post the user is currently navigating. How would I pass the post id in as a parameter? $post->ID doesn't work in this scenario and I can't find out why.


title: Trying to hide subcategories which have categories without posts

text: On custom archive pages, I want to show subcategories that **_don't_** have their own posts but have sub-subcategories that **_do_** have posts. And if a child category does not have posts, I want to hide its parent too. Here is part of the code I'm using:               if(is_category() && $has_category_children){ //$has_category_children is true if the current category has subcategories.         $args = array(             'hide_empty' => 1,             'hierarchical' => 0,             'parent' => $term->term_id,         );         $categories = get_categories($args);         foreach ($categories as $cat) {              echo $cat->category_nicename;         }     }      What is the right approach to achieving this?


title: PHP Code stuck in Cache [Memcached]

text: Been having a bit of a problem with my site regarding our caching method and my php code not refreshing or flushing. To start, my site is on a dedicated Nginx webserver. I used W3 Total Cache for the initial caching setup. Everything was set up to cache through Memcached.   (I should note, my website is somewhat of a 'guest' on this server, which is bit of a semi-community donation semi-sponsored server that runs some other things. The admins are skilled but also volunteers. I have their full support for fixing things, but they don't have time to troubleshoot my very odd issue (especially because I asked for caching to get turned on for the site myself). If we had some hints on what to go on it would make things easier for us than taking shots in the dark ;) So any suggestions are welcomed.) At some point we noticed that changes to php pages and Wordpress & Plugin updates were not working at all, while the code on the server reflected updates, the pages still processed through the older php code. This presented a couple unique issues. W3 Total Cache stores it settings in php files. Other php files, when deleted, stop working, but when they are restored to the server, memcached still insists on using its ultra-old memcached copy. The W3 Total Cache settings, whether i removed or altered the settings php files, would NOT stop running everything through cached memcached data. The server admin attempt rebooting memcached and then flushing it. Neither of those seemed to have any effect. All the other basic settings seem to be set- up correctly. We can, of course, still add new plugins, all the data that comes from the database works just fine. At least one other site on the server that is not wordpress also uses memcached with no issues. Any help is appreciated, should be able to provide further information if it is needed.


title: Limit wordpress posts loop to continue onto another page

text: Theres a site i did that on the home page, i created kind of like a **news** box type of thing which is what the client wanted... the posts bit im using to limit the posts on the index page is               query_posts('posts_per_page=4');      Now, this limits my posts to "4" or whatever number i want etc, when the user clicks on the "news" page button, it takes them to a page which has the full posts loop without the `query_posts('posts_per_page=4');` which essentially shows them all the posts. Now the problem is that, this person is posting A LOT now and the page now has a bunch of posts one after the other. Is there a way to limit these to any number (that i choose) and show the rest of the posts on another page??? So essentially something that says filter out 20 messages/excerpts for example, BUT after 20 show a "next" page or something like that? is that possible? Because as it stands now, by years end this ONE page will have hundreds of posts. ive looked around but not sure exactly what im looking for. This one came close (here on SO) http://stackoverflow.com/questions/3875895/wordpress-loop- show-limit-posts And although its similar, i need a way to limit the posts on the page AND continue them on another page so that one page doesnt hold ALL the posts. Thanks in advanced.