Both a page loop and posts loop on the same page

I'm trying to get first the content of a single page (the one that is queried), and then in a small section below i want to display the title of my bloggposts as a "Latest News" section. The problem is that if i first use `<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>` to get the page content. And then try to use `$posts_array = get_posts( $args );` to get the blogposts i just get the heading of the page twice. Obviously the `get_posts` function takes on the id of the page instead of looping through the blogposts. Is there a way to tell get_posts to search for the first 5 blogpost id's and not the current page id? Grateful for all answers, suggestions, tips or hints :) here is my code:               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
                        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> role="article">
<?php the_title(); ?>

                             <?php the_content(); ?>                             <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'monster' ), 'after' => '
' ) ); ?>                             <?php edit_post_link( __( 'Edit', 'monster' ), '', '' ); ?>

                 <?php endwhile; // end of the loop. ?>                      <?php                      $args = array(                          'numberposts'       => 5,                         'offset'            => 0,                         'category'          => ,                         'orderby'           => 'post_date',                         'order'             => 'DESC',                         'include'           => ,                         'exclude'           => ,                         'meta_key'          => ,                         'meta_value'        => ,                         'post_type'         => 'post',                         'post_mime_type'    => ,                         'post_parent'       => ,                         'post_status'       => 'publish');                          $posts_array = get_posts( $args );                       ?>

<?php _e('Siste nytt:', 'monster'); ?>
                          <?php                          $count = 1;                         foreach ($posts_array as $monster_news) {                              setup_postdata($monster_news);                                  if ($count == 1) {                                 echo '
';                              } else {                             echo '
';                             }                                  the_title();                                  echo '
';                               }                           $count = null;                          ?>


phpBB 3 to bbPress

I am updating a diabetes forum to make it more extensive for which I have previously used phpBB 3. I have decided to use WordPress on the new build and have installed bbPress, however, I would like to import/transfer the existing users, forums and posts on phpBB into bbPress. There aren't that many of each to do manually, but I would still like to be able to do this manually. I have tried the ForumConverter and WP phpBB Bridge plugins but neither of them worked, so if anybody has any advice or suggestions that would be greatly appreciated. I don't know if it's because I have downloaded the latest stable version of everything but strangely I don't appear to have any tables with the "bb_" prefix in my database either...


Remove taxonomy menu without removing the metabox?

I'm creating a custom taxonomy for a CPT and I need to remove the ability to create new terms for this taxonomy. I would like to know if there is a way to remove from admin menu (`show_ui => false`?) but keep the metabox. I've seen some solutions hooking to the `admin_menu` action and removing manually but I would like to know if there is a way to tell Wordpress when I am registering this taxonomy to not put a menu for it and keep the default metabox. Just to illustrate what I want:               +----------+----------------------------+     |  show_ui | meta_box_cb                |     +----------+----------------------------+     | true     | false                      | #=> show menu but remove metabox     | false    | false                      | #=> remove everything     | false    | true (or something truthly)| #=> this is what I want     +----------+----------------------------+      Thanks


Custom MetaBox : Food Menu Item Available Dates

I am looking to create a custom metabox with check-boxes that will serve to display item availability. I have included two sample images of what I am wishing to accomplish. Any Help would be much appreciated. Moreover, I am really just trying to figure out where to start on this problem. For more information, I will be creating a custom post type that will be specific to Menu Items. This is for a local cupcake bakery. Thanks! http://brocknunn.com/help-pics/Menu-Dates.jpg http://brocknunn.com/help-pics/checkbox.png


Add custom meta to nav menu items

I need to attach meta data to every menu item, with a key 'foo'. Is it possible to do that, without editing core WP? A quick look at the nav-menu files showed that no hooks exist near the place I want to add the input box (below Description, here - http://cl.ly/0v2Z0X1n2e1L431t0h1G)


Changes done to .htaccess are not getting reverted back

I am new to WordPress and playing around with it to get some idea about its working. I have done some changes to WordPress' `.htaccess` file to add some redirection and that worked perfectly fine. Now my problem is even after removing the changes from the .htaccess file, WP is still redirecting me as per the redirection I added up to the file. I am not sure what other changes I have to do to restore the default working in my WordPress as I even removed the database and than re-installed it but still not able to solve the issue. Any help in this regard will be much helpful. Hers is what i added to my htaccess file which i removed later on               Options +FollowSymLinks      RewriteEngine on     RewriteRule (.*)$ http://www.abc.com/$1 [L,R=301]      I took the initial refrence from this web-site Htaccess File URL Rewriting I am using WAMPP server on my local-machine and even after clearing any possible cache i know about, problem still persist.


Sync Wordpress Articles from Local to Remote?

I am starting a Blog and I am trying to keep my Localhost version as up to date as possible with my Remote server version on the web. I would really like to be able to make a post/article on my Localhost install and have it somehow post the same article/post to my Web version (remote version) once I hit publish. Does anyone know if there is a plugin or other method to easily automate or help with such a task? My main goal is that I will have a Local and Remote version of all articles when I post them, I would prefer to be able to post first on my Local version and then publish the end result to my website/remote install


WordPress theme options settings not saving

I have problem with my theme options settings saving. My settings is to saving to permanently , its just only save when you stay on the theme options page after saving the settings. But when I go to any other page or reload the current page the settings disappeared. **HERE is Code**                   function theme_options_do_page() {             global  $theme_options, $icons_options, $new_values, $shortname, $values_array;                  if( !isset( $_REQUEST['submit'] ) ) {                 $_REQUEST['submit'] = false;             }         $values_array = array(          array(                     "name" => "Footer copyright text:",                    "desc" => "Enter text in the footer.",                    "id" => "footer_text",                    "type" => "text",                    "std" => array ('footer_text'=>$_POST['footer_text'],)                  ),          array(                     "name" => "Facebook URL :",                    "desc" => "Enter your Facebook URL here.",                    "id" => 'facebook',                    "type" => "text",                    "std" => array ('facebook'=>$_POST['facebook'],)                  ),          array(                     "name" => "Twitter URL :",                    "desc" => "Enter your Twitter URL here.",                    "id" => 'twitter',                    "type" => "text",                    "std" => array ('twitter'=>$_POST['twitter'],)                  ),          array(                     "name" => "Google+ URL :",                    "desc" => "Enter your Google+ URL here.",                    "id" => 'google',                    "type" => "text",                    "std" => array ('google'=>$_POST['google'],)                  ),          array(                     "name" => "Instagram URL :",                    "desc" => "Enter your Instagram URL here.",                    "id" => 'instagram',                    "type" => "text",                    "std" => array ('instagram'=>$_POST['instagram'],)                  ),          array(                     "name" => "Linkedin URL :",                    "desc" => "Enter your Linkedin URL here.",                    "id" => 'linkedin',                    "type" => "text",                    "std" => array ('linkedin'=>$_POST['linkedin'],)                  ),          array(                     "name" => "Pinterest URL :",                    "desc" => "Enter your Pinterest URL here.",                    "id" => 'pinterest',                    "type" => "text",                    "std" => array ('pinterest'=>$_POST['pinterest'],)                  ),          array(                     "name" => "Rss URL :",                    "desc" => "Enter your Rss URL here.",                    "id" => 'rss',                    "type" => "text",                    "std" => array ('rss'=>$_POST['rss'],)                  ),          array(                     "name" => "Stumbleupon URL :",                    "desc" => "Enter your Stumbleupon URL here.",                    "id" => 'stumbleupon',                    "type" => "text",                    "std" => array ('stumbleupon'=>$_POST['stumbleupon'],)                  ),          array(                     "name" => "Vimeo URL :",                    "desc" => "Enter your Vimeo URL here.",                    "id" => 'vimeo',                    "type" => "text",                    "std" => array ('vimeo'=>$_POST['vimeo'],)                  ),          array(                     "name" => "YouTube URL :",                    "desc" => "Enter your YouTube URL here.",                    "id" => 'youtube',                    "type" => "text",                    "std" => array ('youtube'=>$_POST['youtube'],)                  ),             );     if ( $_GET['page'] == basename(__FILE__) ) {                            if (isset ( $_POST[ 'submit' ] ) ) {                 update_option( 'new_theme_options', serialize( $values_array ));              }          $theme_options = get_option('new_theme_options',false);         $theme_values = unserialize($theme_options);          }              if (isset ($_POST['submit'])) {                 $icons_size = array (                     'width'=>$_POST['width'],                     'height'=>$_POST['height'],                 );                 update_option('social_settings_responsivetheme_options', serialize($icons_size));         };         $icons_options = get_option('social_settings_responsivetheme_options');         $icons_values = unserialize($icons_options);              ?>         <?php if( false !== $_REQUEST['submit'] ) : ?>

<?php _e( 'Options Saved', 'responsivetheme' ); ?>

         <?php endif; ?>
             <?php $theme_name = wp_get_theme() ?>             <?php screen_icon(); echo "
" . $theme_name . __( ' Options', 'responsivetheme' ) . "
"; ?>                         <form method="post" action="themes.php?page=theme-options.php">     <?php foreach ($values_array as  $value) {          ?>
     <?php           ?>          <?php      ?>
     <?php echo $value['name']; ?>	     <input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php foreach ($value['std'] as $key){echo $key;}?>" />

     <?php echo $value['desc']; ?>

               <?php          }//end foreach     ?>

                  <input type="submit" name="submit" class="button-primary"  id="submit" value="<?php _e( 'Save Options', 'responsivetheme' ); ?>" />
         </form>
      I hope I will get my problems solution. Many thanks in advance.


Custom Post type forgetting data

I just set up a custom post type, mostly following this tutorial. I'm setting up things on my site now, doing a lot of CSS modifications and such, and every few minutes the post just forgets everything that's in the custom meta boxes. I'm sure I've done something wrong in the add_action/update_post_meta section, but I don't know what it is, because I don't really understand the entirety of what the code does. In any case, here's the entire thing:               add_action('init', 'portfolio_register');          function portfolio_register() {              $labels = array(             'name' => _x('My Portfolio', 'post type general name'),             'singular_name' => _x('Portfolio Item', 'post type singular name'),             'add_new' => _x('Add New', 'portfolio item'),             'add_new_item' => __('Add New Portfolio Item'),             'edit_item' => __('Edit Portfolio Item'),             'new_item' => __('New Portfolio Item'),             'view_item' => __('View Portfolio Item'),             'search_items' => __('Search Portfolio'),             '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,             'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',             'rewrite' => true,             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => null,             'supports' => array('title','editor','thumbnail')           );               register_post_type( 'portfolio' , $args );     }          register_taxonomy("portfolio_cat", array("portfolio"), array("hierarchical" => true, "label" => "Categories", "singular_label" => "Category", "rewrite" => true));          add_action("admin_init", "admin_init");          function admin_init(){       add_meta_box("media_meta", "Media", "media_meta", "portfolio", "normal", "low");       add_meta_box("highlights_meta", "Highlights", "highlights_meta", "portfolio", "normal", "low");       add_meta_box("main_meta", "Main", "main_meta", "portfolio", "normal", "low");       add_meta_box("tabbed_meta", "Tabbed", "tabbed_meta", "portfolio", "normal", "low");     }               function media_meta(){       global $post;       $custom = get_post_custom($post->ID);       $media_meta = $custom["media_meta"][0];       ?>
Media:
       <textarea cols="110" rows="5" name="media_meta"><?php echo $media_meta; ?></textarea>
       <?php     }          function highlights_meta(){       global $post;       $custom = get_post_custom($post->ID);       $highlights_meta = $custom["highlights_meta"][0];       ?>
Highlights:
       <textarea cols="110" rows="5" name="highlights_meta"><?php echo $highlights_meta; ?></textarea>
       <?php     }          function main_meta(){       global $post;       $custom = get_post_custom($post->ID);       $main_meta = $custom["main_meta"][0];       ?>
Main:
       <textarea cols="110" rows="5" name="main_meta"><?php echo $main_meta; ?></textarea>
       <?php     }          function tabbed_meta(){       global $post;       $custom = get_post_custom($post->ID);       $tabbed_meta = $custom["tabbed_meta"][0];       ?>
Tabbed:
       <textarea cols="110" rows="5" name="tabbed_meta"><?php echo $tabbed_meta; ?></textarea>
       <?php     }          add_action('save_post', 'save_details');          function save_details(){       global $post;            update_post_meta($post->ID, "media_meta", $_POST["media_meta"]);       update_post_meta($post->ID, "highlights_meta", $_POST["highlights_meta"]);       update_post_meta($post->ID, "main_meta", $_POST["main_meta"]);       update_post_meta($post->ID, "tabbed_meta", $_POST["tabbed_meta"]);     }          add_action("manage_posts_custom_column",  "portfolio_custom_columns");     add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns");          function portfolio_edit_columns($columns){       $columns = array(         "cb" => "<input type=\"checkbox\" />",         "title" => "Portfolio Title",         "description" => "Description",         "media_meta" => "Media",         "highlights_meta" => "Highlights",         "main_meta" => "Main",         "tabbed_meta" => "Tabbed",         "portfolio_cat" => "Portfolio Categories"       );            return $columns;     }     function portfolio_custom_columns($column){       global $post;            switch ($column) {         case "description":           the_excerpt();           break;         case "media_meta":           $custom = get_post_custom();           echo $custom["media_meta"][0];           break;         case "highlights_meta":           $custom = get_post_custom();           echo $custom["highlights_meta"][0];           break;         case "main_meta":           $custom = get_post_custom();           echo $custom["main_meta"][0];           break;         case "tabbed_meta":           $custom = get_post_custom();           echo $custom["tabbed_meta"][0];           break;         case "portfolio_cat":           echo get_the_term_list($post->ID, 'portfolio_cat', '', ', ','');           break;       }     }


