How to hide a custom field from admin?

I created a custom field that I would like to hide from the wp-admin (because the system generates it and I don't want user to change it; Hidding it with CSS should be OK in this case), Like this,                'postal_address' => array(                                 'guid' => 'postal_address',                                 'control' => array(                                     'type' => 'text',                                     'default' => '',                                     'allow_empty' => false                                 ),                                 'label' => 'Postal Address',                                 'help'  => 'Postal Address of Apartment'                             ),      Wich works, Problem is that the html element doesn't have any id/class so I can select it and Hide it, Is there a way to add an html attribute from the definition? thanks!


How can I check if taxs changed on save_post/post_updated action?

Im running some custom actions on the 'post_updated' action hook. But I need to know if the taxonomies changed on post update to run some extra functions. The action hook only returns $post_after and $post_before so I don't see a clear way to check if the taxonomies changed.


How to add postcounts behind every category wich are added in the standard wordpress menu?

How to add postcounts behind every category which are added in the standard wordpress menu? Like this:   * Apples (3)   * Strawberries (7) Do i need to add some code in functions.php to achieve this? Which code exactly? Please help!


Tax query not producing any results

I have created a custom post type called 'course' which has 7 posts each being an individual training course. I've also tagged them with individual custom taxonomies 'course_codes' eg. h001, h002, h003, etc. These correlate to the individual courses provided by a training centre. I have several training centers that have there own custom post type 'training_centre' each training centre will be tagged with the same custom taxonomies 'course_codes' that they provide, not all training centres have the facilities to train all courses so some are only tagged with couple of courses. So on my training centres template I've created a WP_Query to find all custom post type 'course' that have been tagged with the same custom taxonomy 'course_code' in training centres however, tax_query produces zero results, without tax_query I can get all the custom post types in 'course' however I only want the ones that are available at the training centre which is why I'm using 'course_code' to make the match - this is the code that produces zero results:               <?php     // Create a new instance     $args = array(     'post_type' => 'course',     'tax_query' => array(         array(             'taxonomy' => 'course_codes',             'field' => 'slug',             'term' => 'h001'             )         ),     'post_status' => 'publish'     );               $welcomepost = new WP_Query($args);?>     <?php while( $welcomepost->have_posts() ) : $welcomepost->the_post();?>              <?php the_title ();?>          <?php endwhile;?>     <?php wp_reset_postdata();?>      Where am I going wrong here, have I got the query wrong or am I going about this in the wrong way?


rewrite get parameter with custom post type

I am trying now for a couple days to solve the following Problem: I have a custom post type called `gallery`. I need the URL               http://example.com/gallery/FOOBAR      to be parsed like               http://example.com/gallery/?param=FOOBAR      The Permalink Setting for custom post type is:               /gallery/%postname%/%year%/%monthnum%/%day%/      I think I have tried about every code snipped that I could find to solve this problem but nothing seems to work.   If I flush all rewrites, none of my links work anymore (404) Is is even possible?


Show Previous/Next Posts navigation only inside the same category

Is it possible to force previous/next navigation to browse through the posts (back and forth) that are only inside the same category (and to exclude other categories)?


How to query custom post type by term?

This seems trivial but I can't get it to work. Here's my code:                       $args = array(                 'numberposts'     => -1,                 'eventcategory'   => 'nice-events',                 'post_type'       => 'event',                 'post_status'     => 'publish'              );                  var_dump(get_posts($args));      As you can see, my taxonomy is `eventcategory` and the term is `nice-events`. There are actually over 50 terms and regardless of what term I use in place of `nice-events` I always get the same result: all of the posts. So the term is being ignored and I have no idea why.


Foreach loop duplicating a taxonomy thumbnail image

I'm using the Taxonomy Images plugin to output thumbnails next to my tax terms. I'm using `get_term_children` in a foreach loop to pull out the terms, and a sub-foreach loop to pull out the thumbnail images. Things are working fine, except the images get printed twice. I must be doing something wrong with one/both of the loops. Anyone see any obvious foreach issues?               <?php     $termID = 10;     $taxonomyName = "tool";     $termchildren = get_term_children( $termID, $taxonomyName );     $termThumbs = apply_filters( 'taxonomy-images-get-terms', '', array('taxonomy'=> 'tool'));          echo '
';     foreach ($termchildren as $child) {         $term = get_term_by( 'id', $child, $taxonomyName );         echo '
';         echo wp_get_attachment_image( $termThumb->image_id, 'thumb' )   ;                  if ( ! empty( $termThumbs ) ) {             foreach(  $termThumbs as $termThumb ) {                 print wp_get_attachment_image( $termThumb->image_id, 'thumb' )  ;             }         }              echo 'name, $taxonomyName ) . '">' . $term->name . '';         echo '
';          }     echo '
';     ?>       The screenshot: http://cl.ly/1y2q2J0S0m3x0e0T0N1D


Filter / add_action to upgrade.php page

I'm wanting to change the wording and add some styling to the upgrade.php page. We have a situation where we update our codebase across multiple sites via Git - when a user logs in after the update they are greeted with the "You must update your database" message. This is fine but we want to refine the page a little, either filtering the text or adding a script to do it the dirty way. The problem is I don't see any hook for this page and the text is hardcoded in upgrade.php. Any help appreciated :)


In the Admin Dashboard, can I choose which sections to display?

For the editor I would just like to display Pages, Posts, Media and Menus. Is there a way of doing this with the functions file or similar? Thanks in advance.


Last Login in number of days format

I am trying to capture last user active date and reproduce that into another user-meta field in days only without any text with it. Being very bad with coding, I was hoping someone could help me shed some light on how best to achieve this. I checked many other solutions in the forum but non worked the way I wanted. Currently I am using this:               function set_user_last_active( $user_id ) {     $user = get_userdata ( $user_id );          $dateoflast = strtotime( get_user_meta($user_id, 'last_active') );                  $datenow = strtotime( current_time('mysql') );     $difference = abs($datenow - $dateoflast / 86400);          //add or update the last login value for logged in user     update_usermeta( $user->ID, 'last_active', current_time('mysql') );     update_usermeta( $user->ID, 'last_active_days_ago', human_time_diff( strtotime( get_user_meta($user_id, 'last_active', true) ) ) );     update_usermeta( $user->ID, 'last_active_days_ago2', $difference);                                   }      As you can see, I am trying different ways to achieve this but the closest I got to is the second update_usermeta which outputs a number along with minutes. Although I took the third one from a post here, it outputs a long number that keeps increasing: 1387740860 I hope I can find someone who tried a similar thing or experienced enough to help me do it. Thanks a lot!


What is Global Wordpress Objects?

I was trying to load wordpress in a smarty template and i have got a lot of errors that has the same origin "Fatal error: Call to a member function the_function() on a non-object". The solution to such error is by declaring the wordpress global objects before loading wordpress like this:               global $wp_rewrite;      Is there is a list of these objects that I can use to declare all of them so I don't get any of these errors again?


Non-public custom post type - View post link

I have created a custom post type as follows:               register_post_type( 'testimonials',       array(         'labels' => array(           'name' => __( 'Testimonials' ),           'singular_name' => __( 'Testimonial' )         ),         'public' => false,         'show_ui' => true,         'show_in_menu' => true,         'supports' => array( 'title', 'editor', 'thumbnail' ),       )     );      But when I create a post I receive a message: > Post published. View post With a link that obviously doesn't work. Anyway to get rid of this coming up? Also I'm worried that if WP is doing this, then it might have references to the non-existent URL else where? Am I doing something wrong?


Overwrite rewrite-slug of built in post-type 'post'

I need to change the rewrite-slug of the built in post-type 'post' to 'example.com/magazine/news/any-nice-news-item'. When I re-register the post-type 'post' and set the rewrite-slug to 'magazine/news' it works fine. But now I'm not sure about any side-effects. Does anybody have any positive or negative experience with that? Here is the code:               register_post_type( 'post', array(         'labels' => array(             'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),         ),         'public'  => true,         /* internal use only. don't use this when registering your own post type. */         '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */         'capability_type' => 'post',         'map_meta_cap' => true,         'hierarchical' => false,         'rewrite' => array('slug' => 'magazine/news'),         'query_var' => false,         'delete_with_user' => true,         'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),     ) );


Page templates in subdirectories and auto generator

