Restrict a filter to a custom post type. Am I doing this right?

So I had this little bit of code to short a music charts custom post type that all starts with numbers (the trick was to make the 10th position appear last in the list, not between 1 and 2):               add_filter('posts_orderby', 'orderby_post_title_int', 10, 2 );     function orderby_post_title_int( $orderby ) { return '(wp_posts.post_title+0) ASC'; }      This was working well until I discovered that is was also changing every other posts ;-) So I tried wrapping the filter around a conditionnal statement:               if ($post_type == 'chart') {          add_filter('posts_orderby', 'orderby_post_title_int', 10, 2 );     }      Didn't work. Then I decided to go within the function like this :               function orderby_post_title_int( $orderby, $query ) {         if ($query->query_vars['post_type'] == 'chart') {            return '(wp_posts.post_title+0) ASC';         }         return $orderby;       }      And still nothing. At this point, it doesn't change the regular post, but won't change the chart post type either. So I guess my question is: am I in the right direction here? Is it possible to restrict a filter to a specific custom post type? If so, what should I explore as a way to do it? Thank you


List custom taxonomy terms from custom field

I am trying to output a list of terms associated with a custom taxonomy for each image I am pulling from a custom field, like so:               $portfolio_images = get_field('portfolio_gallery');      Each image has standard WP fields associated with it, such as sizes, title, caption, etc. I would like to output the list of terms associated with each image from the `media_category` taxonomy. I am using `get_the_terms` inside another variable but I think something is wrong with my `foreach` statement. Any help would be appreciated. Full code:               <?php          $portfolio_images = get_field('portfolio_gallery');          foreach( $portfolio_images as $portfolio_image ):          $labels = get_the_terms( $portfolio_image['ID'], 'media_category' );     ?>          <li class="gallery-item" data-myorder="<?php  echo $labels;  ?>">          <img src="<?php echo $portfolio_image['sizes']['portfolio-thumbnail']; ?>" alt="<?php echo $portfolio_image['alt']; ?>" />
                 <a class="mask-link" href="<?php echo $portfolio_image['url']; ?>">

<?php echo $portfolio_image['title']; ?>

<?php echo $portfolio_image['caption']; ?>

           <?php  endforeach; ?>


Exclude posts which have any term in a certain taxonomy from the query

I have a custom taxonomy, and for a certain query I am doing, I want to retrieve all posts which **do not** have any terms of that taxonomy assigned (for example, they are _tag-less_ ). At the beginning I thought to do the following:               $tax_slugs = wp_list_pluck( get_terms('my_tax'), 'slug' );     $query_args['tax_query'] = array(         'taxonomy' => 'my_tax',         'terms'    => $tax_slugs,         'field'    => 'slug',         'operator' => 'NOT IN',     );      However, what this does is looking for posts with `my_tax` taxonomy, _excluding_ all of them, which is obviously not ideal. The only other solution I've thought of is by merging two queries, but I'd rather keep the number of queries at a minimum, since this is already a secondary query.


Why doesn't this code add a table to my database?

To get to the point, I'm trying to add a database table upon installation of my plugin. Here's my code:               global $scimp_db_version;     $scimp_db_version = "1.0";          function scimp_install () {          global $wpdb;          $table_name = $wpdb->prefix . "scimp";           $sql = "CREATE TABLE $table_name (             id int NOT NULL AUTO_INCREMENT,             feedurl text NOT NULL,             category text NOT NULL,             );";          require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );     dbDelta( $sql );          add_option("scimp_db_version", $scimp_db_version);          }          register_activation_hook( __FILE__, 'scimp_install' )      Needless to say, this isn't working. The table isn't being created. I'm hoping that there's just something simple that I'm missing after looking at it too long. Can anyone see anything wrong here?


Is there a directory my plugin can write files to that cannot be viewed via the browser/url?

I want to restrict access to some files uploaded via the admin interface but I cannot rely on the ability to use `.htaccess` (could be turned off, or they might be using a non-apache web server). I cannot rely on having access to a folder outside the web root, so is there either a directory protected from viewing in wordpress or some way wordpress enables writing files that cannot be viewed publicly?


One of my posts is displayed as page

I rebuilt a website (I dont know, if the rebuilt has something to do with the problem. It has a whole different database, just the url is the same. the post existed on the old page as well). One of my posts is displayed as a page (I can tell by the class .page). If I change the permalink from /loriotabend to /loriot-abend it works, but /loriotabend is still available and looks odd. This is the post, as it should look: http://www.regensburgerturmtheater.de/loriot-abend/ This post doesn't even exist in the backend: http://www.regensburgerturmtheater.de/loriotabend/ I would not bother, but Google hasn't indexed the site at the moment, so there is still a link, pointing to /loriotabend.


How to get the id from the custom category?