Querying Multiple Categories With Different Offsets

On my website I have a "Breaking News" section which shows the most recent 4 stories in the "Breaking News" Category. Under this I have a featured news section which displays 5 more stories from the "Breaking News" Category. I get these posts by simply setting the offset to 4 in a WP_Query What I want to do is make an adjustment to the featured news section. So that it still pulls in 5 of the latest stories from Breaking News, but if a story is added to a "Featured News" category, that it pulls that in. Some pseduo code would be something like               Get the 5 latest posts from Breaking News with Offset of 4 and from Featured News with Offset 0      Seems pretty simple when it's written like that, but I can't seem to actually get it to work. I can't get WP_Query to accept an offset from one category and not the other. I've tried this               $featuredPosts = new WP_Query( array(     'posts_per_page' => 5,     'cat' => 169,     'offset' => 4     ),      array(     'posts_per_page' => 5,     'cat' => 172,     'offset' => 0) );      But this only gives me the first 5 posts from cat 169 and ignores the second query array from 172. I have also tried storing all the id's of posts already outputted in "Breaking News" and then not outputting them again so I can do an easier query (Get last 5 from breaking&featured) but the problem there is it won't always output 5 posts since it will be excluding some of the breaking news ones. Maybe I'm completely over thinking this and there's an easier way, has anyone any ideas?


image_downsize returning an Array?

