External Script Using WP - Hooks / Actions Not Working?

I've researched this problem in depth, but still stumped. **Simply stated, I have an external uploader script which loads WP. Yet I cannot seem to grab any of the actions/filters I've put into it. Why is this?** I've tried various methods to load WP in the script. This returns a 404 when the uploader (javascript) calls it:               define( 'WP_USE_THEMES', false );     require_once('../../wp-blog-header.php');      So a work-around I found, seems to do fine:               require_once('../../wp-config.php');     $wp->init();     $wp->parse_request();     $wp->query_posts();     $wp->register_globals();      This above example seems to work, except I cannot find any conceivable way to hook into it. Even if I put the entire upload processor into a function which hooks to various places such as ...               add_action('plugins_loaded', 'the_upload_processing_function');     //or     add_action('wp_loaded', 'the_upload_processing_function');     //and so forth...      Dead air...no response. The script will run if I leave it outside of a function, just running under the load wordpress-start-up code, **but the hooks / actions do not work.** The result I cannot seem to achieve:   * Plugin calls the uploader script via javascript, upload.php (works)...    * The plugin hopefully loads before the upload script, and depending on $_POST var, it will alter the target directory path using a filter: This is the filter...               $targetDir = apply_filters('ss_upload_destination', $targetDir);        * The $`targetDir` should thus be altered, but the hooks seem invisible to the plugin. Absolutely no way to grab it. I've tired to describe the problem without making the issue too long. I'd appreciate any insight that can be shared. * * * **For reference, here is the entire upload script:**               <?php          require_once('../../wp-config.php');     $wp->init();     $wp->parse_request();     $wp->query_posts();     $wp->register_globals();          //define( 'WP_USE_THEMES', false );     //require_once('../../wp-blog-header.php');          if(!is_user_logged_in())         die();          // Make sure file is not cached (as it happens for example on iOS devices)     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");     header("Cache-Control: no-store, no-cache, must-revalidate");     header("Cache-Control: post-check=0, pre-check=0", false);     header("Pragma: no-cache");          /*      // Support CORS     header("Access-Control-Allow-Origin: *");     // other CORS headers if any...     if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {         exit; // finish preflight CORS requests here     }     */          // 5 minutes execution time     //@set_time_limit(5 * 60);          // Uncomment this one to fake upload time     // usleep(5000);          // Settings     $targetDir = ss_upload_dir . ss_blog_path . '/';          if(!is_numeric($_REQUEST['upload_destination']))         die;          $blog_id = $_REQUEST['upload_destination'];          switch_to_blog($blog_id);          $path = ss_get_blog_path($blog_id);          $targetDir = ss_upload_dir . $path . '/';          $targetDir = apply_filters('ss_upload_destination', $targetDir);          //$targetDir = 'uploads';     $cleanupTargetDir = false; // Remove old files     $maxFileAge = 5 * 3600; // Temp file age in seconds          // Get a file name     if (isset($_REQUEST["name"])) {         $fileName = $_REQUEST["name"];     } elseif (!empty($_FILES)) {         $fileName = $_FILES["file"]["name"];     } else {         $fileName = uniqid("file_");     }          $filePath = $targetDir . $fileName;          // Chunking might be enabled     $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;     $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;          // Remove old temp files         if ($cleanupTargetDir) {         if (!is_dir($targetDir) || !$dir = opendir($targetDir)) {             die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');         }              while (($file = readdir($dir)) !== false) {             $tmpfilePath = $targetDir . $file;                  // If temp file is current file proceed to the next             if ($tmpfilePath == "{$filePath}.part") {                 continue;             }                  // Remove temp file if it is older than the max age and is not the current file             if (preg_match('/\.part$/', $file) && (filemtime($tmpfilePath) < time() - $maxFileAge)) {                 @unlink($tmpfilePath);             }         }         closedir($dir);     }                  // Open temp file     if (!$out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb")) {         die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');     }          if (!empty($_FILES)) {         if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) {             die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');         }              // Read binary input stream and append it to temp file         if (!$in = @fopen($_FILES["file"]["tmp_name"], "rb")) {             die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');         }     } else {             if (!$in = @fopen("php://input", "rb")) {             die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');         }     }          while ($buff = fread($in, 4096)) {         fwrite($out, $buff);     }          @fclose($out);     @fclose($in);          // Check if file has been uploaded     if (!$chunks || $chunk == $chunks - 1) {         // Strip the temp .part suffix off          rename("{$filePath}.part", $filePath);         do_action('ss_file_upload_complete', $filePath);     }          do_action('ss_after_upload');          // Return Success JSON-RPC response     die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');


How can I create a custom shortcode that will return a custom post type by ID?

Please excuse my ignorance, this seems simple but I can't figure it out and I've been rushing to hack things together. I can't find anything online to help me out. **What I have:** A custom post type named "case_study". There are going to be a lot of these published and they will be used in various places throughout the site, some of them more than once. **What I need:** To print an individual case study where needed, by ID. I feel like using a shortcode would be the most obvious way to do this, but I'm failing to get there. (Perhaps there is a better user-friendly option?) I would like my shortcode to work like this: [case_study id=31] Here is my plugin code. This currently prints the entire case study category when I use the short code:               //Case study Post Type     add_action('init', 'register_cpt_case_study');          function register_cpt_case_study() {              $labels = array(             'name' => _x('Case Studies', 'case_study'),             'singular_name' => _x('Case Study', 'case_study'),             'add_new' => _x('Add New', 'case_study'),             'add_new_item' => _x('Add New Case Study', 'case_study'),             'edit_item' => _x('Edit Case Study', 'case_study'),             'new_item' => _x('New Case Study', 'case_study'),             'view_item' => _x('View Case Study', 'case_study'),             'search_items' => _x('Search Case Studies', 'case_study'),             'not_found' => _x('No case studies found', 'case_study'),             'not_found_in_trash' => _x('No case studies found in Trash', 'case_study'),             'parent_item_colon' => _x('Parent Case Study:', 'case_study'),             'menu_name' => _x('Case Studies', 'case_study'),         );              $args = array(             'labels' => $labels,             'hierarchical' => false,             'description' => 'A case study plugin for better management and organization',             'supports' => array('title', 'editor'),             'public' => false,             'show_ui' => true,             'show_in_menu' => true,             'menu_icon' => 'http:www.changethis.com', //change this icon             'show_in_nav_menus' => false,             'publicly_queryable' => true,             'exclude_from_search' => true,             'has_archive' => false,             'query_var' => true,             'can_export' => true,             'rewrite' => true,             'capability_type' => 'post'         );              register_post_type('case_study', $args);     }          // THE SHORTCODE FOR CASE STUDIES     function case_study_shortcode($atts) {         extract(shortcode_atts(array(             'id' => '',                         ), $atts));     //The Query         query_posts('post_type=case_study');     //The Loop         if (have_posts()) : while (have_posts()) : the_post();                 echo '
';                 echo the_title();                 echo '
';                 echo the_content();             endwhile;         else:         endif;          //Reset Query         wp_reset_query();     }          add_shortcode('case_study', 'case_study_shortcode');      Any advice would be greatly appreciated!


Remove nav menu item by script

I want to create my custom nav menu using a script in a wp plugin. I'm almost there using this tutorial. All I need is the option to delete menu entries. something like wp_delete_nav_menu_item($menuID, $itemID); As an alternative, I could create a new menu using wp_create_nav_menu($menu_name); so I don"t have to delete the default entries of the menu I would be working with otherwise. The problem here is, that the theme gives options for the position of the menu like 'header' and I dont know how i can define a position for a newly created menu. Hope someone can give advice so I can solve one of these issues. Thanks! This is the code I am working with so far. I need the code for the part to delete the default entries               //Add Menu     //Get Menu ID     $mymenu = wp_get_nav_menu_object('Header');     $menuID = $mymenu->term_id;          //Check if Menu exists     if( !$mymenu ) {         //Menu exists -> Delete the default entries         //     } else {         //Menu does not exist -> Create it         $menuID = wp_create_nav_menu('Header');     }          //Create new Menu Entries     //Create Parent Menu Entries     $myPage = get_page_by_title( 'Home' );     $itemData =  array(     'menu-item-object-id'   => $myPage->ID,     'menu-item-parent-id'   => 0,     'menu-item-position'    => 1,     'menu-item-object'      => 'page',     'menu-item-type'        => 'post_type',     'menu-item-status'      => 'publish'     );     wp_update_nav_menu_item($menuID, 0, $itemData);


Page displaying but the inspector shows 500 Internal Server error?

I have setup custom urls for a wordpress based site, (not using wordpress pages or posts) but custom urls and including custom page templates. I have several urls working fine except one, page displays fine but the inspector shows 500 internal server error. So the question is where does wordpress output header information, any hook or filter to change it or what is the proper way of adding custom url patterns. Im using `add_rerite_tag()` then `add_permastruct()` finally using `template_redirect()` to load a custom php file.


The page that displays Posts on homepage

I want to know the page responsible for displaying the blog posts in WordPress. Where I can probably expect to find the SQL query and post rendering so I can edit some stuff by myself.


Users problem (multi-author plus multisite)

all. I am having a users-related problem on a multi-author site (actually two sites on a multi-site, both of which have the same users). Here are some details: 1) In the backend users' list, the number of users in parentheses at the top is correct (5), but in the actual list, only two appear. 2) The problematic users can sign into the admin. However, one of them can see only the left column; the main content area of the admin remains blank for him. We'll call him "User 1." Oddly, the only other active user of the "problem users" is still able to post. 3) On the front end, on one site of the multisite, existing posts show up fine, even by User 1. On the other site, however, posts by User 1 are missing. That is, the actual full post page is missing. The post appears on the archive page, complete with the user's name, but the single post page renders the title but not the content. 4) On the (static) front page, I am using a WP excerpt query in order to render excerpts of the most recent five posts. This renders fine until it hits the first excerpt it's supposed to show from User 1, at which point the page stops rendering, with the result that his excerpt as well as the sidebar and footer (both of which come later in the HTML) do not render. This _seems_ to have started while User 1 was editing his profile, so I'm considering creating a temporary user, deleting his profile in the database (can't delete it in the admin, since it's not actually appearing in the list) and assigning his posts to the temp, then re-creating his user account to see if that fixes the problem. But someone else perhaps has better ideas. I'm currently running 3.9, but it seems that User 1 problems started before the upgrade.


