Video slideshow

I have a custom post type using caroufredsel and it works alright but I´d like to add videos too. My current code is: // Initialize Slider               function ikos_slider_initialize() { ?>              <?php }     add_action( 'wp_head', 'ikos_slider_initialize' );      // Create Slider               function ikos_slider_template() {              // Query Arguments         $args = array(                     'post_type' => 'slides',                     'posts_per_page'    => 5                 );                // The Query         $the_query = new WP_Query( $args );              // Check if the Query returns any posts         if ( $the_query->have_posts() ) {       ?>

                 <?php                        // The Loop                 while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                              <?php                           // Check if there's a Slide URL given and if so let's a link to it                     if ( get_post_meta( get_the_id(), 'ikos_slideurl', true) != '' ) { ?>                         <a href="<?php echo esc_url( get_post_meta( get_the_id(), 'ikos_slideurl', true ) ); ?>">                     <?php }                                    // The Slide's Image                     echo the_post_thumbnail('slider');                           // Close off the Slide's Link if there is one                     if ( get_post_meta( get_the_id(), 'ikos_slideurl', true) != '' ) { ?>                                              <?php } ?>
                  <?php endwhile;  wp_reset_query(); ?>

                       <?php }              // Reset Post Data         wp_reset_postdata();     }      So, I´d like to be able to add videos (youtube,wordpress,vimeo, any solution will do) I tried adding a metabox with the code found here: http://wp.tutsplus.com/tutorials/creative-coding/youtube-and-vimeo-video- gallery-with-wordpress/ but I got the player displaying errors all the time.. Is there a way to add a metabox and how to display it inside the item in the slider content? I tried pasting inside the metabox the shortcode that wordpress generates [video] but it wont work. When I save the metabox strips everything after the =. (It shows only this: [video flv=) Help please!


Custom Taxonomy conditionals

So I have setup a custom post type 'products' and custom taxonomies / categories 'defence' 'law & enforcement' and 'Commercial'. I have using the following conditional to set some specific css and the correct banner for a product:               <?php if (has_term( 'defence', 'productcat', $post->ID )) { ?>      This works fantastic if the product is in one category. Here's my problem - i have products in multiple categories so i would like a conditional to see how they got to my product page: I have a menu down the left side on taxonomy landing page and on product page, as an example lets say i have product 1 in all 3 taxonomies; down the left hand side there will be the 3 parent taxonomies with the product underneath each one as a child. What i would like to do is have a conditional to set my custom css / banner depending on where the product on the left menu is clicked; ie if product 1 under 'Defense' is click i would like to display the 'Defense' banner, same goes if it is clicked under the other 2 taxonomies. Hope this makes sense. In all honesty i don't think this is possible and products with multiple taxonomies will just have to have the default css and a rotating banner with all taxonomies which it belongs too. Your time and help with this is appreciated **Edit** Just had a thought - if i can get the taxonomies to form part of my permalink ie domain.com/products/taxonomy/product i could use               $_SERVER['HTTP_HOST'] ==


“Unexpected error” on update requests

It needs connectivity to wordpress.org and is timing out. I am behind a corporate firewall. I have never had this issue come up before in previous versions. Why does themes.php need access to wordpress.org and what can I do so it doesn't (or maybe something that will allow me to use my proxy settings). Adding in error message: > PHP Warning: An unexpected error occurred. Something may be wrong with > WordPress.org or this server’s configuration. If you continue to have > problems, please try the support forums. (WordPress could not establish a > secure connection to WordPress.org. Please contact your server > administrator.) in C:\inetpub\wwwroot\ticket\wp-admin\includes\theme.php on > line 298 This is definitely new to 3.7. We have 3.6.1 installed 4-5 times and no issues. I would have people chopping off my head if they couldn't change their theme. **Update:** 3.8 fixed a lot of the major issues. However we still cannot find plugins, find themes or get and of the dashboard feeds. If anyone has a solution to these - even if it a suggestion for the proxy server, that would be helpful.


Extract image from content and set it as the featured image

**The problem:**   I'm posting from the Wordpress iPhone app. When adding an image, the image shows up in the description itself, which I don't like. **What I'm trying to do:**   Remove the image from the description and do one of the following (don't know the benefits of one option over the other):   1. Get the image source from the removed image and add it to a custom field. -OR-    2. Set the image as the featured image  I figure either one of those options would help me to isolate the image URL for use in my post templates. **What I've tried:**   Literally everything under the sun. Right now I'm adding code to functions.php but would eventually like to make this a plugin. I think the code below is way off, but I want to post it to show some of the attempts I've made: I've added an action to run a function mpb_remove_post_image on content_save_pre ...               add_action('content_save_pre', 'mpb_remove_post_image');      Problem with that is I don't have access to the post_id (which I need in order to set the featured image) using content_save_pre so I have to get the image url and look for a post with the guid equal to the image src...               function mpb_remove_post_image( $content ){              // strip slashes, I guess we need to readd slashes when we're done?         $content = stripslashes($content);              // get the first image src         $image_src = get_first_image($content);              // if there's an image src we can jam         if(!is_null($image_src)){                  global $wpdb;                  // query the db for an attachment with this image             //$thumb_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts WHERE guid='$image_src'"));             $result = $wpdb->get_results("SELECT ID, post_parent FROM {$wpdb->posts} WHERE guid ='$image_src'");                  $thumb_id = $result[0]->ID;                      $post_id = $result[0]->post_parent;                  // set the featured image             mpb_set_featured_image($thumb_id,$post_id);             // update_post_meta( $post_id, '_thumbnail_id', $thumb_id );              }              // remove any images in the content         $content = preg_replace("/<img[^>]+\>/i", "", $content);              $content = addslashes($content);              return $content;     }      the code above references this function I wrote to get the image...               function get_first_image($html){              require_once('simple_html_dom.php');              $post_dom = str_get_dom($html);              // get the first image         $first_img = $post_dom->find('img', 0);                 // if any images then return the src attribute         if($first_img !== null) {             return $first_img->src;         }              return null;     }      And to set the featured image ...               // set the featured image     function mpb_set_featured_image( $thumb_id, $post_id ){              update_post_meta( $post_id, '_thumbnail_id', $thumb_id );          }      I've also tried to add an action for save_post, but anything I do inside the function that runs seems to trigger another hook that runs save_post again so it turns into an endless loop. Does anyone know (even if it's at a high level) what steps I can take to accomplish this? To recap here's what I want to do... On inserting a post 1) get the first image src 2) set it as a custom field or set it as a featured image 3) remove the image from the post. **edit** - I should mention the code I posted does work if you add the post through the wp admin. But not if you add it via the mobile app.


Removing "Sub-menus" from My Sites Drop-down in Admin Bar

How does one remove the "sub-menu" that appears to the right of each site listed in the My Sites drop down from the admin bar? That is, I want to have a list of My Sites without the Dashboard/New Post/Manage Comments/Visit Site links appearing to the right of the arrow for each site in the My Sites drop down list. This would simplify the user interface significantly for my users. Any guidance would be greatly appreciated. Thank you.


bbPress - select a topic reply as "answer"

