How do I make a draft post accessible to everyone?

I have several **unpublished** posts in my Wordpress website and I am trying to make it accessible for normal users (who are not logged in) using the normal post slugs (`site.com/post-here`). I understand it may not be the best practice but for my special purpose, this needs to be done. I have tried adding the following code snippet into my `functions.php` file:               function enable_view_drafts() {     $role = get_role( 'subscriber' );      $role->add_cap( 'read_private_posts' );      $role->add_cap( 'edit_posts' );     }     add_action( 'after_setup_theme', 'enable_view_drafts');      I've also tried `init` hook instead of `after_setup_theme`. No luck. My understanding is that changes to roles are saved to the database so only need to be done once. That is why I'm using `after_setup_theme` hook to call the function. But when I try to access the page as a normal user, I'm being shown a 404 page instead of showing the post content. I've also tried loading the preview URL (`site.com/?p=212&preview=true`) but that didn't work either. These are my guesses:   * the normal user doesn't have enough `caps` to read the drafts post.   * testing and viewing draft posts on the front-end is not possible for any users (including administrators). What changes do I have to make in order to accomplish what I'm trying to do? If it's not possible, what alternative solutions do you suggest? **Note:** I'm not looking for plugin-based solutions.


Consequences if using PHP include TEMPLATEPATH?

I have created a **Theme Options page** using Settings API so now I need to style it using CSS. Instead using function like this inside **functions.php**               function mytheme_add_init() {     if ( is_admin() ) {         $get_path=get_bloginfo('template_directory');         wp_enqueue_style("functions", $get_path."/css/admin.css", false, "1.0", "all");              }     }     add_action( 'wp_enqueue_scripts', 'mytheme_add_init' );      I am using `<?php include (TEMPLATEPATH . "/functions/admin_css.php"); ?>` directly inside my file responsible for creating my **Theme Options Page**. Reason for this approach is that I will use some images _(their path will be dynamicly generated using`get_template_directory_uri()` thingy)_ inside my **Options Page**.      So what really want is to add my theme to **WordPress.org repository**. **Question:** Because I am using that approach will I **_suffer consequences_** like being my theme rejected by **WordPress Theme Review Team ?**


URL rewrite custom taxonomy using add_rewrite_rule() or generate_rewrite_rules()

I'm trying to get my head around amending some URL's for a website I have created. After reading two (very informative) answers (1, 2) but I'm still a little unsure how to approach creating a URL that shows a custom post type in the hierachy of it's categories (created by custom taxonomies). From my reading, I gather that `add_rewrite_rule` or `generate_rewrite_rules` seem to be the best options to use, but I cannot seem to get it functional... like... at all! **Here is the URL structure I have currently** :               Base        = http://domain.com/bands     Category    = http://domain.com/band-type/acoustic-duos     Single Post = http://domain.com/bands/duo-1      And **here is what I am looking to achieve** :               Base        = http://domain.com/bands     Category    = http://domain.com/bands/acoustic-duos     Single Post = http://domain.com/bands/acoustic-duos/duo-1      In the scenario above, **`bands` is the custom-post-type**, whilst **`band- type` is the custom-taxonomy** I have created for 'bands'. From using @jan-fabry Rewrite Analyzer plugin, I can see the custom taxonomy pattern is: `band-type/([^/]+)/?$` for the first argument for `add_rewrite_rule()` but I don't know how Wordpress references custom taxonomies in the index.php URL variable, used for the `$redirect` argument (e.g. `index.php?tax=bands`)... so unsurprisingly the following code (placed within `functions.php`) did not work at all:               wp_reset_query();     function sheixt_init()     {     add_rewrite_rule(         'band-type/([^/]+)/?',         'index.php?cat=&band-type=$matches[1]',         'top' );     }     add_filter( 'query_vars', 'sheixt_query_vars' );     function sheixt_query_vars( $query_vars )     {         $query_vars[] = 'band-type';         return $query_vars;     }      I still feel I'm not grasping how this works (at all!) and reading the codex is confusing me further so I'm not sure how to approach using `generate_rewrite_rules()`. Lastly, I'm wondering if I'm fooling foul of a permalink conflict, as I want the custom-taxonomy (band-type) to use the custom-post-type's slug ('bands') as the baseline for the URL. Please can you point me in the right direction, I can provide more information if necessary. Thanks.


how to server over http and https with one installation

is there an easy way to set up a single wordpress intallation to serve its pages both over http and https? I have an http based website, and I have some pages that I would like to make accessible as facebook pages too. But facebook requires https, and I would prefer to stay with https for normal requests. Do you know a way to share the same page over both protocols? I'm running my wordpress on a webfaction account. Akasha


Add category description to list of category with taxonomy image

I'm using the Taxonomy Images plugin. Would like to list categories with their thumbnails AND descriptions. Code below give a list of categories (titles are linked to category archive) and thumbnails. I can't figure out how to add category description.                   $terms = apply_filters( 'taxonomy-images-get-terms', '', array('taxonomy' => 'category') );          if ( ! empty( $terms ) ) {            echo '
';            foreach( (array) $terms as $term ) {           echo '
taxonomy ) ) . '">' . $term->name . '
';           echo '
taxonomy ) ) . '">' . wp_get_attachment_image( $term->image_id, 'thumbnail-small' ) . '
';           echo '

In this issue

[CATEGORY DESCRIPTION SHOULD GO HERE]

';       }            echo '
';          }


Include caption underneath post images

