Keep active class in post page

I have one category and under this category I have many posts. Normally when I go to my category page from menu it added active class `class="current-menu- item"`. Bellow is the rendered html

Home

Rentals

Products

Services

company

Contact US

      But from the category page when I go to any post, there is no active class added. It is normal I think. But I want to keep my active class when I go to that category posts . How can I do that? Bellow is my active class code in function               add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1);     add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1);     add_filter('page_css_class', 'my_css_attributes_filter', 100, 1);          function my_css_attributes_filter($var) {       return is_array($var) ? array_intersect($var, array('current-menu-item', 'current-menu-ancestor')) : '';          }


Invalid Post Type error when attempting to filter and Bulk Edit posts

WP 3.8.1 Posts Categories:   1. News   1.1 Press Release   1.2 etc.   2. Blog   2.1 Technology   2.2 Around The World   2.3 Eetc. "Invalid Post Type" example: Posts => Filter by "Press Release" + checkmark ALL + Edit + Apply + I change the author name + Apply:               wp-admin/edit.php?s=&post_status=all&post_type=Array      I basically want to change all Press Release author names. That's it. But I keep getting "Invalid Post Type" error.


How do I disable dashboard update notifications for subscribers?

For registered users to my blog, if they click on the dashboard, they get an alert suggesting that they tell the site administrator (me) that the new version of WordPress is available. All I want is to hide dashboard alerts from the subscribers. Where can I find the code to change this? I found a site here that suggests that I'm looking for the code:               add_action('admin_head','addDashboardAlert');      But I don't know where to look for it. ## UPDATE I found some more relevant code to make the alerts conditional on user role, here:               if (!current_user_can('delete_posts')) {


Font shows up as Arial instead of Times

I am the webmaster of Palo Alto High School's online publication, The Paly Voice. We're using Wordpress, and for some reason occasionally chunks of stories change fonts. Here is an example. I inspected it, and there's no surrounding element - just text. But why? How can I fix this?


Excerpt not alway available

I have a php function that should print last three posts with title and excerpt. For the first post printed there is no excerpt. Here is the code:                 $posts = wp_get_recent_posts( array('numberposts' => 3, 'post_status' => 'publish')  );       foreach ($posts as $post)       {         setup_postdata($post);         echo "
".$post['post_title']."
";         if($post['post_excerpt'])               echo $post['post_excerpt']." Continue...";         else echo 'no excerpt';         echo "

";       }      I want to show the excerpt for the first post printed too (the last posted one). What is wrong in my code? Why it's not working for the first post printed?


Cannot modify header information when I try my site with www

When I try to reach my website and include www in it's address I get this error:                Warning: Cannot modify header information - headers already sent by (output started at .../wp-content/themes/BulletPressWP/framework/includes/post-meta-details.php:1) in .../wp-includes/pluggable.php on line 896      If I try address without www everything is OK.


500 internal error at wp_generate_attachment_metadata

I found that my PHP script throws an 500 (Internal Server Error) at the line which `wp_generate_attachment_metadata` function is used:               $attach_data = wp_generate_attachment_metadata( $attach_id, $fullpathfilename );      I can exit and take an output before this line but not after that. I checked the inputs too:               Array     (         [attach_id] => 101362         [fullpathfilename] => /home/appleapp/USER/wp-content/uploads/2014/05/Beat-the-Boss-2-17+945428.png     )      Any help is really appreciated.


Get category id from post id of a custom post type

I want to get category id from post id of a custom type. I have the post id, but I can't get it's category id. I have used so many codes but it doesn't work, may be due to custom post type.               $category = get_the_category( $post->ID );      Any suggestions?


WP not logging in at first time

I've been experiencing a weird "bug" in my website which I have a form in the front page to do the log in, it doesn't log, redirects me to the WP-login.php and it says the Cookies may not be active in my browser. I've checked my browser and the cookies are active. After log in (on the WP-login page) it never happens again. But after cleaning my cache and testing again, it does the problem. How do I fix this?


remove_filter excerpt_more from a plugin class

I'm trying to remove a filter from within my plugin class. I need to remove the 'continue reading' link from the_excerpt. The base theme is the twenty ten theme and they are applying a filter `twentyten_auto_excerpt_more`. I cannot remove the filter, I assume because I'm within a class:               class MyAwesomeClass {          private static $instance;          public static function instance() {         if ( !isset( self::$instance ) ) {             self::$instance = new MyAwesomeClass;             self::$instance->setup_actions_and_filters();         }         return self::$instance;     }          private function __construct() {}          public function setup_actions_and_filters() {         add_filter( 'excerpt_more', array( $this, 'change_excerpt_more' ) );     }          public function change_excerpt_more( $excerpt ) {         remove_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );         return '';     }          }          MyAwesomeClass::instance();      The filter I am trying to remove:               add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );      Is there a way of doing this?


Is there a way to have wordpress 301 versus 302 urls by default?

Sorry if this is a duplicate but I didn't find my answer in "Questions that already have your answer". Currently on my site if I visit an old URL link or if I outright make up a URL like `example.com/made-up-place.html` I am getting redirected with a 302. Whats weird is that it 302's by default instead of 301 for moved URLs, but I'm really intrigued as to why a URL that has never existed 302's back to the homepage. So my two questions are:   1. How do I force all 302 to 301 (I would think there is a hook to add into `functions.php`)?   2. Why would made up urls to a file 302 and not 404? I would like some understanding of what I'm seeing. **Edit 1:** My theme does have a 404 template that does work in some situations. Example: Current site URL structure is: `example.com/id/1234/slug`   1. If I put in an invalid URL like example.com/id/999999 then i would get a 404 response which is expected.   2. If `example.com/id/999999/some-slug` I see a 301 on some-slug followed by a 404 on the full URL.   3. `example.com/some-made-up-thing.html` this goes to 302 instead of a 404. Past site structure was `example.com/slug` (but no pages ever included the extension) and this page had never existed. What is interesting is that this only occurs on the main domain. All subsites (example2.com, example3.com) all work correctly and as expected #1, #2, and #3 all 404 as they should!


Get children post mime type using parent post_ID wp_post

Consider parent post_id is 11 for the same post. If I add media, the information about media is passed to the post_id 12 by taking parent_id 11 in wp_post. So, if I want to get media information using `get_post_id()` as a parameter, it returns the mime type of post 11 which will be null, but for that id I need to fetch its children post data, lets say 12.


Get custom wp_query search results to appear on search.php