This might be a shoot in the dark but here goes... I know that starting with wp 3.4 i can put page template aka page-template.php in sub folders. (ref: Page templates in subdirectories) which is great and helps me to make a lot of order in an over-crowded custom theme folder. **this works - however:**   i need to auto-create many pages on theme activation and thus, i use the script i added below. **but:**   picking / setting the page template doesnt work if the page is in a sub folder. **The script i use:**               $start_number   = 2;     $iim_pages      = array('tools', 'clients-manager', 'task-manager');          foreach($iim_pages as $page) {              $page_title     =   ucwords(str_replace('-', ' ', $page));         $page_filename  =   'page-'.$page.'.php';              $page_check = get_page_by_title($page_title);         $new_page = array(             'post_type'     => 'page',             'menu_order'    => $start_number,                    'post_title'    => $page_title,             'post_content'  => '',             'post_status'   => 'publish',             'post_author'   => 1,         );         if(!isset($page_check->ID)){             $new_page_id = wp_insert_post($new_page);                  update_post_meta($new_page_id, '_wp_page_template', $page_filename);               // THIS WORKS! : add_post_meta($new_page_id, 'testmeta', $page_filename);                }              $start_number++;     }      I tried many variation but it seems that wp doesnt set the page template   unless in outside the sub-folder can anyone offer a solution?


Showing Notifications While Activating Plugin

I want to give errors like this, while activating my plugin. ![enter image description here](http://i.stack.imgur.com/3yAem.jpg) Which hooks should i use ? Can you share simple examples ? In shortly,when user activate my plugin, is a directory's CHMOD isn't 777 , i'll warn it and stop activation.


Sticky (or any boolean field) taxonomies?

I would like to add an extra field to a custom taxonomy, wich I would use a little bit like sticky posts, this way I could have a menu with some special taxonomies, is that posible? I can't seem to find anything like this here -EDIT- Is there any simpler implementation than this one (I'm sure it works but It looks like reinventing the wheel a little bit)?


How to do a wp_query using "BETWEEN" with two meta_values?

I'm starting with Wordpress, already achieved some queries, but this one... ugh! It's being a pain to me! What i want to do is this part of query:               " ... WHERE "VALUE_THAT_I_WANT" BETWEEN event_start_date AND event_end_date ..."      Where "event_start_date" and "event_end_date" are meta keys ( i want to use their values, not mine!) This is what i had so far..               $tEA = array(         'post_type' => 'event',         'meta_key' => $metaKey,         'orderby' => 'meta_value',         'order' => $order,         'posts_per_page' => $postPerPage,         'meta_query' => array(             array(                 'key' => $metaKey,                 'value' => $today,                 'compare' => "=",                 'type' => 'DATE'             ),             array(                 'key' => '_event_end_time'             )         )     );


Exclude recently updated post from custom WP_Query using multiple loops

I want to do something like this but can't manage to figure it out. [Click][1] I am using this custom WP_Query to display upcoming events on my homepage.                       $events_args = array(             'post_type' => VA_EVENT_PTYPE,             'posts_per_page' => $number,             'no_found_rows' => true,             'post_status' => 'publish',             'ignore_sticky_posts' => true,             'tax_query' => array(                 array(                     'taxonomy' => VA_EVENT_DAY,                     'field' => 'slug',                     'terms' => $days,                     'include_children' => false,                 ),             ),             'meta_key' => VA_EVENT_DATE_META_KEY,             'orderby' => 'meta_value',             'order' => 'asc'         );              $r = new WP_Query( $events_args );              if ( $r->have_posts() ) :      What I need to do now is: Exclude the most recently updated 2 posts from this query, because these posts are already displayed somewhere else. I can't do it using multiple loops, because this is a widget and the other query is in another widget. Help would be much appreciated!


.htaccess RewriteBase equivalent for WordPress - Passing a URL as a variable without getting a 404

I have a page ran by a javascript plugin that changes the url every time a slide in a gallery is cycled. This means that while slide 1 is visible, the URL is `http://www.sitename.com/gallery/slide1/` and while slide 2 is visible, the URL is `http://www.sitename.com/gallery/slide2/` ... and so on. Outside of WordPress, I used the RewriteBase command in an .htaccess file to make it so that when a user goes to `http://www.sitename.com/gallery/slide2/` they're directed to a page where slide 2 is visible. However, I cannot find a way to make this happen in WordPress. Is there a way to pass this information as a variable without using a format like `http://www.sitename.com/gallery?slide=slide2` The script I'm currently using is:               // change url - unless IE8 because IE8 hates life     if ($.browser.msie && $.browser.version < 9) {} else {         $histimg = img.name.toLowerCase();         var stateObj = { foo: "bar" };         history.replaceState(stateObj, "", pathname + imageprefix + $histimg + "/");     }      Then, when a link is accepted, I run this to find out which plan to display:               patharr = location.pathname.split("/").reverse(); //Get the URL of the page          result = patharr[1]; // Get the Slide Number          $('#xmenu button[data-index="' + result + '"]').trigger("click");          }         NOTE: I do not wish to accomplish this with a plugin, or by hacking files directly inside of the WordPress installation. This is part of a theme and needs to be contained within the theme.


Keyboard Shortcut to Publish Post on the Mac

What's the keyboard shortcut to update posts? I've read that it's Alt + Shift + p, but that doesn't work on my Mac, nor does Ctrl + Shift + p.


Custom Posts on homepage

I'm just getting my feet wet with creating a custom post type (which is up and running). I'd like to display the CPT alongside other posts on my homepage... I can't figure it out for the life of me. I'm hoping someone can see the error of my ways before I pull more hair out. I'm sure it's a rookie mistake, I have been staring at the screen perhaps a little too long... any help would be appreciated! I've also come across a few articles suggesting pre_get_posts isn't a good idea. I'm using a Woothemes Canvas Child Theme * * * Have a page called Home that uses the Canvas Magazine Template so...                function review_post() {          $labels = array(           'name'=> _x( 'Reviews', 'Post Type General Name', 'text_domain' ),           etc....          );              $rewrite = array(             'slug'=> 'review',         etc...          );          $args = array(          'label'               => __( 'post_review_key', 'text_domain' ),         'description'         => __( 'Posts for Review Snippets', 'text_domain' ),         'labels'              => $labels,         'supports'            => array( 'title', 'editor', 'thumbnail', 'revisions', ),         'taxonomies'          => array( 'reviews'),         'hierarchical'        => false,         'public'              => true,         'show_ui'             => true,         'show_in_menu'        => true,         'show_in_nav_menus'   => true,         'show_in_admin_bar'   => true,         'menu_position'       => 5,         'menu_icon'           => '/review-star-16x16.jpg',         'can_export'          => true,         'has_archive'         => true,         'exclude_from_search' => false,         'publicly_queryable'  => true,         'rewrite'             => $rewrite,         'capability_type'     => 'page',          );         register_post_type( 'post_review_key', $args );          }           // Hook into the 'init' action     add_action( 'init', 'review_post', 0 );          }      and then               add_action( 'pre_get_posts', 'add_my_post_types_to_query' );          function add_my_post_types_to_query( $query ) {     if ( is_home() && $query->is_main_query() )         $query->set( 'post_type', array( 'post', 'review_post' ) );     return $query;     }


Custom Post Types posts as submenus in Nav Menu

I have created a Custom Post Type called "Collections". I'd like to have in the Nav Menu (no custom menus involved) a menu item 'Collections' that links to the `index` page of Collections Custom Post Type, and hanging from this Menu Item, a list of `n` Submenu Items each linking to a single `post`. I've done some research and I think there is no literature about the subject. Probably some hooking involved (rewriting the `wp_nav_menu()` perhaps). I've managed to have the 'Collections' menu item by declaring `'show_in_nav_menus' => true` in `register_post_type()` but I don't know how to move forward in making the single posts appear as a submenu. Any help? Note: using a Thematic Child Theme


How to Create a Simple Related Posts Plugin

I think it would be best to keep some things in a plugin. I have this code:

Related posts
          <?php         $orig_post = $post;         global $post;         $tags = wp_get_post_tags($post->ID);              if ($tags) {         $tag_ids = array();         foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;         $args=array(             'tag__in' => $tag_ids,             'post__not_in' => array($post->ID),             'posts_per_page'=>4, // Number of related posts to display.             'caller_get_posts'=>1         );              $my_query = new wp_query( $args );              while( $my_query->have_posts() ) {         $my_query->the_post();         ?>
             <a rel="external" href="<? the_permalink()?>"><?php the_post_thumbnail(array(150,100)); ?>
             <?php the_title(); ?>
              <? }         }         $post = $orig_post;         wp_reset_query();     ?>
      But I am not sure how to add it to a plugin. My main problem is I am not sure how to call this in my single.php...I know to add the class and function in the plugin and the basic setup, but other than that any advice is helpful :)


How to make dynamically-generated content searchable in WordPress?

I'm writing a plugin for WordPress that dynamically generates content from a Google Documents Spreadsheet. Specifically, the plugin provides a shortcode that generates a good-looking staff list. It works, but there are two problems:   1. Pages that use the shortcode load a little slow, because they have to make multiple requests to another server   2. Since the content is generated when the page is loaded, the contents of the staff list do not show up in search results on the site I can fix the first problem with some level of caching, but what can I do about the second problem? I mention the first problem because I think the ideal solution is one in which WordPress indexes the cached copy of the page. Another solution I can think of would be to have the content of the page composed by a plugin periodically. That way the page could be searched and wouldn't be dynamically generated every time. However, it seems like a strange paradigm for a plugin to completely control the content of a page...are there other plugins that do this? Also, this approach exposes complexity to the user that it shouldn't have to. (They'd have to edit the contents of the page from a plugin page instead of the normal place.) Here's a sample of what part of the markup for the page looks like:
General Management
          [staff-directory department="General Management"]      The spreadsheet to hit is configured separately. The "department" specifies the worksheet. (I'd show you what the results look like, but I don't have enough rep to post an image.) Your suggestions are greatly appreciated.


Recommended Media Size for Twenty Fourteen

is there a recommended media size for Thumbnail size in twenty fourteen? am trying to sort out my website so that it doesn't serve any resized media on the home page, most of the resized media are coming from the featured image on the home page. When i test the page speed i get "The following images are resized in HTML or CSS" Any help on the thumbnail media size wold be greatly appreciated.


$page = get_page_by_title CONTAINS

Just wondering how to fetch a page by using 'title contains'. I can retrieve a page by using the following               <?php      $page = get_page_by_title('Restaurants and Pubs');     ?>      but how could I do 'page title contains "Pubs"'? Thanks


query_posts orderby postmeta