remove plugin admin menu in wordpress without installing plugin in v3.8.1

I follow instruction on this page to remove some admin menus. http://codex.wordpress.org/Function_Reference/remove_menu_page But is seems it only works on default wp admin menus. Admin menu added by plugins is not getting removed. For example, I tried removing admin menu of wordpress seo by yoast using remove_menu_page( 'admin.php?page=wpseo_dashboard' ); But the menu remains there. All other standard wp admin menus were removed except wp seo by yoast. Any idea how can I also remove admin menu of plugins? I saw some similar questions but the recommended codes doesn't seem to be 3.8.1 compatible so I added this question to start a new fresh question specific to 3.8.1 Thanks


Add Menu Item in Specific Order

I am using the code below to add a Login/Logout menu item to WordPress programatically. I am trying to figure out how to specify the placement of this menu to be in the #2 position. IE - Main Menu Home | Login/Logout | Contact Us               add_filter('wp_nav_menu_items', 'voodoo_loginout_link', 10, 2);           function voodoo_loginout_link($items, $args) {         $voodooredir = htmlspecialchars($_SERVER['REQUEST_URI']);         $loginoutlink = wp_loginout($voodooredir, false);         return $items . "<li> $loginoutlink </li>";     }


Including Older Version of jQuery for IE7/IE8