I'm attempting to generate a thumbnail for an image I have posted, but it seems when I call image_downsize, the index[0] actually prints an array as the URL. I'm a bit confused, so any help would be appreciated! My code:               $wpUploadPath = wp_upload_dir();     $target_path = $wpUploadPath;     $filename = 'http://www.mysite.org/uploads/sampleFile.jpeg';          $fileNameFinal = pathinfo($filename);          $wp_filetype = wp_check_filetype($filename, null);          $attachment = array(      'post_mime_type' => $wp_filetype['type'],      'post_title' => $fileNameFinal['filename'],      'post_content' => '',      'post_status' => 'inherit'     );          $attach_id = wp_insert_attachment( $attachment, $target_path);          $upFile = image_downsize( $attach_id, 'thumbnail' );      Here is where I encounter the problem. If I `print_r($upFile);` I get:               Array (          [0] => http://www.mysite.org/uploads/Array         [1] => 0          [2] => 0          [3] =>     )       Is this normal? I can't seem to generate the thumbnail to update my user meta's with this. Any help would be appreciated. Thanks! Tre


Creating custom post type and taxonomy archives and pretty URLs

I've created a custom post type, `Local Pages` and two different taxonomies: `Locations` and `Services`. As of now, the custom post type works. However the urls are not pretty. They look something like: `http://domain.com/?localpage=%post_name%` Ideally, I'd like to create an archive for the post type and the taxonomies. For example, the main archive would be something like `http://domain.com/localpage`, which would list all of the posts in that post type. I assume this would require it's own archive template. I'd also like to create a category list page for my taxonomies, where the URL would be something like `http://domain.com/localpage/locations` and `http://domain.com/localpage/services`. Both of these pages would essentially list the all of categories or items of the particular taxonomy. Filter the links on each of those pages to the next taxonomy. An example of how this would work would be: > **Locations:** Abbott, CA; Aberdeen, CA; Cable, CA; Strawberry, CA; Zuver, > CA > > **Services:** Aluminum Adjustable Patio Covers; Insulated Patio Covers; > Store Front Awnings; Sunroom Enclosures. > > When visiting `http://domain.com/localpage/locations`, you would see the > above listed locations. Upon clicking on any particular location, you would > then be sent to something like > `http://domain.com/localpage/%location_name%/services` where it would list > all the services for that location. Upon clicking on a service, you would be > taken to the post at something like > `http://domain.com/localpage/%location_name%/%service_name%/%post_name%` How might I accomplish this and what page template files (archive.php, single.php, etc) are needed? Here's the code I'm using in my 'functions.php' to create the custom post type and taxonomies.               /////////////////////////////////////////////////     // Local Page Custom Post Type     /////////////////////////////////////////////////     function create_local_pages() {              $labels = array(             'name' => _x( 'Local Pages', 'post type general name' ), // Tip: _x('') is used for localization             'singular_name' => _x( 'Local Page', 'post type singular name' ),             'add_new' => _x( 'Add New', 'Local Page' ),             'add_new_item' => __( 'Add New Local Page' ),             'edit_item' => __( 'Edit Local Page' ),             'new_item' => __( 'New Local Page' ),             'view_item' => __( 'View Local Page' ),             'search_items' => __( 'Search Local Pages' ),             'not_found' =>  __( 'No Local Pages found' ),             'not_found_in_trash' => __( 'No Local Pages found in Trash' ),             'parent_item_colon' => ''         );              $annoucement_args = array(             'labels' =>$labels,             'singular_label' => __('Local Page'),             'public' => true,             'show_ui' => true,             'menu_position' => 5,             'capability_type' => 'post',             'hierarchical' => false,             'rewrite' => false,             'supports' => array('title', 'editor'),             'has_archive' => true,          );         register_post_type('localpage', $annoucement_args);     }     add_action('init', 'create_local_pages');                    /////////////////////////////////////////////////     // Local Page Taxonomies     /////////////////////////////////////////////////     add_action( 'init', 'build_locations', 0 );         function build_locations() {             register_taxonomy( 'location', 'localpage', array( 'hierarchical' => true, 'label' => 'Locations', 'query_var' => true, 'rewrite' => true ) );         }          add_action( 'init', 'build_services', 0 );         function build_services() {             register_taxonomy( 'services', 'localpage', array( 'hierarchical' => true, 'label' => 'Services', 'query_var' => true, 'rewrite' => true ) );         }          add_action( 'init', 'build_keywords', 0 );         function build_keywords() {             register_taxonomy( 'keyword', 'localpage', array( 'hierarchical' => true, 'label' => 'Keywords', 'query_var' => true, 'rewrite' => true ) );         }      Any help would be greatly appreciated. **Additional information** In the example provided, the local pages are pages within the site that relate to a geographic location and a single, particular service. Hence my reference to them as "local pages" for the custom post type. They could be named anything different for that sake. From my understanding, this is an SEO play on his behalf. Most of the content is identical with the exception of some keyword and location changes throughout the content. Not something I'm real fond of, but I'm attempting to deliver what the client asked for.


How do I test my localhost WordPress project with VirtualBoxVM?

I'm working on a WordPress project set up with MAMP on localhost. I try testing the site on internet explorer with VirtualBoxVM by browsing to my local ip. My problem is, wp_head() outputs absolute path's to css and js resources, so the VirtualBoxVM Browser tries to load http://localhost:[port]/wp-content/themes/twentytwelve-[xy]/style.css?ver=3.5 which will, of course, fail. How do I get VirtualBoxVM to load these resources properly? Maybe I can make the resource urls relative?


Automatic Delete post on a specific date

i want to display all posts as well as count the days of the post since it was published               if ($pageposts):       foreach ($pageposts as $post):             setup_postdata($post);         echo '<p>';             the_title();             echo '</p>';       endforeach;     endif;      Output should be something like this Post Title1 - This post is published 4 days ago Post Title2 - This post is published 3 days ago Post Title3 - This post is published 6 days ago and at the same time i want to delete the post once it reaches 10 days I really need your help guys thanks i appreaciate it alot


"Post name" permalink returns home page for custom posts

I'm new here. I badly need help on this permalink issue. In my site I've one custom post type 'portfolio' but when I set the permalink structure to 'Post name' it returns loads index.php page not its page-portfolio.php page. But with other permalink structure it works fine. Sorry I tried but there were no similar answers. I'm running on my wamp server which has mod-rewrite rules enabled and I can change permalink structures (to 'Post name') for other themes (with custom post types) and that works smoothly. There is may be some trouble in my codes. Please help. Thank you in advance for your kind time and support.               /*     * Custom Post types for Portfolios!     */     function jm_portfolio_post_type(){         $labels = array(             'name'          => _x('Portfolio', 'post type general name'),             'singular_name' => _x('Portfolios', 'post type singular name'),             'add_new'       => _x('Add New', 'Portfolio'),             'add_new_item'  => __('Add New Portfolio'),             'edit_item'     => __('Edit Portfolio'),             'new_item'      => __('New Portfolio'),             'all_items'     => __('All Portfolios'),             'view_item'     => __('View Portfolio'),             'search_items'  => __('Search Portfolios'),             'not_found'     => __('No portfolios found'),             'not_found_in_trash' => __('No portfolios found in the Trash'),             'parent_item_colon' => '',             'menu_name'     => 'Portfolio'         );              $args = array(             'labels'        => $labels,             'description'   => 'Portfolio',             'public'        => true,             'menu_position' => 5,             'menu_icon'     => null,             'hierarchical'  => true,             'supports'      => array('title', 'editor', 'thumbnail'),             'rewrite'       => array('slug' => 'portfolio'),             'has_archive'   => true         );         register_post_type('portfolio', $args);     }          add_action('init', 'jm_portfolio_post_type');          /*     * Custom Messages for Portfolio     */     function jm_portfolio_updated_messages($messages){         global $post, $post_ID;         $messages['portfolio'] = array(             0   => '',             1   => sprintf(__('Portfolio updated. View portfolio'), esc_url(get_permalink($post_ID))),             2   => __('Custom field updated.'),             3   => __('Custom field updated.'),             4   => __('Portfolio updated.'),             5   => isset($_GET['revision']) ? sprintf(__('Portfolio restored to revision from %s'), wp_post_revision_title((int) $_GET['revision'], false)) : false,             6   => sprintf(__('Portfolio published. View portfolio'), esc_url(get_permalink($post_ID))),             7   => __('Portfolio saved.'),             8   => sprintf(__('Portfolio submitted. Preview portfolio'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))),             9   => sprintf(__('Portfolio scheduled for: **%1$s**. Preview portfolio'), date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)), esc_url(get_permalink($post_ID))),             10  => sprintf(__('Portfolio draft updated. Preview portfolio'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))),         );         return $messages;     }          add_filter('post_updated_messages', 'jm_portfolio_updated_messages');          function jm_rewrite_flush() {         flush_rewrite_rules();     }     add_action( 'after_switch_theme', 'jm_rewrite_flush' );


Wordpress staging environment that syncs everything except posts?

I've already looked at this question and didn't find it too helpful. We're using Wordpress as a CMS that also includes a blog/news section. The blog/news uses WP "posts" and those are made whenever and are j We're already using version control for the files, so that's simple enough. The main issue is the database. We basically want a selective backup that excludes posts. Are there any best practices or well tested ways to do this? I'm comfortable enough with sql (not specifically MySql, but the dialects are similar enough I'd think) that I could come up with a script to do it, but I'd rather not risk subtle errors if there's already a well-tested solution available. If there isn't already a solution, are there any caveats or pitfalls I should be aware of when doing this? Any relevant articles that would be helpful in preparing this?


How to give a website (Wordpress) a custom title and description in Google search

it's about the website www.kindheitsorte.de. When you do a Google search for "kindheitsorte.de" you get to see "kindheitsorte.de/" as the result - no custom site title or description at all. When you do a Google search for "kindheitsorte" you get "Informationen" as the site title (which is pretty weird because this title has never been added - you can't even see it in the website's source code. The website is running on Wordpress 2.9.2 and makes use of the All in One SEO Pack 1.6.13. I have added a custom description for each page with the All in One SEO Pack since the Home page of the website does not contain any text that Goolge could be interested in. What do I have to do in order to have Google display the right title and also the description I have added? Thanks a lot, guys!


Can't access wp-admin

When trying to login one of my WP installs (regular WP 3.4.2-no multisite), I keep being redirected to the `wp-login.php` file. I've checked nearly everything:   * Password is correct and changed...nothing   * Reset to a default theme...nothing   * Deactivated al plugins...nothing   * Reuploaded my wp-login.php file...nothing   * Checked the .htaccess files...nothing   * wp-config.php still looks the same.   * Erased my browser data and used an other browser... Still nothing.   * Completely overwritten every WordPress file with a fresh download install.  What else could this be? I didn't make any upgrades to the code.


Custom Post Type or just Post Categories?

I'm using WordPress as a Content Management System. I currently have a few different Custom Post Types: `featured`, `species`, `answers`, `forums` and `glossary`. These are all bespoke and wouldn't work with the default Posts functionality. However, I've also got three separate types of Post which require the same functionality but are displayed on three separate areas of the website: `news`, `articles`, `blogs`. My question is this: **should I just use categories to display these posts, or should I create Custom Post Types for them?**. At the moment I'm using categories, but it's causing a couple of issues:   * As default a `blog`, an `article` or a `news` post all have the same URL format: `website.com/post_slug`   * I'd prefer it to be `website.com/news/post_slug`, `website.com/blog/post_slug` etc. ...   * I'd like to be able to use a URL structure such as `website.com/blog/author/name` or `website.com/author/name/blogs` to view only that author's blog-type posts. Thanks in advance,


Free Google Analytics plugin that works with Wordpress in network mode (WPMU)?

Is there any free Google Analytics plugin that works with WPMU? Please suggest only if you use it and it works.


Custom attributes to javascript tags

My site uses cloudflare but I really want to enable rocket loader, but if I put it on automatic mode, it messes up my whole site... So I googled and found This answer which has helped in terms of adding the `data-cfasync="true"` or the `data-cfasync="true"` tags (see cloudflare wiki for this) to the `script` tag. But it ads it AFTER the URL. For rocket loader to use the tag, it needs to be straight after the opening script tag. So basically:               <script data-cfasync="true(or false)" type="text/javascript" src="domain.com/jshere.js"></script>      The answer on the page above (here) gives instructions on how to do it, I added it to my `functions.php` file and it added the tag on the relevant URL. But it adds the code after the URL and thus is pointless because rocket loader does not see the tag as it is after the url. I am no good at php and I have been playing with the code for a day to try and get the tag to go before the URL but I can't seem to do it. I am wondering if anyone can modify that code for the `functions.php` so this can be accomplished?


I'm writing a plugin, most of my code is wrapped in classes, except for an admin_notice fallback function that I call when I am not loading the main plugin class:               class MyClass {         //Main plugin class     }          if ( $check = true ) {         $myClass = new MyClass();     } else {         add_action( 'admin_notices', 'admin_notice' );     }           function admin_notice() {         echo "plugin not loaded";     }      this worked before like it should, until suddenly I got an error when I deactivated and reactivated te plugin: **Plugin could not be activated because it triggered a fatal error.** **Fatal error: Cannot redeclare admin_notice() (previously declared in myplugin.php:12) in myplugin.php on line 14** The line numbers (12&14) refer to the first and last lines of the function, the file is the same. the strange thing is that when I wrap the function in a function exists conditional like this:               if ( ! function_exists('admin_notice') ) {         function admin_notice() {             echo "plugin not loaded";         }     }      I get an error that the function doesn't exist! I have tried deleting & reinstalling the plugin files, renaming the function, but that doesn't help... Any ideas what's going on?


Custom MySQL Query for Post and Post Meta

I have a custom table called "tags" that contains a `charity_id` that is a reference to a post ID ... I need to query the "tags" table to grab this `charity_id` and then pull in the post title and a few of the meta data. Ideally, the end result would produce the following:               tags.serial_number, post.title, post_meta_data.post_title, post_meta_data.location_city, post_meta_data.location_state, post_meta_data.location_country


Is it possible to put a site other than #1 as a Multisite top-level domain?

Assuming a WordPress network with subdomains:               [blog ID #1] http://mysite.com      [blog ID #2] http://site1.mysite.com      [blog ID #3] http://site2.mysite.com      Is it possible to move one of the subsites to the home site URL? Result:               [blog ID #1] (inaccessible or I don't care)     [blog ID #2] http://mysite.com     [blog ID #3] http://site2.mysite.com      I realize that there's no simple configuration change, and that URLs are often hard-coded in the database, so it's not an easy task. But I'm wondering if this is possible at all with "Sunrise" site mapping, some plugin, etc? Another acceptable result would be:               [blog ID #1] http://mysite.com     [blog ID #2] http://mynewsite.com     [blog ID #3] http://site2.mynewsite.com     [all further blogs on mynewsite.com as well]      ie. all subsites should map to the new domain


Nonce failing with second argument

The plugin Plugin Maker pastebin is not working and I've narrowed it down to its nonce-mechanism failing. At one point it checks for               check_admin_referer('$pluginmaker_nonce', $pluginmaker_nonce);      which is where it fails. (it gives an error "Are you sure you want to do this") I've noticed that if you leave out the second argument (`$pluginmaker_nonce`) it works. (the default argument value is `'_wpnonce'`.) The way `$pluginmaker_nonce` is defined is               if (!function_exists('wp_nonce_field')){         function pluginmaker_nonce_field($action = -1){             return;             }         $pluginmaker_nonce = -1;         }     else {         function pluginmaker_nonce_field($action = -1){             wp_nonce_field($action);             }         $pluginmaker_nonce = 'pluginmaker-nonce-key';         }


Output Taxonomy Title as Part of Result

I have a list of product details in pdf format. There are about 300 of them, and each one is a post within a custom post type of "details". Each post is linked to any combination of 3 taxonomies: Profile, Thickness, and Location. Each product has a pdf file linked to it. Users are given the opportunity to filter the list of product details via 3 select boxes that contain the various taxonomies. So for example a customer selects "bevel", "3/8"", and "ceiling" and is presented with a table containing all products that apply:

             Product A	             Bevel	             3/8"	             Ceiling	             Download Link

             Product B	             Bevel	             3/8"	             Ceiling	             Download Link

      Where the profile, thickness and location are (ideally) pulled from the taxonomies. So far, my ajax looks like the following ($profile, $thickness and $location are returned from the filter form and the value is the correct taxonomy slug) and functions as it should, I can select different options and return only the proper results to the table:               <?php         $args = array(             'post_type' => 'details',             'posts_per_page' => 50,             'edge_profile' => $profile,             'overall_thickness' => $thickness,             'location' => $location         );         $posts = get_posts($args);         foreach($posts as $post):setup_postdata($post);     ?>
         <?php the_title(); ?>	         	         	         	         <?php the_content(); ?>
     <?php         endforeach;         wp_reset_postdata();     ?>      Where I'm having a problem is with those three blank td's up there where I should be displaying a profile name, a thickness name, and a location name. I've tried multiple solutions and just can't seem to find the right one. I'm hoping someone here can help me out. Thank you in advance.


How Can I pass an image file to wp_handle_upload?

I have been looking everywhere for this and havent been able to find an answer. I need to pass a file from the url source to wp_handle_upload. How can I accomplish this? Thank you


List of Posts in a Custom Field

I have a question. I have a custom post type called Place. I have a situation that there can be place in place. I want to have a custom field `parent_place` where I could choose a parent of place.   The Place can have none or one parent. Is there any posibility to list all posts (`type = place`) in custom field and choose one of them? In plugins for custom fields I can choose dropbox, radio, etc, but I have to type values. How can I automatically fill in a list of all posts which type is Place?


Register slug capitalized in url directs to separate page

I'm designing a theme in Wamp using the underscore theme. I also have buddypress enabled. I've been working on a custom registration page under localhost/testsite/register/ but I had cap locks on when entering the register slug and found that localhost/testsite/REGISTER/ takes me to an entirely different page with a comment template and the word Register at the top. Why is that?


Force HTTPS using .htaccess - stuck in redirect loop

My Wordpress website is located at example.com/wordpress and I need everything inside to be accessible only using SSL. I've created a .htaccess rule that redirects http -> https:               RewriteEngine On     RewriteRule ^/?(.*) https://%{SERVER_NAME}/wordpress/directory/$1 [R,L]      After implementing this rule the website is inaccessible as it is stuck in a redirect loop. What am I doing wrong? My Wordpress .htaccess:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /wordpress/directory/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /wordpress/directory/index.php [L]     </IfModule>


Pass taxanomy parameters to next_post_link()?

I am trying to find out if it is possible to pass certain parameters to next_post_link() and previous_post_link() to make it only show other custom posts that have the same custom taxonomy values choosen? In my case i have a custom post type named "houses" and two custom taxonomies called "num_floors" and "collection" If a user is on a single house page i want next/prev links only to other houses with the same value for num_floors and collection as the one currently viewed.. Appreciate your help!


Which core file is responsible for gravatars?

I realize modifying the core files is frowned against but I strongly believe that the WP core SHOULD NOT rely on external links. In my situation, I'm behind the Great Chinese Firewall, the gravatar sites are blocked. This causes a lag in my page load times. I have a patch in place but I'd like to remove it from my install altogether.


get attributes/part of the gallery shortcode

I'm trying to grab all image id's that are associated with the [gallery] shortcode that are listed as exclude. For example: if my post has `[gallery exclude="1,2,3"]` I'd like to get a variable that would echo like this `echo $excludes;` result `1,2,3` thank you for any help you can offer.


Give "Read More" precedence over excerpt() word count

By default, `the_excerpt()` displays the content before the `<!--more-->`, trimming it at ~50 words. Is there any way to prevent this trimming functionality when the `<!--more-->` is present, but still have it work when `<!--more-->` is absent? Thanks!


One Click Access To Users Account In Wordpress?

I am trying to figure out a way that my support team can access my user accounts within wordpress. What I am trying to do is create a report inside the Admin Panel of all users and then have a button that takes them to the users account as if they're the user. We need this in order to confirm that their accounts function correctly, support, etc. I know you can't decode the one way MD5 from wordpress - but has anyone been able to create or code something that would capture this functionality ?


custom post type post sub page

I have a CPT and my permalink format is like this: http://animup.net/anime/attack-on-titan/ I want to be able to have a sub page like http://animup.net/anime/attack-on- titan/ **download** My code looks like this:               function my_disable_redirect_canonical( $redirect_url ) {         if ( is_singular( array('recommends','reviews','anime','manga') ) )             $redirect_url = false;         return $redirect_url;     }      but when I try to reach sub page (animup.net/anime/attack-on-titan/download) it shows 404. How can I handle sub pages of CPTs?


Custom post type (Jigoshop): unexpected value for $category_id (via $term->term_taxonomy_id) on live server

I have hacked together a function to spit out the category description for a Jigoshop custom post type, along with its associated image. (The product_cat image field is implemented by the Jigoshop plugin). It works locally, but on my server the image is not always being found — the returned $category_id seems to be out by 1 for some (but not all) of the products.               function cyclelux_brand_info() {     function get_the_category_bytax( $id = false, $tcat = 'category' ) {         $categories = get_the_terms( $id, $tcat );         if ( ! $categories )         $categories = array();         $categories = array_values( $categories );         foreach ( array_keys( $categories ) as $key ) {             _make_cat_compat( $categories[$key] );         }         // Filter name is plural because we return alot of categories         return apply_filters( 'get_the_categories', $categories );     }     // TODO: tidy this up, won't work if product assigned to multiple categories     $cat = get_the_category_bytax($post->ID,'product_cat');     // print_r(get_the_terms( $id, 'product_cat' ));     // print_r($cat);     foreach ( $cat as $term ) {            $category_description = $term->description;            $category_id = $term->term_taxonomy_id;     }     // echo "category_id = " . $category_id;     // echo "
jigoshop_product_cat_image = " . jigoshop_product_cat_image($category_id)["image"];     // echo "
jigoshop_product_cat_thumb_id = " . jigoshop_product_cat_image($category_id)["thumb_id"];     echo "
";     echo "

" . $category_description . "

";     }


jQuery drop down not appearing for autocomplete/autosuggest

I have set a field to autocomplete/autosuggest but the drop down isn't appearing as I type. I can see the admin-ajax.php requests and the data returned in the Network tab of Chrome Developer Tools so that appears to be retrieving the suggestions fine. I'm not real sure how to troubleshoot this further, and sort the issue out. The Javascript is as follows:                   <script type="text/javascript">         var se_ajax_url = '<?php echo admin_url('admin-ajax.php'); ?>';              jQuery(document).ready(function() {             console.log(jQuery('#body-type').suggest(se_ajax_url + '?action=se_lookup'));         });         </script>      Below is the code I've added to wordpress:               <?php          add_action('wp_enqueue_scripts', 'se_wp_enqueue_scripts');     function se_wp_enqueue_scripts() {     wp_enqueue_script('suggest');     }          add_action('wp_head', 'se_wp_head');     function se_wp_head() {     ?>     <script type="text/javascript">         var se_ajax_url = '<?php echo admin_url('admin-ajax.php'); ?>';              jQuery(document).ready(function() {             console.log(jQuery('#body-type').suggest(se_ajax_url + '?action=se_lookup'));         });     </script>     <?php     }          add_action('wp_ajax_se_lookup', 'se_lookup');     add_action('wp_ajax_nopriv_se_lookup', 'se_lookup');          function se_lookup() {         global $wpdb;              $search = like_escape($_REQUEST['q']);              $query = 'SELECT DISTINCT meta_value FROM '.$wpdb->postmeta.'             WHERE meta_value LIKE \''.$search.'%\'             AND meta_key = \'machinery_bodyType\'             LIMIT 5';              foreach ($wpdb->get_results($query) as $row) {             $value = $row->meta_value;             echo $value."\n";         }         die();     }          ?>


I'm getting this error while trying to log in: > ERROR: Cookies are blocked or not supported by your browser. You must enable > cookies to use WordPress. Yet I have cookies enabled and not blocked. I've tried this on a few different browsers, and in the incognito/private modes of those browsers, too, and get the same messages. I've also tried clearing all cookies from the cache, pursuant to the instructions on Mozilla Support. What could be causing this, and how would I go about debugging this issue?


Plugin won't activate

I am trying to redirect a user once they click "activate" on my plugin, the redirect is working great using the register_activation_hook however the plugin is failing to activate. Any thoughts on what i need to do to make it run the hook after activation and not before?               function install_redirect() {     wp_redirect('http://www.mydomain.com');exit;     }     register_activation_hook(__FILE__, 'install_redirect');      Thanks


Preventing Truncation of First Post

I'm looking for a way to prevent only the first post on the blog index from being truncated (showing the post snippet and featured image). So the full contents of the most recent post would be output, then all other after that would be displayed as normal. Is there any way to easily achieve this?


wp_get_attachment_image returns different image size

It is a bug?               wp_get_attachment_image( $attachment_id, 'post-thumb-size-small');      Same code, called in template, and in AJAX call returns same image SRC, but different image width and height. dumb from template call:                     dump from AJAX call                     i'm confused, whats wrong? index.php code                   <?php if (have_posts()) : while (have_posts()) : the_post(); ?>              <?php include 'post.php'; ?>              <?php endwhile; endif; ?>      post.php code
          <?php     if( in_array( $post_type, array( 'audio', 'video', 'quote', 'link'))) {       $theme->theme_post->display_post_element( $post_type, $post_size, $post);     }     ?>
      display_post_element function code                   function display_post_element( $post_type, $post_size, $post) {     $attachment_id = get_post_meta( $post->ID, '_view_attachment_id', true);             if( $post_type == 'single_image') {                 $img = wp_get_attachment_image_src( $attachment_id, 'full');                      if( is_array( $img)):                                 ?>
                     <a href="<?php echo $img[0]; ?>" class="lightbox"><?php echo wp_get_attachment_image( $attachment_id, 'post-thumb-size-' . $post_size); ?>                     <a href="<?php echo $img[0]; ?>" class="lightbox zoom">
                 <?php                 endif;             }     }      load posts with ajax call code:               function load_posts_ajax() {         global $post;         $query_string = $_POST['query_string'];              query_posts( $query_string . '&posts_per_page=' . get_option( 'posts_per_page') . '&post_status=publish&offset=' . (int)$_POST[ 'off']);              if ( have_posts() ) : while ( have_posts() ) : the_post();             include TEMPLATEPATH . '/post.php';         endwhile; endif;              die;     }


Custom query form submission pagination

There is a question very similar to mine, which can be found here. The difference with my question is: my search form is on several pages (`page.php` and `single.php`) and I don't use wp-pagenavi. I've tried the suggested solutions posted there but they didn't work. **What is working**   * The query displays the right results   * The query displays the right results after form submission   * Pagination shows with the correct links (ie example.com/overview/?paged=2 and example.com/city/boston/?paged=2)   * Pagination with the same settings works on search.php **What is not working:** if I submit the form and click on any page but page 1 the URL does become example.com/overview/?paged=2 or example.com/city/boston/?paged=2 but no results are displayed. **Updated after the accepted answer:** Please read the notes in the code to see how the problem was solved. **--- Below here the setup of my code** On **page.php**               if(is_page('overview')) {         get_template_part('templates/overview', 'main');     }      On **single.php** (include the same file)               if(is_singular('cities')) {         get_template_part('templates/overview', 'main');     }      On **overview-main.php**               include_once 'overview-search-input.php';      include_once 'overview-sidebar.php';      On **overview-search-input.php (changed after UPDATE 3, original code below here)**                  if(!empty($_GET['period'])) {             $period = $_GET['period'];        }        else {             $period = 'upcoming'; // Set to upcoming if nothing is selected        }             $query = search_v1($period, $paged); // Passing the $paged parameter in the query             $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // The $paged parameter      On **overview-sidebar.php**               <form action="<?php echo get_permalink(); ?>" method="get">      <select name="period" placeholder="Select">       <option value=""></option>       <option value="all"></option>       <option value="upcoming"></option>     </select>     </form>      in the function **search_v1** :                   $args = array(             'post_type'         => 'events',             'post_status'       => 'publish',             'posts_per_page'    => 20,             'paged'             => $paged, // This was passed into the function             'meta_query'        => array($meta_query), // This is generated based on the $period input and it's working (tested)             'meta_key'          => 'date_from',             'orderby'           => 'meta_value',             'order'             => 'ASC',         );              return new WP_Query($args);      Then on **overview-main.php**                  if($query->have_posts()): while ($query->have_posts()): $query->the_post();           // Do stuff         endwhile;              create_pagination($query);              wp_reset_postdata();         endif;      And in the function **create_pagination** :               $query->query_vars['paged'] > 1 ? $current = $query->query_vars['paged'] : $current = 1;          $args = array(         'base' => @add_query_arg('paged','%#%'),         'format' => '?paged=%#%',         'total' => $query->max_num_pages,         'current' => $current,         'show_all' => false,         'end_size' => 1,         'mid_size' => 2,         'prev_next' => true,         'prev_text' => '',         'next_text' => '',         'type' => 'list'     );          return paginate_links($args);      **The problem was:** Since both pagination functions work and display the correct pagination links I assume that's not the problem. I think it lies in the custom query (since this pagination works on search.php when the results are generated once and not altered by form input). **The problem was solved:** by using the 'paged' parameter and passing it into the query


How to make a category page the blog home page?

I want to use a category page as the home page of my blog. Is that possible and how can I do it? It tried it with a .htacces rewrite rule but that didn't worked.


Wordpress hide the username/password fields in login page

I have installed the wordpress social login and I want users to login only using social website IDs. Now as a second step I do not want the username and password fields for users in the login page as that is redundant. One way is to hack the php files that display the login page... but I want a more modular structure. I plan to make the username and password fields invisible by adding custom css (using a custom css plugin) and adding the following:               label[for='user_name']     {         visibility:hidden !important;     }     label[for='user_pass']     {         visibility:hidden !important;     }      However the fields still remain visible. Any solutions please?


SimplePie and Updates to original post

If I'm using SimplePie to fetch feeds from another site and store them in my database, running the fetch every hour, will SimplePie detect a change in one of the source's posts and update the content on my site accordingly?


Customising a theme

So I'm kinda new to this WordPress infrastructure. Everyone's been telling me about how great WordPress is and how something like 10% of the top sites out there are using it. So I have a couple of really basic questions about how this all comes together. Maybe they're really obvious, but not so much to me.   1. I found a theme I liked and am using the CSS offered by the Links widget as the main navigation across my site (instead of the CSS in Pages). I therefore created some Pages and am linking to them through Links. However, the site automatically puts links to Pages on the sidebar along with my Links. How do I hide Pages?   2. I created a post for my front page, but I don't like having dates show up? How do I hide?   3. I'd like one CSS style to apply to another class or define a particular object to have another class property. Is there an easy way to do this? Does this require I hack the style sheet? In general, I have experience with HTML/CSS and some PHP so I know the underlying technologies. However, I would like to know how I can leverage the power of Wordpress while still maintaining the flexibility of a fully powered programming language.


Wordpress Users not showing posts

I have a fair few authors on a wordpress blog and I'm facing a problem. In the backend I can list all authors and it shows their post counts -> ![Wordpress Users Listed in Backend](http://i.stack.imgur.com/dDvoF.jpg) But then when I click into this number it is telling me there are no posts by this author! ![Wordpress User No Posts](http://i.stack.imgur.com/W5a8n.jpg) I'm not sure whats happened here. Have tried all the plugins disabled. Posts are being created from the frontend - see http://pastebin.com/Hvvn2tNy Whats going wrong here?


Not your usual Class 'Memcached' not found error

I have several WordPress (3.6) sites on the same server, all of these sites use the Memcached Object Cache - http://wordpress.org/plugins/memcached/ This plugin uses the memcache (no "d") extension.               root@linux10 [~]# php -m | grep mem     memcache     memcached      (Yep, both are installed)               root@linux10 [~]# php -v     PHP 5.4.21 (cli) (built: Oct 29 2013 12:40:13)       2 sites work great with no issues. One particular site only works on the front end. The wp-admin fails to load with this error;               Fatal error: Class 'Memcache' not found in /home/townhous/public_html/wp-content/object-cache.php on line 372      L372 is $this->mc[$bucket] = new Memcache(); I know the object cache is working because the site uses a heavy and slow API, home page load times are 3+ seconds without the object-cache and milliseconds with the object-cache. Disabled the home page takes 3+ seconds and wp-admin works. Enabled and the homepage is fast but wp-admin doesn't work. So, how can object-cache.php work for the front end and report a fatal error in the wp-admin? **Edit** Currently working around this issue with a nasty hack in load.php


Plugin on all site except primary one

I'm using Wordpress multisite on a SAAS project and I want to create a plugin which deals with my custom post types. I want them to be accessible on all sites except on the main site. Do I have to just check blog_id ? Thanks !


How to change hierarchical page permalinks to be flat

I'm building a site for a client with a large navigational structure. I think it would be easiest for them to manage if the pages were listed hierarchically in the admin panel, but it would also be better for their SEO for the permalinks to be shorter. Right now, they have some pages with beastly URLs like this: > www.example.com/company/sustainability/environmental-footprint/recycling- > programs/ Ideally, I'd like to be able to change the permalink structure for pages to be more flat. But I'd really like the highest parent to be present in the URL too. So in this case, the URL for the above page would be: > www.example.com/company/recycling-programs I know that it is possible to put some functions inside the theme's functions.php file that customize the rewrite structure but I'm not really sure where to start. **Note** : I saw the solution proposed here, but it's not really what I'm looking for. WordPress is already redirecting to the correct page when I type in > www.example.com/company/recycling-programs I'd like the permalink to appear as the shortened version by default instead.


Custom class file

I have created a class for custom post-type, taxonomy and meta boxes. I made a method called form-elements and within that I have included HTML form elements. I need to share this method with other form-classes like front-end, or contact form. I just want to reuse this method. Extend can help me do that but I can't figure out how to use 2 or more classes which are entirely different, front-end and form classes. If there is any other way to do this, please share it.


Set posts_per_page in WP_Query for custom taxonomy

I'm using the below code to get all the pages under the custom taxonomy terms, and it shows all the pages. What i want is to limit this and gets only say the last two pages published under the custom taxonomy. The posts_per_page=1 is not working here and show all pages.               <?php     $post_type = 'page';          // Get all the taxonomies for this post type     $taxonomies = get_object_taxonomies( (object) array( 'post_type' => $post_type ) );          foreach( $taxonomies as $taxonomy ) :           // Gets every "category" (term) in this taxonomy to get the respective posts     $terms = get_terms( $taxonomy );          echo '
';     foreach( $terms as $term ) :          $customposts = new WP_Query( "taxonomy=$taxonomy&term=$term->slug&posts_per_page=1" );     $customposts->set('posts_per_page', 1);     if( $customposts->have_posts() ):         while( $customposts->have_posts() ) : $customposts->the_post();             echo '
';             echo '' . get_the_title();              echo '
';         endwhile;          endif;          endforeach;          echo '
';     endforeach;      ?>      Thanks # Edit The right code to solve the problem               <?php             $post_type = 'page';                  // Get all the taxonomies for this post type             $taxonomies = get_object_taxonomies($post_type); // names (default)                  foreach( $taxonomies as $taxonomy ) :                       // Gets every "category" (term) in this taxonomy to get the respective posts                  $terms = get_terms( $taxonomy );                       echo '
';                 foreach( $terms as $term ) :                      $args = array(                 'showposts' => 1,                 'tax_query' => array(                     array(                         'taxonomy' => $taxonomy,                     'terms' => $term->slug,                     'field' => 'slug'                     )                 )                 );                      $customposts = new WP_Query( $args );                      if( $customposts->have_posts() ):                     while( $customposts->have_posts() ) : $customposts->the_post();                         echo '
';                         echo '' . get_the_title();                          echo '
';                     endwhile;                      endif;                      endforeach;                      echo '
';             endforeach;         ?>


How to get Woocommerce Variation ID?

I am trying to create some additional functionality on my Woocommerce backend where I add a custom field to the variations section of backend of Woocommerce. However I cannot for the life of me figure out how to get the current variation id so I can get the post meta. here is what I have been working with:               <?php                  // Get variations             $args = array(                          'post_type'     => 'product_variation',                          'post_status'   => array( 'private', 'publish' ),                          'numberposts'   => -1,                          'orderby'       => 'menu_order',                          'order'         => 'asc',                          'post_parent'   => $post->ID                      );                      $variations = get_posts( $args );                   foreach ( $variations as $variation ) {                               $variation_id           = absint( $variation->ID );$variable_id = $this['variation_id'];                          $variation_post_status  = esc_attr( $variation->post_status );                          $variation_data         = get_post_meta( $variation_id );                          $variation_data['variation_post_id'] = $variation_id;                         echo get_post_meta( $variation_data['variation_post_id'], '_my_custom_field', true) . ' - TEST';                           }               ?>      When I check the backend it looks like it is pulling all the post meta into each variation like this: ![enter image description here](http://i.stack.imgur.com/epum1.png) However if I use the actual variation id like the below then it works for that variation:               echo get_post_meta( 134, '_my_custom_field', true) . ' - Test Variation #134';      * * * **UPDATE:** * * * Here is everything in its entirety in case this helps.               // Display Fields     add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields' );     //JS to add fields for new variations     add_action( 'woocommerce_product_after_variable_attributes_js', 'variable_fields_js' );     // Save Fields     add_action( 'woocommerce_process_product_meta_variable', 'variable_fields_process', 10, 1 );          function variable_fields( $loop, $variation_data, $variation ) {     ?>

                         <?php _e( 'My Custom Field', 'woocommerce' ); ?>                         <input type="text" size="5" name="my_custom_field[<?php echo $loop; ?>]" value="<?php echo $variation_data['_my_custom_field'][0]; ?>"/>                <?php           if (isset( $_POST['variable_sku'] ) ) :             $variable_sku = $_POST['variable_sku'];             $variable_post_id = $_POST['variable_post_id'];             $variable_custom_field = $_POST['my_custom_field'];             for ( $i = 0; $i < sizeof( $variable_sku ); $i++ ) :                 $variation_id = (int) $variable_post_id[$i];                 if ( isset( $variable_custom_field[$i] ) ) {                     update_post_meta( $variation_id, '_my_custom_field', stripslashes( $variable_custom_field[$i] ) );                 }                 echo get_post_meta( $variation_id, '_my_custom_field', true) . ' - Test';             endfor;         endif;                  //works echo get_post_meta( 134, '_my_custom_field', true) . ' - Test 134';                         ?>

     <?php     }          function variable_fields_js() {     ?>

                         <?php _e( 'My Custom Field', 'woocommerce' ); ?>                         <input type="text" size="5" name="my_custom_field[' + loop + ']" />

     <?php     }          function variable_fields_process( $post_id ) {         if (isset( $_POST['variable_sku'] ) ) :             $variable_sku = $_POST['variable_sku'];             $variable_post_id = $_POST['variable_post_id'];             $variable_custom_field = $_POST['my_custom_field'];             for ( $i = 0; $i < sizeof( $variable_sku ); $i++ ) :                 $variation_id = (int) $variable_post_id[$i];                 if ( isset( $variable_custom_field[$i] ) ) {                     update_post_meta( $variation_id, '_my_custom_field', stripslashes( $variable_custom_field[$i] ) );                 }             endfor;         endif;     }


Solutions to repost categories into multisite blogs?

I have done a search on this topic but was unable to find a solution to this specific question involving wordpress multisite. I currently have a wordpress network where domain.com is our main site and then each site has been localized with country code domains and also specific country services. Eg: Main domain.com - Australia domain.com.au - UK domain.co.uk etc In the back end it is set up as sub directories, domain.com, domain.com/au etc. What I am looking to do is to set up categories on the main site eg: Gallery - Australia - UK etc When I tick the box for "Australia" it would automatically repost all posts from the sub category "Australia" into configure/set matching categories? Is there a plugin/solution to this qeury? Have read a lot of articles but were only meant for single site installations.


How to run Two Wordpress blogs with different themes and with single database and same content

How do you run two Wordpress blogs with different themes using one database where the content remains the same in both sites? The issue that I am getting is at the Domain mapping in both blogs.


Single functions.php or split into many small files?

I am creating a simple framework with theme options. I have divided chunks of code within `functions.php` and placed it within a specific folder structure. Now in my main `functions.php` file, I only have `require_once` calls to these files. But for the sake of argument - let's say that I'll end up with 20 files to include. ### QUESTIONS:   1. Does this have effect on WP performance in a visible way ?   2. Is it better to keep it all within 1 file (functions.php)   3. what is the best way to go about this ? Thanks.


Saving zero as meta value

I have a meta_key called "_ordre" and each time I create a new custom post, a new meta_value is set for that meta_key. The thing is, when I set the value of '_ordre' to 0, the meta_value is not saved into the database. Anything else is ok but 0. here is my code:               function wp_audio_save_meta( $post_id, $post )      {         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )             return;         if ( !isset( $_POST['wp_audio_posts_nonce'] ) )             return;         if ( !wp_verify_nonce( $_POST['wp_audio_posts_nonce'], plugin_basename( __FILE__ ) ) )             return;         if ( !current_user_can( 'edit_post', $post->ID ) )             return;         if ( $post->post_type == 'revision' )              return;              $value = $_POST['_ordre'];              if ( get_post_meta( $post->ID, '_ordre', FALSE ) )          {             update_post_meta( $post->ID, '_ordre', $value );         }          else          {              add_post_meta( $post->ID, '_ordre', $value );         };              if ( !$value ) delete_post_meta( $post->ID, '_ordre' );          }     add_action( 'save_post', 'wp_audio_save_meta', 1, 2 );      Any help would be appreciated. Thank you. EDIT: var_dump($_POST):               array(56)      {      ["_wpnonce"]=> string(10) "f874332a30"      ["_wp_http_referer"]=> string(44) "/admin/wp-admin/post-new.php?post_type=audio"      ["user_ID"]=> string(1) "2"      ["action"]=> string(8) "editpost"      ["originalaction"]=> string(8) "editpost"      ["post_author"]=> int(2)      ["post_type"]=> string(5) "audio"      ["original_post_status"]=> string(10) "auto-draft"      ["referredby"]=> string(40) "http://www.xxx.com/admin/wp-admin/"       ["_wp_original_http_referer"]=> string(40) "http://www.xxx.com/admin/wp-admin/"        ["auto_draft"]=> string(1) "1"      ["post_ID"]=> string(4) "1539"      ["autosavenonce"]=> string(10) "f9cf5bed77"      ["meta-box-order-nonce"]=> string(10) "629f95f577"      ["closedpostboxesnonce"]=> string(10) "b121fed9eb"      ["post_title"]=> string(0) ""      ["samplepermalinknonce"]=> string(10) "96f452a929"      ["post_category"]=> array(1) { [0]=> string(1) "0" }      ["newcategory"]=> string(29) "New category name"      ["newcategory_parent"]=> string(2) "-1"      ["_ajax_nonce-add-category"]=> string(10) "411da663fa"      ["wp_custom_audio_file_noncename"]=> string(10) "584d7b259e"      ["xxx"]=> string(4) "1539"      ["title_up_1"]=> string(0) ""      ["wp_audio_posts_nonce"]=> string(10) "584d7b259e"      ["_ordre"]=> string(1) "0"      ["post_name"]=> string(0) ""      ["wp-preview"]=> string(0) ""      ["hidden_post_status"]=> string(5) "draft"      ["post_status"]=> string(7) "publish"      ["hidden_post_password"]=> string(0) ""      ["hidden_post_visibility"]=> string(6) "public"      ["visibility"]=> string(6) "public"      ["post_password"]=> string(0) ""      ["jj"]=> string(2) "03"      ["mm"]=> string(2) "02"      ["aa"]=> string(4) "2013"      ["hh"]=> string(2) "15"      ["mn"]=> string(2) "03"      ["ss"]=> string(2) "28"      ["hidden_mm"]=> string(2) "02"      ["cur_mm"]=> string(2) "02"      ["hidden_jj"]=> string(2) "03"      ["cur_jj"]=> string(2) "03"      ["hidden_aa"]=> string(4) "2013"      ["cur_aa"]=> string(4) "2013"      ["hidden_hh"]=> string(2) "15"      ["cur_hh"]=> string(2) "15"      ["hidden_mn"]=> string(2) "03"      ["cur_mn"]=> string(2) "03"      ["original_publish"]=> string(7) "Publish"      ["publish"]=> string(7) "Publish"      ["post_mime_type"]=> string(0) ""      ["ID"]=> int(1539)      ["comment_status"]=> string(6) "closed"      ["ping_status"]=> string(6) "closed"      }


How can I use WordPress functions in my stylesheet?

I have my `style.php` file looking like this.               <?php  header('Content-Type: text/css');?>     #div{         background:<?php  echo get_option('bgcolor');?>;     }      This does not work, but when I do this it works.               <?php  header('Content-Type: text/css');?>     #div{         background: <?php  echo 'blue';?>;     }      What would be the problem? This is the mainfile.php                <?php               function test(){         global get_option('bgcolor');?>                  <input type="text" id="bgcolor" name="post_popup_settings[bgcolor]" value="<?php echo get_option('bgcolor');?> " />         <?php     }         add_action('admin_head','test');      This is actually in the admin section.


How to use plugins_url() inside PHP stylesheet file

I created a plugin and use php file as stylesheet file PHP style sheet file:               <?php         header('Content-type: text/css; charset: UTF-8');         $x_position = 0;         $y_position = -40px;     ?>     .blugin_box{         width:140px;         height:140px;         background:url("/mysite/wp-content/plugins/myimgfolder/my_img.png") no-repeat $x_position $y_position;     }      **It works well** , **but** when I try to use plugins_url() as below, **stylesheet stop loading**               background:url(plugins_url()."/myimgfolder/my_img.png") no-repeat $x_position $y_position;      How can I make it work?


Whats the proper way to use a php stylesheet in a wordpress theme?

> **Possible Duplicate:**   >  How can I use WordPress functions in my stylesheet? I have a file, custom.php, thats basically a stylesheet with php variables for the styles. I used this guide to make it but Im not sure how to use the style sheet in my theme. Here is my /styles/custom.php:               <?php      header("Content-type: text/css");      ?>     div{background-color:<?php echo "red" ?>;}      and my functions.php file has this:               $root=get_bloginfo('template_directory');      wp_enqueue_style("custom", $root."/styles/custom.php");       So the custom.php file should be rendered as a stylesheet right? But my wordpress site doesnt load the file contents. When I look at the source code via firebug and expand the custom.php file all I see is:               Reload the page to get source for: http://samsung/wordpress/wp-content/themes/kjd/styles/custom.php?ver=3.4.1      This is on my dev machine running Ubuntu 12.04, LAMP and Wordpress 3.4.1


Translation to ACF relationship field

I'm building a WordPress site that is supposed to end up with a Danish backend. This works fine for core WordPress, but some plugin makes it really hard to make a complete translation. A problem I just found has to do with the relationship field in the ACF plugin. I love the plugin, but there seems to be one bad call here from the developer's side. Or maybe I'm missing something. The problem is the `post_type` descriptions here: ![Relationshipfield](http://i.stack.imgur.com/123YE.png) So the problem is where it says "Production". That's a custom post type that I've set up with a Danish label "Forestilling" with CPT UI. But when I look into the code behind this relationship field it seems to be pulling the `post_type` rather than the label:               // right aligned info     $title = '';          if( in_array('post_type', $field['result_elements']) )     {         $title .= get_post_type();     }          // WPML     if( $options['lang'] )     {         $title .= ' (' . $options['lang'] . ')';     }          $title .= '';      I would assume that they took their precaution with the WPML section. But I'm not using WPML, and have no idea if this is needed just to change the translations. All I would do is swap the `get_post_type` line with this:               $title .= get_post_type_object( get_post_type( $post ) );      But that means hacking the plugin, and this would be overwritten as soon as I update the plugin. How could I go about fixing this?


Media Manager (since 3.5): How to show an empty Media Library when creating a media frame?

Is there a way to make sure the "Media Library" tab does not show any images until I start uploading some in the "Upload Files" tab? I am creating a wp.media frame with the following code:               var myframe =  wp.media({         title : 'Bla Bla',         frame : 'select',         library: {             //query : false, // not working             type : 'image',         },         //library : '', // not working either         multiple : true,         button : { text : 'Finish' },        });      It creates this: ![Media Library with all items ever uploaded](http://i.stack.imgur.com/GUrOS.png) Is there a way to make sure the "Media Library" tab does not show any images until I start uploading some in the "Upload Files" tab? And then obviously only shows those images that I just uploaded from the "Upload Images" tab.


Archive Page - How to output a specific custom field instead of post content

I have several custom post types and I am using `archive.php` and it works fine, but now the client wants to replace the post content with a custom field called `ingredients` for the custom post type `packaged`. I wasn't going to create a separate archive page for each custom post type unless it was necessary, so how would I write a conditional statement and loop to replace:               genesis_standard_loop();      if the custom post type is `packaged`?


Comments not showing in custom post type - Wordpress

I've created a custom post type, and i want to display and allow comments. I have this in function.php :               // Add Custom Post Types         add_action( 'init', 'thm_post_types' );          // Add Custom Post Types Function         require_once ( THEME_INCLUDES . 'theme-post-types.php' );              require_once ( THEME_INCLUDES . 'theme-comments.php' );      In my theme-post-types.php i have :               register_post_type( 'product',         array(             'labels' => array(                 'name' => 'Product Items',                 'singular_name' => 'Product' ,                 'add_new' => 'Add New Product',                 'add_new_item' => 'Add New Product Item' ,                 'edit' => 'Edit Product',                 'edit_item' => 'Edit Product Item',             ),             'description' => 'Product Items.' ,             'public' => true,             'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ), // ***** i believe this is the problem ******             'taxonomies' => array('category', 'post_tag')              )     );     register_taxonomy( 'product_category', array( 'product' ), array( 'label' => "Categories", "singular_label" => "Category" ) );      And finally in my theme-comments.php :               function thm_format_comment($comment, $args, $depth) {     $GLOBALS['comment'] = $comment; ?>     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">         <div class="comment" id="comment-<?php comment_ID() ?>">
<?php echo get_avatar( $comment, $size='80' ); ?>             <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ) ?>

                 <?php comment_author_link(); ?>                 <?php comment_date( 'F d, Y - G:i ' ); ?>

                 <?php if ($comment->comment_approved == '0') : ?>
<?php _e( 'Your comment is awaiting moderation.' ); ?>
                 <?php endif; ?>                 <?php comment_text() ?>

      In my custom post type php i have :
                 <?php comments_template(); ?>
      Custom post shows content, but it's not showing comments or comment form... Any ideas?


Front end Submit not posting to Custom Post type

I have a custom script that allows to add per form submit to add contacts to a custom post type. But for some reason it always adds the data to the posts instead into the post type. i have tried everything so far but no luck here is the code for the form i took out the form verification out since that part is working                       if( !isset( $hasError ) ) {                  $submit_to_contact_manager = array(                 'post_title' => 'Request from '. esc_attr(strip_tags($_POST['request_lastname'])),                 'post-type' => 'tpf_cnm',                 'post_status' => 'pending'             );                  $contactmanager_id = wp_insert_post($submit_to_contact_manager);                  if($contactmanager_id)             {                      // Update Custom Meta                 update_post_meta($contactmanager_id, 'tpf_first_name_preorders', esc_attr(strip_tags($_POST['request_firstname'])));                 update_post_meta($contactmanager_id, 'tpf_last_name_preorders', esc_attr(strip_tags($_POST['request_lastname'])));                 update_post_meta($contactmanager_id, 'tpf_email_preorders', esc_attr(strip_tags($_POST['request_email'])));                 update_post_meta($contactmanager_id, 'tpf_preorder_desc', esc_attr(strip_tags($_POST['request_message'])));                 update_post_meta($contactmanager_id, 'tpf_preorder_desc', esc_attr(strip_tags($_POST['request_category'])));                       }         }      and here is the post type function                       add_action('init', 'tpf_cnm_init');              function tpf_cnm_init(){              $tpf_cnm_type_labels = array(         'name' => _x('Contacts', 'post type general name'),         'singular_name' => _x('Contact', 'post type singular name'),         'add_new' => _x('Add New Contact', 'image'),         'add_new_item' => __('Add New Contact'),         'edit_item' => __('Edit Contact'),         'new_item' => __('Add Contact'),         'all_items' => __('View Contacts'),         'view_item' => __('View Contact'),         'search_items' => __('Search Contacts'),         'not_found' =>  __('No Contacts found'),         'not_found_in_trash' => __('No Contacts found in Trash'),          'parent_item_colon' => '',         'menu_name' => 'Contacts'         );              $tpf_cnm_type_args = array(             'labels' => $tpf_cnm_type_labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,              'show_in_menu' => true,              'query_var' => true,             'rewrite' => array( 'slug' => _x( 'contact-manager', 'URL slug', 'your_text_domain' ) ),             'capability_type' => 'post',             'has_archive' => true,              'hierarchical' => false,             'menu_position' => null,             'supports' => array( 'title', 'comments', 'custom-fields' )           );               register_post_type('tpf_cnm', $tpf_cnm_type_args);          }      any help would be nice im going crazy with this atm thank you all in advance


Only ads with pictures in featured slider

I have classified ads wordpress website with jCarouselLite slider on main page. Is there any way to make the featured slider exclude ads that have no image attachments, so the featured slider only shows ads that have images uploaded? I've built my site on free basis, so all ads gets in featured slider. Many people not uploading pictures and i do not want to force them doing that, but blank white squares in slider looks ugly. So, i think, that way if i figure out how to filter ads for slider, it will motivate them to upload images. This part of code that generates random ads in slider:                   /**      * Returns ads which are marked as featured for slider      */     function cp_get_featured_slider_ads() {              $args = array(             'post_type' => APP_POST_TYPE,             'post_status' => 'publish',             'post__in' => get_option('sticky_posts'),             'posts_per_page' => 15,             'orderby' => 'rand',             'suppress_filters' => false,         );              $args = apply_filters( 'cp_featured_slider_args', $args );              $featured = new WP_Query( $args );              if ( ! $featured->have_posts() )             return false;              return $featured;     }      I have found a way to determine if a post has an image attachment:               $query_images_args = array(         'post_type' => 'attachment',         'post_mime_type' =>'image',         'post_status' => 'inherit',         'post_parent' => $post->ID     );          $attachments = get_children($query_images_args);      OR               $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image') );      But how to combine this together correctly?


foreach pagination

I am looking for help in how to paginate my foreach output. I've looked at other questions and answers and cannot find a solution that works for me or that I can figure out on my own. Right now my code, which is below, outputs everything into table rows. My problem, of course, is that it dumps all data on a single page -- hence the reason I want pagination. I want to paginate for every 11 items on the page. The page is a magazine archive, and there are 11 issues pear year -- so every page is equal to 1 year of our magazine. The first page should host issues 1-11 and page two should host issues 12 through 22, etc. We have 10 years worth of magazine issues. Any help would be greatly appreciated. Thank you!

     <?php $col = 0; ?>     <?php foreach (get_terms('term') as $cat) : ?>          <?php if ($col > 0 && $col % 3 == 0): ?>

     <?php endif; ?>     <?php $col++; ?>                    <a href="<?php echo get_term_link($cat->slug, 'term'); ?>"><?php echo $cat->name; ?>
          <a href="<?php echo get_term_link($cat->slug, 'term'); ?>"><?php echo $cat->description; ?>
          <a href="<?php echo get_term_link($cat->slug, 'term'); ?>"><img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" />     	     <?php endforeach; ?>


Second level subcategory

I'm trying to get anoter level subcategory to show in my select option. I've managed to get one... how can i get the other?               <?php         $taxonomies = array(CUSTOM_CAT_TYPE);         $args = array('orderby' => 'count', 'hide_empty' => 0);              $myterms = get_terms($taxonomies, $args);         $output = "<select class=\"select\" name='select_cat' title=\"Select Category\">";         $output .= "<option value=''>Selecteer Rubriek</option>";                   foreach ($myterms as $cate)             {                                    if($cate->parent == 0)                 {                 $catename = "";                 $catename = $cate->name;                 $output .='<option disabled="disabled" value="'.$cate->term_id.'">'.$catename. '</option>';                     foreach ($myterms as $subcate)                         {                         if($subcate->parent == $cate->term_id)                             {                                                                $catename = "";                             $catename = $subcate->name;                             $output .='<option value="'.$subcate->term_id.'">'.'    '.$catename.'</option>';                                 foreach ($subcate as $subsubcate)                                     {                                     if($subsubcate->parent == $cate->term_id)                                         {                                                                            $catename = "";                                         $catename = $subsubcate->name;                                         $output .='<option value="'.$subsubcate->term_id.'">'.'    '.$catename.'</option>';                                              }                                     }                             }                         }                     }             }                   $output .="</select>";         echo $output;              ?>      Any ideas?! Or perhaps a better way to get where I want to be! :)


How do I share categories across multiple post types?

I have three custom post types in my theme, and each of them have categories enabled. I want these post types to share the categories between them, so that when adding a category to one, the others get it as well. Is there a way to do this easily?


Weather Plugin Recommendation

Has anyone used any of the Wordpress Weather Plugins? Any recommendations? Anyone tried out more than one? Hoping to get pointed in the right direction before I dive in.


Force the Website URL to Include "www" and to be Upper Case?

No matter what url somebody uses to access my site, I'd like it to redirect to www.MyUrl.com. Is this possible?


How to add multiple copies of a widget from "available widgets"

I've found a widget that I need to add to more than one sidebar widget area. However, apparently its been coded so that once you drag it from "available widgets" over to a sidebar widget, it disappears from the "available widgets" listing. I'd like to use it in more than one sidebar. What determines this in the widget code?


Inserting rows into a custom table, when plugin is activated

Trying to create a plugin that creates a custom table & populates it with a row of data, once activated. The table is created OK, but the row of data is not added. Please can someone point out what I have done wrong with the row of data?                register_activation_hook( __FILE__, 'pu_create_plugin_tables' );         register_activation_hook( __FILE__, 'pu_insert_custom_table' );              function pu_create_plugin_tables()         {             global $wpdb;                       $table_name = $wpdb->prefix . 'countries';                  $sql = "CREATE TABLE $table_name (               id int(11) NOT NULL AUTO_INCREMENT,               name varchar(255) DEFAULT NULL,               labour_cost_rate int(11) NOT NULL,               overheads     DECIMAL(6,2) NULL,               profit DECIMAL(6,2) NULL,               UNIQUE KEY id (id)                   );";                       require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );             dbDelta( $sql );         }                        function pu_insert_custom_table(){                  global $wpdb;                $welcome_id = "3";           $welcome_name  = "helen";                $rows_affected = $wpdb->insert( $table_name, array( 'id' => $welcome_id, 'name' => $welcome_name ));          require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );          dbDelta( $rows_affected );                 }