I have a search.php page in my template which works fine when used with the native search widget, but I am making a search plugin which has a custom wp_query in it and I want those results to appear on search.php INSTEAD of regular search widget results. My plugin so far works well, I "just" want it outputted in search.php. I tried adding `pre_get_posts` filter and also `posts_search` action but the filter hook shows "the connection was reset" in the browser and the action hook does the same PLUS it gives a WP Database error on the page where the plugin is loaded. Relevant part of the function that makes the query:               $blog_url = get_bloginfo('url');              $form = <<<EOH
         <form method="get" action="{$blog_url}" id="ss-search">             <input type="text" value="{$search_text}" name="supers" onblur="if (this.value == '') { this.value = '{$search_text}';}" />             {$list}             <input type="submit" id="sbc-submit" value="Search" />         </form>
     EOH;               if (isset($_GET['supers'])) {              global $q;         // global $q;         $args = array(             // 'category__not_in' => 1,             's' => $_GET['supers'],             'paged' => get_query_var('paged')         );              $q = new WP_Query($args);              if ( $q->have_posts() ) {                 echo '
';             while ( $q->have_posts() ) {                 $q->the_post();                 echo '
' . get_the_title() . '
';             }                 echo '
';                 // echo '
Posts found :'.$q->found_posts.'

';                 echo get_pagination_links2();         } else {             echo 'no posts found';              }              /* Restore original Post Data */         wp_reset_postdata();     }          return $form;          } // end function


Using get_bloginfo('template_directory') or variable - performance issue

Can I please ask you about the performance of these two approaches in term of execution speed and server load? **approach 1:**               <img src="<?php echo get_bloginfo('template_directory'); ?>/data1/images/1.jpg">     <img src="<?php echo get_bloginfo('template_directory'); ?>/data1/images/2.jpg" />     <img src="<?php echo get_bloginfo('template_directory'); ?>/data1/images/3.jpg" />      **approach 2:**               <?php $variable= get_bloginfo('template_directory'); ?>     <img src="<?php echo $variable; ?>/data1/images/1.jpg">     <img src="<?php echo  $variable; ?>/data1/images/2.jpg" />     <img src="<?php echo $variable; ?>/data1/images/3.jpg" />      The answer to this question will be very useful for me since I meet such cases many times during Wordpress developement. Is the time to get variable content less than the time querying the database for blog info?


How to allow only certain users to login

I have looked but could not find either a plugin or code that allows only certin users to login in to my wordpress site e.g wan, velma, bob and no other. Does anyone know how to do this. Thanks Tim


Wordpress Plugins Don't Automatically Update

I have several installations of wordpress on my vps and I have a couple that add/update plugins with no problems. When adding a new plugin I get the following progress messages: > Downloading install package from > `http://downloads.wordpress.org/plugin/hello-dolly.1.6.zip`   >  Unpacking the package…   >  Installing the plugin…   >  Successfully installed the plugin _Hello Dolly 1.6._   >  Activate Plugin | Return to Plugin Installer   > However, on most of my WP installations the message stops at the first line: > Downloading install package from > http://downloads.wordpress.org/plugin/hello-dolly.1.6.zip… The plugin is in the plugin list when I check and all I need to do is activate it. Also, when updating a plugin it doesn't reactivate, so I have to manually do it myself. On a working installation the plugin is reactivated automatically. I've tried cross referencing folder permissions with WP installations that work but I'm having no success. If anyone could help, I would appreciate it, I find it very annoying and tedious when I have to update everything manually.


Wordpress Options Framework, add to main menu not appearance menu

I am using the Wordpress Options Framework theme but I want to be able to have the "Theme Options" link appear in the Admin UI menu as oppose to under the "Appearance" (themes, etc.) menu item. I've tried and tried but can't for the life of my figure out how. Any ideas? The files are all on Github - https://github.com/devinsays/options-framework- theme


How to create drop down for child categories of current taxonomy being viewed?

I need to know how can I get the child/grandchild terms of the current taxonomy being viewed, and put it into a drop down so that I can add values to the options. I am currently using this code to display exactly what I want, but I am unable to modify the options in the drop down -               <?php          //first get the current term     $current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );          //then set the args for wp_dropdown_categories      $args = array(         'child_of' => $current_term->term_id,         'taxonomy' => $current_term->taxonomy,         'hide_empty' => 0,         'hierarchical' => true,         'depth'  => 2,         'title_li' => '',             'show_option_all' => All,             'hide_if_empty' => true         );      wp_dropdown_categories( $args );     ?>      The other code Im using that I need it to look like or be similar to -               <?php     $terms = get_terms("videoscategory");      $count = count($terms);      if ( $count > 0 ){          echo "<select id='filter-select2' style='width:225px;'>";     echo "<option value='*' data-filter-value='' class='selected'>All items</option>";          foreach ( $terms as $term ) {              echo "<option value='.{$term->slug}'>" . $term->name . "</option>";          }          echo "</select>";      }     ?>      So basically what I am looking for is a way to add " **value='.{$term->slug}'** " to the options of the first code which displays the child terms. Any idea how I can modify either one of the codes above so that I can add a the term name as a value to the drop down for child categories?


$query conflicting with other queries in the same page

This is my front page:               <?php          /**      * Template Name: Front Page      *      * @package bbPress      * @subpackage Theme      */          get_header(); ?>

<?php echo __( 'Recent Articles', 'twentyeleven' ) ?>
               <?php while ( have_posts() ) : the_post(); ?>                      <?php get_template_part( 'content', 'front-page' ); ?>                      <?php comments_template( '', true ); ?>                    <?php endwhile; // end of the loop. ?>

<?php echo __( 'Upcoming Events', 'twentyeleven' ) ?>
               <?php echo do_shortcode('                 [events_list limit="3"]

                       #_EVENTIMAGE{60,60}

#_EVENTLINK

#_CUSTOMEXCERPT

                 [/events_list]               '); ?>

<?php echo __( 'Recent Forum Topics', 'twentyeleven' ) ?>
               <?php // Create and run custom loop                   $custom_posts = new WP_Query();                   $custom_posts->query('post_type=topic&posts_per_page=7');                   while ($custom_posts->have_posts()) : $custom_posts->the_post();               ?>  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>

                 <?php endwhile; ?>

<?php echo __( 'Taiwan News', 'twentyeleven' ) ?>

                 <?php                   include_once(ABSPATH.WPINC.'/rss.php'); // path to include script                   $feed = fetch_rss('http://www.taiwansnews.net/index.php/rss/0dd057261bcc461b'); // specify feed url                   $items = array_slice($feed->items, 0, 4); // specify first and last item                 ?>                      <?php if (!empty($items)) : ?>                 <?php foreach ($items as $item) : ?>

<a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?>

                      <?php endforeach; ?>                 <?php endif; ?>

<?php echo __( 'Events Calendar', 'twentyeleven' ) ?>

                 <?php echo do_shortcode('[events_calendar long_events=0 ]'); ?>

<?php echo __( 'Weather Forecast', 'twentyeleven' ) ?>

                   <?php echo do_shortcode('[forecast location="Taipei, Taiwan" caption="Weather for Taipei" measurement="C" todaylabel="Today" datelabel="date("m/d/Y")" highlow="%%high%%°/%%low%%°" numdays="3" iconset="Incredible" class="weather-forecast" cache="true" width="100%"]'); ?>

<?php echo __( 'My Articles', 'twentyeleven' ) ?>
             <?php // Create and run custom loop                 global $tax_selection; // use your variable                 $custom_posts = new WP_Query();                 $custom_posts->query( array(                      'post_type' => 'post',                      'posts_per_page' => 5,                      'category__in' => $tax_selection['categories'],                 ) );                 while ($custom_posts->have_posts()) : $custom_posts->the_post();             ?>  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>

               <?php endwhile; ?>

          <?php get_sidebar(); ?>     <?php get_footer(); ?>      I have this in functions.php:               add_action( 'pre_get_posts', 'do_user_post_selection' );          function do_user_post_selection( $query ) {              if( !is_home() || !is_user_logged_in() )             return;              if( isset( $query->query_vars['post_type'] ) && ( 'nav_menu_item' == $query->query_vars['post_type'] ) )             return;          if( 1 < did_action('wp') )             return;         global $current_user;              $tax_selection = get_user_option( 'taxonomy_selection', $current_user->ID );              if( empty( $tax_selection ) )             return;              if( isset( $tax_selection['categories'] ) && ( is_array( $tax_selection['categories'] ) ) && ( !empty( $tax_selection['categories'] ) ) )              $query->set( 'category__in', $tax_selection['categories'] );         if( isset( $tax_selection['post_tag'] ) && ( is_array( $tax_selection['post_tag'] ) ) && ( !empty( $tax_selection['post_tag'] ) ) )              $query->set( 'tag__in', $tax_selection['post_tag'] );              return;     }      This is making `Recent Forum Topics` to disappear. How to only apply the `$tax_selection;` to My Articles without breaking the other posts?


Highlighting Sub topic in a post?

Have seen this sub topics highlighter in many blogs. It gives a special attraction to a sub topics used in the post. Is this a plugin or part of code? How can I add this? http://imgur.com/UbGpz7j


How to prevent access to wp-admin for certain user roles?

I did try using the plugin Front End Users but this clashes with something as it prevents access to some front end pages. So I need to manually just set it so that anyone who isn't one of two usernames (or roles) can't access wp- admin.


how should the comment form really work?

taken on someone elses code and trying to get a clear understanding of just how the comments forms should work. they're being used as feedback for someones visit to the venue, so not as a comment on a post like normal wordpress installations. the comments form looks custom, but i think its fairly standard and it definitely uses the standard wp-comments-post.php page to add them to the db.                           <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" name="commentform" id="commentform">
                     <?php if ( is_user_logged_in() ) : ?>                          Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out »                          <?php else : ?>                          <input value="Name" type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />                     <input value="Email Address" type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />                     <input style="display:none" type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />                          <?php endif; ?>

                         Comment :                         <textarea style="float:left" name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea>                         Submit                         <?php comment_id_fields(); ?>                         <?php do_action('comment_form', $post->ID); ?>                         <input type="hidden" name="comment_post_ID" value="<?php echo $post->ID; ?>" />
                 </form>      so user submits a comment, this hits the comments-post.php page which then redirects the user to a news item. its the last bit i dont understand and it feels wrong. i would have thought it would go back to the submitting page, and display the "thanks for submitting..." message. i know its possible to alter the redirect by amending the $location var in the following lines which are the last 3 of the wp-comments-post.php page.               $location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;     $location = apply_filters('comment_post_redirect', $location, $comment);          wp_safe_redirect( $location );[/code]      but the problem with that is you lose your info in POST and the thanks for submitting message never appears. it also feels like a hijack. so whats the way to get this working right? is it to load the comment form with the right variable for the redirect and then get that into POST the usual way (by being inside the form?)? if ive missed some glaringly obvious article on how to do this without reinventing the wheel please direct me to it.


Use Single Blog Post as Site Front Page Without Redirect

I am attempting to do something similar to the accepted answer on this question Is it possible to use a single custom post as the site front page My problem is that this implementation causes a redirect. So for example if I add the code below to twentyeleven functions.php on a default WordPress install, and then select the `Hello World` post from the `reading->front page` drop down my home url such as `mysite.com` will redirect to `mysite.com/?p=1`. So it is impossible to actually stay on the home page because of this redirect. Is it possible to avoid this redirect? If so, the solution below will be great for showing a post or custom post as the home page.               add_filter( 'get_pages', 'add_pages_to_dropdown', 10, 2 );          function add_pages_to_dropdown( $pages, $r ){         if ( ! isset( $r[ 'name' ] ) )             return $pages;              if ( 'page_on_front' == $r[ 'name' ] ) {             $args = array(                 'post_type' => 'post'             );                  $portfolios = get_posts( $args );             $pages = array_merge( $pages, $portfolios );         }              return $pages;     }


Why cant you place the Loop outside of the index.php?

This may sound like a stupid / noob question. But I'm curious to wonder as to why you can't insert the wordpress php loop functions outside into say a blog.php file but you can in a index.php file? For instance, when I try running all the loop code in say a blog.php file, and linking the pages up nothing shows. I've tinkered with the reading settings as well just to make sure nothing is off. However, when I move the loop php code into an index.php file the blog page will then display the pages. Am I missing something, or is there a way to insert the loop into a different .php file instead of the index? -Thanks,


New user Registration data imported into Page

Here's my goal....New users apply to use a site that I'm working on. When I get an application, I talk to them, and afterwards I approve them. From there, the information they supplied online is automatically imported into a page. The page can be edited by the user or any admin. The user can only edit their own page. Here's what I've done so far...I'm using Register Plus Redux to gather all of the additional information from the user that I need while they are registering for the site. This is done through the usual wp- login.php?action=register This works well. The user is 'unverified' when they initially apply online. I get the form, talk to them, and then I can approve them online. Everything works well in this area. From there I don't know how to get all of that information transferred over to the user's page. When I say page, I mean an actual 'Page' not their user account page. If you know of a good way without manually copying and pasting let me know. I'm then using Capability Manager Enhanced to stop the user from deleting or editing other pages. The only thing I also need in this area, is to allow the user to only have 1 page total. I know this is a lot so any help with any part of it would be greatly appreciated! Thanks!


add span class inside wp_nav_menu link anchor tag

I found examples adding a class to top level items, so we can display an arrow in menu items with sub-items, but is seems terrible to cope with the already built in WordPress classes, can't display the arrow with current and css hover, it just ruins all states. The current nav menu is like this `<li><a>Text</a></li>` Is there someway to add a `<span class="arrow"></span>` within the parent `<a></a>` tags instead? Example, Add ⇒ `<span class="arrow"></span>` inside ⇒ `<a/></a>` tags Thus ⇒ `<li><a>Text<span class="arrow"></span></a></li>` that is parent. The current code Adds the `<span></span>` tags outside the `<a></a>` tags that is parent               class My_Walker_Nav_Menu extends Walker_Nav_Menu {         function start_lvl(&$output, $depth, $args) {             $indent = str_repeat("\t", $depth);             if('primary' == $args->theme_location && $depth ==0){                 $output .='';             }             $output .= "\n$indent
\n";         }     }      Original question title edited from: " **add span class inside`<a>`**"


What is the condition to check if we are in admin or frontend? I want to add_action not in backend, but only in frontend.


Wordpress Plugin Dev: Using array for WP options

I am busy dabbling with writing a WP plugin and hitting a bit of a problem. I believe its best practice to store wp options to an array rather than individually which is great no probs. I have two pages. Page one which updates for example:               $xyz_options['api_user'];      $xyz_options['api_key'];      Page two which say has:               $xyz_options['site_bgcolor'];     $xyz_options['site_fontcolor'];      However when updating from either of the pages it empties the other pages settings when using the built in wordpress form building and so forth. I am wondering if I would be better breaking away from the built in methods would be best or is there another way using WP methods that I have missed. A quick example. Say I first set 'api_user' and 'api_key' with 1 and abc123. Then go to style page and update 'site_bgcolor' with #fff and 'site_fontcolor' with #000 it updates the colors but the api_user and api_key values vanish from the $xyz_options array pulled from wp_options. Hope that makes sense. Thanks guys in advance any pointers would be great.


Hook or function to upload media via url

I am working on image aggregation site. Is there a wordpress hook or function to upload media especially image if a url is provided to it? Rest I can do with wp_handle_upload function. Thanks


Allowing Yoast SEO plugin to track me

I've recently installed the WordPress SEO plugin by Yoast and it's asking me whether to allow it or not to track my blog? Seems like a stupid question on my part but I'm still new on the blogging arena. What do you guys think? What's the difference if I allow it to track me or not? Is there a mutual benefit for the two of us?


BuddyPress - Hook to Update Custom Profile Fields

I am working on custom app for a client that requires some extra fields in the user's profile. I have successfully created a registration page that saves the custom fields and now I need to do the same for the "Edit Profile" page. The function that I used to save the custom fields on registration is generic enough that I think I can use it for the update too. I cannot find the right hook to make it work, though. I have tried "profile_update", "edit_user_profile_update", and "personal_options_update" with no luck. Is there something that I am missing here?


Delete WordPress plugin Repository

I wanted to create a WP plugin. So I requested and my request was approved by WordPress.org But I don't want to develop that plugin anymore. How can I delete the repository forever or request its deletion.


WordPress Custom Superfish CSS Problem

The problem can be found here: http://themeforward.com/demo2/ Use my menu and navigate to Features > Shortcodes > Typography. Notice how the border ( `ul .sub-menu { border:1px solid #000 }` ) moves the third level menu item (typography) down one pixel. How do I get rid of that one pixel gap so that the third level menu item lines up correctly? Here is my CSS:               /*** 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: #EEE     }     .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 { border:1px solid #000 }     ul li .sub-menu a { color:#262626!important }     ul li .sub-menu a:hover { background:#EEE!important }


Not displaying any articles on a custom made file

I have created the file **latest.php** in the public_html so that when I go to **www.domain.com/latest.php** it will show me the latest articles. Sadly, nothing of the posts came up. Later, I will sort them with other ways (mostly based on custom fields). This is my **latest.php** file (I removed any styling for better understanding)               <?php include("wp-load.php"); ?>     <?php get_header(); ?>     <?php wp_head(); ?>          **AND HERE IS WHAT I COPY-PASTED FROM MY INDEX.PHP THAT IS WORKING**          <?php while (have_posts()) : the_post(); ?>              <a title="" href="<?php echo get_permalink(); ?>" ><?php the_title(); ?>          <?php endwhile; // End the loop ?>          <?php posts_nav_link(' · ', 'previous page', 'next page'); ?>      My question is how can I make it possible to show the latest articles with pagination? Should I use an entire different method for my task? If yes, which one? UPDATE header and other functions are working CORRECTLY. It just not shows the posts.


How to create a subdomain for mobile?

I have a site, I'd like to create a subdomain of it for mobile presentation.   1. Both websites will show the same posts and custom posts. (shared database)   2. Each website will have different pages that will display those posts differently. Because of #2, I can't just use a theme switcher, I really need to design an entirely new website from the ground up for mobile, but using a shared database. How can I achieve this? This seems to me such a basic question, but I can't find answers anywhere. All I get referenced to is Multisite (I'm not trying to create a network)and WP- Touch (might be useful, but I need more than just switching a theme). Anyone know the steps needed? Any tutorials I've not found in my days of scouring the web for answers? As a side note, I've developed the main site with heavy usage of Toolets "Types & Views" and it's awesome. I have an incredibly complex main website. My goal is to create a very customized, stripped down version of that site for mobile. Other thoughts: I don't need to map page-for-page, since the pages on each site will be very different. I'll look to auto-detect for mobile and also allow switching between, but each time it can land on the requisite home pages. I just need to know how to connect 2 domains to 1 database.


What's the best way to detect referrer?

I've been searching for some WP specific way to detect any referrer. Have an idea? I know how to do that in PHP but I just want to know if there's some WP function to do that? **EDIT:** here is what I 'm trying to test =>               $referer = wp_get_referer();     if (  strpos($referer ,'http://wordpress.org') !== false ) echo 'you come from wordpress.org';


How to create different navigation for registered users in WooThemes Canvas?

I'm building a website with wordpress and the Canvas Theme (from WooThemes). I'm using the Top navigation for displaying items when a user is logged in. When the user is not logged in, you can see only 'become a member' and 'login'. When the user logins, he/she sees another navigation with other menu items. I thought of the following solution:   1. register a new navigation.   2. apply a hook which checks if a user is logged in or not   3. According to the result, apply the navigation for registred users, otherwise show other. I put this code in my _functions.php_ :               add_action( 'init', 'register_top_menu_myisa', 10 );          function register_top_menu_myisa() {         $menus = array(                     'top-menu-myisa' => __( 'Top Menu MyISA', 'woothemes' )                 );         register_nav_menus( $menus );     }          add_action( 'woo_top', 'custom_top_navigation', 10 );          function custom_top_navigation() {         if ( function_exists( 'has_nav_menu' ) && has_nav_menu( 'top-menu' ) ) {                  if(is_user_logged_in()) {                 $top_menu = 'top-menu-myisa';             } else {                 $top_menu = 'top-menu';             }              echo '
';         echo '
';         echo '
' . woo_get_menu_name( $top_menu ) . '
';         wp_nav_menu( array( 'depth' => 6, 'sort_column' => 'menu_order', 'container' => 'ul', 'menu_id' => 'top-nav', 'menu_class' => 'nav top-navigation fl', 'theme_location' => $top_menu ) );         echo '
';         echo '
';         }     }      The first function registers the new navigation. The second function contains the logic for deciding which top navigation should be displayed. **However: when I look at my site, it displays both menu's (the one for non logged in users and the one for logged in users)** ![Two navigation menu's displayed](http://i.stack.imgur.com/2WPD1.jpg) **How can I modify the code so that it displays one top navigation menu, based on if the user is logged in or not?**


How do I turn a post thumbnail into a background image?

I believe the answer o this question was posted on this page, but it is still not clear to me. The snippets are scattered all over the discussion and several glitches happen when I implement them.


if conditional in sidebar plugin Password content shortcode

I have this code [][/] on page and work perfectly! so i want now if i can in sidebar check if the form is properly completed on the page and then will echo some word in sidebar. for example something like this in sidebar:               if (isset($_POST['csp_submit'])) {     if ($_POST['csp_input'] == $password AND $password != '') {     echo 'password is corect and echo some words';     }     else     {     echo 'password is wrong';     }     }     else     {     echo 'you must enter pasword on page';     }      https://wordpress.org/plugins/password-content-shortcode/


How to change permalink on post click on post listing page

I have a posts listing page, my requirement is that I want to change the url on the click of the post and expand the post to full detail. I am not sure if this can be done without refresh. Any ideas how this can be done?


can't make jQuery work (change image on time interval)

I don't get it why jQuery function is not working. I read on the interned how to load jQuery in wordpress, but with no success. Can anyone help me? What I did so far: I've put this in header.php inside tags:               <?php wp_enqueue_script("jquery"); ?>          <?php wp_head(); ?>      <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/wp-includes/js/jquery/slideshow1.js"></script>      css styles used for jquery:                #gallery1{      float:right;      width:400px; /* Set your image width */      height:300px; /* Set your image height */      }      #gallery1 img{     position:absolute;     z-index:8;             }        #gallery1 img.active{     z-index:10;       }      #gallery1 img.last-active{      z-index:9;       }      html code: slideshow1.js:               function slideSwitch() {     var $active = $('#gallery1 IMG.active');          if ( $active.length == 0 ) $active = $('#gallery1 IMG:last');          var $next =  $active.next().length ? $active.next()         : $('#gallery1 IMG:first');          $active.addClass('last-active');          $next.css({opacity: 0.0})         .addClass('active')         .animate({opacity: 1.0}, 1000, function() {             $active.removeClass('active last-active');         });      }           $(function() {      setInterval( "slideSwitch()", 5000 );      });      I read that I need to change $ to something else, like 'jQuery'. I tried that, but with no luck too. Can anyone help me?


What's the best approach to do this?

I want to start a new site where I want the main page to be a static page showing information about myself, a kind of resumee without personal details. Then, there would be a `site.com/blog/` where I occasionally write to demonstrate the skills listed on the static page. Finally, I want all of this to be in English and Spanish. * * * So far, I changed the static front page to "About me" and then I created a new empty page "Blog", and chose it as posts page. When I click on "Blog", I get to the posts page but the URL looks like `/?page_id=11`. I would like it to look as I said before (`/blog/`). About the language, I see there are multiple plugins that translate the content. I'm interested in write it by myself, and the only plugin that seems to allow this is qTranslate, which doesn't work with the latest WP version. The only idea that comes to my mind is to do two separate installations on `site.com/en` and `site.com/es`. What else could I do?


Query Custom Post Types by date (custom field) range

I've seen similar questions and solutions, but so far I couldn't apply it to my code. The following code (functions.php) works perfectly fine:                  if( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'turniere' )     {         $query->set('orderby', 'meta_value_num');           $query->set('meta_key', 'date_start');           $query->set('order', 'ASC');          }        Now I want to add a sort of date range. This is the "best" I've got so far:               if( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'turniere' )     {         $query->set('orderby', 'meta_value_num');           $query->set('meta_key', 'date_start');           $query->set('order', 'ASC');         $query->set('meta_value', '20140520');         $query->set('compare', '>=');         $query->set('type', 'NUMERIC');     }         But it doesn't work, the page just says "no posts available". I've tried different combinations of each parameter (meta_value with or without ', different compare methods and every possible type). 'date_start' is stored as yyyymmdd. I use the plugin "advanced custom fields" to set the date in each post. Any help is much appreciated. :)


Excerpt is only getting shown for first post

I'm using the following code in my category.php file. I want it to show my custom post type 'Products' the thumbnail and an excerpt. At the moment it's showing the post title, the thumbnail for all the posts. However it's only showing the excerpt for the first post.               <?php     /*     Template Name: Category     */     ?>     <?php get_header(''); ?>                                 <?php /* Products sidebar */         if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('product_sidebar') ) : ?><?php endif; ?>
     <?php if ( function_exists('yoast_breadcrumb') ) {         yoast_breadcrumb('
','
');     } ?>

            <?php          if (!category_has_children()) {?>     <?php foreach(get_the_category() as $category) {     $cat = $category->cat_ID; }?>     <?php query_posts('post_type=Product&cat=' .$cat .'&order=ASC'); ?>                 <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?><?php the_post_thumbnail(array(100,100)); ?>                 <?php the_excerpt(); ?>
                         <?php endwhile;?>             <?php endif; ?>      <?php get_template_part('loop', 'index');     } else {?>

     <?php      $cat_id = get_query_var('cat');     $catlist = get_categories('hide_empty=0&child_of=' . $cat_id);     echo "
";     foreach($catlist as $categories_item)     {     echo '
term_id ) . '" title="' . sprintf( __( "View all products in %s" ), $categories_item->name ) . '" ' . '>' . $categories_item->name.'
 ';         echo '
'. $categories_item->description . '
';     }     echo "
";     }     ?>

         <?php get_footer(); ?>      This is in my functions.php as well               //Display product categories     function category_has_children() {     global $wpdb;     $term = get_queried_object();     $category_children_check = $wpdb->get_results(" SELECT * FROM wp_term_taxonomy WHERE parent = '$term->term_id' ");          if ($category_children_check) {               return true;          } else {               return false;          }     }      Does anyone know why? **What i'm trying to achieve:** My main category page on my site is 'Products'. On this page it displays child categories of the parent category. Going on to a child category page will either display more child categories, or if there isn't any, it's displays my custom post types 'Product'. The code i'm using is saying. If the Category has children then display them else display Products. **Update:** I've been experimenting and found something out. Using the following code and a different custom post type 'News', it displays the excerpt for all posts.               <?php query_posts(array('post_type'=>'News')); ?>                 <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_time('j M. Y'); ?><a href="<?php the_permalink(); ?>"><?php the_title(); ?>             <?php the_excerpt();?>
                <?php endwhile;?>             <?php endif; ?>       If i change 'News' to 'Product' the excerpt only displays for the first product created. The only difference i can think of between these two custom post types is 'News' is a post type and 'Product' is a page type. I don't know why this isn't working. Also i haven't written an excerpt for either of them, so the excerpt is automatic from Wordpress.


how can I remove the sidebar from my wp homepage

What's the best practice when it comes to **removing the sidebar on the wordpress homepage**? I'm using wp Version 3.2.1 and Skeleton Child Theme 1.6


How can I redirect foreigners by IP to other URL in WordPress?

I want that visitors out of my country would be redirected to www.mysite.com/en. How I can do this in Wordpress?


Display attachments by ID in a wp.media frame

I'm trying to use the new wp.media uploader frame for an app I'm building. I've read up a lot on other questions, blog posts, etc etc. The code I pasted below is working already quite fine and even does some extra stuff that I left in for reference in case it's useful to anyone. But there is one modification I'd like to bring to it: when the frame is opened, **I want it to filter the "media library" display to only show attachment defined by a list of IDs that I provide.** Here is my current code:               // Uploading files      var file_frame;           $('.upload_attachments_button').on('click', function( event ){          event.preventDefault();          // If the media frame already exists, reopen it.     if ( file_frame ) {       file_frame.open();       return;     }          // Create the media frame.     file_frame = wp.media.frames.file_frame = wp.media({       title: jQuery( this ).data( 'uploader_title' ),       button: { text: jQuery( this ).data( 'uploader_button_text' ) },       library : { type : 'image' },       multiple: true  // Set to true to allow multiple files to be selected     });             // When frame is open, select existing image attachments from custom field     file_frame.on( 'open', function() {          var selection = file_frame.state().get('selection');     var attachment_ids = jQuery('#attachment_ids').val().split(',');          // This is my attempt at showing only attachment with ID 275 --> but doesn't work!     file_frame.state().set( 'library', media.query({ id: 275 }) );          attachment_ids.forEach(function(id) {       attachment = wp.media.attachment(id);       attachment.fetch();       selection.add( attachment ? [ attachment ] : [] );     });      });            // When images are selected, place IDs in hidden custom field and show thumbnails.     file_frame.on( 'select', function() {          var selection = file_frame.state().get('selection');          // Place IDs in custom field     var attachment_ids = selection.map( function( attachment ) {       attachment = attachment.toJSON();       return attachment.id;     }).join();     if( attachment_ids.charAt(0) === ',' ) { attachment_ids = attachment_ids.substring(1); }     $('#attachment_ids').val( attachment_ids );               // Show Thumbs     var attachment_thumbs = selection.map( function( attachment ) {       attachment = attachment.toJSON();       if( attachment.id != '' ) { return '<img src="' + attachment.sizes.thumbnail.url + '" id="id-' + attachment.id + '" />'; }     }).join(' ');     $('#images-feedback').show();     $('#thumbs').html(attachment_thumbs);          });          // Finally, open the modal     file_frame.open();     });                // Place selected thumbnail ID into custom field to save as featured image       $(document).on('click', '#thumbs img', function() {      $('#thumbs img').removeClass('chosen');      var thumb_ID = $(this).attr('id').substring(3);      $('#wpuf_featured_img').val(thumb_ID);      $(this).addClass('chosen');      });      I'm attempting to filter the media library display as seen here, but it gives no results:               file_frame.state().set( 'library', media.query({ id: 275 }) );      Does anyone know how to write the syntax?


Permalinks: site.com/post-tite vs site.com/post-id/post-title for SEO and Speed

What are the differences, in terms of overall "work" required by the PHP processor to retrieve a page using these two permalinks settings:               /%post_id%/%postname%/      vs               /%postname%/      The second example has been widely adopted and used for the "SEO" benefits of having a clean, keyword friendly URL. The first example, which feeds WordPress the post id, is thought to be more efficient on the PHP processor since it does not have to look up the post-id from the post-title. This should not be an issue on smaller sites, the thinking goes, but on larger sites, it could play a significant role. The first example has been suggested as a happy medium between efficiency and overall site speed and SEO. Is this true?


How to show Home Page link in Wordpress Menu and how to add an icon to this?

I tried with this code:                 function home_page_menu_args( $args ) {     $args['show_home'] = true;     return $args;     }     add_filter( 'wp_page_menu_args', 'home_page_menu_args' );         but gives me this error: `Error 404 - Not Found`   I would like that when I click on "Home Page" menu appears the recent posts.   And I would like to place an **icon** instead of "Home Page" writing.   Thank you!


Targeting specific Page Template for sidebar page

Currently, there is a sidebar dedicated to all posts, and one for all pages. What I would like to do is target specific page templates to display sidebars for each template.               if(is_front_page())                 {                   if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Blog Sidebar") ) :                   endif;                      }                 else if(get_post_type($post) == "post" || is_search()  )                 {                   if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Blog Sidebar") ) :                   endif;                      }                 else if((get_post_type($post) != "post" && get_post_type($post) != "page") || get_post_type() == "")                 {                   if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Portfolio Sidebar") ) :                   endif;                      }                 else if(get_post_type($post) == "page" || is_author() || is_404() )                 {                   if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Page Sidebar") ) :                   endif;                      }      So instead of posting "Page Sidebar" for all of the pages. I would like to target, for example, the products.php template so that I can put a specific sidebar for those pages. I have added into functions, additional dynamic_sidebars but I need to find a way to target them on this sidebar.php. IF you need more info please let me know


