Get Tags specific to Category using WooCommerce plugin

Could anyone help me to implement this code in WooCommerce, ie instead of categories to use product categories, and instead of tag to use product tag. In functions.php :               function get_category_tags($args) {     global $wpdb;     $tags = $wpdb->get_results     ("         SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link         FROM             wp_posts as p1             LEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID             LEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id             LEFT JOIN wp_terms as terms1 ON t1.term_id = terms1.term_id,                  wp_posts as p2             LEFT JOIN wp_term_relationships as r2 ON p2.ID = r2.object_ID             LEFT JOIN wp_term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id             LEFT JOIN wp_terms as terms2 ON t2.term_id = terms2.term_id         WHERE             t1.taxonomy = 'category' AND p1.post_status = 'publish' AND terms1.term_id IN (".$args['categories'].") AND             t2.taxonomy = 'post_tag' AND p2.post_status = 'publish'             AND p1.ID = p2.ID         ORDER by tag_name     ");     $count = 0;     foreach ($tags as $tag) {         $tags[$count]->tag_link = get_tag_link($tag->tag_id);         $count++;     }     return $tags;     }      In wp theme:               $args = array('categories'=> '3');      $tags = get_category_tags($args);      $content .= "
";      foreach ($tags as $tag) {          $content .= "
tag_link\">$tag->tag_name
";     }      $content .= "
";      echo $content;


WordPress 3.1 not compatible with jQuery Mobile?

I recently updated to WordPress 3.1, and with that update, something very interesting happened. Links became unclickable -- clicking on any link would literally result in nothing happening. Interestingly enough, all of the jQuery stuff still works. Removing the jQuery Mobile script gets rid of the problem. The error being generated was:               Error: uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"  location: "JS frame :: http://......./wp-includes/js/jquery/jquery.js?ver=1.4.4 :: anonymous :: line 138"  data: no]      Any idea how to fix this?


How to create a custom search in wordpess matching with title and metadata

I want a custom search in wordpress where the search query should return results matching to post title or with a custom metadata. For example if a user is searching for "chicken" in my site, it should return all posts with a matching title like "chicken fry" and all posts which use chicken as an "ingredient" (ingredient is the metadata name). I wrote the following script                       $searchArgs = array(                 'post_type' => 'post',                 'post_status' => 'publish',                 'orderby' => 'title',                 'order' => 'ASC',                 'nopaging' => true,                 'meta_query' => array(                     'relation' => 'AND',                     array(                         'key' => 'ingredient',                         'value' => $q,                         'compare' => 'LIKE',                     )                 )                    );             $the_query = new WP_Query( $searchArgs );             while ( $the_query->have_posts() ) {                 $the_query->the_post();                 echo get_the_title();             }      How can I include a like search in title also? I found this post Using meta query ('meta_query') with a search query ('s') But it needs three queries and seems a little complex. Is there any direct query?


Using My-Meta-Box-Class plugin, how is 'Date' value stored?

I've created some custom fields in a custom post type using the my-meta-box- class plugin which comes with a built in 'date' type of meta box input. I'm having a hard time ordering my custom posts by date. Is the date in this plugin stored as a strtotime()? If not, how can I slightly modify the plugin to get it to do so. Is that even necessary? Is there an easier way to order the events in my custom post type using what is already there in the plugin?


Using functions from a plugin in your theme