get_template_part from plugin

This is default get_template_part function inside WordPress:               function get_template_part( $slug, $name = null ) {         do_action( "get_template_part_{$slug}", $slug, $name );              $templates = array();         if ( isset($name) )             $templates[] = "{$slug}-{$name}.php";              $templates[] = "{$slug}.php";              locate_template($templates, true, false);     }      I am trying to use that action for locating custom post type loop file from plugin:               add_action( "get_template_part_templates/loop", function($slug, $name){         if ("example" == $name){             if (!locate_template("templates/loop-{$name}.php", false, false)){                 /* What do you suggest to do here? */             }         }        },10,2 );      I need a solution that;   1. Check if theme have files for "example" custom post type   2. If dont have; use plugin's template files for showing and dont use theme's default solution **Update:** this is the code that calling template part in theme:               global $post;     get_template_part( 'templates/loop', $post->post_type );


Modifying the media-template.php file, the right way?

The `[gallery]` shortcode accepts the `columns='0'` as an attribute so that it doesn't insert any breaks in the HTML between gallery items, however this option is not available in Gallery Settings interface ("Add Media" pop-up when editing pages/posts). I've located the code in `wp-includes\media-template.php` line 396 to 406;                        <?php _e('Columns'); ?>         <select class="columns" name="columns"             data-setting="columns">             <?php for ( $i = 1; $i <= 9; $i++ ) : ?>                 <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, 3 ); ?>>                     <?php echo esc_html( $i ); ?>                 </option>             <?php endfor; ?>         </select>           I don't want to directly edit a core file but I would like to add `<option value="0">Responsive</option>` to that list. What's the best way to do that without editing core files? I was thinking some kind of filter, although I'm not too familiar with them.