Hello I've been struggling for ages trying to find a solution for this. Basically I just want to retrieve all images from a post and display a caption underneath. Here is the code i'm using:                   <?php     $argsThumb = array(         'order'          => 'DESC',         'post_type'      => 'attachment',         'post_parent'    => $post->ID,         'post_mime_type' => 'image',         'post_status'    => null     );     $attachments = get_posts($argsThumb);     if ($attachments) {         foreach ($attachments as $attachment) {             echo '
ID, 'thumbnail', false, false).'" />

'.apply_filters('the_title', $attachment->post_title).'

';         }     }     ?>      As you can see it currently displays the title, but not the caption. I have tried using: $caption = $attachment->post_excerpt; - but not exactly sure where to implement it and what I have tried doesn't work. Any help would be greatly appreciated!


.current_page_ancestor broken in Twenty Eleven

I would like to have a level 1 menu in a vertical menu and a full menu in a vertical menu in the left sidebar in Twenty Eleven. My problem is that I would like to make the top item bold if the user is in it, or in one of it's child menues. The ideal solution would be to apply a rule for `.current_page_ancestor`. But for my biggest surprise, that rule IS already in the original css file for Twenty Eleven. But it seems to be broken, as nothing happens!               #access .current_page_item > a,     #access .current_page_ancestor > a {         font-weight: bold;     }      Do you know how to fix this? Is there a ticket for this bug already? To have an idea, have a look at this site, I made the selector red to make it visible. What I would like to achieve is that the top menu stays red even if I'm in one of the child menus on the left. sample page


Can I limit this meta box to a particular page?

I am using a version of this (http://www.deluxeblogtips.com/meta-box-script- for-wordpress/) meta box script but I want to be able to limit which edit screen a meta box shows. For example, if I only want a meta box to show in the "contact" page edit screen, is that possible?               $meta_boxes[] = array(     'id' => 'project-box-1',                            // meta box id, unique per meta box     'title' => 'Project Box 1',         // meta box title     'pages' => array('page'),   // post types, accept custom post types as well, default is array('post'); optional     'context' => 'normal',                      // where the meta box appear: normal (default), advanced, side; optional     'priority' => 'high',                       // order of meta box: high (default), low; optional


Sorting custom post types in edit.php : Post disappear

I've got a few custom post types with different taxonomies and I have a function that adds certain categories to post list view in edit.php admin screen. Everything good there. I've also added a function that will allow the user to sort by those categories. This is where things go wrong. When you sort by name or date, everything is fine, but when you sort by the custom categories all the posts disappear and I can't figure out why. Here's the code all the way back through the custom post type registration. The code in question is the very last block, but I figured people may need to see the whole thing in context               // Add custom post type Artists         add_action( 'init', 'create_post_type' );         function create_post_type() {             register_post_type( 'band_artists',                 array(                     'labels' => array(                         'name' => __( 'Artists' ),                         'singular_name' => __( 'Artist' ),                         'add_new' => __( 'Add New','Artist' ),                         'add_new_item' => __( 'Add New Artist' ),                         'edit_item' => __( 'Edit Artist' ),                         'new_item' => __( 'New Artist' ),                         'view_item' => __( 'View Artist' ),                         'search_items' => __( 'Search Artists' ),                         'not_found' => __( 'No Artists Found' ),                         'not_found_in_trash' => __( 'No Artists In Trash' ),                         'parent_item_colon' => ''                     ),                 'public' => true,                 'has_archive' => true,                 'supports' => array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail' ),                 'rewrite' => array('slug' => 'artists'),                 'taxonomies' => array('category', 'post_tag')                 )             );             register_taxonomy('large_feature', array('band_artists'), array('hierarchical' => true, 'label' => 'Large Feature', 'rewrite' => false));             register_taxonomy('small_feature', array('band_artists'), array('hierarchical' => true, 'label' => 'Small Feature', 'rewrite' => false));         }          // Add custom taxonomies to Admin "Post List" Page         add_filter( 'manage_edit-band_artists_columns', 'my_edit_band_artists_columns' ) ;         function my_edit_band_artists_columns( $columns ) {                  $columns = array(                 'cb' => '<input type="checkbox" />',                 'title' => __( 'Artists' ),                 'large_feature' => __( 'Large Feature' ),                 'small_feature' => __( 'Small Feature' ),                 'date' => __( 'Date' )             );             return $columns;         }          // Make those columns display data         add_action( 'manage_band_artists_posts_custom_column', 'my_manage_band_artists_columns', 10, 2 );         function my_manage_band_artists_columns( $column, $post_id ) {             global $post;             switch( $column ) {                 case 'large_feature' :                     $terms = get_the_terms( $post_id, 'large_feature' );                     if ( !empty( $terms ) ) {                         $out = array();                         foreach ( $terms as $term ) {                             $out[] = sprintf( '%s',                                 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'large_feature' => $term->slug ), 'edit.php' ) ),                                 esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'large_feature', 'display' ) )                             );                         }                         echo join( ', ', $out ); }                     else { _e( '' ); }                 break;                 case 'small_feature' :                     $terms = get_the_terms( $post_id, 'small_feature' );                     if ( !empty( $terms ) ) {                         $out = array();                         foreach ( $terms as $term ) {                             $out[] = sprintf( '%s',                                 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'small_feature' => $term->slug ), 'edit.php' ) ),                                 esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'small_feature', 'display' ) )                             );                         }                         echo join( ', ', $out ); }                     else { _e( '' ); }                 break;                 default :              break;              }         }          // Make those columns sortable         add_filter( 'manage_edit-band_artists_sortable_columns', 'my_band_artists_sortable_columns' );         function my_band_artists_sortable_columns( $columns ) {             $columns['large_feature'] = 'large_feature';             return $columns;         }         add_action( 'load-edit.php', 'my_edit_band_artists_load' );         function my_edit_band_artists_load() {             add_filter( 'request', 'my_sort_band_artistss' );         }         function my_sort_band_artistss( $vars ) {             if ( isset( $vars['post_type'] ) && 'band_artists' == $vars['post_type'] ) {                 if ( isset( $vars['orderby'] ) && 'large_feature' == $vars['orderby'] ) {                     $vars = array_merge(                         $vars,                         array(                             'meta_key' => 'large_feature',                             'orderby' => 'meta_value'                         )                     );                 }             }                  return $vars;         }


Image format not using single-image.php

I am trying to isolate a particular post format for images, and reading the Codex, I thought it would be possible to create a new template file single- image.php. However, that file is not being used. Instead, I've got a file called content-image.php instead. I've refreshed permalinks, still no joy. Here's register_post_type():               function register_post_type( $post_type, $args = array() ) {     global $wp_post_types, $wp_rewrite, $wp;          if ( !is_array($wp_post_types) )         $wp_post_types = array();          // Args prefixed with an underscore are reserved for internal use.     $defaults = array(         'labels' => array(), 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null,         'capability_type' => 'post', 'capabilities' => array(), 'map_meta_cap' => null,         '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false,         'public' => false, 'rewrite' => true, 'has_archive' => false, 'query_var' => true,         'supports' => array(), 'register_meta_box_cb' => null,         'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null,         'can_export' => true,         'show_in_nav_menus' => null, 'show_in_menu' => null, 'show_in_admin_bar' => null,         'delete_with_user' => null,     );     $args = wp_parse_args($args, $defaults);     $args = (object) $args;          $post_type = sanitize_key($post_type);     $args->name = $post_type;          if ( strlen( $post_type ) > 20 )             return new WP_Error( 'post_type_too_long', __( 'Post types cannot exceed 20 characters in length' ) );          // If not set, default to the setting for public.     if ( null === $args->publicly_queryable )         $args->publicly_queryable = $args->public;          // If not set, default to the setting for public.     if ( null === $args->show_ui )         $args->show_ui = $args->public;          // If not set, default to the setting for show_ui.     if ( null === $args->show_in_menu || ! $args->show_ui )         $args->show_in_menu = $args->show_ui;          // If not set, default to the whether the full UI is shown.     if ( null === $args->show_in_admin_bar )         $args->show_in_admin_bar = true === $args->show_in_menu;          // Whether to show this type in nav-menus.php. Defaults to the setting for public.     if ( null === $args->show_in_nav_menus )         $args->show_in_nav_menus = $args->public;          // If not set, default to true if not public, false if public.     if ( null === $args->exclude_from_search )         $args->exclude_from_search = !$args->public;          // Back compat with quirky handling in version 3.0. #14122     if ( empty( $args->capabilities ) && null === $args->map_meta_cap && in_array( $args->capability_type, array( 'post', 'page' ) ) )         $args->map_meta_cap = true;          if ( null === $args->map_meta_cap )         $args->map_meta_cap = false;          $args->cap = get_post_type_capabilities( $args );     unset($args->capabilities);          if ( is_array( $args->capability_type ) )         $args->capability_type = $args->capability_type[0];          if ( ! empty($args->supports) ) {         add_post_type_support($post_type, $args->supports);         unset($args->supports);     } elseif ( false !== $args->supports ) {         // Add default features         add_post_type_support($post_type, array('title', 'editor'));     }          if ( false !== $args->query_var && !empty($wp) ) {         if ( true === $args->query_var )             $args->query_var = $post_type;         else             $args->query_var = sanitize_title_with_dashes($args->query_var);         $wp->add_query_var($args->query_var);     }          if ( false !== $args->rewrite && ( is_admin() || '' != get_option('permalink_structure') ) ) {         if ( ! is_array( $args->rewrite ) )             $args->rewrite = array();         if ( empty( $args->rewrite['slug'] ) )             $args->rewrite['slug'] = $post_type;         if ( ! isset( $args->rewrite['with_front'] ) )             $args->rewrite['with_front'] = true;         if ( ! isset( $args->rewrite['pages'] ) )             $args->rewrite['pages'] = true;         if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive )             $args->rewrite['feeds'] = (bool) $args->has_archive;         if ( ! isset( $args->rewrite['ep_mask'] ) ) {             if ( isset( $args->permalink_epmask ) )                 $args->rewrite['ep_mask'] = $args->permalink_epmask;             else                 $args->rewrite['ep_mask'] = EP_PERMALINK;         }              if ( $args->hierarchical )             add_rewrite_tag("%$post_type%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");         else             add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");              if ( $args->has_archive ) {             $archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;             if ( $args->rewrite['with_front'] )                 $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;             else                 $archive_slug = $wp_rewrite->root . $archive_slug;                  add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' );             if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) {                 $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';                 add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );                 add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );             }             if ( $args->rewrite['pages'] )                 add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' );         }              add_permastruct( $post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite );     }          if ( $args->register_meta_box_cb )         add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1);          $args->labels = get_post_type_labels( $args );     $args->label = $args->labels->name;          $wp_post_types[$post_type] = $args;          add_action( 'future_' . $post_type, '_future_post_hook', 5, 2 );          foreach ( $args->taxonomies as $taxonomy ) {         register_taxonomy_for_object_type( $taxonomy, $post_type );     }          do_action( 'registered_post_type', $post_type, $args );          return $args;      }


is_post_type_archive not working in feed

I'm trying to alter a feed for my plugin's custom post type to add lines for podcasting. Here is the code I've got right now:               add_action ('init', 'my_plugin_init');          function my_plugin_init() {         if ( is_post_type_archive('my_plugin_custom_type') ) {             add_action('rss2_ns', 'my_plugin_podcast_ns');         }     }          function my_plugin_podcast_ns() {         echo 'xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"';     }      The archive for this post type is located at `http://example.com/custom_type/`, and I'm getting the feed at `http://example.com/custom_type/feed/`. However, my extra line is not showing up. What am I doing wrong?


Remove full size image in wordpress

I am using wordpress 3.5 and everuthing is good except that each time one image uploaded, it will created many unnecessary image sizes. I confirmed my theme and found that it does not use the full size image and i think it's kind of cost my host too much with all image sizes saved. Would you please let me know how can solve this issue .Actually i am searching for solutions to resolve below two things   1. Do not upload full size image at Media   2. Remove existing full size images I found http://sumtips.com/2011/12/custom-image-sizes-in-wordpress.html link which guide how to disable unnecessary image but it does not remove the full size image Thank you very much in advanced for any advice.


ACF Image Object Sizes Issue on Multisite

I am using Advanced Custom Fields and have added an image with the return value being an image object. In my theme I if I dump the values of the object all the URL's for sizes are the same regardless if it is `thumbnail`, `medium`, or `large`. I am doing this on a multisite. Here is what the image object looks like:               (     [id] => 123     [alt] =>      [title] => My image     [caption] =>      [description] =>      [mime_type] => image/jpeg     [url] => http://example.com/files/2013/12/my_image.jpg     [width] => 5400     [height] => 3600     [sizes] => Array         (             [thumbnail] => http://example.com/files/2013/12/my_image.jpg             [thumbnail-width] => 150             [thumbnail-height] => 100             [medium] => http://example.com/files/2013/12/my_image.jpg             [medium-width] => 300             [medium-height] => 200             [large] => http://example.com/files/2013/12/my_image.jpg             [large-width] => 1024             [large-height] => 682         )     )


Custom Post Type Dynamically Updates other Custom Post Type

I have two custom post types, one is products, the other is vendors. The vendors CPT has things like name, address, and which products are sold there. The products CPT has the product name, description of the product and which vendors carry each product. Is there a way to have each CPT update the other? So say, if I put that this vendor sells this product it will automatically update the product to say that it is sold by that vendor?


A way to automatically install pages on theme install?

I'm trying to build a theme which would require specific pages to be included. Is there a way to automatically create pages and assign them to their page templates when a theme is installed?


wp.getUsers XML-RPC method is returning only 50 users, how can i get all the users

In my iphone app i am trying to list out all the users using the **wp.getUsers XML-RPC method** , but its not returning all the users, in that blog i have around 180 members , but it has returned only **50 users** in the list,,how can i get all the users ?? i am passing these following 3 parameters **blog_id** , **username** and **password** ,,should i pass **any other parameter** to get all the users in the list?? plas help me out thanx in advance


Returning all radio button options when using Advanced Custom Fields

When using the Advanced Custom Fields plugin for Wordpress, Suppose I have a radio button field with possible choices: o Apples o Bananas o Cranberries How can I return each one of these options regardless of which one is selected? Thanks everyone