Which jQuery packages are included in Wordpress 3.1.2?

I haven't found a document, except this one, that says which jQuery packages are included by wordpress. Thus, I don't know if I should add jQuery to my header.php or not. The link above, doesn't state the version of the libraries included nor the wordpress version that this applies to. Should I load jQuery UI manually?


How to use an associative array in post__in with WP_Query?

I have stored user favorite posts in the `user_meta` table of WordPress. The data is stored in a format, for example `a:1:{s:8:"post-134";s:3:"134";s:8:"post-136";s:3:"136";}`. How can I get this in the form of an array like `array( 134, 136 )` so that I can use it in the query below.               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $query = new WP_Query( array(          'paged' => $paged,          'post_type' => 'post',          'post__in' => I WANT AN ARRAY HERE      ) );     if ( $query->have_posts() ) :          while ( $query->have_posts() ) : $query->the_post();             get_template_part( 'content', 'fav' )         endwhile;         wp_pagenavi();         wp_reset_postdata(); else :             ?>
You have not faved any post.
<?php     endif;


Fatal Errors on pluggable.php

I was looking to change the "Wordpress" name in all of my sent mail. In the past I have customized my Wordpress backend to display my desired email. But I have downloaded a new plugin that has altered the email name field. I went to attempt to change it again but this time in the pluggable.php template file. However things did not go as planned now I have a fatal error: Fatal error: Call to undefined function _fill_user() in /home/content/61/7791761/html/Portal/wp-includes/pluggable.php on line 199 I need to fix this seems as though it has something to do with the $wpdb variable               /**      * Retrieve user info by a given field      *      * @since 2.8.0      *      * @param string $field The field to retrieve the user with.  id | slug | email | login      * @param int|string $value A value for $field.  A user ID, slug, email address, or      login name.      * @return bool|object False on failure, User DB row object      */     function get_user_by($field, $value) {     global $wpdb;          switch ($field) {         case 'id':             return get_userdata($value);             break;         case 'slug':             $user_id = wp_cache_get($value, 'userslugs');             $field = 'user_nicename';             break;         case 'email':             $user_id = wp_cache_get($value, 'useremail');             $field = 'user_email';             break;         case 'login':             $value = sanitize_user( $value );             $user_id = wp_cache_get($value, 'userlogins');             $field = 'user_login';             break;         default:             return false;     }           if ( false !== $user_id )         return get_userdata($user_id);           if ( !$user = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->users WHERE $field = %s", $value) ) )         return false;          _fill_user( $user );          return $user;     }     endif;


Sorting the portfolio by an ACF?

I have an advanced custom field attached to every item in my portfolio (its another date) and I want to sort my portfolio by this field. Is this possible? I was hoping you could just swap the orderby for the custom name (which is date_sold) in:               [portfolio items="40" order="DESC" orderby="date_sold" columns="4" generate_thumbnail="true" show_title="true" show_excerpt="true" show_filters="true" filter_display="text" show_pagination="true" show_item_categories="false" link_behavior="detail_page" show_all_text="Show All" paginate="yes" categories="recent"]      Thanks for any help!


What is the right way to make custom main page?

I am making a custom theme and I want the main page to be a gallery, not a blog,   is it right to change `index.php` to a gallery page (content wise) or should I use another page?


When enqueing a stylesheet, is it possible to remove the type attribute?

I'm updating my self-built theme to HTML5, and easily made a number of changes already. My theme's sole stylesheet is added to the page head via `wp_enqueue_style` in the `functions.php` file, as follows:               function gridded_enqueue_styles() {         wp_enqueue_style('style', get_template_directory_uri() . '/style.css', array(), null, 'all');     }     add_action('wp_enqueue_scripts', 'gridded_enqueue_styles');      The resulting markup is:               <link rel='stylesheet' id='style-css'  href='http://grantpalin.com.dev:81/wp-content/themes/gridded/style.css' type='text/css' media='all' />      The stylesheet is loaded, the page renders, all good. However, the HTML5 spec indicates that the `type` attribute is no longer needed for the `link`, `style`, and `script` elements. Looking through the codex reference, I don't see a way to alter or remove the `type` attribute. Can this even be done? The obvious workaround is to hard-code the stylesheet reference in my `header.php`, but that's avoiding the benefit of the enqueue functionality.


Child pages on hierarchical Custom Post Types 404s

I've been working with Custom Post Types lately and haven't had any major problems. This time I'm trying something new. I want to create a CPT which basically works like Pages, with page hierarchy. The real thing is in Swedish so I'll use "Books" as an example on how I would like it to work. So first I create my new post type:               define('BOOKS_HTTP_PATH', WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));     function add_custom_post_type_books() {         register_post_type( 'lpm-books', array(              'labels' => array(                  'name' => 'Books',                 'singular_name' => 'Book',                 'add_new' => 'New book',                 'add_new_item' => 'Add new book',                 'not_found' => 'No books found' ),             'public' => true,              'show_ui' => true,             'show_in_nav_menus' => true,             'menu_icon' => BOOKS_HTTP_PATH . 'images/books-icon.png',             'menu_position' => 20,             'hierarchical' => true,             'rewrite' => array( 'slug' => 'books'),             'capability_type' => 'page',             'supports' => array('title','editor','page-attributes'),             'query_var' => '',             '_builtin' => false,             )          );     }     add_action( 'init', 'add_custom_post_type_books' );      In my case I have a specific name for the CPT, lpm-books (might sound weird in this example but as I said earlier I'm doing this in Swedish but I'd like the post type name in English if possible). I set the rewrite slug to books for my permalinks and I add `'hierarchical' => true` and `'supports' => 'page- attributes'` to make the Attribute meta box available. In Admin->Books the view would be something like this:   * Book 1      * Chapter 1     * Chapter 2   * Book 2      * Chapter 1     * Chapter 2     * ... So, I add a regular page called My books (slug: my-books) to have a "start page" which describes my collection of books. The url is `http://www.example.com/my-books/`. On that page I list all my added books and their chapters. Works perfectly if I click on Book 1 (or Book 2). The url is `http://www.example.com/books/book-1/`. But if I want to view a chapter (url: `http://www.example.com/books/book-1/chapter-1`) I get 404'd. My permalink structure is: `/%category%/%postname%/` I really can't figure out why the custom child pages (posts) 404's. Since my regular start page "My Books" slug doesn't clash with either the CPT name or the rewrite slug I guess I'm all out of thoughts atm. Note: I've also tried to remove `'rewrite' => array( 'slug' => 'books')` but I still get 404 on the "child posts". How do you guys do when creating hierarchical CPTs? Can I make this work or do I need to rethink the structure? Thank you!


Validate data on attachment_fields_to_save

I'm very glad that there is such a dedicated website for WP. My problem is data validation upon saving attachment fields. I have added many custom fields to attachment/media library dialog, most of them are marked as mandatory. (Ex. `$form_fields["some_custom_field"]["required"] = true;`) But this just adds the class, but no validation or checking is done on WP side, so I want to check them myself with functions attached to `attachment_fields_to_save` filter. I can check and so on, BUT THE QUESTION IS: How to validate these fields, so if validation do not pas - WP returns an error in it's regular style, just like in registration form if you fill bad email. In registration process in `register_post` action you can do this `$errors->add('some_error_code', "<strong>Klaida</strong>: Nenurodėte įmonės kodo");` and it will not save data and return to visitor an error. I want that in saving attachment form :D


Hard-coding custom menu elements for menu manager

I realize that one can add custom links through the menu manager but is there a way to manually create such components through the functions.php file? More specifically, one example here relates to a situation I currently have where I created a custom post type for "events" meaning all associating posts show up like domain.com/events/events-name-abc/ and where the main events page domain.com/events/ is just defined through a custom post type template. As such, when using the admin menu manager interface there is no way for a user to see this main "events" page as an option to add to his menu. Ideally, I am looking for some example code I can add to my functions.php file which would allow me to define/code in such items manually (with the optional ability to pre-defining custom attributes like a predefined class) and have any of these elements automatically added as options to any of the menu manager meta-boxes or places into a custom meta-box. Any plugins or code anyone is aware of which extend the menu manager to allow for such functionality?


Adding all sub-pages to the menu manager

Is there some simple way which would allow one to add a page to a menu (through the menu manager interface) and be able to define if the inclusion of this item should automatically add all subpages up to a specific depth? Essentially, the logic I am trying to use here applies to a user adding a new page with content then associating this page as a sub-page of another and by doing so this page automatically shows up on the fronted whenever a specific custom menu is requested where such logic was added. Not sure if the logic of the menu manager allows for such dynamic list capabilities to take place.


Add a class to posts in increments of 2

Is it possible to add specific classes to posts/pages in a query in increments of 2? For example   * Post 1   * Post 2   * Post 3 (add custom class)   * Post 4 (add custom class)   * Post 5   * Post 6   * Post 7 (add custom class)   * Post 8 (add custom class)   * Post 9 I don't mind using jQuery if needs be.


Permalinks so that one custom post type appears to be a child of another, not working

Currently I have two post types, "products" and "products-data" they are separate post types; however, for all intents and purposes products-data is a child post of products. The relation is established via a meta element for products-data "parent" that will have a products post's post ID. The "products-data" posts are created only one way --- a user clicks on a product in the products post type and enters data into a popup window. This uses wp_insert_post to create a products-data post and it adds a meta element "parent" with the value of the "products" post's ID. This data is displayed via a modal window if a user clicks on the product type. I am trying to have their permalinks as follows: Permalink schema for a "products" post (for this example this post's ID is 123): http://example.com/products/new-product-1/ Permalink schema for a "products-data" post that has a meta key/value of parent=>123 http://example.com/products/new-product-1/information-product-data/ Here is the code I am using to register the post type and create rewrite rules; however, after adding this code and flushing my rewrite rules (settings>permalink) it works fine for a "products-data" post type BUT when I try to access a "products" post it displays the homepage for the WordPress site (N.B. this is not via redirect, the URL bar displays the "products" URL). I am wondering if the issue is that the two permastructs appear that they can collide with each other, however there will never be an instance of this in practice due to the permastructs schema. Any help would be greatly appreciated on how to resolve this. Code:               add_action ( 'init', 'register_product_post_types' );     add_action ( 'init', 'products_add_rewrite_rules' );     add_filter ( 'post_type_link', 'products_permalinks', 10, 3 );          function register_product_post_types() {             register_post_type( 'products',             array(                     'supports' => array( 'title', 'editor', 'author',"custom-fields", "thumbnail", "excerpt", 'comments' ),                     'labels' => array(                     'name' => __( 'Products' ),                     'singular_name' => __( 'Products' )                 ),             'public' => true,             'has_archive' => false,             'rewrite' => FALSE,             )         );              register_post_type( 'products-data',             array(                     'supports' => array( 'title', 'editor', 'author',"custom-fields" ),                     'labels' => array(                     'name' => __( 'Products-Data' ),                     'singular_name' => __( 'Products-Data' )                 ),             'show_in_menu' =>'edit.php?post_type=products',             'public' => true,             'has_archive' => false,             'rewrite' => FALSE,             )         );     }               function products_add_rewrite_rules() {         global $wp_rewrite;         $wp_rewrite->add_rewrite_tag('%products%', '([^/]+)', 'products=');         $wp_rewrite->add_rewrite_tag('%products-data%', '([^/]+)', 'products-data=');         $wp_rewrite->add_rewrite_tag('%parent%', '([^/]+)', 'parent=');         $wp_rewrite->add_permastruct('products-data', '/products/%parent%/%products-data%', false);          }          function products_permalinks($permalink, $post, $leavename) {         $no_data = 'no-data';         $post_id = $post->ID;         if($post->post_type != 'products-data' || empty($permalink) || in_array($post->post_status, array('draft', 'pending', 'auto-draft')))             return $permalink;         $data = sanitize_title(get_the_title(get_post_meta($post_id, 'parent', true)));         if(!$data) $data = $no_data;         $permalink = str_replace('%parent%', $data, $permalink);         return $permalink;     }


Add .html extension to custom post type taxonomies

I want to have the `.html` extension in the custom post type taxonomy urls. My custom post type taxonomy it is called "`product_cat`". I will need something like: www.mydomain.com/product-category/product-category-name.html Tried this one, inserting in `functions.php`, without success:               add_action('init', 'add_html_ext_to_custom_post_type_taxonomies');     function add_html_ext_to_custom_post_type_taxonomies() {         add_rewrite_rule('^product_cat/([^/]+)\.html', 'index.php?product_cat=$matches[1]', 'top');     }      **Further tries:** Also I've used the Custom Post Type Permalink plugin and have played around line 559. Replaced the code from line 559 to line 561 with the next one:               $termlink = str_replace( $wp_home, $wp_home, $termlink );     $str = rtrim( preg_replace("/%[a-z_]*%/","",get_option("permalink_structure")) ,'/');//remove with front     return str_replace($str, "", $termlink.'.html' );      This will return the `.html` in the taxonomy view page url, but it gives a 404.


Auto Redirect after login

In multisite this code redirect users (authors) to /wp-admin/post-new.php after the login ....but also redirects me (super admin) how can I prevent this?               function primary_login_redirect( $redirect_to, $request_redirect_to, $user )     {         if ($user->ID != 0) {             $user_info = get_userdata($user->ID);             if ($user_info->primary_blog) {                 $primary_url = get_blogaddress_by_id($user_info->primary_blog) . 'wp-admin/post-new.php';                 if ($primary_url) {                     wp_redirect($primary_url);                     die();                 }             }         }         return $redirect_to;     }      add_filter('login_redirect','primary_login_redirect', 100, 3);


How to Order a list of taxonomies? orderby?

I am using this code to fetch a list of child taxonomies. I want the order displayed to be alphabetical, but it is not! Any help in figuring out how to do it? I guess ordering it before returning it will be most optimal? thanks               <?php     $termID = 4;     $taxonomyName = "location";     $termchildren = get_term_children( $termID, $taxonomyName );          echo '
';     foreach ($termchildren as $child) {     $term = get_term_by( 'id', $child, $taxonomyName );     echo '
name, $taxonomyName ) . '">' .   $term->name . '
';     }     echo '
';     ?>


How to setup LDAP authentication with WP multisite

I would like to set up my WP multisite install so that it will authenticate with our LDAP server. I had this working using the WPMU LDAP authentication plugin, but it no longer appears to be working with WP 3.9.1 and MySQL 5.3. Other plugins I've tried seem to call for the plugin to be configured on every site, and I would prefer for something to work over the entire network. Can anyone explain how to go about setting up my WP multisite installation running WP 3.9.1 to authenticate over LDAP?


CPT, meta-data, url parameter

does someone could point me a lecture that could explain me how to create some "filter" passed by pretty link ? Let me explain my self, I have a custom post type called **"spectacle"** and I have a meta_key who contain an array of dates for this spectacle. I know how to extract my date, and filter them if I give explicitly some filter to my display, my problem is not coming from there, what I'm trying to achieve, is to access > http://myurl.com/spectacles (show upcoming spectacles - **already done** ) > http://myurl.com/spectacles/2014 (show all 2014 spectacle) > http://myurl.com/spectacles/2014/01 (show all spectacle from january 2014) > http://myurl.com/spectacles/2014/01/01 (show all spectacle from january 1st > 2014) http://myurl.com/spectacle/name-of-the-spectacle (show this spectacle > - **already done** ) All i need to is a way to enable theses permalink and to extract theses parameters than i'll be able to do what I want, I already have my filtering functions. This is what i've done so far :               // Register Custom Post Type     function build_cpt() {     $labels  = array(         'name'               => _x( 'Programmation', 'Post Type General Name', 'mlog_lang' ),         'singular_name'      => _x( 'Spectacles', 'Post Type Singular Name', 'mlog_lang' ),         'menu_name'          => __( 'Programmation', 'mlog_lang' ),         'all_items'          => __( 'Tous les spectacles', 'mlog_lang' ),         'view_item'          => __( 'Afficher ce spectacle', 'mlog_lang' ),         'add_new_item'       => __( 'Ajouter un spectacle', 'mlog_lang' ),         'add_new'            => __( 'Ajouter un spectacle', 'mlog_lang' ),         'edit_item'          => __( 'Modifier un spectacle', 'mlog_lang' ),         'update_item'        => __( 'Mettre à jour ce spectacle', 'mlog_lang' ),         'search_items'       => __( 'Rechercher un spectacle', 'mlog_lang' ),         'not_found'          => __( 'Aucun spectacle trouvé', 'mlog_lang' ),         'not_found_in_trash' => __( 'Aucun spectacle dans la corbeille', 'mlog_lang' ),     );          add_rewrite_tag( '%event-year%', '(\d{4})' );     //add_rewrite_tag( '%event-month%', '(\d{2})' );     //add_rewrite_tag( '%event-day%', '(\d{2}|\d{1})' );          $rewrite = array(         //'slug'       => 'spectacles/%event-year%/%event-month%/%event-day%/',         'slug'       => 'spectacles/%event-year%/',         'with_front' => true,         'pages'      => true,         'feeds'      => true,     );     $args    = array(         'label'               => __( 'programmation', 'mlog_lang' ),         'description'         => __( 'Liste des spectacles', 'mlog_lang' ),         'labels'              => $labels,         'supports'            => array( 'title', 'editor', 'revisions' ),         'taxonomies'          => array(),         'hierarchical'        => false,         'public'              => true,         'show_ui'             => true,         'show_in_menu'        => true,         'show_in_nav_menus'   => false,         'show_in_admin_bar'   => false,         'menu_position'       => 4,         'menu_icon'           => 'dashicons-groups',         'can_export'          => true,         'has_archive'         => true,         'exclude_from_search' => false,         'publicly_queryable'  => true,         'rewrite'             => $rewrite,         'capability_type'     => 'page',     );     register_post_type( 'programmation', $args );      Now I can access : > http://myurl.com/spectacles/2014 but it shows the home page instead of archive-programmation.php And I can't access : > http://myurl.com/spectacles/name-of-the-spectacle


Multiple orderby parameters in pre_get_posts() action

Referencing @Otto's response to a question I also had about ordering by multiple fields, here is what he said: > Can't do it with a naive WP_Query. Use the posts_orderby filter to add your > own ordering string.               function my_order($orderby) {          global $wpdb;          return "{$wpdb->posts.post_author} ASC, {$wpdb->posts.post_date} DESC";      }      add_filter( 'posts_orderby', 'my_order' );           $blah = new WP_Query(...);           remove_filter( 'posts_orderby', 'my_order' );       > -Otto This appears to be the way it would be done in a new call to WP_Query --> how would I go about this same thing in a `pre_get_posts()` action with two meta fields, with a default sort to?:               function mouldings_sort($query) {         if ($query->is_main_query() && is_tax(array('wood_types','profile_categories','combination_categories'))) {                  $query->set('meta_key', '_mouldings_dimensions_height');             $query->set('order', 'DESC');             $query->set('orderby','meta_value_num');         }          }     add_action('pre_get_posts','mouldings_sort');      I had previously tried simply adding in another meta field like so:               $query->set('meta_key', array('_mouldings_dimensions_height', '_mouldings_dimension_width'));     $query->set('orderby','meta_value_num');      with a default sortback of `title` as so:                $query->set('orderby','meta_value_num title');      but it doesn't look like `meta_key` can accept arrays and my `title` fallback goes back to Otto's original response on the matter. Any help would be a greatly appreciated. Thanks!


Adding WordPress colorpicker in widget settings

I want to add the WordPress default colorpicker in widget settings form. Here's what I'm trying: In my functions.php, I have this:               function widgets_scripts( $hook ) {         if ( 'widgets.php' != $hook ) {             return;         }         wp_enqueue_style( 'wp-color-picker' );                 wp_enqueue_script( 'wp-color-picker' );      }     add_action( 'admin_enqueue_scripts', 'widgets_scripts' );      In my widget file, I have this:               <script type="text/javascript">         jQuery(document).ready(function($) {             $('#<?php echo $this->get_field_id( 'color' ); ?>').wpColorPicker();         });     </script>     <input id="<?php echo $this->get_field_id( 'color' ); ?>" type="text" name="<?php echo $this->get_field_name( 'color' ); ?>" value="<?php echo esc_attr( $instance['color'] ); ?>" />      Using the above code, I can see the colorpicker "Select color" button, but it does not let me click it initially. It only lets me click after the widget is saved. I'm guessing that it is because of assigning the ID. If I try to use a css class name, it displays the button 2 times (I don't know why, even the class exists only once in a widget). This is what I see if I use class name: ![enter image description here](http://i.stack.imgur.com/GKdJo.png) Also i think class name will cause the problem if same widget is used multiple times. That's why I'm trying to use a dynamic ID for the input field.


How to add links under every posts? ( WHILE BUILDING PLUGIN not manually )

I want to use, change, add and delete the links that appears with every posts. (e.g. May 21, 2014| 1 Comment) If I'm not wrong these are called template tags. I can play with them manually by getting into the theme codes but is there any built in way of wordpress to handle them or is there a way to handle them while plugin building?


jquery code didnt run on my plugin

I use this to hook my scripts and styles to my plugin               add_action('admin_init', 'the_box_init' );          // Init plugin options to white list our options     function the_box_init(){         register_setting( 'the_box_options', 'the_box', 'the_box_validate' );         wp_enqueue_style( 'myprefix-style', plugins_url('theboxstyle.css', __FILE__) );         wp_enqueue_script( 'myprefix-script', plugins_url('theboxjs.js', __FILE__) ); //this hook my custom js, preferrably which contents almost my jquery codes.          }      however, the jquery codes doesn't work even in this simple codes (refer below)               $( document ).ready(function() {     alert("asdasd");     });       and only javascript did work.. what does suppose my implementation get wrong that jquery didnt work? im open in any suggestions, recommendations and idea's. Thank you in advance.


Disabling auto-resizing of uploaded images

Whenever I upload a large image, it gets resized to the width of the post. This will be a negative feature for comic reading sites. I need to display the full width images, which I can resize when I need during upload. If anything that can fix this issue?


Login redirect shows white page in firefox

I am developing a plugin which allows to link a local wordpress account to a two-factor authentication service. The login and linking flow works perfectly in Chrome and IE, but the redirects result in a white page in Firefox. Strangely, there is no error whatsoever, as all code is executed and a simple F5 refresh of the page shows the correct page. As you can see in the code below, I am only using a wp_redirect() once to trigger the authentication flow, which works and is not the problem. From there on it's Wordpress who handles all redirects and does so nicely in Chrome and IE but fails in Firefox               public function myplugin_callback() {         global $wp_query;              if ($wp_query->get('code')) {             $_SESSION['code'] = $wp_query->get('code');             $_SESSION['state'] = $wp_query->get('state');                  wp_redirect(site_url('wp-login.php', 'login'));             echo 'Please wait, logging in.';             exit;         }     }          public function myplugin_authenticate($user, $username) {         // do the authentication here         if (isset($_SESSION['code'])) {             /* get userdata via OAuth here */                  if (isset($userData['email'])) {                 $userSearch = get_user_by('email', $userData['email']);                      if ($userSearch) { // user exists                     $uuid = get_user_meta($userSearch->ID, 'myplugin_uuid', true);                     if ($uuid == $userData['uuid']) { // user is linked                         $user = new WP_User($userSearch->ID);                     } else { // user is not linked                         $_SESSION['myplugin-data'] = serialize($userData);                         $user = new WP_Error('denied', __('You already have an account with this email on this blog. Please log in to link this account with our service.'));                         remove_action('authenticate', 'wp_authenticate_username_password', 20);                     }                 } else { // user does not exist                     $user = new WP_Error();                 }             }             unset($_SESSION['code']);         } else { // local login             $userSearch = get_user_by('login', $username);                  if ($userSearch) {                 $uuid = get_user_meta($userSearch->ID, 'myplugin_uuid', true);                      if (!isset($_SESSION['myplugin-data']) && !empty($uuid) && !$this->myPluginHelper()->getlocalAuthAllowed()) {                     $user = new WP_Error('denied', __('Local login disabled. Please use myPlugin to log in.'), 'message');                     remove_action('authenticate', 'wp_authenticate_username_password', 20);                 } else {                     add_filter('login_redirect', array($this, 'save_myplugin_uuid'), 10, 3);                 }             }         }         return $user;     }          public function save_myplugin_uuid($redirect_to, $request, $user) {         if (isset($_SESSION['myplugin-data']) && is_a($user, 'WP_User')) {             $userData = unserialize($_SESSION['myplugin-data']);             update_usermeta($user->ID, 'myplugin_uuid', $userData['uuid']);             unset($_SESSION['myplugin-data']);         }         return $redirect_to;     }      I have Googled quite a deal, to no avail. Does anyone have an idea? Thanks Jeroen


WP_Query tax_query problem

When I call WP_Query with tax query or category__in, I get posts only from first category in array of requested categories.               $query = new WP_Query(         array(             "tax_query" => array(                 array(                     "taxonomy" => "category",                     "field" => "term_id",                     "terms" => array(1, 2, 3)                 )             ),             "posts_per_page" => -1         )     );      Here is sql query from $query->request:               SELECT wp_posts.*     FROM wp_posts     INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)     INNER JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id)     INNER JOIN wp_term_relationships AS tt2 ON (wp_posts.ID = tt2.object_id)     WHERE 1=1       AND (wp_term_relationships.term_taxonomy_id IN (1,                                                       2,                                                       3)            AND tt1.term_taxonomy_id IN (1)            AND tt2.term_taxonomy_id IN (1))       AND wp_posts.post_type = 'post'       AND (wp_posts.post_status = 'publish'            OR wp_posts.post_status = 'future'            OR wp_posts.post_status = 'draft'            OR wp_posts.post_status = 'pending'            OR wp_posts.post_status = 'private')     GROUP BY wp_posts.ID     ORDER BY wp_posts.post_date DESC      Results list only posts in category 1. What is wrong with my query?