Folks! I have a good knowledge of Wordpress, and currently I started to use BuddyPress / bbPress to build a project. One of the goals of the project is to set a **"question and answer"** section at each BuddyPress Group. Since bbPress and BuddyPress works well together, I thought to use bbPress forums to build something like that. So, to achieve this, the two things that I need is:   1. Upvote / Downvote a topic reply (witch I could get using a plugin such as bbPress Post Ratings;   2. Select a reply as an "answer", putting it at the top of the replies and highlighting it. For the second item, I found a bbPress plugin named **"Best Answer"** , but I found only the svn repository of it (http://plugins-svn.bbpress.org/best- answer/trunk/) and not a plugin page, so I supose that this plugin is pretty old. If anyone knows a plugin that adds this "mark as answer" feature, or knows a way to do it (or at least a hint to start developing something about it), I'll be very glad! Thanks!


Removing filter dropdown in posts table (in this case Yoast SEO)

I don’t need Yoast SEO meta box for one post type so I removed it with remove_meta_box(). Removed unneeded columns in post table by unsetting columns with manage_edit-custom_post_columns, but drop down is still left. Is there way to remove it? Of course it is not that hard to do with jQuery, but maybe there is filter or something built in WP?


Hightlight search-terms with functions does remove or disable other filters?

I found the following two functions in order to highlight the current search term on my search-results page.               function search_excerpt_highlight() {         $excerpt = get_the_excerpt();         $keys = implode('|', explode(' ', get_search_query()));         $excerpt = preg_replace('/(' . $keys .')/iu', '\0', $excerpt);         echo '
' . $excerpt . '
';     }          function search_title_highlight() {         $title = get_the_title();         $keys = implode('|', explode(' ', get_search_query()));         $title = preg_replace('/(' . $keys .')/iu', '\0', $title);         echo $title;     }      When using this, other filters that are added to `the_excerpt()` are disabled, like e.g. the custom-more-link I added. Now there is plain HTML in my search-results like this `whatever there is class="more-link">` Any ideas how to fix that?


Help with issues on "Adding a Taxonomy Filter to Admin List for a Custom Post Type?"

This question relates to a solution found here from user somatic and mikeSchinkel I am testing somatic's solution, and it loads and populates the dropdown with no issues, but When you click filter, it does not filter anything. I am on WP version 3.0.4. My custom post type = "listings" my custom taxonomy = "Locations" the code:               add_action( 'restrict_manage_posts', 'my_restrict_manage_posts' );     function my_restrict_manage_posts() {              // only display these taxonomy filters on desired custom post_type listings         global $typenow;         if ($typenow == 'listings') {                  // create an array of taxonomy slugs you want to filter by - if you want to retrieve all taxonomies, could use get_taxonomies() to build the list             $filters = array('Locations');                  foreach ($filters as $tax_slug) {                 // retrieve the taxonomy object                 $tax_obj = get_taxonomy($tax_slug);                 $tax_name = $tax_obj->labels->name;                 // retrieve array of term objects per taxonomy                 $terms = get_terms($tax_slug);                      // output html for taxonomy dropdown filter                 echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";                 echo "<option value=''>Show All $tax_name</option>";                 foreach ($terms as $term) {                     // output each select option line, check against the last $_GET to show the current option selected                     echo '<option value='. $term->slug, $_GET[$tax_slug] == $term->slug ? ' selected="selected"' : '','>' . $term->name .' (' . $term->count .')</option>';                 }                 echo "</select>";             }         }     }      Am I missing something in there to make the filter work? I am organizing my column's with the following code, not what was in step 3 and 4. (not sure if this is the issue?)               add_action("manage_posts_custom_column",  "listing_custom_columns");     add_filter("manage_edit-listings_columns", "listing_edit_columns");          function listing_edit_columns($columns){       $columns = array(         "cb" => "<input type=\"checkbox\" />",         "title" => "Listing Name",         "address" => "Address",         "Locations" => "Location",       );            return $columns;     }     function listing_custom_columns($column){       global $post;            switch ($column) {         case "address":           $custom = get_post_custom();           echo $custom["address_meta"][0];           break;         case "Locations":           echo get_the_term_list($post->ID, 'Locations', '', ', ','');           break;       }     }      Any help would be appreciated. thank you.


Get current page's taxonomy

I've got some pages with a custom taxonomy for each page and i'm trying to retrieve this taxonomy on the page. I'd basically need something like `the_current_taxonomy()` like `the_title()`. This has to run outside the loop cos i'll use it in a custom `WP_Query` right after. Edit: Found a solution using a different way to retrieve the information i needed. Thanks for your help guys.


hosted wordpress.com to local directory?

This question was posted at onstartups - one that I frequently hear. Figure that I would ask the experts over here - can one maintain a hosted wordpress.com blog yet make it a subdirectory under their domain? From: http://blog.domain.com to http://domain.com/blog IF so, what step(s) / .htaccess changes are necessary to make it happen? {Edit to clarify some points}   1. user currently has a wordpress.com blog ( http://username.wordpress.com )   2. user currently has a domain / site (http://domain.com)   3. user likes wordpress.com hosting and doesn't want to install a local version of wordpress on domain.com. User is willing to pay wordpress.com for custom url, but doesn't want http://blog.domain.com - (s)he wants blog to be a directory http://domain.com/blog.


What are the pros and cons to a WordPress run newsletter v. third party newsletter?

I am currently building a site that will use newsletters, email notifications for new posts and email notifications for new comments on posts. I keep going back and forth between running this through third party sites and doing it solely through my WordPress website. I should mention, when I say third party, I am including the WrodPress.com email/comment subscriptions built into Jetpack, maybe FeedBurner for new post emails instead and I am considering MailChimp.com for newsletters. If running it myself, I haven't decided on any plugins yet, but I know plenty are available. I suppose my main reasoning for wanting to run everything myself is so I can have a more fine level of control. I can email specific user roles, etc. As well, I am not a big fan of the double opt-in used by MailChimp and Jetpack. Double opt-in simply annoys me. I prefer ReCaptcha or some other anti-spam method on the signup form I have been trying to come up with pros and cons on each side, other than double opt-in (which I understand, can be a pro or con for both depending on your views), what are pros and cons of each method? Thanks.


How can I improve site/page performance of WordPress websites?

To improve site/page performance, I added the following code to accept headers:               <php flush(); ?>      It works, but perhaps not as well as it could. Any advice? I also tried to leverage browser caching, using the following code:               # Begin Expires Caching     <IfModule mod_expires.c>     ExpiresActive On     ExpiresByType image/jpg "access 1 year"     ExpiresByType image/jpeg "access 1 year"     ExpiresByType image/gif "access 1 year"     ExpiresByType image/png "access 1 year"     ExpiresByType text/css "access 1 month"     ExpiresByType application/pdf "access 1 month"     ExpiresByType text/x-javascript "access 1 month"     ExpiresByType application/x-shockwave-flash "access 1 month"     ExpiresByType image/x-icon "access 1 year"     ExpiresDefault "access 2 days"     </IfModule>     # End Expires Caching      Again, any advice to optimize the results will be appreciated.


Adding 'menu order' column to custom post type admin screen

I want to use the `menu order` attribute to control ordering for a custom post type that's going to be used for a specific purpose. It's easy enough to add this to the CPT via `supports => array('page- attributes')` but how do I expose the menu order value on the admin listing screen for this CPT?


How to publish page that can't be detected by search engines?

I like to publish drafts in my 'Uncategorized' category. This category is not linked anywhere on my site. It's great for allowing contributors to an article to read the draft before it is made public. The problem is that after just 2 or 3 days, search engines begin picking up the draft and people start posting comments. I don't want to password protect the draft. Is there some way to hide it from search engines while it is in the 'Uncategorized' category?


WordPress objects class reference

In WordPress we have several objects defined through classes that are enough documented. These are the `WP_Query`, `WPDB`, `WP_Post` and other. There are other objects however that are actually created at runtime, usually converting an array to a standard object, or reading from the DB. For instance, the taxonomy object you get from `get_taxonomy()` function. Even though there isn't an actual class that defines these objects, **I wonder if there is any detailed documentation of all properties we can find in these objects** that doesn't require me to alway dig in the code to remember which are the properties names.


Check If posts exist in custom post type category, outside of loop

I'm building a navigation, outside of the main loop, that includes drop downs. I have a custom post type called 'Events', that has its own categories. I would like there to be a drop down if there are posts within that custom post type and category, but I'm not sure what functions I should be using to determine this... I have...               $hasposts = get_posts('post_type=Events&category=40');     if($hasposts) {         ..// show the drop down menu     }       Should I even be using `get_posts()`? Everything I am getting returned has an empty array, but I know that some of those categories include posts... Many thanks, WA.


Advanced Custom Fields and date picker, show posts only if the day is today no matter the year

I've created a site made just with custom fields about famous people in sport. In the post page I've a born date and a death date field using the data picker. What I'm trying to achieve is to show posts of people who have died today in the past, if someone has died the 14th of february 1982 I want to show in a page/widget every 14th of february of this year and the next to come. I'd also would like to retrieve from the born and death date only the year. Let's take Jesse Owens. He was born on September 12, 1913 and died March 31, 1980. I would like to have a post like this: Jesse Owens (1913 – 1980)   * Jesse Owens is the title of the post but how to show 1913 and 1980? Thanks!


Change how WP e-Commerce calculates price total at checkout

My situation: I'm selling a few products. I need to get some options at checkout (like Do you want to add installation services?) that will affect the price, and I need to reference a custom database table to do some complex price calculations to get a total order price. I wanted to use getshopped.org's wp e-commerce shopping cart, but somehow override the checkout page to do what I need, then return my calculated price to wp e-commerce to finish the order up. How would I do this? Would I use a hook? Should I change some method that calculates the totals (without losing my changes on the next update)? Or do I have to drop the plugin and roll my own completely? Thanks so much.


How to update same text on two Pages at once

One of my sites is for a local organization with different clubs within the one organization. I have to list the upcoming meetings in two separate locations: (1) the home page where the upcoming meeting for all of the clubs is listed (in different tabbed entries), and (2) on the page for the individual club. This is different from a calendar listing. The line of text describing the meeting is formatted differently on the different Pages. Is there a way to enter the text in one place and have it copy automatically to two pages, within the format codes each Page requires? Not a whole page or post worth, just a line of text?


Setting get_queried_object

I know that `get_queried_object` contains the object that was queried for the current page. My question is, what methods of querying affect the contents of this? For instance:   * `query_posts`   * `get_posts`   * `get_post`   * `new WP_Query`   * etc.


Correct folder permissions?

I just recently installed PHP and wordpress on our coldfusion box and wordpress is throwing me an dialog saying I need to input FTP information so wordpress can alter the files. I read up on this and basically this only comes up if wordpress cannot manipulate the files directly via PHP/apache user. My question is now how should I set the folder permissions so things are secure and play nicely? The wordpress root folder has the following permissions               drwxrwxr-x  6 wwwtech    root  4096 Feb 21 14:09 home      files and folders within have               -rw-r--r--  1 wwwtech root   418 Sep 25  2013 index.php     drwxr-xr-x  9 wwwtech root 12288 Jan 23 20:17 wp-admin      PHP and apache are running under user `tech`               tech     12465  0.0  0.0   9400   936 pts/0    S+   09:58   0:00 grep --color=auto php      and are part of group               tech : tech root adm dialout cdrom plugdev sambashare lpadmin admin


(solved) how to have the gallery shortcode output one single UL list instead of several DL?

I need the built-in gallery shortcode to output UL instead of DL. How can I do it? I know I can use the 'post_gallery' filter, but that means almost duplicating the media's gallery_shortcode function. I'd like to find a less 'verbose' solution. Thank you


Split Content and Gallery

Is there a way to split up the post content and the gallery short code. I want to display the gallery outside my normal content no matter how or where it is placed. I can use this to get the shortcode itself:               if(has_shortcode(get_the_content(), 'gallery')){         $pattern = get_shortcode_regex();          preg_match("/$pattern/s", get_the_content(), $matches);         echo do_shortcode($matches[0]);     }      But this doesn't work if the gallery short code isn't the first instance. Is there a way to split my content and gallery up completely? * * * **Edit:** I have a semi-solution but it seems like a long winded way to go about it. It first grabs the first shortcode in the post (which needs to be fixed since I only want the "Gallery" shortcode) then removes all shortcodes from the content (again, not really what I want to do.               <?php if(has_shortcode(get_the_content(), 'gallery')) : ?>         <?php              $pattern = get_shortcode_regex();              preg_match("/$pattern/s", get_the_content(), $matches);         ?>
             <?php echo strip_shortcodes(get_the_content()); ?>

             <?php echo do_shortcode($matches[0]); ?>
     <?php endif; ?>      * * * **Edit #2** - Ok, I've been able to only get gallery shortcodes in the post. I've also added a filter to remove the gallery shortcode form `the_content()` - the problem is that its not necessarily removing the shortcode since it does post it, but its not allowing me to run "do_shortcode()" **Functions.php**               function remove_gallery($content) {         global $post;              if($post->post_type == 'artcpt')             remove_shortcode('gallery', $content);              return $content;     }     add_filter( 'the_content', 'remove_gallery', 6);       **The Loop**               <?php preg_match('/\[gallery ids=[^\]]+\]/', get_the_content(), $matches); ?>
         <?php the_content(); ?>

         <?php echo do_shortcode($matches[0]); ?>
      in The Loop it will return my short code **Twice** (i'm on a single page, should be looped twice - so its not running do_shortcode()). Not sure why.


Custom Loop Pagination on WordPress

I'm trying to create a magazine style website. For this particular page (not homepage) I'd like to fetch the latest post and style it one way (style1). For all the other posts I'd like to just display smaller (style2). This is working fine, BUT I would also like to enable pagination. Is there anyway to have pagination appear at the bottom, when the user clicks previous older posts will be shown in the second style (style2)? My code so far is below:               <?php      /*     Template Name: Interview     */     get_header(); ?>

Interviews
     <?php         $args=array(         'cat' => '12,3',         'post_type' => 'post',         'post_status' => 'publish',         'posts_per_page' => 3,         'caller_get_posts'=> 1         );         $my_query = null;         $my_query = new WP_Query($args);         while ($my_query->have_posts()) : $my_query->the_post();               $counter++;         if($counter===1) {     ?>
     <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">     <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'slider-image' );  } ?>
<?php the_title(); ?>
     <?php the_time('j M') ?> | <?php comments_number('No Comments', 'One Comment', '% Comments' );?>          <?php my_excerpt(40); ?>

     <?php } else { ?>
     <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">          <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'latest-thumb-small' );  } ?>

     <?php the_title(); ?>
     <?php the_time('j M') ?> | <?php comments_number('No Comments', 'One Comment', '% Comments' );?>     <?php my_excerpt(30); ?>

     <?php } ?>          <?php endwhile; ?>          <?php next_posts_link('« Older Entries', $my_query->max_num_pages) ?>     <?php previous_posts_link('Newer Entries »') ?>

     <?php get_sidebar(); ?>
     <?php get_footer(); ?>      TL;DR: Ideally I want to:   1. Display the latest post as style1   2. Display all the other posts as style2   3. When the user clicks NEXT/PREVIOUS, load more posts and style them as style2. Unless they are on the latest post page. UPDATED CODE;               <?php      /*     Template Name: Film     */     get_header(); ?>

     <?php           // Only on the first page     if ( ! is_paged() ) {              // Custom query - latest post         $latest_post = new WP_Query( array(             'cat' => '4',             'post_type' => 'post',             'post_status' => 'publish',             'posts_per_page' => 1         ) );         // Output latest post         if ( $latest_post->have_posts() ) : while ( $latest_post->have_posts() ) : $latest_post->the_post();             ?>
     <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">     <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'slider-image' );  } ?>
<?php the_title(); ?>
     <?php the_time('j M') ?> | <?php comments_number('No Comments', 'One Comment', '% Comments' );?>          <?php my_excerpt(40); ?>

     <?php          endwhile; endif;         // Don't forget me         wp_reset_postdata();          }          // Main query     if ( have_posts() ) : while ( have_posts() ) : the_post();     ?>
     <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">          <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'latest-thumb-small' );  } ?>

     <?php the_title(); ?>
     <?php the_time('j M') ?> | <?php comments_number('No Comments', 'One Comment', '% Comments' );?>     <?php my_excerpt(30); ?>

     <?php      endwhile; endif;     ?>
     <?php      // Pagination     next_posts_link();     previous_posts_link();          ?>

                 <?php get_sidebar(); ?>
     <?php get_footer(); ?>      Functions:               function wpse121486_pre_get_posts( $query ) {             // Main blog posts index, first page, main query             if ( is_home() && ! $query->is_paged() && $query->is_main_query() ) {                 $query->set( 'posts_per_page', 9 );                 $query->set( 'offset', 1 );             }         }         add_action(           'pre_get_posts', 'wpse121486_pre_get_posts' );


How to Remove Sidebar when get_sidebar() is not get called in page?

I see in my WordPress theme, there is no call of get_sidebar() in single.php etc. but sidebar comes. Here it is telling about customizing based on get_sidebar(). I want to use get_sidebar() to include sidebar so that I can think of customization. Is there any default method to include sidebar from where it can come ?


How to return count of custom post type posts with a specific custom field value via $wpdb?

I am trying to get count of a custom post type with a specific custom field value from wpdb without doing a WP_Query or get_posts since I think it is more resource efficient and I need to return 10 different counts for 10 different values on one page. I can't get the right count to show up. A number is returned, but it is wrong. Here is the code :               $meta_value = key($choices);             $count = $wpdb->get_var(                 $wpdb->prepare (                 "                 SELECT  count(ID)                  FROM    $wpdb->posts, $wpdb->postmeta                 WHERE   $wpdb->posts.post_status = 'publish'                         AND $wpdb->posts.post_type = 'tasks'                         AND $wpdb->postmeta.meta_key = 'task_status'                         AND $wpdb->postmeta.meta_value = %s                 ",                 $meta_value             )); ?>      How can I make it right? key($choices) returns the right value (string) for the $meta_value variable. It is my absolute first use of $wpdb so have mercy. Edit: solved by adding INNER JOIN:               "             SELECT  count(ID)              FROM    $wpdb->posts             INNER JOIN $wpdb->postmeta                 ON $wpdb->posts.ID = $wpdb->postmeta.post_id             WHERE   $wpdb->posts.post_status = 'publish'                     AND $wpdb->posts.post_type = 'tasks'                     AND $wpdb->postmeta.meta_key = 'task_status'                     AND $wpdb->postmeta.meta_value = %s             "


Javascript as Jquery Function Call?

Refer to Nice scroll to wordpress wordpress runs jquery in noconflicts mode which means that you either need to write your JS code using the jQuery function call               var seq = 0;            $(document).ready(function() {             $("html").niceScroll({styler:"fb",cursorcolor:"#000"});              $("#mainlogo img").eq(1).hide();         function goSeq() {           var nxt = (seq+1)%2;           $("#mainlogo img").eq(seq).fadeIn(2000);           $("#mainlogo img").eq(nxt).fadeOut(2000);           seq = nxt;           setTimeout(goSeq,2500);         };         goSeq();              $(window).load(function(){           setTimeout(function(){             $("#gmbox div").animate({'top':60},1500,"easeOutElastic");           },1500);         });              function trackLink(link, category, action) {           try {             _gaq.push(['_trackEvent', 'tracklink' ,'click',link.href ]);             setTimeout('document.location = "' + link.href + '"', 100)           }catch(err){}         }              $('[rel="outbound"]').click(function(e){                 try {             _gaq.push(['_trackEvent','outbound','click',this.href]);           }catch(err){}         });            });      This is the javascript that i want to add in functions.js using the Jquery function call. To make it work I inserted $ in (). Could you please correct this?


Editing or filtering the output of the Genesis navigation

I'm trying to edit or apply a filter to the default Genesis navigation `genesis_do_nav` Currently I'm extending a Walker class to add a `<span>` with data-attribute around the navigation's link text.               class Menu_With_Data_Attr extends Walker_Nav_Menu {         function start_el(&$output, $item, $depth, $args) {             global $wp_query;             $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';                  $class_names = $value = '';                  $classes = empty( $item->classes ) ? array() : (array) $item->classes;                  $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );             $class_names = ' class="' . esc_attr( $class_names ) . '"';                  $output .= $indent . '
ID . '"' . $value . $class_names .'>';                  $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';             $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';             $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';             $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';                  $item_output = $args->before;             $item_output .= 'title.'">';             $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;             $item_output .= '';             $item_output .= $args->after;                  $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );         }     }      How might I apply that walker to the output of the genesis_do_nav?


How to make an xml file (just the xml file) available at a specific url?

I'm trying to include an xml file in my WP site where you could go to a url, much like this one: **www.example.com/somepage/anotherpage/thefile.xml** and view "thefile.xml" - no header, no footer, just the xml file. I've been searching for ways to accomplish this for awhile now.


My php code is not being executed

I have a wordpress page that has this code in the text editor part of a web page:               This page creates a cookie and houses a etst link that is only accessible to the holder of the cookie.                Test Link (authentication required).           Syntax:     setcookie(name, value, expire, path, domain);     <?php setcookie(accesscookie, testing1234, time()+86400, /, foo.example.com); ?>      When I navigate to the page it does not create a new cookie. Can somebody tell me what I am doing wrong to create the cookie?


Get parse_query filter to return slug instead of id

After much headache in the last week I feel like my problem is almost solved. I have been attempting to customize the admin edit.php page of custom post types to display and sort/filter custom taxonomies. I've frankensteined a collection of actions and filters from things found on the web but fear I may be using deprecated code as some of them were quite old. I think I've narrowed the problem down to this filter               add_filter('parse_query','convert_large_feature_id_to_taxonomy_term_in_query');     function convert_large_feature_id_to_taxonomy_term_in_query($query) {         global $pagenow;         $qv = &$query->query_vars;         if ($pagenow=='edit.php' &&                 isset($qv['taxonomy']) && $qv['taxonomy']=='large_feature' &&                 isset($qv['term']) && is_numeric($qv['term'])) {             $term = get_term_by('id',$qv['term'],'large_feature');             $qv['term'] = $term->slug;         }     }         When I choose the dropdown menu for `large_feature` it accurately displays the "categories" (is that what you call them when they are of a custom taxonomy?) and post count, however when it is actually filtered, the query comes up empty. I noticed, however, that when I modified the query URL from               http://www.ampeg.com/2012/wp-admin/edit.php?post_status=all&post_type=ampeg_artists&action=-1&m=0&cat=0&large_feature=291&paged=1&mode=list&action2=-1      to               http://www.ampeg.com/2012/wp-admin/edit.php?post_status=all&post_type=ampeg_artists&action=-1&m=0&cat=0&large_feature=home_page_large&paged=1&mode=list&action2=-1      It displays as intended. This leads me to believe that this filter isn't outputting the slug as it's supposed to... right?


Wordpress Theme Options Values

I am designing a wordpress website with theme options: In my theme options I have code that looks like this:                   $class = (isset($this->field['class']))?$this->field['class']:'regular-text';              echo '
field['id'].'-ul">';              if(isset($this->value) && is_array($this->value)){             foreach($this->value as $k => $value){                 if($value != ''){                          echo '
<input type="text" id="'.$this->field['id'].'-'.$k.'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" value="'.esc_attr($value).'" class="'.$class.'" /> '.__('Remove', 'nhp-opts').'
';      It displays a text field in my theme options panel, and I am able type in it and save it. Here is my problem, I changed my code to add a text area with the options, and it looked something like this:                   $class = (isset($this->field['class']))?$this->field['class']:'regular-text';              echo '
field['id'].'-ul">';              if(isset($this->value) && is_array($this->value)){             foreach($this->value as $k => $value){                 if($value != ''){                          echo '
<input type="text" id="'.$this->field['id'].'-'.$k.'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" value="'.esc_attr($value).'" class="'.$class.'" /> <textaread id="'.$this->field['id'].'-'.$k.'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][]" class="'.$class.'">'.esc_attr($value).'</textarea> '.__('Remove', 'nhp-opts').'
';      Now when I go to my theme options panel, both boxes are there, but if i type something different in each one and save it. Both boxes are displayed to showing the exact same thing. Is there a way I can fix this?


Hidden Custom Post Type

I am just wondering is it possible to create a custom post type in wordpress which is hidden from the wordpress admin panel?


Need a Membership Plugin

I need some help. We are a gymnastics club volunteer parent group. We need members (parents) to be able to log in and view their account, so they would have their own page. On that page we need to have several things in a database -   1. They will be given a membership number   2. They can pay their member fees and competition/other fees (Paypal OK) and see what they still owe.   3. They can sign up for fundraising activities which they get credit for and see what their total credit is   4. We would need to export various reports   5. Needs to be easy to manage (the more automation the better)   6. Would be nice to import excel spreadsheet of current member list This sounds like a lot so any help would be greatly appreciated, I have looked at several member plug-ins but nothing I found really fits. Thanks.


Slugs as breadcrumbs for Pages

I´m trying to create a function that creates a breadcrumb trail of _Page_ slugs outside of The Loop. These breadcrumbs show the path from the homepage to the current (sub)page. For example, on the page "example.com/attractions/parcs/parc-name" this breadcrumb would be shown: **Home > Attractions > Parcs > Parc Name** I´ve done a lot of research and found various code snippets that can perform part of the function, but my PHP skills are not good enough to create the whole function myself. This is what I have:   * Get the post slug in The Loop: `$slug = basename(get_permalink());` (src)    * Get the post slug outside of The Loop: `global $post; echo $post->post_name;` (src: see above)   * Get posts´parent slug `<?php global $post; if($post->post_parent) { $post_data = get_post($post->post_parent); echo $post_data->post_name; } ?>` (src)   * Get breadcrumb trail of pages using page titles (this is what I´m using now):               if ( is_page() )      {       $post = $wp_query->get_queried_object();       if ( $post->post_parent == 0 )       {          echo "
 » ".the_title('','', FALSE)."
";        }        else        {         $title = the_title('','', FALSE);         $ancestors = array_reverse( get_post_ancestors( $post->ID ) );         array_push($ancestors, $post->ID);         foreach ( $ancestors as $ancestor )         {           if( $ancestor != end($ancestors) )           {             echo '
 » '. strip_tags( apply_filters( 'single_post_title', get_the_title( $ancestor ) ) ) .'
';           }            else            {             echo '
 » '. strip_tags( apply_filters( 'single_post_title', get_the_title( $ancestor ) ) ) .'
';           }         }       }     }      All ideas, suggestions and solutions are very much appreciated :)


What is a Theme textdomain?

I've found that any WordPress theme uses this functions, but I don't understand what is the purpose of it and what is it, in this case `'themify'`? Here are some examples in Themify `functions.php`: 1).               load_theme_textdomain( 'themify', TEMPLATEPATH.'/languages' );      2).               if (function_exists('register_nav_menus')) {             register_nav_menus( array(                 'main-nav' => __( 'Main Navigation', 'themify' ),                 'footer-nav' => __( 'Footer Navigation', 'themify' ),             ) );         }      And in tempate file: 3). `<?php _e( 'Sorry, nothing found.', 'themify' ); ?>` And many more! My doubt is what is `'themify'` stand for? What is their purpose? Could I Change it or delete it? What is the place, `'themify'`, for?


Asset loading with gulp.js or Grunt

I just started using gulp.js which is a task runner like Grunt and a lot of the sites I work on are using WordPress so I was wondering if anyone has some ideas about how to use the combined scripts that gulp will output with WordPress (or for that matter any file that combines multiple files into one). So say I have gulp setup to concatenate and minify a couple vendor plugin files, like fancybox, and flexslider to a file called `plugins.min.js`. I would then load that into my theme by using `wp_enqueue_script` from the `functions.php` file.               function enqueue_scripts() {         wp_register_script( 'custom-plugins', get_template_directory_uri() . '/assets/js/build/plugins.min.js', array( 'jquery' ), '1.0', true );              wp_enqueue_script( 'custom-plugins' );     }          add_action( 'wp_enqueue_scripts', 'enqueue_scripts' );      But say a plugin gets installed that uses fancybox as well (damn clients). Since the script is being loaded as `custom-plugins` instead of `fancybox` the `fancybox.js` file will be loaded from that plugin as well as my minified script file, which could cause issues and unnecessary file size. Same goes for `wp_enqueue_style`. Any thoughts / ideas on this?


WordPress import tool didn't transfer Media in posts?

I have a blog on blogger CrateScienz.com that we're trying to migrate to WordPress. Right now the WordPress database that we're migrating to is at 2woMedia.com/CrateScienz. The majority of our posts on blogger are embedded media, i.e, youtube videos, soundcloud, etc. I used the >tools>import>"magic button" method and it seems to only have migrated the post titles. In most of the posts, the content isn't displaying properly, if at all. For example, this post on Blogger VS the same post on WordPress post import. Any idea if there is another method to import so that the posts display properly, or should I buckle down and do it all over manually? I'd dread doing that, we have over 9000+ posts.


Conditional avatar

I am using a plugin that allows users to upload profile graphics in place of avatars. The plugin is "User Avatar". I am displaying user profile graphics with this code:                   echo get_avatar( get_the_author_meta('user_email'), $size = '60')      It works fine except I would like it to function so that, if a user does not have a user profile graphic, it defaults to display nothing. If I use the avatar Discussions settings to display "Blank" when there is no user avatar I still get text that is wrapped around where the graphics would be, creating an empty square where a user profile should otherwise be. Does anyone have any suggestions? Thank you in advance for considering.


How to access .php file directly in wordpress site

I want to access one specific file with .php extension. Similar to, http://www.pnrstatus.co.in/trainschedule.php At the same time, want to access the blog content with wordpress permalinks. Similar to,http://www.pnrstatus.co.in/irctc-halts-e-commerce-portal-is-it- shutdown/ In short, how to access .php file directly without adding to theme folder, It will in the same directory where wordpress installed. When i tried to access the file directly, like www.example.com/test.php, got 404 error.


Can each user have only access to a private area (his own categories and posts)?

I am working on a wordpress site and one of the key features i want to have is the fact that each user, once registered should be able to :   * create his own categories (that will be visible only by him)   * create posts in his own categories   * access only to the content he created (cotegories/posts) So his front end view should be only his posts and the categories he created. Is there a way for achieving this with Wordpress? I made a lot of search on the net, but i didn't find any answer for this specific question. EDIT : The main idea of my question is : is there a way to separate data per user (not only their login, passwd and profile) that would include the categories that each user would create and the posts in these categories? Each user will have in this case a unique vue (his own directory) on the site with only his categories & posts. Thanks for your help !


Custom Background: Can't Set Color Default

I'm using the standard WP Custom Backgrounds feature, however, the color is defaulting to #166b4c and I'm unsure why. #166b4c does not appear in my stylesheet. Below is my code.                   add_theme_support( 'custom-background' );         $defaults = array(             'default-color'          => '000',             'default-image'          => '',             'wp-head-callback'       => '_custom_background_cb',             'admin-head-callback'    => '',             'admin-preview-callback' => ''         );          add_theme_support( 'custom-background', $defaults);      Live example: http://themeforward.com/demo2/


New WP_query in template not working with CPT+category on some pages

I have three page templates, homepage, documentary, and corporate, each using the same CPT WP_query code with only the category name changed for each respectively. The homepage works fine, pulling and showing the correct category of my CPT. The other two do not work. Here is a snippet of the code for the homepage:               <?php     /*     Template Name: Homepage Reels     */          /*     @package _tk     */          get_header(); ?>          <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

              <?php $args = array( 'post_type' => 'films',                              'tax_query' => array(                                                 array(                                                 'taxonomy' => 'film-type',                                                 'field' => 'slug',                                                 'terms' => 'homepage',                                                 )                                             ),                              'posts_per_page' => '-1', );               $the_query = new WP_Query( $args ); ?>          <?php if ( $the_query->have_posts() ) : ?>     <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>          <?php /* Get the current post ID. */                         $post_id = get_the_ID();                       /* If we have a post ID, proceed. */                         if ( !empty( $post_id ) ) { ?>
                                  <?php //
<?php the_title(); ?><?php //
 ?>                                  <?php $videourl = get_post_meta( $post_id, 'film_embed', true );                                   if ( $videourl != '' ) {                                     echo wp_oembed_get( $videourl );                                    } ?>                                  <?php if ( get_post_meta( $post_id, 'film_textarea', true ) ) : ?>

<?php echo get_post_meta( $post_id, 'film_textarea', true ); ?>

                             <?php endif; ?>
                              <?php } else { ?>
<?php _e( 'Sorry, no posts matched your criteria.' ); ?>
                              <?php } ?>                  <?php wp_link_pages( array(                 'before' => '
' . __( 'Pages:', '_tk' ),                 'after'  => '
',             ) ); ?>              <?php endwhile; ?>         <?php endif; ?>      and the documentary template:               <?php     /*     Template Name: Documentary Reels     */          /*     @package _tk     */          get_header(); ?>          <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

              <?php $args = array( 'post_type' => 'films',                              'tax_query' => array(                                                 array(                                                 'taxonomy' => 'film-type',                                                 'field' => 'slug',                                                 'terms' => 'documentary',                                                 )                                             ),                              'posts_per_page' => '-1', );               $the_query = new WP_Query( $args ); ?>          <?php if ( $the_query->have_posts() ) : ?>     <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>          <?php /* Get the current post ID. */                         $post_id = get_the_ID();                       /* If we have a post ID, proceed. */                         if ( !empty( $post_id ) ) { ?>
                                  <?php //
<?php the_title(); ?><?php //
 ?>                                  <?php $videourl = get_post_meta( $post_id, 'film_embed', true );                                   if ( $videourl != '' ) {                                     echo wp_oembed_get( $videourl );                                    } ?>                                  <?php if ( get_post_meta( $post_id, 'film_textarea', true ) ) : ?>

<?php echo get_post_meta( $post_id, 'film_textarea', true ); ?>

                             <?php endif; ?>
                              <?php } else { ?>
<?php _e( 'Sorry, no posts matched your criteria.' ); ?>
                              <?php } ?>                  <?php wp_link_pages( array(                 'before' => '
' . __( 'Pages:', '_tk' ),                 'after'  => '
',             ) ); ?>              <?php endwhile; ?>         <?php endif; ?>      I have no errors via WP_DEBUG. Here is the testing site: http://thegallerymusic.com/test/ Can't think of what could possibly be allowing homepage to work, but causing the documentary/corporate templates to NOT work. Any ideas?


How add short description Featured Products or Related Products

I would like to have a short description in the widget _Featured Products_ or before the list _Related Products_. How can I do that?


Adding existing domain name to Wordpress.com

Can i redirect my domain to wordpress.com using my own nameserver?


drop-down list another query

i tried this code, it is not giving me any 404 page instead it is giving me the same page back, now i think the submit buttons needs to be configured               function the_taxonomy_dropdown($taxonomy) {       $id = "{$taxonomy}-dropdown";       $terms = get_terms($taxonomy);       echo "<select name=\"{$id}\" id=\"{$id}\">";       foreach($terms as $term) {         echo '<option value="';         echo get_term_link(intval($term->term_id),$taxonomy);         echo '">' . "{$term->name}</option>";       }       echo "</select>";     }     add_action('init','jquery_init');     function jquery_init() {       wp_enqueue_script('jquery');     }      this code was provided to me by one of the person from this website, i just modified it, this works but its just showing me the home page again


add_filter return value

function validate_username( $username ) {         $sanitized = sanitize_user( $username, true );         $valid = ( $sanitized == $username );              return apply_filters( 'validate_username', $valid, $username );     }      in wp-includes/registration.php i want to change               $sanitized = sanitize_user( $username, true );      to               $sanitized = sanitize_user( $username, false );      I couldnt success to write add_filter in there, somehow its not working. Can you write a filter for this please?


Gravity Forms Hide/disable entry reation

I am trying to disable the entry creation for a gravity form I have on my Wordpress website. The form consists of username/password for a another application(not Wordpress) and I do not want it to list/create entries in the wordpress database for every time this form is used. I have a dashboard widget also which displays all forms in the website as well as all the entries of each. I am trying to find a way to either hide the form entirely from the widget or not create entries at all. I tried the following hook in the functions.php under the theme.               add_filter("gform_disable_post_creation", "disable_post_creation", 10, 3);        function disable_post_creation($is_disabled, $form, $entry){        return true;     }      But this isn't working. Does anyone know of a way I can hide the form or disable entry creation for this specific form?


drop-down list taxonomy problem

i have a function of custom taxonomies to display a drop down list on my website, which is working fine, but there is one problem, the default value is a custom taxonomy, but that i dont want, i want a custom word, like select cause the current default value, when i select it, it is not redirecting to the corresponding page, if you wanna chaeck it, goto my website, on the home page i have kept that drop-down list www.mbas.in and the code of the function is               function the_taxonomy_dropdown($taxonomy) {           $id = "{$taxonomy}-dropdown";           $js =<<<SCRIPT         <script type="text/javascript">          jQuery(document).ready(function($){           $("select#{$id}").change(function(){             window.location.href = $(this).val();           });          });         </script>         SCRIPT;           echo $js;           $terms = get_terms($taxonomy);           echo "<select name=\"{$id}\" id=\"{$id}\">";           foreach($terms as $term) {             echo '<option value="';             echo get_term_link(intval($term->term_id),$taxonomy);             echo '">' . "{$term->name}</option>";           }           echo "</select>";         }         add_action('init','jquery_init');         function jquery_init() {           wp_enqueue_script('jquery');         }      what i do for keeping default value as Select ????


How to Exclude post from a category

This is my home page code here is a feature post section, i want to exclude post by a category 'Collage' in this section ...               <?php      $count = 1;     if (have_posts()) : while (have_posts()) : the_post(); if($count == 1) : ?>

     <?php woo_get_image('image',455,245,' '.$GLOBALS['align']); ?>

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

<?php dynamic_excerpt(400); ?>
     (<?php _e('आगे      पढे ', 'shreshthbharat'); ?>)

          <?php else : ?>            <--- Rest of post goes here --- >

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


WP 3.3 Tooltips API?

Does anyone have a tutorial on how to implement the new Tooltips API into a theme or plugin? I'm eager to tap into this to help first time users of my theme and plugins. From mashable'e excellent intro to 3.3... >   1. New Tooltips > > > This may seem a bit annoying to more experienced users, but it can prove > quite useful for most. > > Tooltip popup bubbles now display to help guide users through the new > features found in WordPress. You’ll see one of these immediately upon > upgrading, which points to the new admin bar. > > _**> Developers are able to use these popups to add their own feature tours. > This will prove useful for theme and plugin authors who need an easy way to > walk their customers through their WordPress products_**


Hotel reservation plugin you would recommend

What hotel reservation plugins for Wordpress would you recommend for a Small hotel that has not more than 25 rooms? It needs to display room availability and can accept payment online.


using wp_update_post on save_post

im trying to update a posts date (-1 year), when you hit update. but it causes an infinite loop. any other ways of doing this? thanks.               function change_year($post_id, $post){     if ( $post->post_type == 'post' ) {         $format = 'Y-m-d H:i:s';          $id = $post->ID;         $old_date = $post->post_date;         $old_gmt_date = $post->post_date_gmt;         $new_date = date( $format, strtotime( '-1 year' , strtotime( $old_date ) ) );         $new_date_gmt = date( $format, strtotime( '-1 year' , strtotime( $old_gmt_date ) ) );              $new_values = array (             'ID' => $id,             'post_date' => $new_date,             'post_date_gmt' => $new_date_gmt         );              wp_update_post( $new_values );     }     }          add_filter('save_post', 'change_year',10,2);


How to query an out put value?

I have this custom query that Im working on and I need to be able to query output values as well as actual stored values. Example:               $string = "This is #*&^% a test";     $string = preg_replace('/[^(\x20-\x7F)]*/','', $string);     $string_clean = $string      So if I echo $string_clean, I'll get this:               This is a test      Which is fine, but the issue is that the $string_clean value isn't a stored value (just an output), so I dont know how to use its value in a query, being that the query results are based on stored database values. Im using a multi array capability of the wordpress query ( **here**). Basically, I use two keys in the array with AND as the meta_compare. Ideally, I would like to be able to query both value (stored and output). Im interested in this as a search functionality for my query. Can someone help me with this? How do I do it?. Or if someone knows of a better solution please let me know. **UPDATE:** This is the code that Im working with. I couldn't find any reliable solutions to implement REGEXP. Basically, what this should do, in theory, is use the php `preg_replace` function to remove/replace any special characters in the string and query the new clean string, that will then be used in the query's argument. Here it is: *The initial value of the variable are submitted through a simple html form (not included).                if(isset($_POST['providername'])) {              $providername = $_POST['providername'];              if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $providername))             {                 $clean = $providername;                       // Replace other special chars                 $specialCharacters = array(                 ',' => '',                 '&amp' => 'and',                 '@' => 'at',                 '.' => '',                 '+' => '',                 '=' => '',                 '/' => '',                 '*' => '',                 '!' => '',                 '(' => '',                 ')' => '',                 '$' => '',                 '#' => '',                 '%' => '',                 '\'' => '',                 '_' => '',                 '^' => '',                 '-' => ''                 );                      while (list($character, $replacement) = each($specialCharacters)) {                 $clean = str_replace($character, '-' . $replacement . '-', $clean);                 }                      // Remove all remaining other unknown characters                 $clean = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $clean);                 $clean = preg_replace('/^[\-]+/', '', $clean);                 $clean = preg_replace('/[\-]+$/', '', $clean);                 $clean = preg_replace('/[\-]{2,}/', '', $clean);                      if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $providername)) {                     $providername = $clean;                 } else {                     $providername = $_POST['providername'];                 }             }     }          if(isset($_POST['providerloc'])) {         $provider_location = $_POST['providerloc'];     }      This is the multi array argument:               $args = array(         'count_total' => true,         'role' => 'subscriber',         'offset' => 8,         'number' => 8,         'meta_query' => array(         'relation' => 'AND',             array(                 'key' => 'jabber',                 'value' => $provider_location,                 'compare' => 'LIKE'             ) ,             array(                 'key' => 'keywordcontent',                 'value' => $providername,                 'compare' => 'LIKE'             )           )     );      After testing this solution, I get no results when trying to search for the "clean" outputted value. For example: If...               $value = "G-P's Workin' Barn";      After applying `preg_replace`, the output will be... GPs Workin Barn Now...if I search for "GPs Workin Barn" (the output value), I get no results. But when I search for "G-P's Workin' Barn" (the original value), it shows the result for that term. So it seems that the query isn't able to process the output value. As I thought, this makes sense because the query is searching against stored values in the database...There should be a way for the query to interpret/translate the output value and compare it against the stored value. After searching online, the closest solution that relates to what I need is the post_where filter for posts [credit @Rarst]. There doesn't seem to be a similar filter for users. Even so, I need a way to search using REGEXP against actual variable values. Any thoughts or solutions? Thanks


Integrating planning tools in wordpress

Is there a way in wordpress that can integrate planning tools e.g If I need to provide tools, for example a guest list manager or a budget calculator, how do I integrate an these along with the site which will be linked to each user's account? Is it through creating a multisite and assigning each registered user with a site and having the tools on the users site that can be accessed by the user only? Any thought?


doubled content

I'm taking two templates and molding them into one that suits my needs. I'm getting this weird issue where things are repeating themselves just before the footer. Here's the code:               <?php get_header(); ?>          <?php if ( get_option('mycuisine_blog_style') == 'false' ) { ?>         <?php if ( get_option('mycuisine_quote') == 'on' ) { ?>

<?php echo get_option('mycuisine_quote_line1'); ?>

<?php echo esc_html(get_option('mycuisine_address')); ?>

          <?php } ?>

                  <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<?php esc_html_e('Address','MyCuisine'); ?>
                              <?php echo esc_html(get_option('mycuisine_address')); ?>

<?php esc_html_e('Hours Of Operation','MyCuisine'); ?>

<?php esc_html_e('Monday-Saturday:','MyCuisine'); ?> <?php echo esc_html(get_option('mycuisine_mon_fri')); ?>

<?php esc_html_e('Sunday:','MyCuisine'); ?> <?php echo esc_html(get_option('mycuisine_sat_sun')); ?>

<?php esc_html_e('Contact Info','MyCuisine'); ?>

<?php esc_html_e('Telephone:','MyCuisine'); ?> <?php echo esc_html(get_option('mycuisine_telephone')); ?>

                                     <?php do_action('et_location_additional_info'); ?>

                                                                                <?php do_action('et_location_content'); ?>                  <?php endwhile; endif; ?>

      <?php } else { ?>

                     <?php get_template_part('includes/entry','home'); ?>
                        <?php get_sidebar(); ?>

      <?php } ?>          <?php get_footer(); ?>      You can see it live (although, nobody knows about the site yet and it's not nearly finished) here. I have tried removing lines just to see what would happen and I can't sort it out.


Include CPT values in another CPT?

I'm trying to add CPT values in a drop-down menu within another CPT, not sure if this is do-able. Basically I have a Store CPT and a Manager CPT, in the manager cpt i have regular posts with the title, featured image, etc and what I would like to do is when I add a new store (on the Store CPT) i'd like to have a drop-down menu filled with the titles of Managers to be selected and associated, so that on the store page I can display the store manager as well. A point in the right direction would be appriciated. *CPT = Custom Post Type


list author's posts in author.php

I want to list 10 last posts of author in author.php template. I used this code:               <?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?>
     <?php endwhile;?>      But I can see only the last post of current author. Any help?


Hook into trash_post_comments, update_user_meta

I have a theme where the author get points for posting posts and comments. When I trash a post, the user get 1 point removed from their score. This works fine with this function: However... When I trash a post, I also want to trash the attached comments to it, and thus deduct a point for the comment being trashed. Because of wp_trash_post_comments I can't seem to get this to work, since it's not being set into the actual trash bin, it just changes the status. Any ideas how to hook this?


Displaying post excerpt using wpdb query

I'm using a modified version of the code from a question (Get WordPress Posts Grouped by Month) to group my posts by year. Everything is working fine, but I'm having trouble getting the post excerpt to display for the posts. Here is my current code: Pastebin I was able to get the post content to display by using post_content in place of post_excerpt in both the query and the output, but the excerpt just doesn't want to show up. I've also tried just using `the_excerpt();` and other methods of retrieving the excerpt, with no luck. I appreciate any help.


Site is not updating because something is wrong with custom code. How to fix it?

I really didnt know what a proper title for this question could be. Anyways, I have this code in functions.php which is breaking my site               function wp_show_post_views(){     global $post;     $postid = $post->ID;     $output_views = get_transient('views' . $postid);     if( !is_object( $post ) || true === $output_views ) return;     if( function_exists( 'stats_get_csv' ) ){         $args = array(               'days'  => -1,               'post_id'  => $postid          );          $postviews = stats_get_csv( 'postviews', $args );          $output_views = $postviews['0']['views'];              update_post_meta($post_id, 'postviews', $output_views);         set_transient('views' . $postid ,$output_views,60*60);     }     echo $output_views;     }       I am calling it in my single.php as follows:               <?php wp_show_post_views(); ?>      In the front end, everything looks good. However, if I go to the backend and update some widgets, there are no changes in the front end. Once I remove the code, everything works fine. So, I hope someone can tell me what is wrong with the code and if there is a way to fix it. **EDIT:** I narrow it down to this:                           $args = array(                   'days'  => -1,                   'post_id'  => $postid              );              $postviews = stats_get_csv( 'postviews', $args );              $output_views = $postviews['0']['views'];      So, the error must be in there. **EDIT: After enabling WP_DEBUG, I get his:**               [18-Sep-2013 19:44:36 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/user/public_html/domain.com/wp-includes/functions.php:2998) in /home/user/public_html/domain.com/wp-content/plugins/jetpack/modules/stats.php on line 433     [18-Sep-2013 19:44:36 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/user/public_html/domain.com/wp-includes/functions.php:2998) in /home/user/public_html/domain.com/wp-content/plugins/jetpack/modules/stats.php on line 434      **EDIT: Found more erorrs:**               [18-Sep-2013 20:02:51 UTC] PHP Notice:  Trying to get property of non-object in /home/user/public_html/domain.com/wp-content/themes/2012.ffwd/functions.php on line 235      **EDIT:** This is line 235                   $postid = $post->ID;      I am also getting this error:               [18-Sep-2013 20:16:19 UTC] PHP Notice:  has_cap fue llamado con un argumento que estÃ¡ obsoleto desde la versiÃ³n 2.0! El uso de niveles de usuarios por plugins y temas estÃ¡ obsoleto. Usa los perfiles y capacidades en su lugar. in /home/user/public_html/domain.com/wp-includes/functions.php on line 2998      Translated:               [18-Sep-2013 20:16:19 UTC] PHP Notice:  has_cap was called with an argument who are  obsolete  since version 2.0! The use of user levels by plugins and themes is deprecated. Use the profiles and capabilities instead. in /home/user/public_html/domain.com/wp-includes/functions.php on line 2998


GPL and intellectual or exclusive ownership

I have been searching and saw a lot of WordPress Themes Shops listed here http://wordpress.org/extend/themes/commercial/ that they have releasesd their themes in GPL but add this rule also, is this ok? > You may not claim intellectual or exclusive ownership to any of our > products, modified or unmodified. All products are property of .......


Point static content like css and js to cookieless subdomain

How can I change the links that WordPress generates for all static content like css, js, png, jpg, gif, etc to a cookieless subdomain? I don't want to use mod_rewrite. I want the PHP code to replace `www` with `s0` in the URL.


Where this validating message come from?

I wrote a simple form, including text field, textarea, select and some validating by WP_error. When I try to submit the form without filling text field or textarea, I got a popup tip pointing the blank text field, it says "please fill in the field". This is different from the error message I wrote, and I didn't write any ajax for validating-- my validating messages comes after the form submitted and redirected. Is this validating part of WP3.3 new feature? or it's a firefox feature? Edit: Thanks to joseph, found the reason-- it's html5 new feature-- required attribute > The required attribute applies to all form controls except controls with the > type hidden, image inputs, buttons (submit, move-up, etc), and select and > output elements. For disabled or readonly controls, the attribute has no > effect.


Modify posts listing at back end

I want to modify posts listing at back end? Say, for a particular user, with role author, O want to list only few posts at posts listing. How can I do this?


TinyMCE - no auto formatting using the_editor()?

I'm embedding the_editor on a admin page:               <?php the_editor(get_option('options_name'),'options_name'); ?>        And everything works fine, at least in back-end: ![TinyMce](http://i.stack.imgur.com/lcXtE.png) BUT on the front-end side I'm always getting inline output, there are no automatic paragraphs, breaks etc. They're just not being created. When I type them manually using HTML tags - it works. ![enter image description here](http://i.stack.imgur.com/Pkpxx.png) Any ideas what's wrong? Here's the full code so you will be able to copy&paste everything and check for your own. Does it work for you guys> Admin page:               <form method="post" action="options.php">     <?php wp_nonce_field('update-options'); ?>

                         <?php the_editor(get_option('custom_editor_test'),'custom_editor_test'); ?>

     <input type="hidden" name="action" value="update" />     <input type="hidden" name="page_options" value="custom_editor_test" />
     <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
     </form>      Front-end (do_shortcode part is optional, by the way shortcodes are being rendered just fine in my case):               <?php echo do_shortcode(get_option('custom_editor_test')); ?>


Simple/basic use of get_current_screen

I would like to load a stylesheet on only 3 admin pages:   * post.php?post=7&action=edit   * post.php?post=10&action=edit   * post.php?post=18&action=edit I was trying with `admin_enqueue_script` but it doesn't seem to be capable of such specificity (see my related wpse post), which led me to `get_current_screen`. But all the examples and articles I find about `get_current_screen` refer to using it with a plugin and/or plugin options page:   * http://codex.wordpress.org/Function_Reference/get_current_screen#Example   * http://code.tutsplus.com/articles/quick-tip-conditionally-including-js-and-css-with-get_current_screen--wp-25378   * http://amme86.wordpress.com/2013/12/10/25/ **I would simply like to use`get_current_screen` in my functions.php to determine if the admin page loaded is 1 of the 3 pages and if so load a css file.** A simple example would be very helpful (php novice here). Thank you for any help.


How might I retrieve a featured post image from an external WP site and display it as a link back?

I have two WP sites. I want to reach from one of them, into the other, and retrieve specific featured images for posts, and display them with a link to that post. I am using this line (with the correct info for my target database):               $mydb = new wpdb('username','password','database','localhost');      What would I follow that with to retrieve and display a post thumbnail? I am tinkering with a line of code I found elsewhere that looks like this:               $result = $mydb->get_results("select * from wp_posts where ID='1885'");      where '1885' is a sample post ID number. In an ideal world, I would develop this to the point where it functions as a widget. The client could simply enter a post ID number from the external WP site, and the widget would retrieve the appropriate thumbnail, and display it as a link back to the appropriate post on the other site. I am not literate at all with PHP. So far I do my best just manipulating snippets and working them into my theme templates.


Run Function if Order Meta Exists - WooCommerce

If a checkbox is checked, it saves a value of 1 for a 'my_checkbox' custom order field in WooCommerce. I'm editing the order admin table and I need to be able to echo a particular icon url if the value of 'my_checkbox' equals 1. I just don't know how to check if the value is equal to one so I can echo the url. Any ideas? To make troubleshooting easier, here's the code:               /**     * Add checkbox field to the checkout     **/     add_action('woocommerce_after_checkout_billing_form', 'match_previous_order_checkbox');          function match_previous_order_checkbox( $checkout ) {     echo '
';     woocommerce_form_field( 'my_checkbox', array(          'type'     => 'checkbox',          'class'    => array('form-row notes'),          'label'    => __( 'This is a previous order' , 'woothemes'),          'required' => false,         ),          $checkout->get_value( 'my_checkbox' ));         echo '
';     }     /**     * Update the order meta with field value     **/     add_action('woocommerce_checkout_update_order_meta', 'match_order_checkout_field_update_order_meta');          function match_order_checkout_field_update_order_meta( $order_id ) {         if ($_POST['my_checkbox']) {         update_post_meta( $order_id, 'My_Checkbox', esc_attr($_POST['my_checkbox']));         }     }     global $order;     $match_order_meta = get_post_meta( $order_id , 'My_Checkbox' );      `$match_order_meta = get_post_meta( $order->ID , 'My_Checkbox' );` doesn't work either. Also whether or not I include `global $order;` doesn't seem to matter.


How do I increase the 255 character limit on the 'description' field for link library links?

My descriptions are being cut off and I need to increase this field to accomodate more text. Thanks.


How to display error messages using WP_Error class?

I have registration form code in my `functions.php` file like this               if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['action']) && $_POST['action'] == 'registration') {            $error = new WP_Error();             if (empty(esc_attr($_POST['email'])))             {                 $error->add('regerror','Email is required.');             }             if (!is_email(esc_attr($_POST['email'])))             {                 $error->add('regerror','Invalid email format.');                  }             if (email_exists(esc_attr($_POST['email'])))             {                 $error->add('regerror','Email already in use. Did you forget your Password? If yes click here to reset.');                  }     }      Now can someone tell me how to display those error messages in my `register page`? ## Update: My registration page has code like this               <form method="post" action="<?php the_permalink(); ?>">     <!-- form fields goes here -->     <input name="action" type="hidden" value="registration" />     <input type="submit" id="submit" value="Register">     </form>


My jQuery is enqueued properly. So why isn't it working?

I'm just trying to add a simple bit of Show/Hide jQuery to a child theme.               $(document).ready(function(){      $("#openbtn").click(function(){       $("#openingtimes").toggle(300);      });     });      I've saved the above code in a file called `buttons.js`. I have then registered and enquequed the script using the following in my `functions.php` file:               <?php      if ( !is_admin() ) {      wp_register_script('buttons',        get_bloginfo('stylesheet_directory') . '/buttons.js',        array('jquery'),        '1.0' );           wp_enqueue_script('buttons');      }      ?>       In the outputted Source Code, the script seems to have properly loaded.                          But the button has no effect. For good measure, here's the HTML it should be affecting:               <button id="openbtn">Opening Times</button>

                        Mondays: Closed
                        Tues-Fri: Noon-3pm; 5.30pm-10pm
                        Sat-Sun: Noon-10.30pm

      Any help much appreciated.


Compatibility of MathJax extension and JetPack

I just installed the MathJax Extension for Wordpress because I did not really like the way the math were rendered with the `[latex]` tags provided with the JetPack. If I use the classic `$$`, the blog renders the equation using MathJax. However, if I keep using `[latex]` the JetPack function seems to be used, and I can't find a way to only remove this feature from the jetpack? Is there any known issue in having the two methods at the same time? Is there a way to remove only this feature from the jetpack?


Date based URLs for custom posts and pagination

I have created a custom permalink structure for a custom post type (events) using the code below:               $GLOBALS["wp"]->add_query_var("event_year");     $GLOBALS["wp"]->add_query_var("event_monthnum");     $GLOBALS["wp"]->add_query_var("event_day");          $GLOBALS["wp_rewrite"]->add_rewrite_tag("%event%", "([^/]+)", "event=");     $GLOBALS["wp_rewrite"]->add_rewrite_tag("%event_year%", "([0-9]{4})", "event_year=");     $GLOBALS["wp_rewrite"]->add_rewrite_tag("%event_monthnum%", "([0-9]{1,2})", "event_monthnum=");     $GLOBALS["wp_rewrite"]->add_rewrite_tag("%event_day%", "([0-9]{1,2})", "event_day=");          $GLOBALS["wp_rewrite"]->add_permastruct("event", "/event/%event_year%/%event_monthnum%/%event_day%/%event%", false);      For the most part this works just as expected. A problem however arises when I try to use pagination on a URL with a year, month and date. In which case it is assumed that "page" is the value for %event%. I used the _Monkeyman Rewrite Analyzer_ plugin where I noticed the required pattern (`event/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$`) is listed, but only after the pattern that tries to use the page argument as event name (`event/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$`). I also noticed that calling `$GLOBALS["wp_rewrite"]->rewrite_rules()` after the rewrite definitions will make pagination work but breaks URLs with event names (somehow event_year, event_monthnum, event_day and event translate to $1, $2, $3 and $4 in that case). Calling `$GLOBALS["wp_rewrite"]->flush_rules()` did make everything work as I required but that wouldn't be a good solution. Is there some way I could flip the patterns so that the pattern that looks for a page comes before the pattern that looks for a post name?


Plugins used on this wp page

I am currently setting up a wordpress page and am looking for suitable plugins. The style of the questions posted in the "top questions" section is actually what I need. Also the voting widget in a question post looks great. Does anybody know how these plugins are called or where I can download them if not at wordpress.org? I'd really appreciate an answer! Cheers


Woocommerce disable shopping cart based on user roles

Is there anyway to disable the shopping cart for guest users but have a quote only option and have the shopping cart function for wholesale users? Any help is greatly appreciated. Thank you.


Using is_main_query to select custom post type on certain page

I've been trying to implement some of the ideas discussed by Andrew Nacin http://wordpress.tv/2012/06/15/andrew-nacin-wp_query/ into my workflow, specifically trying to move away from using query_posts or a new WP_Query and altering the main query instead. So far I have this working on my homepage pretty well using the following code:               function some_name($query) {         if ( $query->is_main_query() && $query->is_home() ) {             $query->set( 'post_type', array( 'home_portfolio' ) );         }     }     add_action( 'pre_get_posts', 'some_name');      This simply changes the default query's post_type to home_portfolio. I had to use the default index.php file and not select a page to use as the front page in order to get this to work. I would like to use this method on certain pages too, but I'm unsure how to target the pages from functions.php. if I use `$query->is_page(ID)` the standard loop on the page returns a 404 whenever I try and change the post_type. In other words, it seems to me that I should just be able to replace `$query->is_home()` with `$query->is_page(ID)` in `functions.php` and I should be able to target that specific page ID however I can't get it to work. Any help would be greatly appreciated. Otherwise I'm being really efficient on my home page but all other pages are still running multiple queries (compared to modifying the main query on those pages).


Custom fields issue

I installed the plugin Advanced Custom Fields and created few custom fields , but I'm not able to add any content in it. How is this done?


Append data to the_content within the database (not using filter)

My site requires that people can search for terms that are included in tags and categories (towns and counties). I'm having some resource issues using the 'Search Everything' plugin, it's causing the mysql database to lock and giving me massive slowdown. I don't blame the plugin, I blame my shared hosting. BUT, I was wondering if I could avoid using a plugin at all by simply appending the post tags and category names to the_content **within the database** (instead of using a filter which I believe would only include the terms as they are rendered on the page) so that the **in-built WordPress search** could then be satisfactory and would find these terms. I've read lots of different codex pages and tutorials and not found what I need, but I'm hoping someone could have a look at the following code and give their thoughts on whether it might work (I do not have a test server available at the moment and am hesitant to run it on a live site!) (Note this example includes tags only so far)               function tags_in_content($post_id, $post) {          $content = get_the_content();     $tags = get_tags();           $content->append('$tags');     }          add_action ( 'publish_post', 'tags_in_content' );      **It can't be that simple can it?!** Many thanks for any help anyone can give me!


How do I do this with WordPress? Taxonomies?

I was hoping to get some help with how I organise posts in WordPress. I have 2 Custom Post Types called 'Places' and 'Events'. In the Admin, I'd like to be able to create a 'Place' post and associate multiple 'Events' posts to this. So perhaps inside an 'Event' post, I can select a 'Place' post from a list to associate that 'Event' with that 'Place'. Can someone explain how I would achieve this? Would I have to look at Taxonomies? Many thanks for any advice.


Using Query In Post Type Archives

I'm using the script below to call post from a certain category in the sidebar. It pulls from all post type on the homepage and on the single post page, but when it comes down to the post type archive pages it doesn't show but only from that post type archive in which you are viewing.....I want it to show from all post types not matter what post type archive you are viewing.               <?php     $queryObject = new  Wp_Query( array(             'showposts' => 4,             'post_type' => array('pretty-little-liars', 'revenge', 'once-upon-a-time','scandal'),             'category_name' => celebrity,                 'orderby' => 1,             ));     // The Loop!     if ($queryObject->have_posts()) {      ?>     <?php     while ($queryObject->have_posts()){         $queryObject->the_post();         ?>      How do i get it to show post from all post type by category on the post type archive page?


Custom rewrite rule for backend/admin?

I would like to create a custom rewrite rule that will take the URL: `http://domain/submit-project/add` but display `http://domain/wp/wp-admin/post-new.php?post_type=project` Is there any way to do this? I am trying to add the rewrite rule so in my theme's `functions.php`               add_action( 'init', 'add_custom_rules' );          function add_custom_rules() {       add_rewrite_rule(         "^submit-project/add",               "/wp/wp-admin/post-new.php?post_type=project",               "top");     }      I've tried flushing the rules, but this always seems to enter some kind of loop always going back to the 'login' page. **Edit**   1. The URL is actually just 404-ing now   2. I should add that I do have a page with the slug `submit-project` and thus the URL: `http://domain.com/submit-project` in case it matters.   3. I've installed the plugin Rewrite Rules Inspector and can't seem to find my rule in there.


What happens when two or more plugins use the same hook?

Two of my plugins use the same filter hook: `the_content`. What happens in this case? Is there a priority handler, like which plugin will be served first? I would like to use both of the plugins. I need to call one plugin first and then the second plugin will add more content onto the end of the first plugin. What is the best approach to accomplish this? Or am I doing something wrong here?


Hierarchial Custom Post Types/Taxonomies

I've been learning Wordpress for the last few weeks and I'm now creating my own theme. I found this question which seems to be exactly what I want to do, but I can't get it working and I suspect its me rather than a code issue. URLs are to be like this: > domain-root/sports --> would show a list of all sport-types regardless of > which type they are in > > domain-root/sport/sport-type-parent --> would show parent and recurring > child sport-types > > domain-root/sport/sport-type-parent/sport-type-child --> shows sport-type > child and children of it > > domain-root/sport/sport-type-parent/sport-type-child/sport-page --> shows > the page for the sport I'm using these sport-types:               - Football (Parent Sport Type)         - 6-a-side (Child Sport Type)             - Powerleague (page)         - 11-a-side      I want to end up with a URL like > domain-root/sport/football/6-a-side/powerleague which is a page to view about that _powerleague_. I'm currently working on the basis that I would never have more than 3 levels so changed the original source in the question above accordingly. My _Settings > Permalink_ option is set to default, but I don't know what it should be. Is this all correct? What needs changing to get this working? Here is the functions from my functions.php file:               function custom_post_sport() {         $labels = array(             'name'               => _x( 'Sports', 'post type general name' ),             'singular_name'      => _x( 'Sport', 'post type singular name' ),             'add_new'            => _x( 'Add New', 'book' ),             'add_new_item'       => __( 'Add New Sport' ),             'edit_item'          => __( 'Edit Sport' ),             'new_item'           => __( 'New Sport' ),             'all_items'          => __( 'All Sports' ),             'view_item'          => __( 'View Sport' ),             'search_items'       => __( 'Search Sports' ),             'not_found'          => __( 'No sports found' ),             'not_found_in_trash' => __( 'No sports found in the Trash' ),              'parent_item_colon'  => '',             'menu_name'          => 'Sports',             'rewrite'            => array( 'slug' => 'sports/%taxonomy_name%' )         );              $args = array(             'labels'        => $labels,             'description'   => 'Holds our sports and sport specific data',             'public'        => true,             'menu_position' => 6,             'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),             'has_archive'   => true,         );              register_post_type( 'sport', $args );        }          add_action( 'init', 'custom_post_sport' );          function taxonomies_sport() {         $labels = array(             'name'              => _x( 'Sport Types', 'taxonomy general name' ),             'singular_name'     => _x( 'Sport Type', 'taxonomy singular name' ),             'search_items'      => __( 'Search Sport Types' ),             'all_items'         => __( 'All Sport Types' ),             'parent_item'       => __( 'Parent Sport Type' ),             'parent_item_colon' => __( 'Parent Sport Type:' ),             'edit_item'         => __( 'Edit Sport Type' ),              'update_item'       => __( 'Update Sport Type' ),             'add_new_item'      => __( 'Add New Sport Type' ),             'new_item_name'     => __( 'New Sport Type' ),             'menu_name'         => __( 'Sport Types' ),             'rewrite'            => array( 'slug' => 'sports', 'with_front' => true, 'hierarchical' => true )         );              $args = array( 'labels' => $labels, 'hierarchical' => true, );              register_taxonomy( 'sport-type', 'sport', $args );     }          add_action( 'init', 'taxonomies_sport', 0 );          add_filter('rewrite_rules_array', 'mmp_rewrite_rules');          function mmp_rewrite_rules($rules) {         $newRules  = array();         $newRules['basename/(.+)/(.+)/?$'] = 'index.php?custom_post_type=$matches[4]';     // my custom structure will always have the post name as the 5th uri segment         $newRules['basename/(.+)/?$']                = 'index.php?taxonomy_name=$matches[1]';               return array_merge($newRules, $rules);     }          function filter_post_type_link($link, $post) {         if ($post->post_type != 'custom_post_type_name')         return $link;              if ($cats = get_the_terms($post->ID, 'taxonomy_name')) {             $link = str_replace('%taxonomy_name%', get_taxonomy_parents(array_pop($cats)->term_id, 'taxonomy_name', false, '/', true), $link); // see custom function defined below         }         return $link;     }     add_filter('post_type_link', 'filter_post_type_link', 10, 2);          // my own function to do what get_category_parents does for other taxonomies     function get_taxonomy_parents($id, $taxonomy, $link = false, $separator = '/', $nicename = false, $visited = array()) {             $chain = '';            $parent = &get_term($id, $taxonomy);              if (is_wp_error($parent)) {             return $parent;         }              if ($nicename)                 $name = $parent -> slug;                 else                 $name = $parent -> name;              if ($parent -> parent && ($parent -> parent != $parent -> term_id) && !in_array($parent -> parent, $visited)) {                 $visited[] = $parent -> parent;                 $chain .= get_taxonomy_parents($parent -> parent, $taxonomy, $link, $separator, $nicename, $visited);         }              if ($link) {             // nothing, can't get this working :(         } else                 $chain .= $name . $separator;                 return $chain;         }


save_post hook frustration

Clean 3.8.1, clean Twenty Fourteen theme, no plugins except for my own custom one. The main plugin PHP file only has a single "require_once('test.php')" And "test.php" in its entirety is:               add_action('save_post','save_post_action');     function save_post_action($post_ID) {         echo '
THIS IS A TEST
';     }      When I create a new post, I get a red banner across the top of the page as expected. But when I change the post and click "Update" I do not. I've searched and seen several other people with the same problem, but none of the suggested solutions are doing anything for me. Clearly I'm doing something wrong... But what?


Ajax, jQuery and Wordpress

I'm having trouble getting AJAX and jQuery to work with WP, and wondering if someone can point me in the right direction. I have a form, and I want to pass the data from the form to a PHP function, where the data is returned and a `<div>` is created with the data manipulated by a PHP function. I've got a version working outside of WP, but I can't seem to port it. I've followed many tutorials, and nothing seems to work. I've got the following code, it should simply create an alert window with the data from the form , with "hello" prepended, but the JS function never even gets called. It keeps adding `?name=name` to the page URL. I've also tried creating a seperate JS file, and loading the script with..               wp_enqueue_script(     'myaddwordscript',     plugins_url() . '/MyPlugin/script.js',     array( 'jquery' )      Any help getting it to work is greatly appreciated.               <?php     /**      * Plugin Name: Addword      * Plugin URI: Addword      * Version: 1.0      */               /**      * Make sure jquery is loaded      */     function add_to_header() {         wp_enqueue_script('jquery');      }      add_action( 'wp_enqueue_scripts', 'add_to_header' );               /**      * Add shortcode to show form and script      */          function add_word( ) {                $script = "     <script>     jQuery('#ajax_form').bind('submit', function() {         alert('clicked');         var form = jQuery('#ajax_form');         var data = form.serialize();         data.action = 'add_word_to_form'         jQuery.post('/wp-admin/admin-ajax.php', data, function(response) {             alert(data);                    });         return false;     });     </script>";          $form ='     <form class="form" id="ajax_form">                                     <input type="text" name="name" id="name"  placeholder="Word Goes Here" required="">         <input type="submit" value="Submit" id="submitaddword">     </form>';          return $script.$form;               }     add_shortcode( 'addword', 'add_word' );               /**       * Set up AJAX call to add word      */     add_action("wp_ajax_add_word_to_form", "add_word_to_form");     add_action("wp_ajax_nopriv_add_word_to_form", "add_word_to_form");          function add_word_to_form ($data)     {         return "Hello".$data;          }               ?>