Saving metabox repeatable fields

This is a code that I'm adapting from https://gist.github.com/2057532. The problem is that I'm not being able to save the content from the new fields that I created. I had checked the other questions here, but none helped me. Any idea where is the problem?               add_action('admin_init', 'slider_metabox_caption', 1);     function slider_metabox_caption() {     add_meta_box( 'repeatable-fields', 'Captions', 'repeatable_metabox_display', 'slide', 'normal', 'high'); }          function repeatable_metabox_display() {     global $post;          $repeatable_fields = get_post_meta($post->ID, 'repeatable_fields', true);     wp_nonce_field( 'repeatable_meta_box_nonce', 'repeatable_meta_box_nonce' ); ?>

                 	                 Text	                 Fx	                 Easing	                 Speed	                 X	                 Y	                 Width	                 Height

              <?php          if ( $repeatable_fields ) :             foreach ( $repeatable_fields as $field ) { ?>
             -	                  <input type="text" class="widefat" name="text[]" value="<?php if($field['text'] != '') echo esc_attr( $field['text'] ); ?>" />	             <input type="text" class="widefat" name="fx[]" value="<?php if($field['fx'] != '') echo esc_attr( $field['fx'] ); ?>" />	             <input type="text" class="widefat" name="easing[]" value="<?php if($field['easing'] != '') echo esc_attr( $field['easing'] ); ?>" />	             <input type="text" class="widefat" name="speed[]" value="<?php if($field['speed'] != '') echo esc_attr( $field['speed'] ); ?>" />	             <input type="text" class="widefat" name="x[]" value="<?php if($field['x'] != '') echo esc_attr( $field['x'] ); ?>" />	             <input type="text" class="widefat" name="y[]" value="<?php if($field['y'] != '') echo esc_attr( $field['y'] ); ?>" />	             <input type="text" class="widefat" name="width[]" value="<?php if($field['width'] != '') echo esc_attr( $field['width'] ); ?>" />	             <input type="text" class="widefat" name="height[]" value="<?php if($field['height'] != '') echo esc_attr( $field['height'] ); ?>" />	                  |||
         <?php } else :          // show a blank one ?>
             -	                  <input type="text" class="widefat" name="text[]" />	             <input type="text" class="widefat" name="fx[]" />	             <input type="text" class="widefat" name="easing[]" />	             <input type="text" class="widefat" name="speed[]" />	             <input type="text" class="widefat" name="x[]" />	             <input type="text" class="widefat" name="y[]" />	             <input type="text" class="widefat" name="width[]" />	             <input type="text" class="widefat" name="height[]" />	                  |||
              <?php endif; ?>
             -	                  <input type="text" class="widefat" name="text[]" />	                     <input type="text" class="widefat" name="fx[]" />	             <input type="text" class="widefat" name="easing[]" />	             <input type="text" class="widefat" name="speed[]" />	             <input type="text" class="widefat" name="x[]" />	             <input type="text" class="widefat" name="y[]" />	             <input type="text" class="widefat" name="width[]" />	             <input type="text" class="widefat" name="height[]" />	                  |||

Add another     <input type="submit" class="metabox_submit" value="Save" />
          <?php     }          add_action('save_post', 'repeatable_meta_box_save');     function repeatable_meta_box_save($post_id) {     if ( ! isset( $_POST['repeatable_meta_box_nonce'] ) ||         ! wp_verify_nonce( $_POST['repeatable_meta_box_nonce'], 'repeatable_meta_box_nonce' ) )         return;          if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)         return;          if (!current_user_can('edit_post', $post_id))         return;          $old = get_post_meta($post_id, 'repeatable_fields', true);     $new = array();          $text = $_POST['text'];     $fx = $_POST['fx'];     $easing = $_POST['easing'];     $speed = $_POST['speed'];     $x = $_POST['x'];     $y = $_POST['y'];     $width = $_POST['width'];     $height = $_POST['height'];          $count = count( $text );          for ( $i = 0; $i < $count; $i++ ) {         if ( $text[$i] != '' ) :             $new[$i]['text'] = stripslashes( strip_tags( $text[$i] ) );              elseif ( $fx[$i] != '' ) :             $new[$i]['fx'] = stripslashes( strip_tags( $fx[$i] ) );              elseif ( $easing[$i] != '' ) :             $new[$i]['easing'] = stripslashes( strip_tags( $easing[$i] ) );              elseif ( $speed[$i] != '' ) :             $new[$i]['speed'] = stripslashes( strip_tags( $speed[$i] ) );              elseif ( $x[$i] != '' ) :             $new[$i]['x'] = stripslashes( strip_tags( $x[$i] ) );              elseif ( $y[$i] != '' ) :             $new[$i]['y'] = stripslashes( strip_tags( $y[$i] ) );              elseif ( $width[$i] != '' ) :             $new[$i]['width'] = stripslashes( strip_tags( $width[$i] ) );              elseif ( $height[$i] != '' ) :             $new[$i]['height'] = stripslashes( strip_tags( $height[$i] ) );              endif;     }          if ( !empty( $new ) && $new != $old )         update_post_meta( $post_id, 'repeatable_fields[$i]', $new );     elseif ( empty($new) && $old )         delete_post_meta( $post_id, 'repeatable_fields[$i]', $old );     }


Scheduled event does not run at midnight

I have an event scheduled to fetch feeds from different sources at midnight. I believe for some reason it is not being triggered. I use Core Control plugin for testing. When I 'Run Now' through it, it works fine. What could be possible reason? Any hint that could facilitate me to get to the cause? There is no argument to the handler and it is a reoccurring once daily task.


Confit theme on Wordpress.org

I'm a fairly new user of wordpress.org. I have a wordpress.com site using the Confit theme and wish to transfer it to .org. I exported the site from .com and into imported to .org successfully, only to find that .org did not offer the Confit theme. I have since downloaded the directory for the Confit theme from here: https://wpcom-themes.svn.automattic.com/ and saved it in the wp- content/themes/confit. The Confit theme option appears normally in the installed themes section of the .org suite, alongside twenty eleven and twenty twelve preinstalled themes. However, when trying to apply the theme to the site, the progress bar gets half way before the whole thing turns blank, no matter what address within the site I try and visit. I can no longer access the admin page to change the theme back. As a result, I wiped the databases on the domain, deleted and reinstalled wordpress on the site etc. Again the site works fine until I try to apply the theme. The last time, I have tried to preview the theme before applying it and, unsurprisingly, the preview is blank - no side bar or anything. Can anyone suggest what I might have done wrong when installing the theme? Cheers, Tom.


Exclude category from loop not working

I have this code in my index.php file. I have a different template for a static home page, this is the blog page. I'm trying to exclude all posts with the category "new" which is tag_id "13"               <?php query_posts($query_string . '&cat=-13'); ?>     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
<?php the_title(); ?>

<?php the_excerpt(); ?> <a href="<?php the_permalink()?>">read in full

Written by: <?php the_author_posts_link(); ?>
                                <?php the_time('F jS, Y') ?>

          <?php endwhile; ?>      Any ideas why this isnt working?


single page site with subpages

i want to make a single page site which has subpages with following structure about us   team   -member1   -member2   contact   and i want the output to be like
     team content

     team content

              member1 content

              member2 content

     team content
      and this is my loop so far               <?php query_posts(array('post_type'=>page, 'orderby'=>menu_order, 'post_parent' => $thePostID)); ?>                  <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                       <?php if ( 0 == $post->post_parent ) { ?>
<?php the_title(); ?>
                  <?php } else { ?>
<?php the_title(); ?>
                  <?php } ?>
<?php the_title(); ?>
                  <?php the_content(); ?>             <?php endwhile; endif; ?>      thanks for helping, helmut


Taxonomy term in permalink

I have a big problem. I have been banging my head on this all day long. It seems to be a stupid easy question. Possibly also with a stupid easy answer. But I can't seem to find it. What I want is simple. I have a custom_post_type called "producten" and a taxonomy called "producten_categorie". Inside there I have got some couple hundred products that are all assigned to a "produten_categorie" term. I want to change the permalinks so they display the taxonomy term in the product permalink. **What I have now is as follows:**   * www.domain.com/producten/ (producten archive)     * www.domain.com/producten/category (producten category archive)   * www.domain.com/producten/category/subcategory (producten subcategory archive)   * www.domain.com/producten/post_tile (single page for post in "producten") **What I want is the following:**   * www.domain.com/producten/ (producten archive)     * www.domain.com/producten/category (producten category archive)   * www.domain.com/producten/category/subcategory (producten subcategory archive)   * www.domain.com/producten/category/post_tile (single page for post in main category)   * www.domain.com/producten/category/subcategory/post_tile (single page for post in sub category) I can't get it to work. I first tried the "custom post type permalinks" plugin. Which did not work and gave me 404 errors. Even after flushing the permalinks more than a few times. After that I tried manually changing the permalink by using "filter_post_type_link". But I just can't get it to work. You can find my code for registering the post type on the taxonomy here -> http://pastebin.com/DMfA21qb Hope someone can help me.


Get all image from single page using this query

I'm having some trouble with this sample widget code. I want to get all images (Minus the post thumbnail) from a page called "Gallery" but for some reason this is pulling all uploaded images from the entire site. Also, how would I go about excluding the post thumbnail from this query?                 query_posts('pagename=gallery');     if (have_posts()) :      echo "
";     while (have_posts()) : the_post();         $args = array(         'post_type' => 'attachment',         'numberposts' => 1,         'post_status' => null,         'post_parent' => $post->ID     );          $attachments = get_posts( $args );         if ( $attachments ) {         foreach ( $attachments as $attachment ) {            echo '
';            echo wp_get_attachment_image( $attachment->ID, 'full' );            echo '
';           }         }     endwhile;          endif;      wp_reset_query();


How to add a 2nd "featured image" to a post?

My theme has a slider widget that allows the end user to select a category and it assigns the posts in that category to the slider. If a post has a featured image, its used as the background of the slide for that post. However, there are cases where the featured image on the post itself needs to be different that the one used in the slider. What are some options for a workaround? Ideally, I'd like to just create a clone of the "Featured Image" panel, calling it "Slider Image". How difficult would that be? What files do I need to clone? Any plugins that already do this?