Let me choose permalinks

I need to pick a permalink called 'mysite.com/1418', but wordpress keeps adding '-2' to the permalink. Normally this means i already have a page called the same that is in the trash or something. But that doesn't seem the case here. I tried resetting the permalinks in the settings this also doesn't help. How can i use numbers as page name permalink, without wordpress adding the '-2' to to permalink.


AJAX-login over https on a http page, is it possible?

I would like to a ajax login-form on every page. Most of the site's pages are served over http. The ajax-login request is over https. Everything works as expected if I am already on https and try to login, but I cannot get it to work if I am on http and want to login via the ajax-https call. The login credentials are verified but the correct cookies are never set. Is this possible to achive this, I have seen non-Wordpress sites do this? I found a simular question with no answer; How can I make an Ajax login form work with FORCE_SSL_ADMIN enabled? I would like to not have a separate login-page at all.


Custom taxonomy parent from another taxonomy

I've had a look around for this but nothing has came up (perhaps am not searching good enough?) but I'm trying to set a parent on a taxonomy which is loaded from another taxonomy. For example I have Car Makes and Car Models, when adding a new model I would like to select its parent (Car Make) not another parent within itself. Makes cannot have any parents, but can have unlimited children, models cannot have any children and there parent must be a make. Is this possible? Preferably without a plugin.               /* Makes */     $labels = array(     'name' => _x( 'Makes', 'taxonomy general name' ),         'singular_name' => _x( 'Make', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Makes' ),         'all_items' => __( 'All Makes' ),         'parent_item' => __( 'Parent Make' ),         'parent_item_colon' => __( 'Parent Make:' ),         'edit_item' => __( 'Edit Make' ),         'update_item' => __( 'Update Make' ),         'add_new_item' => __( 'Add New Make' ),         'new_item_name' => __( 'New Make' ),     );       register_taxonomy('makes', 'car', array('hierarchical' => false, 'labels' => $labels, 'query_var' => false, 'rewrite' => false, 'with_front' => false));          /* Models */     $labels = array(     'name' => _x( 'Models', 'taxonomy general name' ),         'singular_name' => _x( 'Model', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Models' ),         'all_items' => __( 'All Models' ),         'parent_item' => __( 'Parent Model' ),         'parent_item_colon' => __( 'Parent Model:' ),         'edit_item' => __( 'Edit Model' ),         'update_item' => __( 'Update Model' ),         'add_new_item' => __( 'Add New Model' ),         'new_item_name' => __( 'New Model' )     );     register_taxonomy('models', 'car', array('hierarchical' => true, 'labels' => $labels, 'query_var' => false, 'rewrite' => false, 'with_front' => false));      This question is slightly related: Show WordPress Custom Taxonomy Items Based On a Selected Item From Another Custom Taxonomy however I assume the parent/child elements are from one taxonomy? In my case they need to be two separate taxonomies.