I realise jQuery 2.0 dropped support for some browsers including IE7 and IE8. I'm only using a bit of jQuery on my WordPress site, but since I need to support IE7/IE8, I was wondering what the best way was to go about including older versions of jQuery? Or should I just choose one version (like 1.9.1), that supports older and more modern browsers, and stick with that? I'm currently injecting jQuery into my `functions.php` like so:               if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);     function my_jquery_enqueue() {         wp_deregister_script('jquery');         wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js", false, null);         wp_enqueue_script('jquery');     }      Any help is appreciated. Thanks in advance!


Allow unfiltered HTML for not logged in users when saving a post

I'm using this code:               $var1 = $_GET["t1s2ninput"];     $var2 = $_GET["t1s2pinput"];     $new_post = array (         'post_title'    => 'Title

Variation:

'. $var1 .'

',         'post_author'   => 5,         'post_content'  => 'Lorem ipsum',         'post_status'   => 'publish',         'post_type'     => 'product',     );          $post_id = wp_insert_post($new_post);          wp_set_post_terms( $post_id, 72, "product_cat");          $var3 = $var2 / 1;     update_post_meta( $post_id, '_price', $var3 );          global $woocommerce;      $woocommerce->cart->add_to_cart($post_id, 1);      When I'm logged as admin it works flawlessly, however in any other case (logged out, other user...) the title of the post doesn't work as it should, the `HTML` tags (in this case `<dl class="variation">` and the others) disappear. What am I doing wrong? Thank you.


how to show the data from a myqsl database in a post

im new with using wordress. I am trying to make a website that would show the data table from my mysql database. or is there any free plugin that will be able to do this?


media library not showing thumbnails after deleting full image

I am using a bit of code, that deletes the unneccessary full images after uploading and adding different sizes. deleting function in functions.php:               add_filter( 'wp_generate_attachment_metadata', 'delete_fullsize_image' );     function delete_fullsize_image( $metadata )     {     $upload_dir = wp_upload_dir();     $full_image_path = trailingslashit( $upload_dir['basedir'] ) . $metadata['file'];     $deleted = unlink( $full_image_path );          return $metadata;     }      So, that works great, but the problem is I can not see any thumbnails in the media library anymore as they are generated by the full size image only, it seems. This makes it really complicated/hard to work with the uploaded images. Is it somehow possible to "repair" this and and get those little thumbnails in the media library from another size (like medium, large or any custom named size)? Thank you in advance, guys.


Problem with wp_editor

I tried to add wp_editor in this function but no success. Can someone help me to add wp_editor in the 'story' field..                   function guestposts_shortcode( $atts ) {         extract ( shortcode_atts (array(             'cat' => '1',             'author' => '1',             'thanks' => get_bloginfo('home'),         ), $atts ) );              return '<form class="guests-post" action="'. plugin_dir_url("guest-posts.php") .'guest-posts/guest-posts-submit.php" method="post">             ' . __('Post Title:', 'guest-posts') . '
                 <input type="text" name="title" size="60" required="required" placeholder="' . __('Post title here', 'guest-posts') . '">
             ' . __('Story', 'guest-posts') . '             '. wp_nonce_field() .'                 <textarea rows="15" cols="72" required="required" name="story" placeholder="' . __('Start writing your post here', 'guest-posts') . '"></textarea>
             ' . __('Tags', 'guest-posts') . '
                 <input type="text" name="tags" size="60" placeholder="' . __('Comma Separated Tags', 'guest-posts') . '">

             ' . __('Your Name', 'guest-posts') . '
                 <input type="text" name="author" size="60" required="required" placeholder="' . __('Your name here', 'guest-posts') . '">
             ' . __('Your Email', 'guest-posts') . '
                 <input type="email" name="email" size="60" required="required" placeholder="' . __('Your Email Here', 'guest-posts') . '">
             ' . __('Your Website', 'guest-posts') . '
                 <input type="text" name="site" size="60" placeholder="' . __('Your Website Here', 'guest-posts') . '">

             <input type="hidden" value="'. $cat .'" name="category"><input type="hidden" value="'. $author .'" name="authorid">             <input type="hidden" value="'. $thanks .'" name="thanks">             <input type="hidden" value="'. str_replace('/wp-content/themes', '', get_theme_root()) .'/wp-blog-header.php" name="rootpath">             <input type="submit" value="' . __('Submit The Post', 'guest-posts') . '"> <input type="reset" value="' . __('Reset', 'guest-posts') . '">
             </form>             ';         }     add_shortcode( 'guest-posts', 'guestposts_shortcode' );          ?>      And this is the submit.php                   <?php          //Get the submitted form     ob_start();     require_once($_POST["rootpath"]);     $title = $_POST["title"];     $story = $_POST["story"];     $tags = $_POST["tags"];     $author = $_POST["author"];     $email = $_POST["email"];     $site = $_POST["site"];     $authorid = $_POST["authorid"];     $category = $_POST["category"];     $thankyou = $_POST["thanks"];     $path = $_POST["rootpath"];     $nonce=$_POST["_wpnonce"];          //Load WordPress     //require($path);          //Verify the form fields                  //Post Properties         $new_post = array(                 'post_title'    => $title,                 'post_content'  => $story,                 'post_category' => $category,  // Usable for custom taxonomies too                 'tags_input'    => $tags,                 'post_status'   => 'pending',           // Choose: publish, preview, future, draft, etc.                 'post_type' => 'post',  //'post',page' or use a custom post type if you want to                 'post_author' => $authorid //Author ID         );         //save the new post         $pid = wp_insert_post($new_post);              /* Insert Form data into Custom Fields */         add_post_meta($pid, 'author', $author, true);         add_post_meta($pid, 'author-email', $email, true);         add_post_meta($pid, 'author-website', $site, true);          header("Location: $thankyou");     ?>


How to make taxonomy both hierarchical and not

I need my taxonomy to be a checklist, so I set `hierarchical => false`. However, I also need a search functionality similar to when hierarchical is set to true. Is there a way to "combine" both? Or how to add a search functionality for my taxonomy?


Latest Post Styled Different Than other Posts

I'm just completely mixed-up with this. I need the 1st post of the loop looks differently, as a kind of magazine style, you know: bigger thumbnail and bigger title. I tried already nth-of-type in CSS, :first-child, and different php variations. But nothing works. Here is the main part of code on index.php::
The Latest
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>     <div class="post excerpt <?php echo (++$j % 2 == 0) ? 'last' : ''; ?>">     <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="nofollow" id="featured-thumbnail">

     <?php if ( has_post_thumbnail() ) { ?>     <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php echo '
'; the_post_thumbnail('slider',array('title' => '')); echo '
'; ?>     <?php } ?>

     <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?>

          <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>

      I'll be tremendously appreciate if you could help me with this.


Multiple image uploaders

Ok, using the following code, I attempted to add two upload fields to a costom post type for reviews that are submitted by clients on the front end of a website here: http://pictureperfectponds.com/testimonials-submit-your-review/               /* -------------------------------*/             /* Upload & attach client picture - before */             /* -------------------------------*/                  if( !isset($rc_swt_options['disable_picture']) ) {                 if( trim( $_POST['client_picture'] ) === '' ) {                          require_once(ABSPATH . 'wp-admin/includes/admin.php');                     $id = media_handle_upload( 'client_picture', $post_id );                     unset($_FILES);                     if ( is_wp_error($id) ) {                         $errors['upload_error'] = $id;                         $id = false;                     }                          if( $errors ) {                         $client_picture_error = apply_filters( 'rc_swt_error_upload', __('There was an error uploading your before picture.', 'rc_swt') );                         $hasError = true;                     } else {                         $client_picture_url = wp_get_attachment_url( $id );                         update_post_meta( $post_id, $field_prefix . 'client_picture', $client_picture_url );                     }                      }             }                  /* -------------------------------*/             /* Upload & attach client picture - after */             /* -------------------------------*/                  if( !isset($rc_swt_options['disable_picture_after']) ) {                 if( trim( $_POST['client_picture_after'] ) === '' ) {                          require_once(ABSPATH . 'wp-admin/includes/admin.php');                     $id = media_handle_upload( 'client_picture_after', $post_id );                     unset($_FILES);                     if ( is_wp_error($id) ) {                         $errors['upload_error'] = $id;                         $id = false;                     }                          if( $errors ) {                         $client_picture_after_error = apply_filters( 'rc_swt_error_upload', __('There was an error uploading your after picture.', 'rc_swt') );                         $hasError = true;                     } else {                         $client_picture_after_url = wp_get_attachment_url( $id );                         update_post_meta( $post_id, $field_prefix . 'client_picture_after', $client_picture_after_url );                     }                      }             }      And the form is code is here:               <?php if( !isset($rc_swt_options['disable_picture']) ) { ?>                          <?php echo apply_filters( 'rc_swt_label_upload_profile', __('Upload your before picture:', 'rc_swt') ); ?>             <input type="file" name="client_picture" id="client_picture" class="rc_swt_testimonials_form_input" />                  <?php if( isset($client_picture_error) && $client_picture_error != '') { ?>                 <?php echo $client_picture_error; ?>

             <?php } ?>             <?php } ?>                  <?php if( !isset($rc_swt_options['disable_picture_after']) ) { ?>                          <?php echo apply_filters( 'rc_swt_label_upload_after', __('Upload your after picture:', 'rc_swt') ); ?>             <input type="file" name="client_picture_after" id="client_picture_after" class="rc_swt_testimonials_form_input" />                  <?php if( isset($client_picture_after_error) && $client_picture_after_error != '') { ?>                 <?php echo $client_picture_after_error; ?>

             <?php } ?>             <?php } ?>      Can anyone see what I am missing to get this to work? Or, is it not possible to have two image upload fields on the front end? I tried debug mode an didn't see any errors regarding this. The second image won't upload. I can also populate the field in the dashboard via the metabox, but that defeats the purpose. Help is greatly appreciated! Matt


Simple seo-friendly custom $_GET url rewrite with htaccess

I have this url:               http://sitename.com/?game=runescape      Is it possible to modify the htaccess file or rewrite the url via Wordpress to become like this:               http://sitename.com/game/runescape


Custom Post Type as Home Page Problem

I wrote plugin which uses Custom Post Types to create a series of pages. I have the code which adds the CPT to the "Reading" dropdown menu and it works great. Here it is...               add_filter( 'get_pages',  'add_wpwebinar_front' );     function add_wpwebinar_front( $pages ) {          $my_wpwebinar_pages = new WP_Query( array( 'post_type' => 'wpwebinar' ) );          if ( $my_wpwebinar_pages->post_count > 0 ) {              $pages = array_merge( $pages, $my_wpwebinar_pages->posts );          }          return $pages;     }      The code works but if you select a Custom Post Type as the home page it redirects to the CPT actual page. Example... domain.com would redirect to domain.com/slug/pagename In order to fix this, I found this code which I added...               function enable_front_page_stacks( $query ){     global $post, $wp_query;        if('' == $query->query_vars['post_type'] && 0 != $query->query_vars['page_id'])             $query->set('post_type', 'wpwebinar');     }     add_action( 'pre_get_posts', 'enable_front_page_stacks' );      This keeps the Custom Post Type as the main page. But... I have a few issues.   1. If you select the default of show latest posts IT'S OK.   2. If you select a Custom Post Type page as the front page IT'S OK. The problem is when you select a normal PAGE as the frontpage. It inherits the Custom Post Type template and does not show the page content of course, because there's not code there for it. I'm sure the fix is simple, but I have no idea what to change. Ideas anyone? It would be greatly appreciated.


Adding a single text input field to a custom Dashboard widget

I have a client whom I want to give as much Dashboard control over the admin area as possible. I know how to create a custom dashboard widget that contains just text/html but I have no idea how to create one that contains just a single text input field. Adding the form html would be straightforward I can see that but I don't know:   1. Where to submit the form data too   2. How to redirect back to the Dashboard after the form is submitted   3. How to retrieve the value in my non-admin theme templates


filter get_children to return all mime types EXCEPT 'x'

Like it says on the tin - Im trying to create a list of post attachments that includes everything except say audio, which I'll feed into a player instead.   * The filter needs to be generic: 'audio' not 'audio/mpeg'. (For some reason `if ( $mime !== 'audio/mpeg' )` will filter out valid mp3 files –– weird.) So the following dosen't work:               $children = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment' ) );                      if ( !empty( $children )){                     foreach ( $children as $attachment_id => $attachment ) {                         $mime = get_post_mime_type($attachment);                         $url = wp_get_attachment_url( $attachment->ID, false );                               if ( $mime !== 'audio/mpeg' ) {                                                                                $content_attach .= ' ' . $title . ' | ' . $mime . '';                             }                     }                         }       echo apply_filters('the_content', $content_attach );       Further listing every audio mime type like so: `if($mime !== 'audio/mpeg' || $mime !== 'audio/ogg')` etc will still leave out those crazy mp3 files. What does work is: `$children = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'audio' ) );` which will return all the attached audio types in one go - great my player can handel it. Now I need to _omit_ everything that _isn't_ audio and list it. Does anyone have any ideas? and thanks again for your help and experience. . .


Wordpress Redirecting Form Action to Home Page

Why does wordpress redirect to the home page after submitting a form? How can I make wordpress call the right page in the form action?


Update plugin settings option_name for big plugin update

I am working on a plugin update and have changed the settings option_name and key. I would like that the old options are transferred to the new option_name. The old option name is: plugin_options The new being: plugin_settings_general The keys have changed too, from "ga_accountId" to "ga_account_id". I looked at $wpdb and update_option but could not working any thing out that worked. This should work if I did not need to change the keys too.               // Get entire array     $plugin_options = get_option( 'plugin_options' );     // Update entire array     update_option( 'plugin_name_settings_general', $plugin_options );     // Delete old array     delete_option( 'plugin_options' );


do_shortcode inside AJAX callback

I have an AJAX callback function inside my `functions.php` file, which displays posts in a specific category.               add_action( 'wp_ajax_ajaxified_function', 'ajaxified_function' );     add_action( 'wp_ajax_nopriv_ajaxified_function', 'ajaxified_function' );     function ajaxified_function()      {          $post = get_post($_POST['post_id']);         $feat_image = get_the_post_thumbnail($post->ID);         $desc_values = get_post_custom_values("designation",$post->ID);         $title = current(explode(' ', get_the_title($post->ID)));         if( is_array( $desc_values ) )         {          foreach($desc_values as $key => $value );         }            $email_values = get_post_custom_values("email",$post->ID);         if( is_array( $email_values ) )         {             foreach($email_values as $key => $email_value );         }         echo '
'.$feat_image.'
'.$post->post_.'
'.$post->post_title.'

'.$value.'

Email '.$title.'

'.$post->post_content.'
';          echo '';            echo '

';                     echo do_shortcode('[contact-form-7 id="698" title="Meet The Team Email"]');                     echo '

';           die();       }      When I use this its just **echoing** the shortcode instead of showing the contact form. I am working on local now. I have a demo which just uses just the ajax, not the colorbox. You can see a Email link in the **biography** div. On clicking on that link I want to show a colorbox with the contact form.


How to load a plugin when doing an Ajax call?

I have posted this question: How to use shortcodes on a widget sidebar when doing an ajax call?, with no answers. Now I want to ask a more specific question. The problem seems to be that the shortcode is not processed by the plugin., as if I replace the shortcode with e.g. `[audio src="audioFile.ogg"]` it works perfect. So I'm guessing that I could make it work if the plugin is loaded before. But I don't know how to achieve it (maybe I'm wrong with it). Any suggestion? This is the code in `functions.php`:               add_action( 'init', function() {        ps_register_shortcode_ajax( 'ps_get_slider', '8' );      } );          function ps_register_shortcode_ajax( $callable, $action ) {         if(isset($_POST['href'])) {             $pageId = preg_match( '/^http:\/\/.+\/\?page_id=\d+$/', $_POST['href'] ) ? substr( strrchr( $_POST['href'], '=' ), 1 ) : '8' ;                  if ( empty( $pageId ) || $pageId != $action )                 return;                  call_user_func( $callable );         }     }          function ps_get_slider() {         //require_once('../wp-load.php'); Nothing changes              apply_filters('ps_register_shortcode_ajax', 'slider_widget_init');         if ( dynamic_sidebar('Slider') ) : else : endif;         //echo do_shortcode( '[promoslider post_type="news" height="300px" width="70%" numberposts="5" start_on="first" display_title="fancy" display_excerpt="excerpt"  pause_on_hover="pause"]' );         get_template_part( 'home', 'ajax' );         die();      }       The Slider side-bar is loaded just in home and-home-ajax pages (id=8). It works right in home page, but not in home-ajax page.


User facing form to upload image on wordpress

I have a client who bought a wordpress theme that is built for posting job listings, a user can create an account and then post job listings but my client wants it converted to post Wheel listings (car wheels). I have converted it pretty well so far but I need to allow the user to upload an image for a listing. A listing is simply a post but it is posted from a user facing form instead of in the admin panel. I would like to utilize the `the_post_thumbnail()` is possible, is it possible for me to allow a user to upload through this without going into the admin panel?


Display next 3 posts based on custom taxonomy

I am wondering if anyone could help me accomplish something like this: https://medium.com/thoughts-and-words/5ccef7b3e1fc with custom post types? I have a custom post type called projects and custom taxonomy called project- category. I would like to show the next 3 projects in the same project- category on the single project page. One will show title and excerpt and the other two will just show titles.


Import data from arbitrary CSV to WPAlchemy meta fields

I've created a **custom post type** with several **custom fields** with the help of WPAlchemy, and now I need to **import** a bunch of stuff from some **CSV files**. I'm using `WPALCHEMY_MODE_EXTRACT`. By toying with csv import plugins, I know I can import the fields correctly in the postmeta table, but the problem is that I can't see them in both back and front end. I managed to isolate the difference between manually inserted posts and imported posts, and it's an extra meta field (`_myprefix_meta_fields`) that contains serialized stuff I don't know how to generate. Any suggestion on how to solve the problem and correctly import the data? **UPDATE** : Looking up WPAlchemy code (here) it seems that the only way to fix this is by running a script that for each post of custom type adds the extra meta field, that is just the serialization of the array containing all the metabox fields. Serializing and adding the meta field is done by using add_post_meta. I'll add myself a basic script as an answer when I'm done importing data.


Shortcode adding p and br tags

I apologize as I realize this has been asked before and I believe the issue is with `wpautop` function adding closing p or br tags but every solution I've found has not worked so I'm at a loss for fixing the issue. I'm doing:               class my_plugin {            public static function init() {         remove_filter('the_content', 'wpautop');         add_shortcode('myshortcode', array(__CLASS__, 'my_shortcode'));       }            public static function my_shortcode() {         /* do stuff here */         ob_start();         include('views/file.php');          return ob_get_clean();       }     }          my_plugin::init();      I've also tried:               remove_filter( 'the_content', 'wpautop' );     add_filter( 'the_content', 'wpautop' , 99 );     add_filter( 'the_content', 'shortcode_unautop', 100 );      This is what's in the view file right now:               <form method="get" id="search" action="<?= get_permalink() ?>">         <input name="st" id="st" class="text" type="text">         <input id="search" class="submit" value="Search" type="submit">     </form>      And here is what's being rendered:               <form method="get" id="search" action="">         <input name="st" id="st" class="text" type="text">
         <input id="search" class="submit" value="Search" type="submit">
     </form>      If I take the original version and remove all line breaks it renders correctly. The issue is it's a significantly simplified version of original file and it would make editing "views" a nightmare if they had to be on a single line. For what it's worth if instead of returning the view content I echo it out everything works as expected (except of course being able to place the shortcode in other content correctly). Also the do stuff here part is just getting two variables from the request and one API call to set up the variables used in the view.


action init hook and get_post_types

Why if I register a custom post type by `add_action( 'init', 'custom_post_type' )` hook it doesn't show in returned array by `get_post_types` function? Example:               function test(){         $args = array(                 'public'          => true,                 'publicly_queryable' => true,                 'show_ui'         => true,                 'query_var'       => true,                 'exclude_from_search' => true,                 'hierarchical'    => false,                 'has_archive'     => false,                  );                   register_post_type( 'test', $args );     }     add_action( 'init', 'test' );     print_r(get_post_types());      Array     (         [post] => post         [page] => page         [attachment] => attachment         [revision] => revision         [nav_menu_item] => nav_menu_item         //no test post type in array     )      but if I just run function `test()` the post type `test` appears in `get_post_type` array.


How to limit users to one comment per post

I am using WordPress as a petition site and hacking the comments system to work as the petition signup. I would like to find out how I can limit a user to post only one comment per post. So far I can limit each user to one comment on the whole WordPress site as shown in the code below, but that's not what I am looking to accomplish. Again, how can I limit each user to one comment per post?                  <?php        /*         * Single Petition Template         * @package WordPress         * @subpackage Twenty_Thirteen         * @since Twenty Thirteen 1.0         * template author: Facinet Toure         * website URL: http://mongage.com        */           get_header(); ?>

         <?php /* The loop */ ?>         <?php while ( have_posts() ) : the_post(); ?>         <?php //get_template_part( 'content', get_post_format() ); ?>                  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                              <?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
                     <?php the_post_thumbnail('full'); ?>
                 <?php endif; ?>
                     <?php the_title(); ?>

<?php echo get_avatar( $post->post_author, 74 ) ?>                     <?php the_author_meta( 'display_name' ); ?>                      | This post currently has                     <?php comments_number( 'no responses', 'one response', '% responses' ); ?>                     .

                 <?php the_content( __( 'Continue reading →', 'twentythirteen' ) ); ?>                 <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'twentythirteen' ) . '', 'after' => '
', 'link_before' => '', 'link_after' => '' ) ); ?>
                                                <?php twentythirteen_entry_meta(); ?>                 <?php if ( comments_open() && ! is_single() ) : ?>                                  <?php comments_popup_link( '' . __( 'Sign the petition', 'twentythirteen' ) . '', __( 'One comment so far', 'twentythirteen' ), __( 'View all % comments', 'twentythirteen' ) ); ?>                                  <?php endif; // comments_open() ?>                 <?php edit_post_link( __( 'Edit', 'twentythirteen' ), '', '' ); ?>                 <?php if ( is_single() && get_the_author_meta( 'description' ) && is_multi_author() ) : ?>                 <?php get_template_part( 'author-bio' ); ?>                 <?php endif; ?>

 This post currently has             <?php comments_number( 'no responses', 'one response', '% responses' ); ?>             .
         <?php twentythirteen_post_nav(); ?>
             <?php         //Gather comments for a specific page/post          $comments = get_comments(array(             'post_id' => $post->ID,             'status' => 'approve' //Change this to the type of comments to be displayed         ));              //Display the list of comments         wp_list_comments(array(             'per_page' => -1, //Allow comment pagination             'reverse_top_level' => false, //Show the latest comments at the top of the list,             'max_depth' => '1',             'avatar_size' => 0,         ), $comments);     ?>
         <?php // check if user has previously commented the post             global $current_user;             if ( !is_user_logged_in() ) {             echo 'you must be logged in to sign the petition';             } else {             $args = array('user_id' => $current_user->ID);             $usercomment = get_comments($args);             if(count($usercomment) >= 1) {                  echo '
Vous avez déjà signé cette pétition. S\'il vous plaît partager avec votre famille et vos amis
';                  } else { comment_form();              }          }?>         <?php endwhile; ?>

                 <?php get_sidebar(); ?>     <?php get_footer(); ?>


strange behavior with comment position

I've created a custom `content.php` and removed any comments on the `content.php` page then i changed the `sharing-service.php` from jetpack and added `comments_popup_link` there:               // Wrapper     $sharing_content .= '
';     $sharing_content .= '
';          if ( $global['sharing_label'] != '' )         $sharing_content .= '
'. comments_popup_link(  __( 'Leave a reply', 'changed2012' ) , __( '1 Reply', 'changed2012' ), __( '% Replies', 'changed2012' ) ) . $global['sharing_label'] . '
';     $sharing_content .= '

';      and it looks like this:   ![comment position](http://i.stack.imgur.com/ddvxY.gif) ![enter image description here](http://i.stack.imgur.com/A5Dmj.gif) does anyone have an idea why its getting moved there? and how i can move it back where it should be?


"Issues" loading MANY featured images on a single page (custom template)

I have a page that loads a lot of featured items in a grid. There are up to 56 images loading, and it does have a bit of a delay. This is the code as it runs now:               if( count( $postslist ) > 0 ) {       foreach ($postslist as $post) : setup_postdata($post);       ?>
         <?php          $image = get_the_post_thumbnail($this_post->ID, 'full size');          $imageSrc = substr($image, strpos($image, "src") + 5);         $imageSrc = substr($imageSrc, 0, strPos($imageSrc, "\""));         $finalImage = "";         $lastImage = "";         $lastImage .= $finalImage;         $lastImage .= "";         echo $lastImage;         ?>
       <?php        $currentCount = $currentCount + 1;       endforeach;     }      I understand there are issues with the code, basically hitting the database once for every image in a loop, which is causing the slowness. Can anyone help me out with a solution to speed up the loading? My thought is grabbing everything from the database all at once and displaying it from there, but I have yet to figure out how to handle that. Thanks! Edit: Sorry, I should have explained this a bit more: The get_the_post_thumbnail is asking for the fullsize image because the fullsize image is what it needs (189x189). The featured image in the post is that image, and will always be 189x189. catch_that_image() just grabs the first (and only) image in the post body to be displayed when the user clicks on the featured image (thumbnail) using a js library (magnific-popup.js). Edit 2: It looks like my issue is database related. The calls are too slow to do one at a time (since there are so many). Is there a way to get everything back in one call then process it from there?


On a freshly built site running version 3.1.3 with the twentyten theme active and no plugins, when I click on "Media" to go the media manager, I'm getting this error: > Warning: explode() expects parameter 2 to be string, array given in > C:\xampplite\htdocs\testsite\wp-includes\query.php on line 2390 > > Warning: in_array() expects parameter 2 to be array, null given in > C:\xampplite\htdocs\testsite\wp-includes\query.php on line 2399 > > Warning: in_array() expects parameter 2 to be array, null given in > C:\xampplite\htdocs\testsite\wp-includes\query.php on line 2399 > > Warning: in_array() expects parameter 2 to be array, null given in > C:\xampplite\htdocs\testsite\wp-includes\query.php on line 2399 > > Warning: in_array() expects parameter 2 to be array, null given in > C:\xampplite\htdocs\testsite\wp-includes\query.php on line 2399 > > Warning: in_array() expects parameter 2 to be array, null given in > C:\xampplite\htdocs\testsite\wp-includes\query.php on line 2399 > > Warning: in_array() expects parameter 2 to be array, null given in > C:\xampplite\htdocs\testsite\wp-includes\query.php on line 2399 > > Warning: in_array() expects parameter 2 to be array, null given in > C:\xampplite\htdocs\testsite\wp-includes\query.php on line 2399 > > Warning: in_array() expects parameter 2 to be array, null given in > C:\xampplite\htdocs\testsite\wp-includes\query.php on line 2399 > > Warning: Cannot modify header information - headers already sent by (output > started at C:\xampplite\htdocs\testsite\wp-includes\query.php:2390) in > C:\xampplite\htdocs\testsite\wp-includes\functions.php on line 851 > > Warning: Cannot modify header information - headers already sent by (output > started at C:\xampplite\htdocs\testsite\wp-includes\query.php:2390) in > C:\xampplite\htdocs\testsite\wp-includes\functions.php on line 852


Determining Whether Automatic Upgrade will Fail?

I've been traumatized by the automatic upgrade in the past, and am fearful to ever try it again. It seems that there's no transaction logic, and when it fails, it leaves everything broken. Is there some way I can tell whether the upgrade will succeed or not based upon WordPress' ability to overwrite certain files, and whether it can make necessary changes to the database? I'd love to be able to simply ask WordPress to test the various types of access it needs to upgrade, and then tell me whether or not those tests passed before trying to do the actual upgrade. Any solution that is capable of doing this?


Writing Custom Rewrite Rules that Incorporate Category for Custom Post Types?

I'm registering a Custom Post Type and in the rewrite array I am trying to do something like this: > `'rewrite' => array('slug' => "explore/resources/".$CATEGORY, 'with_front' > => false)` I want the rule to 'dynamically' get the post's category name somehow. I also tried using `%category%` there but it doesn't work either. I need the post's url to represent the entire path/route to it. Any ideas on how to achieve this? **UPDATE:** Here is more clarification: I have a custom post type of '`resources`' and these post have several different categories like '`forms`', '`mp3`' etc. now this Resources area in the site is under another section (that is a page with custom loop for those custom posts) which is called Explore. What I want to achieve is: > domain.com/Explore/Resources/Resource-Category/Resource-Name or > domian.com/explore/resources/forms/production-form-1 My current rewrite rule in `register_post_type()` is: > `'rewrite' => array('slug' => "explore/resources", 'with_front' => false)`. Thanks!


Unable to align my sidebar to the contents section instead of comments

Relevant link: http://themeforward.com/demo2/2011/01/17/testing-comments/ I've been toying with this for about 10 minutes, trying to get the sidebar to align properly and I can't figure it out. I placed my comments in a new DIV to separate them from the posts. Usually I wouldn't do this but I want designers to have full CSS control without adding new classes when they start using this theme to build. **Anyway, my sidebar ends up being aligned with my comments rather than the content on my page.** Moving the div under the endif is not an option here because I want to be able to style just the post by itself if desired. Putting the comments below the sidebar makes the comments disappear! My code looks like this:               <?php get_header(); ?>

          <?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>

     <?php the_time('F j, Y'); ?> by <?php the_author_posts_link( ); ?>, under <?php the_category(', ') ?>
               <?php the_content(); ?>               <?php edit_post_link('Edit', '
', '
'); ?>
<?php the_tags('Tags ',' / ','
'); ?>

<?php $turl = getTinyUrl(get_permalink($post->ID));     echo 'Short URL '.$turl.'' ?>

<?php previous_post_link('%link', '-', TRUE); ?>

<?php next_post_link('%link', '+', TRUE); ?>

     <?php endwhile; else: ?>
No matching entries found.
     <?php endif; ?>
          <?php comments_template(); ?>     <?php get_sidebar(); ?>

     <?php get_footer(); ?>


Custom link color or stylesheets

I'm developing av theme for my WPMU users and are wondering is there a function for choosing the colors on the links? The same way Wordpress lets you change the background-color or header-images. Just for the link-color.. An alternative is to switch between 2 or 3 stylesheet files


how to get current user name by user_id in buddypress?

I want to display the user names by the reference of user id. Is there any function like get_user_displaynme($userid)? (and one more Is there any shortcode to get group names?) Thanks in Advance


How can I make the loop not count special post formats towards the post count?

I have WordPress set to display 5 posts per page, which is what I want. However, I'm now starting to use the new post formats (link, status, quote etc.) but I would these to not be counted towards the 5 posts per page. So how can I make the loop display the last x posts until it hits 5 standard posts?


HTTP_HOST changing in functions.php

I have getting variable results from the $_SERVER['HTTP_HOST'] variable in the functions.php file of our child theme. Let me explain our setup and then I'll explain the issue. We are running WP 3.5.2 on Nginx with PageLines 2.4 as our parent theme and a handful of plugins that I can detail if necessary. Our virtual host is set to answer to *.salesgenie.com as we have several private label subdomains that will change the branding of the site. www.salesgenie.com will be the generic domain but att.salesgenie.com is an example of a branded subdomain. So I need to be able to detect the subdomain the client calls with which I am trying to get with $_SERVER['HTTP_HOST']. The issue is that $_SERVER['HTTP_HOST'] is accurate the first time a client comes to their domain but reverts to the $_SERVER['SERVER_NAME'] value after that either on page reload or navigation to any other page. Any ideas why this might happen or how to work around it? To test this I've got a function logging the $_SERVER['SERVER_NAME'] and $_SERVER['HTTP_HOST'] to a cookie called CmsCookie and you can test it by going to cms.salesgenie.com (the CNAME is working) and both variables will read cms.salesgenie.com. But if you modify your host file to point att.salesgenie.com at 54.208.87.200 then you can test att.salesgenie.com and the cookie will be correct the first time you hit a page, but if you reload, both server name and host will be cms.salesgenie.com


display shortcodes outside of the_content

Is there a way to display shortcode content outside of the_content? I am building a custom theme who's theme options includes two text boxes that can be displayed on the front page. I want to be able to display shortcode content placed in these text box options. The theme uses files from the Options Framework.


plugin for emails to prevent spam but also let mailto working?

I'd like to have the emails displayed on my pages/posts in such a way that they to not be able to be read/used by bots/spammers. So for instance I can use some plugin which replace "@" with "[at]" and so on, but in that case I am no longer able to automatically use mailto, like:               somemail@somedomain.com      Can you please suggest a plugin which can work for this case? (keep the email address as it's normally displayed but prevent bots to read it?) Thanks.


Entire VPS locks up when using particular theme

I have a VPS with, so far 2 osCommerce websites, and it was running fine. I then installed Wordpress 3.4.1 and it was fine as well. I tried a free theme from the theme installer called Hero, and every 30 or so page loads the entire VPS locks up. Not just the apache or PHP or MySQL, but I can't even access the server via SSH. This is on a test server with 2gb of ram and almost no other visits than my own. Theme: http://wordpress.org/extend/themes/hero


Display Custom Field for a Specific Role, but not for Admin

How do I display a custom field for a specific role, but not display it on the profile page of the admin? When admin goes to edit a profile user that this role, the field will visible. I created two fields for Subscriber role, but the fields appears on admin profile page. I need to display these fields only if admin goes to the profile page of subscribers.               function show_custom_field_for_subscriber(){              if( current_user_can('administrator') || current_user_can('subscriber') ) {              //code html for display the fields          }          add_action( 'show_user_profile', 'show_custom_field_for_subscriber' );


Theme post editor does not have Visual & Html tabs and all buttons?

My theme (which I made myself several years ago based on WP TwentyTen) is only showing a basic post editor (& I cannot remember whether this was so originally or not!).![see screenshot of post editor in my current WP Theme](http://i.stack.imgur.com/oT2mH.jpg) How do I get the post editor to revert/change to full Visual & Html mode with tabs and all buttons as per default WP TwentyEleven theme?-see screenshot below ![TwentyEleven post editor with tabs & all buttons](http://i.stack.imgur.com/xsrYb.jpg) I am most grateful for helpful replies-many thanks EDIT 141212 -my own latest findings in trying to solve my original question.... By unchecking the box on admin page >users>admin I get a WordPress posteditor with Visual and Text tabs-see screen shots below: ![enter image description here](http://i.stack.imgur.com/7gBUY.jpg) Which gives this post editor: ![enter image description here](http://i.stack.imgur.com/c4TTk.jpg) What happened to the HTML tab? Also the kitchen sink button doesn't work when I click on it?! The WordPress editor seems a bit mysterious and less well documented and simple to use than I would like! (probably in line with the rest of WordPress now I think about it!). I hope this post may help anyone else who has questions over the WP post editor.


Add quicktag buttons to the HTML editor

I am trying to figure out how to modify the HTML editor in wordpress; on the image below you can see a screenshot of the editor and the buttons on the top. Is it possible to add new buttons? I would like to add a button that will insert "" tags and some custom short-code tags as well. I know it's not impossible, but does anyone know how to do it? ![enter image description here](http://i.stack.imgur.com/t1MCt.png)


The_content display a different content from a previous loop

I have custom template for my homepage. If i just put the_content(); to this template, nothing else, then it will display my text i entered in my admin panel in the editor. But if i have a different loop in my template, its display the content from an other post.                   <?php          query_posts( array(                 'post_type' => array(                 'movies'                 )         ));         if (have_posts()) : while (have_posts()) : the_post(); ?>                 asd         <?php endwhile; endif; ?>              <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>                 <?php the_content(); ?>         <?php endwhile; ?>      So the the_content(); part in the end is displaying the content from the previous loop. What should i do to fix this?


Including text at the end of every post

I would like to include some text at the end of every post. Like how some people write "Like my posts? Follow me on twitter!" or something like that. There are some buttons for users to tweet or share the posts, but I want to see how people would respond to explicit suggestions. I thought maybe I can just copy-paste it over and over again, but if I ever decide to change it, I'd have to update every one of them, so that isn't a very scalable solution. I also have existing posts that I wish to have this text appear. I'm thinking of changing the theme so that each post has the text, but that doesn't seem like a very "wordpress" way to do it. What is a good way to accomplish this? Being able to choose which posts have the text or not (eg: based on category, tags, etc.) would be nice.


Generate Email if No Posts Within Time Period

I want an email to be sent to a specific list of email addresses if/when there have been no posts on the blog within the past 1 week. Any ideas on how I could do this?


Why is Wordpress asking me to update my new (virtually blank) theme?

I have just setup a new custom theme with little/no data and yet Wordpress has made an update notice about upgrading it to "1.0.1" and I cannot for the life of my work out why. I have stripped down the theme to the following files: I have a blank index.php and style.css:               /*     Theme Name: Fresh     Description: A customisable theme built just for your website     Version: 1.0     Tags: white, two-columns, fixed-width, custom-header, custom-background     */      An obvious fix is just to increase the version number, but it is concerning that for some reason it is checking an external source for version updates when it is not supposed to. I have a large amount of themes in my themes directory, some of them start with the word "fresh" but none are actually called just "fresh". **Edit** It appears to be loading the data for another theme called "Fresh" on some wp-themes.com, I have renamed my theme and it's still checking. Maybe some sort of transient cache isn't clearing?


Validate Custom Login field

I have added an extra login field to the main wordpress login page. It is a checkbox which must be checked (to accept terms & conditions), otherwise the user cannot log in. I have taken code from this question which has allowed me to add a custom checkbox to the login. However, trying to modify the code given to validate whether the checkbox has been checked, I cannot get to work.               function check_checkbox($user) {         $acceptance = $_POST['terms_acceptance'];              $user = get_user_by('login', $username );              if( !$user || !isset($acceptance) ){             remove_action('authenticate', 'wp_authenticate_username_password', 20);                  $user = new WP_Error( 'denied', __("ERROR: You're unique identifier was invalid.") );         }              return null;     }     add_filter( 'wp_authenticate_user', 'check_checkbox', 10, 3 );      I have tried the 'authenticate' & 'wp_authenticate_user' filters as shown, but neither have worked for me. Can anyone tell me what I'm doing wrong?


Create an audio playlist that bookends an audio file from posts with an intro and outro file uploaded to a specific page?

I am trying to create a Podcast audio player that will play on every page, and each page will have its own unique intro/outro audio files that bookend the main podcast file. I am pretty new to wordpress development and php and am not sure where to start. So far, I am using Advanced Custom Fields file input for uploading the audio file to 'Pages', and then another input for uploading the podcast episode in 'Posts'. I want them to play in this order:   1. Page's unique Intro - (uploaded through 'pages')   2. Podcast file (uploaded through 'posts')   3. Page's unique Outro (uploaded through the same page as the intro file) I had been following a Alicia's Advanced Custom Fields Image Object Tutorial tutorial and thought it could work for what I was trying to do. So this was my attempt, but it does not seem to be working:               <?php                 $podcast = the_field('podcast_audio');                 $podcastURL = $podcast['url'];                      $attr = array(                     'src'      => $podcastURL,                     'loop'     => '',                     'autoplay' => '',                     'preload' => 'none'                     );                 echo wp_audio_shortcode( $attr );             ?>      Also, I'm not sure how you could take multiple variables, like $introURL, $podcastURL, $outroURL and make them play sequentially). If anyone has any suggestions or ways of doing this, some guidance would be much appreciated! Thanks!


Fatal error: Call to a member function get_results() on a non-object in on line 26

Ok so I am trying to chain select boxes from a my database. First select box grabs the values just fine. If I hard code all of the select boxes they all return values and as expected do not interact with each other. The problem I am having is the external call to my holder php file for the second drop down. jquery posts to the file and it returns the error I put in the title of this post. I am used to this error showing when $wpdb is not set to global which but it does not seem to be the case as I have declared the global $wpd; in several places trying to debug the code. Here is my front end code               include_once 'select.php';     global $wpdb;     ?>

                      <form id="select_form">         Choose a category:
         <select id="year">             <?php echo $opt->getYear(); ?>         </select>         <select id="make">              </select>         <select id="model">              </select>         <select id="trim">              </select>

         <input type="submit" value="confirm" />      here is select.php with line 26 indicated               class selectList {          public function getModel(){         global $wpdb;         $sql = $wpdb->get_results(             "                  SELECT DISTINCT model                  FROM wp_car_details                   ORDER BY model DESC                  "             );              foreach ($sql as $res) {         echo '<option value="'.$res->model.'">'.$res->model.'</option>';         }     }          public function getMake(){         global $wpdb;         $sql2 = $wpdb->get_results( <---- line 26 ----->             "                  SELECT *                  FROM wp_car_details                  WHERE make             "             );              foreach ($sql2 as $res2) {             echo '<option value="'.$res2->make.'">'.$res2->make.'</option>';         }          }          public function getTrim(){         global $wpdb;         $sql3 = $wpdb->get_results(             "                  SELECT *                  FROM wp_car_details                  WHERE trim                  "             );              foreach ($sql3 as $res3) {             echo '<option value="'.$res3->trim.'">'.$res3->trim.'</option>';         }          }          public function getYear(){         global $wpdb;         $sql4 = $wpdb->get_results(             "                  SELECT DISTINCT year                  FROM wp_car_details                  ORDER BY year DESC                  "             );              $year = '<option value="0">choose...</option>';         foreach ($sql4 as $res4) {         $year = '<option value="'.$res4->year.'">'.$res4->year.'</option>';         echo $year;         }          }      } $opt = new selectList(); Here is select_type.php               global $wpdb;     include_once 'select.php';     echo $opt->getMake();      I fully understand that my approach is probably the wrong way to go about this whole ordeal but this is my first time putting this together so be kind please. :P my question is why is the $_POST to select_type.php returning the fatal error and what can I do to correct it? Also please advise if I have not included enough information I included what I thought was relevant for the initial question.


get_query_var() and permalinks

I have a permalink structure that looks like this, %category%/%postname% I have a category.php template coded up and and trying to pull of the post of a certain category, so for example my URL may look like this, /category/category1 I want all posts that are in category1 to be return however, when using the following code I get null returned, `get_query_var('cat')` I assume that this code is looking for URL that looks like this, ?cat=category1 So how do I make it work with permalinks?


Index.php duplicating home URL and itself showing in GTmetrix

Using Gtmetrix to measure my site performance I notice index.php is duplicating my home URL also it is duplicating or called twice in the waterfall. I have no clue why or how this is happening any advice would be appreciated. http://www.tagmebands.co.uk/


Unique Transients user id for Non-Logged In users

I am coding a plugin and it seems wordpress discourage use of Sessions. I have a kind of wizard for non-logged in users that asks for First Name, Last Name etc and some conditional questions from users in 4 different steps and then eventually registers user and shows his username/pass in last step. I am stuck on this last step since I am not able to hold data in sessions. Should I even use Transients API to hold this kind of data? How can I make Transients data a non-logged in user specific? Don't want to use cookies or you think I must use cookies in this scenario?


Advanced Custom Fields: Using category as a rule, before publishing new post?

I am using Advanced Custom Fields plugin to assign some fields to posts with a certain category, but the fields does not appear before I publish the post. I have made some links on the dashboard, so my client can just click on for example "new product", and then go to add new post with the category "products" already selected. But because my client has to publish this new post before it "belongs" to the category "products", the fields I have assigned to "products" via Advanced Custom Fields, are not there. Has anyone got an idea how I can solve this?


Clarification - Change tag base - 301 redirect old indexed links?

I keep reading conflicting guidance on this including the occasional difference of opinion on here. I'm happy with my permalink structure - would love to lose '/category/' but read of many issues with sub-categories for people that tried this - including using plugins. I'm focused on tags. Within Wordpress Admin I can change the tag base 'tag' by default to something else. I'd like to change it to suit how I use it. Possibly 'apps'. My tag pages are indexed at Google - i.e. http://mysite.com/tag/procamera/. I think the change will be fine internally but do I need to write a 301 to redirect old URL to new URL for external links (in this case http://mysite.com/apps/procamera/)? If so can anyone advise of the appropriate htaccess 301 code to redirect from old structure to new? Edit - this link appears to be the correct answer - How to: 301 Redirect /category/ to /customname/ just replacing category with tag - so is it definitely the case that a 301 redirect will be required? I've seen so many posts suggesting Wordpress handles everything.


Use the_post_thumbnail as background image in LESS CSS

I'm trying to use `the_post_thumbnail` featured image as the background image to a div container within a page template file. I'm using LESS CSS and wondered if it was possible to pass in a Wordpress tag to the LESS file or use PHP in anyway? If not, I guess my only option would be inline style?


w3 total cache - Object Caching 2165/2469 objects?

Site is: http://kremim.com WordPress 3.2.1 MS, buddypress,bbpress installed. wp_options have 333 records. But Object Caching 2165/2469 objects? Why 2000+ ? Debug: http://www.unsalkorkmaz.com/problems/kremim_debug.txt lots of notoptions:options , alloptions:options ? whats those?


Can't create new Pods pages

this is strange. Suddenly I can't create any more Pods pages! In the edit page screen instead of publish the main button shows submit for review and when I push it WP says: You are not allowed to edit this post. Well, I'm the admin so I shouldn't have any problems, and indeed I created other pages before. The roles and capabilities seems ok to me... What's going on? EDIT: Looks like is a problem in a last upgrade in my functions.php code. But I can't get what!


Prevent Width and Height Attributes in Image Tag Output

I'm trying to control the output of the random image within this bit of code. The end goal is to NOT output the `width` and `height` attributes for the image. I want this:                     BUT I DON'T WANT THIS (which is what the code below currently outputs):                     **My code:**               $thumb_id = get_post_thumbnail_id(get_the_ID());          $args = array(         'order' => 'ASC',         'orderby' => 'rand',         'post_type' => 'attachment',         'post_parent' => $post->ID,         'post_mime_type' => 'image',         'post_status' => null,         'numberposts' => 1,         'exclude' => $thumb_id     );          $attachments = get_posts($args);     if ($attachments) {         foreach ($attachments as $attachment) {             echo wp_get_attachment_image($attachment->ID, 'full', false);         }     }


How can you group custom post types in the admin sidebar?

Is there an easy way to group custom post types on the admin sidebar menu? The reason i ask is because i want to try to accomplish the following: I've created a custom post type titled "Latest News" it's nothing more than a block area that will have a link that links out to another website so there are only two custom fields in this post type "URL" and "Headline Text". However I will use this custom post type on 27 other different pages and this would not even be an issue if i could just use the same content on all of those 27 pages. Instead there needs to be custom news for each of those 27 pages. Here's my noob approach: I will create 27 different custom post types that have a unique description but ALL have the exact same custom fields which i'll have to create repeatedly as well for each of the 27 pages just so that i can link them to their specific custom post type and include that unique description within the specific page that the news will be relevant to. I know it's a super bloated way to do things and WordPress probably has a better way to do this that requires knowing "if else" statements within custom functions. While i'm not afraid to try that i don't know very well how to do that but am willing to work it. So as you can tell creating 27 custom post types just for this "Latest News" block area will make my Admin menu so long, hence the title of this question on how to group CPT's in the admin sidebar menu, but that's not really what i'm after. Not to mention that if i can't find a better way to do this i'll end up doing the same thing for 10 other custom post types i need to make that will also go on 27 pages that are all using the same template but require unique content. That alone would make a sidebar admin menu with 297 custom post types and that's just insane. Someone slap me and tell me what i'm doing wrong. Thanks.                <?php              $args = array(                 'post_type' => 'latest_news',                 'tax_query' => array(                        'taxonomy' => 'news',                        'field' => 'slug'                        )         );              $the_query = new WP_Query( $args );              ?>              <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                     <?php the_field( 'url_latest_news' ); ?>                   <?php endwhile; else: ?>                   <?php endif; ?>


Author.php not displaying post type posts

I note that the twentyeleven theme author.php template only display the posts from normal posts, the custom post type posts are not display in this template. How do I query all the posts from the author regardless the post type? I tried               global $wp_query;            $theauthorid  =   get_current_user_id( );     query_posts( 'author=' . $theauthorid );       but it also doesn't display post type post. Any clue?


How to add menù section to my WordPress template?

I am pretty new in WordPress blog and I am developing a blog with this template: http://scorejava.com/wordpress351 As you can see at the top of the page there is a "menù" that only show the page in the site (at this moment: "Home" and "Pagina di esempio"). This menù is showed by the following lines of code into the header.php file:               <?php wp_list_pages('title_li=&depth=1'); ?>      So I think that this is not a true menù but only a list of the statics pages present on my blog. If, in the administrator dashboard I go to the menù section in the "Position of themes" square say me that: **"This theme has no support for menus but it is possible use the personalized menu widget to add every created menu in the sidebar"** So I think that my template have no definied a true menù section on the top (but only a list for the static pages). Can I add a true section where add a true menu? How can I do? Tnx Andrea


Best way to develop multisite and deploy on another server?

I have no previous experience in developing multisites so be easy on me. I´m familiar with developing and launching single sites though. I´m looking for the smoothest way to build a multisite for my client. It doesn't matter if I build locally or on a live development server. The sites will be basically the same but in different language versions, the content will also be slightly different. I´ve been reading that it´s hard to migrate multisites to new servers because the url:s are hardcoded in the database in another way than on single installs, making search and replace much harder (or impossible?). So how should I go about then? Develop locally and use the same url as the sites will have at launch, somehow? Use some kind of plugin to migrate multisite? I see Backupbuddy has this as a BETA feature, has anyone tried this? Any ideas or tips on a good workflow here?


How to make is_admin() return false when I need it to?

I am using a plugin to display a Terms and Conditions page to my visitors. The visitors would have to agree to the terms and conditions in order to see the actual content of the website. When this plugin is active and the terms and conditions page is displayed, it does not use the normal theme rendering flow. Instead, the plugin calls get_header(), get_footer(), etc to render the page directly. While doing so, is_admin() would return true, even though we really should consider the terms and conditions page to be the front-end and not the dashboard/admin panel. The theme uses is_admin() to decide whether or not to enqueue certain javascripts, so it enqueues the wrong set of javascript files and I get a whole bunch of javascript errors. How can I make is_admin() return true in the context of the plugin? P.S. The exact plugin in question is this: http://wordpress.org/extend/plugins/force-apply-terms-and-conditions/


Reverse comment pagination numbers

I would like to reverse the comment pagination numbers so that the newest comments show on page 1 instead of the last page. I did an array_reverse for the comments_array and set the Wordpress Discussion Settings to first page displayed by default - everything works fine except when someone leaves a comment it doesn't take in consideration the array_reverse and it takes the user to the link where the comment would be without the array reverse and obviously the comment is not there. I noticed that the redirect comes from wp-comments-post.php `$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;` Is there a way to get the correct redirect link after a comment is submitted? Or is there a simpler way to get the comment pagination numbers reversed? Thanks in advance!


How to use wp_enqueue_script, style when required

There are lot of unused js & stylesheets in my theme. here is wp_register function in my functions.php               wp_register_script( 'moder',    base_url . 'js/modtom.js', array(), false, false );     wp_register_script( 'videojs',  base_url . 'js/vin.js',    array(), false, false );     wp_register_script( 'selevizr', base_url . 'js/sesin.js',  array('jquery'), false, true );     wp_register_script( 'easi',     base_url . 'js/gmin.js',  array('jquery'), false, true );          wp_register_style( 'styles',     base_url . 'style.css', null, false );      i want these scripts to be run when required or when shortcode use.


Google Map Latitude and Longitude values in form

I have a front end submit form and would like to include a two extra custom fields which will hold Latitude and Longitude values. I want the users to select the location on a map which will be included in the form. Anybody know a good way of doing this, or any tutorials? Thanks!


populate post meta in gravity forms

I can populate post author email with this code:               add_filter('gform_field_value_author_email', 'populate_post_author_email');     function populate_post_author_email($value){         global $post;              $author_email = get_the_author_meta('email', $post->post_author);              return $author_email;     }      It's ok, but how i can populate meta of post? meta = imail I'm trying with               add_filter('gform_field_value_meta_imail', 'populate_post_meta_imail');     function populate_post_meta_imail($value){         global $post;              $meta_imail = get_post_meta('imail', $post->post_id);              return $meta_imail;     }


How do I add a new field/meta box to the Custom Post Type Portfolio in the Kaboodle Wootheme?

I've created CPTs using Types in the past, and I've built custom templates, but finding the method for adding a field to an existing Woothemes CPT is frustrating. I'm struggling to find the correct code to either hook or just straight modify the php? Thoughts?


WooCommerce currency converter support

I am using WooCommerce Plugin to make a website. Everything is working fine with this plugin but when I wanted to implement `currency converter`, there is no such facility is available there. I really need to `convert the currency` so how that can be be possible with `WooCommerce`? Any help and suggestions will be highly appreciable.


Add formatting to Array

This displays authors by date of their latest post. I'd like to:   1. **add formatting around each author**   2. **list additional properties** (avatar, latest post title and excerpt) <\-- I have the bits for this, but not sure where to insert them here.
     <?php     //List of users sorted descending by date of latest post written by user     $uc=array();     $blogusers = get_users_of_blog();     if ($blogusers) {       foreach ($blogusers as $bloguser) {         $userpost = get_posts('showposts=1&author='.$bloguser->user_id);         $uc[$bloguser->user_id] = '';         if ($userpost) {           $uc[$bloguser->user_id]=$userpost[0]->post_date;         }       }       arsort($uc);       foreach ($uc as $key => $value) {         $user = get_userdata($key);         $post_count = get_usernumposts($user->ID);         if ($post_count) {           $author_posts_url = get_author_posts_url($key);           echo '
' . $user->user_firstname . ' ' .         $user->user_lastname . ' (' . $post_count . ')
';         }       }     }     ?>


How can I get the jQuery Autocomplete demo to work correctly?

I'm experimenting with jQuery Autocomplete, and I'm having trouble getting it to work. The first bit of code you see below is almost an exact copy and paste from from the demo: http://jqueryui.com/autocomplete/#multiple Here is the page in question on the dev site: http://bluepresley.com/qa/ask-a- question/ (note, the only thing different below than on the demo is the ID tag of the input, and the fact that I'm using php to output the terms) The below code works fine, but notice how I had to keep links to jquery and jquery-ui. What's happening, however, is that other parts of the site that use autocomplete no longer work. To remedy this, I removed the links, and I added wp_enqueue_scripts('jquery- ui-autocomplete') to my functions.php file, and I wrapped that entire block of javascript in a noconflict wrapper (please see second code block below).               <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">       <script src="//code.jquery.com/jquery-1.10.2.js"></script>       <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>       <script>       $(function() {         var availableTags = [                  <?php             // get terms from custom tag taxonomy             $terms = get_terms('dwqa-question_tag');                  foreach($terms as $term){                 print "\"$term->name\", ";             }             ?>          //      "ActionScript",     //      "AppleScript",     //      "Asp",     //      "BASIC",     //      "C",     //      "C++",     //      "Clojure",     //      "COBOL",     //      "ColdFusion",     //      "Erlang",     //      "Fortran",     //      "Groovy",     //      "Haskell",     //      "Java",     //      "JavaScript",     //      "Lisp",     //      "Perl",     //      "PHP",     //      "Python",     //      "Ruby",     //      "Scala",     //      "Scheme"         ];         function split( val ) {           return val.split( /,\s*/ );         }         function extractLast( term ) {           return split( term ).pop();         }              $( "#tags" )           // don't navigate away from the field on tab when selecting an item           .bind( "keydown", function( event ) {             if ( event.keyCode === $.ui.keyCode.TAB &&                 $( this ).data( "ui-autocomplete" ).menu.active ) {               event.preventDefault();             }           })           .autocomplete({             minLength: 1,             source: function( request, response ) {               // delegate back to autocomplete, but extract the last term               var results = $.ui.autocomplete.filter(                 availableTags, extractLast( request.term ) );                    response(results.slice(0, 10));             },             focus: function() {               // prevent value inserted on focus               return false;             },             select: function( event, ui ) {               var terms = split( this.value );               // remove the current input               terms.pop();               // add the selected item               terms.push( ui.item.value );               // add placeholder to get the comma-and-space at the end               terms.push( "" );               this.value = terms.join( ", " );               return false;             }           });       });       </script>      Here is the updated code:               jQuery(document).ready(function($) {                     $(function() {                         var availableTags = [                 <?php                 // get terms from custom tag taxonomy                 $terms = get_terms('dwqa-question_tag');                 //print "<pre>";                 //print_r($terms);                 //print "</pre>";                 foreach ($terms as $term) {                     print "\"$term->name\", ";                 }                 ?>                                  //      "ActionScript",                             //      "AppleScript",                             //      "Asp",                             //      "BASIC",                             //      "C",                             //      "C++",                             //      "Clojure",                             //      "COBOL",                             //      "ColdFusion",                             //      "Erlang",                             //      "Fortran",                             //      "Groovy",                             //      "Haskell",                             //      "Java",                             //      "JavaScript",                             //      "Lisp",                             //      "Perl",                             //      "PHP",                             //      "Python",                             //      "Ruby",                             //      "Scala",                             //      "Scheme"                         ];                         function split(val) {                             return val.split(/,\s*/);                         }                         function extractLast(term) {                             return split(term).pop();                         }                              $("#question-tag")                                 // don't navigate away from the field on tab when selecting an item                                 .bind("keydown", function(event) {                                     if (event.keyCode === $.ui.keyCode.TAB &&                                             $(this).data("ui-autocomplete").menu.active) {                                         event.preventDefault();                                     }                                 })                                 .autocomplete({                                     minLength: 1,                                     source: function(request, response) {                                         // delegate back to autocomplete, but extract the last term                                         var results = $.ui.autocomplete.filter(                                                 availableTags, extractLast(request.term));                                              response(results.slice(0, 10));                                     },                                     focus: function() {                                         // prevent value inserted on focus                                         return false;                                     },                                     select: function(event, ui) {                                         var terms = split(this.value);                                         // remove the current input                                         terms.pop();                                         // add the selected item                                         terms.push(ui.item.value);                                         // add placeholder to get the comma-and-space at the end                                         terms.push("");                                         this.value = terms.join(", ");                                         return false;                                     }                                 });                     });                      });                 < php /*close noconflict wrapper*/ ? >             </script>      ... and here is the functions.php file addition:               function add_qa_scripts(){       wp_enqueue_script( 'jquery-ui-autocomplete' );     }     add_action('wp_enqueue_scripts', 'add_qa_scripts');      I can see the autocomplete jquery file in my footer, autocomplete doesn't work. But, after having removed those two script links, my other autocomplete areas work (the search bar here, for example http://bluepresley.com/qa) How can I get the code to work while not breaking the other parts of the site that are dependent on autocomplete as well?


Generate PDF using tcpdf from WordPress admin side custom page

I'm generating PDF using tcpdf library in WordPress admin side. but getting the following error. TCPDF ERROR: Some data has already been output to browser, can't send PDF file It has header_sent() is true means it has set its headers already and not modifying the pdf headers by tcpdf. any ideas ?


Using WP_Query IN pre_get_posts while searching

This is a continuation on this question. What I'm trying to do, is _rerun_ a search query, to loop through it and index the taxonomy counts (so I can make some kind of facet search). What I do is this (simplefied code):               public function pre_get_posts_hook( $query_obj )     {         if( $query_obj->is_page() == false ) {             if( $query_obj->query_vars['post_type'] == 'products' ) {                 if( empty($query_obj->query_vars['internal-query']) || $query_obj->query_vars['internal-query'] != true ) {                     if ( $query_obj->is_main_query() == false || $query_obj->is_search() ) {                               self::indexTaxonomyCounts($query_obj->query_vars);                           }                 }             }         }         return $query_obj;     }          public static function indexTaxonomyCounts($query_vars)     {         $query_vars['posts_per_page'] = -1;         $query_vars['internal-query'] = true; //to prevent the pre_get_posts_hook to adjust the query              $wpQuery = new WP_Query($query_vars);              //... loop through the posts, do some calculations etc              /* Restore original Post Data */         wp_reset_query();     }      The calculations work (that was my previous question), but `have_posts()` returns false! But `$wp_query->found_posts` does give the correct number of posts! If I remove the `new WP_Query` call from the `indexTaxonomyCounts` function, the calculations don't work - but the `have_posts()` in `search.php` work again. Weird thing is that this works in other pages, where I create my own WP_Query to display some custom products or something. What am I doing wrong here? Have I overwritten the global $wp_query? When I create a new WP_Query object, that shouldn't influence the global $wp_query, right? ## Update - search.php source               ...     //this works, display correct number     $hit_count = $wp_query->found_posts;          if ( 'products' == get_post_type() || (get_post_type() === false && $_GET['post_type'] == 'products' ) ) :              //nope, no results?         while (have_posts()) : the_post();                  get_template_part( 'content', 'review' );              endwhile;          endif;     ...


Update wordpress post terms programatically

I am currently working with woocommerce for wordpress and making a custom plugin. I would like to update the product categories manually through my own admin panel, here is what I have so far:               $catTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC'));      This gets all product categories when looped. I then add checkboxs to the items in the loop like this:               <input name="" type="checkbox" value="" id="cat_term_<?php echo $catTerm->name;?>" name="cat_term[]" /><?php echo $catTerm->name; ?>      I then save the terms like this which isn't working:               $prod_cats = $_POST['cat_term'];     wp_set_post_categories( $id, $prod_cats );      I have also tried the following:               wp_set_object_terms( $id, $prod_cats );      And:               wp_set_post_terms( $id, $prod_cats );      Is there something I am doing wrong? Maybe not saving them in the correct way? Full Code as requested:               <?php                  $cats = array();                             $product->get_categories();                           //print_r($cats);                            $terms = wp_get_post_terms( get_the_id(), 'product_cat' );                            foreach ($terms as $term){                      $cats[] =  $term->name;                  }                  print_r($cats);                      ?>                      <?php $catTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC')); ?>                 <?php foreach($catTerms as $catTerm) : ?>                           <?php if (in_array($catTerm->name, $cats)){ ?>                      <input name="" type="checkbox" value="" id="cat_term_<?php echo $catTerm->name;?>" name="cat_term[]" checked="checked" /><?php echo $catTerm->name; ?>
                                   <?php } else { ?>                      <input name="" type="checkbox" value="" id="cat_term_<?php echo $catTerm->name;?>" name="cat_term[]" /><?php echo $catTerm->name; ?>
                           <?php } ?>                      <?php endforeach; ?>                 <?php } ?>               if (isset($_POST['save'])) {         $id = $_POST['item_id'];              $prod_cats = $_POST['cat_term'];              wp_set_post_terms( $id, $prod_cats );               }


Add .html extension to only one page in my Wordpress site

We had an old site that had html pages in it. One of the pages in that site was linked to from many other sites. Now we moved to a WordPress site, and we created a page with that name, but of course it doesn't have the ".html" extension, so links to that page lead to an empty page... I saw a plugin that adds html extesnsions to all pages, but I don't want that - I have only one page to which I want to add .html. What can I do to accomplish this?


Change custom post type slug from URL

I have two pages showing portfolio posts, one of them shows the posts with parent category 'products', and the other one the posts with parent category 'projects'. The problem is that, the url inside products is: 'www.xxx.com/portfolio/product-name', and 'www.xxx.com/portfolio/project-name' inside projects, and what I want is: 'www.xxx.com/PRODUCTS/product-name' and 'www.xxx.com/PROJECTS/project-name'. I found the function 'rewrite' => array( 'slug' => 'portfolio' ), but it changes both of them, and I need a diferent name for each one.               register_post_type(      'port',      array(        'label' => 'Portfolio',        'public' => true,        'show_ui' => true,        'show_in_nav_menus' => true,        'rewrite' =>            array(               'slug' => 'portfolio',               'with_front' => false            ),        'hierarchical' => true,        'menu_position' => 5,        'supports' =>            array( 'title',                   'page-attributes',                   'editor',                   'excerpt',                   'thumbnail'            )       ) ); Anyone knows how to do that?? Thanks a lot!


Passing variables to templates (alternatives to globalizing variables)

I want to make my WP code simpler (there's some mess within header.php, page.php etc.). So, for example, I want to set something like this global:               $foo = get_option('foo');        So `$foo` will work properly used anywhere in page.php, header.php, footer.php, loop.php and also within different theme files linked to functions.php (require_once). I already know two ways of achieving this, both require editing functions.php: ## Global dynamic function               function foo() {        return 'bar';     }      ## Global constant               define('FOO_BAR', 'directory');          Do I really need to fire a function in multiple places just for one variable? Isn't it an overkill?


What is the difference between terms and tags?

I am working on a problem to get the most recently used tags within the last 30 days. My current thought process is not working, so I am trying to come up with an alternative method. I came across get_term and get_terms, thinking they may be a way to an actual functioning solution to my problem. However, searching for "What is the difference between terms and tags in WordPress" is too general and I cannot find an answer. What is the difference between tags and terms? It what situations would get_term or get_terms be used? Thanks.


changing the labels inside appearance -> menus for some for the fields

So I've create a custom walker for nav menu (i am talking about the menus located at: appearance -> menu -> add a new menu. I now use the following for several things i need: `URL` `Title Attribute` `CSS Classes (optional)` `Description` My question is how do i change the labels of those fields to be more explanatory toward my uses. So instead of title attribute for example it will say something like `menus width` Thanks in advanced.