Linking custom taxonomies and posts

Im trying to figure out how to display data from custom post's into a custom taxonomy in a different post type. I currently have 2 sections. **Work** & **Talent**. **Work** will display individual work/pieces and **Talent** will display individual artists. They both sit on the left hand side, in the admin area, like pages and posts do. What I would like to happen is once I have created an artist(post) that sits under **Talent** this data is pulled through to **Work**. So within **Work** it would show a custom taxonomy listing out all of the artists names which I can then assign to the piece of work. Then on the front end side of this pull through the artists name and further data from the **Talent** section but is display on a **Work** page. I don't want to have to manually re-enter each artist's information to a **Work** post as if the artist updates their information I have to manually go in to each **Work** post and update it. Any advice on this would be great. Thanks.


Can't select a page using is_page()

I've got 2 pages: "home" and "blog". In Settings they're set as following: Front page = "Home", "Posts page = "Blog". However I can't select the "Blog" page: `is_page('blog')` doesn't validate, nor `is_home()` nor is_`front_page()`. What condition could validate this page?


Retrieve post thumbnail as array

How can I retrieve the post thumbnail (featured image) as an array?   Using get_post_thumbnail() I noticed in the WP documentation that there is a third parameter from, which I understand, one would be able to set it to return the values as an array instead of a string, but I can't figure out how.   The reason I want to return the image as an array is to exclude unnecessary attributes in the output such as 'wp-post-image' etc. Problem solved:               $image = wp_get_attachment_image_src( get_post_thumbnail_id(), $size);