What plugin should I use for a basic user signup/login system

I need to present a user signup/login system on the front end of my site. My requirements are pretty straight forward:   * I don't want the user to ever wind up in the WP admin panel.    * A signed up user will have access to one additional page    * I want to keep track of email addresses from these users   * I would like to provide a forgot my password link.    * The users only need to provide an email and password to sign up Any ideas? plugin or otherwise?


Notice: Undefined index

Got this great contact us page to use on in my theme. It works great, but the problem is, in debug mode I get undefined index errors on the following line of code:               $name       = $_POST['name'];     $email      = $_POST['email'];     $message    = $_POST['text'];     $human      = $_POST['human'];     $submitted  = $_POST['submitted'];      So I changed the code to the next two pieces of code based on previous answers and tutorials:               $name       = (isset($_POST['name'])        ? $_POST['name']    : '');         $email      = (isset($_POST['email'])       ? $_POST['email']   : '');         $message    = (isset($_POST['message'])     ? $_POST['message'] : '');         $human      = (isset($_POST['human'])       ? $_POST['human'] : '');         $submitted  = (isset($_POST['submitted'])   ? $_POST['submitted'] : '');      and                    if (isset ($_POST['name'])) {       $name = $_POST['name'];     }     if (isset ($_POST['email'])) {       $email = $_POST['email'];     }     if (isset ($_POST['message'])) {       $message = $_POST['message'];     }     if (isset ($_POST['human'])) {       $human = $_POST['human'];     }     if (isset ($_POST['submitted'])) {       $submitted = $_POST['submitted'];     }      The first set of code removes all debug error messages, but when you submit the form, it triggers the > $missing_content message which fires when all fields are left empty. The second set of code gives me undefined index debug error messages on the following set of code:               $headers = 'Van: '. $email . "\r\n" .         'Aantwoord op: ' . $email . "\r\n";            if(!$human == 0){     else if ($submitted) my_contact_form_generate_response("error", $missing_content);
<?php _e('Naam')?>*
<input type="text" name="message_name" value="<?php echo esc_attr($name); ?>" placeholder="Iemand Anders">

<?php _e('E-pos')?>*
<input type="text" name="message_email" value="<?php echo esc_attr($email); ?>" placeholder="iemand@iemandanders.com">

<?php _e('Boodskap')?>*
<textarea type="text" name="message_text" placeholder="Skryf asseblief jou boodskap hier."><?php echo esc_textarea($message); ?></textarea>
      It also gives me the > $missing_content error. This all tells me that somehow somewhere I must define name, email, text, human and submitted. And this is where my limited skills halts me. Any suggestions on how to define the above and to remove the errors and still have the form to work as it should. Before I forget, the complete code can be viewed here


Login redirect problem

hey i got a slightly weird problem.. i got a form enabling login in certain single's according to the cateory and user level.. it works great but the server which is windows (where the website is hosted on returns the wrong "current page" value Meaning.. this:               'redirect' => site_url( $_SERVER['REQUEST_URI'] ),       returns this: www.somewebsite.com/sub/sub/?p=100 instead of: www.somewebsite.com/sub/?p=100 **This is the actuall form:** > >               <div class="logincategory"> >                 <?php wp_login_form( $args ); >                  $args = array( >                 'echo' => true, >                 'redirect' => site_url($_SERVER['REQUEST_URI']), >                 'form_id' => 'loginform', >                 'label_username' => __( 'Username' ), >                 'label_password' => __( 'Password' ), >                 'label_remember' => __( 'Remember Me' ), >                 'label_log_in' => __( 'Log In' ), >                 'id_username' => 'user_login', >                 'id_password' => 'user_pass', >                 'id_remember' => 'rememberme', >                 'id_submit' => 'wp-submit', >                 'remember' => true, >                 'value_username' => NULL, >                 'value_remember' => false ); ?> >                 </div> >   > > **So..** this is a bug of the server which i can't solve directly **so i used** > $myCurrentUrl = site_url( $_SERVER['REQUEST_URI'] ); $myCurrentUrltwo = > str_replace("www.somewebsite.com/sub/sub/","www.somewebsite.com/sub/", > "$myCurrentUrl"); That (when eching) returns the right URL but how do i insert the variable into this command                   'redirect' => site_url( $_SERVER['REQUEST_URI'] ),


When is get_template_part() preferable to simply using the template.php files?

In this post on wordpress.stackexchange.com I asked whether using get_template_part(), as demonstrated in the TwentyTen theme, is a recommended best practice. The general consensus I got was that it was not necessarily the best practice in all situations. This related question then is: can you provide me with an example where using get_template_part() _would_ be the recommended approach, over simply defining the separate template.php files? For example, I can either define archive.php, single.php and page.php; or I can define loop-archive.php, loop-single.php and loop-page.php. In what circumstances would it be preferable to use get_template_part('loop', 'single') and leverage loop-single.php versus simply defining single.php?


I have over 3000 child pages - but I need a different main page

I set up my website using WordPress. The goal, to have about 70 pages directly linked to the main page (my landing page) and most of those pages having anywhere from 5 to 200 blogs coming off each of those. All seemed well and good until i realized that the reason I was seeing 'no parent' as the parent page of each of my 70 pages was because my main page is not a page at all, but merely a blog post! Oh, no, what to do! I tried creating an identical page to my initial blog main one. I also went into the settings>reading and checked off that I wanted the main page to land on this new page. I attempted to then begin transferring the 70 pages underneath that newly created page (copy of the original main blog). But I soon found out that it won't work, because when I go to the second tier of pages, the url shows three tiers. I want my second tier of pages to have urls that show only two tiers. this is what i want: ttp://www.mainpage.com/ ttp://www.mainpage.com/child-page/ ttp://www.mainpage.com/child-page/grandchild-page/blog but instead I have this: ttp://www.mainblog.com/newlycreatedpage/child-page/grandchild-page/blog I'm a complete newbie and not familiar with unusual jargon-like web building terms. Is it possible for me to change out the main blog landing site for a main web page, and switch the other child pages over to it so I can have a clean-looking url string? At this point I am considering trashing over 3000 pages and starting from scratch!


How to show a tag archive of one post type only

I have a site with multiple custom post types and taxonomies. The taxonomies are shared across all of the post types. On the archive page of the 'videos' post type, I want to show a list of all of the 'country' tags that are associated with videos. When this link is clicked on, I'd like to be able to go to an archive for that country but that only shows the 'videos', not the other post types that may have the same country tag. I also need to be able to do the same for other post types and taxonomies, e.g. when on the 'galleries' post type archive, a tag cloud is shown that links to the tag archive showing only the galleries. I think that this should be easy, but I just can't figure it out! Will I need to create archive templates that take arguments passed via the url? E.g. mysite.com/country/canada?type=video ..and then manipulate the get_tags function somehow? I really just can't get my head around this one. Cheers for your help.


How do you add custom logo to entire themes

I would like to add a custom logo to my entire blog network's dashboard. I went trough a recipe on smashing magazine and got this code:               //hook the administrative header output     add_action('admin_head', 'my_custom_logo');          function my_custom_logo() {         echo '           <style type="text/css">           #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; }           </style>         ';      }      Where do I add it? I think that I should add it in `functions.php`. But if so I should add the code to every theme in my mutlinetworks. Does any one have idea to add it to the entire network? I should also able to set only for a particular sub and not to entire network If I change my mind in future :) Thank you!


How to get the date dynamically from archive.php to date.php?

My **archive.php**               <?php wp_get_archives( array( 'type' => 'monthly', 'limit' => 12, 'show_post_count' => 1 ) ); ?>
      My **date.php**               $date1 = get_query_var('date');                        // The Query                   query_posts( array ( 'date' => $date1, 'posts_per_page' => -1 ) );                        // The Loop                  while ( have_posts() ) : the_post(); ?>
                     <?php the_time( get_option( 'date_format' ) ); ?>
                     <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?>

                        <?php endwhile;                        // Reset Query                   wp_reset_query();?>      but it show all the posts form the blog. how can I edit it to show the post from the proper year and month when some one click the link generated by arhive.php?


Custom Permalink: /year/month/post-goes-here/?

I'm experimenting with adjusting permalinks (for purely educational experimentation). What would I need to place in the "Custom Permalink" option to get my post URLs in the form... /year/month/post-title-goes-here/


Redirect to current page after wordpress login

I just want to redirect the users to their current page after logged in my wordpress website. I have used the following but it won`t work for me since it is in page that created from the admin side.               <?php echo wp_login_url(get_permalink()); ?>


WordPress Tag Page Hook?

Is there any hook for a tag page, so I can alter it's content before outputting?


Is it possible to split database tables using HyperDB?

I'm looking for an answer from someone who's implemented HyperDB or has knowledge of it. I have a database which has just passed the 100mb mark a week or so ago, the problem is my host only allows databases of 100mb a time. I was looking to implement HyperDB but wanted to find out some information first. My current database is around 100mb alone on the posts table of the database. If I implement HyperDB will this table get split between two databases?


Filter custom posts using auto populated dropdown selectors

I've created a custom post type named _agent_. I have a page that lists all agents. When I add an agent I have a whole series of custom meta boxes that can be filled out, region, specialty, language... I'd like to add a series of dropdown boxes on the front end that will populate with all the terms from each custom meta. For example a regions dropbox would populate with all the regions from all the agents. If I add a new agent in a new region, the dropbox will automatically pick that up. Thanks for looking.


WordPress missing user roles on local dev machine. Live site works fine

I have a live WordPress installation and a local one for development purposes. I just exported the live database, replaced all occurences of the live siteurl with the local one, and imported on my dev machine. Problem is that on my dev machine all users have lost any permissions. When logging in I get:               Notice: Undefined offset: 2 in /var/www/mysite/wp-admin/includes/plugin.php on line 1390       On a page template I dumped out the current userinfo with               global $current_user;     var_dump( get_currentuserinfo() );      This returns NULL on my dev machine and the correct userinfo on my live installation. I double checked the table prefixes, permissions, tried a clean WordPress installation, etc but had no luck. The confusing thing about this is, that I can query the userinfo perfectly fine with a custom sql query. EDIT: Upon further inspection I found out that the global $wp_roles contains no user roles and capabilities. WordPress somehow can't retrieve this from the database... EDIT 2: Sorry for the edits. But I found the problem. Inside the wp_options table there is a row "wp_user_roles". The value, an unserialized string did somehow include whitespaces which lead to errors when trying to unserialize the string. I replaced the database value with the live site's one and everything works now.


Add page title as a javacript variable to specific posts

I'm very new to WordPress and I'm sorry if this question may sound ridiculous. I need a way to add the post title into it's content, only in specific posts, and not always at the same place in the content. I've done some research, but all I find is about changing functions in .php files or in _The Loop_. I don't know if there are any kind of predefined functions, tags or code that can be used to print this type of information manually into the content. I tried including `<?php` code, but obviously is not the way as it gets commented (please correct me if I'm wrong). Ps: This is intended to be used by content publishers, SEOs, and people knowing almost nothing about programming.


Wordpress database synch between dev and prod

Question has been asked before about how to synchronize files as well as the database between two Wordpress installations. For the database level, the answer is usually to basically dump one database and insert it onto another server. The problem with this is that you end up losing any changes that have potentially been made on the prod server. For instance, usage metrics, comments, etc... With this in mind, I was starting to wonder whether the it would be possible to extend the Wordpress ORM so that you can generate deltas and then inject those into the prod site. Has anyone tried this, looking into it, or have any ideas or comments ?


How to edit attachment with media-upload.php?

I'm looking to edit an attachment and I'm trying to supply a link to the existing preview image.                    <img src="<?php echo $src_output; ?>" class="preview-upload"/>           I tried adding a **post_id** argument to the href but the thickbox only shows the media-upload box for a new upload. How can I edit an existing image using a link on the preview image?               <a href="media-upload.php?type=image&TB_iframe=true&post_id=<?php echo $id; ?>" ...


Unable to add TAB character to post?

I am using the CodeColorer plugin to display source code in my WordPress. I am trying to have my code indented so that it displays properly on the website. However, when I try to add the following code to the WYSIWYG editor:               [cc lang="csharp"]     using System;     using System.Collections.Generic;     using System.Linq;     using System.Text;          namespace LittleSoftwareStats     {         public static class Config         {             public static bool Enabled { get; set; }                  internal static string ApiUrl             {                 get                 {                     UriBuilder uri = new UriBuilder((Config.ApiSecure) ? ("https") : ("http"), Config.ApiHost, Config.ApiPort, Config.ApiPath);                          return uri.ToString();                 }             }             internal static string AppId { get; set; }             internal static string AppVer { get; set; }                  internal const string ApiHost = "stats.yourwebsitehere.com";             internal const int ApiPort = 80;             internal const bool ApiSecure = false;             internal const string ApiPath = "api."+ApiFormat;                  internal const string ApiFormat = "json";             internal const string ApiUserAgent = "LittleSoftwareStatsNET";             internal const int ApiTimeout = 25000;         }     }     [/cc]      When I update it, the code then becomes:               [cc lang="csharp"]     using System;     using System.Collections.Generic;     using System.Linq;     using System.Text;          namespace LittleSoftwareStats     {     public static class Config     {     public static bool Enabled { get; set; }          internal static string ApiUrl     {     get     {     UriBuilder uri = new UriBuilder((Config.ApiSecure) ? ("https") : ("http"), Config.ApiHost, Config.ApiPort, Config.ApiPath);          return uri.ToString();     }     }     internal static string AppId { get; set; }     internal static string AppVer { get; set; }          internal const string ApiHost = "stats.yourwebsitehere.com";     internal const int ApiPort = 80;     internal const bool ApiSecure = false;     internal const string ApiPath = "api."+ApiFormat;          internal const string ApiFormat = "json";     internal const string ApiUserAgent = "LittleSoftwareStatsNET";     internal const int ApiTimeout = 25000;     }     }     [/cc]      I have also tried replacing the spaces with ` `, and `	` and the actual TAB character. If I add the TAB character in the Text editor then it will stay but once when I switch it to the Visual editor then it is all removed. I was wondering if anyone knows a trick to keeping the code indented or if there's someway to fix it (without modifying the CodeColorer plugin)?


Theme Customization API and child themes

I've recently developed a parent theme that makes heavy use of the Theme Customization API. Is there an easy way to port these settings when a user activates one of my child themes? Currently, the data previously saved in the Customize screen disappears when activating a child theme. Of course, once they reactivate the parent theme, the settings return. Any dealt with this yet?


Code to auto expire posts after 30 days

I've tried the plugins that are available in the Wordpress plugins section but they seem to fail miserably. Initially, I used Auto Post Expire By User Role which worked for a time, but for some reason now it doesn't. What I want is to add a code in functions.php that will automatically set as drafts posts which are 30 days older than their published date. I have the following code but don't know if this is the one that I should be using. Is this correct and if not, what is the correct form?               function expire_posts() {     global $wpdb;     $daystogo = "30";     $sql = "UPDATE wp_posts SET `post_status` = 'draft' WHERE `post_type` = 'post' AND DATEDIFF(NOW(), `post_date`) > '$daystogo')";     }          add_action('wp_head', 'expire_posts');


What's the best way to show custom post types? With page template it's not perfect!

I created a custom post type with name career. I would like to know what's the best way to list the posts. I created a page template with a query inside, but the pager is invisible. I don't know what's wrong.

                     Position	                     Location	                     Close date	                     View details
             <?php $mypost = array( 'post_type' => 'career', );             $loop = new WP_Query( $mypost ); ?>             <?php while ( $loop->have_posts() ) : $loop->the_post();?>             <?php                  $custom = get_post_custom($post->ID);                 $location = $custom["location"][0];                 $close_date = $custom["close_date"][0];             ?>             <tr id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                 <?php the_title(); ?>	                 <?php echo $location; ?>	                 <?php echo $close_date; ?>	                 <a href="<?php the_permalink(); ?>" title="Details">> Details
             <?php endwhile;  ?>
<?php next_posts_link( '← Older'); ?>

<?php previous_posts_link( 'Newer→' ); ?>

      How do you list your custom post types with pager?


Limit user to one comment

is there a nice function I can use to limit logged in users to one comment per post? I'm setting up a review system and only one review permitted per user. Thanks.


How to detect if a viewer is not registered/not logged in and prompt the viewer to register/sign in?

I want to "lock" a certain portion of my website (i.e., user reviews) only to users who are registered and logged in. This is similar to what Quora does. However, this is not just a simple restrict content. I want to be able to detect the user scrolling down and as he scrolls down, start to blur and restrict content while asking him to register/log in to view more. Again, like how Quora does. However, for viewers I want to show a blurred background of the content (as a teaser, if you will) of what it will look like, but require them to register/log in first: ![screenshot](http://i.imgur.com/XYQbgrl.png) I am working with Wordpress/PHP -- I've googled for hours but can't find a plugin or solution for this.


Check Paypal Purchase is Success or Not in Easy Digital Download Plugin

I trying to do something for every purchase of corresponding product in easy digital download. Let say i need to add the auto random discount code for every purchase made in easy digital download. I tried with different hooks. But still i didn't get the correct callback on success process of paypal. Let i make it alert on success callback of paypal. what i am trying is something like this               if($paypal == 'success') {     //do something     } else {     //do something     }     function pw_edd_on_complete_purchase($payment_id) {              // Basic payment meta         $payment_meta = edd_get_payment_meta($payment_id);         ?>         <script type="text/javascript">             alert("this is for payment");         </script>         <?php              // Cart details         //$cart_items = edd_get_payment_meta_cart_details($payment_id);              // do something with payment data here     }          add_action('edd_complete_purchase', 'pw_edd_on_complete_purchase');      But i am not sure how to do this. I have the product which name as gift card let say $5. If the user purchased this gift card then he/she get the random code of discount for purchasing some other product in future. Can anyone tell me which hook is achieving the above criteria ? Any Suggestion would be great thanks


Retrieving Image Storage path

$attachment_id = 8; // attachment ID     $image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array      Could you please specify which database table is referred for to retrieve the image source url?


JSON API : Add a method called create_user to create a new user

First of all I would like to thank **Dan Phiffer** for providing such a wonderful plugin. I have installed the JSON API Plugin on my blog and it works and post perfectly. The problem that I need to add a method called create_user to create a new user. Can someone give me the steps to add such method to JSON API. Thanks for all :)


Approve Page Edits

I'd like to create a role group where users can edit pages and submit them for approval before they are displayed on the website. I've used the following roles (shown below) but they don't allow me to approve page edits. Is it possible to create a role where a user can edit pages and then have the edits be approved by me before being shown on the website?               edit_pages     edit_published_pages     edit_others_pages


/tag/tag_name/page/2 gives a 404 error

I created my own template for list of entries for certain tag (`tag.php`), It will shows up 10 entries, and with Previous & Next link.               <?php     $paged = get_query_var('paged') ? get_query_var('paged') : 1;     $args = array(     'post_type'     => 'custom_post',     'posts_per_page' => '10',     'tag'           => "$some_tag",     'paged'         => "$paged",     'post_status'   => 'publish',     'orderby'       => 'date',     'order'         => 'ASC'     );           $loop = new WP_Query($args);     while($loop->have_posts()): $loop->the_post();     // displaying items here     endwhile;     <nav id="page-nav">         <?php previous_posts_link('≪ Previous', $loop->max_num_pages); ?>         <?php next_posts_link('More ≫', $loop->max_num_pages); ?>     </nav>     <?php endif; ?>     ?>      It creates a `More` link with `/tag/ta_name/page/2` but when i click on it, it shows 404. I've checked on other blogs, tag archives pagination indeed ends with `/page/N` so i guess there is no problem with my url. Where did i make the mistake or any of my settings is wrong?


Tables not showing divs and loop/php items

I know this is an absurd questions, as who uses tables anymore? I got handed this and just need to make it work really. I don't know anything about tables so it's been a learning experience. I finally got my loop to show up but only parts of it. I'm missing some crucial items and can't figure it out. Example: post title shows up but its not a hyperlink. I tried to put these in the post but they broke terribly so I used pastebin. I guess cause the tables? lol blog.php can be viewed here: http://pastebin.com/fYyhGMYa Live version: http://elite.ikvclients.com/blog/ Really appreciate any insight or help. This is confusing as hell.


How to auto send email when publishing a custom post type?

I'd like to have an email automatically sent out to my website's subscribers when I publish a post for a specific custom post type. I've found a few plugins that will do this but only for regular posts (or for any post type that gets published, not allowing you to specify a particular post type). Any suggestions would be greatly appreciated! Thanks.


Automatic linking terms

I am trying to link words that show up anywhere on the website to go to a pre- defined internal url. In the post editor the author is able to choose a product from a drop-down menu using custom fields to add to the post. Client-side, all the products chosen display inline separated by a comma. There is no limit to the amount of products that can be listed, and those names include hyphens and/or slashes. Example: AWESOME-2000 or RAD3/45 I have tried a variety of automatic linking plugins (such as ultimate seo and seo smart links) and all fall short in either being able to handle special characters in the term or they don't link anything in custom fields. Does anyone have a suggestion of what else to try? I'm even willing to try adding a hook from functions.php to swap terms from a pre-define list, but I don't author php yet so have no idea where to start on that front (hence looking for plugin).


do_shortcode() doesn't work if shortcode contained in variable, works if shortcode passed as string

I'm developing a plugin, wherein one of the features is to switch out forms on a specific page by changing the shortcode within a custom field. within my plugin file:               function getShort()     {         global $post;         $m = get_post_meta($post->ID, 'short', true);         return $m;     }      within my theme file:               $short = getShort();     echo do_shortcode($short);      With the code above, it just prints out the shortcode. If I echo the value of $short, copy and paste that as the argument for do_shortcode(), it prints out the expected value. I am 100% confident that the value of $short is a string, and is the correctly formatted shortcode. Any idea why this doesn't work?


How 'secure' are loops?

I am using loops as means of displaying personal meta and customer information on the frontend. For example, I have a page which displays a user's 'profile' information to edit. Their profile is custom post type that was created when the registered. The loop for the edit screen finds the one cpt based on the current user id, populates the form fields, and after submission updates the post. Is this secure? If not what some better ways to handle this type of action? *--Edited to include example code Here is a sample loop. This is pulling in a vendor's items they sell. The GF hooks pre-populate the form in the middle with the meta from the product, after submission the post is updated.               <?php     $q = new WP_Query( array( 'author' => $current_user->ID, 'post_type' => 'product' ) );       if ( $q->have_posts() ) {           while ( $q->have_posts() ) {              $q->the_post( ); ?>                   <div id="<?php the_id(); ?>" class="tab_content_trip" style="display:none;">                    <?php echo do_shortcode('[gravityform id="7" title="false" description="false"  ajax="true"]'); ?>              </div>                  <?php }        wp_reset_postdata();     } ?>      So my question is if it is possible for someone to somehow hijack a loop like this and edit other users posts in some way? (of course not including if they somehow steal their password, or something of that nature) Essentially, I am seeking some insight on best practice for securely filtering user information to be displayed on the frontend


Calculate percentage of post by category

Is it possible to calculate the percentage of posts in each given category? I'd like to make a bar chart to visualize the amout of posts in those categories. I thought what one needs would be the total amount of posts, the amount of posts in each category and then a PHP function that calculates percentages with those values and applies a variable to it which I need to use when building the bar chart. I am not very familiar with extended PHP, so if anyone could show me the right direction, I'd be grateful


How to upload images using Settings API

I want to allow users to upload images for use in a rotating banner. I tried using the media library, but didn't get much help ... So I thought, I'd just implement the upload myself. But I encountered another problem... I am using the settings API they do the update options and stuff for me. How can I handle the upload then? I thought of using the validate callback to upload images and then set $_POST variables manually so that Settings API can save those. But it sounds wrong. Any ideas?


Does WordPress validate inputs to all functions? (such as get_user_meta and insert_user_meta)

Does WordPress validate inputs made to all built-in functions that access the database to protect against SQL injection vulnerabilities or do we have to validate before passing them?


Taxonomy filter all children

I have a custom taxonomy filter that will filter all the pages in the selected taxonomy. I would like the code to select the pages in that taxonomy, and the children of thous pages. Heres the code.               add_action('restrict_manage_posts', 'restrict_manage_posts_section');     function restrict_manage_posts_section()     {         global $post_type;         if ( is_object_in_taxonomy( $post_type, 'section' ) )         {             $dropdown_options = array(                 'show_option_all' => __( 'View all sections' ),                 'hide_empty' => 0,                 'hierarchical' => 1,                 'name' => 'section',                 'show_count' => 0,                 'taxonomy' => 'section',                 'orderby' => 'name',                 'selected' => $cat             );                  add_filter('wp_dropdown_cats', 'wp_dropdown_section_filter', 10);             wp_dropdown_categories( $dropdown_options );             remove_filter('wp_dropdown_cats', 'wp_dropdown_section_filter', 10);         }     }          function wp_dropdown_section_filter($select)     {         $terms  = get_terms('section', array('hide_empty' => false));            foreach( $terms as $term )         {             $select = str_replace('value="'.$term->term_id.'"', 'value="'.$term->slug.'"', $select);             if (isset($_GET['section']) && $term->slug == $_GET['section']){                 $select = str_replace('value="'.$term->slug.'"', 'value="'.$term->slug.'" selected', $select);             }         }            return $select;     }      EDIT Here is my Custom Post Type and Taxonomy Function               /* Register Custom Post Type and Taxonomy     ---------------------------------------------------*/     add_action('init', 'register_module_type');     function register_module_type() {         $labels = array(             'name' => _x('Modules', 'post type general name'),             'singular_name' => _x('Modules', 'post type singular name'),             'add_new' => _x('Add Module', 'module item'),             'add_new_item' => __('Add Module'),             'edit_item' => __('Edit Module'),             'new_item' => __('New Module'),             'view_item' => __('View Module'),             'search_items' => __('Search Module'),             'not_found' =>  __('Nothing found'),             'not_found_in_trash' => __('Nothing found in Trash'),             'parent_item_colon' => ''         );              $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             'rewrite' => array( 'slug' => 'module', 'with_front' => false ),             'capability_type' => 'post',             'hierarchical' => true,             'has_archive' => true,             'can_export' => true,             'menu_position' => null,             'supports' => array('title','editor','thumbnail',/*'excerpt',*/'revisions','custom-fields','post-formats'/*,'page-attributes'*/)             #'taxonomies' => array('category', 'post_tag')         );               register_post_type( 'module' , $args );         #register_taxonomy_for_object_type('category', 'testimonial');         #register_taxonomy_for_object_type('post_tag', 'testimonial');              $labels = array(             'name' => _x( 'Sections', 'taxonomy general name' ),             'singular_name' => _x( 'Section', 'taxonomy singular name' ),             'search_items' =>  __( 'Search Sections' ),             'all_items' => __( 'All Sections' ),             'parent_item' => __( 'Parent Section' ),             'parent_item_colon' => __( 'Parent Section:' ),             'edit_item' => __( 'Edit Section' ),             'update_item' => __( 'Update Section' ),             'add_new_item' => __( 'Add New Section' ),             'new_item_name' => __( 'New Section Name' ),         );                register_taxonomy( 'section', array( 'module' ), array(             'hierarchical' => true,             'labels' => $labels,             'show_ui' => true,             'query_var' => true,             'rewrite' => array( 'slug' => 'section' ),         ));              #add_theme_support( 'post-formats', array( 'chat','aside','gallery','link','image','quote','status','video' ));         flush_rewrite_rules( false );     }


Plugin - Social media share buttons

Is there a plugin with the social media share buttons where I have more control of where to place them? At the moment, the only one's I can find only allow you to place the buttons at the top or bottom of pages/posts. Ideally I'd like a snippet of code to just place wherever I wanted.


Custom Post Type with Custom Title

I have a custom post type without title support and I'm trying to generate one from post's taxonomies and custom fields. To do so, I'm using this code:               function custom_post_type_title_filter( $data , $postarr )         {           if ($postarr['post_type'] == 'cars'){                 $id = get_the_ID();                 $engine= ', '.get_post_meta($id, 'Engine', true).'l';                 $terms = wp_get_object_terms($id, 'brand');                 $abrand= ' '.$terms[0]->name;                 $amodel = ' '.$terms[1]->name;                 $data['post_title'] = $id.$abrand.$amodel.$engine;           }           return $data;         }         add_filter( 'wp_insert_post_data' , 'custom_post_type_title_filter' , 99, 2 );      Problem is, to make it work, I have to republish my post. It does not work with new post (it has no ID yet, I guess) and if I change custom field values in post, it won't generate name from them yet, I'll have to save it twice to get it done. Can someone share a solution with example how it's done properly? Also, would be nice to be able to set custom slug too (different from the title).


How to show Best Selling WP E-Commerce Products

I'm trying (but failing) to create 'Best Sellers' and 'New Releases' pages for my website. I'm using WP-Ecommerce 3.8.4 with WP 3.1.3 and I've gotten close but can't seem to get it right. Any help on this would be greatly appreciated... I've added the following code to wp-ecommerce>wpsc-includes>product- template.php (original code from here):               //Popular products function     function popular_products ( $atts ) {     //Expose the Db to the function     global $wpdb;     //Get the results     $pp = $wpdb -> get_results ( "SELECT prodid, SUM(quantity) FROM {$wpdb->prefix}wpsc_cart_contents GROUP BY prodid ORDER BY quantity DESC LIMIT {$atts['limit']}", ARRAY_A);     //Loop through the results     foreach ( $pp as $item ) {     //Output it     ?>     <img alt="<?php echo wpsc_the_product_title ( null, null, $item['prodid'] )?>" src="<?php echo wpsc_the_product_thumbnail ( null, null, $item['prodid'] )?>" />     <?php echo wpsc_the_product_title ( $item['prodid'] )?>     <?php     }     }     add_shortcode ( 'dm_popular', popular_products );           //END OF POPULAR PRODUCTS       I've then added [dm_popular limit=5] to the best sellers page (http://www.iconiccanvasart.co.uk/best-sellers) but as you can see it's not quite working properly:   1. one product can appear multiple times if it's been ordered in different variations.   2. it isn't retrieving the Products title properly (all are outputted as 'Best Sellers').   3. Ditto for the image Alt tags.   4. I've not added a URL to the products yet as not sure how to at the moment. Once I've this working I'm hoping to alter slightly and have a 'New Releases' page based on a similar query (so any help on this may help to killing two birds with one stone). Any help would be greatly appreciated. ChainsawDR EDIT: I've since managed to get this all working bar the price and product text - final code can be viewed here: http://getshopped.org/forums/topic/bestselling-products/


Is there a need for nonce with Post Metabox?

I looking at the docs for `add_meta_box`. They used a nonce.               wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );      I am wondering, probably the save post form itself should already have a nonce so this is redundant?


How to Use WordPress as Static CMS Without Blog Posts

I am very new to **wordpress**. I want to edit a wordpress theme and remove the blogpost area from it so it can be converted into a website. I also want to make some other changes. How I am trying to do it is, > " I viewed the HTML code of my page and pasted in Dreamweaver and edited it. > Now I am stuck with how to upload it." Please help me out. If there is a better way to do it please suggest. Thanks


Metadata Query when storing data as array possible?

Suppose I store all my post meta data in an array like               $meta = array(         'img' => '',         'caption' => ''     );          update_post_meta($post->ID, 'theme_banner', $meta);      Can I query posts where the img is filled?


Changing the template hierarchy

Is there an easy way to change the WP default template hierarchy? For instance; Say I want to change my theme directory structure so that it completely changes from the Template Hierarchy suggested here based upon conditionals: http://codex.wordpress.org/Template_Hierarchy If I wanted to make sure that for all page types (`is_single()` `is_home()` etc) it always opens one template file which then instigates my own pattern to provide the output? Thanks very much!


Getting a role based on a localized role name

I use the following code to get the Administrator role               $admin = get_role('administrator');      This works fine, but on a different WordPress language setup, this code breaks. For example, in French it should be               $admin = get_role('adminstrateur');      Any cross-language solution?


Loop through posts of a custom-post-type (event) and create .ics (iCal) file?

I really need your help with a feature I have never worked with so far. I have a custom-post-type named `wr_event`. And I created this custom `WP_Query` to retrieve all posts for this post-type that are "younger" than yesterday. Fairly simple and this works like a charm.               function event_list_iCal() {              $yesterday = time() - 24*60*60;         $args = array(             'post_type' => 'wr_event',             'posts_per_page' => -1, // show all posts             'meta_key' => 'event_date',             'orderby' => 'meta_value_num',             'order' => 'ASC',             'meta_value' => $yesterday,             'meta_compare' => '>',         );              $loop = new WP_Query( $args );         $ical = "BEGIN:VCALENDAR         VERSION:2.0         PRODID:-//hacksw/handcal//NONSGML v1.0//EN";              $posts = get_posts( $args );         foreach( $posts as $post ) : setup_postdata($post);             $ical .= "BEGIN:VEVENT             UID:" . md5(uniqid(mt_rand(), true)) . "mysite.com             DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z             DTSTART:".unixToiCal(get_event_date($post), get_event_time($post))."00Z             DTEND:".unixToiCal(get_event_end_date($post), get_event_end_time($post))."00Z             SUMMARY:".get_the_title($post->ID)."             DESCRIPTION:".get_the_content($post->ID)."             END:VEVENT";         endforeach;              $ical .= "END:VCALENDAR";              header('Content-type: text/calendar; charset=utf-8');         header('Content-Disposition: inline; filename=calendar.ics');         echo $ical;         exit;     }          function unixToiCal($uStamp = 0, $tzone = 0.0) {         $uStampUTC = $uStamp + ($tzone * 3600);                $stamp  = date("Ymd\THis\Z", $uStampUTC);         return $stamp;            }       I use this function call in my `index.php` to list all "upcoming" events. _**Creating a .ics file._** There is another feature that I'd like to have. I want to create a .ics (iCal) file on the fly with all "upcoming" events. So I guess this shoudln't be to hard as I already have the query. Any ideas on that matter? I would really appreciate some help with this. **Update:** I have two more problems with the .ics Calendar file. I have a function `get_event_date($timestamp)` that returns a timestamp of the event-date. However there is a (for me) rather complicated part in it. There are two variables `$date[0]` and `$time[0]` that hold different formats. The `$date[0]` holds a timestamp `1347667200` and the `$time[0]` holds a string e.g. `14:00`. I now need to calculate the final timestamp of the "date" plus "time" to pass it along to the `unixToical()` function.               if ( $timestamp ) {                  if ( !empty( $time[0]) ) {                     $time = explode(':', $time[0]);                     $hours = $time[0];                     $minutes = $time[1];                 } else {                      //$hours = "00";                     //$minutes = "00";                 }                 $seconds = "00";                 return $date[0] + ($hours * 60)  + $minutes;                 exit;             }      The part where I set `$hours` to "00" is for when there is no time set. In that case I want to time in the final .ics to be "00:00" (midnight). Any idea what I'm doing wrong here. I guess this might be the problem why when importing the calendar file to iCal only the first event is imported. (When opening the file with a text-editor all events are in there)


Display attachment, post and page in recent comments widget

The following code (old post is here and author is diggy) is useful, but i'd like display post and page on recent comments widget, not only attachments.               function wpse80087_widget_comments_args( $args )     {         $args = array( 'number' => 5, 'post_type' => 'attachment', 'status' => 'approve', 'post_status' => 'inherit' );         return $args;     }     add_filter( 'widget_comments_args', 'wpse80087_widget_comments_args', 10, 1 );      Is it possible? * * * SOLUTION: Thanks to Pieter Goosen and Birgire. **First step:** Plugin **Second step:** function.php               function wpse80087_widget_comments_args( $args ) {         $args = array(             'number' => 9,             'post_type' => array('attachment', 'post', 'page'),         );         return $args;     }     add_filter( 'widget_comments_args', 'wpse80087_widget_comments_args', 10, 1 );


Facebook fanbox problem

I have added Facebook fanbox to my site but it causes performance problems. Is there a plugin that embeds the fanbox and loads the javascript in the footer and asynchronously (if possible)? If not, can I do it manually somehow? I want to load the js file from the footer but the fanbox to appear in an upper section of the page. Thanks in advance


Migrating WPMS from apache to IIS7 causes Database Error

## _// Be sure to read the updates at the bottom_ I have a large multisite installation hosted on XAMPP on an XP 2003 server and am trying to move it from XAMPP/Apache to a new Windows 2008 server with IIS7. I can successfully get fresh installs of WP up and running and can get multisite working perfectly. When I import my old WPMS MySQL database and change the `DB_NAME` in my `wp-config.php` file to have the old WPMS database instead of the new WPMS database, I'm hit with "Error establishing database connection" Here are my `wp-config.php` settings:               // ** MySQL settings - You can get this info from your web host ** //     /** The name of the database for WordPress */     define('DB_NAME', 'migrated_DB_2012');          /** MySQL database username */     define('DB_USER', 'wpms_user_2012');          /** MySQL database password */     define('DB_PASSWORD', 'wpms_password');          /** MySQL hostname */     define('DB_HOST', 'localhost');          /** Database Charset to use in creating database tables. */     define('DB_CHARSET', 'utf8');          /** The Database Collate type. Don't change this if in doubt. */     define('DB_COLLATE', '');      I've double checked the username & password and even changed them several times to make sure they matched up. I've tried `localhost`, `127.0.0.1`, and the IP address of my server itself for the DB_NAME. Nothing. * * * ## _/* UPDATE */_ I've successfully connected to the database finally! Visiting the front page of the domain (http://domain.com) gave me the **Error establishing database connection** message, but trying to visit the dashboard/admin area (http://domain.com/wp-admin) helped me see the problem. In my many DB/user name changes, I neglected to give full permissions to `wpms_user_2012` on `migrated_DB_2012`. **D'OH!** _ ### // New Problem _ I still get the database error when visiting the front page, but now when I visit `/wp-admin`, I see the following: > _One or more database tables are unavailable. The database may need to be > repaired._ When I follow the "repair" link, it walks me through the auto-repair sequence, but since this is a multisite installation, it skips over a few tables and tells me the following tables don't exist:   * wp_posts    * wp_comments    * wp_links    * wp_options    * wp_postmeta    * wp_terms   * wp_term_taxonomy   * wp_term_relationships   * wp_commentmeta Only, these tables **do** exist, but they exist as: `wp_1_posts`, `wp_1_comments`, etc. What should the next steps be to get my migrated DB to work properly? * * * ## _/* Let me explain a little more */_ For this installation, I started from scratch with a fresh install of WP, set it up with a network and then copied the old `/blogs.dir` over to the new `wp- content/`. _(Reasoning for fresh install: I believe my old site had been hacked and I wanted to prevent any compromised core files from being transferred over to the new server.)_ Next, I imported my old database (`migrated_WPMS_database`) into MySQL via phpMyAdmin, gave the appropriate privileges to the `wpms_user` and set up `wp- config.php` with the proper database/user/password information. I ran the WP repair and you can see my **// Update** for the results. Basically, it was telling me that the main site's tables weren't there: I've read that the "repair" feature doesn't work well with WPMS because it looks for `wp_[tableNames]` instead of `wp_1_[tableNames]`. Am I mistaken? After this, I even went through phpMyAdmin and ran it's built in "repair", also. I can still connect successfully to the fresh install's database (`test_database`) if I change `wp-config.php` accordingly. So, it **is** seeing that it is a network and it **is** able to connect to the database server successfully, too. Based on the WP Repair results, it seems WP is still looking for `wp_[tableNames]` instead of `wp_1_[tableNames]`, is that right? Why would it do this? There's got to be something I'm missing inside the migrated database's tables or something, because of the message I receive when trying to access `wp-admin`: > _One or more database tables are unavailable. The database may need to be > repaired._ If it helps, my OLD site was set up as WPMU back before the merge, so the OLD `wp-config.php` is set up slightly different, and if I use it instead of the newer 3.3 `wp-config.php`, my front-end becomes a blank screen and I'm able to get to the wp-login screen ... but it just puts me into a redirect loop back to the login page.


Wordpress contact form 7 to show the form dropdown menus as like

I am using contact-form-7 plugin for one of my form in the site. In that I have some dropdown options. The option are mainly consists of some come courses with their names. Like `course 1, course 2, course 3, course 4....so on`. But I want that my course field should be seen like this **Course A:**                 course 1       course 2       course 3       course 4      **Course B:**                 course 1       course 2       course 3      **Course C:**                 course 1       course 2      **Course D:**                 course 1       course 2       course 3      Currently I have done this type of fields in my contact-form-7 plugin Course applied for`[select courser-applied class:course-applied "Course A" "course 1" "course 2" "course 3" "course 4" "Course B:" "course 1" "course 2" "course 3" "Course C:" "course 1" "course 2" "Course D:" "course 1" "course 2" "course3"]` But this one is not working as I want that course A,course B, course C, course D should come in strong character in dropdowns . So can someone kindly tell me how to do this? Here how I want my form dropdown should look like http://i43.tinypic.com/20b01hs.png


Wordpress 3.6 Video shortcodes in template

I understand the video shortcodes work fine when inserted into a post. Easy. What about when you want to have more control about where the video should be displayed. I would like to use something like:               do_shortcode('[video webm="http://mb2013.mercerbell.com.au/wp-content/uploads/2013/10/sample_mpeg4.webmhd.webm" width="640" height="360" autoplay="true" loop="true"]')      or using the prebuilt WP function:               wp_video_shortcode( array('webm'=>'http://mb2013.mercerbell.com.au/wp-content/uploads/2013/10/sample_mpeg4.webmhd.webm") )      Neither of these solutions seem to work. As anyone else managed to get this to work? Outside of the embedding it in a post scenario? Much Appreciated.


get current order details

I need to get the current order details after someone clicks on the checkout button.I have tried to use hook `"woocommerce_after_checkout_validation"` and then tried to get order details in there,here is my code :               add_action('woocommerce_checkout_process', 'connect_woo_part');          function connect_woo_part()     {         global $wpdb;         global $woocommerce;              $args = array(         'post_type' => 'shop_order',         'post_status' => 'publish',         'meta_key' => '_customer_user',         'posts_per_page' => '-1'         );     $my_query = new WP_Query($args);     $customer_orders = $my_query->posts;           foreach ($customer_orders as $customer_order) {      $order = new WC_Order();           $order->populate($customer_order);      $orderdata[] =$order;     }          print_r($orderdata);      But it's showing old results.


How can I grab and show the reader comments of my site

How can I grab and show the reader comments of my news site in a different page? Suppose, I have comments on a news site, into my posts. I want to show the comments (only the comments) into a different page of my site. How can I show all the news comments of my site?


Multisite: Redirect Subsite Administrator to Subsite Home Page, Bypassing Dashboard

The subsite administrators of my multisite installation want to go directly to the subsite home page upon login, bypassing the dashboard. Irrespective of the wisdom of this, it's what they clearly want to do. I have attempted to implement the suggestions found in the following two posts (among others) without success: http://stackoverflow.com/questions/8127453/redirect-after-login-on-wordpress Multisite - Redirect All Users to Subsite Home Page on Subsite Login (including removing the "if (is_admin)" code ). This seems like it should be straight-forward, but I am struggling. Any guidance would be most appreciated.


Accessing an API with jQuery and AJAX

As a proof of concept I'm trying to access an API using jQuery and AJAX and posting the results to a page. After following some online tutorials and doing my best to put it all together, I have the following: functions.php:               //Fire Customizr     require_once( get_template_directory() . '/inc/init.php' );     function my_init() {         if (!is_admin()) {             wp_deregister_script('jquery');             wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.3.2', true);             wp_enqueue_script('jquery');                  // load a JS file from my theme: js/theme.js             wp_enqueue_script('instant_search', get_bloginfo('template_url') . '/js/instant_search.js', array('jquery'), '1.0', true);                  wp_localize_script( 'my_js_function', 'my_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );              }     }     add_action('template_redirect', 'my_init', 'init');          $dirName = dirname(__FILE__);     $baseName = basename(realpath($dirName));     require_once ("$dirName/twitter_search.php");     add_action("wp_ajax_get_my_option", "get_my_option");      twitter_search.php:               $username = (empty($_REQUEST['username'])) ? FALSE : $_REQUEST['username'];          function get_my_option(){         if($username !== FALSE){             $url = 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name='.$username.'&count=5&include_entities=1&include_rts=1';             // Get cURL resource             $curl = curl_init();             // Set some options             curl_setopt_array($curl, array(                 CURLOPT_RETURNTRANSFER => 1,                 CURLOPT_URL => $url             ));             // Send the request & save response to $resp             $resp = curl_exec($curl);             // Close request to clear up some resources             curl_close($curl);             if($resp){                 echo json_encode($resp);             }         }     }      instant_search.js               jQuery(document).ready(function(){         var user = $('#username');         var result = $('#resp');         $('#grab').click(function(){             if(user.val() !== ''){                 var config = {                     username: user.val()                 }                      function my_js_function(){                     jQuery.ajax({                         url: my_ajax_script.ajaxurl,                         dataType: "json",                         data: ({action : 'get_my_option'}),                         success: function(json){                             for(x in json){                                 result.append(json[x].text);                             }                         }                     })                 };                  }         })      });      Page post in WordPress:               <input type="text" id="username">     <button id="grab">Grab!</button>     <div id="resp">          </div>      I feel like I'm close to right, but a little in over my head when it comes to troubleshooting this. Any help would be greatly appreciated.


How to create custom Admin Pages for Custom Post types and add meta boxes

What I'm trying to do is :   * Create custom Admin Menus and Submenus add_menu_page Test add_submenu_page Add New no problem so far, both pages appear in the menu. Now I'm not sure how to add the metaboxes: post-title, post-content (as big textarea field not the editor), post_submit_meta_box after reading this tutorial -> standard-wordpress-metabox I started playing around with this code:                   if (is_file('includes/meta-boxes.php'))         require_once('includes/meta-boxes.php');         else         require_once(ABSPATH .'wp-admin/includes/meta-boxes.php');                        add_action("admin_menu", "my_add_menu_items");         function my_add_menu_items()         {         $submenu = add_submenu_page("edit.php?post_type=texte", "Add Text", "Add Text", "edit_posts", "texte", "display_my_test_page");              add_action('admin_print_scripts-'. $submenu, 'custom_page_admin_scripts');              function custom_page_admin_scripts() {         wp_enqueue_script('post');         }         }              function display_my_test_page()         {         do_meta_boxes("texte", "normal", null);         }              add_action("load-texte_page_texte", "my_add_metaboxes");         function my_add_metaboxes()         {              add_meta_box('categorydiv', __('Test Tags'), 'post_categories_meta_box', 'texte', 'normal', 'core', array( 'taxonomy' => 'text_from' ));         add_meta_box('submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'texte', 'normal', 'core' );         }      The taxonomy metabox appears and i can switch tabs and add new items, but if i add a new item i have to refresh the page for it to appear in the tax list.   * Isn't there an easier way to create custom pages with standard metaboxes ? ifnot   * How can i find out which meta box in `wp-admin/includes/meta-boxes.php` needs which javascript code ?   * Why do I need to refresh the page to see added terms in my code example ? Thanks in advance


I need captcha implemtation for any custom form in wordpress

need captcha implementation for any existing custom form in wordpress. I have already a form in my plugin where I need one captcha to be added. Please let me know the procedure to implement.


How to change the format of posts on the hompage?

I want to edit the format of how posts are display only on the homepage of a Wordpress site but I can't seem to find which template it is that is being used. I'm using the Twentytwelve theme as a base to create a custom theme. Also when I say the format, I don't mean the post format (ie. bold), I mean the style so changing things around and adding different CSS attributes to elements, that sort of thing. Any help would be greatly appreciated. Thanks!


Media Upload to Subdomain does not upload correctly

I am setting up Media Upload to subdomain, but the actual image will not upload correctly. Wordpress-site: /home/site/www (http://sitename.com)   Media-site: /home/fxsite/www/ /http://fx.sitename.com) I have set upload path to http://fx.sitename.com/img in WP settings. When uploading a media file through the Media Library, the media file gets uploaded to http://sitename.com/img/image.jpg, but the URL becomes http://fx.sitename.com/imag/image.jpg So the file gets the correct URL, but is uploaded to the wrong place. I've followed guides for placing media uploads in subdomain, but I don't understand why it doesn't upload to the correct place. Is it because they are in different folders on the server? Any suggestions?


Uploading PDF file and providing download links to them

One of my clients has a number of documents in PDF format that he wishes to provide download links to on his site. One solution I have been toying with is to treat them similar to images and upload them through the media uploader provided with WP and then provide a named link to the file. I would like to know if the above method is a good way or is there a better way to do this. Moreover, from a maintainability point of view dumping PDF files with images is not exactly the best way to manage these files so it would be good to partition these files into a separate directory. I am also interested to know if there are any plugins available to do this. Thanks in advance. nav


How to post form in ajax mode and handle it in wordpress

currently I can only do it in a normal non-wordpress way. So, does wordpress provide a solution for this circumstance?


Nested comments in WordPress theme

I'm creating own theme to WordPress. Got problem with nested comments. I have enabled option in admin panel for two levels. And what next? I've read a lot of net articles but nothing helpful. I want to create own comments template. comment_reply_link() function not working, I'm stupid as sh*t in it. How I can do it with no pasting written code from net into function.php. And how get level of comment? Please about help.


How to display child page from specific parent page in homepage?

How to display child page from specific parent page in homepage ? This is my page structure               Home     About Us     Hotel Category       Hotel A         Room 1         Room 2       Hotel B         Room 1         Room 2       Hotel C         Room 1         Room 2     Contact Us      And i try to achieve this at homepage(parent page is Hotel Category : id=8)               Hotel A     Hotel B     Hotel C      List Hotel A, Hotel B and Hotel C with some except and thumbnail image(this magic field)


Internationalize plugin so strings can be translated in WPML

A third party developer made a text widget with title, body and thumbnail. This accompany widget plugin has not been internationalized and therefore the strings do not appear in WPML's string translation management. I need them to be loaded. So I am trying to register the plugings domain as indicated here, but the code I added:               function accompany_text_init() {         $plugin_dir = basename(dirname(__FILE__));         load_plugin_textdomain( 'accompany-text', false, $plugin_dir );     }     add_action('init', 'accommpany_text_init');      does not load. It seems as the widget is not registered. Here is the full code. What am I doing wrong? Is the call position off? A plugin coding newbie here and a junior PHP-er so would appreciate some help.


Remove posts after a given amount of time

guys what I'm trying to do is run a series of if checks in the code before executing a series of functions and custom code. One of these if checks will check to see if a post already exists and if so it will then check how old the post is and if the post is say over 48 hours in age it will delete that post and recreate a new one. Something to the effect of:               global $wpdb;          if ( !is_user_logged_in())        echo 'You must be logged in.';          // check if title $my_post_name already exists in wpdb     else if ( is_user_logged_in()&& $wpdb->get_row("SELECT post_title FROM wp_posts WHERE post_title = '" . $my_post_name . "'", 'ARRAY_A')) {          // then check age of the post? assign age to a variable?       $time = age-of-post?          if $time >= 172800 // in seconds     code:  delete the post and create a new one      else     $xtime = 172800 - $time;     echo 'You have already challenged' .$character. 'within the last 48 hours. You can challenge' .$character.'again in' .$xtime.'.';      I hope that sort of make sense. My question is how do you get the age-of-post and is there a function to delete a post already in wordpress? Or is there a simpler way to make posts go POOF after x amount of time?


How to update the 'modified_time' of a post ONLY when content is changed?

For some reasons I show the _Last Modified_ information to my users in the blog. Recently I have to clear up my categories and tags, but these actions will result in the update of 'Last Modified' field of a post, which is not actually I desired. Content updates are what readers really concerned about, and not about meta information (like tags, categories, custom fields, descriptions, etc). So is there a way to update the 'Last Modified' field of a post only when the content is changed?


Adding TinyMCE buttons without removing plugin buttons?

I'm developing a plugin that I'll install for all my clients to make WordPress slightly easier to use for them. One of the things it will change is the default TinyMCE configuration. It'll add things like `underline` and `justifyfull` to the first TinyMCE row. I know I could use other plugins like TinyMCE Advanced to alter TinyMCE for my clients, but they add a lot of unneccessary bloat which is susceptible to problems during updates. I want to make this as minimalistic as possible in order to avoid update issues. I've written this simple code that mostly works great:               function mo_change_mce_buttons( $initArray ) {         $initArray['theme_advanced_buttons1'] = 'bold,italic,underline,strikethrough,|,bullist,numlist,blockquote,|,justifyleft, justifycenter,justifyright,justifyfull,|,link,unlink,wp_more,|,spellchecker,fullscreen,wp_adv';         return $initArray;     }     add_filter('tiny_mce_before_init', 'mo_change_mce_buttons');      This code works great except for one huge problem. It disables any TinyMCE plugins on the TinyMCE row in question (`theme_advanced_buttons1`). The Vipers Video Quicktags plugin for example, which adds a YouTube-button, is removed by using the code above. How can I modify the default first TinyMCE row using simple code in my own plugin without sacrificing the possibility for other plugins to add buttons to it too?


Call dynamic_sidebar but include/exclude named widgets?

Is it possible to include or exclude specific named widgets that are assigned to a named dynamic_sidebar call? For example, if I've registered a sidebar named "my_sidebar" and the user had placed a "Links" widget into it, I want to be able to include or exclude it based on a custom setting in my theme options panel. Is this possible? Any insights much appreciated.


How to show a admin bar menu item only to users with certain capabilities?

I'm trying to add items to the admin bar but only for users with certain capabilities, such as `add_movies` in a plugin. The problem is that, according to @toscho and @TheDeadMedic, the plugin executes its code too early in the order of operations to use `current_user_can`. I tried using `if ($user->has_cap('add_movies'))` but get `Fatal error: Call to a member function has_cap() on a non-object in xxx.` Am I missing an obvious global or is the solution more complicated?


Adding custom Field To The Posts Listing

Are there plugins or hooks to editing custom fields just from the posts listing in admin panel?


Yoast SEO breaking media upload

I have a very simple site that I've modified a very small amount. After installing the Yoast SEO plugin I found that it broke the in post media attach/upload. I'm about 80% sure it's related to Jquery but I'm unable to find anything that refer's to it enqueuing anything. I tried forcing an enqueue from functions.php but it didn't help. Any assistance would be appreciated.               function my_init_method() {         wp_deregister_script( 'jquery' );         wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js');         wp_enqueue_script( 'jquery' );     }                   add_action('init', 'my_init_method');


Wordpress blog clone.. wp-admin issue

I wanted to clone one wordpress blog I own into another domain .. I simply downloaded the root folder with all the files from Site1 and uploaded to Site2.. and created a complete MySQL script of Site1 and executed in Site2 DB.. Everything in the user side is working fine but if I got to Site2/wp- admin, its automatically redirecting to Site1/wp-admin.. Any info on where to change this admin URL settings? Thanks and Best Regards, Ansar


Change Favicon on Login Screen?

I have a rather basic question. Does anyone know how to change the favicon on the login screen? I have it on all other areas of my site. But I cannot change it from showing on this page: http://kindly-remind.com/wp- login.php It even shows a bluehost favicon and my site has been moved from bluehost.


Include an image within auto the_excerpt?

Is it possible to include an image within the auto excerpt? So in the editor you have image then some text and once live it includes the image and not just the text?


Menu of the Day?

I would like to show on a specific page a menu of the day, as well as a month calendar with the foods for each day listed. My current setup uses a plugin(Role Scoper) with some changes of my own to allow specific users to make changes to static pages that are assigned to them. I have looked for a food menu plugin that stores menus for multiple days, or a calendar that would allow storing data such as a menu, and have been unsuccessful in finding anything that comes close, so I believe I'll have to create this myself. Is there a best way to implement this? Or has someone already done something like this? Or is there a plugin that does something similar that I can look at the code for?


Wordpress switch servers

So I switched servers from localhost:8080 to a domain, now I followed the instructions by updating the config, and updating the permalinks and everything. Even updated the database. I can go into my admin control panel fine and all, but when I view the site, all the PHP code is not working or something. I see the layout of the site, the CSS being included, but things like `wp_head()` aren't working. The source is all the basic HTML from the layout, none of the PHP code is working. I click on links in the menu, which are permalinks, and they don't go anywhere, nothing happens. The logo isn't working or anything either. I don't know what else to try, so if anyone has any ideas that would be appreciated.


Can an action callback prevent the parent from continuing execution?

I'm working on a plugin that interacts with Gravity Forms, and under certain conditions I want to prevent a form from being deleted. Here's the method in Gravity Forms that handles deleting a form:               public static function delete_form($form_id){         global $wpdb;              if(!GFCommon::current_user_can_any("gravityforms_delete_forms"))             die(__("You don't have adequate permission to delete forms.", "gravityforms"));              do_action("gform_before_delete_form", $form_id);              $form_meta_table = self::get_meta_table_name();         $form_table = self::get_form_table_name();              //Deleting form Entries         self::delete_leads_by_form($form_id);              //Delete form meta         $sql = $wpdb->prepare("DELETE FROM $form_meta_table WHERE form_id=%d", $form_id);         $wpdb->query($sql);              //Deleting form Views         self::delete_views($form_id);              //Delete form         $sql = $wpdb->prepare("DELETE FROM $form_table WHERE id=%d", $form_id);         $wpdb->query($sql);              do_action("gform_after_delete_form", $form_id);     }      Is it possible to hook into `gform_before_delete_form` and then do something to make delete_form() return at that point without continuing? e.g.,               public function preventGravityFormDeletion()     {         if( $someCondition )         {             // do something that forces delete_form() to stop         }     }     add_action( 'gform_before_delete_form', array( $this, 'preventGravityFormDeletion' ) );      I know that I could call `wp_die()` and just stop everything, but that's not very elegant. Is there a better way? It doesn't seem possible because of scope limitations, but I wanted to check in case there's some WP/PHP magic that I'm not aware of.


How to remove the whitespace in image name and save the new file

I am using a wordpress plugin called "Add Linked Images To Gallery" in order to save a local copy of images posted on my site. I uploaded all my files in a different hosting and I was testing this plugin in localhost to see if it does the job .   **What does this plugin do** :   The plugin searches for external images posted in the site , save a local copy and replace the old image address in HTML code with the new image address which is in the local. **What is the problem** :   While testing the plugin in the local host , I noticed that this plugin does not correctly save images which have "white spaces" on their file names. For example : > This is an Image.png will not display in the blog, instead this is the correct way to show it : > This%2520is%2520an%2520image.png as you can see , the white spaces are replaced with "%2520" , I am not sure why this is happening, but the image wont show up in the blog.   I tried to modify this plugin so it automatically replaces the white space in the image file with "_" , I look at the source code and found this line:                   $content = preg_replace('/(<img[^>]* src=[\'"]?)('.$trans.')/', '$1'.$imgpath, $content);      which I believe is responsible for the replacing images, but when I modified it , it removed the post content and image.   Is it possible to modify this plugin, so it replace the white space in the file name first , then save a local copy, then use that local copy in the blog ?   thanks


Setting up two separate blogs while using WordPress as a CMS

I need to get this set up ASAP and cannot seem to figure out how to do this after searching and searching. I am using a WordPress install mostly as a CMS. I would like to have two separate areas on my site for blogs that do not share posts. When going to mydomain.com, it should show a custom page (nothing to do with a blog). I have this working fine, but I need to make it so /blog will show posts from my company and /photography/blog will show posts only related to photography. My `.htaccess` doesn't have anything except the code WordPress said to put in it. Whenever I go to mydomain.com/blog, it forwards me to a post instead of showing me a list of posts/summaries like mydomain.com on a fresh WordPress install. How can I fix this? My URLs are set up under Reading and Permalinks to look like the following.   * Static FrontPage: http://www.mydomain.com   * Blog Home Page: http://www.mydomain.com/blog   * Blog Category Page: http://www.mydomain.com/blog/category/general   * Blog Tags Page: http://www.mydomain.com/blog/tag/WordPress   * Post Page: http://www.mydomain.com/blog/2009/06/WordPress-cms-blog How can I follow the format below so my posts on Photography will remain separate from my company's posts?   * Blog Home Page: http://www.mydomain.com/photography/blog   * Blog Category Page: http://www.mydomain.com/photography/blog/category/general   * Blog Tags Page: http://www.mydomain.com/photography/blog/tag/WordPress   * Post Page: http://www.mydomain.com/photography/blog/2009/06/WordPress-cms-blog


Authors can edit all posts, except when an owner is specified?

I'm trying to do as follows:   * All users can edit all posts from other authors (sort of wiki)   * Some posts have an "owner". When owner is specified only this user can edit the post. Do you have any suggestions for this kind of permission settings?


add a.parent in wp_list_pages

In relation to question posted here, is it possible to have an output to have something like this instead? where `class="parent"` is applied to the hyperlink?

Page 1

Page with Subpages

Page with another subpage

subsubpage

Page 3

Page 4

      the function below of TheDeadMedic works well for lists:               function add_parent_class( $css_class, $page, $depth, $args )     {         if ( ! empty( $args['has_children'] ) )             $css_class[] = 'parent';         return $css_class;     }     add_filter( 'page_css_class', 'add_parent_class', 10, 4 );      is it possible to use a similar function to target hyperlinks instead of the lists?


Where would I find Custom menu attributes in the database?

In what table would I find the title of a custom menu in MySQL for Wordpress 3.5.x?


Where does multisite store image uploads?

Where are images stored in multisite. I looked in uploads but there's nothing there.


While using WordPress Multisite is it possible to display data to main site from subsites?

I am using WordPress Multisite: Main site --sub site --sub site What i need to anything publish to **sub sites** will auto publish on the **Main site** Regards


Change Post Status from Plugin Settings page

I've been going at this for a few days now, and just can't finish this off. I have a plugin that on activation adds a custom post type (CPT), adds a couple of posts to the DB in a Draft status, and creates a settings page the lists these pages with a checkbox. What I can't get it to do is "on check" and save, to change the post_status from draft to publish. First off from the settings page, when you click save it adds the option to the DB but the value is blank when it should be an array. Secondly, on save, it doesn't change the post status. I don't have working code for yet, and I'm hoping to get some direction on. Here's my settings page code.               <?php     // Create Admin Menu     if ( is_admin() ){         add_action( 'admin_menu', 'xed_create_menu');         add_action( 'admin_init', 'register_xed_settings' );     }          // Create Topics Checkbox Page     function xed_create_menu() {         add_options_page('KonnectED Prospecting Topic Manager', 'XED Topic Manager', 'administrator', 'xed-admin.php', 'xed_options_page');     }          // Form output on Topics Checkbox Page with checkboxes from checkbox creation function below     function xed_options_page() {      ?>

KonnectED Prospecting Topic Manager
             <form method="post" action="options.php">                 <?php                     do_settings_sections( 'xed-admin.php' );                     settings_fields( 'xed_topic_group' );                                    submit_button('Activate Topics');                                ?>             </form>
     <?php }          // Create Settings Section for use on Checkbox Page     function register_xed_settings() {         add_settings_section( 'xed_checkboxes', 'Choose which topics are active', false, 'xed-admin.php');              require('topics.php');         // Loop through each Topic from topics.php         foreach( $topics as $topic ) {             $topic_slug = strtolower(str_replace(' ', '_', $topic['post_title']));             $post = get_page_by_title($topic['post_title'], OBJECT, 'topic');             $status = get_post_status( $post->ID );             if ( $status == 'publish') {                  $value = 1;              } elseif ( $status == 'draft' ) {                 $value = 0;             }                  add_settings_field( $topic_slug, $topic['post_title'], 'xed_checkbox_callback', 'xed-admin.php', 'xed_checkboxes', array( 'name' => $topic_slug, 'value' => $value, 'status' => $status ) );              }              register_setting( 'xed_topic_group', 'xed_topics' );          }          // Create Checkbox     function xed_checkbox_callback( $args ) {         $name = esc_attr( $args['name'] );         $value = esc_attr( $args['value'] );         $status = esc_attr( $args['status'] );              echo "<input type='checkbox' id='$name' name='xed_topics[$name]' value='$value' ".checked( 1, $value, false )." />";         echo '
 status is of ' . $name . ' is ' . $status . ' and value is ' . $value;          }      What my code WILL do right now, is correctly check the checkbox if the post is published, but only if you go to the post and publish it... So to recap, I'm looking for help & guidance on: 1. Add the option to the DB as an array 2. Change the CPT post post_status from this settings page. Thanks all!


Authors cant upload images unless publish_page permissions are set

I have a custom post submit form from frontend so authors can submit articles and use the tinymce editor along with the media manager. The problem, only administrators and editors can upload from frontend but authors cannot. I investigated the issue and solved it by giving the author role **new capabilities:**   * publish_pages   * edit_published_pages    * edit_others_pages **The default author capabilites are:**   * delete_posts   * delete_published_posts   * edit_posts   * edit_published_posts   * publish_posts   * read   * upload_files However, I do not want the authors to have these new capabilities, so how can I allow them to upload files without giving them permission to publish/edit pages?


Show attached media image if no thumbnail image detected

I use the               if ( has_post_thumbnail() ){}      to check if the post have thumbnail image, but this               echo get_attached_media('image', $post->ID);      displays the word               Array      I need to show the attached image


Where is the content of widgets stored in mysql table

I have the cPanel access to a website but no wordpress login info. So I wants to change a widget content in the website. How can I change it through phpmyadmin. Where are that widgets sidebar data actually stored? Is it inside `wp-options` table?


Complicated MySQL Query

I'm trying to build a directory of members that has some search options at the top. Each member has several custom fields as well (using Advanced Custom Fields). Would like to have a single query that gathers all the data at once, including all the custom fields for each member - instead of just querying the posts and looping through and having to query the custom fields (100 show at a time - each with 10 custom fields). We've gotten pretty close, the below query does work and returns all the necessary data in clean rows. It's painfully slow however, ~10 seconds, which we know is coming from the ORDERBY clause. This query has gotten a bit over my head though and I can't figure out how to optimize it run faster. Note that the orderby fields are coming from wp_postmeta, so there is no way just to add an index to the 'member_last_name' field for instance. Any ideas??? THANKS!!! Philip               SELECT * FROM (        SELECT          MAX(CASE WHEN wp_postmeta.meta_key = 'member_first_name' THEN wp_postmeta.meta_value END ) AS 'member_first_name',          MAX( CASE WHEN wp_postmeta.meta_key = 'member_last_name' THEN wp_postmeta.meta_value END ) AS 'member_last_name',         wp_posts.ID FROM wp_posts        LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )        WHERE wp_posts.post_status = 'publish'        AND wp_posts.post_type = 'member'        GROUP BY wp_posts.ID        ORDER BY member_last_name desc        LIMIT 5      ) AS t;


A truely custom login page?

I don't want to use a plugin for this one and i would like to know how i can use a custom form for WP login. I made a form with bootstrap and i added the form action and two hidden fields but it doesn't work                <form name="loginform" id="loginform" class="form-signin login_form" action="<?php echo esc_url( wp_login_url() ); ?>" method="post">     .......          <input type="hidden" name="redirect_to" value="http://localhost/mydomain.dev/_site/wp-admin/<?php //echo $_SERVER["REQUEST_URI"]; ?>" />                             <input type="hidden" name="testcookie" value="1" />      Or should i let this go and alter wp-login.php with hook and filters??? Any tips?


Get specific custom field keys from a post and put into an array

I have the following code to look up the longitude and latitude based off of a custom field upon saving the post. My address fields (street_1, city and state) are separate. I have searched and thought that I could put the values from these separate meta keys into an array and pass them to the URL. I have the state value working but I need the whole address. I have tried many different ways and am now asking for help. Any clues will be appreciated. Here is the code:               function geocode_address($post_id)     {         $custom_fields = get_post_custom();         if(isset($custom_fields['state']) && !empty($custom_fields['state'][0]))         {      $resp = wp_remote_get( "http://maps.googleapis.com/maps/api/geocode/json?address=".urlencode($custom_fields['state'][0])."&sensor=false" );                 if ( 200 == $resp['response']['code'] ) {                         $body = $resp['body'];                         $data = json_decode($body);                         if($data->status=="OK"){                                 $latitude = $data->results[0]->geometry->location->lat;                                 $longitude = $data->results[0]->geometry->location->lng;                                 update_post_meta($post_id, "latitude", $latitude);                                 update_post_meta($post_id, "longitude", $longitude);                         }                 }         }     }     add_action('save_post', 'geocode_address');      Thank you, Deon


I used a plugin that hides wp-admin, but it hid wp-admin for admin too - how to revert back?

I used a plugin that hides wp-admin and does a lot of other things, but it hid wp-admin for admin-user too (due to some bad settings on my part probably) - how to revert back? I deleted the plugin's folder to get back to wp-admin, but as soon as I activate it, it again starts hiding admin-stuff. (It's retaining the settings it seems, because it doesn't hide admin-panel right away upon activation on fresh install. I had to alter the settings in wp-admin to make it hide wp-admin.)


slug: should I use latin characters only?

I build a legal portal in a non-latin language (Greek). I want all my content to be thoroughly indexed by search engines, preferably in Greek. Should I enter my post slugs in Greek? The pages then appear with URLs ending in %20%32%33 etc instead of Greek. Does this affect the page URLs? Will they be properly indexed by Google? Or should I use latin characters instead? Thanks.