Thumbnails generated by "add_image_size" are not removed when removing media

I've noticed that images which are generated by "add_image_size" wont be deleted whenever i delete the media item. So after removing all media items in the media manager i have a upload folder full of thumbnail images. Anyone else experiencing this?


How do I represent 'chunks' of content within Wordpress?

I've only ever used wordpress as a self-hosted blogging platform - until now. I have a requirement to use it for a very basic CMS which will consist of ~ 10 pages, most of which will be static content, updated periodically. I'm going to need to ability to upload documents, embed images, edit copy using the text editor - pretty much all of the standard features wordpress offers. However, I'm having difficulty surrounding the issue of editing specific sections within a page - in particular, just knowing where to begin. A 'normal' CMS would traditionally break a page into separate sections and allow me to edit any of those sections, either by directly editing the content, or by including shared content in that spot. I cannot find out how to do this using wordpress. Is it possible to 'stretch' the Page model so that a Page is actually just a chunk of content, it gets included by a specific page/template, and it's - somehow - protected from being viewed directly (removing it from navigation menus being a start). Any pointers on where to begin? ## Update To clarify, imagine a standard wordpress blog post. Pretend it's a static piece of content. Suppose you wanted an editor to be able to change _just_ the first paragraph of that blog post. Now,   * should the static content on that page be in a Post, Page, Template, or something else?   * should the editable content be a Page, ... or something else? For example:
About us

Example.com is a company specialising in examples, demonstrations,     and canonical stuff.
      If I want that paragraph to be editable, presumably I need something like:
About us

<?php insert_page('name-of-content-chunk'); ?>
      ## Update 2 OK, after a lot of research, trial, and error, I've included the following:   1. Wordpress is _not_ set up to _easily_ replicate a classic CMS, particularly with regard to having several pieces of content on one page.   2. This model _can_ be imitated, more or less, using custom posts (see below)   3. Pages very nearly offer the ability to do this, however:      * A plugin is required just to include a page     * Pages don't seem to be as flexible as posts - e.g. no custom page types The method I've used, using custom post types, is broadly as follows:   1. The page is a 'Page' with a custom template - call it 'mypage.php'   2. That template contains the following:
       <?php         query_posts(array('name' => 'foo', 'post_type' => 'header-text'));         get_template_part('header-text');       ?>

Some static copy in the template that can       only be changed by the site administrator.
            <?php         query_posts(array('name' => 'bar', 'post_type' => 'image'));         get_template_part('image');       ?>
      Does that make sense to **anyone** out there? :-)


custom taxonomy archive permalink shows 404 error

In my plugin I have a custom post type with a slug of 'ready-to-wear' and I have a custom taxonomy called 'seasons' associated with it. The odd thing is that this url with query works: `http://dev.catwalkyourself.com/ready-to-wear/?seasons=autumn- winter-2012-2013-en` but the same one with custom permalink doesn't: `http://dev.catwalkyourself.com/ready-to-wear/seasons/autumn- winter-2012-2013-en` It throws a 404 error. You can try pasting the links yourself. Here is my relevant plugin code: Here is where the custom post type is registered $post_types = array();                   $post_types['rtw'] =  $args = array(             'labels' => array(                 'name' => __('RTW Collections'),                 'singular_name' => __('Ready to Wear Collection'),                 'add_new' => __('Add new RTW collection'),                 'add_new_item' => __('Add a new show to the RTW collection'),                 'edit_item' => __('Edit Collection'),                 'view_item' => __('View Collection'),                 'search_items' => __('Search Ready to Wear Collections'),                 'not_found' => __('No RTW Collections found'),                 'not_found_in_trash' => __('No RTW Collections found in trash')             ),             'query_var' => 'rtw_collections',             'supports' => array('title', 'editor', 'thumbnail', 'author', 'comments'),             'has_archive' => true,             'publicly_queryable' => true,             'show_ui' => true,             'taxonomies' => array('seasons','city'),             'rewrite' => array(                 'slug' => 'ready-to-wear',                 'with_front' => false             ),             'public' => true,             'menu_position' => 6         );      Here is where the taxonomy is configured: $taxonomies = array();                   $taxonomies['seasons'] = array(             'query_var' => 'seasons',             'rewrite' => array(                 'slug' => 'seasons',                 'with_front' => false             ),             'single_value' => true,             'required' => true,             'labels' => array(                 'name' => __('Seasons'),                 'singular_name' => __('Season'),                 'edit_item' => __('Edit Season'),                 'update_item' => __('Update Season'),                 'add_or_remove_items' => __('Add or remove seasons'),                 'new_item_name' => __('Add new Season'),                 'all_items' => __('All Seasons'),                 'search_items' => __('Search Seasons'),                 'popular_items' => __('Popular Seasons'),                 'separate_items_with_commas' => __('Separate Items with commas'),                 'choose_from_most_used' => __('Choose from most used Seasons')             )         );      and here is the call to `register_taxonomy`:               foreach ($taxonomies as $taxonomy => $arr) {                 register_taxonomy($taxonomy, null, $arr);             }      I have tried:   * Flushing the permalinks repeatedly   * Setting 'with_front' true and false repeatedly   * add flush_rewrite action to my functions.php Unfortunately, none of these work. Please help me out.


Application / Admission Form plugin

I'm looking for a plugin that would allow tracking of an application similar to the admission forms used for colleges. Ideally, a student would be able to fill out the application and submit it (and pay, if there's a application fee) and the student could check back periodically on the status of application, i.e. Received, Under Review, Accepted / Rejected, etc. On the Admin side of things, the applications would show up and would allow the admin to review, make notes, etc and mark the application with a new status. Has any one seen or heard of a plugin to do something like this?


Feed links not working even with add_theme_support('automatic-feed-links')

My feed links don't work, even after I add this code to functions.php:                         add_theme_support('automatic-feed-links');      When I try go to mysite.com/feed or mysite.com/?feed=rss or any of the links specified in the Codex, I don't get a feed with my content. In Safari, I get this: > Safari could not update this feed because the source file is no longer > available. In Chrome I get this:                <channel>        <title>My Site Name » Page not found</title>          <atom:link href="http://mysite.com/feed/" rel="self" type="application/rss+xml"/>      etc. My site used to have a feed through Feedburner, but I wanted to switch to built-in Wordpress feeds. It's very possible I'm misunderstanding something basic fact about how feeds work. What am I doing wrong?


How do I remove WordPress Custom Menus hover event and replace it with jQuery onclick?

I am using the WordPress (Appearance > Menus) feature to create a custom navigation menu. I created a menu item that has a dropdown and would like to activate the dropdown menu with a click rather than mouse hover. How would I go about doing this? I'm familiar wit jQuery, I just don't know how to remove the current hover state.


Changing admin user id for database

Is it correct or ok to change default admin user id from 1 to any other number as done by better-wp-security plugin for wordpress for better security? what is best way for admin security. Thanks


Post per page not working if no category specified

I'm going crazy...               <?php query_posts(array('cat' => 3, 'posts_per_page' => 1)); ?>      This shows 1 post (there is two in the category) >> OK               <?php query_posts(array('posts_per_page' => 1)); ?>      This shows 4 posts (there is four in the whole database) >> WTF? :P This is crazy... or am I ? Note: I only have one loop (this one), in this template.


Resources for a complete beginner to learn to work professionally with Wordpress

I have a friend who is interested in starting a side business where she would freelance websites. I have recommended for her Wordpress as probably the best choice where she could most quickly start making useful, customized websites for clients. While I have done a decent amount with Wordpress I am not really plugged into that community so I don't know what the go-to learning tools are. From personal experience I know that reading the wrong thing can be worse than reading nothing at all and I simply don't know what the community-accepted recommendations are. What websites/screencasts/books are the must-haves for a complete novice who is trying to get started with the platform? I would like to point out that she is not so interested in using it as a blogging platform so much as a simple CMS and site-builder that will allow her to build custom websites so the question is more: what are the best resources for a complete programming novice to learn Wordpress theme development? PS, if you feel like Wordpress is not appropriate for this either please let me know and I'll change my recommendation.


Add user capability and check against it

I just realized the following:               // Call the current user info     global $current_user;          // Add a capability     // and set the 2nd argument ($grant) to false     $current_user->add_cap( 'some_cap', false );       Now I've successfully added a capability to the user, but denied her/him the access to this capability. If I now check with `$current_user->has_cap( 'some_cap' );` I'd get a `true` in return. The same goes for `current_user_can( 'some_cap' );` as this is only a wrapper for the has_cap functions arguments. **Q:** Where is the 2nd argument used? Did I get something wrong?


List Category Posts V0.21 upgrade breaks site

I just upgraded the List Category Posts plugin from 0.18.3 to 0.21 and my website has failed. I've determined that the difference causing the failure is that the previous version passes a string parameter to get_posts() while the new version sends the arguments as an array. The problem is that the default value for post_parent=0 does not seem to have an effect when passed as a string (e.g. "?cat=55&post_parent=0") but it is being applied when the parameter is being passed as an array (e.g. array( 'cat'=>'55', 'post_parent'='0') ). My posts are post_type='post', for which post_parent should not be applicable. Many of my posts have a post_parent value which is not zero. They were previously batch converted from pages and it appears that the conversion has left the post_parent value with the id of the previous parent page. As a result of this, all those posts which were previously converted from pages with a parent have disappeared from my category lists. Can anyone explain why the parameter is being applied as an array and not as a string. Why is the default value for post_parent 0 fro the plugin, while it is empty for get_posts()?


Add action hook conditionally - only when home.php in use