Auto-refresh page every minute?

How do I make a WP page (w/ dynamic content) auto-refresh every minute? With PHP, I'd use a "Refresh:" header, and in HTML I could use a HTTP-EQUIV tag or something. However, WP generates headers itself, and I can't tweak anything until the body, no? I searched in vain for a plug-in that does this.


Change CSS/formatting on specific page, but not pages in general?

How do I change the formatting on http://wordpress.barrycarter.info/index.php/voronoi-temperature-map/ so that (for example) the map's nearly flush with the bottom of the menubar? I don't want to edit page.php, since that'll change all pages, not just this one.


Import HTML/JS post to WordPress?

I have a working HTML/JS page that uses Google Maps: http://test.barrycarter.info/sunstuff.html How do I import this into wordpress.barrycarter.info? Simply cutting/pasting or doing "`<?php include()?>`" doesn't work, since WP processes the result before displaying it, breaking the page: http://wordpress.barrycarter.info/index.php/test-sunstuff-include-fail/ (use "view source" to see the hideously mangled JS). I can't even use the "Google Maps v3 Shortcode" plugin, since the map overlays are generated client-side, not via KML.


Display KML (or other "raw data" file) nicely in WP?

I want to display this file: http://data.barrycarter.info/aprswx.txt on wordpress.barrycarter.info, but all my attempts fail because of preprocessing: http://wordpress.barrycarter.info/index.php/test-kml-fail (use "view source" to see what parts of the file WP "hides" from view).


How to modify theme content in Thematic?

I'm not new to PHP, HTML, CSS, and the like, not at all, but I'm definitely new to creating Wordpress themes. I was recommended to use the Thematic theme as a base theme and modify it using functions and CSS. Here's essentially what I'm looking to do:   1. Modify the header to be an image.   2. Add a background image or images to "nicen" things up.   3. Basically completely make the theme look different. Maybe my line of logic is wrong, but I'm fighting the urge to copy over the PHP files defining the layout and modify them to fit. Is this the right approach? I want to basically be as free as possible to modify things dramatically. Should I just build a theme from scratch?