Custom Taxonomy Archive URL rewrite

I would like to create an archive page with a list of my custom taxonomies that link to a page that shows posts with that taxonomy relationship. I registered my taxonomy like this:               register_taxonomy('my_taxo', array('my_custom_post'), array(                 'hierarchical' => true,                 'label' => 'my taxo'                 'show_ui' => true,                 'query_var' => true,                 'show_in_nav_menus ' => true                 )             );      What is the recommended way to create an archive page that can be visited at a url such as mysite.com/my_taxo or mysite.com/taxonomy/my_taxo. Ideally the template file that will be used would be `taxonomy-{taxonomy}.php`. Does this involve add_rewrite_rule? If so what might that look like?


/%post_name%/ or /%postname%/ in Permalinks?

In Settings-->Permalinks is there any difference between: checking Custom Structure and using: /%post_name%/ or /%postname%/ Are they both correct? Will they both work? Thank you. -Laxmidi


Posts are not showing up on particular category

On my website, post are not showing up when I navigate to               http://www.domain.com/category/category-name/      but on wordpress dashboard, I am able to see the actual number of post under that category. It is not getting displayed on website only. Also, when I am logged in to the wordpress dashboard and visit that category page,               http://www.domain.com/category/category-name/      I am not seeing the wp admin bar which used to show on top. but it is showing up on other pages.