I'm trying to retrieve a custom post type and order it by a custom date stored in postmeta. The custom date is a unix timestamp. The meta_query works correctly - it only retrieves posts with a custom date in the future. But the orderby does not work - the order is still based on the post_date. What am I missing?                  $today = date("m/d/Y");        $today = strtotime( $today );               query_posts( array(             'post_type'      => 'custom_cpt',             'orderby'    => 'meta_value',             'meta_key'   => 'custom_date',             'paged'          => $paged,             'posts_per_page' => 5,                  'meta_query' => array(                 array(                     'key'       => 'custom_date',                     'value'     => $today,                     'compare'   => '>',                     'type'      => 'NUMERIC',                 ),             ),         ));


Can't add a class to links in the visual editor since WP 3.1?

Did this feature chang in 3.1? I recall that I could change the class of the link in the thickbox popup. ![Link dialog in WP 3.0.5](http://i.stack.imgur.com/65NaA.png) ![Link dialog in WP 3.1](http://i.stack.imgur.com/kXKIj.png)


Getattachment next and previous by author only

Im trying to get the next and previous attachment by the user its currently displaying, this is what I have and it works great except it gets all of the attachments instead of just the ones from a specific user.
     <?php $attachment_size = apply_filters( 'twentyten_attachment_size', 900 );      echo wp_get_attachment_image($post->ID, array( $attachment_size, 9999) ); // filterable image width with, essentially, no limit for image height.?>

<?php previous_image_link(); ?>

<?php previous_image_link(false, 'Previous Photo'); ?>

 <?php next_image_link(); ?>

<?php next_image_link(false, 'Next Photo'); ?>


Why can't I query more than 1 post type at a time?

I have a custom post types called **publications**. I want to retrieve all the **pages** and **publications**. (I'm also filtering by taxonomy, but that's not what is creating the problem)               $args= array(             'post_type'=>array('publications', 'page')             );     query_posts($args);      The above only returns pages, not publications. If I remove 'page' from the array and leave               'post_type'=>array('publications')      then the publications are returned. Its seems like I cannot query more than I post type at a time, contrary to what the codex explains here: http://codex.wordpress.org/Template_Tags/query_posts#Type_.26_Status_Parameters. I've tried 'post_type' = 'any' with the same results; only the pages are returned. Using WP_Query also yielded the same results. Am I doing something wrong or is this a bug in WP 3.1 rc3?


SQL Query to Get list of all users along with their blogs

How to query for a list of users along with the blogs in which they are member of in a multi site wordpress installation. For example, I need the results as below               user domain     abc  xyz.com     abc  example.com     ggh  example.com      I tried the below query, but its not listing all the domains..               SELECT DISTINCT a.user_login, a.user_email, c.domain     FROM wp_users a     JOIN wp_usermeta b ON a.id = b.user_id     JOIN wp_blogs c ON b.meta_value = c.site_id     LIMIT 0 , 100      I am not sure how the network/multi site works.. can anyone please tell me how to get the result?


Access post meta in future_to_publish function

Why am I having trouble accessing post meta data in a future_to_publish add action in functions.php? I have tried:               function post_to_twitter() {         global $post;         $url = get_post_meta($post->ID, 'short_url', true);         if(!isset($url) || $url == "") $url = get_permalink($post->ID);         //post to Twitter code     }     add_action('future_to_publish', 'post_to_twitter', 5);      I have also tried:               function post_to_twitter($post) {         $url = get_post_meta($post->ID, 'short_url', true);         if(!isset($url) || $url == "") $url = get_permalink($post->ID);         //post to Twitter code     }     add_action('future_to_publish', 'post_to_twitter', 5, 1);      The post to Twitter code is working just fine, and the function is being called when a scheduled post is published. The code above is trying to get a post meta value "short_url", but it doesn't seem to be working. I believe it has something to do with the $post variable. The exact same code is working perfectly for a "publish_post" function. Any ideas?


How I upload, save and set a featured image from my frontend?

I have a form in my site. This the user register one missing person. I created a custom post type missing person, custom taxonomies and custom fields. All this input's save as well in wp. But I dont know submit image and save this image as featured image.               $my_post = array(                      'post_title' => $_POST['title'],                      'post_date' => $_SESSION['cal_startdate'],                      'post_content' => $_POST['myContent'],                      'post_status' => 'draft',                      'post_type' => 'pessoa_desaparecida',                   );          $post_id = wp_insert_post($my_post);               $uploaddir = wp_upload_dir();     $file = $_FILES["test"]["name"];     $uploadfile = $uploaddir['path'] . '/' . basename( $file );          move_uploaded_file( $file , $uploadfile );     $filename = basename( $uploadfile );          $wp_filetype = wp_check_filetype(basename($filename), null );          $attachment = array(         'post_mime_type' => $wp_filetype['type'],         'post_title' => preg_replace('/\.[^.]+$/', '', $filename),         'post_content' => '',         'post_status' => 'inherit',         'menu_order' => $_i + 1000     );     $attach_id = wp_insert_attachment( $attachment, $uploadfile );     update_post_meta($post_id,'_thumbnail_id',$attach_id);          set_post_thumbnail( $post_id, $thumbnail_id );      but not works My Form in frontend is:               <form action="/homolog/cadastro" method="post" enctype="multipart/form-data">      <input type="text"  name="title" />      <input type="file" size="20"  name="test" />     </form>      PRINT: ![enter image description here](http://i.stack.imgur.com/Zd0GX.png) ![enter image description here](http://i.stack.imgur.com/RhUHR.png)


category results within page template

to paint a clear picture of what i am trying to achieve, i will describe my current wordpress theme setup: in my theme, i am making use of the following content types: posts, pages and custom content type pages. the pages content type are the main web pages that are used across the my site which my navigation links to. i have created few page templates, each have built in queries to display related custom type pages. so they essentially work similar to an archive page, but the only difference is that i am able to upload a banner as i would to any other page. a typical archive.php page will not give me the option to display a manageable custom banner or custom meta data. for example, i have a page template called 'Event Page', the functionality within this templates pulls a list of all the events that were created in the event custom content type. when an event is selected from this list, it will call the single-event.php to display the page of the selected event. the Event custom content type also has a list of categories. if i click on any of the categories, it will show me the filtered results within the category.php. is there away i can display the filtered results within the Event page template. i hope this makes sense. currently if i clic


Get canonical link

Hi I know `get_permalink` returns the URL. Some of my posts are redirected and at the same time I update the canonical link to the redirected post URL - (normally relates to post updates). Is there a function I can use to return the canonical URL of a post if it has one rather than it's 'permalink' URL? I use Yoast SEO to edit canonical URLs and also apply redirects. I want to use the 'canonical permalink' in a function.


How can I use the built in Wordpress "browse link" functionality?

I'm coding a widget and I'd like the user to be able to pick a link like you can when editing a regular posts or page (when you click on the little link icon and you get the AJAX search functionality in the pop up). Does anyone know how I get this working? I've got a HTML button which I would like to attach and click even to, and a field for the value to go in. In class-wp-editor.php I found a few interesting things, and wondered if I might need these files..?               wp_enqueue_script('wp-fullscreen');     wp_enqueue_script('wplink');      On calling `fullscreen.link();`,like the file mentioned above, I get this error: `Uncaught ReferenceError: wpActiveEditor is not defined` ..and I'm stumped for now, because the JS that references that variable looks crazy to me. Care to point me in the right direction? I'd love to get this working, it will make a killer user interface for my widgets! ![enter image description here](http://i.stack.imgur.com/PREca.gif) ------edit------- Not that much code so far, apart from the script inclusions that I have previously stated;               <label for="<?php echo $this->get_field_name('link'); ?>">Link URL (including http://) : </label>     <input type="text" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" value="<?php if(isset($link)) echo esc_attr($link); ?>" class="widefat" />     <button class="secondary" id="choose_link">Link Browser</button>      ..the part of the JS which is supposed to trigger the link script to open;               linkBrowserButton.on("click", function(e){         e.preventDefault();         fullscreen.link();     });


Calling dynamic_sidebar in plugin gives error

I am trying to call `dynamic_sidebar` from a plugin page. Whenever I do so, it returns a white page! Any idea why? What I am trying to do is to save the total sidebar output in a transient. I can get the sidebar output in a variable from the theme files, using this codes:               ob_start();     dynamic_sidebar('name');     $sidebar= ob_get_contents();     ob_end_clean();      I can get the data in `$sidebar` and save it in a transient. But whenever I use this code from a plugin, the plugin admin page returns white screen. It happens whenever I call `dynamic_sidebar` in my plugin codes, doesn't matter what's before or after. Does anyone know why? Or any solution please?


How can I fetch the next level of the currently selected main menu (hierarchical menu)?

I have the following structure (defined at Appearance > Menu):   * foo      * fii     * faa     * fee   * bar      * boo     * bee     * bii Now, in my theme I have one horizontal menu that shall _always_ display **foo | bar** Below that, there's another horizontal menu which, when **foo** is clicked, should display: **fii | faa | fee** When **bar** is clicked, that same menu shall display: **boo | bee | bii** Only the sub-menus of the currently selected main menu ( _foo/bar_ ) shall be displayed. **How can this be achieved?**


Display posts from the same category using next/previous post link

I am using this code, but once I click on the next post/previous post link, I am redirected to the next post/ previous post of the different category                    previous_post_link('%link', 'Prev post in category', $in_same_term = true);      next_post_link('%link', 'Next post in category', $in_same_term = true);      I am trying to fix my issue using this article Here is the code i am using posts and categories and i am not using custom post type and categories                <?php                $post_id = $post->ID;               $cat = get_the_category();               $current_cat_id = $cat[0]->cat_ID;     $args=array('category'=>$current_cat_id,'orderby'=>'post_date','order'=> 'DESC');                 $posts = get_posts($args);                 foreach($posts as $post){                 echo $post->post_content;                 }                previous_post_link('%link', 'Prev post in category', $in_same_term = true);                next_post_link('%link', 'Next post in category', $in_same_term = true);                         ?>      This is the code i am using. Its basically fetching all the posts based on the category. And now i want the next post/ previous post link to work only for this particular category.


how to add custom post to User Specific Content Plugin

I am new to coding plugin, My custom post type is not showing up in (User Specific Content) plugin settings panel… I used this code               add_action('init','add_metabox_to_my_custom_post_type',10);     function add_metabox_to_my_custom_post_type(){         $post_type = 'CHANGE_THIS_TO_YOUR_POST_TYPE';         global $U_S_C_i;         add_meta_box(             'User_specific_content',              __( 'User specific content box'),             array($U_S_C_i,'User_specific_content_box_inner'),             $post_type         );     }      in my function.php file and changed this `$post_type = ‘CHANGE_THIS_TO_YOUR_POST_TYPE’;` to `$post_type = ‘listing’;` but after save i get Parse error: syntax error, unexpected ‘ !!! I think “add_meta_box” is undefined, How can i use this code in my theme?


URL Rewrite fires when retrieving a custom value?

I'm working on an old WP Multisite instalation (3.0.1) and something weird is happening. The guy who built the site made a decision to store direct URLs instead of Post IDs to a Custom Field. And this is creeping me with:               // String stored on the database: `http://example.com/wp-content/uploads/2012/07/filename.pdf`     // Code     $cf = get_post_custom($post->ID);     $pdf = $cf['meta_key'][0];     // Result     $pdf == 'http://example.com/wp-content/sitename/files/2012/07/filename.pdf' // true      Any ideas why this might be happening? Why is the URL string being rewritten?


shortcodes not working -they just display as raw shortcode (code)

I'm developing a plugin and need to implement shortcodes, the shortcodes is coming out as it is on a archive/category page - I have used to the shortcode_exists(); to check if the shortcode does exist and it does exist - im developing on localhost and there are no other plugins installed that could be creating conflict issues - I would really appreciate help on this - Im quite new to wordpress frankly - I have included the shortcode function which is in my main plugin file               function load_front_end_display ($atts) {        extract(shortcode_atts(array('filepath' => 'NULL'), $atts,'portrait'));        if ($filepath!='NULL' && file_exists(plugin_dir_url()."/plugin_directory/".$filepath)){          ob_start();          include(plugin_dir_url()."/plugin_directory/".$filepath);            $content = ob_get_clean();          return $content;        }     }     add_filter('the_content','load_front_end_display');     add_shortcode('portrait','load_front_end_display');


What exactly does the import tool do?

I experimented with the import tool a bit and it seems to do different things for different tables. For **`posts`** : if a post (or page, which technically is a post too) `title` from the import file is already present in the database, it **won't** be imported. The Wordpress interface in this case will indicate that "there already exists...". For **`postmeta`** : all rows from the imported database will be added. Regardless whether that information was already present -> tends to bloat the database. I wonder what happens for the other tables. Will rows be **overwritten** , **added** (as in `postmeta`) or **refused** (as in `posts`) if they're already present? And how is "already present" defined here anyway (`post_id`? `term_id`? `name`)?


How can I prevent redirects from mysite/page to mysite/wp path/page?

Apparently this is built into WP somwhere since going to mysite/wp-login.php takes me to mysite/<wp path>/wp-login.php (same for wp-admin and I presume other paths). The problem is, I don't like this functionality. My paths are intentionally not the default in order to make them less accessible to automated brute force attacks, but these redirects prevent the from being effective. I'm assuming I can just filter this away, but I don't know which filter(s) would need to be used. Any nudges in the right direction would be appreciated!


Are There Performance Concerns with Front-End Theming Platforms on Serious WP Sites?

I've been helping a guy put together a site for a client and he insists on using a front end editing/theming platform for WordPress (in this case Pagelines DMS). However, I'm seriously questioning the stability of the entire platform. He's trying to move a client to the platform who's doing $25,000 per month in eCommerce revenue and I'm afraid to do it. So, my question is, should I be concerned with the stability of the platform and its ability to perform well with tens of thousands of visits per month? Why or why not?


problem with plugins installation (quite beginner)

i'm quite a beginner with wordpress, and i'm stuck with the installation of a plugin : Firstly, i tried the photo gallery plugin nextGen : http://wordpress.org/extend/plugins/nextgen-gallery/installation/ i followed the video, that explains that once the plugin actived, to put the shortcode in the page content section : well, i did it, the pictures are in my article, but if i click on it, it launches a new page, instead of doing the javascript-stuff to show the image in the page's center. So, i tried another plugin : lightbox 2 : http://wordpress.org/extend/plugins/lightbox-2/ but after being activated, nothing appears, there's just a reference to it in the settings, but i can't see where the plugin is... Quite frustrating ! If anyone could help me, i would really appreciate. Thanks a lot


unwanted redirect on saving custom post type / custom post not saving

I've added (or at least attempted to add) a custom post type that has a custom meta box allowing a file to be attached to the post. This function has been spotty at best, allowing some files to be uploaded, while others fail without providing an error message. By fail, I mean the post is autosaved as a draft, and the user is redirected without warning to the "posts" page within the admin area. I've poured over the code, and I can't seem to find out why this would happen, so if anyone has any ideas, I'd love to hear them. Attached is the code that I'm using:               function save_custom_meta_data($id) {              /* --- security verification --- */         if(!wp_verify_nonce($_POST['file_upload_nonce'], "nonce_for_uploads")) {           return; //$id;         } // end if              if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {           return;// $id;         } // end if              if( !current_user_can( 'edit_post' ) ) return;         /* - end security verification - */              // Make sure the file array isn't empty         if(!empty($_FILES['wp_custom_attachment']['name'])) {                  // Use the WordPress API to upload the file             $upload = wp_upload_bits($_FILES['wp_custom_attachment']['name'], null, file_get_contents($_FILES['wp_custom_attachment']['tmp_name']));                  if(isset($upload['error']) && $upload['error'] != 0) {                 wp_die('There was an error uploading your file. The error is: ' . $upload['error']);             } else {                 $upload['file'] = str_replace('\\', '/', $upload['file']);                 add_post_meta($id, 'wp_custom_attachment', $upload);                 update_post_meta($id, 'wp_custom_attachment', $upload);                      add_post_meta($id, 'wp_custom_attachment_url', $_POST['wp_custom_attachment_url']);                 update_post_meta($id, 'wp_custom_attachment_url', $_POST['wp_custom_attachment_url']);                  } // end if/else              } else {                  // Grab a reference to the file associated with this post             $doc = get_post_meta($id, 'wp_custom_attachment', true);                  // Grab the value for the URL to the file stored in the text element             $delete_flag = get_post_meta($id, 'wp_custom_attachment_url', true);                  // Determine if a file is associated with this post and if the delete flag has been set (by clearing out the input box)             if(strlen(trim($doc['file'])) > 0 && strlen(trim($delete_flag)) == 0) {                      // Attempt to remove the file. If deleting it fails, print a WordPress error.                 $doc['file'] = str_replace('\\', '/', $doc['file']);                 if(unlink($doc['file'])) {                          // Delete succeeded so reset the WordPress meta data                     update_post_meta($id, 'wp_custom_attachment', null);                     update_post_meta($id, 'wp_custom_attachment_url', '');                      } else {                     wp_die('There was an error trying to delete your file.');                 } // end if/else                  } // end if              } // end if/else          }       And here is the meta box callback               //call back for the file upload     function show_download_file_box() {              //set up the nonce.           wp_nonce_field('nonce_for_uploads', 'file_upload_nonce');              //state the html code         ?>
             Upload your PDF here.
         <input type="file" id="wp_custom_attachment" name="wp_custom_attachment" value="" size="25" />              <?php              // Get the name and url of the file that is uploaded, or tell the user that no file exists             $doc = get_post_meta(get_the_ID(), 'wp_custom_attachment', true);                  if (is_array($doc)) {                      //the string replace here is used to fix a localhost issue on windows machines.                 $doc['file'] = str_replace('\\', '/', $doc['file']);                 $doc_link = $doc['file'];                 $doc_name = basename($doc['file']);                  } else {                      //the file isn't set, so we tell the user this.  techinically it is possible to have                 //a file library post that is empty.  I don't suggest it, but maybe we could use this                 //to put coming soon items.                      $doc_link = "";                 $doc_name = "not set";             }                     // Create a hidden input box used to delete the file and set the file's URL as the text element's value             // Then use the file name, and show the user what is currently being linked         ?>         <input type="hidden" id="wp_custom_attachment_url" name="wp_custom_attachment_url" value="<?php echo $doc_link; ?>" size="30" />          Current file is <?php echo $doc_name; ?>
              <?php         // Display the 'Delete' option if a URL to a file exists         if(is_array($doc) && strlen(trim($doc['file'])) > 0) {             $html .= '' . __('Delete File') . '';         } // end if              echo $html;          }      add_action('save_post', 'save_custom_meta_data');      And here is the call to create the meta box:               function add_IDL_meta_boxes() {     //Other meta boxes removed from this for simplicity              add_meta_box(             'download_library_file_box', // $id             'Downloadable File', // $title              'show_download_file_box', // $callback             'download-library', // $page             'side' // $context             );      }     add_action('add_meta_boxes', 'add_IDL_meta_boxes');


How to auto gen. custom post type values in other custom post type in url?

I have created two custom post types (CPT) say books and reviews. Now how can i auto generated a reviews page for a specific book title??. What i have done so far i made a review page (page-reviews.php) which displays the reviews based on a book's $id. In CPT "reviews" there is a dropdown menu with id's corresponding the book title. I thought of something like `mydomain.com/books/{title-book}/reviews` But how can i auto generate this url path to be recognized and how do i get the book's $id in reviews (page-reviews.php) should i alter the `'hierarchical' => true, 'rewrite' => array( 'slug' => 'reviews' ),` Regards,


Redirecting specific category posts to subdomain

We have a WordPress site, which contains posts and pages with different categories. Now we moved a particular category posts into sub domain & we want 301 redirection so that every post from that specific category points to the sub domain. All the posts have .html extension in main domain so we have also changed the sub domain permalink structure to .html. for example: we have http://www.mydomain.com/category/category-name & we have created the sub domain for this category http://category-name.mydomain.com   we can easily redirect this category to sub domain by using .htaccess 301 redirection but the only the home page of the category is redirected not all the posts, we want to redirect all the posts of this category to points to sub domain posts. Sample Post: www.mydomain.com/sample-posts.html of this category need to redirect with category-name.mydomain.com/sample-posts.html. How to redirect all posts of this category also with this category into sub domain? Also, should we delete all the posts from main domain or we have to keep it ?


different CNAME to corresponding subfolders

I have three wordpress websites hosted on Apache server in three different subfolders, like www.mydomain.com/sub1;www.mydomain.com/sub2;www.mydomain.com/sub3 Now, I have three new domain names (www.sub1.com; www.sub2.com; www.sub3.com), and try to CNAME them to corresponding subfolders. I decided not to use url redirect because it doesnt hide www.mydomian.com, and also not to use frame url forwarding because iframe kills the theme responsiveness. Now the only choice left is to use CNAME method. My question is how to modify the .htaccess to do that? or some other way even better? I am not a server guy, and i have done the searches, didnt get what i want. Appreciate anyone who could help me out.


Adding Category Items to Non Category Menu Item

I'm using Events Calendar Pro and would like events that I categorize as "Featured" to automatically be added as a second-level nav item in my site's nav menu, underneath of the top-level item "Events". My question shouldn't be specific to events, but rather Pages, since ECP is just a page type. My nav menu should look like the following: EVENTS (/events/)   - Featured Event #1 (/events/featured/event1/)   - Featured Event #2 (/events/featured/event2/)   - Featured Event #3 (/events/featured/event3/)   - View All Events (/events/) Any help with how to achieve this? Thanks!


Games product for hire monthly

I want to display games products on my wordpress site with hire and reserve button for monthly subscription. Can somebody told me the right plugin or code? Thanks in advance.


Is it OK to redirect to a new address instead of showing 404 Error page?

Here is my question, Recently I moved my site from **_blog.mysite.com_** to **_www.mysite.com_**. Then I added 301 permanent redirection using this code in .htaccess file.               RewriteEngine on     RewriteCond %{HTTP_HOST} ^blog\.mysite\.com$ [OR]     RewriteCond %{HTTP_HOST} ^www\.blog\.mysite\.com$     RewriteRule ^/?$ "http\:\/\/www\.mysite\.com\/" [R=301,L]      Everything was OK, and when I go to my site by typing **_blog.mysite.com_** it automatically redirected to **_www.mysite.com_**. But, I found that when I click a Google search result of my old site doesn't redirect to the new site. Guess Google result URL is http://blog.mysite.com/how-to-create-simple-but-fully-styled-navigation Though it doesn't redirect to http://www.mysite.com/how-to-create-simple-but-fully-styled-navigation It only goes to the old URL which is http://blog.mysite.com/how-to-create-simple-but-fully-styled-navigation which shows my hosting provider's 404 Error page. So, then what I did was creating a custom 404 error page and added a php code to get the Google's search result URL and replace the word 'blog' with 'www' then redirecting to http://www.mysite.com/how-to-create-simple-but-fully-styled-navigation So, now everything's working perfectly and no any error pages. But I want to know if what I've done is OK with SEO logics. I've heard that 301 permanent redirection tells the Search engines that the site has moved. And where the new site is. I want to know if there's no damage to 301 redirection after I've created custom 404 page and added a tricky redirection... Thanks... Hope you understand. :-)


Problem with wordpress links on a live site

I am trying to create a website at the following link: http://www.knowthelaw.in/ The website was created with wordpress using the twentyeleven theme. The problem I am facing is as follows: As soon as you agree to the disclaimer and hit the "Proceed to .. " button, you are served with a 404 error. The page it redirects to is the "Welcome!" page which can also be accessed from the "About" section. Apart from this one page, all other pages work OK. This problem is not seen in the wordpress website on localhost. What I have done so far:   1. Checked all permalinks.   2. Changed the link for the "Proceed .. " button to a `?page_id` link. This does not work.   3. Kept the permalink in the drop-down menu. This too does not work.  I am at my wits end to figure out what the problem is. Any help is most welcome.


Display posts with tag that matches current post title

How would I show posts that have a tag who's name matches the title of the current post? For example if you are on a post called "Hippo" at the bottom of the page I would like posts with the tag "Hippo" to be displayed.


How can I make a different theme be viewed for logged in users vs guests?

Well, as the title says is my question. But more details: Currently I'm using a "coming soon" plugin (http://wordpress.org/extend/plugins/underconstruction/) so that any random passer-bys don't see the website looking all weird as I muck around with it trying to make it up. But ideally I'd like to use one of those minimalistic themes, load up a bit of content (about, contact, location, etc pages), then leave that minimalistic theme up for everybody else to view while I (because I'm the only person who can logged in) am just able to see the actual theme as I make modifications to it. Any plugins which do that or other easy ways to do it? Cheers! ==== Update Edit: I just thought I'd leave an update and say I've found a MUCH cooler plugin than underconstruction. It is: "WP Maintenance Mode" (the Lego one is ultra cool! Says this "boy" who grew up on a steady diet of Lego, and yes by diet I mean sometimes the Lego blocks got actually ingested!) http://wordpress.org/extend/plugins/wp-maintenance-mode/ Although it doesn't (hmm... although I could be wrong, perhaps with your own style sheet and excluding a bunch of pages that get linked to from the home then it would get 50% of the way to what I want) do what I asked for in the original question of having multiple pages along with any theme I like (which is different to the one I'm developing and viewing while logged in as Admin), for the purpose of having one single page to let visitors know what is going on it is much superior to UnderConstruction.


How to avoid duplicating same meta_value?

I have "publication_year" as meta_key for some images/attachments. I want to list all meta_values inside html table, but I don't want same publication_year value to repeat, my code is:               <?php $args = array( 'post_type' => 'attachment',                          'post_mime_type' => 'image',                          'numberposts' => -1,                          'orderby' => 'menu_order',                          'order' => ASC                          );     $attachments = get_posts( $args );     echo '
';     if ($attachments) {     foreach ( $attachments as $post ) {         setup_postdata($post);         echo '
';         if ( get_post_meta( $post->ID, '_publication_year', true )) {              echo get_post_meta( $post->ID, '_publication_year', true );             };         echo '	';         echo '';         echo get_the_excerpt();         echo '
';         }     }     echo '
';      and with it I get this:               2002 imageDesc1     2003 imageDesc2     2003 imageDesc3     2003 imageDesc4     2004 imageDesc5      but I want this:               2002 imageDesc1     2003 imageDesc2          imageDesc3          imageDesc4     2004 imageDesc5      So if there are attachments with same _publication years_ , I want them to _group_ and not _repeat_ How can I avoid duplicating same meta_value?


attach several images to post + gallery

i'm wondering if its possible to attach several images to a post then display those images in a thumbnail/fading gallery? By the way, the images should also be resized to a fixed size + thumbnail. thanks


wp_dequeue_script not working for my plugin. I want to remove the themes JS from the dashboard

There is a theme my client is using. It enqueues many scripts in the admin area of wordpress. I'd like to dequeue these so that my plugin works properly. Commenting out this code `wp_enqueue_script( "ocmx-jquery", get_template_directory_uri()."/scripts/ocmx.js", array( "jquery" ) ); ` makes my plugin work properly. So rather than edit their code, I want to add the following to my plugin `wp_dequeue_script( 'ocmx-jquery' );`. I've added that, and it's as if I never did. Is there a better way to tell the theme's JS not to load in my plugins settings page?


List posts that are in the same category as the current post title

How would I call out additional posts that have a tag by that matches the current post's title? For example if the current posts is titled "opossum" I would like teasers from all posts tagged with "opossum" to show at the bottom of the page.


Where to store custom tagging data associated with a custom post type

My application allows users to add tags to an image (similar to facebook). Each tag can consist of up to 8 attributes and there is currently no limit on the amount of tags a user can add. At the moment, tag information is stored across 3 post meta key/value pairs. Each post meta value is serialized before storing. We're approaching a rewrite of this functionality and I wanted to ask for some advice on the best approach to storing tag data. IMO there are two approaches:   1. post meta key/value for each tag/attribute (this has the potential to create a huge dataset - `n` tags times 8 attributes)   2. A new table just for tags Both approaches would avoid storing serialized data, which I think is what I need to achieve. Which is the better approach?   Is a third option possibly even more feasible?


jQuery vs. $ - Creating jQuery scripts in JavaScript in WordPress using External Libraries

I am trying to utilize Trent Richardson's Date Time Picker (see here). I am trying to get the selected time when the popup closes, so I am using the following code (in an external .js file):               jQuery(function()     {         var startDateTextBox = jQuery('#start_date_field');              startDateTextBox.datetimepicker(         {             onClose: function(dateText, inst)             {                 var testStartDate = startDateTextBox.datetimepicker('getDate');                 alert(testStartDate);             }         });     });      However, the alert is coming up saying that the variable is undefined (which also happens when I step through the function). What am I doing wrong? I opened up Trent's source and I noticed that he is using $ in place of jQuery - I saw elsewhere that you should always use jQuery in WordPress in order to put it into 'no conflict mode' - is that accurate? What are the ramifications of using $ instead of jQuery?


Custom post type and custom taxonomy archive inaccessible

I've created some custom post type let say:   * `post_type_1`   * `post_type_2` Those post types are related to each other, every `post_type_1` has parent of many `post_type_2`. Then I created a custom taxonomy for `post_type_2`, let's call it `tax_1`. The following are the code:               function registerPostType1() {       $supports = array(         'title', 'editor', 'thumbnail', 'excerpt',         'comments', 'post-formats'       );       $args = array(         'public' => true,         'hierarchical' => false,         'query_var' => false,         'has_archive' => true,         'rewrite' => array('slug' => 'posttype1'),         'supports' => $supports       );       register_post_type('post_type_1', $args);     }               function registerPostType2() {       $supports = array(         'title', 'editor', 'author', 'thumbnail', 'excerpt',         'comments', 'post-formats'       );       $args = array(         'public' => true,         'hierarchical' => false,         'query_var' => false,         'has_archive' => true,         'rewrite' => array('slug' => 'post-type-2'),         'taxonomies' => array('post_tag'),         'supports' => $supports       );       register_post_type('post_type_2', $args);     }               function registerTax1() {       $args = array(         'hierarchical' => false,         'query_var' => 'tax-1'       );       register_taxonomy('tax-1', 'post_type_2', $args);     }               add_action('init', 'registerPostType2');     add_action('init', 'registerTax1', 0);               function registerPostType1Query() {       add_rewrite_tag('%posttype1%','([^&]+)');     }          function addPostType1QueryVar($query_vars) {       $query_vars[] = 'posttype1';       return $query_vars;     }          function modifyPostType2Query($query) {       if ($query->is_main_query() &&       haveTaxonomyQuery($query, 'tax-1')) {         $query->set('orderby', 'rand'); // Randomly order the posts         $query->set('posts_per_page', 1); // Show only one post              $query->set('meta_key', 'posttype1');         $query->set('meta_value', $query->query_vars['posttype1']);       }     }          function haveTaxonomyQuery($query, $taxToFind) {       if (!property_exists($query, 'tax_query') ||       empty($query->tax_query) ||       !property_exists($query->tax_query, 'queries')) {         return FALSE;       }            foreach ($query->tax_query->queries as $index => $taxQuery) {         if ($taxQuery['taxonomy'] === $taxToFind)           return TRUE;       }       return FALSE;     }               add_action('init', 'registerPostType1Query');     add_filter('query_vars', 'addPostType1QueryVar');     add_action('pre_get_posts', 'modifyPostType2Query');      Now I'm trying to create posts for `post_type_1` in which for each `post_type_1` page they have a link to archive page of `tax-1` (let say `term-1` & `term-2`) in which the page is gonna be used to filter 1 random post under `tax-1` (depends on which term was clicked) and have relationship with that previous `post_type_1` post. So in short it's like relationships between `city` (`post_type_1`), `people` (`post_type_2`) and `gender` (`tax-1`) then with `male` (`term-1`) and `female` (`term-2`). Therefore I have:   * `single-post_type_1.php`   * `single-post_type_2.php`   * `taxonomy-tax-1.php` The following is the code to generate the link to the `taxonomy-tax-1.php` page, it's in `single-post_type_1.php` file:               <a href="<?php echo get_term_link('term-1', 'tax-1') ?>?posttype1=<?php the_ID(); ?>">       <img src="<?php bloginfo('template_url'); ?>/images/term-1.jpg" />           At first the link showed me 404 page, then I refresh the permalink from _Settings_ -> _Permalinks_ and it was working well. However the next day, when I accessed the page again, it showed me the index page instead until I refresh the permalinks again. I also tried installing a rewrite analyzer plugin like **Monkeyman Rewrite Analyzer** and tried comparing the rewrite between each (the working one and the error one which shows me the homepage). The different was the error one showed something like (on the `tax-1` rewrite rule's substitution): > This query variable is not public and will not be saved Does anyone has any idea what I did wrong? It's really annoying to have to refresh the permalinks every single time. Any help would be much appreciated. Thanks in advance.


Add javascript confirmation popup on "Move to Trash" link

I want to open javascript error message when some one clicks on "Move to Trash" link in Publish box in wp-admin


HTML5, WordPress and Tiny MCE issue - wrapping anchor tag around div results in funky output

So I'm using HTML5 on a website and am trying to wrap a div in an anchor tag, which is supposedly acceptable in HTML5 websites. But when I do this...
Some content
      ...through the WordPress Tiny MCE editor, I get this output:

Some content

      All kinds of messed up. If I flip to the visual editor and back to Text in Tiny MCE, it has changed the code to this:
Some content
            Does anyone know how to force Tiny MCE to allow this? (ideally without resorting to the advanced plugin version of Tiny MCE) Thanks for any advice.


WordPress gallery 'post_gallery' filter doesn't work with feeds?

We can use the `post_gallery` filter to modify/replace the default WordPress gallery template (AKA output code) to suit our needs. But this doesn't seem to affect the markup in RSS feeds. No matter what I do, the markup for gallery images in my RSS feed is simply like this:                                                         So, is there a way (something like a filter, function, etc.) to modify the default WordPress gallery markup in RSS feeds? # What I've tried For a start (just to check), all I had to do was comment out this bit in `wp- includes/media.php` core file:               if ( is_feed() ) {         $output = "\n";         foreach ( $attachments as $att_id => $attachment )             $output .= wp_get_attachment_link($att_id, $size, true) . "\n";         return $output;     }      And it kinda worked. Now the gallery markup in my RSS feeds is the same as what you see on the front-end of my site (i.e. in posts). But when I do the same using the `post_gallery` filter, it doesn't work—the markup in RSS feeds is unaffected. I have no idea why! On the whole, this is the code (related to `post_gallery`) in my functions.php. Am I doing something wrong? * * * Since I am frequently asked what I am trying to do—in this case, I want to modify the markup for WordPress galleries in RSS feeds to look like this:

Puppies are cute

Kittens are too


How to add cropped custom header image?

I don't see in my custom theme any option for uploading the header image (although there is a code for it in the header)   Do I need to register it somehow? Also, I have a specific size I want to implement, is it possible to hard-crop the header image on upload? (I want it to be cropped, not resized with CSS) **Solution I found:** I used `custom_header_support`               $custom_header_support = array(         'width' => 260,         'height' => 300,         'header-text' => false,     );          add_theme_support( 'custom-header', $custom_header_support );


disable jscrollpane in specfic div

I installed the library jscrollpane , and its working fine but i need to disable it in the #content that is in frontpage template //               jQuery.noConflict();     jQuery(document).ready(function($) { //tells WP to recognize the $ variable          //paste your jquery code here     $('#content').jScrollPane();          }); //end document ready functions          /* ]]> */     </script>      http://www.integritycorp.org/study/ i just want to disable in frontpage but working on the rest of the theme Thanks


Metaboxes not saving data

I'm rebuilding a metabox for a plugin and it now won't save the data I enter. The HTML is almost exactly the same as before, but the save_meta function just don't work. I've read through quite a few tutorials, checked out tons of questions here on StackExchange and several other sites and tried to identify any easy pitfalls, but none of those seem to be the problem. Could someone check this out and show me what I missed here? Notes: This is all in a class. The array in the time_date_meta function is for another function that returns the HTML. As far as I can tell, this isn't the problem. The HTML field appears correctly and has nearly the same source code as the manually written-out HTML fields I had before. The differences between the hand-written HTML and this function's output are things like the name, class, and id attributes. When I edit a post that already has metadata from before I rewrote this metabox, only the time and location fields show the correct data. I don't have any with the video URL and the date doesn't work at all.               function __construct() {              // Add Seminar time and date meta box         add_action( 'load-post.php', array( $this, 'seminar_create_meta_box' ) );         add_action( 'load-post-new.php', array( $this, 'seminar_create_meta_box' ) );              // Save meta data         add_action( 'save_post', array( $this, 'save_meta' ), 10, 2 );          }          function seminar_create_meta_box() {              add_meta_box( 'cemb_seminar_meta', 'Seminar Info', array ( $this, 'time_date_meta'), 'cemb_seminar', 'side', 'high' );          } // End of seminar_create_meta_box()               function time_date_meta( $post ) {              // Grab data         global $post;              $checks = array( 'date', 'hour', 'minute', 'ampm', 'location' );         $metas  = array();              foreach ( $checks as $check ) {                  $meta_key   = 'cemb_seminar_' . $check;             $meta_value = get_post_meta( $post->ID, $meta_key, true );             $date       = ( $check == 'date' && empty( $meta_value ) ? time() : date( 'D, n/j/Y', strtotime( $meta_value ) ) );             $value      = ( $check == 'date' ? $date : esc_attr( $meta_value ) );             $metas[$check]  = ( !empty( $meta_value ) ? $value : '' );              } // End of $checks foreach              // Get optional video URL         $meta_value         = get_post_meta( $post->ID, 'cemb_seminar_video_url', true );         $metas['videourl']  = ( !empty( $meta_value ) ? esc_url( $meta_value ) : '' );              // Security         wp_nonce_field( basename( __FILE__ ), 'cemb_seminar_nonce' );              // Output         ?>

<?php                       $datepicker_args['class']       = 'seminar_date';                 $datepicker_args['id']          = 'cemb_seminar_date';                 $datepicker_args['label']       = 'Date';                 $datepicker_args['value']       = $metas['date'];                      echo $this->toolkit->date_picker( $datepicker_args ); ?>

<?php                       $time_args['class']                 = 'floatright';                 $time_args['id']                    = 'cemb_seminar_time';                 $time_args['label']                 = 'Time';                      $time_args['hours']['class']        = 'seminar_time';                 $time_args['hours']['id']           = 'cemb_seminar_hour';                 $time_args['hours']['military']     = false;                 $time_args['hours']['value']        = $metas['hour'];                       $time_args['minutes']['class']      = 'seminar_time';                 $time_args['minutes']['id']         = 'cemb_seminar_minute';                 $time_args['minutes']['mintype']    = 'quarters';                 $time_args['minutes']['value']      = $metas['minute'];                       $time_args['ampm']['class']         = 'seminar_time';                 $time_args['ampm']['id']            = 'cemb_seminar_ampm';                 $time_args['ampm']['value']         = $metas['ampm'];                       echo $this->toolkit->time_fields( $time_args ); ?>

<?php                      $input_args['class']        = 'seminar_location';                 $input_args['id']           = 'cemb_seminar_location';                 $input_args['inputtype']    = 'text';                 $input_args['label']        = 'Location';                 $input_args['value']        = $metas['location'];                      echo $this->toolkit->input_field( $input_args ); ?>

<?php                      $input_args['class']        = 'seminar_video';                 $input_args['id']           = 'cemb_seminar_video_url';                 $input_args['inputtype']    = 'text';                 $input_args['label']        = 'Video URL';                 $input_args['value']        = $metas['videourl'];                      echo $this->toolkit->input_field( $input_args ); ?>

 <?php          } // End of seminar_meta_box()          function save_meta( $post_id ) {              if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {                  return $post_id;              } // End of Auto-Save check              if ( $_POST['post_type'] == 'cemb_seminar' ) {                  if ( !current_user_can( 'edit_post', $post_id ) ) {                      return $post_id;                  } elseif ( !current_user_can( 'edit_page', $post_id ) ) {                       return $post_id;                   } // End of capability check              } // End of post_type check              if ( empty( $_POST['cemb_seminar_nonce'] ) && check_admin_referer( basename( __FILE__ ), 'cemb_seminar_nonce' ) ) {                  return $post_id;              } else {                  $checks = array( 'date', 'hour', 'minute', 'ampm', 'location', 'video_url' );                  foreach ( $checks as $check ) {                      $meta_key   = 'cemb_seminar_' . $check;                 $posted     = $_POST[$meta_key];                      if ( empty( $posted ) && $posted != 'cemb_seminar_video_url' ) {                          // Return an error message if any field but video_url is empty                     $msg_args   = array( 'which' => 'empty', 'field' => $meta_key );                     $notices[]  = $this->display_notices( $msg_args );                               return;                      } else {                          if ( $meta_key == 'cemb_seminar_date' ) {                              // Get the posted date and convert it to PHP time                         $new_meta_value = ( isset( $posted ) ? strtotime( $posted ) : '' );                          } else {                              // Get the posted data and sanitize it for use as an HTML class.                         $new_meta_value = ( isset( $posted ) ? sanitize_html_class( $posted ) : '' );                          } // End of $meta_key check                          // Get the meta value of the custom field key.                     $meta_value = get_post_meta( $post_id, $meta_key, true );                          if ( $new_meta_value && $meta_value == '' ) {                              // If a new meta value was added and there was no previous value, add it.                         add_post_meta( $post_id, $meta_key, $new_meta_value, true );                          } elseif ( $new_meta_value && $new_meta_value != $meta_value ) {                              // If the new meta value does not match the old value, update it.                         update_post_meta( $post_id, $meta_key, $new_meta_value );                          } elseif ( $new_meta_value == '' && $meta_value ) {                              // If there is no new meta value but an old value exists, delete it.                         delete_post_meta( $post_id, $meta_key, $meta_value );                          } // End of meta value checks                      } // End of empty check                  } // End of $checks foreach                  $semester_meta = get_post_meta( $post_id, '_semester', true );                  if ( empty( $semester_meta ) ) {                      $semester = $this->determine_semester( $date ) . ' ' . date( 'Y', $date );                      update_post_meta( $post_id, '_semester', $semester );                  } // End of empty check              } // End of nonce check          } // End of save_meta()


adding .current* tags to custom post types and taxonomies

TwentyTen adds some classes to custom menus, for instance: `#access #menu-item-262.current-menu-item, #access #menu-item-262.current- menu-ancestor` All the top-level links in my primary navigation have the class `.current- menu-ancestor` when the user is on a child page -- **except when I'm viewing content in the custom post type I've built**. _**How do I set the current page in navigation when viewing a custom post type?_** Thanks...


Where are Sessions are being started?

I have this site here http://www.taranmarlowjewelry.com/, I am using twentyeleven theme and there is a session I need to adjust called 'PHPSESSID' The problem I having with PHPSESSID is that when you goto my site you will see nothing in the top right corner, you refresh the a shopping cart appears, when I delete PHPSESSID it goes away again. I'm using wp e-commerce plugin


Screen Options Wordpress WYSIWYG

Is there any way to set a checkbox for WYSIWYG box in this options so admin is able to hide it in case there's no need for content in a page


TinyMCE - Show Advanced Options (2nd Row) By Default

So I've customized my tinyMCE a bit to add some buttons and rearrange some things:               function myformatTinyMCE($in)     {         $in['theme_advanced_buttons1']='bold,italic,underline,bullist,numlist,hr,blockquote,link,unlink,justifyleft,justifycenter,justifyright,justifyfull,outdent,indent';         $in['theme_advanced_buttons2']='formatselect,pastetext,pasteword,charmap,undo,redo';         return $in;      }     add_filter('tiny_mce_before_init', 'myformatTinyMCE' );      I thought by not adding `wp_adv` to the end of the first button list, the 2nd row would show by default but this is not the case - I just lose the 2nd row entirely. I want to show the 2nd row - always, without pressing or displaying the `wp_adv` button. How can I show a 2nd row in my TinyMCE by Default?


Contact Form not working !

I have added a new Contact Us page but it's not working and says > **E-mail has not been setup properly. Please add your contact e-mail!** Please help... From where do I can configure it properly? Here is the link **http://designstutorial.com/?page_id=93**


Allowing specific users to only add posts using certain custom taxomy terms

I was searching through the forums, but I can only find slightly related issues. This is my problem: I'd like to assign some editors the capability to only add posts in a predefined term of a custom taxonomy. I have made a taxonomy called events, which holds a list with events that are added by an admin. Certain users are only allowed to add posts using a single event, e.g. "Japan" or "Haiti". Anyone with a hint on how to tackle this? are there user management-plugins that have this kind of capabilities? Regards, Joost.


Stop a specific plugin from executing based on product id in cart

I am trying to stop a specific plugin from executing based on product id in cart. However i can't seem to get it running. There are a few places where i want the plugin to stop inserting its function. (mainly the checkout page, thank you page and email sent to customers) This is what i have done till now. However, it just does not seem to work.               $found = false;     global $woocommerce;     foreach($woocommerce->cart->get_cart() as $cart_item_key => $values ) {         $_product = $values['data'];         if( $_product->id == 1097 ) {             $found = true;         }     }     if ($found){         global $wdt;         remove_action('wp_enqueue_scripts', array($wdt, 'enqueue_scripts'));         remove_filter('woocommerce_checkout_fields', array($wdt, 'checkout_fields'), 20, 1);         remove_action('woocommerce_before_order_notes', array($wdt, 'show_field'), 20);         remove_filter('woocommerce_checkout_fields', array($wdt, 'checkout_fields'), 20, 1);         remove_action( 'woocommerce_checkout_update_order_meta', array( $wdt, 'save_field' ) );         remove_action( 'woocommerce_admin_order_data_after_shipping_address', array( $wdt, 'admin_show_field' ) );         remove_filter( 'woocommerce_locate_template', array( $wdt, 'email_template' ), 10, 3 );     }      Basically what i did was to look at the plugin class and tried to reverse the action and filters added by the class. Hence, you see these remove actions and filter lines. Really appreciate any kind of help over here. Thanks. I cant seem to identify what's wrong with my code. FYI, the first part of the plugin class function is this:               <?php     if ( !class_exists( 'woo_deltime' ) )     {         /**          * This class adds date time picker for delivery when shipping          * Delivery time will be save as a part of order and will be included in emails          */         class woo_deltime         {             /**          * Class constructor          * Add hooks to Woocommerce          */         function __construct()         {             // Enqueue scripts and styles             add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );                  // Show delivery time field before order notes, e.g. after shipping address             add_action( 'woocommerce_before_order_notes', array( $this, 'show_field' ), 20 );                  // Check if delivery time field is required             add_filter( 'woocommerce_checkout_fields', array( $this, 'checkout_fields' ), 20, 1 );                  // Save delivery time into order ( post ) meta             add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'save_field' ) );                  // Show time delivery on order detail page in admin area             add_action( 'woocommerce_admin_order_data_after_shipping_address', array( $this, 'admin_show_field' ) );                  // Change email template to include Delivery Time             add_filter( 'woocommerce_locate_template', array( $this, 'email_template' ), 10, 3 );              }


View content from uploaded file in editor

I have a custom metabox that let's the user upload .csv files while creating a page. The content of the .csv is shown on the created page at the "front-end". I would like to show the content on the admin page in the WYSIWYG-editor so the user can change if necessary. Can anybody tell me how to view the content of a uploaded file? I don't really think the code to the metabox and upload function is necessary but if anybody wants is let me know. M.


Create user assessment and use results in sql query

I am building a plugin that displays custom post types based on a user's assessment result. For that I need the user to fill out a form (not a very complicated one). This form submission needs to save the user's identity as well in order for me to pull it from the database. Is there a plugin that I can use for this assessment or do I need to code my own?


Better way to remove HTML syntax from all content

I have a bunch of articles imported via a very old Joomla 1.0 installation. The content of these posts have a lot of unwanted inline html. I was able to clean all with something like this (I made a template with this inside, then I opened it):               <?php      $tochange = get_posts('post_type=post&numberposts=-1');         foreach ($tochange as $post):         setup_postdata($post);              $changed = array();         $changed['ID'] = $post->ID;         $changed['post_content'] = strip_tags($post->post_content, '');         print_r($post->ID);          echo '
';         $out = wp_update_post($changed);         echo 'changed:'.$out.'
';              unset($changed);          endforeach;     ?>      But it seems a little bloated, considering that makes a loop for _every_ post. Any suggestions?


Wrong url in sortable column headers & pagination in the admin, when behind a proxy

Recently I changed the url of my site from atlas.site.com to site.com, one thing I just came across in the admin area for posts, custom post types, pages, where there are more than one page of posts, the arrows for next, previous, first & last page, are all pointing at atlas.site.com/wp-admin/... I've done a find and replace for atlas in the db, but perhaps I'm not looking in the right place, and it returned 0 results, and WP_SITEURL & WP_HOME in wp- config are both set to http://www.site.com/ The same applies for Title, Author, Date at the top of the columns for sorting. Thanks


How to remove entire admin menu?

I need to customize the admin panel for my user. So how do I remove the entire admin menu? Not remove the menu item, I mean entirely remove the left vertical menu bar, include the design of the menu (eg, css, background..etc). I want it become blank. I can do it by css hack. But I prefer to use hook to do it. Any ideas? Thanks


Change custom post status to draft before today

I tried this code which I made but looks like I am not doing it correctly.. The main problem is my code fetches all posts ordered by meta value date, but I need to hide the posts from the date today (which I am unable to do), so I did this from php strtotime (which is also fine), but the main issue is I need only 5 latest posts... If some one can give a tip to get this code to work it would be great               echo '
';     global $wp_query;     $tDate = strtotime('now');     $query = new WP_Query(          array(             'post_type' => 'event',             'posts_per_page' => 999,             'post_status' => 'publish',             'meta_key'=>'event_date',               'orderby' => 'meta_value',              'order' => ASC         )     );         $count = 0;          while ( $query->have_posts() ) : $query->the_post();         $database_date = get_field('event_date');         if( strtotime($database_date) > strtotime('now') ) {             $count++;             if ($count !="6") {                 echo '
';                 echo '';                 echo '';                 echo '
' . get_the_title() . '

';                 $originalDate = get_field('event_date');                 $newDate = date("l M d", strtotime($originalDate));                 echo $newDate . '

';             }         }     endwhile;          wp_reset_postdata();     echo '
';


Using search.php without a 's' field in searchform.php

Sorry if this is a simple/daft question but I'm still getting to grips with how WordPress search functions. I want to completely replace the standard search within my template with a custom search that only queries a certain custom post type and its meta fields. I have a search form which does this and search.php which returns the correct data. **However** , the search will not function unless I include a input field named 's' and it is not empty. I take it WP needs this to access search.php? I have no need for a search field as my search is based upon custom taxonomies and meta fields. So how can I still use my search without this field? Is this possible?


set permalink for CPT

I have a CPT and two custom taxonomy I registered. I also registered the taxonomy for the CPT. This is my register code:                $args = array(     'labels' => $labels,     'public' => true,     'publicly_queryable' => true,     'show_ui' => true,      'show_in_menu' => true,      'query_var' => true,     'rewrite' => array( 'slug' => 'provider' ),     'capability_type' => 'page',     'has_archive' => false,      'hierarchical' => false,     'menu_position' => null,      'register_meta_box_cb' => 'init_metaboxes_gallery',         'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail', 'excerpt', 'comments' )       );             register_post_type( 'provider', $args );                    $args = array(             'hierarchical'      => true,             'labels'            => $labels,             'show_ui'           => true,             'show_admin_column' => true,             'query_var'         => true,             'rewrite'           => array( 'slug' => 'zone','hierarchical' =>'true' ),         );              register_taxonomy( 'zone', array( 'provider' ), $args );          $args = array(             'hierarchical'      => true,             'labels'            => $labelscat,             'show_ui'           => true,             'show_admin_column' => true,             'query_var'         => true,             'rewrite'           => array( 'slug' => 'procat','hierarchical' =>'true' ),         );              register_taxonomy( 'procat', array( 'provider' ), $args );      Of curse I set labels for each register. I want that the link will be:               www.mysite.com/procat/procat-sub/zone/zone-sub      If there isn't sub for the procat or for the zone it will be without the sub, of course. So I set the sructure of the permalink on admin panel to:               /%procat%/%zone%/%postname%/      but the url is still               www.mysite.com/provider/provider-name


Custom Post Types and Categories?

For the life of me I cannot seem to get categories to come into existence with my custom post type. I've added the following -- simple -- code to the bottom of my theme's `functions.php` file, yet see no categories in my custom post from the admin side.               register_post_type("customy", array(         'label' => 'Customy',         'description' => 'Custom stuff for this site.',         'public' => true,         'hierarchical' => true,         'supports' => array('title', 'editor', 'author', 'thumbnail', 'revisions'),         'taxonomies' => array('category')     ));     register_taxonomy_for_object_type('category', 'customy');


Simple widget causing whitescreen

This widget code is causing my WP site to white screen. I've re-factored the code about 5 times trying to solve it, but no luck.               <?php              class latest_mag_issue_widget extends WP_Widget {                  function latest_mag_issue_widget() {                 $widget_ops = array('classname' => 'widget_latest_issues', 'description' => 'Latest Mag Issues' );                 $this->WP_Widget('latest_issues', 'Latest Issues', $widget_ops);             } //end constructor                  function widget( $args, $instance ) {                 extract( $args );                      // widget options                 $title = apply_filters( 'widget_title', $instance['title'] );                 $pastissues = $instance['pastissues'];                 $thisissue = $instance['thisissue'];                      echo $before_widget;                      echo '
';                      if ( $title ) {                     echo $before_title . $title . $after_title;                 }                      wp_reset_query();                 $wp_query = new WP_Query();                 $wp_query->query(array( 'post_type' => 'mag-issue', 'post_status' => 'publish', 'paged' => 1, 'posts_per_page' => 1));                      if ( have_posts() ) : while ( have_posts() ) : the_post();                      $image_url = get_post_meta($post->ID, 'press_smart', true);                 $image_title = the_title();                 $image_thumbnail = the_post_thumbnail( array(125,166) );                      echo '

Latest Issue
                         ' . $image_thumbnail . '

                     ';                          if ( $thisissue == true) {                           echo '

In This Issue

';                                      for ($i=1; $i < 10; $i++) {                                      $headline_meta = get_post_meta($post->ID , 'headline_' . $i  , true);                                     if ( $headline_meta ) { echo '
' . $headline_meta . '

';}                                 }                                       endwhile; endif; wp_reset_query();                         echo '

                         ';                          }                          if ( $pastissues == true ) {                               $wp_query->query(array( 'post_type' => 'mag-issue', 'post_status' => 'publish', 'paged' => 1, 'posts_per_page' => 9, 'offset' => 1 ));                              if ( have_posts() ) : while ( have_posts() ) : the_post();                              $post_url = get_post_meta( $post->ID, 'press_smart', true );                         $post_title = the_title();                          echo '

Past Issues

                                     ' . $post_title . '
';                              endwhile; endif; wp_reset_query();                              echo '

';                          }                  echo '
';                      echo $after_widget;                        } //end function widget()                  function update( $new_instance, $old_instance ) {                 $instance = $old_instance;                 $instance['title'] = strip_tags( $new_instance['title'] );                 $instance['thisissue'] = strip_tags( $new_instance['thisissue'] );                 $instance['pastissues'] = strip_tags( $new_instance['pastissues'] );                 return $instance;             } //end function update()                       function form($instance) {                      $title = esc_attr( $instance['title'] );                 $thisissue = esc_attr( $instance['thisissue'] );                 $pastissues = esc_attr( $instance['pastissues'] );                      ?>
                     <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title'); ?>                     <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />

                     <input id="<?php echo $this->get_field_id('thisissue'); ?>" name="<?php echo $this->get_field_name('thisissue'); ?>" type="checkbox" value="1" <?php checked( '1', $thisissue ); ?>/>                     <label for="<?php echo $this->get_field_id('thisissue'); ?>"><?php _e('Display headlines?'); ?>

                     <input id="<?php echo $this->get_field_id('pastissues'); ?>" name="<?php echo $this->get_field_name('pastissues'); ?>" type="checkbox" value="1" <?php checked( '1', $pastissues ); ?>/>                     <label for="<?php echo $this->get_field_id('pastissues'); ?>"><?php _e('Display past issues?'); ?>
                      <?php             } //end function form()              }              // Register the widget         add_action( 'widgets_init', 'register_mag_issues_widget' );         function register_mag_issues_widget() {             register_widget( 'latest_mag_issues_widget' );         }          ?>      Thanks, Dom