I am trying to add action hook in functions.php only if the page is `home.php` but the following does not work               if ( is_page_template("home.php") ) {          // do stuff          }      To make sure that file being used is `home.php` I do this               global $template; echo $template;


How may I filter get_users() similarly to pre_get_posts?

I have filtered posts, pages and custom_post_types based on $current_user custom usermeta field values using pre_get_posts(). Is there a similar method/function to alter get_users() based on $current_user custom field values? I've searched quite a bit but came up empty handed. For example, let's assume I want to filter the results of get_users() for an editor with the "town" custom meta of "Paris" to only return the list of users with the same value in "town" field. Similarly, an editor with "Rome" in "town" should get only users from "Rome", and so on... Ideally, I'd like this parameter to append itself to all get_users() done by the website's functions in both back and front end as long as the user is logged in. Is this possible in WordPress? Thank you.


Is this the proper usage of creating / using a transient?

I'm new to using transients. Is this the proper format to create a transient and have it pull from the DB instead of using the http api? I have standardized my snippet so others can double check their code as well...               function google_transient() {              $url = 'http://www.google.com';         $the_whole_body = wp_remote_retrieve_body( wp_remote_get($url) );              $transient_name = 'google';              // Get any existing copy of our transient data         if ( false === ( $transient_name = get_transient( $transient_name ) ) ) {                  // It wasn't there, so regenerate the data and save the transient              set_transient( $transient_name, $url, 60*24); // 24 hour cache                   }              return $the_whole_body;     }


Search URL parameters query

> **Possible Duplicate:**   >  Custom search form with empty parameters Hopefully this is a quick one, but I've hit a wall here. I have multiple search terms, keyword, category, country and date. I've set it up so that the user doesn't have to search all of these filters. I can leave off category and/or date and it will show looser results. But if I leave off country it shows no results, doing the same to any other parameter still shows results. The problem lies with country only. `/?s=a&cat=41&country=&monthnum=&year=` produces no results but `/?s=a&cat=41&monthnum=&year=` does. Why is this? Surely these are the same thing? This is my wp_query, simply pulls posts, I had the foreach to clear this issue before but currently if I remove it. The search works no differently.               $args = array('post_type' => 'post')     // This foreach doesn't actually need to be here ?     foreach(array('s', 'cat', 'country', 'monthnum', 'year') as $key) {         if(isset($_GET[$key]) && trim($_GET[$key]) !== '') {             $args[$key] = $_GET[$key];         }     }


How can I make wp_list_categories output li with category-slug as class, for its children?

Simply put, I'd like to change the `wp_list_categories` output from this:
Articles

Design
      to this instead:
Articles

Design
      So I tried Google and I've found a solution mentioned on this question add filter to wp_list_categories and query if used to list tax-terms? . I need to put this on my `functions.php`:                add_filter('wp_list_categories', 'add_slug_css_list_categories');           function add_slug_css_list_categories($list) {               $cats = get_categories();               foreach($cats as $cat) {              $find = 'cat-item-' . $cat->term_id . '"';              $replace = 'category-' . $cat->slug . '"';              $list = str_replace( $find, $replace, $list );              $find = 'cat-item-' . $cat->term_id . ' ';              $replace = 'category-' . $cat->slug . ' ';              $list = str_replace( $find, $replace, $list );*/          }               return $list;      }      **EDIT:** Now I realize the problem! The filter above works for parent categories. However it doesn't work for the children! So, using that code, if I use `wp_list_categories`, it will output as this:
Articles

Tips

Tutorials

Design
      Notice that even if the parents' class are `category-articles`, the children class stays as `cat-item-10`. Is there any fix to this?


Pagination in category

**Updated:** **I have 50 categories and i wants to show each 5 category on one page and next 5 on next page and next 5 on next page. and so on. with pagination.** I have 50 categories in a WordPress site. I wants to show five categories on every page with pagination with 10 post. I have tried but pagination is not creating.               <?php          // get all the categories from the database         $cats = get_categories();         // loop through the categries         foreach ($cats as $cat) {         // setup the cateogory ID         $cat_id= $cat->term_id;         // Make a header for the cateogry         ?>

<?php echo '
'.$cat->name.'
'; ?>

                     <?php                     // create a custom wordpress query                     query_posts("cat=$cat_id");                     $count = 1;                          if (have_posts()) : while (have_posts()) : the_post(); ?>                              <div class="post-wrap<?php if ($count%3 == 0) { ?> right<?php } ?>">                                  <div <?php post_class(); ?> id="post-main-<?php the_ID(); ?>">

<a href="<?php the_permalink() ?>" rel="<?php _e("bookmark", "solostream"); ?>" title="<?php _e("Permanent Link to", "solostream"); ?> <?php the_title(); ?>"><?php the_title(); ?>

                             <?php include (TEMPLATEPATH . "/postinfo.php"); ?>

                 <?php if ( $count%3 == 0 ) { ?>

     <?php } ?>                              <?php $count = $count + 1 ?>                     <?php endwhile; endif;                     // done our wordpress loop. Will start again for each category ?>

     <?php } // done the foreach statement ?>


Possible to change the slug of default post type?

I have custom post types on my wordpress site and I've set the slugs to say "/blog/{post_type}/{post_title}". I'm using the default post type as a "notes" section, so I want that slug to be "/blog/notes/{post_title}". Is this possible?


Sign in with social media accounts without creating a WP account

I'd like users to sing in with their social media accounts (facebook, twitter, linkedin, google+) without creating a WP account. This is for them to be able to leave comments on a website. Is this possible and what's the best approach for this?


Export WordPress Posts and Meta Information in CSV format

I need to export all WordPress Posts and related Meta information using an SQL query. I've managed to export just the Posts but realised that the Meta information is in another table. Could someone please tell me how I would go about doing this please? Thanks! **EDIT: The final outcome of the CSV file should look something like this.** [POSTS TABLE] post_content | post_title | post_excerpt | Author (meta_key) | [META TABLE] AuthorName (meta_value) | Publisher (meta_key) | PublisherName (meta_value) | BookCondition (meta_key) | BookCondition (meta_value) So one post per row with the meta information in one row but in the same column.


how to keep currently selected menu item while selecting another menu item in second menu

In wordpress 3.9.1 I'm trying to create my own theme. One of the things my theme should be able to deliver is to have two menu's. I do have that. It is working. So no worries there. One of the menu's is the "main" menu and when selecting an item in this menu it is styled as the so named "current-menu-item". Some of the selections show a second menu at the top of the window. If I select an item in this second menu a new page is rendered and the menu item in the main menu is no longer selected. And there is where it does not work as I want. If one of the items is selected in the top menu I still want the item in the main menu be styled as the current menu item. So my users still know in which main menu item they are. Is there someone who can point me in the right direction on how to solve this issue? Why I did not include any code? Because I want to grasp the idea of how to solve it and then try to build it myself. I don't want a cut-n-paste solution as I think it will not teach me that much.


False URL for shopping cart

OK. Re wording my question   1. I have a digital product on a wordpress site   2. Using a shopping cart I'm charging .99 cents for people to look at a video (going to charity)   3. The cart directs them to a page on the site for them to view the video   4. It's in the form of an email link which is encrypted (Good)   5. It loads the page BUT then show the real URL in the address bar (bad)   6. This means that someone can view it and copy the URL and email it to anyone and nothing goes to charity, (bad) So, I need a way of showing the page with the embedded video in it but not showing the correct URL so that someone could copy & paste it and view it. It need to be unobtainable, false, random as the displayed URL but linkable from the cart. For example the page may be www.abc.com/page but it display something like www.abc.com/785df76wd9 and if copied and pasted into a browser it wouldn't exist.


Dashboard Disappears after Upgrade