Adding fields to the "Add New User" screen in the dashboard

I'd like to add the field "Company Name" to the add new user page in the admin panel. I've done quite a bit of searching and have been unable to find details on how to do this. I can easily add info to the profile page and registration with..                  function my_custom_userfields( $contactmethods ) {         //Adds customer contact details         $contactmethods['company_name'] = 'Company Name';         return $contactmethods;        }        add_filter('user_contactmethods','my_custom_userfields',10,1);      But no dice on anything else.


Making a 1140px wide header logo in the twenty-ten theme?

I've created a child theme that is a wide version of twenty-ten, and it is working for the most part. But I am struggling to make the header logo wider. You can see the work in progress here at http://7d7d.net The CSS that is not working is (it still shows as 980px):               #branding {         margin: 0 auto;         width: 1140px;     }      I can see that the generated html for the logo div is:

      And that header.php defines the logo like so:               <img src="<?php header_image(); ?>"       width="<?php echo HEADER_IMAGE_WIDTH; ?>"       height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />      But I can't see where to set `HEADER_IMAGE_WIDTH` and `HEADER_IMAGE_HEIGHT`. The CSS file is here: http://7d7d.net/wp-content/themes/twenty-ten- wide/style.css


Mini-Site Strategy

I'm working on a project to allow a number of mini-sites within a WordPress multisite installation. Here's how it's _supposed_ to function: The client has a large number of individual locations, each of which has their own website. All of these websites are sites within a large WordPress network to allow for centralized user and site maintenance. This part is working already. But each location has any number of clients and wants each client to have their own "mini-site" within the network. Essentially a new WordPress site, but housed underneath the location's site, URL, and administrator list. Users of the mini-site should only be able to use that mini-site, not the parent site, and not any other site on the network. As I've been working on this, I've come across two different ways to set this up. Both are somewhat complex: ### Multi-network Installation WordPress allows you to install several standalone networks with one codebase. It's like multisite, but on steroids. My first attempt at solving the above problem was to bury a bunch of multi-network functionality in the system. When you added a new client mini-site, you were actually adding a new site to a network "owned" by the parent site. This half-worked. You could create the sites just fine, but without deeper control over the server (my client asked for a plugin, something they can drop on the server without needing to give me SSH access) it was difficult to get the routing to work in Apache. Some of the new mini-sites would load, others would 404, others would redirect back to the parent site. The other problem was management. Though you could create as many mini-sites as you wanted (and could verify through phpMyAdmin that they existed), I had difficulty reading back out a list of the sites that were available. The other problem was database management. Every time you create a new site, you create 10+ new tables in the database. If the site will only ever have 1 or 2 posts/pages, this is overkill. ### Custom Post Type with Theme Override My new approach is to set up the clients as a custom post type. Then, users of the parent site can write new posts and check a field in a meta box to associate the content with a client (using a post-to-post relationship scheme). When you visit the page for the custom post type, WordPress overrides the display and presents a custom theme (a mod of P2) displaying posts associated with the custom post type. Not as many problems with scalability here, just in content management. I haven't quite figured out a way to allow filtering of content from one client to another (remember, content is associated with a CPT based on a meta field, so unless I build out another post management screen, it's hard to view "all posts for client-x"). My question: Which of these approaches is the best? Is there another approach I should consider that might be easier for the end user to work with?


the_posts filter been called multiple time

I have create an endpoint so I can do some checkout processing of my cart. Everything is working fine in sense that every thing is hooked up properly. Though I am having issue that to serve the content of my endpoint, I define the_posts filter, where if my "endpoint" is choosen than I check other query_vars and do the processing. It works for me for couple of project. However in this project, I need to mark my cart as paid and remove it from session. So, as usual under my the_posts filter/action function I define a switch and do the processing. But, when said page is called, cart was not getting marked. I debug and found that the_posts action function was called thrice on my page. and the first call did get it marked and clear session, but next call didn't find session value and hence it unmark the cart again. the three call I have on my page are   1. From wordpress URL rewrite module [I am guessing this] that it try to pick content or redirect them? [seems like a main_query as well]   2. I have a custom post type as news that I show in my side header for this I create a new WP_query object, but it still call the_post as it is in header.   3. My page content call where I actually needed it.   4. I have another call that is in footer recent post thing. but it doesn't matter for my purpose. in my the_post method I check for Query_var               global $wp_query, $wpdb, $cardcomm;     if(isset($wp_query->query_vars[cardcomendpoint]) ) { ... }      since all four call set this query var as true I am not sure how can I ensure that it is called for my purpose only. Any idea how to tackle this?


List Categories for Custom Post Types - WordPress

I'm using custom post types in WordPress 3.0 (now 3.0.1) to setup a custom directory system, but can't seem to find how to list out the categories under the custom taxonomy similar to how you'd use the `wp_list_categories` for normal posts. Anyone know how you'd do this on a page? Thanks! I've seen suggestions for options like the following, but have had no luck when popping them in there:               <?php         //list terms in a given taxonomy using wp_list_categories  (also useful as a widget)         $orderby = 'name';         $show_count = 0; // 1 for yes, 0 for no         $pad_counts = 0; // 1 for yes, 0 for no         $hierarchical = 1; // 1 for yes, 0 for no         $taxonomy = 'genre';         $title = '';              $args = array(             'orderby' => $orderby,             'show_count' => $show_count,             'pad_counts' => $pad_counts,             'hierarchical' => $hierarchical,             'taxonomy' => $taxonomy,             'title_li' => $title         );     ?>     <ul>     <?php wp_list_categories($args); ?>     </ul>


Is it possible to send blog posts via email to subscribers?

Would like to be able to send the blog post in an email mail to my subscribers, this would be great if it can be achieved through a plugin.


how to add a custom form in a page

1. How do I add a custom form to a WordPress page? I do not need contact form I need a custom form that has my own fields. Some fields get data from a database table like cities and country or any other dependable fields.   2. How can I make a form to save data from a user to user meta fields that I created in the dashboard area? I found a plugin that works as form manager, but it's not free. I tried using cform and didnt know how to get access to posted data from the form.


Different side menu on each page

Does anyone have a solution how to have different side menus on different pages? Do I need to create template for every page? I've registered many nav_menus in functions.php and than used pages ID as a switch/case parameter. It doesn't solve anything if someone gonna create couple new pages and I didn't add ID's to my file... As you can see english is not my first language but I hope it was all understandable.


Is it posibble to have alink to display all posts on index.php?

I have restricted to display 20 posts on index.php, but also I want to add a link to display all posts without restrictions. Any advices on how to achieve this? Thanks!


Styling issue with custom menus and sub menus

In a previous question I asked (and later worked out) how to style sub menus, I want to expand on that with another question related to styling sub-menus. I have hit an issue were if the parent is the selected page all child pages pick up the same styling, I believe this is because the `current-menu-item` class gets added to the parent li. If a child element is selected only the child is highlighted (which is correct) Has anyone encountered this before? What is the best way to only have the selected page highlighted and not the child elements of that page? As requested, here is the CSS that is being called to highlight the child menu.               .current-page a, .current-menu-item a {         background-color: #EE8833;     }


Styling child custom menu pages

I have a custom menu created using Appearance > Menus which contains top level and child pages. I would like to be able to indent my child level pages to give some sort of visual hierarchy to the content. What is the best way to achieve this?


Are the Theme frame works or Theme builders slow downs the performance?

I depend on theme builders like Suffusion for my Multi-Site Installation. Some WP users say the theme frameworks slow downs the performance and load speed. Is that really affects the performance? A follow up question... is there any chance for performance problem if I enable BuddyPress on same Installation Thanks !


Latest Foursquare Checkin function

Does anyone know how to display the latest Foursquare checkin for a specific account on a WordPress blog? Ideally I would like to add the function to the theme rather than use a plugin but i'm open to suggestions. Thanks in advance, G


How can I hide that I Use Wordpress (with W3 Total Cache)

For security reasons I don't want it to be obvious that I use Word Press. I use the W3 Total Cache plugin and minify HTML, CSS and JS. I may also use a CDN. Is it possible to modify the W3 Total Cache plugin so that it can rewrite the Wordpress directories "wp-content", "wp-admin" and "wp-includes" without actually renaming these directories? I'd ideally like to be able to rewrite W3 Total Cache directories such as "w3tc"


Custom page sidebar using Template dropdown box

i am wondering how i go about making a Template for some of my pages to use a different sidebar? I have created the widget like this:               register_sidebar(array(         'id' => 'ourPat-sidebar',         'name' => 'ourPat Sidebar',         'before_widget' => '
',         'after_widget' => '
',         'before_title' => '
',         'after_title' => '
'     ));      In side my Functions.php code. Then i go into my Widget panel and its displayed just fine. Then i proceed to add text to it in order to form the sidebar html. ![widget menu](http://i.stack.imgur.com/gq2x0.jpg) However, when i go to my Page menu and create a new page, i do not have the choice to use the custom widget code? ![theme](http://i.stack.imgur.com/ICeCr.jpg) So i must be doing something incorrect since its not in there. To recap, i'm just looking for a way for different pages of mine to use a different sidebar using a custom widget i made.


Get a row from a separate table by matching a posts meta_key to a tables ID column

I am trying to match a posts meta_key value to a separate tables column ID and call that row/array in the single-listing.php. I have a meta_key value that is called dot_number. The table is called wp_csadata and has a column called dot_number. Lets say the meta_key equals 12. I need to call that wp_csadata table and match the meta_key value of 12 to the column called dot_number, which has the same number, and return values in the row. Thanks.