I am a beginner to wordpress (and to php for that matter). I am trying to understand some of the basics, and building a little e-commerce store using a plugin called "Jigoshop." I'm reading through the source files and seeing a bunch of useful functions- things like a "is_featured" function that returns true if the product has a product meta that marks it as featured; or a reference to all products that I can use without having to set up my own by querying the posts and filtering out those that are not products. I have a custom-template file that I am using for the storefront (homepage), and I would like to access some of these functions to simplify the code I have to write, but it seems I don't have access to them. My questions is: Are functions and objects defined in a plugin useable in my theme templates (or custom templates; I'm using a child theme right now)?


Display number of latest images from wordpress gallery in your homepage

I was trying to get a solution for something that I am trying to accomplish. I am using the wordpress native and simple gallery to show images in a page called: "gallery" so far - very simple. it works fine and I have a gallery page with thumbnails. Now, I would like to show 8 latest photo thumbnails in my homepage. no link to the bigger image is necessary, just literally, grab 8 (or another number..) latest images which was added to that gallery and show them in a simple box in my homepage. I would also like to output my own HTML so I can customize it to my homepage needs. anyone has a solution? Thanks a lot.


Multiplile values checkbox or select in custom meta box

I have followed the great answer by Jan Fabry in this question . How to make multicheck for post/page meta box this works great. My question though would be , what if someone WANTS a serialized value (array e.g. :"banana,apple,grapes" in ONE field ? ) and not separate values ? It is strange how in all the tutorials, example, and classes, everyone ignores multiple selection (also in select list)


How to make an admin create/edit post page to look like taxonomy page?

This idea just came to me, where I thought it would be great to have something like this for CPTs that doesn't need much content/fields to fill out. Basically a Post page where your able to add a post, as well as see the other posts in a list-table next to edit. For instance like the picture below: ![Post Page that looks like Taxonomy Admin Page](http://i.stack.imgur.com/Z4ecm.jpg) Of course, there will be no use for WYSIWYGs, but I think this would be great for simple CPTs if this is something we're able to create in the Admin page. Would love to know if this is possible, or examples of something similar if you seen such a thing.


PHP Fatal Error - $wpdb a non-object?

I'm getting many Fatal errors like this in Wordpress 3.6.1, multisite with Buddypress: `PHP Fatal error: Call to a member function suppress_errors() on a non-object in /myblog/wproot/wp-includes/option.php on line 143` The non-object referred to is the global value $wpdb, in the line: `$suppress = $wpdb->suppress_errors();` which is in the function **wp_load_alloptions()** Any ideas why $wpdb would not be set, and if there is anything to be done to remedy this? Sorry I don't have any more useful on this, the errors are isolated and don't show a stack trace.


Multilanguage site with two domains

I want to make the same site in two languages, spanish and english. After test a pair of plugins and see which options exists looking at some technical blogs, I think the better is to make two blog with native languages in different domains. So now I have one site running in spanish (not full but near ready), and I need to translate to english. Migrate content is hard but I think I can do it. The problem for me is how to display flags, and redirect to target site. ¿How can I do this? I´ve seen Zanto plugin but I don´t know if it suits my needs. Any comment or advise is very welcome.


Grant user rights to access certain tabs of a plugin

I found out a way to grant a user permission to access a single plugin but it has its flaws. Right now there are 6 tabs on the options page of this plugin. ![The tabs](http://i.stack.imgur.com/mh1cC.png) The user has access to all these tabs now. I just want him to be able to access "1, 2 and 4 ". The rest should **not** be visible for him. This is the piece of code I have set up for this. It allows the Editor to access the settings page. See image for the settings page.               if ( is_admin() )       {           add_action( 'admin_menu', 'add_plugin_for_editors' );       }            function add_plugin_for_editors()        {           if (!current_user_can( 'manage_options' ))           {               add_menu_page('Rooster', 'Rooster', 'editor', 'rooster', 'rooster_html_page');           }       }        If something is unclear please let me know. Feel free to edit my post if you see any grammatical errors.


Wp3.5 Media Gallery Edit modal: change captions to title

How can i change those editing inputs to title from caption? ![wp3.5 gallery edit](http://i.stack.imgur.com/MDUwZ.png) Some sources i found about new upload system:   * Using the WordPress 3.5 Media Uploader within plugins   * How to Add the WordPress 3.5 Media Manager Interface Basically looking for a proper solution like this:               // http://wordpress.org/support/topic/wp-35-any-way-to-default-add-media-to-upload-files#post-3709109     // If you want to have the editor default to the Upload Files tab in the admin editor     add_action( 'admin_footer-post-new.php', 'idealien_mediaDefault_script' );     add_action( 'admin_footer-post.php', 'idealien_mediaDefault_script' );     function idealien_mediaDefault_script()     {         ?>     <script type="text/javascript">     jQuery(document).ready(function($){         wp.media.controller.Library.prototype.defaults.contentUserSetting = false; // making editor default to the Upload Files          });     </script>     <?php }


Variable use in get_template_part

As far as I understand (from the get_template_part codex) `get_template_part` is just a wrapper round the PHP require function. So if I have a variable that I have create in a page template file e.g. `$message`, I would have assumed you could directly use that variable in the template part So in template file:               <?php      $message = 'my message';     get_template_part('messages');      ?>      Then in template part messages.php:               <?php echo $message; ?>      However the echo will display nothing.


How to change twentytwelve child theme site title separator

I am using a child theme with WordPress twentytwelve. I'm confused as to what function I can use in the child theme's functions.php to just change the site title separator, from its default vertical slash | to a hyphen -


Get all media categories

I've added a new taxonomy for the medias post type:               function register_taxonomy_for_images()     {         register_taxonomy_for_object_type('category', 'attachment');     }          add_action('init', 'register_taxonomy_for_images');      And I've added a few categories via wordpress admin.How can I get an array of all the media categories that I added? I've tried get_categories() but it doesn't work.


WordPress 3.8 get current admin color scheme

I'm trying to get the stylesheet of the currently active admin color scheme to style a plugin to fit into the color context. As mentioned in this post I had a look at the implementation of `admin_color_scheme_picker()` in `wp-admin/includes/misc.php:564`. They use a global variable called `$_wp_admin_css_colors` but when I try to access (`var_dump()`) it, it's `NULL`. Is there any way to access to actual CSS code? Why is the global variable `NULL`? I did a `grep -n '$_wp_admin_css_colors' -r .` and couldn't find any line where it gets destroyed... **EDIT** I see it wasn't clear what I exactly want. I don't want to access the actual CSS code, but the color codes that gets parsed into CSS. In `wp- includes/general-template.php:2117` the default themes are registered like this:               wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ),         admin_url( "css/colors$suffix.css" ),         array( '#222', '#333', '#0074a2', '#2ea2cc' ),         array( 'base' => '#999', 'focus' => '#2ea2cc', 'current' => '#fff' )     );      And I'd like to access the variables like this in PHP. Copying the definition is not an option, since other plugins and themes could add their theme themselves.


publish_post plugin hook doesn't always pass $post->post_content

I've written a simple plugin that grabs the contents of a post, as the post is published, and sends them to an external site for archiving. This generally works but when dealing with posts that haven't previously been saved or published, no `post_content` value is available. If you save as draft before publishing it all works fine, it's only when you publish straight away that the value is empty. My plugin is something like this:               function send_data($postID,$post){       global $post;       print_r($post); //used for debugging the contents of $post       //stuff here to send the post for archiving     }     add_action('publish_post','send_data',2);      And, if all goes well, I get this as the content of $post:               WP_Post Object ( [ID] => 159 [post_author] => 1 [post_date] => 2013-01-30 09:11:05 [post_date_gmt] => 0000-00-00 00:00:00 [post_content] => This is the content of the post [post_title] => Something new [post_excerpt] => [post_status] => draft [comment_status] => open [ping_status] => open [post_password] => [post_name] => [to_ping] => [pinged] => [post_modified] => 2013-01-30 09:11:05 [post_modified_gmt] => 2013-01-30 09:11:05 [post_content_filtered] => [post_parent] => 0 [guid] => http://wordpress/?p=159 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw )      But, if I jump straight from creating my post contents to the 'publish' button, I get an empty value for `$post->post_content`:               WP_Post Object ( [ID] => 159 [post_author] => 1 [post_date] => 2013-01-30 09:11:05 [post_date_gmt] => 0000-00-00 00:00:00 [post_content] => [post_title] => Something new [post_excerpt] => [post_status] => draft [comment_status] => open [ping_status] => open [post_password] => [post_name] => [to_ping] => [pinged] => [post_modified] => 2013-01-30 09:11:05 [post_modified_gmt] => 2013-01-30 09:11:05 [post_content_filtered] => [post_parent] => 0 [guid] => http://wordpress/?p=159 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw )      Does anyone have any thoughts on how I can make this more reliable? Is there a hook for `after_publish_post` or something similar? Any thoughts appreciated.


Facebook social publisher and custom post type fields

I have a problem with how Facebook plugin shows my WordPress-based posts on my timeline. What basically happens is that the post image isn't shown. Now, the post image I want to show is a custom field of a custom post type, and this is probably what's causing the problem to the Facebook plugin. On the single-post page I added manually the `og:` tags, and they're working properly (I see the image if I share the link on Facebook, and the Facebook object debugger shows it too, saying there are no problems). Do have I to do something to add manually the requested `og:` tags in post_publish hook? A sample page is this: http://www.zannoni-store.it/prodotti/canestro-sonoro And what I added in order to let the image be shown on share is this:               ..     $img = get_post(get_post_meta($post->ID, 'immagine', true));      echo '<meta property="og:image" content="'.$img->guid.'" />';     ..


Parse a shortcode differently based on on what it's nested in

Suppose we have two different sets of nested shortcodes, like this: ### Apple version   * `[wrapper snack="apple"] Today I had a [flavor] snack... [/wrapper]`   * **Desired output:** My snack was quite HEALTHY today... ### Donut Version   * `[wrapper snack="donut"] Today I had a [flavor] snack... [/wrapper]`   * **Desired output:** My snack was quite FATTY today... My question is: how can I parse the nested shortcode (`[flavor]`) differently depending on the shortcode it's nested in (i.e., based on `[wrapper]`'s snack attribute)? Please accept for the sake of the question that it's impossible/impractical to add an attribute to `[flavor]`. In pseudo-code, it might work something like this:               function flavor_shortcode_handler ( $atts, $content ) {         $wrapper = ??? // The value of the shortcode this is nested inside              if ( $wrapper == 'apple' ) return 'HEALTHY';         if ( $wrapper == 'donut' ) return 'FATTY';     }      I imagine there are a variety of ways to get the same effect by how we write `wrapper`'s handler function. ## Idea 1: Use a global variable               function wrapper_shortcode_handler ( $atts, $content ) {          // After extracting the snack attribute...          $GLOBALS['wrapper_value'] = $snack;          return do_shortcode( $content );     }      ## Idea 2: Find/replace the nested shortcode before processing it               function wrapper_shortcode_handler ( $atts, $content ) {          // After extracting the snack attribute...          $new_content = str_replace( '[flavor]', '[flavor wrapper="'.$snack.'"]', $content );          return do_shortcode( $new_content );     }      Obviously the examples and solutions are oversimplified, but is there an alternative that would work better?


Is it possible to remove next-post / previous-post with out creating a custom template?

I'm creating a plugin that uses a custom post type. I do not want to make a custom template for viewing the posts and discovered I can add a filter for the_content to include my custom fields, this works great. However, I don't want visitors to navigate the custom post types with the previous next navigation. It there a way to remove these without creating a custom template? Thank you for taking the time to look at my issue.


Show all parents and child posts using Types plugin

I'm using the plugin Types and need to show all the parents and their children. There parent is specialty and the child is specialtytype For example:   1. parent      * child     * child   2. parent      * child   3. parent      * child     * child     * child Here is my code that is only show the parents and not outputting the child posts:               $args = array('numberposts' => -1, 'orderby' => 'name', 'post_type' => 'specialty');     $query = get_posts($args);          foreach($query as $post)     {       echo '
' . get_the_title($post->ID) . '
';            //children       $child_posts = types_child_posts('specialtytype', array('post_id'=> $post->ID));            foreach ($child_posts as $child_post)       {         echo '
' . get_the_title($child_post->ID) . '
';       }     }


WordPress Multisite — Have same navigation, sidebar and footer across all sites.

I've been looking around for a while now and still can't find a solution so am asking here. I have a site where anyone can sign up and create their own blog as a subdirectory of the main website. What I want is for every blog to have the same navigation (in essence the same header), footer and sidebar as the main website of the network. I couldn't find what I was looking for in the WordPress Codex. Has anyone found a solution to this before or can point me in the right direction?


How can I check for a thumbnail in WordPress?

How can I can I check if a post has a thumbnail and if does do something? If doesn't do something else. This is what I have:                <?php if (has_post_thumbnail()) ?>           <?php the_thumbnail(); ?>      ?>           <?php else ?>           <?php the_permalink();?>           <?php endif; ?>      Any help will be appreciate it.


add_action 'init' from inside a class for custom post types

I'm trying to create archive pages for my custom post type. I create custom post types from within custom classes: functions.php               include_once(get_template_directory() . '/admin/admin_init.php');      admin_init.php               include_once(ADMIN_CPT_DIR . '/CPT.php');      CPT.php               class CPT     {         protected $cpt_name;              public function __construct($cpt_name)         {             $this->cpt_name = $cpt_name;             add_action('init', array( $this, 'cpt_init' ) );         }              public function cpt_init()        {             $labels = array(             'name' => __('custom_name', 'textDomain'),             'singular_name' => __('custom_name', 'textDomain')              );                  $args = array(             'labels' => $labels,             'public' => true,             'has_archive' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'show_ui' => true,             'show_in_menu' => true,             'has_archive' => true,             'query_var' => true,             'rewrite' => array('slug' => 'custom_name'),             'supports' =>array('title','editor', 'custom-fields','thumbnail')         );              register_post_type( $this->cpt_name, $args );        }     }          if( is_admin() )         $cpt = new CPT('cpt_child');      The custom post type is registered and all works fine, but I always get a 404 when trying to access the archive page (archive-custom_name.php). If I take the inner part of the cpt_init - method and put it into the functions.php like so:               add_action( 'init', 'create_post_type' );              function create_post_type()         {             $labels = array(             'name' => __('mycpt', 'synTh_textDomain'),             'singular_name' => __('mycpt', 'synTh_textDomain')             );                  $args = array(             'labels' => $labels,             'public' => true,             'has_archive' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'show_ui' => true,             'show_in_menu' => true,             'has_archive' => true,             'query_var' => true,             'rewrite' => array('slug' => 'boom'),             'supports' =>array('title','editor', 'custom-fields','thumbnail')             );                    register_post_type( 'mycpt', $args );         }      everything works as expected. There is an `archive-boom.php`, which I can access via: `www.domain.com/boom/` I flushed the permalinks settings and I have them set to postname. Is there a difference, when attaching to a hook from inside a class??


How to add external remote JS source to Gravity Forms?

I would like to add an external javascript source to my Gravity Form. Like this:               <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true_or_false"></script>      How to do this? I don't get how can I do this with the function: wp_enqueue_script Then after adding this external/remote JS source, I would like use a custom JS with http://www.gravityhelp.com/documentation/page/Gform_register_init_scripts such as this line:               var autocomplete = new google.maps.places.Autocomplete(inputAddress);      But this won't work unless I have the external JS source added...Any ideas?


How to load a jQuery script last?

How to get this to load last?                <script type="text/javascript">       jQuery(document).ready(function(){        jQuery("div.domTip_tipBody").mouseover(function(){        jQuery("#yyy a.tippy_link").css("background-color","yellow");});               jQuery("div.domTip_tipBody").mouseout(function(){        jQuery("#yyy a.tippy_link").css("background-color","red");      });       });        </script>      It is running before "div.domTip_tipBody" is being run (which is generated by a shortcode) so nothing happens. I have tried:               <script src="script.js" type="text/javascript" defer="defer"></script>      in my header.php before               </head>       but it doesn't help. Have seen "window.onload =" but not sure how to apply it. Any insight is appreciated. Thanks


Using browser detection and the body_class() function to modify css

I'm using the following function, as described here: http://www.nathanrice.net/blog/browser-detection-and-the-body_class-function/ Now when I use the following css styles, it does exactly what I want in Safari and Chrome:               .safari li#linkrss {margin-top: -15px;}     .chrome li#linkrss {margin-top: -15px;}      When I try `.gecko li#linkrss {margin-top: 0px;}` for Firefox, however, it doesn't seem to apply. For example, when I inspect the css element using FireBug, it shows the style for Safari. Any tips on how to fix this?


Wordpress Excerpt Paragraph Limiting

I was wondering if it was possible to get the first two paragraphs and the feature image in the excerpt. I currently have the first 100 words, but would like the the first two paragraphs. What I want to achieve is something like Smashing Magazine, where the first paragraph is one font, and the second is the base, while and image is in- between. (http://smashingmagazine.com) I know you can do this with the manual excerpt too, but that's way too tedious!


wp_set_object_terms() Fails to Set Terms

Okay guys, here's the scenario. I'm am trying to setup a function that will automatically duplicate a post (when published) over to another post type. So, a regular blog post is published, and when it is published, all of its information is copied over to a custom post type (for WP ECommerce), automatically creating a store entry for that blog post. I've written a function that takes care of picking up all of the information and inserting it into a new post with wp_insert_post(). It all works great, except for one thing. I'm using wp_set_object_terms() to set the store category ids of the new product based on the tags of the blog post. However, for some reason, wp_set_object_terms() never works. Now, here's the catch. I'm running all of this on a multi site install and am using threeWP_Broadcast to allow me to cross publish posts. The blog posts (which have to be copied to the store) are published from a sub site and broadcasted to the main site. The store is on the main site. So I've hooked my custom function into the broadcast plugin so that it gets fired when a post is broadcasted from a sub site to the main site. Everything with my function works great, except for the wp_set_object_terms() Here's function:               function copy_post_to_store_product() {          global $blog_id;     global $wpdb;          // only copy the post over if on main site, not subsites     if ($blog_id == 1) {              $args = array('numberposts' => 1);         $latest = get_posts($args);         foreach($latest as $post) : setup_postdata($post);                  // if NOT Tip and NOT source avail, create product             // if source, price is ALWAYS $4             // auto create for source files only -- regular post type                  $custom_meta = get_post_custom($post->ID);                  // what kind of post is this?             $post_type = $custom_meta['cgc_post_type'][0];             // does this post have a source file product associated with it?             $source_avail = $custom_meta['cgc_source_avail'][0];                  // source file price             $price = '4';                       $product_info = array(                 'post_title'    => $post->post_title,                 'post_type'     => 'wpsc-product',                 'post_content'  => $post->post_content,                 'post_author'   => $post->post_author,                 'post_status'   => 'draft',              );                       if($post_type == 'Regular' && $source_avail == true) {                 // only auto create product for Regular posts that have source files for sale                 $product_id = wp_insert_post($product_info);                 update_post_meta($product_id, '_wpsc_price', $price);                      if (has_tag('blender', $post->ID))                  {                      $product_cats = array(23,32);                 }                 elseif (has_tag('max', $post->ID)) {                     $product_cats = array(23,34);                 }                 elseif (has_tag('modo', $post->ID)) {                     $product_cats = array(23,19);                 }                      // set the product categories                 wp_set_object_terms($product_id, $product_cats, 'wpsc_product_category' );                  }                   endforeach;     }      } The function works by retrieving the latest post from the main site ($blog_id == 1) and copying all of its information into variables for wp_insert_post(). Now, the really interesting thing is that works perfectly if I attach the function to a publish_post hook, but, unfortunately, I can't do that because that hook doesn't fire when a post is broadcasted. Any ideas would be hugely appreciated.


How To create ajaxed wp-pagenavi?

I'm using WordPress as a Facebook platform and have a page that shows posts from 2 different categories. Each category has it's own pagination using wp- pagenavi. In order to stay in Facebook I need the pagination links to load using ajax. I've seen this article which gives a nice clue about it, but would love to know if anyone had already solved this and has any leads. My main issue here (and this is stupid), I get that I need to call an ajax function with jQuery and pass it the specific category and the desired page number. I have no idea how to get the page number. But once again, if you have an already made solution - it will be much appreciated Currently I tried using this tutorial, the tab code can be seen here. as you can see pagination affects both categories :-(


3 moderators to approve comment

Guys, I need to know how to do the following: When I receive a comment ... This comment must be approved by three moderators. To appear on the site. Anyone know how to do it or some plugin?


Listing Category 'child_of' by slug rather than ID

I want to list categories belonging to a parent. The problem is using category id's isn't useful and makes things harder to understand. Is there any easier way to list categories belonging to a parent, similar to the default way supplied in the WP codec?               <?php wp_list_categories('child_of=8'); ?> //what category is '8' ?!          <?php wp_list_categories('child_of=clients'); ?> //much nicer, but doesn't work      I would prefer to avoid using another query in the loop, but to make sense to other developers, I might have to.


Popular Post With Thumbnail?

Is there any plugin that allows you to use a custom field as the thumbnail to display the most popular post within the last day (24 hours)? I have found several plugins but none seem to have the capabilities that would allow me to add a custom field as the image or even a thumbnail at all.


$wpdb->query() multiple query support

Just bump into the issue that I can't execute multiple sql queries using the `$wpdb->query()`. Generated queries work fine directly in phpmyadmin so its something will the ezSQL class only. By design perhaps? I found this http://wordpress.org/support/topic/wpdb-gtquery-fails-when- multiple-update-statements-are-used which also says its by design. Can anyone confirm? ezSQL docs dont say anything about multiple queries support. If you have to do a bunch of queries mainly (INSERT/UPDATE/DELETE), any better way of doing them other than doing them one by one using `$wpdb->insert()` and like functions?


Wordpress native thickbox language

Is there any clean way (not overwriting wp-includes\js\thickbox\thickbox.js file) to translate english next/ prev/ image # of # and Close tooltip in Wordpress native Thickbox script?


Warning: preg_replace(): Compilation failed: unknown option bit(s) set at offset -1

I recently upgraded my dedicated server to Apache 2.4.6, MySQL 5.5.32, and PHP 5.4.21. Now on my website I get this error: > Warning: preg_replace(): Compilation failed: unknown option bit(s) set at > offset -1 in /home/champion/public_html/wp-includes/shortcodes.php on line > 295 Here is the code from shortcodes.php on line 295:               $text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);      Is the preg_replace function not compatible with the new PHP 5.4.21?


How do I exclude posts by custom field value?

I need to exclude posts that have a custom field 'city' value of 'Melbourne'. After much searching I think the solution might consist of 2 parts. In functions.php : A function to get the post IDs for all posts which have a custom field 'city' value of 'Melbourne'. Then in my loop : Exclude these posts using the post_not_in argument, using the returned ids from the first loop? Is this the right approach? What is the correct code?


Display categories inline

how can I show the categories inline in a widget?? I already tried using the wp function wp_list_categories ('style = none') and using the php function str_replace to replace the tags br but without success. Thanks


Get Tags get_terms() - by user->ID ?

Is it possible to get tags for a specific user ID, i mean i want to get the tags list on author page where i want list the tags the author used to make his/her posts only - not want to get the full wordpress tag cloud ? Is this possible ?


How to write .htaccess dynamically?

I am trying to set permalink structure on theme activation. The following function included in function.php of theme.               // Executes function on theme activation     function myactivationfunction() {              global $wp_rewrite;         $wp_rewrite->set_permalink_structure( '/%category%/%postname%/' );         // register taxonomies/post types here         flush_rewrite_rules();          }     add_action("after_switch_theme", "myactivationfunction", 10 ,  2);      This code works correctly but value not writing into .htaccess or .htaccess not creating. How can i write .htaccess file dynamically? Any help would be greatly appreciated. Thanks


Wordpress installed on a Sub-directory

I've already read this and followed the steps, however I can't get it work yet.   * My Wordpress URL: `http://mydomain.com/web` (this is where it's installed)   * My Site URL: `http://mydomain.com` I've copied `index.php` and `.htaccess` to /public_html which is the root directory. /.index.php               <?php     define('WP_USE_THEMES', true);     require( dirname( __FILE__ ) . 'web/wp-blog-header.php' );      /web/index.php               <?php     define('WP_USE_THEMES', true);     require( dirname( __FILE__ ) . 'wp-blog-header.php' );      /.htaccess (the same as /web/.htaccess)               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /web/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /web/index.php [L]     </IfModule>     # END WordPress      I can still access to my admin page on `http://mydomain.com/web/wp-admin`, but Wordpress content media isn't recognized yet because I once changed "wp- content" folder name to "media" (using iThemes Security plugin) and this to `wp-config.php` /web/wp-config.php               <?php     define( 'WP_CONTENT_URL', 'http://mydomain.com/web/media' );     define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/web/media' );      So, media (plugins, themes, language) isn't recognized. I've tried with `http://mydomain.com/wp-admin` and it doesn't redirects me to `http://mydomain.com/web/wp-admin` either.


Getting 'SELECT + FROM comments...' in comment notification email

I just got a notification from my installation of Wordpress that someone has posted a comment there is no text in the comment area apart from the following: Comment: SELECT * FROM comments ORDER BY RAND() LIMIT 0, 100 The comment is showing up in the WP dashboard with the same message. Previous comments today seem to be okay. This is a new installation of WP (3.5.2) but with imported data from a previous WP (3.4.2) installation. Also got these errors in the Error Log today but not sure it's connected: [11-Oct-2013 09:52:26 UTC] PHP Fatal error: Out of memory (allocated 2359296) (tried to allocate 122880 bytes) in /home/--/public_html/--/wp-includes/class- wp.php on line 230 [11-Oct-2013 09:52:26 UTC] PHP Fatal error: Out of memory (allocated 16515072) (tried to allocate 122880 bytes) in /home/--/public_html/--/wp-includes/media.php on line 1420 [11-Oct-2013 09:52:26 UTC] PHP Fatal error: Out of memory (allocated 24641536) (tried to allocate 30720 bytes) in /home/--/public_html/--/wp-includes/default- widgets.php on line 320 [11-Oct-2013 09:52:26 UTC] PHP Fatal error: Out of memory (allocated 11796480) (tried to allocate 30720 bytes) in /home/--/public_html/--/wp-includes/comment.php on line 1677 [11-Oct-2013 09:52:26 UTC] PHP Fatal error: Out of memory (allocated 13107200) (tried to allocate 30720 bytes) in /home/--/public_html/--/wp-includes/kses.php on line 923 [11-Oct-2013 09:52:26 UTC] PHP Fatal error: Out of memory (allocated 5242880) (tried to allocate 30720 bytes) in /home/--/public_html/--/wp- includes/formatting.php on line 2779 [11-Oct-2013 09:52:26 UTC] PHP Fatal error: Out of memory (allocated 19922944) (tried to allocate 30720 bytes) in /home/--/public_html/--/wp-content/plugins/required-foundation-tooltip- shortcode/required-foundation-tooltip-shortcode.php on line 136 Why would it do this? And do I need to fix something? Thanks for your help in advance. Cheers, Tracy S.


My Infinite Scrolling plugin is not working, despite filling in the parameters correctly

I'm using the plugin "Infinite Scroll" (v2.6.2), but it's not working with my theme despite me filling in the parameters correctly. These are the parameters I am using: Content Selector: `#main-post`   Navigation Selector: `#main-menu`   Next Selector: `div.navigation a:first`   Item Selector: `#main-post li.post` I created a jfiddle so you can see the HTML and CSS, and verify if the parameters are correct.


Call to undefined function add_menu_page() on theme activation

I am attempting to activate a theme that works perfectly on one WordPress install. I have matched the plugins installed up and copied the theme over but when I go to activate it I get...               Fatal error: Call to undefined function add_menu_page()       It points to the following line as being the cause of the error....               add_action('admin_menu', 'register_custom_menu');          function register_custom_menu() {     add_menu_page('Design', 'Design', 'delete_others_posts', '/nav-menus.php', '', get_stylesheet_directory_uri() . '/img/tv.png', '5.1' );     add_submenu_page( '/nav-menus.php', 'Widgets', 'Widgets', 'delete_others_posts', '/widgets.php', '' );     add_submenu_page( '/nav-menus.php', 'Nav Menu', 'Nav Menu', 'delete_others_posts', '/nav-menus.php', '' );     add_submenu_page( '/nav-menus.php', 'Event Options', 'Event Options', 'delete_others_posts', '/admin.php?page=mytheme-options', '' );     }      Can anyone see where I am going wrong?


How important is it to enqueue a theme's stylesheet?

I have trawled the net looking for an answer to this, but for some reason all I can find are actual examples, but without that particular explanation, which is clear say in the case of scripts. Can someone explain to me why it's important/advantageous to enqueue styles when developing a theme, rather than just using `<link rel=stylesheet>` in header.php. Also, what about the theme's default stylesheet, should that be enqueued too?


Fixing custom rewrite rule

I am following the WP Example. I know my rewrite rule is being added into wordpress, so I just need to fix the actual rule. So here is my current code:               add_filter('rewrite_rules_array','mcs_TextbookRewriteRules');     add_filter('query_vars','mcs_insertTextbookQueryVars');          // Adding a new rule     function mcs_TextbookRewriteRules($rules) {         $newrules = array();         $newrules['textbook/(cantonese|mandarin)/([C|M]K?[0-9]+)/([0-9]+)$'] = 'index.php?pagename=textbook/$matches[1]/?cls=$matches[2]&ch=$matches[3]';         //$newrules['textbook/(cantonese|mandarin)/([C|M]K?[0-9]+)/([0-9]+)$'] = 'textbook/$matches[1]/index.php?cls=$matches[2]&ch=$matches[3]';         return $newrules + $rules;     }          // Adding the id var so that WP recognizes it         function mcs_insertTextbookQueryVars($vars) {         array_push($vars, 'cls');         array_push($vars, 'ch');         return $vars;     }      I want to map `http://localhost/wordpress/textbook/cantonese/CK1/6` to `http://localhost/wordpress/textbook/cantonese/?cls=CK1&ch=6`


Different banner on home page

How can I have one larger banner on the home page, but a smaller banner on all other pages. My home page is actually a page (as opposed to a post). But I'm thinking the banner is too big (and the newness/cuteness of it is warn off to see it over and over on every page). http://NealWalters.com P.S. - Someone with enough points, please add "banner" as a tag!


gform_after_submission content appears immediately after <body>, not in post body

I have the following function that successfully uses form fields (IDs 13 and 18) from a Gravity Form (ID 18) as parameters within wp_query. This displays a list of posts with specific taxonomy terms that match those chosen in the form:               add_action("gform_after_submission_18", "set_post_content", 10, 2);     function set_post_content($entry, $form){              //getting post         $post = get_post($entry["post_id"]);         $concern = $entry[13];         $sensitivity = $entry[18];              $loop = new WP_Query( array(              'post_type' => 'recommended',                 'tax_query' => array(             'relation' => 'AND',             array(                 'taxonomy' => 'concern',                 'field' => 'slug',                 'terms' => $concern             ),             array(                 'taxonomy' => 'sensitivity',                 'field' => 'slug',                 'terms' => $sensitivity             )             ),                  'orderby' => 'title',             'posts_per_page' => '-1',              'order' => 'ASC'           )         ); ?>          //THIS BIT DISPLAYS THE CORRECT LOOP BUT IT APPEARS IMMEDIATELY AFTER  RATHER THAN IN THE POST CONTENT
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_title(); ?>
        <?php endwhile; ?>
        <?php                //THIS BIT DISPLAYS THE CHOSEN FORM FIELD INSIDE MY POST CONTENT - WRONG CONTENT, RTIGHT POSITION      $post->post_content =      "
" .      $concern .      "
 sensitivity: " .      $sensitivity .      "
"     ;           }      The problem is that this is being inserted immediately after the 'body' tag rather than into the post body. How do I move this to where it should be?! I could well be going about this all wrong and I'm stumped


wordpress get_post_meta give only first value

I made one custome post in that there is one _custom field_ call **_as_roomname**. I create total 5 custom post and I want to retrive all it's name but I get only first value.               function postlogo(){     global $post;     $counting = 1;     $count = 1;     $args = array( 'post_type' => 'casino', 'posts_per_page' => 5 );     $rPosts = new WP_Query($args);          while ($rPosts->have_posts()) : $rPosts->the_post();?>     <h1><?php echo get_post_meta(get_the_id(), '_as_roomname', true);?> Review </h1><?php     $count = $count + 1;         endwhile;     }       **Output**               Casino.com Review     Casino.com Review     Casino.com Review     Casino.com Review     Casino.com Review      I want this unique name from all post but it give me only first value. How will I get that I don't know.


Organizing by super-categories (or nested categories)?

Suppose I want to blog about three somewhat unrelated main topics: Money, Languages, and Information-Technology on the same blog. How should I organize things for the best user experience? How does would such a structure affect the default menu structure at the top So far I found this: Category-manager and researching further. Apparently Category-Manager is a plug-in, I'm installing it now.


Wordpress variables and memory

When checking get_defined_vars() on an empty template file my theme loads over 70000 lines of output. Before even including elements on a page all of this is loaded.   1. Is this correct?    2. Is there any way to reduce it or remove unnecessary variables?   3. Do all wp_rewrite rules have to be available for every page load?


List all pages and children in separate ul

I've been trying to do this all weekend, I'm going round in circles now. I want to list all pages and their children in separate ul's The page setup is like this                   HOME        ABOUT         CONTACT                     Who we are    Where we are                      What we do    How to find us                     How we do it        I want to output it like this

Home

About

Who we are

What we do

How we do it

Contact

Where we are

How to find us

      This will give me the top pages in separate ul's                   <?php           $args = array(             'sort_column' => 'menu_order',             'parent' => 0,           );           $pages = get_pages($args);           foreach($pages as $page){             ?>

                 <?php                              echo $page->post_title;                         ?>

             <?php           }              ?>      I'm now trying to add the child pages to the ul I'm thinking something like this but this gives me all the pages in each ul                   <?php           $args = array(             'sort_column' => 'menu_order',             'parent' => 0,           );           $pages = get_pages($args);           foreach($pages as $page){             ?>

                 <?php                              echo $page->post_title;                             wp_list_pages('title_li=&depth=0&child_of'.$page->ID.'');                         ?>

             <?php           }              ?>              Is there a way to say all children of this page. Any help would be greatly appreciated.


Empty paragraphs around figure and figcaption tags when using markdown

I'm using WP 3.8 and Markdown on Save Improved plugin and have following code for outputing HTML5 tags when inserting images via Media Uploader:               function html5_insert_image($html, $id, $caption, $title, $align, $url, $size, $alt) {       $src  = wp_get_attachment_image_src( $id, $size, false );       $html5 = "
";       $html5 .= "";       if ($caption) {         $html5 .= "
$caption
";       }       $html5 .= "
";       return $html5;     }     add_filter( 'image_send_to_editor', 'html5_insert_image', 10, 9 );      And in editor output is fine, but on publish my code looks like this:

caption_txt

      If I put `div` wrapper around `figure` then there are no empty paragraphs but I'm wondering why figure and figcaption aren't recognized as block elements? Also, this doesn't happen with wp-markdown plugin so it seems it's not markdown problem since both plugins use same parser. When combining HTML and markdown in other ways, output is fine so I think that's not the issue.


How do I safely change the name of a custom post type?

I made a custom post type called 'portfolio' but I want to change it to 'projects'. What would be the exact steps I need to take in order to safely change the name and prevent the custom post type posts from disappearing in the dashboard? Note: There are already posts in `portfolio` so I can't just switch out `portfolio` with `projects`.               /* Register Portfolio Post Type */     add_action('init', 'create_portfolio');          function create_portfolio() {              $labels = array(             'name' => __('Portfolio', 'post type general name'),             'singular_name' => __('Project', 'post type singular name'),             'add_new' => __('Add New', 'portfolio item'),             'add_new_item' => __('Add New Project'),             'edit_item' => __('Edit Project'),             'new_item' => __('New Project'),             'view_item' => __('View Project'),             'search_items' => __('Search Projects'),             'not_found' =>  __('Nothing found'),             'not_found_in_trash' => __('Nothing found in Trash'),             'parent_item_colon' => ''         );              $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             'rewrite' => true,             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => null,             'supports' => array('title','editor','thumbnail')           );               register_post_type( 'portfolio' , $args );     }          /* Register Skills Taxonomy */     register_taxonomy("Skills", array("portfolio"), array("hierarchical" => true, "label" => "Skills", "singular_label" => "Skill", "rewrite" => true));          /* Add Fields */     add_action("admin_init", "add_portfolio_fields");          function add_portfolio_fields(){         add_meta_box("website_url", "Website URL", "website_url", "portfolio", "side", "low");         add_meta_box("view_more", "View More", "view_more", "portfolio", "side", "low");         add_meta_box("screenshot_name", "Screenshot Name", "screenshot_name", "portfolio", "side", "low");         add_meta_box("thumbnail_name", "Thumbnail Name", "thumbnail_name", "portfolio", "side", "low");         add_meta_box("thumbnail_alt", "Thumbnail Alt", "thumbnail_alt", "portfolio", "side", "low");     }          function website_url(){         global $post;         $custom = get_post_custom($post->ID);         $website_url = $custom["website_url"][0];         ?>         Website URL:         <input size="50" name="website_url" value="<?php echo $website_url; ?>" />         <?php     }          function view_more() {         global $post;         $custom = get_post_custom($post->ID);         $view_more = $custom["view_more"][0];         ?>         View More:         <input size="50" name="view_more" value="<?php echo $view_more; ?>" />         <?php     }          function screenshot_name() {         global $post;         $custom = get_post_custom($post->ID);         $screenshot_name = $custom["screenshot_name"][0];         ?>         Screenshot Name:         <input name="screenshot_name" value="<?php echo $screenshot_name; ?>" />         <?php     }          function thumbnail_name() {         global $post;         $custom = get_post_custom($post->ID);         $thumbnail_name = $custom["thumbnail_name"][0];         ?>         Thumbnail Name:         <input name="thumbnail_name" value="<?php echo $thumbnail_name; ?>" />         <?php     }          function thumbnail_alt() {         global $post;         $custom = get_post_custom($post->ID);         $thumbnail_alt = $custom["thumbnail_alt"][0];         ?>         Thumbnail Alt:         <input name="thumbnail_alt" value="<?php echo $thumbnail_alt; ?>" />         <?php     }          add_action('save_post', 'save_portfolio_details');          function save_portfolio_details(){         global $post;              update_post_meta($post->ID, "website_url", $_POST["website_url"]);         update_post_meta($post->ID, "view_more", $_POST["view_more"]);         update_post_meta($post->ID, "screenshot_name", $_POST["screenshot_name"]);         update_post_meta($post->ID, "thumbnail_name", $_POST["thumbnail_name"]);         update_post_meta($post->ID, "thumbnail_alt", $_POST["thumbnail_alt"]);     }          /* Custom Columns */     add_action("manage_posts_custom_column",  "portfolio_custom_columns");     add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns");          function portfolio_edit_columns($columns){         $columns = array(             "cb" => "<input type=\"checkbox\" />",             "title" => "Project Title",             "description" => "Description",         );              return $columns;     }          function portfolio_custom_columns($column){         global $post;              switch ($column) {             case "description":             the_excerpt();             break;         }     }


Should I put my plugin javascript inline?

I have a small bit of (localised) Javascript bundled with a plugin. Currently it's in a non-minified .js file, called at via enqueue_scripts. Given that this script will likely run on every page, should I minify it or output it so it's inline in the page?


Getting error “The package could not be installed. PCLZIP_ERR_BAD_FORMAT ”

i am newbie in wordpress. i have created my own plugin and it's working fine for me... now i have created rar/zip file my plugin folder... i am uploading my plugin .rar file in my another wordpress project... it's giving error               The package could not be installed. PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature      through FTP it's working fine in my all wordpress projects... but i want to make it uploadable. my plugin file structure is :-- /mypluging_dir                **--images---**       **--css--**      **--pluginfile.php--**      **--abc.php--**      **--xyz.php--**      i am using xampp 3.2.1 and my wordpress version is 3.7.1 Any help will be appreciate.. Thanks in advance


Structuring a product catalogue in Wordpress

I am trying to create a product based content managed website in Wordpress (by clients request). I have created a custom post type where all the products reside, aptly named 'Products'. The products must be shown in different categories as illustrated by the attached image. Being new to Wordpress I am struggling with how to put this together and would like some advice. Is it best to create a bunch of categories with corresponding pages. When the link is clicked I then somehow filter all the posts in that category? Just a little advice on how the best way to achieve this if possible. Many thanks in advance. ![Wordpress menu showing catalogue structure](http://i.stack.imgur.com/9Ossz.jpg)


How can I implement an Add to Collection function on my Image Gallery to be downloaded later?

I am building a WordPress Image Gallery like a Stock Photo Gallery for internal office use. I am using the Media Gallery to upload files and then using the image gallery to display the photos. It's working all well with four download options which you can choose. The problem I'm having is that I want to collect those images with a click of a button so that I can keep them and then later on, download them as a zip file. It'll make life easer for users to do this instead of downloading individuals photos. This is kinda like istock or shutterstock **Add to Lightbox feature**. I've seen a plugin which is the closes to what I want. It's called, Add to favorites. But it just gives you a list of titles in a widget. I don't want users to register into the site therefore just using cookies is enough so that whenever they close the browser, the collections reset. I dug into HTML5 local storage and jquery cookie but this seems kinda hardcore for me. I also thought of a shopping cart plugin but I don't need the paypal or whatever payments because I just want people to collect and download with an ease. Is there any way I can do this? Is there a kind of plugin which I can use?


Save HTML formatted data to post meta using add_post_meta()

Array     (         [post] => Array             (                 [jw_objective] => Exposure to end to end development of various applications; right from requirement analysis to system study, designing, coding, testing, de-bugging, documentation and implementation. Adept in handling the design and coding functions                 [postid] => 363                 [jw_fullname] => Pradeep                 [jw_email] => pradeepsk88@gmail.com                 [jw_phone] => 9952149811                 [jw_website] => www.por.com                 [jw_address1] => 83, VGP Nagar East                 [jw_address2] => T Nagar                 [jw_address3] => Chennai, India 605602                 [jw_title] => Senior Web Developer                 [jw_cname] => TPF Software Solutions                 [jw_startdate] => Dec 2010                 [jw_enddate] => Present                 [jw_desc] => This is my responsibilites in this job                 [jw_qualifications] => Certiﬁed Public Accountant (CPA)                             Certiﬁed Management Accountant (CMA)                             Certiﬁed Financial Manager (CFM)                             Certiﬁed Fraud Examiner (CFE)                             Certiﬁed Financial Planner (CFP)                             Certiﬁed Internal Auditor (CIA)                             Enrolled Agent (EA)                             Certiﬁed Government Financial Manager (CGFM)                                                                                [jw_educname] => B.E                 [jw_eduiname] => Arunai College of Engineering                 [jw_edustartdate] => May 2005                 [jw_eduenddate] => May 2009                 [jw_edudesc] => This is a riduculous thing happened in my life,                  [jw_interest] => These are my interests                 [jw_referance] => This Is my referance             )              )      This is the array I iterate through, and add it to the `wp_postmeta` through the following foreach loop               foreach ($_POST AS $key => $value) {         add_post_meta($pid, $key, $value, true);     }       The information is posted from a custom form. The problem I have is the HTML tags like `<b>` and `<i>` are automatically stripped off when entering the database. The HTML is generated from a jquery wysiwyg editor But the information is saved successfully. Is there any way to save postmeta with the HTML tags?


How To Set Custom Post Type Title Without Supports

So, I asked this question differently in another thread but it was more of an advice type question so it really didn't render any useful responses. I believe I can word it better and should help some of you decipher what I am trying to accomplish and possibly help someone else once we collaborate on a solution. I have a custom post type that is using very limited Supports (described here) values because I only need the meta-box values for my custom post type. It doesn't make sense for my type to include a title and content. Code below:               register_post_type( 'athlete',             array(                 'labels' => array(                     'name' => 'Athletes',                     'singular_name' => 'Athlete',                     'add_new' => 'Add New',                     'add_new_item' => 'Add New Athlete',                     'edit' => 'Edit',                     'edit_item' => 'Edit Athlete',                     'new_item' => 'New Athlete',                     'view' => 'View',                     'view_item' => 'View Athlete',                     'search_items' => 'Search Athletes',                     'not_found' => 'No Athletes found',                     'not_found_in_trash' => 'No Athletes found in Trash',                     'parent' => 'Parent Athlete'                 ),                      'public' => true,                 'menu_position' => 15,                 'supports' => array( 'thumbnail' ),                 'taxonomies' => array( '' ),                 'has_archive' => true             )         );      As you can see, I only need the thumbnail supports option because the rest of my post type will be meta-boxes (not including in this question). The problem is, when I save an Athlete, I have two problems, I do not know how to display my meta-box values in the Athlete list (as columns in the grid) and I do not know how to set the Title value as it always sets it to "Auto-Generated" which is not preferred. If the Title will be a field that is searchable, I would prefer to set the value to [First Name]+[Last Name]. Can anyone help with these two issues and explain if I am going to run into any problems by using a custom post type as opposed to using custom database tables and a custom UI to manage my object?


WP Super Cache unable to locate cache file for only the homepage

I have WP Super Cache working perfectly on all pages of my blog except for the homepage. I'm using the PHP caching method (mod-rewrite is not compatible with my specific configuration with suPHP). I've monitored the debug log and cache folder and can see _that the cache file is created successfully_ , but when its reloaded wp-super-cache cannot find it and recreates it. A big clue seem to be that if I load the index.php file directly it works i.e. www.site.com/blog/ <--- **Cannot find cache file** www.site.com/blog/index.php <--- **Able to find cache file (caching works!)** Im using the following permalink structure; **www.site.com/blog/%postname%** The .htaccess file is standard for the permalink structure               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /blog/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /blog/index.php [L]     </IfModule>      I'm using the following DirectoryIndex directive in my virtual machine config.               DirectoryIndex index.php      I've tried everything I can think of to resolve this including using the inotify package to monitor real-time file system activity to see what file name its looking for but it didn't help. Any assistance would be greatly appreciated.


How to Reload the Dashboard After Clicking Update in Quick-Edit?

How can I refresh the `wp-admin/edit.php` page after a user clicks **Update** in the _Quick-edit_ form?


Trouble getting wordpress working after moving servers

So I have 17 wordpress sites that I am moving from Server A to Server B. All the sites have been up and running on Server A for over 2 years, no recent changes (ie, no new plugins, no new themes) to any of them. I have moved all the files and all the databases to Server B. All good. Created MySQL users, gave permissions, all good. Problem: Some sites work, some sites don't. The sites that don't work are just a blank white page. Sometimes I can login to the admin, sometimes I can't. Problem: Some sites have plugin errors (didn't exist before move) The sites that don't work often have a bunch of PHP errors related to various plugins that prevents the site from loading. The sites that work, work as if they were never moved. Any ideas of whats going on?


Privilege to recover trashed posts

I can't seem to find which built in privilege is required for recovering a trashed post. Would it be `delete_posts`, which is as its name suggests, can move items into the trash and remove them completely, or `edit_posts` or `publish_posts`..? I aim to have something like, when an admin trashes a post of a lesser role, that lesser role should not be able to recover it. I don't want to add a new capability.


Theme-Option-Panel: Select List of Pages, Childpages and Posts

I just can't solve this problem: in the **wp dashboard** I want the user to have the **option** of selecting between all **pages, sub-pages and posts** (also custom-post-types) for displaying them in special content-boxes at the home. This is what I got, unfortunately sub-pages(childs) and posts are not working… I am thankful for any kind of advice!                   function getTopArticlePosts($options, $currentPost)     {       $ret = '<option value="">Select Article</option>';       foreach($options as $option) {         $selected = ($option[0] == $currentPost) ? ' selected' : '';         $ret .= '<option value="'.$option[0].'"'.$selected.'>'.$option[1].'</option>';       }            return $ret;     }     function my_settings()     {           $pages = array_merge(         get_pages(),         get_posts(array('post_type' => 'post')),         get_posts(array('post_type' => 'books')),         get_posts(array('post_type' => 'ebooks'))       );           $childpages = array_merge(         get_pages()       );            $options = array();       $otheroptions = array();       foreach($pages as $page) {         if(!has_post_thumbnail($page->ID)) {           $otheroptions[] = array($page->ID, $page->post_title);         } else {           $options[] = array($page->ID, $page->post_title);         }       }          ?>


Create a new different blog layout

I'm not native English, so I use a translator. It may be that the phrases are not correct all I'm trying to create a new template to display blog posts differently. For example, I want the image of the post to larger. So I copied and pasted the contents of the index.php page and changed the image size. I then created the page, leaving the fields blank and selecting my template. I then go to Option Reading, check "static page" and selects the new page. Unfortunately, it does not work because the page displayed is : One blank blog article, instead of all items with the bigger picture. What might be the problem? Here is my page index.php                   <?php get_header();         global $redux_demo; ?>              <div class="body container" <?php echo 'style="font-family:'.$redux_demo['body_font_family']['font-family'].';">';?>

                                                          <?php                              $args = array(                                         'post_type'      => 'slide' ,                                         'orderby'        => 'menu_order' ,                                      );                                  $slides = new WP_Query( $args );                                  if ( $slides->have_posts() ) : $count=1; ?>

                                         <?php while ( $slides ->have_posts() ) : $slides->the_post(); ?>                                         <div class="item <?php if($count=="1"){echo 'active';}?> ">                                             <?php add_image_size( 'category-thumbs', 670, 400 ); ?>                                             <?php the_post_thumbnail( 'category-thumbs' ); ?>

<?php the_title(); ?>

<?php the_content(); ?>

                                         <?php $count++; endwhile; ?>
                                                                      ‹                                   ›

                                 <?php endif; ?>                                   <?php if(have_posts()) : ?>                             <?php while(have_posts()) : the_post(); ?>
                                 <?php if ($redux_demo['enable_post_category'] == 1) { ?>
<?php foreach((get_the_category()) as $category) {echo $category->cat_name . ' ';}?>
<?php } ?>                                 <div class="post" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>

                                         <?php add_image_size( 'medium-thumb', 350, 200);?>                                         <?php the_post_thumbnail( 'medium-thumb' ); ?>                                          <?php setup_postdata ($post);                                        if ($post->post_content = $post->post_excerpt)                                            the_content();                                        else                                         {                                            the_excerpt();                                            ?>                                     <?php  } ?>

                                             <?php the_time('j F Y') ?> <?php the_author() ?><?php $posttags = get_the_tags(); if($posttags){?> <?php } the_tags('',', ','') ?><?php comments_popup_link('0', '1', '%','pull-right'); ?>

                                       <?php endwhile; ?>
                                     <?php theme_pagination(); ?>
                             <?php else : ?>
Désolé, mais vous cherchez quelque chose qui ne se trouve pas ici .
                             <?php include (TEMPLATEPATH . "/searchform.php"); ?>                         <?php endif; ?>

                         <?php get_sidebar(); ?>

                 <?php get_footer(); ?>                          and my blog-large.php page.                   <?php     /*     Template Name: [Blog] Large Thumb     */      get_header();             global $redux_demo; ?>                  <div class="body container" <?php echo 'style="font-family:'.$redux_demo['body_font_family']['font-family'].';">';?>

                                                                  <?php                                  $args = array(                                             'post_type'      => 'slide' ,                                             'orderby'        => 'menu_order' ,                                          );                                      $slides = new WP_Query( $args );                                      if ( $slides->have_posts() ) : $count=1; ?>

                                             <?php while ( $slides ->have_posts() ) : $slides->the_post(); ?>                                             <div class="item <?php if($count=="1"){echo 'active';}?> ">                                                 <?php add_image_size( 'category-thumbs', 670, 400 ); ?>                                                 <?php the_post_thumbnail( 'category-thumbs' ); ?>

<?php the_title(); ?>

<?php the_content(); ?>

                                             <?php $count++; endwhile; ?>
                                                                              ‹                                       ›

                                     <?php endif; ?>                                       <?php if(have_posts()) : ?>                                 <?php while(have_posts()) : the_post(); ?>
                                     <?php if ($redux_demo['enable_post_category'] == 1) { ?>
<?php foreach((get_the_category()) as $category) {echo $category->cat_name . ' ';}?>
<?php } ?>                                     <div class="post" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>

                                             <?php add_image_size( 'large', 550, 200);?>                                             <?php the_post_thumbnail('large', array('class' => 'post-image')); ?>                                              <?php setup_postdata ($post);                                            if ($post->post_content = $post->post_excerpt)                                                the_content();                                            else                                             {                                                the_excerpt();                                                ?>                                         <?php  } ?>

                                                 <?php the_time('j F Y') ?> <?php the_author() ?><?php $posttags = get_the_tags(); if($posttags){?> <?php } the_tags('',', ','') ?><?php comments_popup_link('0', '1', '%','pull-right'); ?>

                                           <?php endwhile; ?>
                                         <?php theme_pagination(); ?>
                                 <?php else : ?>
Désolé, mais vous cherchez quelque chose qui ne se trouve pas ici .
                                 <?php include (TEMPLATEPATH . "/searchform.php"); ?>                             <?php endif; ?>

                             <?php get_sidebar(); ?>

                     <?php get_footer(); ?>


Display user's total comment count outside The Loop

How do I display a user's total comment count outside The Loop? I use this code to display comment count **inside the loop** :                   <?php         global $wpdb;         $user_id = $post->post_author;         $where = 'WHERE comment_approved = 1 AND user_id = ' . $user_id ;         $comment_count = $wpdb->get_var(             "SELECT COUNT( * ) AS total         FROM {$wpdb->comments}         {$where}     ");         echo 'Comments: <strong>' . $comment_count . '</strong>';         ?>      That works perfectly inside the loop. In an attempt to make that code work outside the loop, I changed `$user_id = $post->post_author;` to `$user_id = get_the_author_meta( 'ID' );` but it did not work. The closest that I have been is with this code:                                           <?php                                 global $wpdb;                                 $where = 'WHERE comment_approved = 1 AND user_id <> 0';                                 $comment_counts = (array) $wpdb->get_results("                                     SELECT user_id, COUNT( * ) AS total                                     FROM {$wpdb->comments}                                     {$where}                                     GROUP BY user_id                                     ", object);                                 foreach ( $comment_counts as $count ) {                                     $user = get_userdata($count->user_id);                                     echo 'Comments: ' . $count->total . '                                     ';                                 }                                 ?>      However, this echos comment count for all users, like this: "Comments: 28 Comments: 11 Comments: 55" etc What code can I use to **show the user's comment count outside the loop**?


Set Custom Post feature image as og:image

I am trying to set the Featured image as the `og:image` I have tried various ways and plugins (Yoast) but finding it hard to get my head around this. The issue is that it isn't picking up the feature image at all instead it is picking up the images in the content. This is my current pages code for the single blog post. This is the part which i need to be able to get when sharing the blog post to Facebook rather then the content images.
             <?php if( get_field('featured_image') ): ?>             <?php $featuredImage = get_field('featured_image'); ?>             <img rel="image_src" src="<?php echo $featuredImage['url']; ?>" alt="">             <?php else: ?>                          <?php endif; ?>
      It does do this weird thing when a blog post hasn't got any images in the content it then picks up the feature images and images in the sidebar. I also ran the Facebook debugger but again it is only picking up the contents imagery. I did find this snippet that targets the featured image but i have a feeling because mine is a custom post it may not be picking it up.               <meta property="og:image" content="<?php $post_thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'large'); echo $post_thumbnail[0]; ?>" />      Any suggestions would be great. If you need anything else, let me know.


Archive list with only years and months

I'm trying to show the archive list like that

Year

Month

Month

Month

Year

Month

      and so on, with the relative link only on the month. I tried different solutions as the CG Archive plugin ( http://wordpress.pastebin.ca/209160 ) and that's the only kind of plugin I can use since I need to place the php output wherever I want and the other plugins/widgets I found doesn't let me do that. The problem is that it doesn't show anything at all! Do you know any alternative solutions to accomplis that? Really thanks in advance and sorry for my poor english.


Grab values from the query string to fill in hidden fields in ninja forms

I've added a custom page template where I pull out a list of available jobs from the database. The page displaying the jobs is called `jobs`. I'm using the `Ninja forms` plugin to add a form on a page called `apply.php`, which has fields for a job application. Now for each job title offered on the jobs page, I want it to be a link that the user can click on to apply, and be redirected to `apply.php`, where I can grab the job id and save in a hidden field on `apply.php`. This is so that when I save the applicant's submission, I can get it saved together with the job they applied to. I've added the link alright - as follows:               ?page_id=18&jid=2      where 18 is the id of the apply page, the page that I've got the ninja form on. But how can I grab the jid from the query string and use it in the ninja form fields?


Navigation menus not showing because of custom post type filter

I use this filter to show content from all custom post types in tags archive page               function tagFilter($query) {         $post_type = $_GET['type'];         if (is_tag()){             if (!$post_type) {                 $post_type = 'any';             }             $query->set('post_type', $post_type);         }         return $query;     };     add_filter('pre_get_posts','tagFilter');      but somehow it stops the `wp_nav_menu` function and navigation menus do not appear in tags archive pages. I can't figure out where is the conflict between the two. Any ideas?


What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?

I have the following doubt related to the **posts** table of the WordPress database. I see that when I create a new post in this table are automatically created 2 new rows.               32  1   2014-08-16 15:07:22 2014-08-16 15:07:22 TEST REVISION   TEST REVISION       inherit open    open        31-revision-v1          2014-08-16 15:07:22 2014-08-16 15:07:22     31  http://localhost/wordpressAsper/2014/08/16/31-revi...   0   revision        0          31  1   2014-08-16 15:07:22 2014-08-16 15:07:22 TEST REVISION   TEST REVISION       publish open    open        test-revision           2014-08-16 15:07:22 2014-08-16 15:07:22     0   http://localhost/wordpressAsper/?p=31   0   post        0      I know that the one having 32 as ID is the post revision while the one having 31 as ID is the published post. For some reason I need to delete all the posts revision from my databse. If I delete all the revision of all posts can I have some kind of problem with the post of my blog? Or it still work using only the published post?


comment_karma. Archived info on using it is outof date

Using the tentyfourteen theme, how would I go about using comment_karma to change the displayed order of comments? There is a solution posted on several sites (inc here, Sort comments by karma) but I cant figure it out at all. Based on experience I would have to conclude that the information is out of date (2011) or am I totally wrong? I have spent an entire day trying to figure this one thing out.


Show post titles only on the homepage

Is there any way to show a list of all posts without any preview of the content on the homepage?


append links with unique number string

I am in the process of developing a WordPress theme for a news site that delivers the news in bitesized chunks with the story regally updated with new content. What I am having trouble with is this: Next to each update I would like a number, so the first post will be 1, then the next update will be 2 and so on. I would also like these numbers to be links with a unique number string at the end of the normal URL so for instance if the URL was `example.com/NSA-hacks- merkels-cell-phone` the second update would be `example.com/NSA-hacks-merkels- cell-phone/123456` so that that update can be easily shared. Is any of this possible? any help that the community can give me on this would be very much appreciated.


Creating wordpress user registration form

I am having a form page called Test Form with this form :               <div id="container">     <form action="wp-content/themes/max-magazine/TestForm.php" method="post" name="myForm">     User <input type="text"  name="uname" />     Email  <input id="email" type="text" name="uemail" />     Password  <input type="password"  name="upass" />     <input type="submit" value="Submit" /></form>     </div>      And in backend am having a php file named TestForm.php               <?php      function create_account(){     $user = 'AccountID';     $pass = 'AccountPassword';     $email = 'email@domain.com';     if ( !username_exists( $user )  && !email_exists( $email ) ) {         $user_id = wp_create_user( $user, $pass, $email );         $user = new WP_User( $user_id );         $user->set_role( 'contributor' );     }      }     add_action('init','create_account');     ?>      Now if this function is defined in function.php then it works fine and create the user but same function in TestForm.php does not work. Please help Also I will be fetching data from form like this :               <?php     $user = $_POST['uname'];     $pass = $_POST['upass'];     $email = $_POST['uemail'];     ?>


Short code for Venues

I am using the Event Organiser plug in and I am trying to setup the "venues." In the post my client and I would like a little more information on the venue to appear, I found the short code for the Google Map, but there is no other information. When I click on the location nothing happens.   Is there a short code to post more information on the Venue?


How to access the post meta of a post that has just been published?

I am using the hook `publish_post` to run my code where I need the post meta of the just published post. But the post meta value I am looking for is somehow not available at this point of execution. On checking the `wp_postmeta` table, I found that my meta key value hasn't been created yet. Also, I want this to work for a post published for the first time. Is there any other hook that can give me access to it?               function push_notification($post_id)      {          $ref_ids = get_post_meta($post_id,'ref_id');               if($ref_ids)          {              //my code goes here          }      }           add_action('publish_post','push_notification');


Insert retrieved image into another table?

I am retrieving one image from a table name "user_templates" after retrieving ,I have to insert that retrieved image into another table name "ca_woocommerce_order_items" but I am not able to insert image in ca_woocommerce_order_items" table.I am using woo commerce plugin and following function I written in function.php.                function insertimage() {                  echo $item_id;           echo "hi";           global $wpdb;           $result = $wpdb->get_results ( "SELECT * FROM user_templates  where id= ".$_SESSION['user_te']);           foreach ( $result as $print )             $img_post=$print->BgImageName;           echo $img_post;               $ca_woocommerce_order_items  =  $wpdb->prefix . 'ca';          $wpdb->insert($ca_woocommerce_order_items , array('BgImageName' => 'sdfsd'));           echo "success";           exit;         }


Get all woocommerce comments/reviews

What I need to achieve is to get all comments from all products in Woocommerce. This is not getting me ANY comments at all...               <?php $comments = get_comments( array( 'post_type' => 'product') ); ?>      However               <?php $comments = get_comments( array( 'post_id' => '4169') );      Gets me comments for particular product ID. How to query ALL comments? Thanks in advance.


Check if user is logged in using JQuery

I want to execute custom jquery code which shows login dialog to user if he clicks a button and he is not logged in. How could I do that?


How to set up php,javascript and css to allow for our finished product to be displayed within a page?

hey wordpress experts, We have coded a table using php, javascript and css which pulls up information from a text file and displays it in the browser. We have everything working as desired when we set up our files on a local server. However, we are trying to integrate our finished product into a page on a wordpress website. We are using the "CSS & javascript toolbox" plugin to make a php&javascript code block and a css code block and applying it to the page in question. However, I understand that pages are stored in sql tables so this makes it hard for me to figure out how I can access the code on the server and where to put the text file on the server so that the table is displayed on the page in question and works as desired. ![Picture of our table](http://i.stack.imgur.com/iv4qZ.jpg)


htaccess has broken my site

I made a small addition to the htaccess file and it broke my site (I'm certain there were no errors, however). So I deleted what I added and 24 hours later the site is still broken. I've disabled the htaccess file altogether. replaced the wp-admin and wp- includes moved all the themes off the server only leaving the default. turned on debugging and no errors are produced I only get the white screen of death. I'm not sure what else to do at this point.


remove missing image attachments

Best way to programatically remove attachments that are missing images? I ask because after using a caching plugin, I have images that have been input in the database as attachments that don't actually exist. These usually take the form of xxxx.1jpg, where xxxx.jpg is a valid. Sometimes this number is a 2 or a 21. ![bonus image attachment](http://i.stack.imgur.com/lxqmI.png) I guess it would be better to just remove "duplicate" bad images. I think it might be good to have other types of missing images remain, so they could be corrected. Ideas?


Different Subdomain changes page content

I know it seems to be a strange ask here but hear me out. I have a client who has several subdomains for different countries, such as us.example.com and uk.example.com. I want to change one or two pages of a wordpress website when there is a certain subdomain entered. Before anyone asks I have mentioned having the different options selectable in the main site but they would rather have it this way. I could always just have another wordpress install, or put it under a multi- site but if one can do it this way that would be great. Thanks in advance!


Modify featured image path to amazon s3

I have uploaded my images to amazon s3. There are some Featured images. Inorder to modify their path, I run the update scripts to change the path of wp_posts.guid. But the image still points to the old path. How can I change the featured image url so as to point to amazon s3 path? thanks


Default content for a new site in multi site

I'm building a network with multi-site.   When create a new site, I want some data for site: category, tag, post, active plugin... also create as default data. Who can show me how to do? Write a plugin and add data as I want, direct modification function create?


How to leverage hefty memory actions from programmatically creating nav menus

I'm working on a plugin right now and hitting a wall. Long story short, part of the plugin process is to construct a dynamic nav menu. This nav menu can get rather large, and I'm finding that it seems to be taking up too much memory and causing a white screen. (some of the loads that succeeded took 84MB of memory and over 4K queries). The code for creating the nav menu items looks something like this (note, this is NOT the exact code, it's formatted just to give you the general idea of what's going on):               // Cycle through each item and create the nav menu item accordingly     /// Probably around 80 or so nav menu items will be output from this array     foreach ( $menus as ... ) {              // ...              $ID = wp_update_nav_menu_item( $this->menu_ID, 0, $args );              if ( ! is_wp_error( $ID ) ) {             // About 5 post meta items             foreach ( $custom_meta as $meta_name => $meta_value ) {                 update_post_meta( $ID, $meta_name, $meta_value );             }         }              // If there are submenus, cycle through them         if ( $submenus ) {                  foreach ( $submenus as ... ) {                      // ...                      // $args contains $ID as the parent item ID                 $submenu_ID = wp_update_nav_menu_item( $this->menu_ID, 0, $args );                      if ( ! is_wp_error( $submenu_ID ) ) {                     // About 5 post meta items                     foreach ( $custom_meta as $meta_name => $meta_value ) {                         update_post_meta( $submenu_ID, $meta_name, $meta_value );                     }                 }             }         }     }      So as you can see, there is a LOT of wp_update_nav_menu_item()'s and a lot of update_post_meta()'s. That's a lot of queries and a lot of processing. My question is... what's the best method for trying to leverage a task like this? How can I split it up without the user having to refresh a bunch of times or something? AJAX? CRON? Something else? I'm so lost.


how rewrite is working in wordpress

I have installed a plugin called marketpress. And it have a url as `http://www.mydomain.com/store/shopping-cart/shipping/` Now i just want to know which php page it refers to. In **my db** and found there is a row in **wp_options** table with the key **rewrite_rules** and it have               [store/shopping-cart/?$] => index.php?pagename=cart     [store/shopping-cart/([^/]+)/?$] => index.php?pagename=cart&checkoutstep=$matches[1]      so as per my url the link will be as like `index.php?pagename=cart&checkoutstep=shipping` If the url is like this **which php page the wordpress will look for?** Basically i am a cakephp developer. So all i think is for a controller and action something like that. Can someone explain me how can i find the how the wordpress will refer tot he dependent php page base on the url? **Which page i should refer if ?pagename=cart is passed is passed** My english may poor. But i hope you guys understand what i am trying to ask :\


Display Posts by Views (Popular Posts Widget)

I am trying to display the most popular posts based off of this, but I don't think it is working properly. When you view a post it seems to add 1 view to each of them, not just the unique ID.               <?php          class SEM_Podcast_Widget extends WP_Widget     {            protected $defaults;              public function __construct()         {             // Set the default widget settings             $this->defaults = array(                 'title'         => '',                 'showdate'      => '1',                 'posts_cat'     => '',                 'postid'        => '',                 'showsummary'   => 1,                 'showfeatured'  => 1,                 'featuretype'   => 'latest'             );                  // Widget settings             $widget_ops = array(             'classname' => 'featuredpodcast',   // CSS classname for widget div             'description' => 'Displays the latest / featured podcast with excerpt and player.'  // Description shown in the WP Admin on the widgets page             );                  // Widget control settings             $control_ops = array(             'id_base' => 'featured-podcast',             'width' => 250,             'height' => 250             );                  // Create the widget             $this->WP_Widget('featured-podcast', 'SEM Geeks Featured Podcast Widget', $widget_ops, $control_ops);         }                   // prints the form on the widgets page         public function form ($instance)         {                  // Merge with defaults             $instance = wp_parse_args((array) $instance, $this->defaults);         ?>
             <label for="<?php echo $this->get_field_id('title'); ?>">Title:             <input type="text" name="<?php echo $this->get_field_name('title') ?>" id="<?php echo $this->get_field_id('title') ?> " value="<?php echo $instance['title'] ?>" size="25">

             <label for="<?php echo $this->get_field_id('showdate'); ?>">Date:             <input type="checkbox" name="<?php echo $this->get_field_name('showdate') ?>" id="<?php echo $this->get_field_id('showdate') ?> " value="1" <?php checked($instance['showdate']) ?>>

             <label for="<?php echo $this->get_field_id('showsummary'); ?>">Show Summary:             <input type="checkbox" name="<?php echo $this->get_field_name('showsummary') ?>" id="<?php echo $this->get_field_id('showsummary') ?> " value="1" <?php checked($instance['showsummary']) ?>>

         <label for="<?php echo $this->get_field_id('posts_cat'); ?>">Podcast Category:         <?php             $categories_args = array(                 'name'            => $this->get_field_name('posts_cat'),                 'selected'        => $instance['posts_cat'],                 'orderby'         => 'Name',                 'hierarchical'    => 1,                 'show_option_all' => 'All Categories',                 'hide_empty'      => '0'             );             wp_dropdown_categories( $categories_args ); ?>
              <fieldset>             <legend>Select which podcast episode you would like to display:</legend>
                 <input type="radio" name="<?php echo $this->get_field_name('featuretype'); ?>" id="<?php echo $this->get_field_id('featuretype'); ?>_val1" value="latest" <?php checked($instance['featuretype'], 'latest'); ?>/>                 <label for="<?php echo $this->get_field_id('featuretype'); ?>_val1">Latest Podcast from Category
                 <input type="radio" name="<?php echo $this->get_field_name( 'featuretype' ); ?>" id="<?php echo $this->get_field_id('featuretype'); ?>_val2" value="featured" <?php checked($instance['featuretype'], 'featured'); ?>/>                 <label for="<?php echo $this->get_field_id('featuretype'); ?>_val2">Featured Podcast (set id below)
                      <label for="<?php echo $this->get_field_id('postid'); ?>">Featured Post's ID:                 <input type="text" name="<?php echo $this->get_field_name('postid') ?>" id="<?php echo $this->get_field_id('postid') ?> " value="<?php echo $instance['postid'] ?>" size="5">
         </fieldset>                   <?php                    echo '
';                  if (function_exists('powerpress_init'))                   echo ' PowerPress is installed.
';                  echo '
';                  echo '
Widget Shortcode: [featuredpodcast]
';         }                   // used when the user saves their widget options         public function update ($new_instance, $old_instance)         {             $instance = $old_instance;                  $instance['title'] = strip_tags($new_instance['title']);             $instance['showdate'] = $new_instance['showdate'];             $instance['posts_cat'] = $new_instance['posts_cat'];             $instance['postid'] = $new_instance['postid'];             $instance['showsummary'] = $new_instance['showsummary'];             $instance['showfeatured'] = $new_instance['showfeatured'];             $instance['featuretype'] = $new_instance['featuretype'];                  return $instance;         }                   // used when the sidebar calls in the widget         public function widget ($args, $instance)         {             extract($args);                  // Merge with defaults             $instance = wp_parse_args((array) $instance, $this->defaults);                  echo $before_widget;                  if (!empty($instance['title']))                 echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;                  // retrieve post information from database             if ($instance['featuretype'] == 'featured')             {                 $query_args = array(                     'post_type' => 'post',                     'cat'       => $instance['posts_cat'],                     'showposts' => '3',                     'ignore_sticky_posts' => true,                      'meta_key' => 'post_views_count',                      'orderby' => 'meta_value_num',                      'order' => 'DESC'                      );             }             else             {                 $query_args = array(                     'post_type' => 'post',                     'cat'       => $instance['posts_cat'],                     'showposts' => '3',                     'ignore_sticky_posts' => true,                      'meta_key' => 'post_views_count',                      'orderby' => 'meta_value_num',                      'order' => 'DESC'                      );             }                            $featured_post = new WP_Query($query_args);                      echo '';                  if ($featured_post->have_posts())             {                 while ($featured_post->have_posts())                 {                     $featured_post->the_post();                     observePostViews(get_the_ID());                          echo '
';                          if ($instance['showdate'])                          echo '';                         echo get_the_date('m.d.Y', $post->ID);                         echo '';                          // Show hyperlinked post title                     printf('
%s
', get_permalink(), the_title_attribute('echo=0'), get_the_title());                          // If selected, show excerpt from the post                     if ($instance['showsummary'])                         the_excerpt(); // Show excerpt from the post                          echo '';                          if ($instance['playerwidth'] > 0)                         $output_text = do_shortcode('[powerpress width="' . $instance['playerwidth'] . '"px]');                     else                         $output_text = do_shortcode('[powerpress]');                          echo $output_text;                     echo '';                          // printf('[Read More...]', get_permalink());                          echo '
';                      }                          echo '
';                          echo '';                     echo "VIEW MORE PODCASTS";                     echo '';                          echo '';                     echo '';                     echo '
';                     echo '';             }                  echo $after_widget;             wp_reset_query();         }     }               // Hook the widget up to WordPres     add_action('widgets_init', create_function('', 'return register_widget("SEM_Podcast_Widget");'));


pluggable function in theme, to be overridden by plugin

Is it possible to add a function in functions.php like this:               // ACF         if ( !function_exists('get_field') ) {             function get_field() {                 return false;             }         }      and then let plugins that creates that function override my theme function? In this case I'm using Advanced Custom Fields, and id like to have a fail-safe, that won't create "function does not exist" errors, in case the plugin gets deactivated. So i'd like my theme to have a fallback for that same function. Im assuming i might need to hook in somewhere, but I'm don't really know when. If i do what i've done above then it won't allow me to activate Advanced Custom Fields, because now the functions already exists (in my theme). Thanks