Following a recent upgrade to WP and MySQL one site that has a custom built plugin throws a Fatal error: > Fatal error: Cannot re-assign auto-global variable _REQUEST in > /home/mysitexyz/public_html/wp- > content/plugins/employment_application/employment_application.php on line > 549 Here is the offending code:               function getApplications($_REQUEST) {         global $wpdb;         $sql = "SELECT * FROM employment_applications";         if($_REQUEST['s'] != '') {              }         $sql .= " WHERE applicant_name LIKE '%" . $_REQUEST['s']  . "%'";     //echo "SQL: $sql
";          $applications = $wpdb->get_results($sql);         $wpdb->show_errors();         //$errors = $wpdb->print_error();         $error = $wpdb->last_error;              if($error != '') {             echo '
' . $error . '
';         }         //print_r($applications);         return $applications;     }      I know that this forum does not support Plugins, and since I am not the original developer and have only inherited the problem, I would like to address the other problem: When I remove the above mentioned plugin by changing the name of the folder the site comes back up but only the sidebar navigation of the Dashboard shows. The rest of it is blank. ![enter image description here](http://i.stack.imgur.com/zWHJ2.png) Is there a way to disable plugins without removing them from the Plugins folder? Is there a better way to troubleshoot the root cause of the empty dashboard? Thanks!


Rewrite and replace url wp-admin/edit.php and wp-admin/post-new.php

everybody I want to rewrite and replace all url **mydomain.com/wp-admin/edit.php -> mydomain.com/wp-admin/edit/** and **mydomain.com/wp-admin/post-new.php -> mydomain.com/wp-admin/addnewpost/** How i can do it or suggest ? Thank you very much.


Force WordPress to NOT display the manual excerpt

I'm forced to use manual excerpts on a number of my posts to integrate them with a shortcode plugin. However, this is interfering with how they're being displayed on an archive page (using a page template). Is there a way to force WordPress to display an automated excerpt (ie, the first 80 words) on one page template only?


Is it possible to create a conditional for content_width?

Searching here I've found two questions related and at the time, this wasn't possible. how to create a conditional content_width for a wordpress theme? And an alternative way via CSS described by Philip Arthur Moore (the code is also on Codex): What is the role and history of the $content_width global variable? Since the questions mentioned are a little old, my question is if the versions released after mid 2013 have improved the function so we could use it with conditionals.


URL Rewrite for CPT single posts

I'm struggling with Wordpress' rewrite function I have the following URL structure               http://example.com/album/test-7/      'album' is the slug for the CPT single page 'test-7' is the slug for the CPT post I'm trying to create a rewrite to allow a URL like               http://example.com/album/test-7/page/2      I'm using `paginate_links()` to create these links but when you visit a link with the desired structure the URL reverts to               http://example.com/album/test-7/      I've tried adding a URL tag and rewrite, but I'm very bad with both of these, here's what I have:               add_rewrite_tag('%paged%','([^&]+)');          add_rewrite_rule('^album/([a-z])/([0-9]{1,})?','index.php?p=$matches[1]&page=$matches[2]','top');      I'm not sure if I'm way off or close to getting it, but this would help clear up rewrite situations involving CPT ID's and pagination variables.


Uploading Images to Multi-Site Causes Failure to HTTP Error

Just to fill you in on my situation. Running WordPress multi-site version: 3.5.2 clean install. Zero 3rd party plugins. All of my plugins have been disabled for debugging. Using WordPress MU Domain Mapping for multiple different TLDs in the network. I have also spoofed all network URLs to serve file from my local server, rather than the existing live network. Hosts file: `vi /etc/hosts/` **Might contain something like:**               127.0.0.1 domain-a.com     127.0.0.1 www.domain-a.com     127.0.0.1 domain-b.com     127.0.0.1 www.domain-b.com      for each site in the network .... etc. I did that, so that I do not have to change site URLs and what have you. * * * Everything on each network site works as intended. The only issue is uploading media attachments. For whatever reason, they are not uploading properly. User is full-blown administrator user role, so it cannot be permission related. I am currently running _Ubuntu 12.04 with PHP 5.4.6 (FAST-CGI)_. When uploading an image, I get some very generic error from WordPress. ![Error 40 Year Old … to Life.jpg HTTP error.](http://i.stack.imgur.com/XHWev.png) `Error 40 Year Old … to Life.jpg HTTP error.` After switching the PHP from `FAST-CGI` to `MOD-PHP` I received a bit more specific of a response from WordPress. ![Error 40 Year Old … to Life.jpg The uploaded file could not be moved to wp- content/uploads/sites/3/2013/07.](http://i.stack.imgur.com/jjzk4.png) `Error 40 Year Old … to Life.jpg The uploaded file could not be moved to wp- content/uploads/sites/3/2013/07.` I have checked out the directory: `./wp-content/uploads/sites/3/2013/` and there is no `/07/` created automatically. So I have tried manually creating it and uploading again from both `FAST-CGI` and `MOD-PHP`, still the same errors follow. I have looked at something like: `./wp-admin/network/site-settings.php?id=3` in the network admin dashboard, searching for media related options.               Uploads Use Yearmonth Folders => true     Upload Path => '' //blank     Upload Url Path => '' //blank      I have checked the live multi-site network along with other multi-site installs and they seem to have the same settings. I then began to think it might be .htaccess related. When I go to `Network Admin -> Settings -> Network Setup` It tells me to use:               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # add a trailing slash to /wp-admin     RewriteRule ^wp-admin$ wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^(wp-(content|admin|includes).*) $1 [L]     RewriteRule ^(.*\.php)$ $1 [L]     RewriteRule . index.php [L]      Which is what I have been using, other than the slight modification at the beginning (Immediately following `RewriteEngine On`) allowing non-www URLs to redirect to www URLs. **Example:**               # DOMAIN-A Redirect non-www urls to www     RewriteCond %{HTTP_HOST} ^domain-a.com     RewriteRule ^(.*)$ http://www.domain-a.com/$1 [R=301,L]          # DOMAIN-B Redirect non-www urls to www     RewriteCond %{HTTP_HOST} ^domain-b.com     RewriteRule ^(.*)$ http://www.domain-b.com/$1 [R=301,L]      However, those rules are not the same as the WordPress Codex explains. I have tried the recommendations as per the WordPress Codex, still with no luck on image uploads within my WordPress Multi-Site Network. I currently have `SUBDOMAIN_INSTALL` set to true, using the appropriate rewrite rules as per the WordPress Codex. I have also tried setting `SUBDOMAIN_INSTALL` to false, again ... using the appropriate rewrite rules. Neither have corrected the issue. Live network (Version: 3.5.2) install has also stopped allowing image uploads. I am not experienced enough with multi-site to know what might be causing this issue. I will continue investigating this unless someone else may have an idea how to fix this issue, please share your acquired knowledge! Please note that it is 100% not a memory issue. It won't even upload a 1kb image file. I have tried all of the possible solutions as mentioned in How to Fix HTTP Error When Uploading Images? and still no luck getting this working. Using `Dashboard -> Media -> Add New -> browser uploader` instead of the multi-file uploader, results in and Internal Server error. For what ever reason, I am able to consistently upload this one random particular image over and over without ANY problems but any other image I try uploading fails... even 1kb sized images. ![media uploader success](http://i.stack.imgur.com/Z3NhL.png) I'm able to upload some images and not others. Some image uploads throw internal server errors and some don't. Some could be 1kb and some could be 5mb. Absolutely puzzling.


Get WP Install Directory

I have a theme which - I was quite proud of myself! - I designed to be installed in wp sites where wp is on root level. Then half my users installed the theme on a mysite.com* _/wordpress/_ * ! ...and it no work... So some path conversion are in order. I created a number of constants so I didn't always have to rewrite paths. Example:               //http constants     $symbiostock_template_directory = get_bloginfo('template_directory');               define('symbiostock_CLASSDIR', $symbiostock_template_directory . '/inc/classes' );      ...and more constants like this for various paths               //filepath constants      $symbiostock_theme_root = get_theme_root() . '/symbiostock';     define('symbiostock_STOCKDIR', $_SERVER['DOCUMENT_ROOT'] . '/symbiostock_rf/' );      ...and more constants like this for various paths define('symbiostock_STOCKDIR', $_SERVER['DOCUMENT_ROOT'] . '/symbiostock_rf/' ); These should work, right? Is there a nice universal way to get wordpress operating from any level? A "best practice" tutorial out tehre?


Automatically generate custom post title based on meta

I'm working with custom post types to create a custom "product review" type. I'm customizing the UI to have fields for the "Reviewer", "Product", and their "Review". This doesn't really require a post title though, so I've removed that field. This is all working fine, but when I go to look at all Product Reveiws, the titles are completely unhelpful (Auto Draft, Auto Draft 2, etc.). What I want to do is automatically set the post title to be a combination of the Reviewer's name and the product they reviewed; something along the lines of "John Smith, Car Radio". I have a function that hooks into the save_post action, and updates the custom meta fields I have set. I figure I need to add something here to accomplish what I'm trying to do, but I'm not sure what function or process this requires. Thanks in advance!


Display one category and its suncategories

I am using this code to filter posts. How can I modify to display only one category and its subcategories. Not all categories.               <form action="<?php bloginfo('url'); ?>/" method="get">     <?php     $select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0');     $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);     echo $select;     ?>
<input type="submit" value="View" />
     </form>


How do I remove RSS feeds from themes?

How do I remove RSS feeds from being listed in the HTML source? Like I want to remove the following:               <link rel="alternate" type="application/rss+xml" href="foo.com">      I don't want to remove the RSS feeds by any means, just the automatic output in the theme.


Displaying a message upon user registration

I have a question that I hope will be pretty simple for some of the WordPress Gurus out there. I have a WordPress network and whenever a users signs up, I would like to show (on signup confirmation page) a message that shows the code:               <script type="text/javascript" src="http://mysite.com/js/redirection-mobile.js"></script>          <script type="text/javascript">          SA.redirection_mobile ({nmobile_url :     "USERURL.mysite.com", });          </script>      **Note** that I am trying to display the user's URL that they just signed up with in the message. Does anybody know how to do that without modifying any of the WordPress core? Let me know if this is a little too vague, or if you need any more information. Thanks, Keenan


Paginate yearly archives for a custom post type

Here's the code I'm using to create yearly archives for a custom post type:               function myquery_custom_post_rewrite( $rewrite_rules ) {       $myqueryslug = 'customposttype';       $month_archive = array( $myqueryslug . '/([0-9]{4})/?$' => 'index.php?year=' . $wp_rewrite->preg_index(1) . '&post_type=' . $myqueryslug . '&paged=' . $wp_rewrite->preg_index(3));       $rewrite_rules = $month_archive + $rewrite_rules;       return $rewrite_rules;     }     add_filter('rewrite_rules_array', 'myquery_custom_post_rewrite');      This works okay, except for the pagination. Trying to get to page 2 or any page other than 1 always shows a 404 page. Here's the URL I'm trying to use to get to pages other than 1:               http://mysite.com/customposttype/year/page/2      With the slug for my custom post type for customposttype and a year, like 2012, for year. What am I doing wrong? ============================= UPDATE: I got it working! Just in case anyone else needs it, here's the code that got it working:               function myquery_custom_post_rewrite( $rewrite_rules ) {       $pagination_base = $GLOBALS['wp_rewrite']->pagination_base;       $myqueryslug = 'customposttype';            $year_archive = array(         $myqueryslug . '/([0-9]{4})/' . $pagination_base . '/?([0-9]{1,})/?$' => 'index.php?post_type=' . $myqueryslug . '&year=$matches[1]&paged=$matches[2]',         $myqueryslug . '/([0-9]{4})/?$' => 'index.php?post_type=' . $myqueryslug . '&year=$matches[1]',       );       $rewrite_rules = $year_archive + $rewrite_rules;       return $rewrite_rules;     }     add_filter('rewrite_rules_array', 'myquery_custom_post_rewrite');


Force core to use .dev JavaScript files

I was wondering if there's some constant telling WordPress **not** to use the minified versions of scripts but instead load .dev ones. Already tried `define('SCRIPT_DEBUG', true);` but it only turned off script unification.


Custom Capabilities for CPT and Problem with current_user_can()

I have setup a CPT with custom capabilities.               add_action('init', 'fac_product_posttype_init');     function fac_product_posttype_init(){         $product_labels = array( ... );         $caps = array(                 'publish_posts' => 'publish_products',                 'edit_posts' => 'edit_products',                 'delete_posts' => 'delete_products',                 'edit_published_posts' => 'edit_published_products',                 'delete_published_posts' => 'delete_published_products',                 'delete_others_posts' => 'delete_others_products',                 'edit_others_posts' => 'edit_others_products',                 'edit_post' => 'edit_product',                 'delete_post' => 'delete_product',                 'read_post' => 'read_product',                 'upload_files' => 'upload_files'             );         $args = array(             'labels' => $product_labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,              'query_var' => true,             'rewrite' => true,             'capability_type' => 'product',             'capabilities' => $caps,             'hierarchical' => false,             'supports' => array('title','editor','thumbnail'),             'has_archive' => 'products',             'menu_position' => 5,              'show_in_nav_menus' => false         );          register_post_type('product',$args);     }      Then assigned those capabilities to `administrator` and `subscriber`               function fs_add_roles(){         $roles_set = get_option('fs_roles_are_set');         //if(!$roles_set){              $admin = get_role('administrator');         $admin->add_cap('publish_products');         $admin->add_cap('edit_products');         $admin->add_cap('delete_products');         $admin->add_cap('edit_published_products');         $admin->add_cap('delete_published_products');         $admin->add_cap('edit_others_products');         $admin->add_cap('delete_others_products');              //update_option('fs_roles_are_set', true);              $subscriber = get_role('subscriber');         $subscriber->add_cap('publish_products');         $subscriber->add_cap('edit_products');         $subscriber->add_cap('delete_products');         $subscriber->add_cap('edit_published_products');         $subscriber->add_cap('delete_published_products');         //}     }     add_action('init', 'fs_add_roles');      All good upto this point and I can see on `$wp_roles` global array that all those custom caps are set `true` for `administrator` and `subscriber`. **BUT** when I call `current_user_can('delete_product', $post_id);` it returns `false`. I have double checked the $post_id. Its created by the `$current_user` I am trying to figure out the problem for hours. But not sure whats going on. Any advice on troubleshooting is greatly appreciated!


wordpress 3.4.2 + wp_nav_menu + chunk theme not working

I'm trying to create a page for each of the categories i got in my blog and it should appear on the menu i got in Chunk theme. the idea is to have a link to each of the categories which would guide you to something like this 'http://blog.direktio.com/category/business-intelligence/' so I found out that wp_nav_menu is the one that creates the menus, and that it has a parameter named `'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>'` which allows me to add other stuff to the wrapping of the menu created by the function.. so te idea is to do something like this: `<?php wp_nav_menu( array( 'theme_location' => 'primary', 'items_wrap' => 'sssssss %3$s' ) ); ?>` so I would get a menu with some 'sssss' and then the usual list items.... but hey... it doesn't show 'sssss' at all... so the question here is why is this parameter `items_wrap` not working according to documentation thanks in advance for any help edit: as requested here is a link to the theme in question, hadn't include that since it is one of the default themes anyway... i don't think there is a real problem with the them per se, im reading wp_nav_menu docs (more) thouroughly now edit2: found an answer.... lemme write it!


How to access variables in the function where apply_filters() is called?

I am trying to filter some data based on whether a variable from within the function that calls `apply_filters()` is equal to specific value. That variable is not passed to the `apply_filters()` parameters. This might explain what I mean:               // function in wordpress core     function get_var_b() {         // generating $var_a         $var_a = "a";         // some code ...         $var_b = apply_filters('get_var_b', $var_b);         return $bar_b;     }          // in functions.php     add_filter('get_var_b', 'filter_var_b');     function filter_var_b($var_b) {         if ($var_a == "c") {             $var_b = "d";         }         return $var_b;     }      I tried to use `global $var_a;` inside of my function but with no success. The only way I could access `$var_a` was by editing the core file and passing `$var_a` to the `apply_filters()` function like:               apply_filters('get_var_b', $var_b, $var_a);      Is there a way to access this variable without editing the core file or trying to regenerate $var_a from scratch? Thanks. **EDIT:** The filter that I am trying to hook to is `dynamic_sidebar_params` which is called from `dynamic_sidebar()` function in `wp-includes/widgets.php` file. I am trying to change the `$params[0]['before_widget']` from `<aside>` to `<nav>` IF the `$id` was equal to `categories-2`.


Securing Admin Accounts - Username Discovery

We've had Limit Login Attempts installed for some weeks now, and the number of brute force attempts occurring on wp-admin/wp-login is pretty amazing. At first the attempts were all with the username "Admin," which doesn't exist on our site, so I considered it an annoyance but not much of a threat. However, now we're seeing lockouts occurring with other named admin user accounts and I'm completely at a loss of understanding for how the attackers are deducing the usernames of these accounts. No content on our site is authored by anyone in particular and I can't find any other location on our site where these usernames are publicly published. Any idea as to how usernames might be discoverable?


Get the ID of the current post's child category

A client of mine wants to create a simple "related posts" loop that shows 6 of the most recent posts that match the current post's category. The issue is that every one of their posts have the same parent category and then are organised using children of that category so simply using `get_the_category` as I have been doing isn't going to work as they all share the same parent. So, my question is, is there a way that I can get the ID of the current post's lowest tier child category, but ignore it's parent(s)? So for example if you're viewing a post that has the following category structure;               - Parent Category         - First Child Category             - Second Child Category      How could I get the ID of JUST the `Second Child Category` while ignorning it's parents?


Wordpress add_options_page() function not considering role

I am new to WordPress plugin development and i am stuck at why the wordpress function `add_options_page()` is not accepting role. This is my code which is not working               add_action('admin_menu', 'ct_admin_settings_page');     function ct_admin_settings_page()     {         add_options_page(             'CT Settings',             'CT Settings',             'Administrator',             'ct_admin_settings',             'ct_admin_settings_page'         );     }      but if i try the following, the menu appears (changing **Administrator** to **manage_options** ),               add_action('admin_menu', 'ct_admin_settings_page');     function ct_admin_settings_page()     {         add_options_page(             'CT Settings',             'CT Settings',             'manage_options',             'ct_admin_settings',             'ct_admin_settings_page'         );     }      It is my understanding that the third parameter in function `add_options_page` is ROLE so why Administrator which is a ROLE not being accepted?


How to limit number of attachments

I'm using Sweet Cake theme. As you can see the portfolio section show all pictures. I want when someone load the site to be displayed items of the first category , instead of everything. How can I do that?               <?php if($data['anchor_portfolio'] == 1){ ?>

             <a href="<?php echo $data['anchortoplink_portfolio']; ?>"><img class="anchortop" alt="" src="<?php if($data['anchortopimage_portfolio']): ?><?php echo $data['anchortopimage_portfolio']; ?><?php else: ?><?php echo get_template_directory_uri(); ?>/img/anchors/topportfolio.png<?php endif; ?>" />             <a href="<?php echo $data['anchorbottomlink_portfolio']; ?>"><img class="anchorbottom" alt="" src="<?php if($data['anchorbottomimage_portfolio']): ?><?php echo $data['anchorbottomimage_portfolio']; ?><?php else: ?><?php echo get_template_directory_uri(); ?>/img/anchors/bottomportfolio.png<?php endif; ?>" />

               <?php } ?>
                       <div class="grid_12 titlesection <?php if ($data['introeffect_portfolio'] == 1): echo $data['animation_portfolio']; endif ?>">
<?php echo do_shortcode(stripslashes($data['title_portfolio'])); ?>

Show all
                                               <?php                     $args=array(                         'type' => 'attachment',                         'child_of'                 => 0,                         'orderby'                  => 'name',                         'order'                    => 'ASC',                         'hide_empty'               => 0,                         'hierarchical'             => 1,                         'post_status'              => 'inherit',                         'taxonomy'                 => 'portfolio'                     );                     $categories=get_categories($args);                          foreach($categories as $category) { ?>
<a style="background-color:<?php echo $category->description; ?>;" href="#filter" data-option-value=".<?php echo $category->slug; ?>"><?php echo $category->name ?>
                     <?php } ?>

                  <?php             foreach($categories as $category) {                 $args = array(                     'post_type' => 'attachment',                     'posts_per_page' => -1,                     'post_status' => 'inherit',                     'tax_query' => array(                         array(                             'taxonomy' => 'portfolio',                             'field' => 'slug',                             'terms' => $category -> slug                         )                     )                 );                           $attachments = get_posts($args);                 if ($attachments) {                     foreach ( $attachments as $attachment ) { ?>                              <?php                         $id = $attachment->ID;                         $big_image = wp_get_attachment_image_src($id, '');                         $thumb_image = wp_get_attachment_image_src($id, 'portfolio-thumbnail');                         $alt = get_post_meta($id, '_wp_attachment_image_alt', true);                         $image_title = $attachment->post_title;                         $caption = $attachment->post_excerpt;                         $description = str_replace('"', '\'',$attachment->post_content);                         ?>                                                       <div class="element <?php echo $category -> slug; ?>" data-category="<?php echo $category -> slug; ?>">                                                               <?php if (!empty($alt)) { ?>                                 <a href="<?php echo $alt; ?>">                             <?php } else { ?>                                 <a class="alttooltip" title="<?php echo $description; ?>" data-rel="prettyPhoto[]" href="<?php echo $big_image[0]; ?>">                              <?php } ?>                                                                   <img alt="<?php echo $alt; ?>" class="imgwork" src="<?php echo $thumb_image[0]; ?>" />
                                 <img alt="" src="<?php echo get_template_directory_uri(); ?>/img/section-works/arrow.png" />

<?php echo $image_title; ?>

<?php echo $caption; ?>

                                                   <?php } ?>                 <?php } ?>             <?php } ?>

              This is the code from portfolio.php. It displays "Show all", all other categories and all attachments. As you can see the section _Start Options_ is calling all categories + Show All button. After that is the section _Start images_ where are displayed all images for the current category. I don't know how to get rid off "Show all" and display only first category.


Using XML RPC to import data into WordPress

I've been asked to create a website in WordPress that should display many phone operators/agents who can be called from a given phone number on the website. So far so good but the website should also display to status of the agents status (available, away, busy etc) in realtime. The agents use external software for this and the data to show their availability is available through XML RPC. En example of a response can be seen below               <?xml version="1.0"?>       <methodResponse>       <params>         <param>         <value>          <struct>               <member>           <name>param1</name>           <value><string>value1</string></value>         </member>              <member>          <name>param2</name>          <value><string>value2</string></value>         </member>            </struct>       </value>      </param>           </params>      </methodResponse>      Is this even possible as I can't hardly find any information about importing non-WordPress data with XML RPC. The information that I've found is either outdated or really unclear and confusing to me. If anyone know if it is possible to display the received data/status into a (custom) post type in WordPress please let me know. Or if anyone has more information about this please let me know.


Permalinks URL not working without index.php

we've just transferred a WordPress site to its domain. The Permalinks settings all have an `index.php` at the end. This results into URLs such as `http://[domain].com/about` not working but `http://[domain].com/index.php/about` works. **Screenshot:** ![enter image description here](http://i.stack.imgur.com/C6GeS.jpg) I've tried setting it to Default and set a Custom Structure as `/%postname%/` but this did not change anything. Maybe it's something to do with the htaccess or config? This is what I have in the htaccess, which seems to be correct               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      Thanks in advance for any help.


How to hide a customization link themes menu in wordpress?

Anyone know how to hide or remove customization menu in wordpress? The link menu seen in OPTIONS:Widgets Menus **_Theme Options_** and Appearance -Theme -Widgets -Menus _**-Theme Option_** -Editor Thank you


shortcode for recent custom type post

I'm not a coder so I may have done some "coding" crimes, apologies. I've bought a theme who has shortcodes for last posts but not for last "custom post type". So I tried to create last "custom post type" function modifying the Last post function provided. Last post funtion:               function get_custom_posts( $params ) {     extract( shortcode_atts( array (         'number' => '1',         'excerpt' => 290,         'readmore' => 'no',         'readmoretext' => 'Read more'     ), $params ) );          //$latest_posts = get_posts( 'category=0&numberposts=' . $number . '&suppress_filters=false');     OLD     $latest_posts = query_posts( 'cat=0&posts_per_page=' . $number );     wp_reset_query();          $result = '
';     $count = count($latest_posts);     foreach ($latest_posts as $key => $latest_post) {       $author = get_the_author_meta('nickname', $latest_post->post_author );       $post_link = get_permalink( $latest_post->ID );       $date = mysql2date(get_option('date_format'), $latest_post->post_date);       $category = get_the_category_list( ', ', $parents = '', $latest_post->ID );            $result .= '

';       // POST THUMBNAIL       if (get_the_post_thumbnail( $latest_post->ID, 'thumbnail' )) {           $result .= '
';           $result .= '';           $result .= get_the_post_thumbnail( $latest_post->ID, 'thumbnail' );           $result .= '';           $result .= '
';       }            // POST BODY       $result .= '
';       $result .= '

' . $latest_post->post_title . '

';       if ( $latest_post->post_excerpt ) {           $result .= '
' . $latest_post->post_excerpt . '
';       }       else {           $limit = $excerpt;           $my_text = substr($latest_post->post_content, 0, $limit);           $pos = strrpos($my_text, " ");           $my_post_text = substr($my_text, 0, ($pos ? $pos : -1)) . "...";           $read = "";       if($readmore == 'yes'){         $read = ' '.$readmoretext.'';       }           $result .= '
' . strip_tags($my_post_text) . $read . '
';           //$result .= '
' . substr_replace( $latest_post['0']->post_content, '...', 350 ) . '
';       }            $result .= '
';            if ($count - 1 != $key)       $result .= do_shortcode('[rule]');            $result .= '

';     }     $result .= '
';          return $result;     }     add_shortcode( "get_posts", "get_custom_posts" );      Then I tried to modify it like this, (my custom post type is ait-dir-item):               function get_custom_items( $params ) {     extract( shortcode_atts( array (         'number' => '1',         'excerpt' => 290,         'readmore' => 'no',         'readmoretext' => 'Read more'     ), $params ) );          //$latest_posts = get_posts( 'category=0&numberposts=' . $number . '&suppress_filters=false');     OLD     $latest_items = WP_query( 'post_type' = 'ait-dir-item', 'cat=0&posts_per_page=' . $number );     wp_reset_query();          $result = '
';     $count = count($latest_items);     foreach ($latest_items as $key => $latest_item) {       $author = get_the_author_meta('nickname', $latest_item->post_author );       $post_link = get_permalink( $latest_item->ID );       $date = mysql2date(get_option('date_format'), $latest_item->post_date);       $category = get_the_category_list( ', ', $parents = '', $latest_item->ID );            $result .= '

';       // POST THUMBNAIL       if (get_the_post_thumbnail( $latest_item->ID, 'thumbnail' )) {           $result .= '
';           $result .= '';           $result .= get_the_post_thumbnail( $latest_post->ID, 'thumbnail' );           $result .= '';           $result .= '
';       }            // POST BODY       $result .= '
';       $result .= '

' . $latest_item->post_title . '

';       if ( $latest_item->post_excerpt ) {           $result .= '
' . $latest_item->post_excerpt . '
';       }       else {           $limit = $excerpt;           $my_text = substr($latest_item->post_content, 0, $limit);           $pos = strrpos($my_text, " ");           $my_post_text = substr($my_text, 0, ($pos ? $pos : -1)) . "...";           $read = "";       if($readmore == 'yes'){         $read = ' '.$readmoretext.'';       }           $result .= '
' . strip_tags($my_post_text) . $read . '
';           //$result .= '
' . substr_replace( $latest_item['0']->post_content, '...', 350 ) . '
';       }            $result .= '
';            if ($count - 1 != $key)       $result .= do_shortcode('[rule]');            $result .= '

';     }     $result .= '
';          return $result;     }     add_shortcode( "get_items", "get_custom_items" );      Of course, this function doesn't work... Can someone help me? I want to modify this function instead of installing a plugin because I want to use the same classes so I will have the same design for both shortcodes. Thanks in advance!


Custom user registration shortcode - redirect header issue

I've created a custom shortcode that calls a function which will produce a registration page. Registration works. No issue here. The issue I am having is to log the user in after a successful registration. I understand the reason I am getting `header already sent error` is because the shortcode is loaded after the header information. What is the best way to redirect or log the user in within a shortcode `add_action( 'user_register', array($this,'auto_login_new_user'), 10);`               function auto_login_new_user( $user_id ) {         // exit($user_id);         wp_set_current_user($user_id);         wp_set_auth_cookie($user_id);              wp_redirect( home_url() );         exit;     }


How can I add an author-box below a post?

I would like to have a box below each blogpost with information about the author. These screenshots are examples for what I would like to have: ![enter image description here](http://i.stack.imgur.com/6JSPR.png) * * * ![enter image description here](http://i.stack.imgur.com/xYJmP.png) * * * **Links that could help** : I've found these links so far:   * Author Templates     * wp_list_authors I would prefer a plugin (or widget, I don't know the difference), but if nothing like that existed, I would have to adjust **single.php** to my needs, wouldn't I? What would happen, if the theme (Modern Style) got updated? **Related question** : How to add author details in the post sidebar? This is not the same question, as I would like to get the box below the post. But if this is not easily possible: Where should I save the given code?


bbPress plugin - How do I add a forum description?

This might be a total dummy question, but I have no idea where to enter the forum description with bbpress. I see it on plenty of other bbPress-powered forums, and the plugin is inserting `<div class="bbp-forum- description"></div>` into my table of entries, but when I create or edit a forum, I don't see a field to enter this information. Is this normal or is something strange going on with my bbPress forum?


How to create a plugin page that shows XML?

I'm looking for the best way to create a plugin page that displays XML. It needs to be:   * Front facing to the public   * Valid XML that removes all the admin hub-bub and allows me to change the header info   * Doesn't display in the side menu


Adding custom class names to anchor in wp_list_pages

I've the following navigation: (example)

Wat is het

Hoe werkt het?

Resultaten?

OncoNavigator?

Ziekenhuizen?

      Can I add custom classes to a anchor element inside `Wp_list_pages`? because the current `wp_list_page` doesn't use a class attribute inside a anchor element. I want to add a unique class to each anchor element. For final result, I want to make a tab based horizontal dropdown menu. I looked for couple of WordPress dropdown menu plugins but there wasn't anything out there that fulfill my wishes.


How to force unlink on attached/inserted images?

When users insert an image into the content, WordPress automatically wraps the image in a hyperlink that, when clicked, creates an "attachment" page showing only the image inside the theme. Can I insert a code in my theme that tells WP not to create this link?


Custom post and category template pagination problem

I have a category template which holds a query to custom post with a category. The strange thing is when the pagination loads it displays how many pages we have. But when I click on the second page of the pagination it gives me a 404 page. If I make the query only to fetch the custom post or to fetch the category it works fine. After I have refresh the query with the test for the custom post and the category it works fine. Here is the code of the category template:

     <?php     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array(         'posts_per_page' => 6,         'post_type' =>  'awards-pub',         'cat'=>6,         'paged' => $paged,         'order'=>'DESC'     );     $wp_query = new WP_Query( $args );     //wp_query->query('showposts=5'.'&paged='.$paged);     $i=1;     while ( $wp_query->have_posts() )     {         $wp_query->the_post();         ?>     <article class="article-first-vision <?= ($i==2)?'mar':'' ?>" >       <?php if ( has_post_thumbnail()) { ?>       <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">       <?php the_post_thumbnail('menu-pub'); ?>              <?php     }; ?>
         <?php the_title(); ?>

         <?= truncateHtml(get_the_content()); ?>
       <a href="<?php the_permalink(); ?>" style="bottom:0; right:0;" class="pa"><img src="<?php bloginfo('template_url') ?>/img/link-articles.png">
     <?php     if($i==3){$i=0;}     $i++;     }     ?>

     <?php         get_template_part('pagination');     ?>

     <?php         wp_reset_query();     ?>      And this is the pagination:               global $wp_query;     $big = 999999999;     echo paginate_links(array(         'base' => str_replace($big, '%#%', get_pagenum_link($big)),         'format' => '?paged=%#%',         'current' => max(1, get_query_var('paged')),         'total' => $wp_query->max_num_pages,         'prev_next'    => True,         'prev_text'    => __('«'),         'next_text'    => __('»'),     ));      And this is the custom post:                register_post_type('awards-pub', // Register Custom Post Type         array(         'labels' => array(             'name' => __('Awards', 'awardspub'), // Rename these to suit             'singular_name' => __('Awards Post', 'awardspub'),             'add_new' => __('Add Awards', 'awardspub'),             'add_new_item' => __('Add Awards  Post', 'awardspub'),             'edit' => __('Edit', 'awardspub'),             'edit_item' => __('Edit Awards Post', 'awardspub'),             'new_item' => __('New Awards Post', 'awardspub'),             'view' => __('View Awards Post', 'awardspub'),             'view_item' => __('View Awards Post', 'awardspub'),             'search_items' => __('Search Awards Post', 'awardspub'),             'not_found' => __('No Awards Posts found', 'awardspub'),             'not_found_in_trash' => __('No Awards Posts found in Trash', 'awardspub')         ),         'public' => true,         'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages         'has_archive' => true,         'supports' => array(             'title',             'editor',             'excerpt',             'comments',             'thumbnail'         ), // Go to Dashboard Custom HTML5 Blank post for supports         'can_export' => true, // Allows export in Tools > Export         'taxonomies' => array(             'post_tag',             'category'         ) // Add Category and Post Tags support     ));      And to add the category to the custom post:               register_taxonomy_for_object_type('category', 'awards-pub');     register_taxonomy_for_object_type('post_tag', 'awards-pub');


query posts and split meta information into separate div's

I'm trying to replicate the functionality of the content showcase/slider seen here: http://stylewatch.stelladot.com/ From what I see in the HTML, it appears that there's 2 divs, one with the post images and one with the post titles. I'd like to use something like `wp_list_pages` to return the 4 most recent posts and put them in the slider, but I'm not quite sure how to do it. It seems that they're in separate div's - how would I query the posts and split the set of images from the set of post names? I guess I could make 2 queries and have one query images while the other queries titles but it seems that isn't the most efficient way to do so. EDIT: Adding sample desired markup - the content of `media-0` and `title-0` should be from the same post.

text

text


How do i migrate a Multi site to individual site?

I have a client who built a site on a sub site of a Multi site network Can this be migrated to a new domain and independant wordpress site?


How to add "Template" option in page attributes panel?

I am new in WordPress. In my theme, I do not have "Template" option in 'Page Attributes panel'. I want to add this option. I tried to solve this problem from the following post. But It did not work for me. I am using "WordPress 3.6". Adding a Template to the Page Attributes Panel for both Posts and Pages? I already made a new template file(sunrise.php), which contains -               /*     Template Name: Sunrise     */      And, I added the php code in my function.php file, from the above link. But, I did not find the template selecting option in my "Page Attributes" panel. Below, I have added an image of my new page present condition. Thanks, in advance.


How is WP_Query parsed to determine which template to request?

I noticed that when I changed the WP_Query to ask for a certain category, the page served was `category.php`. So I'm guessing there's a block of code somewhere that decides which template to serve based on keys in the query. Where is it?


Check if tag, category or author on archive.php

i'm making a wordpress theme and want to use a single archive.php page in order to present posts under a specific author, a category or tag. Now, i'm doing it like :                if (is_author())       {            }            if (is_category())       {            }            if (is_tag())       {            }      I know i can divide this in more templates, but i don't want to repeat myself and i generally prefer to do it in a single php file. So, my question is : How can i get either the category, tag or author in each of these ifs ? It seems that for the author i can use something like :               $author = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));      and for the category :               get_query_var( 'cat');      But is this indeed the way to do it ? What is a safe way to get that information independent of permalinks ?


Including inline Custom Fields info with add_filter in functions.php

I have a function set up to place some standard text in each post for a Custom Post Type. However, within that standard text I want to pull some unique text from a few custom fields. Not sure what is wrong with my code:               function default_content($content) {       global $post;       if ($post->post_type == 'my-custom-post-type') {         $content .= '
Custom Field Text here: <?php echo get_post_meta( get_the_ID(), \'custom-field-1\', true )

<a href="http://myblog.com/?checkout=<?php echo get_post_meta( get_the_ID(), \'custom-field-2\', true )">Link 01
';       }       return $content;     }     add_filter('the_content', 'default_content', 0);


Wordpress postboxes On Tabbed Views and Hiding Registered Pages

Firstly here is a YouTube of me explaining my problem... https://www.youtube.com/watch?v=Nenu1stzLRw I want to be able to use postboxes on tabbed pages. Usually tabbed pages are called views to avoid confusion with actual admin registered pages. I have around 5 plugin pages and each has a tab menu. I cannot use postboxes full ability on them because each tab/view shares the same settings registered for the WP admin page they are on. So one page, multiple views. Wordpress does not appear to have a parameter to create settings per tab/view as it relies on the "page" variable in the URL which is always for a registered page. So I've went ahead and registered all of my views. Around 30 and I want to hide 25 of them say. The 5 left will show menus allowing access to the rest of my plugins admin pages. That is my attempt at a solution but it does not work. This is the function that prevents postboxes being used properly on tabbed views...               function wp_ajax_meta_box_order() {     check_ajax_referer( 'meta-box-order' );     $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;     $page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';          if ( $page_columns != 'auto' )         $page_columns = (int) $page_columns;          $page = isset( $_POST['page'] ) ? $_POST['page'] : '';          if ( $page != sanitize_key( $page ) )         wp_die( 0 );          if ( ! $user = wp_get_current_user() )         wp_die( -1 );          if ( $order )         update_user_option($user->ID, "meta-box-order_$page", $order, true);          if ( $page_columns )         update_user_option($user->ID, "screen_layout_$page", $page_columns, true);          wp_die( 1 );      TablePress See the TablePress plugin for an example of what I DO NOT want my plugin to do. I want the tab menu but I do not want the tabs to be reflected in the main plugin menus and vice-versa. This plugin is great coding standards and makes perfect use of the WP core but I'm trying to improve on it. If I could do it the TablePress plugin could have a single page.


Posting an XML request using HTTP API

I'm trying to work with an API that expects an XML string in the body of the post. Additionally, the docs for the API specify: > Please post with mime-type text/xml with the XML in the body of the post I want to use the WordPress HTTP API to make this work, but I'm running into some problems. So far I have code like the following that seems to be failing.               $url = 'https://www.testurl.com';     $xml = <<<TESTED XML HERE>>>;     $response = wp_remote_post(          $url,          array(             'method' => 'POST',             'timeout' => 45,             'redirection' => 5,             'httpversion' => '1.0',             'headers' => array(                 'mime-type' => 'text/xml'             ),             'body' => array('xml' => $xml),             'sslverify' => false         )     );      My question is, am I properly setting the mime-type and am I sending the XML in the right place? It's surprisingly tough to find examples of the WordPress HTTP API utilizing XML requests.


comments_popup_link without echo?

I would like to just get the HTML that comments_popup_link generates, and echo it later on. I don't see the comments_popup_link has an `$echo` parameter, and I don't see a get_comments_popup_link function, like there is get_the_ID, that _returns_ HTML istead of displaying it. I'm using WordPress 3.1.2 What can I do?


Current Post/Page Ancestor, CSS

LINK: http://themeforward.com/demo2 Checkout my menu. Hover over Features > Shortcodes > Typography. Notice how when you put your mouse over typography the background of Shortcodes turns to the darker red? **How do I get the background to turn to the darker gray (#EEE) instead while on the third level of the menu without changing the parent menu link colors (Home, Templates, Features, Portfolio, Blog)?** Here is the part of my CSS creating this:               /*** DEMO SKIN ***/     .sf-menu {         float:          left;         z-index: 900     }     .sf-menu a, .sf-menu a:visited  { /* visited pseudo selector so IE6 applies text colour*/         color:          #FFF;         padding:        10px;         text-decoration:none     }     .sf-menu li {         margin-right:35px;         z-index: 900     }     .sf-menu li li {         z-index: 900;         background:#FAFAFA     }     .sf-menu li li li {         background:     #FAFAFA;         z-index: 900     }     .sf-menu li:hover, .sf-menu li.sfHover,     .sf-menu li a:focus, .sf-menu li a:hover, .sf-menu li a:active {         outline:        0;         background: #AF1D21     }          .sf-menu .current-post-ancestor a, .sf-menu .current-menu parent a, .sf-menu .current-page-ancestor a, .sf-menf .current-category-ancestor a, .sf-menu .active_category a, .sf-menu .current-menu-item a { color:#1a1a1a }               ul .sub-menu { }     ul li .sub-menu a { color:#262626!important }     ul li .sub-menu a:hover { background:#EEE!important }


Use Wordpress engine for user registration and management

I am building a web app and would like to use the Wordpress Engine only for Authentication and User Management. Is there any good tutorials out there on how I can connect only the back end of wordpress to my simple app?