How do i get the ID from the current custom taxonomy (category) the user is browsing? It uses a custom post type called "products" The categories are called "pcategories" With normal categories i would get it like this:               <?php if ( is_category() )       {           $cat= get_category( get_query_var( 'cat' ) );         $cat_id = $cat->cat_ID;         $categorytable = myrp_api_comparison_table( $category = $cat_id, $number = null, $visit_text = "Visit Text", $image_set = null, $custom_fields = null, $rating_categories = null, $return = false );         if(empty($categorytable))         {} else          {                    echo $categorytable;         }      }      ?>      So how would i do this with custom taxonomies? If i do: `<pre><?php print_r($wp_query->query_vars); ?></pre>` I get:               Array     (     [pcategory] => televisies     [error] =>      [m] => 0     [p] => 0     [post_parent] =>      [subpost] =>      [subpost_id] =>      [attachment] =>      [attachment_id] => 0     [name] =>      [static] =>      [pagename] =>      [page_id] => 0     [second] =>      [minute] =>      [hour] =>      [day] => 0     [monthnum] => 0     [year] => 0     [w] => 0     [category_name] =>      [tag] =>      [cat] =>      [tag_id] =>      [author_name] =>      [feed] =>      [tb] =>      [paged] => 0     [comments_popup] =>      [meta_key] =>      [meta_value] =>      [preview] =>      [s] =>      [sentence] =>      [fields] =>      [category__in] => Array         (         )          [category__not_in] => Array         (         )          [category__and] => Array         (         )          [post__in] => Array         (         )          [post__not_in] => Array         (         )          [tag__in] => Array         (         )          [tag__not_in] => Array         (         )          [tag__and] => Array         (         )          [tag_slug__in] => Array         (         )          [tag_slug__and] => Array         (         )          [ignore_sticky_posts] =>      [suppress_filters] =>      [cache_results] => 1     [update_post_term_cache] => 1     [update_post_meta_cache] => 1     [post_type] =>      [posts_per_page] => 10     [nopaging] =>      [comments_per_page] => 50     [no_found_rows] =>      [taxonomy] => pcategory     [term] => televisies     [order] => DESC


cforms plugin function "my_cforms_logic" (for writing custom logic), is running 5 times

I'm using cforms plugin, which provides a way for writing custom functions for the form action handler page, using the file my-functions.php and the function my_cforms_logic(. The issue is that whenever I submit the form, the function works well but it runs for 5 times. For example, if i write a statement in the function such as, echo "A"; then in the output I see, "AAAAA".


wordpress multisite domain mapping redirects to original subdomain

This week I installed Wordpress 3.4.2 (Linux Centos + Apache2) and configured the network option using subdomains. Then I installed the MU Domain Mapping plugin, so I would be able to use it with domain names instead of subdomains. This works for one domain, however the second domain redirects to the subdomain.   * base site: multisites.com   * two subsites: one.multisites.com and two.multisites.com   * two new domains: one.de and two.com.de   * one.de works correct (based on one.multisites.com)   * two.com.de redirects to two.multisites.com      * NB: two.com.de is a subdomain of com.de, and this is similar to the actual situation!  Two.com.de should not redirect. I don't see any differences in the setup. What could cause this and do you experience problems like this as well? * * * NB: I changed the domain names in the example to make it more clear.


Adding a Variable Product in WooCommerce Programatically

How do I make it a variable product and add variations? Are variations handled like attributes? this code creates a product and adds an attribute(XL size) but i cannot make that attribute used as a variation, width a custom price(etc). this is a function called via ajax               function createnewproduct(){     $new_post = array(         'post_title' => "Custom Variable",         'post_content' => 'Lorem ipsum dolor sit amet...',         'post_status' => 'publish',         'post_type' => 'product'     );          $skuu = randomsku('csm','custom',6);     $post_id = wp_insert_post($new_post);     update_post_meta($post_id, '_sku', $skuu );     update_post_meta( $post_id, '_price', "25" );          //made it variable but variations wont be added!     wp_set_object_terms ($post_id, 'variable', 'product_type');     wp_set_object_terms( $post_id, 'XL', 'pa_size' );     //everything works well but     //how do i make the "pa_size" attribure a variation?          update_post_meta( $post_id, '_visibility', 'search' );     update_post_meta( $post_id, '_stock_status', 'instock');          }      this function declares in woocommerce that the new product added is a variable product and adds a "size" attribute . The problem is how we tell woocommerce that "size" attribute is a variation.


Can't Output get_post_meta?

I have a custom field for my post and I am trying to output it onto my post's page but nothing appears. I know my code works otherwise if instead of trying to call my custom field, I use a fixed string. My custom field key has an id of               _dad_wysiwyg      I am using this to try to display the value of the key from within functions.php:               add_action( '__after_content' , 'add_dad_cents' );     function add_dad_cents() {         echo get_post_meta($post->ID, '_dad_wysiwyg', true);     }      I know the key has a value by looking at my postmeta table in my database. The value of the key is
test
      Logically, after my post content, I'd expect to see the above string but nothing appears. As I stated, if I change my function to echo a string, I see the string where expected after my post content. edit: It appears $post is empty. Clearly, I need help calling the post ID from functions.php... Can anyone help me figure out how to call the value? Thanks!


Function to delete a term when a custom post with the same slug is trashed

I have a function that whenever i add a new post in the custom post type "artists" it adds a new term with the same name in the custom taxonomy "artists".               function add_artist_category_automatically($post_ID) {     global $wpdb;     if(!has_term('','byartist',$post_ID)){         $cat = get_the_title($post_ID);         wp_set_object_terms($post_ID, $cat, 'byartist');         wp_set_object_terms($post_ID, NULL, 'byartist' );     }     }     add_action('publish_artists', 'add_artist_category_automatically');      Now i want a function that whenever i trash a post from the "artists" custom post to delete the term with the same slug that was created with the auto add function. I haven't managed to make this work:               function delete_artist_term_automatically($post_ID) {     global $wpdb;         $catigoria = get_the_title($post_ID);         $theterm = term_exists($catigoria, 'byartist');         wp_delete_term($theterm->term_id, 'byartist');     }     add_action('trashed_artists', 'delete_artist_term_automatically');      **UPDATE:** I use get_term_by slug now after getting the post_name and not title. But it doesn't seem to work too. I'm not sure if that's the right way to get the term_id. I also removed $wpdb.               function delete_artist_term_automatically($post_ID) {         $cat = get_post($post_ID);         $termslug = $cat->post_name;         $theterm = get_term_by('slug', $termslug, 'byartist');         wp_delete_term($theterm->term_id, 'byartist');     }     add_action('deleted_artists', 'delete_artist_term_automatically');


Custom pages on all multisite network, to NOT show in wp-admin at all

I have a Wordpress Multisite that I would like to create additional pages for all of the sites in my network. These pages will not show up in the list of pages that are editable by the site admin in their wp-admin area, but instead will be static pages using css that is not the same as the theme of the actual site itself. They will not have access to the traditional Wordpress admin, and will only get the information from these pages as a custom admin panel. My question is, how do I create a plugin that generates these pages that do not exist inside the traditional page flow and are hard coded to always exist on every one of the sites.


Email setting in wordpress

I have a WordPress website that works perfect without any problem, In the front end i have a contact page with a contact form, when i set the receiving email to any email using ( Googole, Yahoo, or Hotmail) the email arrives to the destination without any problem , but when emails send to (example@company.com) no email received. What to change or configure in my website since this is the first time to face a problem like this.


Problem with ajax plugin for refreshing posts

Im using a cool plugin called "wp ajax random posts". It basically lets me call a function into a template that can auto refresh a loop of posts. It works great until I tried to change the loop structure inside the function. My posts have embedded youtube videos so I set it up so the section was only calling the video and its ratings. Originally it was just for a title and that worked fine but when I added the video it returns a second post under the original that was suppose to dissapear. From there it refreshes the bottom video like normal which boggles my mind. Here's the original function and then the modified one. Can someone point out why this is happening?               function WARP_Random_posts($args=''){     $defargs=array('number' => 8, 'cmtcount' => 0, 'excerpt' => 0, 'length' => 100, 'auto' => 0, 'time' => 60);     $args = wp_parse_args($args, $defargs);$output='';$number=$args['number'];     query_posts("showposts=$number&orderby=rand&cat=3");     if(have_posts()){         while (have_posts()) :the_post();             $output.='

'.get_the_title().'';             if($args['cmtcount']!=0)$output.='('.get_comments_number().')';             $output.='
';             if($args['excerpt']!=0)$output.='
'.WARP_Random_posts_substr(strip_tags(get_the_content()),(int)$args['length']).'
';;             $output.='
';         endwhile;         $output.='

'.__('Refresh', 'WP-Ajax-Random-Posts').''.($args['auto']?': '.$args['time'].'':'').'

';         return $output;     }else{         WARP__showErr(__('There is no post.','WP-Ajax-Random-Posts'));     }     }      modified...               function WARP_Random_posts($args=''){         $defargs=array('number' => 8, 'cmtcount' => 0, 'excerpt' => 0, 'length' => 100, 'auto' => 0, 'time' => 60);         $args = wp_parse_args($args, $defargs);$output='';$number=$args['number'];         query_posts("showposts=$number&orderby=rand&cat=3");         if(have_posts()){         while (have_posts()) :the_post();              $name = get_post_meta(get_the_ID(),'video_code',true);              youtube_video_embed( $name, 'autoplay=on&width=640&height=376' );              if(function_exists('the_ratings')) { the_ratings(); };              if($args['cmtcount']!=0)$output.='('.get_comments_number().')';              $output.='
';          if($args['excerpt']!=0)$output.='
'.WARP_Random_posts_substr(strip_tags(get_the_content()),(int)$args['length']).'
';;              $output.='
';              endwhile;              $output.='

'.__('Refresh', 'WP-Ajax-Random-Posts').''.($args['auto']?': '.$args['time'].'':'').'

';              return $output;              }else{              WARP__showErr(__('There is no post.','WP-Ajax-Random-Posts'));            }           }


Can't seem to do combined query AND sort?

Below is the code I'm using to query multi-day events. The problem I'm having is that I can either sort by the start date (evstart_date) OR I can do a combined query against start date and end date (evend_date). But I cannot do both the combined query AND sort. The code below gets the query right (continues to display multi-day events that started in the past but have not yet ended), but the sort is broken (reverts to default sort by post date). I've tried several variations, but have been unable to find a solution.               <?php         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $today = date('Y-m-d', strtotime('-6 hours'));         $upcomingevents = new WP_Query(array(             'post_type' => 'events',              'posts_per_page' => 6,               'paged' => $paged,             'meta_query'=>array(             'relation'=>'OR',                 array(                     'key' => 'evstart_date',                     'value' => $today,                     'compare' => '>=',                     'type' => 'CHAR'                     ),                 array(                     'key' => 'evend_date',                     'value' => $today,                     'compare' => '>=',                     'type' => 'CHAR'                     )                  ),             'meta_key' => 'evstart_date',             'orderby' => 'meta_value',             'order' => 'ASC'         ));      ?>


How to use Jeditable plugin with admin-ajax.php?

Jeditable is saving data to the file like:               $('.edit_area').editable('http://www.example.com/save.php', {               type      : 'textarea',              cancel    : 'Cancel',              submit    : 'OK',              indicator : '<img src="img/indicator.gif">',              tooltip   : 'Click to edit...'          });`      How do I replace JQuery.ajax with admin-ajax.php? Do I just replace http://www.example.com/save.php to admin_url('admin-ajax.php')?


How to force users to nest their comments

I am trying to figure out how to force commenters to use threaded comments (and not the general comment box at the bottom of the post) on one particular post. I want only admins to be able to post new top-level comments and to force all other users to click the Reply button under the comment to which they are responding. I've tried using CSS to hide the comment box or to accentuate the Reply link, but it's not working. and it's a terrible hack anyway. I'm using WordPress 3.8.1, and unfortunately don't have the ability to add plug-ins due to being on @%^&%#^$@# managed hosting. Thanks for any tips or tricks.


Custom post type not displaying all entries

This is using a custom post type that I've set up in the functions.php file. What I was hoping to get some advice one was why I have 14 entries in my custom "SPEAKERS" post type but only have 10 showing on my page? What might be limiting it? This is what I put in my functions.php page               // Creates Speakers post type     register_post_type('speakers', array(     'label' => 'Speakers',     'public' => true,     'show_ui' => true,     'capability_type' => 'post',     'hierarchical' => false,     'rewrite' => array('slug' => 'speakers'),     'query_var' => true,     'supports' => array(     'title',     'editor',     'excerpt',     'trackbacks',     'custom-fields',     'comments',     'revisions',     'thumbnail',     'author',     'page-attributes',)     ) );      This is a screenshot of all 14 of my speakers, but when you go to my speakers page you only see 10. ![enter image description here](http://i.stack.imgur.com/xRtDN.png) Any advice is appreciated!


Disable media library tab for non admins in uploader screen

I am developing a plugin in which i am required to allow front end users to upload media, which I am able to do. But I don't want to let them sneak into media library which comes as tab with uploader screen. I tried the following               function remove_medialibrary_tab($tabs) {         if ( !current_user_can( 'administrator' ) ) {             unset($tabs['library']);             return $tabs;         }         else         {             return $tabs;         }     }     add_filter('media_upload_tabs','remove_medialibrary_tab');      But seems this filter is deprecated and doesn't works anymore.


Why Does Automattic use SVN for WordPress Instead of Git?

I use Git on my development and I find it to be reliable so I wonder what is the reason Automattic choose to use SVN for WordPress?


Adding Language Support using .pot and .mo files to a WordPress Theme?

How do we add language support using .pot and .mo files in a WordPress theme? And how we retrieve the theme?


Show add_meta_box by selecting a specific category

In my plugin I want to display an add_meta_box under the WYSISWYG in the new post page, which is no problem and works fine. But the box should only appear when a specific category (example: category with id = 5) is selected, otherwise it is not visible. How can this be achieved? Edit as requested in the comments here is my jquery:               $script = "                 <script type='text/javascript'>                     jQuery(document).ready(function($) {                         $('#metabox_sectionid').hide();                         $('#in-category-".CATEGORY."').is(':checked') ? $('#metabox_sectionid').show() : $('#emetabox_sectionid').hide();                         $('#in-category-".CATEGORY."').click(function() {                             $('#metabox_sectionid').toggle(this.checked);                         });                     });                 </script>";             echo $script;      BR & Thanks, mybecks


How can I use a logo in the header?

I'm trying to set up a new site, using the Hemingway theme. I want to add a logo to the header. The theme editor wants me to use the admin panel to upload the logo. There are two problems with this. First, that method is bound to fail, because of course WordPress doesn't have write access to the filesystem and I'm not about to grant it such access. Second, the normal way to post such things on a website is to upload the relevant files to the server in the proper location and link to them. But where does the logo go? In my theme, the logo is placed by the following code:               <?php if ( get_theme_mod( 'hemingway_logo' ) ) : ?>
            <a href='<?php echo esc_url( home_url( '/' ) ); ?>' title='<?php echo esc_attr( get_bloginfo( 'title' ) ); ?> — <?php echo esc_attr( get_bloginfo( 'description' ) ); ?>' rel='home'>       <img src='<?php echo esc_url( get_theme_mod( 'hemingway_logo' ) ); ?>' alt='<?php echo esc_attr( get_bloginfo( 'title' ) ); ?>'>
       The way I see it, I have two options:   1. Modify the code and hard code my logo here. The problem here is that the more I modify the code, the more maintainability issues I can expect to encounter.   2. Figure out where this code expects a logo. It appears that the function `get_theme_mod` is the key, but when I looked up its definition, it appears that there's quite a tangle of code to follow (and I've never heard of an interactive debugger for PHP). Of these options, I think that number 2 is quite preferable, but I don't understand the code sufficiently to do it. What recommendest thou?


Tutorials for Unit-Testing in WordPress and for unit-test.svn.wordpress.org?

I'm starting to learn Selenium and PHPUnit and I am interested in implementing what I've learned in my WordPress projects. I've seen http://unit- test.svn.wordpress.org and wonder if there are any tutorials or core- developer's notes on how to use it?


Anyone know a php snippet for showing the first 200 characters of the most recent post?

I wish I knew PHP as well as I do Rails. I'd imagine this is fairly intuitive. Thanks!


custom post type or taxonomy

I'm working on a real-estate site where I need to create a profile for each **agent** , the initial view when you click on **view agents** would be to list them alphabetically, ideally from a dropdown you could select a **region** to view all the **agents** from that **region** , or chose a **language** to view all the **agents** who speak a given **language**. My thinking is **Agent** would be a custom post type, **region** and **language** would be a taxonomy. The listing of **agents** would then be created by showing many posts, just only showing limited details, then when clicked act as a single post, with more details shown? Does this seem like the best way to go about this? Thanks


check first and last child pages wordpress

I have an index/parent page and there are few sub/chlid pages in Wordpress. How to check which sub page is the first child, and which is last child? Thanks a lot!


Why does get_term() require taxonomy? Are term_ids not unique?

A related WPSE question asks how to get the term by specifying ID only, without specifying taxonomy. My question is more philosophical. Generally, stuff in WP core is there for a reason. I'm trying to understand why term_id can't be the primary key for the term - why do we need the taxonomy as well? Can a single term record be a member of multiple taxonomies? That's certainly not currently supported in the API. Is there a use case where this might be desirable? Or is the required `$taxonomy` parameter in `get_term()` a vestigial tail from an earlier incarnation of the database structure?


Two Navigation Menus in Themes Produce the same menus?

Alright so I've got two navigation menus that I've registered with my theme:               <?php          if ( function_exists('register_sidebar') )         register_sidebar();          add_theme_support( 'menus' );          if ( function_exists('register_nav_menu') ) {         register_nav_menu( 'primary_nav', 'Primary Navigation');         register_nav_menu( 'secondary_nav', 'Secondary Navigation');     }          ?>      ## **Functions.php**       And then Beyond that I've got two places in my header where I display the navigation menus:                               <!-- BEGIN: Navigation Menu primary_nav (Primary Navigation) -->                     <?php                       if(function_exists('wp_nav_menu'))                       {                         wp_nav_menu(                             array(                                 'menu' => 'primary_nav',                                 'container' => '',                                 'depth' => 1,                                 'menu_id' => 'menu'                             )                         );                       }                       else                        {                     ?>                        <ul>                         <?php wp_list_pages('title_li=&depth=1'); ?>                        </ul>                     <?php                       }                     ?>                     <!-- END: Navigation Menu primary_nav (Primary Navigation) -->                 </div>      **header.php** - Location 1                       <!-- BEGIN: Secondary Navigation Menu -->             <?php                    if(function_exists('wp_nav_menu')) {                     wp_nav_menu(                         array(                             'menu' => 'secondary_nav',                             'container' => '',                             'depth' => 1,                             'menu_id' => 'secondary_nav_id'                         )                     );                   }                   else {             ?>                      <ul>                     <?php wp_list_pages('title_li=&depth=1'); ?>                 </ul>             <?php                   }             ?>             <!-- END: Secondary Navigation Menu -->      **header.php** - Location 2 In the admin page for the theme everything shows up just fine, both menus appear in the list both Primary Navigation and Secondary Navigation. And from the admin screen I've added two distinct sets of menu items. However, whenever I load up my theme, for some reason I end up with only the menus from the Primary Navigation appearing twice. Is there something I've forgotten that would cause this behavior?


Problem with special character WordPress

I have a WordPress and everything seems perfectly fine but I have this page that has title 77% and it shows error 404 page. How can I fix this? I am kind of sure it is because of the % in the 77%. The permalink uses the 77 but for some reason wordpress still doesn't like that % in the title. What can I do to fix this while keeping the % there?


front end editing using iFrames, best approach?

I was going to give users back end access to edit entries but don't like the idea of them having access to the back end. I currently am using/developing with Adminize and Role Scooper and have set up custom editing screens for the users. Users will have access to a custom post type for their user profile and to a single custom post type for their company profile page. My site is a directory of companies. What I would like to have is the ability to load in the custom editing pages from the back end into iFrames on the front end via an edit menu on the custom post page. I assume I will need to use AJAX in some form or another. I have looked at a few front end editing plugins but they seem to all fall short f what I need/am looking for.   1. Is it possible to load in the back end editing pages into iFrames?   2. Can I save the edits and reload the front end page simultaneously? I think I can but unsure of how to approach it.   3. Is there a better way of accomplishing this? Thanks for any insights and suggestion you may have!


wp_list_table multiple checkboxes

I have a custom class which extends wp_list_table and show list of posts with two checkboxes in each row (one which have post ID as value for determining which posts are to be processed and other to determine should image be included for specific post). I have two functions for this                function column_cb($item){         return sprintf(             '<input type="checkbox" name="%1$s[]" value="%2$s" />',             /*$1%s*/ $this->_args['singular'],              /*$2%s*/ $item['ID']                        );     }          function column_image($item){         return sprintf(             '<input type="checkbox" name="%1$s[]" value="%2$s" />',              /*$1%s*/ $this->_args['singular'],              /*$2%s*/ 'yes'           );     }         This would produce array like (ie if three posts are selected and two checkboxes for images selected)               [post] => Array (                [0] => 6238                [1] => 6230                [2] => yes                [3] => 6224                [4] => yes              )       But what I would like to get is something like (be it numeric or associative array)               [post] => Array           ( [0] => Array ([0] => 6238 [1] => yes)            [1] => Array ([0] => 6230 [1] => '')            [2] => Array ([0] => 6224 [1] => yes)          )      How can I achieve this (and what if at some point I want include one more checkbox)?


Stomping WP_Query in author archive to facilitate pagination with custom queries

I am using `get_posts` and `get_comments` to build several loops on the page, at which I am having some issues in pagination. I have the global posts per page option **(Settings > Reading)** set to **10** , and this seems to vary the problem. As of now, I can easily get to **Page 2** - http://dev.ashfame.com/author/ashfame/page/2/, but **Page 3** returns a **404**. If I lower the global value, I get to have more paginated pages but not all (lesser number than how many there should be). **Update:** I just tried setting my custom setting as 2 (and the global one too), and WordPress should paginate until **page 4** (I have **7** items to show) but now it does but also **page 5 & 6. 7** gives **404**. Why? How do I troubleshoot this thing now? **Progress:** @t31os helped me figure out that its the WP default query on the page which is setting up the pagination for that page. Now I can think of one way to kill the default WP query on that page (but how?) and then how would I further paginate the **author.php** page? Or is there any other way of doing it? **Current code:**               <?php                      $author_details = $wp_query->get_queried_object();                      // Posts Per Page option                 // $ppp = get_option('posts_per_page');                 $ppp = 1; //custom setting, if you want to obey the global setting here, comment this line and uncomment the above line                      if (!is_paged()) {                     $custom_offset = 0;                 } else {                     $custom_offset = $ppp*($paged-1);                 }                      echo '
Author ID : '.$author_details->ID.', Page : '.$paged.', Custom Offset : '.$custom_offset.'
';                      ?>
Articles
                      <?php                 $args = array(                 'numberposts' => $ppp,                 'offset' => $custom_offset,                 'category' => 7,                 'author' => $author_details->ID                 );                      $posts_data = get_posts( $args );                      // print_r($posts_data);                      if ( count( $posts_data ) > 0 ) {                                    echo '
';                                     foreach ( $posts_data as $post ) {                                               echo '
ID ).'">'.$post->post_title.'
';                     }                                    echo '
';                 } else {                     echo '
No articles by this user
';                 }                            ?>
Journals
                      <?php                 $args = array(                 'numberposts' => $ppp,                 'offset' => $custom_offset,                 'category' => 6,                 'author' => $author_details->ID                 );                 $posts_data = get_posts( $args );                      // print_r($posts_data);                      if ( count( $posts_data ) > 0 ) {                                    echo '
';                                     foreach ( $posts_data as $post ) {                                               echo '
ID ).'">'.$post->post_title.'
';                     }                                    echo '
';                 } else {                     echo '
No journals by this user
';                 }                 ?>
Questions
                      <?php                 $args = array(                 'numberposts' => $ppp,                 'offset' => $custom_offset,                 'category' => 3, // parent category ID is enough                 'author' => $author_details->ID                 );                 $posts_data = get_posts( $args );                      // print_r($posts_data);                      if ( count( $posts_data ) > 0 ) {                                    echo '
';                                     foreach ( $posts_data as $post ) {                                               $category_array = get_the_category( $post->ID );                         $category_name = $category_array[0]->name;                         $category_permalink = get_category_link( $category_array[0]->term_id );                         echo '
ID ).'">'.$post->post_title.'
In: '.$category_name.'
'.get_comments_number( $post->ID ).' Answers
';                     }                                    echo '
';                 } else {                     echo '
No questions by this user
';                 }                 ?>
Answers
                      <?php                 $args = array(                 'user_id' => $author_details->ID,                 'number' => $ppp,                 'offset' => $custom_offset,                 'status' => 'approve'                 );                 $answers_list = get_comments( $args );                      // print_r($answers_list);                      if ( count( $answers_list ) > 0 ) {                     $date_format = get_option( 'date_format' );                     echo '
';                     foreach ( $answers_list as $answer ) {                         echo '
Answer: '.substr( $answer->comment_content, 0, 20 ).'..
'.date( $date_format, strtotime( $answer->comment_date ) ).'
Question: comment_post_ID ).'">'.get_the_title( $answer->comment_post_ID ).'
';                     }                     echo '
';                 } else {                     echo '
No answers by this user
';                 }                 ?>


Why are only inactive plugins showing?

Pretty much sums it up. On the plugin page, only the inactive plugins show.


Redirect outside WP after login

I have `http://example.com/admin.php` There I check whether the user is admin or not. If not, I send the user to the wp-login page like this:               blog.mysite.com/wp-login.php?redirect_to=http%3A%2F%2Fmysite.com/admin.php      I expect redirect back for admin.php but WordPress always sends me to `wp- admin` control panel. After researching, I found that when the destination host is not in filter `allowed_redirect_hosts`, WP just redirects the user to `wp-admin`. How can I add more hosts to the filter? If I put this example from the WP Codex in `functions.php`, it stops working.               add_filter( 'allowed_redirect_hosts' , 'my_allowed_redirect_hosts' , 10 );     function my_allowed_redirect_hosts($content){         $content[] = 'blog.example.com';         $content[] = 'codex.example.com';         // wrong: $content[] = 'http://codex.example.com';         return $content;     }


Admin area error because of theme?

I'm working on a new theme system. In the `functions.php` I include the `wp- config.php` file.               // Include the config file     require ('wp-config.php');      It works fine on the front end of the site, but in the admin area it loads an error. Should I just switch the require to include? Or is it something to be concerned about?


Format the output of List category posts plugin

I wanted to have the first few lines (say 5 lines) of individual user posts with a particular tag to appear along with their featured image on a particular page. My search for a plugin to do the same took me to your plugin "List category posts" and found that it does things I want but not in a very formatted and exact manner i want.   1. Though the lines in the posts are separate, the plugin shows everything in single continues line. Is there a way to display the first few lines from the post as it is? i.e with out combining them into a single line?   2. Is there a way to adjust position of the featured image displayed by List category posts? I use thumbnail=yes to get the pic. I want the pic to be on the left and the text parallel to the right edge of the photo.   3. Is there a way to hide displaying the name of the post?   4. Is there a way to specify the first 'n' lines should be displayed?


Woocommerce Subscriptions - Customer change subscribed product after placed

Im using Woocommerce, and the Woo Commerce Subscriptions plugin, along with a bunch of others - creating a members only / subscription based ecommerce site. The best way to highlight what I'm trying to accomplish is this... Customer comes to our site and orders **_Time Magazine_** for 12 months. We want to be able to allow our customers, 2 months down the road in their subscription to say "Hey, **_Time Magazine_** isn't working out for me, log into their account, and simply select the order, click maybe a drop-down and select **_Seventeen Magazine_**. This would then obviously change on the admin end, and we would ship them their new choice without fail. It shouldn't be complicated, as all of our products are the same cost, and not even worried about inventory at this point - just that our customer has the ability to change what they are getting on a monthly basis. Anyone have an idea of how to approach this correctly, as far as which template to modify - and an idea of how to go about it? I'd love to just add a widget in the Account Management area of Woo that shows which product they are getting, and let them change it there.. but at this point I'll take anything! Thanks in advance folks!


page 1 is not paged

I have rules that only work on paginated pages (is_paged). However, they don't work on page number one (/page/1). This one is behaving exactly like the homepage (!is_paged), but unlike pages 2,3,4 etc. I want to prevent page 1 from behaving like the homepage and have it behave just like any other page.               if (strpos($url,'/page/1') || is_paged()) {include 'paged.php'; } // this is to load a different template for paged results     if (is_home() && !is_paged() && !$paged = 1) echo 'good'; else echo 'bad'; // this is what i want to do inside the page and cannot. It returns 'good' on both homepage and page 1     if (is_home() && !is_paged() && !strpos($url,'/page/1')) echo 'good'; else echo 'bad'; // this returns 'bad' on both     if (is_home() && !is_paged()) echo 'good'; else echo 'bad'; //this returns 'bad' on both


Images showing up in editor but don't show up in front end

The images showing up on the front and post sections (under the fold) aren't featured images, but the first images in the post. The pictures show up in the back end, but are supposed to appear in the post itself in the front end and don't. Are there any things I should look for to solve this? I've already checked plugins and cleared cache. (Latest wordpress update) http://www.epmchannel.com/


Managing event dates vs published dates in admin custom post type

I have a custom post type which uses dates and i have my custom columns set up in the admin. I need to be able to do order by that column by default - i have tried this code which I found on the net but after playing with it for an hour i still couldn't make it work and it only seemed to want to sort by title; can anyone help me. https://www.facebook.com/note.php?note_id=147785468608658


how to log in to WP if the "Log in" link under Meta is missing

Help Please: somehow I have stuffed up my WP site, now when I put in my URL and bring up my site there is no Meta (word) or "log in link" option so I can access my "dashboard", so i cannot get into the back end of my site, can someone please help with directions as to how I can fix this. Cheers Cheryl


Advice for a voting / multiple rating plugin for post types other than GD Star Rating

I would like to let users of one of my WP projects to cast votes on certain post types; the type of votes cast should differ slightly according to post type. For example for one post type they might vote for things like "money value", "quality", "comfort" (imagine a hotel...) for other things they might cast votes for things like "is the article interesting?" or "helpful". For other post types there wouldn't be polls at all. And so on. I need to show average ratings in a widget and perhaps the user individual rating to be displayed along his comment (users should be registered and, on certain post types at least, post rating contextually to comment, which would function as user review as well). It would be nice if I can make it work also for BBPress plugin, since technically forum posts are custom post types, therefore users might rate forum threads for being "interesting" or "useful" for example. I've found GD Star Rating plugin, but it seems to me a bit overcomplicated, documentation is a bit obscure (I guess it's for paid support only, but I want to be sure if it's what I really need before subscribing a license). On the other hand there's no built in support for post types, which is scheduled for release 2.0. Is there any simple alternative? Doesn't matter if it's a free or commercial plugin, as long as it's straightforward to use and provides support for what I'd like to achieve. Thank you!


Message on Custom Posts Type admin page

Is there any way that I can add a short message to the custom posts type page in - ie the page where the posts are listed. I have checked the codex and searched the web to no avail.


Control Loop Within Loop

I am attempting to control a loop I have within a loop. What I would like to do is display all post and have a custom post type inserted every 3 post. So it would be like this "post post post CPT post post post cpt..." I accomplished this by doing this               global $loop_counter;     $loop_counter = 0;     if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>     ?>          // DO STUFF          <?php $loop_counter++; ?>          if ( $loop_counter%3 == 0 ) {          $args = array(             'post_type' => 'testimony',         );         $testimony = new WP_Query($args);         if ( $testimony->have_posts() ) {             while ( $testimony ->have_posts() ) {                 $testimony->the_post();                 ?>                      //LOOP WITHIN LOOP                  } }          } END loop count if      ?> I slimmed down the code a bit but this should be enough. Now this is working like I want with one issue. The inner loop keeps repeating as long as the main loop has posts. I want the stop looping through the inner loop as soon as we are out of posts to display. Any help would be appreciated.


How to store custom user data on the database?

I'm developing a WP multi-site network which have a goal of 10,000 sub blogs. The site needs to store custom data related to the user. There are additional 20 fields of data for each user. What is the best way to store data in the WP?   1. Store in a custom table   2. Store in user meta table I'm using a dedicated server for the database. The specs are 16GB RAM - Intel(R) Xeon(R) CPU X3430 @ 2.40GHz Store data in the User Meta table will affect to my site's performance? Thanks


Override widget in function WordPress

Im trying to override the text widget in WordPress. My code looks like this:               class WP_Widget_Text_Custom extends WP_Widget {              function __construct() {             $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML'));             $control_ops = array('width' => 400, 'height' => 350);             parent::__construct('text', __('Text'), $widget_ops, $control_ops);         }              function WP_Widget_Calendar( $args, $instance ) {             extract($args);             $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );             $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );             echo $before_widget;             if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
<?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?>
             <?php             echo $after_widget;         }              function update( $new_instance, $old_instance ) {             $instance = $old_instance;             $instance['title'] = strip_tags($new_instance['title']);             if ( current_user_can('unfiltered_html') )                 $instance['text'] =  $new_instance['text'];             else                 $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed             $instance['filter'] = isset($new_instance['filter']);             return $instance;         }              function form( $instance ) {             $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );             $title = strip_tags($instance['title']);             $text = esc_textarea($instance['text']);     ?>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('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 esc_attr($title); ?>" />
                  <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
<input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?>
     <?php         }     }          function custom_register_widgets() {         register_widget( 'WP_Widget_Text_Custom' );     }          add_action( 'widgets_init', 'custom_register_widgets' );      I'm getting the following error message: > *function WP_Widget::widget() must be over-ridden in a sub-class.* I have copied the `WP_Widget_Text` from `default-widgets.php` to `functions.php` and added `_Custom` in class name. Why am I getting this error and how do I fix it?


WordPress MU and nested sites addresses?

I'm creating my first path-based WordPress Multisite Network. Right now it runs a few blogs, such as:               www.mymaindomain.com     www.mymaindomain.com/blog1     www.mymaindomain.com/blog2     www.mymaindomain.com/blog3      I'm wondering is it possible to change my blogs URLs to something like:               www.mymaindomain.com     www.mymaindomain.com/directory/blog1     www.mymaindomain.com/directory/blog2     www.mymaindomain.com/directory/blog3      It's quite tricky to achieve with .htaccess as I have absolutely no idea how to tell the difference between sites such as `www.mymaindomain.com/blog1` and pages like `www.mymaindomain.com/contactpage`. Any ideas?


disbale default widgets on theme activation

I want to deactivate all default widgets on theme activation which are active by default for new WordPress installation. I'm using following function as callback for theme activation :               if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ) {         //      }      By default activated widgets are :   1. Search    2. Recent Posts    3. Recent Comments   4. Archives   5. Categories   6. Meta I don't want to deregister them permanently but hide from the sidebar. Is that possible ??


Get a list of galleries from an album in NextGEN Gallery

I want to get a list of galleries of a certain album. Than I would create a link to this galleries. How do I get the list of galleries in PHP? I saw that there is some code like               global $nggdb;     $gallery = $nggdb->get_gallery ($galleryID, 'sortorder', 'ASC', true, 0, 0);      but is there some documentation which functions I could use?


Plugin AJAX Save to Custom Table

I am learning how to use AJAX in the admin for a new plugin I am writing. In the PHP I have the function:               function ppmhnh_add_location(){         global $wpdb;         $values = array();         parse_str($_POST['form'], $values);         $sql = "INSERT INTO ppm_hoopsandhits_locations VALUES ('{$values['locale']}', '{$values['locale_city']}', '{$values['locale_state']}')";         $wpdb->query($sql);          echo "Added successfully!";         die();     }     add_action('wp_ajax_ppmhnh_new_location','ppmhnh_add_location');      The javascript uses this:               $('#newLocation').submit(function(e){             $('#wait-gif').show();             $('#btnAddLocation').attr('disabled', true);             data = {                 action: 'ppmhnh_new_location',                 form: $(this).serialize()             };                  $.post( ajaxurl, data, function(response){                 alert(response);                 $('#wait-gif').hide();                 $('#btnAddLocation').attr('disabled', false);                 location.reload();             });             return false;         });      If I echo $sql in response, I get the correct SQL statement               INSERT INTO ppm_hoopsandhits_locations VALUES ('100 Midtown', 'Atlanta', 'GA')      However nothing is being added to the table. Also, I would prefer just to refresh the part of the admin page where the table is displaying all of the values of the table rather than the whole page but I haven't figured that out yet. Any help is appreciated!


Wordpress Plugin Authenticate With Facebook WIth No AppID

I am working on my first wordpress plugin and posting to facebook. I have been looking for the last few days for ways to authenticate with facebook. I have found numerous sites that use the method of having the user create an App and then input the AppID and App Secret. However, I have used plugins before that use Oauth (I think) as it opens a pop up and the user basically logs into facebook and then says this app (your wordpress site) wants to control things. Does anyone know of any resources for authenticating with Facebook without the user having to go through the trouble of creating apps? Examples I have found but they require APPid and App Secrets. http://www.sanwebe.com/2012/02/post-to-facebook-page-wall-using-php-graph http://www.pontikis.net/blog/auto_post_on_facebook_with_php


How to get the true permalink of the static home page?

I asked a very similar question earlier today (http://wordpress.stackexchange.com/questions/30392/how-to-get-the-original- post-id-of-a-static-home-page) and thought I had the answer, but now it appears otherwise. If I have a post/page with the original permalink of `http://mydomain.com/blog/my-post/` for example, and I set that as the static home page of the blog, I am unable to get the original permalink of that page when I visit it, since WP only returns the root (`site_url()` essentially) permalink and redirects me there, since it is now set as the home page. How can I retrieve the ORIGINAL permalink? `get_option('page_on_front')` doesn't work because it will just return the blog root url, such as `http://mydomain.com/blog/`. I need to fetch the full original unaltered permalink of the currently-set static home page. Hope that's clear... thanks all!


Determine which theme location a wp_get_nav_menu_items is for

Is there a way to determine which theme placement a menu is for when modifying it with the `wp_get_nav_menu_items` filter hook? I'd like to only add items to certain menus and I don't want to have to depend on the ID or the name of the menu.


WP is not using the select custom template.php that its selected for a page

I created a childtheme: Fisio Inside I have: page-team.php with the name:               <?php     /*     Template Name: Page - Team     */     ?>     <?php get_header(); ?>     <script>alert('its the team page')</script>       And in the wp-admin I selected it for the page: Team ![Please check the page name and the selected template](http://i.stack.imgur.com/2nVPL.png) The problem is that any changes I make to page-team.php are not affected. In fact, the alert is never executed. What am I missing? PD: Is there a way to know wich was the template used having a look to the source code? I can't find this -EDIT- forgot to mention that team is listing a custom post_type: team, here is the declaration in functions.php               <?php     /**      * Custom Post type register framework      */     include(get_stylesheet_directory(). '/inc/acpt/init.php');     add_action('init', 'makethem');     function makethem() {         $args = array(             'supports' => array( 'title', 'editor', 'page-attributes', 'thumbnail', 'excerpt'  ),             'hierarchical' => true,         );              $team = new post_type('team','team', false,  $args );          }          /**      * Initialize the metabox class      */     add_action( 'init', 'be_initialize_team_meta_boxes', 9999 );     function be_initialize_team_meta_boxes() {         if ( !class_exists( 'team_Meta_Box' ) ) {             require_once( get_stylesheet_directory(). '/inc/metaboxes/fisio-metaboxes.php' );             require_once( get_stylesheet_directory(). '/inc/metaboxes/init.php' );              }     }     ?>


Adding a text link under the post title in the lists of posts

I made a lot of changes to my WP settings and now, when I approve and publish pending posts, authors have one hour to modify their articles. After the hour has gone the edit link disappear and they can't change anymore. I need to give them the opportunity to remove the post but the "trash" link has gone either. I've been thinking about adding a new text link under the post title to let the authors send me a message asking to delete the post. The text link should have the name of the post as subject in order to understand wich post need to be removed. Is this possible? Thanks


Permalink sending user to featured image media page rather than the post?

I'm working on a site and, on a particular category archive page, the permalink to the individual post is instead sending me to a media page for the thumbnail file. What's weird is that it's only doing this for some posts- not all. Does this sound familiar to anyone? EDIT: Here is the loop.               <?php if (have_posts()): while (have_posts()) : the_post(); ?>
              <a href="<?php the_permalink(); ?>">
                  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

                  <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>                      <?php the_post_thumbnail(); ?>                  <?php endif; ?>
<?php the_title(); ?>

<?php echo get_post_meta($post->ID, 'ecpt_secondline', true); ?>

<?php echo get_post_meta($post->ID, 'ecpt_thirdline', true); ?>

                  <?php endwhile; ?>                  <?php else: ?>

<?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?>

                  <?php endif; ?>      Thanks.


How do I programmatically set default role for new users?

I would like new users of the blog to have custom role, rather then Subscriber. How do I set this programmatically? I know that it can be changed from the backend.


Metabox textarea showing whitescreen

The problem is when i add textarea i get white screen without data   Below is my Code Which i got from Stack exchange.               add_action( 'add_meta_boxes', 'dynamic_add_custom_box' );          /* Do something with the data entered */     add_action( 'save_post', 'dynamic_save_postdata' );          /* Adds a box to the main column on the Post and Page edit screens */     function dynamic_add_custom_box() {         add_meta_box(             'dynamic_sectionid',             __( 'Client Information', 'myplugin_textdomain' ),             'dynamic_inner_custom_box',             'page');     }          /* Prints the box content */     function dynamic_inner_custom_box() {         global $post;         // Use nonce for verification         wp_nonce_field( plugin_basename( __FILE__ ), 'dynamicMeta_noncename' );         ?>
         <?php              //get the saved meta as an arry         $ourwork = get_post_meta($post->ID,'ourwork',true);              $c = 0;         if ( is_array( $ourwork ) ) {             foreach( $ourwork as  $track ) {                 if ( isset( $track['thumb'] ) || isset( $track['client-img1'] ) || isset( $track['client-img2'] ) || isset( $track['client-img3'] ) || isset( $track['client-img4'] ) || isset( $track['client-desc'] ) ) {                     printf( '
Thumb Image :  <input type="text" name="ourwork[%1$s][thumb]" value="%2$s" size="50" />
Client Image 1 : <input type="text" name="ourwork[%1$s][client-img1]" value="%3$s" size="50" />
                     Client Image 2 : <input type="text" name="ourwork[%1$s][client-img2]" value="%4$s" size="50"/>
                      Client Image 3 : <input type="text" name="ourwork[%1$s][client-img3]" value="%5$s" size="50" />
                      Client Image 4 : <input type="text" name="ourwork[%1$s][client-img4]" value="%6$s" size="50" />
                     Client Desc :
<textarea name="ourwork[%1$s][client-desc]" value=""></textarea>
                     %8$s
', $c, $track['thumb'], $track['client-img1'], $track['client-img2'] , $track['client-img3'] , $track['client-img4'], $track['client-desc'],  __( 'Remove' ) );                     $c = $c +1;                 }             }         }              ?>          <?php _e('Add+'); ?>
<?php          }          /* When the post is saved, saves our custom data */     function dynamic_save_postdata( $post_id ) {         // verify if this is an auto save routine.          // If it is our form has not been submitted, so we dont want to do anything         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )              return $post_id;              // verify this came from the our screen and with proper authorization,         // because save_post can be triggered at other times         if ( !isset( $_POST['dynamicMeta_noncename'] ) )             return;              if ( !wp_verify_nonce( $_POST['dynamicMeta_noncename'], plugin_basename( __FILE__ ) ) )             return;              // OK, we're authenticated: we need to find and save the data              $ourwork = $_POST['ourwork'];              update_post_meta($post_id,'ourwork',$ourwork);     }


Woocommmerce show SKU in cart page

How to show the SKU next to the product name in the cart page of Woocommerce ? tried to copy it from the Meta.php of single product but it breaks the page...


Looking for a theme to show unread/updated posts since last visit or like that

Good morning WP fans ! I try to find a theme for a .wordpress.com blog (it's hosted there) What I would like to have is a "notification system", like for example to notify the visitor that there are updated/unread posts in a category since his last visit/refresh/whatever. Like for example with a **bold number** inside brankets next to a category. Or with ANY other way if that is possible. Do you know of any theme that has that functionality ? Thanks !!!


How to put Periods and Spaces for Array Values (Meta Key)

_**Problem:_** Before I created meta-boxes I did things the old fashion way by entering custom fields directly. I went through the process of filling in the ID and the Value by hand and hitting the "update button". I would input whatever I wanted, `spaces` and `.` (periods) and they would be correctly applied in my database (ERROR FREE). However I no longer want to do this manually which is why I have created meta-boxes, but since I began using them, special characters like `.` and `spaces` wont take, resulting in a blank field when I attempt to update the post in order to save the meta-box values. What am I missing and why do the rules for special characters differ when you manually enter the ID as opposed to having it preset through meta-boxes. Ultimately how can I create meta-box array ID's with special characters? _Note: All my non-special character meta-boxes function properly. So the problem is NOT in the functionality of the code_ _**Details_** : I am using the mp3 player plugin "mp3-jplayer" which uses custom fields to display audio. The custom field format (which the creator of this plugin determined and I cannot change myself) is... ID = TrackNumber mp3.Artist ( **note** the space and the period above, this is what trips up the submission of the metabox value) Value = SongTitle@SongURL ![enter image description here](http://i.stack.imgur.com/x8Emb.png) At the moment I am using meta-boxes to input custom fields as follows:               $meta_boxes[] = array(     'id' => 'musicboxes',     'title' => 'Music Box Head',     'pages' => array('post'),     'context' => 'normal',     'priority' => 'low',          'fields' => array(     array(             'name' => 'Musicbox 1',             'desc' => 'ID',             'id' => '1 mp3.Artist',             'type' => 'text',             'std' => '',         )     )     );      However, when I input in the array ID field "1 mp3.Artist" the custom field does not update correctly (in other words, remains blank) and I'm thinking it's because there is a space between the number and the word "mp3". So how would I (if its possible) still be able to keep the space so that the custom field functions properly with the mp3-jplayer plugin.


Wordpress Custom Fields by category

let's say I have 100 categories and each has 10 custom fields for it self,for example : category Computer : Cpu - Hard - Ram - ... category TV : resolution - inch - usb support - ... ... now I want the editor only can see related custom fields to post(ex. computer) , I don't want them to see like 1000 custom fields and tries to find the related custom field to fill in, it will take for ever ! I'm making my own theme and can do what ever change that is needed !! I couldn't find any plugin for this ! thanks in advance .


Update post date to modified date automatically

I would like to find a function that will automatically change a posts date to the modified post date. I'm using wp User front end plugin so that visitors can add and edit a custom post. I'm also using the Post expirator plugin so that their post will automatically be set to draft after 1 month. The user will then be emailed and asked to update their post for it to go back on line. The problem is that the plugin only sees the post date. So once a user logs back in and edits their post (using front end user) the expirator date isn't reset to be 1 month from the modified date, instead it still uses the original date. Hope that all makes sense. So my choices are to either try and write my own function to handle the post expiration based on the modified date or to try and force the posts date to change to the same as the modified date once it has been updated. Can anyone help me with either solution? I'm guessing the latter solution would be the most straight forward to implement but willing to head advice. Many thanks D I've tried the suggestions below but have not managed to get this to work. Can anyone offer a solution to this? Thanks again! D


wp_schedule_event only when admin is visited

On the documentation page it says "The action will trigger when someone visits your WordPress site, if the scheduled time has passed." Is it possible to make this action trigger only when the admin is visited? I am trying to prevent a slow operation from impacting users on the front side.


List posts AND custom post type by category

I found this question asked elsewhere, but it was unanswered, so I'm asking myself. I have a custom post type (Features) that shares my Categories and Tags with my standard posts. I'm listing my categories with this:               <?php wp_list_categories('title_li=&hierarchical=false'); ?>      The resulting list includes categories that are applied only to Features. I know this is working because some of these point to empty pages. So the problem is with the loop that I'm using on my archive page. Here's the loop:               <?php if (have_posts()) : ?>     <?php while (have_posts()) : the_post(); ?>                 <?php $custom_classes = get_post_meta($post->ID, 'custom_post_class', false);  ?>         <article <?php post_class($custom_classes) ?> id="post-<?php the_ID(); ?>" role="article">                              <hgroup>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>

By <?php the_author_posts_link() ?>

<time datetime="<?php echo get_the_date('c'); ?>"><?php echo get_the_date('F jS, Y'); ?></time>
                 </hgroup>
                 <?php the_content(); ?>                 <?php edit_post_link('Edit this post ✍', '
', '
'); ?>

          <?php endwhile; ?>      Can you tell me what I'd need to add in order to get my custom post type to show up here?


URL issues with WordPress

I am having some URl issues with WordPress Basically i have different categories and for some reason whenever I have posts with exact same title...even though in "different" categories...I still have WordPress change the URl and adds like -#...where # stands for duplicate number. like I can have links like gateway, gateway-2, gateway-3 and so on...WordPress automatically appends those numbers because they have same title...but they are all in different categories...so I need help here please....what can I do to stop wordpress from doing this and use the exact title since they are in different categories? Thanks.


Registration Hooks don't appear to be working

I am trying to hook in to automatically sign-in the user after registration. (using a GravityForms registration form). None of the hooks seem to be working. I've tried: gform_user_registered, user_register, a filtered 'update_user_metadata'.... Why would this not kill the script after a registration happens?               add_action("user_register", "my_auto_login");     function my_auto_login($user_id) {         die('x');     }      Login after registration seems like it should not be that complicated.


Featured Images not appearing

I'm helping a friend with a WordPress blog since I'm a "computer person," although I have no specific WordPress experience and I haven't used PHP in years. So, I really appreciate any light that anyone can shed on this subject. The primary purpose of the blog is to catalog items and there are about 8,000 posts, each containing one photo. The blog began on another platform and was migrated to WordPress years ago, so things are pretty mucked up on the back end. Thousands of the posts were migrated from the other platform, and then thousands more were posted from the WP CMS. They recently upgraded to the latest version of WordPress (and a new theme, Themolio) and now are having two major problems (with the first being the biggest problem, though I'd like to solve them both):   1. The `<img>` tag for the photo in each post is contained in the post_content field. However, some of the URLs are absolute, and some are relative based on the messy history of the blog I described above. I do not know which are "correct," i.e., the way WP generates them, and which were imported from the other platform. The absolute ones are appearing fine everywhere. The relative ones are fine within each post, but are breaking when they appear within the Archive pages. Can I somehow get the images to appear correctly on all pages despite the fact that each page may have a different path? Should they all be relative or all absolute? And finally, can I use some combination of MySQL queries and regular expressions to update all the entries in the DB to be uniform?   2. No thumbnail images are appearing on the front page of the blog or on the Search page. There are not even broken links- there are no links at all. It seems that Featured Images in WP are supposed to have a meta_key field called _thumbnail_id... none of these posts have this. It appears the old theme on the old version of WP was pulling thumbs from a meta_key field called "Featured Image", which contains the filename of the image relative to the /uploads/ folder. Clearly this is going to be an issue... can I somehow get WP to get thumbnail URLs from this Featured Image meta_key?  Thank you!!! **Solution**   Based on the comments from Gorit, here is the code I used to fix each problem: Question 1: Executed a SQL command pretty much exactly as written in her post. Change whatever details you need to for your particular case. Question 2: Ran this piece of php code placed in the root folder.               require_once './wp-config.php';     global $wpdb;      $wpdb->show_errors();     $posts = $wpdb->get_results("SELECT id, post_parent FROM wp_posts WHERE post_type = 'attachment'", ARRAY_N);     if ($posts) {         foreach ($posts as $post) {         // First insert a thumbnail_id meta tag for the attachment that points to itself         $wpdb->query("INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES ('" . $post[0] . "', '_thumbnail_id', '" . $post[0] .  "')");         // Next, insert a thumbnail_id meta tag for the attachment's parent post that points to the attachment         $wpdb->query("INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES ('" . $post[1] . "', '_thumbnail_id', '" . $post[0] .  "')");         }     }


Updating client websites on a regular basis

I hope the following question is acceptable here, as it's half WordPress- related and half-business related. Updating WP regularly is important for security purposes, but it can be time consuming if there are many websites to update and even more if some updates require plugin updates (and in some cases, a plugin ceases to work after WP update which potentially requires a time-consuming solution). What is the best solution to address this ongoing problem? Should WP regular updates be charged for example? Should it be mentioned in the initial contract?


Polldaddy doesn't show up on own theme

I'm developing my own theme on a website where I use the polldaddy polls & ratings plugin. I've set the ratings to show up on the homepage and that's working with e.g. the twentytwelve theme. However with my own theme, I do see the polldaddy div, but there's nothing in it:

      This is my `index.php`:               <?php     get_header(); // Loads the header.php template.      if ( have_posts() ) :          while ( have_posts() ) : the_post(); ?>
                 <h2 class="post_title" id="post-<?php the_ID();?>"><a href="<?php the_permalink();?>" rel="bookmark" title="<?php the_title();?>"><?php the_title();?>
                 <?php the_excerpt(); ?>
         <?php endwhile;      else :          get_template_part( 'loop-error' ); // Loads the loop-error.php template.      endif;      get_footer(); // Loads the footer.php template.      ?>      The `header.php` and `footer.php` just make a basic box model. Then, the relevant codes of the polldaddy plugin, `ratings.php` (there is a filter addition on the bottom):               <?php     function polldaddy_show_rating_comments( $content ) {         if ( !is_feed() && !defined( 'DOING_AJAX' ) ) {             global $comment;             global $post;                  if ( isset( $comment->comment_ID ) && $comment->comment_ID > 0 ) {                 $unique_id  = '';                 $title      = '';                 $permalink  = '';                 $html       = '';                 $rating_pos = 0;                      if ( (int) get_option( 'pd-rating-comments' ) > 0 ) {                     $rating_id = (int) get_option( 'pd-rating-comments' );                     $unique_id = 'wp-comment-' . $comment->comment_ID;                     $rating_pos = (int) get_option( 'pd-rating-comments-pos' );                     $title = mb_substr( preg_replace( '/[\x00-\x1F\x80-\xFF]/', '', $comment->comment_content ), 0, 195 ) . '…';                     $permalink = get_permalink( $post->ID ) . '#comment-' . $comment->comment_ID;                     $html = polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, '_comm_' . $comment->comment_ID );                          if ( $rating_pos == 0 )                         $content = $html . '
' . $content;                     else                         $content .= $html;                 }             }         }         return $content;     }          function polldaddy_show_rating( $content ) {         global $wp_current_filter;         if ( !in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {             if ( !is_feed() && !is_attachment() ) {                 if ( is_single() || is_page() || is_home() || is_archive() || is_search() || is_category() ) {                     $html = polldaddy_get_rating_html( 'check-options' );                          if ( !empty( $html ) ) {                         $rating_pos = 0;                              if ( is_page() ) {                             $rating_pos = (int) get_option( 'pd-rating-pages-pos' );                         } elseif ( is_home() || is_archive() || is_search() || is_category() ) {                             $rating_pos = (int) get_option( 'pd-rating-posts-index-pos' );                         } else {                             $rating_pos = (int) get_option( 'pd-rating-posts-pos' );                         }                              if ( $rating_pos == 0 )                             $content = $html . '
' . $content;                         else                             $content .= $html;                     }                 }             }         }         return $content;     }          function polldaddy_get_rating_html( $condition = '' ) {         global $post;         $html = '';              if ( $post->ID > 0 ) {             $unique_id = '';             $title = '';             $permalink = '';             $rating_id = 0;             $item_id = '';             $exclude_posts = explode( ',', get_option( 'pd-rating-exclude-post-ids' ) );             $exclude_pages = explode( ',', get_option( 'pd-rating-exclude-page-ids' ) );                  if ( is_page() ) {                 if ( !in_array( $post->ID, $exclude_pages ) ) {                     $unique_id = 'wp-page-' . $post->ID;                     $item_id =  '_page_' . $post->ID;                     if ( $condition == 'check-options' ) {                         if ( (int) get_option( 'pd-rating-pages' ) > 0 ) {                             $rating_id = (int) get_option( 'pd-rating-pages-id' );                         }                     } else {                         $rating_id = (int) get_option( 'pd-rating-pages-id' );                     }                 }             } elseif ( !in_array( $post->ID, $exclude_posts ) ) {                 $unique_id = 'wp-post-' . $post->ID;                 $item_id =  '_post_' . $post->ID;                 if ( is_home() || is_archive() || is_search() || is_category() ) {                     if ( $condition == 'check-options' ) {                         if ( (int) get_option( 'pd-rating-posts-index' ) > 0 ) {                             $rating_id = (int) get_option( 'pd-rating-posts-id' );                         }                     } else {                         $rating_id = (int) get_option( 'pd-rating-posts-id' );                     }                 } else {                     if ( $condition == 'check-options' ) {                         if ( (int) get_option( 'pd-rating-posts' ) > 0 ) {                             $rating_id = (int) get_option( 'pd-rating-posts-id' );                         }                     } else {                         $rating_id = (int) get_option( 'pd-rating-posts-id' );                     }                 }             }                  if ( $rating_id > 0 ) {                 $rating_title_filter = get_option( 'pd-rating-title-filter' );                      if ( $rating_title_filter === false )                     $title = apply_filters( 'the_title', $post->post_title, $post->ID, '' );                 elseif ( strlen( $rating_title_filter ) > 0 )                     $title = apply_filters( $rating_title_filter, $post->post_title, $post->ID, '' );                 else                     $title = $post->post_title;                      $permalink = get_permalink( $post->ID );                 $html = polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, $item_id );             }         }         return $html;     }          /**      * Construct a Polldaddy target div for a given rating_id and optional item_id      * Define a Polldaddy ratings variable for a given rating_id and optional item_id      *      * @param int     $rating_id      * @param string  $unique_id      * @param string  $title     Post title      * @param string  $permalink Post permalink      * @param string  $item_id      * @return HTML snippet with a ratings container and a related JS block defining a new variable      */     function polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, $item_id = '' ) {            $html = sprintf( '[polldaddy rating="%d" item_id="%s" unique_id="%s" title="%s" permalink="%s"]', absint( $rating_id ), polldaddy_sanitize_shortcode( $item_id ), polldaddy_sanitize_shortcode( $unique_id ), polldaddy_sanitize_shortcode( $title ), polldaddy_sanitize_shortcode( $permalink ) );         return do_shortcode( $html );     }          function polldaddy_sanitize_shortcode( $text ) {         $text = preg_replace( array( '/\[/', '/\]/' ), array( '[', ']' ), $text );         return esc_attr( $text );     }          if ( (int) get_option( 'pd-rating-pages' ) > 0 || (int) get_option( 'pd-rating-posts-index' ) > 0 || (int) get_option( 'pd-rating-posts' ) > 0 ) {         add_filter( 'the_content', 'polldaddy_show_rating', 5 );         add_filter( 'the_excerpt', 'polldaddy_show_rating' );     }          add_filter( 'comment_text', 'polldaddy_show_rating_comments', 50 );     ?>      How can I make the ratings show up right?


Accessing multiple sites via FTP

I've installed wordpress MU, and established a different site in my domain/dev/sitename -- but I want to then install a theme on that site, and edit it directly. However, my FTP only shows the main Wordpress installation. How do I get at the /sitename subdirectory?


Only nextpagelink on wp_link_pages

Does someone have a solution to display only the `nextpagelink` with `wp_link_pages` in single posts? I've tried different solutions, but none of it worked. As I reach the last page - `wp_link_pages` remove `nextpagelink` and show `previouspagelink`. But I need only nextpagelink at all pages except last one. Or maybe a solution to add class for nextpagelink? **Found solution:**               <?php global $multipage, $numpages, $page;      if( $multipage && $page == $numpages )      {        //Do nothing      } else {       wp_link_pages('before=&after=&next_or_number=next&previouspagelink=&nextpagelink=More');      } ?>


plugin where users can manage their ratings and reviews on posts?

Is there a plugin where logged in users can manage ratings and reviews on posts? I have seen plugins where users can leave comments with ratings on posts but haven't seen one where the user can actually manage the comments he left (edit / delete). And if this supports custom post types, that would be great.


Xampp maximum execution time not changing through php.ini

I have WordPress installed on my localhost through Xampp, and when I try to use the WordPress importer I get the following error: **Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\wordpress\wp-includes\functions.php on line 1542** Now, I've searched around for this and almost everyone says that setting the max_execution_time in xampp/php/php.ini file from 30 to a higher value will solve this problem. I did the above and restarted Xampp but that didn't solve it. Also, when I upload the files to the live server, this doesn't happen so I'm pretty sure it has to do with the Xampp settings. Can someone please tell how can I tackle this problem? Thanks!


wp_list_table search box does not show

I'm using wordpress 3.8 and a custom class derived from `WP_List_Table`. Why is there no search form? ![My Plugin admin page \(using WP_List_Table\)](http://i.stack.imgur.com/C3y1L.png) My code in plugin class:               function __construct()                 {                     register_activation_hook( __FILE__, array( $this, 'swb_plugin_install' ) );                     register_deactivation_hook( __FILE__, array( $this, 'swb_plugin_deactivate' ) );                     register_uninstall_hook( __FILE__, array( $this, 'swb_plugin_remove' ) );                          add_action( 'wp_head', array( $this, 'swb_header' ) );                     add_action( 'admin_menu', array( $this, 'swb_admin_page' ) );                     add_action( 'admin_enqueue_scripts', array( $this, 'swb_admin_script' ) );                 }              function swb_admin_resellers()             {                 $list_obj = new SWB_Resellers_List_Table();                 if( isset($_POST['s']) ){                     $list_obj->prepare_items($_POST['s']);                 } else {                     $list_obj->prepare_items();                 }                 echo '

Resellers List
';                 ?>                 <form method="post">                     <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />                     <?php $list_obj->search_box('search reseller(s)', 'search_id'); ?>                     <?php $list_obj->display(); ?>                 </form>
                 <?php             }          function swb_admin_page()             {                 add_menu_page( '', 'Smarts Web Builder', 'activate_plugins', 'swb_plugin_root', array( $this, 'swb_admin_settings' ) );                 add_submenu_page( 'swb_plugin_root', 'SWB General Setting', 'General Settings', 'activate_plugins', 'swb_plugin_root', array( $this, 'swb_admin_settings' ) );                 add_submenu_page( 'swb_plugin_root', 'SWB Resellers List', 'Resellers', 'activate_plugins', 'swb_resellers', array( $this, 'swb_admin_resellers' ) );                 add_submenu_page( 'swb_plugin_root', 'SWB Licenses List', 'Licenses', 'activate_plugins', 'swb_licenses', array( $this, 'swb_admin_licenses' ) );                 add_submenu_page( 'swb_plugin_root', 'SWB Customers List', 'Customers', 'activate_plugins', 'swb_customers', array( $this, 'swb_admin_customers' ) );                 add_submenu_page( 'swb_plugin_root', 'SWB Themes', 'Manage Themes', 'activate_plugins', 'swb_themes', array( $this, 'swb_admin_themes' ) );                 add_submenu_page( 'swb_plugin_root', 'SWB Plugins', 'Manage Plugins', 'activate_plugins', 'swb_plugins', array( $this, 'swb_admin_plugins' ) );             }      The class which extends WP_List_Table:               if(!class_exists( 'SWB_Resellers_List_Table' ) )     {         class SWB_Resellers_List_Table extends WP_List_Table         {             function __construct()             {                 parent::__construct(array(                     'singular' => 'wp_list_text_link',                     'plural' => 'wp_list_test_links',                     'ajax' => false                 ));             }                  function get_columns()             {                 return $column = array(                     'col_name' => __('Real Name'),                     'col_username' => __('Username'),                     'col_contact_no' => __('Contact No.'),                     'col_email' => __('Email'),                     'col_active' => __('Is Active?'),                     'col_registered_time' => __('Registered'),                     'col_modified_time' => __('Last Modified')                 );             }                  public function get_sortable_columns()             {                 return $sortable = array(                     'col_name' => array(                         'name',                         false                     ),                     'col_username' => array(                         'username',                         false                     ),                     'col_email' => array(                         'email',                         false                     ),                     'col_active' => array(                         'active',                         false                     ),                     'col_registered_time' => array(                         'registered_time',                         false                     ),                     'col_modified_time' => array(                         'modified_time',                         false                     )                 );             }                  function prepare_items($search='')             {                 global $wpdb;                      $table = $wpdb->prefix . SWB_TABLE_RESELLER;                 $join1 = $wpdb->prefix . "wlm_user_options";                 $join2 = $wpdb->users;                      $short_table = "T1";                 $short_join1 = "T2";                 $short_join2 = "T3";                      $column = "{$short_table}.reseller_id reseller_id,                     {$short_table}.user_id user_id,                     {$short_table}.active active,                     {$short_table}.modified_time modified_time,                     (SELECT {$short_join1}.option_value FROM {$join1} {$short_join1} WHERE {$short_join1}.option_name='custom_real_name' AND {$short_join1}.user_id={$short_table}.user_id) name,                     (SELECT {$short_join1}.option_value FROM {$join1} {$short_join1} WHERE {$short_join1}.option_name='custom_contact_no' AND {$short_join1}.user_id={$short_table}.user_id) contact_no,                     {$short_join2}.user_login username,                     {$short_join2}.user_email email,                     {$short_join2}.user_registered registered_time";                 $on1 = "{$short_join2}.ID={$short_table}.user_id";                      $where = "";                 $where .= !empty($_POST['name']) ? "name=" . trim($_POST['name']) : null;                 $where .= !empty($_POST['username']) ? "username=" . trim($_POST['username']) : null;                 if(!empty($search)){                     if( !empty($where) )    $where .= " AND ";                     $where = "(name LIKE '%{$search}%' OR username LIKE '%{$search}%')";                 }                 if( !empty($where) )    $where = " WHERE " . $where;                      $ordercolumn = !empty($_GET['orderby']) ? trim($_GET['orderby']) : null;                 $orderdirection = !empty($_GET['order']) ? trim($_GET['order']) : null;                 $orderby = "{$ordercolumn} {$orderdirection}";                 if( !empty($orderby) )  $orderby = "ORDER BY " . $orderby;                      $query = "SELECT {$column} FROM {$table} {$short_table} JOIN {$join1} {$short_join1} JOIN {$join2} {$short_join2} ON {$on1}{$where}{$order_by}";                      $totalitems = $wpdb->query($query);                      $perpage = 10;                      $paged = !empty($_GET["paged"]) ? intval($_GET["paged"]) : '';                      if (empty($paged) || !is_numeric($paged) || $paged <= 0) {                 $paged = 1;                 }                      $totalpages = ceil($totalitems / $perpage);                      if (!empty($paged) && !empty($perpage)) {                 $offset = ($paged - 1) * $perpage;                 $query .= ' LIMIT ' . ( int ) $offset . ',' . ( int ) $perpage;                 }                      // Register page                 $this->set_pagination_args(                     array(                         "total_items" => $totalitems,                         "total_pages" => $totalpages,                         "per_page" => $perpage                     )                 );                      // Register column                 $columns               = $this->get_columns();                 $hidden                = array();                 $sortable              = $this->get_sortable_columns();                 $this->_column_headers = array(                     $columns,                     $hidden,                     $sortable                 );                 // var_dump($this);                 // echo $query;                      // Fetch items                 $this->items = $wpdb->get_results($query);                  }         }              function display_rows()         {             $records = $this->items;             $columns = null;             $hidden  = null;             list($columns, $hidden) = $this->get_column_info();                  if (!empty($records)) {                 foreach ($records as $rec) {                     echo '
reseller_id . '">';                     foreach ($columns as $column_name => $column_display_name) {                     $class = "class='{$column_name} column-{$column_name}'";                         $style = "";                         if (in_array($column_name, $hidden))                             $style = ' style="display:none;"';                         $attributes = $class . $style;                              switch ($column_name) {                             case "col_name":                                 echo '' . stripslashes($rec->name) . '	';                                 break;                             case "col_username":                                 echo '' . stripslashes($rec->username) . '	';                                 break;                             case "col_contact_no":                                 echo '' . stripslashes($rec->contact_no) . '	';                                 break;                             case "col_email":                                 echo '' . stripslashes($rec->email) . '	';                                 break;                             case "col_active":                                 $active = ( intval($rec->active) == 1 ) ? 'Yes' : 'No';                                 echo '' . $active . '	';                                 break;                             case "col_registered_time":                                 echo '' . date("F j, Y g:i a", stripslashes($rec->registered_time)) . '	';                                 break;                             case "col_modified_time":                                 echo '' . date("F j, Y g:i a", stripslashes($rec->modified_time)) . '	';                                 break;                         }                     }                     echo '
';                 }             }         }     }      I don't know why the search box doesn’t show up. What is missing?


Change the domain url?

So I have two urls. www.url.com and www.urlb.com I don't want to manually transfer the files to the other website, instead I just want to change the domain, so that it says www.urlb.com in the URL field. Is this possible? Is it considered duplicate content?


Date archives for custom post type

I have seen many questions/posts regarding this, but have yet to find a decent solution. Basically I am trying to do what `wp_get_archives` does, but for a custom post type (personally I am unsure why `wp_get_archives` doesn't support custom post types!). The code I am currently using is as follows **functions.php**               function Cpt_getarchives_where_filter( $where , $r ) {       $post_type = 'events';       return str_replace( "post_type = 'post'" , "post_type = '$post_type'" , $where );     }      **sidebar-events.php**               add_filter( 'getarchives_where' , 'Cpt_getarchives_where_filter' , 10 , 2 );     wp_get_archives();     remove_filter('getarchives_where' , 'Cpt_getarchives_where_filter' , 10 );      This code displays the dates (e.g. April 2014, March 2014) etc, which is great, but clicking the links just goes to a 404. The URL that is created on each date link is /2014/04/, however it should be something like /events/2014/04/. Is there any way to include 'events' in the URL so that the archive-events.php template can be used, and is there any reason why the links currently generate a 404? Many thanks for any help


Database Name Change

I read it was more secure to use something else besides wp_ as the database prefix, so I downloaded my .sql file replaced all instances of wp_ with tsi_ and then dropped the wp_ tables and imported my .sql file. The prefix is now correct, so then I went to my wp_config file and changed the prefix table from wp_ to tsi_ and I thought everything was good. Well, all my posts were still there, but the images are missing. I say missing because when you look in the uploads folder they are there, correctly sorted and everything, but in the media library, they appear as grey icons instead of the previews and they are missing from all my posts. Is there any way to get the images to display correctly? *The domain name did not change or any of my settings, I just changed the database prefix and that's it. The grey icons in the media library: ![enter image description here](http://i.stack.imgur.com/1Jsi2.png) The posts without images: ![enter image description here](http://i.stack.imgur.com/vYlpf.png) Thanks,   Josh


How to filter post using custom feild value in shortest and longest duration?

I am working on a video blog. On the front page I have a sort by option. You can try the option at the following link http://cricketclips.net/ Can't figure out how to make the shortest and longest video option to work. In db I have custom field named "complete" with value in decimals (i.e 4.23,0.26,1.28 etc Where 4.23= 4 minute and 23 sec.) For shortest video; I want to display the videos in ascending order with respect to the decimal values mentioned above. And for longest video: want to display the videos in descending. Any help in this regard will be appreciated.


How to save the date/time of last update of an extra user profile field?

I have a function that adds and saves very well an extra field to the user profile. But, because the content of this field gets old very quickly, I need to know when the user refreshed it last time - **only this specific field, not the whole user meta data!** I need to know if the user REALLY updated (edited) the content of this field, not only simply pushed the update button. How to do this?               /* Add extra fields to the user profile */          add_action( 'show_user_profile', 'extra_user_profile_fields' );     add_action( 'edit_user_profile', 'extra_user_profile_fields' );          function extra_user_profile_fields( $user ) { ?>

<?php _e("Consultation day"); ?>	           <textarea rows="3" cols="30" name="consultations_day" id="consultations_day" style="margin-bottom: 0px;" /><?php echo esc_attr( get_the_author_meta( 'consultations_day', $user->ID ) ); ?></textarea>
              <?php _e("Put here your consultations day and hours"); ?>

        <?php     }          /* Save extra user profile fields */          add_action( 'personal_options_update', 'save_extra_user_profile_fields' );     add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );          function save_extra_user_profile_fields( $user_id ) {             if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }             update_user_meta( $user_id, 'consultations_day', $_POST['consultations_day'] );  //Consultations day          }


Authenticate return value

I am trying to hook into the _authenticate_ return value to display error message on custom login form. The `$user` object is not returned.               add_action( 'authenticate', 'my_login_check' );     function my_login_check( $user ){         if( is_wp_error( $user ) ){             exit();         }     }