How to default display name to first name and last and disable the profile field

Hi I have been looking for a way to default display name to first name and last and disable the profile field for all users except admin. I have looked at plugins and fixes on here but have found nothing that works. I am using wordpress 3.9.2. I cannot find anywhere in the settings or codex to at least default to first name and last name.


looking for a way to allow users to backup the plugin db data(save as)

I have a custom build plugin and I want to add the option to let the user save the plugin data(not using a thirdparty plugin to do this for me). So if a user clicks on the button it will allow them to save the file as(dont want to save the file to a folder). Has WP a function for this or need I use a custom made function? thanks


Sortable column containing numeric values for Custom Post Type at WordPress Backend

I have custom post type named **Cars**. By default, it is sorted by post publishing date, which is very unusual. WordPress should have provided option to sort columns containing numeric values. Alas, it's not available, and I am looking for solution for the same. Help is appreciated.


WP-API restfull JSON and post meta?

OK I'm using this plugin: https://github.com/WP-API/WP-API/ to turn my site into a rest full API and it's working great.. Then I'm using ths plugin to add custom post meta: https://wordpress.org/plugins/types/ My problem is i can't seem to query the url endpoint to return my my post meta as if i was querying this:               get_post_meta( $post_id, $key = '', $single = false )      how do i go about this? Chris


How to implement a 'fail whale' to graciously limit server load (Solutions for system capacity governing)

With our website, we want to make it so that if the site is about to go down, it instead displays a custom 503 (based on a server load limit set by us). Is there something that can handle this that is already built in, or a plugin that might help? _I know manual switching maintenance mode plugins are available but if the site hits heavy traffic they will get taken out._


Passing variables through permalink structure in custom post types

I'm having a real headache with this one, and not sure what to try. Basically, I'm building a website with a custom post type of 'charities'. There are many charities listed, we'll use RSPB as an example. SO visiting "example.com/charities/rspb" will load the custom post type, and this works fine. What I want to do is pass a variable to change the page content: > example.com/charities/rspb/contacts/ I am looking for a query var of 'contacts' to be true if this URL is passed, or similarly: > example.com/charities/rspb/donation-information/ ... to make a query var of 'donation-information' to be set to true if this URL is passed, etc etc. I've tried adapting this solution: Passing variables through permalink structure And had no luck. It works on the 'charities' page (which loads the archive- charities.php template file just fine, and can pass a variable to it) but I can't get anything to work for passing variables to the custom posts themselves. Some additional info, I'm running WP 3.7 on an Apache2 server (ubuntu). Any ideas or any pointers would be great. I've spent quite a bit of time researching this and the permalink structure, and I am still in the dark as to how to make it work for my scenario. Thanks in advance for any help. ** EDIT - Here's my code! (thanks for the heads up here!) **                   // Register the variables that will be used as parameters on the url         function add_my_var($public_query_vars) {                  array_push($public_query_vars[], 'contacts', 'donation-info', 'comments');             return $public_query_vars;         }              add_filter('query_vars', 'add_my_var');              function do_rewrite() {                  foreach (array('contacts', 'donation-info', 'comments') as $item) {                 add_rewrite_rule('(charities)/[/]?([^/]*)$', 'index.php?pagename=charities&'.$item.'=$matches[2]','top');             }              }         add_action('init', 'do_rewrite');              // ...Get the query vars on template file         get_query_var('contacts');


how to change menu titles

At the top of this website Wordpress answers is 6 menu items in the header `Questions` `Tags` `Users` `Badges` `Unanswered` `Ask Question` I need to change these on my website homesfriscotx.com how do I do it? Thanks, Debbie


custom post type capabilities - needs to be VERY secure

Hi I'm trying to define custom post type capabilities for staff contracts on an intranet site, so due to the sensitivity of the information this needs to have as best security as possible and simply hiding the menu links via jQuery or css isn't good enough. Here's how I've defined the post type at the moment:               function user_contract_post_type(){         register_post_type(         'Contract',         array(             'labels' => array(             'name' => __('Contracts', 'intranet'),             'singular_name' => __('Contract', 'intranet')             ),             'public' => true,             'publicly_queryable' => true,             'exclude_from_search' => true,             'show_ui' => true,             'menu_position' => 71,             'query_var' => true,             'has_archive' => false,             'rewrite'   => array(             'slug' => 'contracts',             'with_front' => false,             'feeds' => false             ),             'hierarchical' => false,             'supports' => array(             'title',             'editor',             'page-attributes'             ),             'capability_type' => 'contract',             'capabilities' => array(             'edit_contract',             'read_contract',             'delete_contract',             'publish_contract',             'edit_contracts',             'delete_contracts',             'delete_published_contracts',             'edit_published_contracts'             ),             'map_meta_cap' => true,             'can_export' => true         )         );     }     add_action('init', 'user_contract_post_type');      Which is allowing me to edit the contracts as I can see the Contracts link in the admin main-menu and the Contracts edit screen, whereas other users can't, but I can't do anything else. All I can do is read and update an already published contract, and preview and submit new contracts for review. Any help is much appeciated. Thanks!


Gravity Forms need hook after lead update

I'm using this Gravity Form List & Edit plugin to show all entries/leads in front end. This plugin has few buttons. Edit/Delete/View Lead. a.e. I found a way to get hook after submit and after delete.               // Deletion Hook     add_action("gform_delete_lead", "deleted_entry_post");     function deleted_entry_post($entry){         $deleted = array (             "action" => "DELETE",             "id" =>     $entry         );         post_to_url("example.com/post/php", $deleted);       }      Is the are way to to write action which will do something after form was updated. Thanks


Warning: urlencode() expects parameter 1 to be string, array given in and not getting the preffered output

> Warning: urlencode() expects parameter 1 to be string, array given in > `D:\xamppp\htdocs\sample\wp-includes\formatting.php` on line 3690 When I try to give the `category_name` in the `query_post`,               <?php        $args=query_posts(         array(          'posts_per_page' => -1,        'category_name' =>array('Breaking News Stories', 'Call-out', 'Featured Story', 'Standard Stories')       ));      ?>      I'm having the above warning in `formatting.php` file. line 3690 has the below code:               <?php        function wp_basename( $path, $suffix = '' )          {           return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) );          }     ?>


Custom theme won't use search.php

I have a custom searchform.php and search.php in my theme. However, when searching for something all I see is the front page (with mysite.com/?s=something in the adressbar). I use a filter to make Wordpress use my custom search form (don't know why it won't use it otherwise). The search does work when I use a different theme. Filter code snippet in functions.php:               function search_form_no_filters() {       // look for local searchform template       $search_form_template = locate_template( 'searchform.php' );       if ( '' !== $search_form_template ) {         // searchform.php exists, remove all filters         remove_all_filters('get_search_form');       }     }     add_action('pre_get_search_form', 'search_form_no_filters');      My searchform.php               <form id="searchform" action="<?php echo home_url( '/' ); ?>" method="get" role="search">
             <input id="s" type="text" name="s" class="form-control">                              <button class="btn" type="button" id="submit">Go</button>
              </form>      For debugging purposes I currently use search.php from the Twentyfourteen theme. I've researched this problem and it seems that the most common mistake is that the search query input field has a name other than "s". I got that right though.


Alter menu item parent relationships with walker?

An example custom menu structure I would like users to see               About      Interests     - Movies     - Toys     - Fun     Job     Hangouts      The end result outputted menu ready for dropdownage would be               About     - Interests       - Movies       - Toys       - Fun     - Job     - Hangouts      The way I have solved it for now is by filtering the wp_nav_menu_object               add_filter( 'wp_nav_menu_objects', 'add_menu_parent');          function add_menu_parent( $items ) {            //grab the id of the first menu item       $parent = $items[1]->ID;            foreach ($items as $key => $object) {             //if menu item has not parent and not the first item set the items menu parent to be the first item in the menu          if ($object->menu_item_parent === 0 && $object->ID != $parent){           $object->menu_item_parent = $parent;       }           }     }      I'm wondering if there is a more robust way to do this with a custom walker class.


When using the get_terms and trying to order the terms using the 'order' and/or 'orderby' does not work

does this code really get you the categories in the order you want?               $categories = get_terms( 'category', 'order=ASC' );     echo "
";        var_dump($categories);      for me, it does not. In fact, the following three produces the same output               $categories = get_terms( 'category', 'order=ASC' );     $categories = get_terms( 'category', 'order=DESC' );     $categories = get_terms( 'category', 'orderby=count&hide_empty=0' );      Though the codex ( http://codex.wordpress.org/Function_Reference/get_terms ) says `order` and `orderby` valid params! What am I missing? Does the below code really work for you and produce different outcomes?               $categories = get_terms( 'category', 'order=ASC' );     echo "
";        var_dump($categories);     echo "
";       echo "
";     $categories = get_terms( 'category', 'order=DESC' );     echo "
";        var_dump($categories);     echo "
";


Problem loading wordpress functions outside of wordpress

I´ve just finished setting up my first ever website and blog, so please be gentle ;) . I am having a problem using some functions outside my wordpress installation (blog.example.com). To be specific: The function `is_user_logged_in()` always returns a `false` and I can´t get the admin bar to show up (googled a lot about that last problem, couldn´t find a solution and I´m guessing that both problems are somehow related), when not at the subdomain blog.example.com, whereas functions like `the_content()` or `the_excerpt()` work perfectly fine outside of the installation. * * * Some further information: Every page not located at the subdomain is enclosed by `get_header()` and `get_footer()`, so that the blog and website looks the same and I already tried including `wp-blog-header.php` and/or `wp-load.php`. The header looks like this:                    <?php include "$_SERVER[DOCUMENT_ROOT]/wordpress_installation/wp-blog-header.php" ?>                           <title>                 //no problems here             </title>                  //trying to get the admin bar to work                          <link rel="stylesheet" type="text/css" href="http://blog.example.com/wp-includes/css/admin-bar.css">                  //everything fine after that             <LINK href="<?php bloginfo('stylesheet_url')?>" rel="stylesheet" type="text/css">             <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>"             <meta name="author" content="author" >             <meta name="keywords" content="website name" >                  //loading wp_head             <?php wp_head(); ?>                       //trying to get that damned admin bar to show up!         <?php             wp_admin_bar_render();         ?>         //more irrelevant content after that      And the footer looks like this:
             //this works only when called from the subdomain blog.example.com             <?php if(is_user_logged_in()):?>             Logout             <?php else:?>             Login             <?php endif?>
          <?php wp_footer(); ?>                          Many thanks in advance! Tobi


Post navigation not working

I'm having a strange issue on a blogpage that I'm working on. I have created an index.php page with a loop that display's only a specific category of posts. It also displays the next and previous posts links when needed. All fine. I've copied that loop with into a new template page and modified the loop to display a different category of posts. But this time the next and previous posts links are not displayed on the page. How is that possible? This is the loop on the template page:               <?php  $custom_query = new WP_Query ('cat=4&order=DEC&paged='.$paged);?>          <?php if ($custom_query->have_posts()) : while ($custom_query->have_posts()) :          $custom_query->the_post();  ?>

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

 Published on:      <?php the_time('j F Y'); ?> |  Author: <?php the_author(); ?>
          <?php the_content(); ?>
          <?php endwhile; ?>
          <?php next_posts_link(' Previous posts') ?>      <?php previous_posts_link('Next posts ') ?>


Pagination on custom template doesn't work

I have a custom template for my blog homepage and for some reason the pagination isn't working. I am using next_posts_link and previous_posts_link for the pagination. The main blog page is located at www.myurl.com/posts and when a user clicks the previous posts link, the page will refresh and the url will be updated to www.myurl.com/posts/page/2/ but the actual posts will stay the same. Here is my query:                <?php          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $args=array(           'post_type' => 'post',           'post_status' => 'publish',           'posts_per_page' => 20,           'paged' => $paged,           );              query_posts($args); ?>              <?php if( have_posts() ) { ?>                <?php while( have_posts() ): the_post(); ?>             <div id="post-<?php get_the_ID(); ?>" <?php post_class(); ?>>               <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( array(200,220) ); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                         <?php the_time('F jS, Y'); ?> / <?php the_author_link(); ?> / <?php comments_popup_link(__('0 comments','example'),__('1 comment','example'),__('% comments','example')); ?>               <?php the_excerpt(__('Continue reading »','example')); ?>
           <?php endwhile; ?>

<?php next_posts_link('« Previous Entries') ?>

<?php previous_posts_link('Next Entries »') ?>

         <?php } else { ?>

<?php _e('None found.','example'); ?>


Making $paged work with WP_Query

I've created a page that displays posts of a certain category from a custom post type but I can not get the paging to work. I've tried to use this as a guide but I don't understand what I am doing wrong. This is the code I have:               <?php      // set the $paged variable     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     // new query     $args = array(     'post_type' => 'ai1ec_event',     'events_categories' => 'M3C',     'paged' => $paged     );          $query2 = new WP_Query( $args );          if ( $query2->have_posts() ) :     while ( $query2->have_posts() ) : $query2->the_post(); ?>          <article class="<?php echo $post->post_type; ?>">
<a href="<?php esc_url( the_permalink() ); ?>" title="Permalink to <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?>
     <?php the_excerpt(); ?>
          <?php endwhile; ?>          <?php if ( function_exists('wp_pagenavi') )     {         wp_pagenavi();     }     elseif ( get_next_posts_link() || get_previous_posts_link() )     {         ?>

<?php next_posts_link('Older Posts') ?>

<?php previous_posts_link('Newer Posts') ?>

           <?php } //if wp_pagenavi     endif;     ?>      I'd really appreciate any pointers, I'm still learning so it may be a bit hacky. Thanks.


How to update plugin without overwrite custom code

I am using horizontal-scrolling-announcement plugin to announce a news bellow the header.I have added some custom code to hide scrolling news announcement at one event if the admin change the status display no and its working .Before the customize the plugin if i set the status display no it was scrolling news with text "No announcement available.". Now the problem is that if the plugin updated automatically my custom will be overwrite with new code i just wanted know that how can i update the plugin without overwrite the my previous custom code. Bellow is the function which i have added some custom code to hide scrolling.               <?php     function HSA_shortcode( $atts )      {     if ( ! empty($data) )          {     // Scroll new announcement           }     else   //Hide scrolling bar              {          ?> <style>          .breaking-news{     visibility:hidden;     height:0;     width:0;     opacity:0;           }          </style>             /*$what_marquee = $what_marquee . "No announcement available.";             if($group <> "")             {                 $what_marquee =  $what_marquee . " Please check this group " . $group;             }  */         <?php }               return $what_marquee;     }


Displaying the number of updates available in the Admin area

I am having an issue finding out how to display the number of plugins/updates available to call somewhere else other than the admin header. I found the function `wp_get_update_data` should be what I need: How is the " wp_get_update_data " function used? However, I wasn't sure how to get this to display as an actual count of the total plugins and updates available or any working example on the internet of how to use it. Any suggestions would be much appreciated.


Missing visual editor after placing a redirect rule into the .htaccess file

My blog (blog.mywebroom.com) isn't showing the visual editor whenever I try to edit or add a new post. I tried a whole host of solutions, except I couldn't figure it out. The editor disappeared about a week ago after I placed a redirect url into the .htaccess file. I've tried contacting my host provider who could provide no solution and I've scoured the forums for an answer. Can anyone provide a solution? I added these rules:               RewriteCond %{HTTP_HOST} ^(www\.)?blog\.mywebroom\.com$ [NC]     RewriteRule ^ http://www.mywebroom.com/blog%{REQUEST_URI} [NE,R=301,L]


Apply ordering args to newly merged queried

I have two queries with arguments and then I merged them to form my new query - $wp_query. I would like to now apply arguments to the new query to show the merged pages/posts by meta_value_num. This ordering works great on the $page_args array if I apply it there but not to the combined array. Also the meta_value_num prints out in the loop, but does not order the posts/pages at all. What am I missing here? Thanks.               $page_args = array(         'post_type' => array( 'page'),         'post__in' => get_pageslug(" 'first_page', 'second_page' ")     );          $blog_args = array(         'post_type'=> array('blog'),         'showposts' => 1,//latest         'offset' => 0     );          $query_1 = new WP_Query( $page_args );//5     $query_2 = new WP_Query( $blog_args );//1          $args = array(         'meta_key' => 'my_ordering',         'orderby' => 'meta_value meta_value_num',         'order' => 'ASC'     );          // Create new empty query and populate it with the other two queries to combine     $wp_query = new WP_Query($args);     $wp_query->posts = array_merge( $query_1->posts, $query_2->posts );      $wp_query->post_count = count( $wp_query->posts ); //6          while ( $wp_query->have_posts() ) : $wp_query->the_post();     $box_ordering = get_post_meta($post->ID, 'my_ordering', true);     echo $box_ordering . '<br>'; //outputs meta values for each page/post correctly     //but does not order the content by meta value     endwhile;


Getting the excerpt from latest blog post, could someone please explain?

I know this question has been asked a bunch, but due to my newness to Wordpress, nothing I came across was working for me. I finally found a question with a chunk of code that actually displayed something when I used it: How can I list recent posts excerpts? ....but I don't understand exactly what to do next. Here is what they started with:               <?php      $args = array('numberposts'=>'3');      $recent_posts = wp_get_recent_posts( $args );     foreach( $recent_posts as $recent ){          echo '
'. $recent["post_title"].'
 ';     }     ?>      The answer to his question was "Steal the code from get_the_excerpt()":               apply_filters( 'get_the_excerpt', $recent['post_excerpt'] )      But how do I steal that code? Where do I put it exactly? What do I do with it? I have tried plugging that line in all sorts of places but nothing is working. I am so confused :(


Wordpress Media Uploader error messages localization on frontend

I'm working with ru-RU wordpress vertion. I've faced with issue that I can not get russian error messages on custom media uploader on front end. This error strings media uploader get from pluploadL10n which is localized and printed by `wp_plupload_default_settings()` function which is called by wp_enqueue_media(). I've checked, how it work and print this part to see result `echo $wp_scripts->get_data( 'wp-plupload', 'data' );`. In admin section data prints localized, but on frontend I've got English version. I can't understand in which way I should pass localization parameters to get localized data. Thanks in advance for help! Upd 1: I enqueue sripts this way:               add_action('wp_enqueue_scripts', 'wp_enqueue_sripts');          function wp_enqueue_sripts() {         if(is_page('new-recipe') || is_page('edit')){                  wp_enqueue_media();         }     }      Upd 2: Found where is my translation dissapear. In class Translations, file /wp-includes/po-mo/translations.php this function sould return the object of Translation Entry, but, return nothing on frontend. Now I completely stuck and don't know what to do :(               function translate_entry(&$entry) {         if ($entry->singular == 'You have attempted to queue too many files.') // <- Debuging my string;             print_r($entry);         $key = $entry->key();         if ($entry->singular == 'You have attempted to queue too many files.') // <- Debuging my string;             print_r($this->entries[$key]);         return isset($this->entries[$key])? $this->entries[$key] : false;     }


ted talks embed fixed, but can't control size

I used this changes to functions.php that are written in this post: TED talks shortcode not working But I can't figure out how to control the size/ratio now. The video is embedding as way taller than it is wide. Any fix for this??


jQuery Ajax: re-executing plugin on success, when plugin function is NOT known beforehand

I'm a WordPress theme developer and I've building an ajaxified theme having structure like this ...
 content here

 content here

 content here
                Now when any link is clicked, a jQuery script like this is executed ...               $.ajax({                url: targetURL,           dataType: "html",           success: function(response) {                    var targetBody = $(response).filter('#site-body').html();                    $('body').prepend('

');               $('#ajax-body').append(targetBody);                }           });      And it works perfectly fine. But now the issue is, target page may use some wordpress plugin (based on jQuery) e.g. a page having a contact form using contact form 7. Now if i submit the form, the page will refresh (instead of ajax submitting) because jquery script of this wordpress plugin is not RE- INITIATED in ajax callback. Ofcourse, i can add it's function as callback in ajax function. But i'm developing a theme for mass audience and i've no control on which plugins will be used by my customers. And infact, adding hundreds, if not thousands, of WordPress plugins functions in jQuery ajax callback will not be a good practice. What could be the solution here?


Delete all custom fields at once?

I have about 50 custom fields I need to delete at once, going through each one and deleting one at a time would take too long because it takes about 4 seconds for a page to load and I just don't have time to do that. I need to delete them because I previously used a plugin called Advanced Custom Fields (ACF), but apparently it doesn't work well together with qTranslate, so I'm replacing ACF with another plugin called Types, which does pretty much the same thing a little uglier. The problem is, even after deleting all custom field groups with ACF, the fields are still there! And I need to remove them because otherwise I can't create new fields with the same name with Types. I found a plugin called "Delete Custom Fields" but it didn't work. Any other ideas on how to delete _all_ of them at once? Can I manually delete the fields from the database? EDIT: I should also mention you can manage custom fields from within Types, but appareantly you can only manage the ones that are "under Types' control" a.k.a. the ones created by Types, so that didn't work.


How do I centre all page titles site wide without centring post titles or site title?

I'd like page titles centred site wide especially for landing pages. Is this possible without centring posts titles and everything else on the site?


Mamp Pro features like virtual hosts in Xampp or Wamp?

A friend of mine showed me the virtual hosts feature within Mamp, its pretty nifty. Using git and mamp pro to work locally makes it really easy to set up staging for WordPress sites. Was wondering if there was a similar feature within xampp or mamp (using windows for development), or do I have to manually change my hosts files for local test sites?


wp_redirect "headers already sent" after front-end submission form

I'm trying to practice with setting up a front-end post submission form. And I'm getting this error:               Warning: Cannot modify header information - headers already sent by (output started at /home/sadlight/public_html/members/wp-content/themes/default-child/announcement-submit.php:1) in /home/sadlight/public_html/members/wp-includes/pluggable.php on line 876      announcement-submit.php is my template below. I've tried this solution, but no go. Also, when I use wp_redirect in my code below, it inserts TWO posts instead of one. When I remove it, it only enters one. Any help would be great! Just for extra info: I'm using buddypress with the default buddypress theme.               <?php          /*      * Template Name: Announcement Submit       */          $postTitleError = '';     if ( isset( $_POST['submitted'] ) ) {         if ( trim( $_POST['postTitle'] ) === '' ) {             $postTitleError = 'Please enter a title.';             $hasError = true;         }     }               get_header(); ?>

                      <form action="" id="primaryPostForm" method="POST">                     <fieldset>                         <?php _e('Post Title:', 'framework') ?>                         <input type="text" name="postTitle" id="postTitle" class="required" value="<?php if ( isset( $_POST['postTitle'] ) ) echo esc_attr( stripslashes( $_POST['postTitle'] ) ); ?>" />                     </fieldset>                     <fieldset>                         <?php wp_editor( 'Testing some content', 'postcontent'); ?>                     </fieldset>                     <fieldset>                         <?php wp_nonce_field( 'post_nonce', 'post_nonce_field' ); ?>                         <input type="hidden" name="submitted" id="submitted" value="true" />                         <button type="submit"><?php _e('Add Post', 'framework') ?></button>                     </fieldset>                 </form>                      <?php if ( $postTitleError != '' ) { ?>                     <?php echo $postTitleError; ?>

                 <?php } ?>                      <?php                     if ( isset( $_POST['submitted'] ) && isset( $_POST['post_nonce_field'] ) && wp_verify_nonce( $_POST['post_nonce_field'], 'post_nonce' ) ) {                         if ( trim( $_POST['postTitle'] ) === '' ) {                             $postTitleError = 'Please enter a title.';                             $hasError = true;                         }                         $post_information = array(                             'post_title' => wp_strip_all_tags( $_POST['postTitle'] ),                             'post_content' => wp_kses_post( $_POST['postcontent'] ),                             'post_type' => 'post',                             'post_status' => 'pending'                                                               );                         wp_insert_post( $post_information );                                         }                          $post_id = wp_insert_post( $post_information );                          if ( $post_id ) {                         wp_redirect( home_url() );                         exit;                                        }                 ?>

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


edit-tags.php in plugin admin menu hides when is the active page

For the plugin I'm building I have added a submenu as a child to a custom main menu item in admin. The submenu page is an `edit-tags.php` page. This shows up as intended under the main menu item. When clicking on this sub menu item, the user is taken to the correct page, however, the main menu item collapses back down, hiding the currently open sub menu item. My initial feeling is that the parent slug attribute is wrong, but other submenus I have added use the same parent slug attribute and they work correctly. I'm clearly missing some option in the `add_submenu_page()` function, but I cannot figure out what. Here is how I am registering the sub menu:               $this->plugin_screen_dashboard = add_submenu_page(         $this->plugin_slug, // Parent slug         __( 'Subscriber Lists', $this->plugin_slug ), // Page title         __( 'Subscriber Lists', $this->plugin_slug ), // Menu title         'manage_options', // Capability         'edit-tags.php?taxonomy=subscriber_list&post_type=subscriber' // Menu slug     );      **_--Edit--_** Here is how I register the main menu item:               $this->plugin_screen_hook_suffix = add_menu_page(         __( 'My Plugin', $this->plugin_slug ), // Page title         __( 'My Plugin', $this->plugin_slug ), // Menu title         'manage_options', // Capability         $this->plugin_slug, // Menu slug         array( $this, 'display_plugin_admin_page' ), // Function         'dashicons-plus-alt' // Icon url     );


Why is output buffering used here?

wondering if anyone could explain why the author used ob_start() and ob_clean() in this code to build an import/export page in WordPress? Since I'd like to integrate this code into another plugin, and I want to separate the code into different files, where would I need to place ob_start() for this to work?               <?php     /*     Plugin Name: I/E Option     Plugin URI: http://wp.tutsplus.com/     Description: This is a sample plugin with backup and restore options feature.     Author: Lee Pham     Version: 1.0     Author URI: https://twitter.com/leephamj     */          function register_ie_option() {         ob_start();         add_menu_page('IE Option Page', 'IE Option', 'activate_plugins', 'ie-option', 'ie_option_page', '');             add_submenu_page('ie-option', 'Import', 'Import', 'activate_plugins', 'ie-import-option', 'ie_import_option_page');         add_submenu_page('ie-option', 'Export', 'Export', 'activate_plugins', 'ie-export-option', 'ie_export_option_page');      }          /*        *  Main page      */     function ie_option_page() {     ?>

Backup & Restore

This is only a sample plugin that demonstrate how to create a simple import/export feature for your own templates or plugins.

Hope it useful for you!

Get in touch with me:

E-mail: leephamj@gmail.com

Twitter: @leephamj

Facebook: Lee Pham

     <?php        }          /*        *  Import feature      */     function ie_import_option_page() {     ?>

Import
             <?php                 if (isset($_FILES['import']) && check_admin_referer('ie-import')) {                     if ($_FILES['import']['error'] > 0)                          wp_die("Error happens");                             else {                         $file_name = $_FILES['import']['name'];                         $file_ext = strtolower(end(explode(".", $file_name)));                         $file_size = $_FILES['import']['size'];                         if (($file_ext == "json") && ($file_size < 500000)) {                             $encode_options = file_get_contents($_FILES['import']['tmp_name']);                             $options = json_decode($encode_options, true);                             foreach ($options as $key => $value) {                                 update_option($key, $value);                                 }                             echo "

All options are restored successfully.

";                         }                            else                              echo "

Invalid file or file size too big.

";                     }                 }             ?>
Click Browse button and choose a json file that you backup before.

Press Restore button, Wordpress do the rest for you.
             <form method='post' enctype='multipart/form-data'>
                     <?php wp_nonce_field('ie-import'); ?>                     <input type='file' name='import' />                     <input type='submit' name='submit' value='Restore'/>
             </form>
     <?php     }          /*        *  Export feature      */     function ie_export_option_page() {         if (!isset($_POST['export'])) {      ?>

Export

When you click <tt>Backup all options</tt> button, system will generate a JSON file for you to save on your computer.

This backup file contains all configution and setting options on our website. Note that it do NOT contain posts, pages, or any relevant data, just your all options.

After exporting, you can either use the backup file to restore your settings on this site again or another Wordpress site.
                 <form method='post'>
                     <?php wp_nonce_field('ie-export'); ?>                     <input type='submit' name='export' value='Backup all options'/>
                 </form>
     <?php          } elseif (check_admin_referer('ie-export')) {                  $blogname = str_replace(" ", "", get_option('blogname'));             $date = date("m-d-Y");             $json_name = $blogname."-".$date; // Namming the filename will be generated.                  $options = get_alloptions(); // Get all options data, return array                  foreach ($options as $key => $value) {                 $value = maybe_unserialize($value);                 $need_options[$key] = $value;             }                  $json_file = json_encode($need_options); // Encode data into json data                  ob_clean();             echo $json_file;             header("Content-Type: text/json; charset=" . get_option( 'blog_charset'));             header("Content-Disposition: attachment; filename=$json_name.json");             exit();         }     }     add_action('admin_menu', 'register_ie_option');


Disable all admin UI access to authors (except to custom post type add, edit and modify)

I just created a custom post type named Catalog. Where authors can create as many entries they need. But I need to restrict/deny access to all admin parts: Posts, Profile, Media or other admin parts except their Catalog entries. Do I need to compare against $_SERVER['REQUEST_URI'] or theres a better way? Thanks in advance.


Restrict Contributors to view only their own custom post types?

For our 'Posts' type, our Contributors can see only their own posts, which is what we want. But for our custom post types, Contributors can see every post, including drafts. Is there a way to limit their view of custom posts so they only see their own posts like it is in the 'Posts' type? Edit: Maybe I wasn't as clear about my problem. I want the Contributors to be able to see all of the custom types (Videos, Images, etc), but within each custom type I want them to be able to see only their own posts. So if they look at the CPT Videos, for example, they would only be able to see their own posted videos, not a post by someone else.


Displaying related posts in a custom post type by a custom taxonomy

I'm trying to display related posts by a custom taxonomy (product_tags) in a custom post type (products). The following code works, but it ignores **posts_per_page**. Any ideas?                               global $post;                     $terms = get_the_terms( $post->ID , 'product_tags', 'string');                     $do_not_duplicate[] = $post->ID;                          if(!empty($terms)){                         echo 'Related Products';                         foreach ($terms as $term) {                             query_posts( array(                             'post_type' => 'products',                             'product_tags' => $term->slug,                             'posts_per_page' => 3,                             'ignore_sticky_posts' => 1,                             'orderby' => 'rand',                             'post__not_in' => $do_not_duplicate) );                             if(have_posts()) {                                 while ( have_posts() ) : the_post(); $do_not_duplicate[] = $post->ID; ?>
                                 <?php if (has_post_thumbnail()) { ?>                                     <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">                                         <?php the_post_thumbnail( 'related_sm', array('alt' => get_the_title()) ); ?>                                                                      <?php } else { ?>                                     <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?>                                 <?php } ?>
                                 <?php endwhile; wp_reset_query();                             }                         }                     }


Missed schedule

My future posts are going missed. They are not getting published on the time they should, and it says "Missed Schedule". I read somewhere that it could be a server issue, so how can I fix it?


Problem with WP_Query loop and search term

I have a custom query to display random posts in my sidebar like this:               $newQuery = array(          'post__in'  => get_option('sticky_posts'),          'post_type' => 'ad_listing',          'posts_per_page' => 10,          'orderby' => 'rand',          'post_status' => 'publish');          // Get new set of ads     $smStickyPosts = new WP_Query($newQuery);          if ($smStickyPosts->have_posts()) : while($smStickyPosts->have_posts() : $smStickyPosts->the_post();         //Display posts     endwhile;      This works fine in all pages, except on the search page, for some reason the first post on the list is always the post that coincides with the search term (for example, if I search for foo and I have a post with the title "foo" it will show first followed by 9 random posts), it's like the search term is getting passed to the custom loop as well. Also I noticed that if I search for something that doesn't find any results the posts are always the same, it's like the orderby => rand is not doing anything, it works fine on the rest of the site though. Does anyone know what could be wrong? Thanks in advance.


How to *remove* a parent theme page template from a child theme?

I'm using the TwentyTen theme to create a child theme, but I can't seem to get rid of the 'One column, no sidebar' page template that is in the TwentyTen parent theme. I thought just copying it over and deleting the contents would do the trick, but it seems not. Does anyone know how to do this? I'm sure it's very simple. Thanks osu


What hooks to hook onto for automatic cache clearing

I have a WP-site with not that many writes, but quite a few reads and a few specific hotspots in the templates that I'd like to cache pretty aggressively with my own PHP-caching mechanism. I could implement this with a time-based cache expiration scheme, but as I'm sure Wordpress provides all the API I need for listening to different events, I could also hook into them for info on when I need to clear caches. So, I'm a bit lost on the whole hooks / filters -thingy of Wordpress. I can add listeners to hooks easily enough, but I'm just a bit too overwhelmed with the amount of hooks available, so my question is: What hooks should I hook into to basically be able to execute a script upon every INSERT / UPDATE / DELETE operation on the posts-table? Any pointers on the way onward are much appreciated!


Filter Home Page Posts in Buddypress

I would like to remove blog posts from the home page if they belong to a certain category. How can I go about this in Buddypress (preferably without a plugin)?


How to Add Javascript Only When a Function Exists?

I have a few function. For both of them need javascript code. I need to add javascript code in header only when function is active. At this time I have all my javascript code in header for all my function and newermind which one of them is active. I tried to make this code but nothing is changed: All I have in **scripts.php**               function my_scripts() {       if (!is_admin()) {         wp_enqueue_script('jquery');         wp_enqueue_script( 'custom',            get_bloginfo('template_directory').'/js/custom.js',            array( 'jquery' ),            '',            true );         if (is_front_page()) {           if (function_exists('function_one'))             wp_enqueue_script( 'jquery1',               get_bloginfo('template_directory').'/js/jquery.plugin.js',                array( 'jquery' ));           else if (function_exists('function_two'))             wp_enqueue_script('jquery2',                         get_bloginfo('template_directory').'/js/jquery.plugin2.js',                array( 'jquery' ));           else if (function_exists('function_three'))             wp_enqueue_script( 'jquery3',               get_bloginfo('template_directory').'/js/jquery.plugin3.js',                array( 'jquery' ));          }       }     }     add_action('wp_print_scripts', 'my_scripts');      **mycode.php** This code include all my three functions. Looks like:               function function_one() { ?>       ...code..      <?php }          function function_two() { ?>       ...code..      <?php }          function function_three() { ?>       ...code..      <?php }      This two files are defined in `functions.php`. I'm new in php, please help me how should I need to do? Thank you! * * * **UPDATE** Function for choosing slider's looks like this               function sliders {       $sliders = get_option('src_switcher'); // array in theme options with sliders name       if($sliders == 'First slider') {         function_one();       }       if($sliders == 'Second slider') {         function_two();       }       if($sliders == 'Third slider') {         function_three();       }     }


Wordpress Theme for Video Showcase

Does anyone know of a good theme for showcasing multiple Youtube videos? Thanks!


How to direct to any page

How to direct to login page and go to destination page? for example: if user click any URL who that user not yet login, direct to login page. After, sign in, user continue directly to page that user want. How to get URL, save in temporary trick in wordpress. Code sample : page 1 : `<a href="">Game List</a>` page 2 : `if (is_user_logged_in()){\\\here***how save this URL**//}else{go to login page}` page login : `if login success go to **save this URL**`. Any suggestion, please? Thank you


permalink and add_rewrite_rule - error 404

I'd like to have comments in a separate page with a dedicated template only for posts in a specific category (slug shops). Example: mysite.com/post- incatshops --> mysite.com/post-incatshops/comment To do this I create different functions that I put in my functions.php. The problem is that for some posts it returns a 404 error randomly. My permalink structure is: /%postname%. I'm using the plugin WP No Category Base. Monkeyman Rewrite Analyzer returns for each post in that category this line > ^my-post-title/comment p: 16138 Could you please help me and tell me where I'm wrong? Thanks in advance               function setup_permastruct() {     add_rewrite_tag('%opinioni%','([^/]+)');     add_rewrite_tag('%codici-sconto%','([^/]+)');     }          function eg_add_rewrite_rules() {       global $wp_rewrite;       global $wp, $wpdb, $post;              $loop = new WP_Query(array('post_type' => 'post',                     'posts_per_page' => -1,                     'category_name' => 'shops',                     'orderby' => 'date',                     'order' => 'DESC')             );              while ( $loop->have_posts() ) : $loop->the_post();                 $custom = get_post_custom($post->ID);                 add_rewrite_rule( '^'.$post->post_name.'/comment', 'index.php?p='.$post->ID, 'top' );                  endwhile;             $loop = null;             wp_reset_query();                  $wp_rewrite->flush_rules(false);         }         add_action( 'template_redirect', 'eg_add_rewrite_rules' );               function change_template_include( $t ) {           $url = explode( '/', $_SERVER['REQUEST_URI'] );           $url = array_filter( $url );           $url = array_pop( $url );           if( $url == 'comment' ) {             $t = str_replace( '/single.php', '/template-single-comment.php', $t );             }           return $t;         }         add_filter( 'template_include', 'change_template_include',10, 1 );


Auto block ALL IP's indicated by Akismet?

I'm thinking of blocking all IP adresses indicated by Akismet as containing spam. Something like cronning               select distinct wp_comments.comment_author_IP     FROM  `wp_commentmeta` JOIN `wp_comments`     WHERE wp_commentmeta.comment_id = wp_comments.comment_id       AND wp_commentmeta.meta_value='true'     ORDER BY wp_comments.comment_author_IP      and then adding the IP's automatically to .htaccess. Even better, I would like to post the current list of 524 IP's to a webservice to be sure hundreds of other people are also blocking the same IP. Is that smart? **update** now checking with http://www.dnsbl.info/ . Interesting e.g. 109.105.192.194 is listed with one of the spam database but not others. So I probably need to write a plugin that auto blocks the IP and then refer them to DSNBL if they want to unblock themselves. IS there already a DSNBL plugin? **update** apparantly (ofcourse) there is : http://wordpress.org/support/topic/visitors-checked-by-dnsbl


What Wordpress Hook Is Used Before Signup Data is Saved?

I need hook which is working before signup data save on new user and blog registration on BP or WP 3.0.3. Any help would be greatly appreciated.


WordPress training materials

Are there any good publicly-available WordPress training materials (videos, manuals, etc.) that could be used to give content editors a basic overview of WordPress? We have a handful of blogs on a WordPress server and I'd really like to be able to automate training some more.


Plugin List Category: post custom field doesn’t show anything

I'm using the Plugin List Category to show a list of posts and I use it with the parameters:               [catlist name=talleres thumbnail=yes thumbnail_size=52,52 excerpt=yes customfield_display=featured]      But it doesn't show anything for the custom fields. I tried with different parameters, still nothing. Does anyone have an idea, do I have the syntax wrong?


associate posts to a page

I created a theme, and I created a page for the theme, and now I want to associate posts to the page. I read this article: http://codex.wordpress.org/Pages Look under the section "Examples of Pages and Templates", there is this code:
      <?php if (have_posts()) : while (have_posts()) : the_post();?>
      <h2 id="post-<?php the_ID(); ?>"><?php the_title();?>

       <?php the_content('
Read the rest of this page »
'); ?>

      <?php endwhile; endif; ?>      It seems to be pulling some posts associated with a page. How can I create posts for a page? And if not possible, what are they doing or what kind of altenrative is available to me, other than hardcoding html into the page?


Add attachment for all images in post

I want to move someone else's WordPress blog to a new server. I only have access to the exported XML file of the blog. When importing the XML with the Wordpress Importer plugin, everything went fine except for importing the images. It seems the authors of the blog did not use the built-in upload functionality to add images to a blog post, but uploaded them separately on the server. I was able to download all the images referenced in the blog posts and store them in the "uploads" folder, so all images display correctly on the new server. However they don't appear in the media library and thus I can't access them in the code of the new theme. So my question is: How do I scan all blog posts for image references and add them as attachments?


Limit number of posts on a custom category template - breaking pagination

The following code was mentioned from one of the commentors, however it is breaking the pagination. Any corrections please                <?php          include(TEMPLATEPATH. '/includes/headline.php'); rewind_posts();         if (have_posts())          {         echo '
';         while (have_posts()) : the_post();         global $post;         $query_string;         query_posts( $query_string .'&posts_per_page=5' );         include(TEMPLATEPATH. '/includes/loop.php');         $q = $wp_query->current_post;         $maxq = tj_current_postnum();         if($q < $maxq-1 && is_int(($q+1)/2)) echo '

';         $postcount++;         endwhile;         echo '
 ';         } else {          include(TEMPLATEPATH. '/includes/not-found.php');          }          if ( $wp_query->max_num_pages > 1 ) tj_pagenavi();?>


Problems when writing a post

I have a blog, with Duena Theme, and when I write is all ok. The problem is when I publish that text, and the margins of the paragraphs split my words. For example The horse is a very wil d animal and he is eatin g carrots, salads and lot s of.... I dont want it to be like that, I don t want my words splitted in half. If it s not enough space, I want all the word to be put down, not parts of it. Please helppp thx


Redirect from home page to post list page?

There is a site at `http://theprimarkonlineshop.com` that I want to be redirected to `http://theprimarkonlineshop.com/category/blog` when a user enters the site. I've tried some stuff like               RewriteEngine on     RewriteCond %{REQUEST_FILENAME} ^/$ [OR]     RewriteCond %{REQUEST_FILENAME} ^$      RewriteRule . http://theprimarkonlineshop.com/category/blog/ [R=301,L]      but it doesn't work. Also there are some redirections that were put into `.htaccess` by WordPress               RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]      I guess they should remain as is?


Wordpress Fancybox Resize Large Image

I have a wordpress users that aren't very good at resizing images so when they upload an image to wordpress it's still big > 3000px. They can import into a post and a thumbnail is generated. When you click on the thumbnail the image appears in a light box (using fancybox) but because the image is so big it takes ages to load. Is it possible to open a smaller version of the image (say 800px wide) in the lightbox? Automatically, without the user having to resize the image before uploading? Is there a plugin for this? Thanks


Plugins Page - "Page disabled by the administrator"

I've encountered an issue on a site I'm looking after. The 'admin' account no longer has access to the plugins page, if I try and manually type in the URL to the page, I get the following error: "Page disabled by the administrator" Any idea what could be causing that? Thanks!


Does wp_insert_post validate the input?

If I use the wp_insert_post in a plugin, will I have to check the content for SQL injection problems and XSS or will the wp_insert_post function do this for me?


Setting up WordPress playground and deploying to production server?

I would like to have WordPress on my local OS X machine to test out different themes, content, etc and then deploy it on to the production Linux server. I'm using WordPress for my website and blogging will be a secondary thing. What is the best way to do this? Please elaborate on the key steps to create it. I googled around and people talk of using Git, capistrano, editing something to fix some links, some are just the simple blog type setup on server, etc... all sounded too complicated for the basic blog setup. I would like to keep user comments when updating production website. Not too worried about loosing my content but would be nice if I didn't loose it.


Why would wp_head() cause the menus to break?

I've done a few and sometimes ive noticed that when I try to implement some plugins, widgets, etc, they don't work. When I add the `wp_head()` function right before the closing head tag, Then they work. The problem I'm having is that when I try to add it before the head tag, It breaks my menu's styling. I am using a menu plug in called Multi-level Navigation Plugin that I found in the wordpress.org downloads section. Is there something I'm missing? When I add `wp_head()`, the only thing that breaks is the menu's styling. As soon as I remove it, everything is works well again.


Set featured image randomly from Wordpress Database on post submission

Basically every time that I publish a post I want that a random image from my wordpress database be set as the feature image for that post. Can someone help me with this please!


URL Redirect in Wordpress

I am facing problem to redirect some url in wordpress. I need to rewrite following URL: First URL is like this: http://example.com/news/?news=2 where news=2 is the news id and I am getting this id by using $_GET['news']. I want to rewrite this above url to http://example.com/news/2/ Second URL is like this: example[dot]com/product-list/?pp=2&page=3/ and I want to rewrite it as example[dot]com/product-list/2/3/ Thanks in advance for help.


Filter what image sizes get generated

I'm looking for a way to chose what images sizes get generated by image. With all the image sizes I have plus a lot of images, in the end I have a whole lot of server space being used up for nothing. Is there a way to either?   * at upload, select what image sizes get generated for a specific image   * after upload, go to the media page and check off certain image sizes


Looks like this if condition is not working

I want a query to be executed IF the following condition is true... but looks like the query is executed anyways. ` if($post->post_parent = '302'){   // Query goes here   }` Is this query fine?? I want to executed the query if the parent page of current page is 302. Thanks


How to include plugin function in theme's functions.php file

Good day, I'm trying to reduce the jquery dom manipulations by including the right plugin functions in my theme's functions.php file. For example, I have a link which triggers a jquery dialog, which in turn holds the custom contact widget, another one which triggers a jquery dialog which holds a contact widget and so on and so forth. All those dom manipulations have a severe impact performance-wise, so is there any way I can include the plugin's constructor in the divs which are converted to jquery dialogs?


add category name to permalinks on product page /category-name/product-name

I'm trying to reconfigure the permalinks used in WooCommerce such that the following format will be displayed: homesite/category/product. Right now, the permalinks only shows under a category page: homesite/?product_cat="category- name" Under the product page: homesite/?product="product-name" Whatever I tried under the 'Permalinks' section of WP didn't work. By the way the reason I'm trying to alter the permalinks is im trying to create a conditional tag for each product category that will display a different message. Please advise.


How do I query for a post by custom field?

I have a custom field called "song-id" and I'd like to lookup a post by a song-id value. Can someone give me the code snippet for it? (bonus: also looking for a code to use the permalink in the post to redirect to that page)


Get multiple shortcode attribute values

I'm trying to get several values from a shortcode. I tried several things without success. The shortcode looks like this:               [myshortcode metakey="<field_key:key1, title:Title 1><field_key:key2, title:Title 2><field_key:key3, title:Title 3> ]      How would I get the field_key values? So in this case key1, key2 and key3?


is_page conditional question

I am using `is_page` in my `functions.php` file to display some code and I wanted only to display the code in the header if the contact page is being shown. I made a template called contact.php and in the top did the template name: contact. The templates shows just fine but when I went into the functions file and did `is_page('contact')` or `is_page('contact.php')` the code stopped working. Is the function based on the permalinks settings? right now I have wordpress setup for default so instead of showing `contact.php` in the address bar, it shows ?`page_id=94`. If I do `is_page(94)` then my test code works


Posts to expire (deleted) after a date

I am creating a coupon site from scratch. I have reviewed many code examples on the Internet, but have not found anything that will work, as my requirements are little different. I need help in creating an expiry function that would delete the "coupon" (post_type) automatically. As a coupon site, all coupons are imported in bulk, so the expiry date format (e.g. 01/12/2014, 01-12-2014, or 1 Dec 2014) differs from coupon to coupon in a particular import (session). This creates a problem when the date format differs, and it's never the same. Custom field is "expiry_date", it will store the date. Does any one have a good solution for this problem?


Specific colours for wordpress author ids

before I ask this question I would just like to say a big thank to those who helped with my other question. On some wordpress blogs I've seen, with multiple post authors. When you view the full post on the single page, in the meta the author name is a different colour to the admin. For example if the a post was posted by the Admin then it's colour would be pink. But if the post was posted by another author, the colour of the name would be yellow. I know some questions ask about different colour posts or comments, but I'm asking about the post author name.


Related posts in all categories of current post (custom post types)

A client of mine has custom post types that they set up using a plugin rather than defining them in the functions.php. (So, YARPP for the solution won't work). In this custom post types, they have various categories. Each post belongs to one or more categories. After each post, they would like to display 5 posts that are in ALL the same categories (could be one or many categories). So, what I need to do is set up a way to dynamically find all the categories a post belongs to (I've done that & have it set up as an echo right now until I work this out), then query to find 5 posts that belong to the exact same categories (either they belong to all of them or they shouldn't be displayed). Here's the code I've come up with - but, I can't figure out how to "combine them" so it not only gets the terms (categories) but also forces the query to use those terms to filter the 5 "related" programs.                 //get the post's terms (troubleshooting - can be removed once figured out!        $category_terms = wp_get_object_terms($post->ID, 'category');     if(!empty($category_terms)){       if(!is_wp_error( $category_terms )){         echo 'Terms
';         foreach($category_terms as $term){           echo '
slug, 'category').'">'.$term->name.'
';          }         echo '
';       }     }       //get post terms done         // get the custom post type's taxonomy terms              $custom_taxterms = wp_get_object_terms( $post->ID,                     'category', array('fields' => 'ids') );         // arguments         $args = array(         'post_type' => 'program_listings',         'post_status' => 'publish',         'posts_per_page' => 5, // you may edit this number         'orderby' => 'rand',         'tax_query' => array(             array(                 'taxonomy' => 'category',                 'field' => 'id',                 'terms' => $custom_taxterms             )         ),         'post__not_in' => array ($post->ID),         );         $related_items = new WP_Query( $args );         // loop over query         if ($related_items->have_posts()) :         echo '
Other Programs in this category

';         while ( $related_items->have_posts() ) : $related_items->the_post();         ?>
<a href="<?php the_permalink(); ?>"                        title="<?php the_title_attribute(); ?>">                 <?php the_title(); ?>
         <?php         endwhile;         echo '
';         endif;         // Reset Post Data         wp_reset_postdata();      So, get the posts terms & echo them (it won't be an echo when it's finished - I was doing that to make sure it actually got the categories/terms) works great. It displays every "category" the post is in. But, the second bit displays posts from any of those categories rather than posts that are only in ALL the categories. Basically, I need to combine the first & second pieces so that the query only returns results of posts that are in ALL categories of the current post. If a post is not in all the same categories (exact match for ALL categories of current post), it should not be returned. (For example, if a post is in the parent "North America" category, but, not any of the other categories that the post is in, it should NOT be returned in the results).


Multisite - getting a 404 for additional site created using subdomain install

I created an additional site on my multisite subdomain installation. Now when I try to visit the new site or its wp-admin, I get a 404 error. My wordpress instance is hosted on AWS Checked the following   * AllowOverride is set to All in httpd.conf    * contents of .htaccess are the same as those in Network settings   * added the necessary statements to wp-config.php   * Tried restarting httpd as well What else could I be doing wrong? Thanks.


Why does WordPress allow inserting <h1> tags into posts?

It is my understanding that there should not be more than one `<h1>` tag on a page, and that the `<h1>` tag should be the site title, for SEO reasons. If that is correct, why does WordPress allow users to insert `<h1>` tags into posts? Also, would it be a good idea for theme designers to not style `<h1>` tags to discourage users from using them? I have found that the Minileven mobile theme from Automattic (included with the Jetpack) uses `<h1>` tags to display post titles within pages. Why would they do that? I have changed them to `<h2>` throughout the theme, as as far as I can tell (from looking at Google Web Master Tools), Google has specific mobile crawling spiders.


How to hack recent comments default widget?

I would like to hack the default **Recent Comments** widget to show also the avatar of commenter. The modification should be really easy, if I change directly the code in `default-widgets.php`               if ( $comments ) {         foreach ( (array) $comments as $comment) {             $output .=  '
' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), 'comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '') . get_avatar($comment->user_id , 20) .  '
';         }     }      but I don't like change core files and I would prefer a more ortodox way to implement it. How can I do it?


Migrating to Tumblr

I've become a big fan of Tumblr for a few reasons (the minimalism, ease of making quote/photo/video style posts, and the clients for mobile devices I use), so I've decided that after 7 loyal years of using WordPress, both hosted privately and the wordpress.com hosted solution, it's time to move. Unfortunately I have no idea how to do this properly. A few posts on the internet suggest importing from an RSS feed, but that won't quite cut it - my requirements are:   * I keep the same base URL (easy enough by mucking around with DNS records)   * All existing post URLs work, or at least 301 redirect to the new URL (to minimise loss of PageRank)   * Media such as embedded photos gets sensibly imported   * Comments get imported Any idea how I should go about doing this? Thanks!


Change image based on menu item id

My client request to put header images, but the images must be unique based on what menu the click. Let say i have 2 menus. First is What is A and second is What is B. I can know the menu id when i hover the menu at the menu panel. Let say first menu id is 36 and second is 37. My question is how can i change the header images based on the menu item id?


upgrade has caused page content to disappear

I've just transferred a site from one server to another and gone through it and tested it and made sure all the content was there etc etc. I then did a backup of the database via phpMyAdmin and did an export of the content within wordpress. I then downloaded the latest version of Wordpress and did a manual upgrade but overwriting all the wp-admin folder, the wp-includes folder, the core files etc - I didn't touch my theme or uploads or plugins folders. I then did an upgrade of the database - all went well but when I returned to my site all is fine except the content on the pages - this is all missing when visiting the website, but when I go into the backend and view the pages to edit all the content is present - it's just not showing up on the live site. Anyone knoe how I can fix this. I've just realised I forgot to deactivate my plugins before upgrading - damn - would that cause the problem?


Tag description doesn't show hyperlink

I have added HTML code into my TAG description box, but for some reason the output doesn't display the required results. I have even tried to add HREF tag manually into this box, but no hyperlinks are visible. The code contains tag_description();


Rewrite permalinks using custom taxonomy or category

I have a blog I'm making for sporting events and I have categories (News, Commentary, etc.) and a custom taxonomy called "events" (100m sprint, long- jump, etc.) I'm trying to set up a permalink structure that cascades, so that if a post is belongs to the News category and the Long Jump events taxonomy, the taxonomy takes precedence. For example: If Post belongs to "News" category and "Long Jump" events taxonomy: _siteurl/long-jump/postname_ If Post belongs to "News" category: _siteurl/news/postname_ How can I set this up? I'm currently trying to learn Regular expressions to understand how rewrite rules work.


Rewrites for taxonomy and custom post type

I am getting my head around the Wordpress Rewrite API and it's plethora of options! What I have managed to do so far is ensure that my product category does not have the preceeding "productcategory" at the beginning of the URL. What I want to do after this is place the product after it and this is where I am a little stuck as to where to begin as I need to take into account the rewrite I have done for the category. I also have the added unwanted side- effect that this method circumvents the regaular posts functionality - i.e. the default "Hello World" post not displayed but I do seem to get a HTTP 200 response! The post type looks like this:               register_post_type("product", array(         "label" => "Products",         "labels" => $labels,         "description" => "Items available to purchase",         "public" => true,         "hierarchical" => true,         "supports" => array("title", "editor", "thumbnail"),         "rewrite" => array(             "slug" => "%prod_cat%"         )     ));      My taxonomy looks like this:               register_taxonomy("productcategory", "product", array(         "public" => true,         "label" => "Category",         "required" => true,         "single_value" => true,         "query_var" => true     ));      And my rewrite thus far looks like this:               add_action("init", function()     {         add_rewrite_tag("%prod_cat%", "([^/]+)(/[0-9]+)?/?$");     });          add_filter("post_type_link", function($permalink, $post)     {         if(strpos($permalink, "%prod_cat%"))         {             //get the product category of the post             $prod_cat = wp_get_post_terms($post->ID, "productcategory");             $prod_cat = array_pop($prod_cat);                  $permalink = str_replace("%prod_cat%", $prod_cat->slug, $permalink);         }              return $permalink;          }, 10, 2);          add_action("parse_request", function($wp)     {         if(!is_admin())         {             //check to see if prod_cat is set             if(isset($wp->query_vars['prod_cat']))             {                 //is this a valid category                 $prod_cat = get_query_var("product_category");                      if(term_exists($wp->query_vars['prod_cat'], "productcategory"))                 {                     //redo the query                     $wp->query_vars['productcategory'] = $wp->query_vars['prod_cat'];                 }             }         }     });      I did manage to do this all through parse_request but I felt that this was the wrong way to do this and I ultimately want to put an endpoint at the end of all this of "options" so that a full url will read http://example.com/jewellery/earrings/options which would translate as http://example.com/{category}/{product}/{custom_endpoint} Any pointers in the right direction would be greatly received! I've spent a while looking around at various articles but I think to fully understand the Rewrite API, I need to take an example I need to use and work from there!


Multisite WPLANG won't save

I have a multisite workpress install (v 3.3.2). I'm trying to save the WPLANG field but nothing happens. I get the confirmation message "Site options updated", but the field is still blank. And when I query it with get_locale, it get the default 'en_US'. I've tried entering in: ja_JP 'ja_JP' "ja_JP" ja-JP 'ja-JP' "ja-JP" Thanks in advance!


wp_insert_post() dont post content like i need it :(

my wordpress instalation have a plugin that "probably" use wp_insert_post() to send content to database. works great. but sometime when i edit the POST with the tinyMCE editor, the editor do the some magic! and my content are mutch more clean. so, i need some advice. I dont whant: 1- Click the edit Post 2- click the Visual on tinymce 3- Click Update i whant: 1- wp_insert_post() get 'the_content' and filter it like tinyMCE do. Thank you :) i will wait some good reply from all of you :)


Making %author% the rewrite slug for custom post type causes 404s on non CPTs

This has been driving me absolutely mad. I created a custom post type which I plan to use to create pretty affiliate/redirect links throughout my site. Here is my `register_post_type()`:               register_post_type('redirect', array(       'label' => 'redirects',       'labels' => array(         'name' => 'Redirects',         'singular_name' => 'Redirect',         'add_new' => 'Add Redirect',         'add_new_item' => 'Add New Redirect',         'edit_item' => 'Edit Redirect',         'new_item' => 'New Redirect',         'view_item' => 'View Redirect',         'search_items' => 'Search Redirects',         'not_found' => 'No redirects found',         'not_found_in_trash' => 'No redirects found in Trash'       ),       'description' => 'Redirects',       'public' => true,       'menu_position' => 5,       'supports' => array(         'author',         'title',       ),       'query_var' => true,       'rewrite' => array('slug' => '%author%')     ));      I then added the filter from this answer and flushed my rewrites. All is well with my custom post types, but clicking on any **default post type** results in a 404 error. I've used Monkeyman Rewrite Analyzer but can't really make sense of why I'm encountering this issue. I would really appreciate anyone who can lend their expertise to help sort this out. Thank you!


Menu items description? Custom Walker for wp_nav_menu()

Normal Wordpress Menu looks like: > Home | Blog | About us | Contact But I've seen many pages with descriptions under these links: > Home Page | Our Blogs | About us | Contact   >  ....meet us...| read more| basic info| contact form How to achieve this? (I want it to be core function for all my themes, so no plugins please, I just want to know how it's done)


How do I add the menu item description to the menu?

> **Possible Duplicate:**   >  Menu items description? Custom Walker for wp_nav_menu() I know this question has been asked before, but I haven't quite found the answer I'm looking for. This handy piece of CSS does most of it: .menu-item a:after { content: attr(title); } But I need a line break between the Menu item name and the Description, so that the latter appears underneath the former. How do I do that? Ideally the two would have an alignment option, too... Sorry if this is a dumb question, but I'm new to CSS and I'm struggling! Thanks.


Allow guests to save favourite pages?

We're creating a site where we want guest users to add pages to a favourites list (post IDs), so they can print or email their selection if they want. What would the best way be to do this in WordPress? I think ajax but I'm not too sure how to save it in the WordPress framework.


What's the handle for media.js?

I want to use `wp_enqueue_script` to load `media.js` from frond end. I use Win Grep searching through the whole WP dir, couldn't find which handle this `media.js` was registered. in this `media.js` , there's a function `findpost.open` , that's what I need. Could anybody tell the handle?


Mass convert MySQL data entries into custom post type?

I have a MySQL table with about 500 rows of entries each containing: title, author, series, and series number. Would anyone know how to mass convert the data into (1 entry per post) custom post type with title becoming post title, author and series as separate custom hierarchical taxonomies, and series number as a custom meta? I'm planning to change from a simple MySQL database management system into a site in a WP MS installation.


How to Filter categories in the permalink structure

Using `/%category%/` `%postname%/` for the permalink I get a URL string of all the categories that the specific post is included in. I would like the categories in the url to be filtered down.here it is, I have a celebrity gossip blog and I have this category structure:               www.myblog.com/category_1 › sub category_1 ›sub category_2 > Post_name     ex: www.myblog.com/pics/a to c/Aniana Lema /myPostName      I would like to skip the `"subcategory_1,2"` in the URL,(only display the parent category) ex: `www.myblog.com/pics/myPostName` Is it possible?


How can I assign separate stylesheets to different pages?

I am trying to figure out how to assign a seperate stylesheet for different pages? I wan't to use the same stylesheet for my front page, and page template and a different stylesheet for my blog and it's related pages. My theme only consists of a front page, a page template and a blog. So I would somehow need to figure out how to differentiate from the actual pages. It would need to be applied to all blog pages. So I am wondering if I could do something like this(added to the header):               <?php if ( 'front-page.php' ) { ?>     <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); type="text/css" media="screen" />     <?php } elseif ( 'page.php' ) { ?>     <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>"  type="text/css" media="screen" />     <?php } else { ?>     <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>"  type="text/css" media="screen" />      <?php } ?>      If it is front page or the page template it uses the normal stylesheet. If it is anything else, it uses the blog stylesheet. If it can be done like that, can anyone help me with the syntax?


Unable to get WP_DEBUG, WP_DEBUG_DISPLAY, WP_DEBUG_LOG to work

I've got the proper debugging constants defined in wp-config.php:               define('WP_DEBUG', true);     define('WP_DEBUG_DISPLAY', true);     define('WP_DEBUG_LOG', true);      But they're not doing a darn thing. When I output something to the log file from my plugin (even without testing for `WP_DEBUG === true`) like this nothing happens on-screen and there's no debug.log to be found either:               error_log('test!');      I'm sure that part of the code in the plug is being executed. What gives? I'm using WP 3.6.1. Thanks.


.htaccess rewrite

I have created a custom post type called 'event' and added an event called London 2012. I want the following URL structure for a page:               local.mysite.com/london-2012/speakers      I have created a page called Speakers giving me a working `/speakers` url (I have Permalinks set to 'Post name'). Now I created a static test site and added the following to the .htaccess:               RewriteEngine On     RewriteRule ^([A-Za-z0-9-]+)/speakers?$ /speakers.php [NC,L]      This meant that if I went to `local.testsite.com/something/speakers` it would display the content of speakers.php whilst retaining the orignal URL. Perfect! Or so I thought... Now, having migrated the rule across to my Wordpress install (both by adding the rule in the .htaccess file directly - under the `RewriteEngine on` line - and through the `add_rewrite_rule()` function) I am getting strange behaviour.               RewriteRule ^([A-Za-z0-9-]+)/speakers/?$ /speakers?event=%1 [L]      Instead of the URL remaining the same and showing me the content of `/speakers`, it is actually redirecting me to the /speakers page and the URL is changing. This is default behavior for a page in WP even without any modifications to the .htaccess file so I can only imagine that it is not matching my rule for some reason and then hitting the `RewriteCond %{REQUEST_FILENAME} !-f` line. Either that, or it is matching it but then continuing despite the `[L]` line. Anyway I think that covers everything - if anyone has any ideas I'd really appreciate it as I'm going a bit crazy with this! **Update 1** Sorted - thanks Brian. Your solution did work but because the query variable was called 'event' it was getting confused and sending me to /speakers/ as a redirect. I changed it to simply be 'e' and it's fine now. Thanks again!


Add a tag like a post

For days I'm looking at different threads Stackexchange, but I can not find the solution. I hope you can help me out. I created a post_type called "bands". I'm trying to, from another post_type (eg entries or pages), there is a meta_box as tags that adding a term, we add the post_type called "bands". Is there a way?


How to open particular featured image clicking on desired post using javascript in wordpress?

I have created a custom post type "gallery" and created seven post in it. Since I am using dynamic featured image plugin of wordpress so I assigned two featured images to each post. Then I created new template "gallery_template.php" and I try to call "title", "content" and "featured image" of each post in loop. I used following code in custom template:                <?php       $query = new WP_Query( array('post_type' => 'gallery' ));       if( $query->have_posts() ) {         while( $query->have_posts() ) {          $query->the_post();          ?>

<?php the_title() ?>

                  <?php the_content() ?>                  <?php if( class_exists('Dynamic_Featured_Image') ) {                        global $dynamic_featured_image;                        $featured_images = $dynamic_featured_image->get_featured_images( );                        foreach($featured_images as $image){                              echo '';                        }                  } ?>

      <?php        }       } else {            echo 'No gallery found!';       }      ?>       It is fetching all post content, title and featured image in loop. But I want that when I click on a particular title of post then it should display related content, and featured image using javascript. I have attatched screenshot as I want: ![display content and featured image when click on particular post title](http://i.stack.imgur.com/G8zgN.png)


Custom Search only for my Custom Taxonomy Page - data

First of all, my post is related to : Link 1 and Link 2 I made my custom taxonomy page. My Custom Taxonomy Page link is > //localhost/myproject/?motion=aamir-khan This page is custom taxonomy page ( note : no custom page , only custom taxonomy ) But now there is a new requirement of a custom search page in which only my custom taxonomy data will be searched. For example, if any one search "aamir khan", "salman khan", then after submittion, on my custom search button, the same page should be seen as of my custom taxonomy, not default wordpress search page Hence I added the custom search form below in my header :               <form role="customsearch" method="get" id="customsearchform" action="<?php echo home_url('/'); ?>">     <div>     <label for="s">Search for:</label>     <input type="text" value="" name="motion" id="motion" />     <input type="submit" id="customsearchsubmit" value="Search Motion" />     </div>     </form>      I have placed above custom search button in my header.php Hence, if any one search with "aamir khan", then the custom taxonomy page should be seen, but I am getting > Page not found Why page not found? Because, after searching with my custom search form, the link generated is: > //localhost/myproject/?motion=aamir+khan where, as my custom taxonomy page link generated is: > //localhost/myproject/?motion=aamir-khan The same when any one search for "salman khan" or any other data: > //localhost/myproject/?motion=salman+khan but my actual custom taxonomy link generated is: > //localhost/myproject/?motion=salman-khan In short, if after I've searched, I want my url to be with `-`, not with `+` I want custom search only for my custom taxonomy data page, hence, if url rewriting, then only for custom search form Note: my default search should not be effected , as I want that too in my website, hence, one wordpress default search button, and another my custom search button, which is only for my custom taxonomy page.


Flexslider not working for my custom theme WordPress

I add flexslider to my theme homepage http://templategraphy.com/wp-demo/bluto/ but it didn'not show on my homepage Here is the order of js i placed in function.php               function theme_name_scripts() {              wp_enqueue_style('style-css', get_stylesheet_uri());             wp_enqueue_style('ico-moon.css', get_stylesheet_directory_uri() . '/css/ico-moon.css');            wp_enqueue_style('flexslider.css', get_stylesheet_directory_uri() . '/css/flexslider.css');         wp_enqueue_style('jquery.fancybox-1.3.4.css', get_stylesheet_directory_uri() . '/css/jquery.fancybox-1.3.4.css');         wp_enqueue_script('jquery-1.8.3.min.js', get_stylesheet_directory_uri() . '/js/jquery-1.8.3.min.js');                wp_enqueue_script('jquery-ui-1.10.0.custom.min.js', get_stylesheet_directory_uri() . '/js/jquery-ui-1.10.0.custom.min.js');          wp_enqueue_script('jquery.hoverizr.js', get_stylesheet_directory_uri() . '/js/jquery.hoverizr.js');         wp_enqueue_script('jquery.isotope.min.js', get_stylesheet_directory_uri() . '/js/jquery.isotope.min.js');                wp_enqueue_script('jquery.flexslider-min.js', get_stylesheet_directory_uri() . '/js/jquery.flexslider-min.js');          wp_enqueue_script('jquery.fancybox-1.3.4.pack.js', get_stylesheet_directory_uri() . '/js/jquery.fancybox-1.3.4.pack.js');                wp_enqueue_script('jquery.nicescroll.min.js', get_stylesheet_directory_uri() . '/js/jquery.nicescroll.min.js');           wp_enqueue_script('scripts.js', get_stylesheet_directory_uri() . '/js/scripts.js');                       }     add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );      Please suggest some solution is there any issue regarding my js order or js conflict any suggestion is helpful for me.


Echo custom field value

So I am customizing the [CPT Bootstrap Carousel plugin][1] to fit my needs. I have added custom field support to the custom post type, where the custom field is suppose to add a button on the carousel items. I have been able to register the custom field in the backend and the button is showing up on the Carousel items, but the `href` property is empty. I believe that the problem is in the custom loop or in the way I am using `echo`, but I can´t seam to figure it out. The area where I believe the problem in the code is have been market with `<!--Possible problem-->`. Here is updated, functioning code: /PS: but have a look a phils answer, probably a more stable solution.               <?php     /*     Plugin Name: CPT Bootstrap Carousel     Plugin URI: http://www.tallphil.co.uk/bootstrap-carousel     Description: A custom post type for choosing images and content which outputs Bootstrap Carousel from a shortcode. Requires Bootstrap javascript and CSS to be loaded separately.     Version: 1.1     Author: Phil Ewels     Author URI: http://phil.ewels.co.uk     License: GPLv2     */          // Custom Post Type Setup     add_action( 'init', 'cptbc_post_type' );     function cptbc_post_type() {     $labels = array(         'name' => 'Carousel Images',         'singular_name' => 'Carousel Image',         'add_new' => 'Add New',         'add_new_item' => 'Add New Carousel Image',         'edit_item' => 'Edit Carousel Image',         'new_item' => 'New Carousel Image',         'view_item' => 'View Carousel Image',         'search_items' => 'Search Carousel Images',         'not_found' =>  'No Carousel Image',         'not_found_in_trash' => 'No Carousel Images found in Trash',          'parent_item_colon' => '',         'menu_name' => 'Carousel'     );     $args = array(         'labels' => $labels,         'public' => true,         'exclude_from_search' => true,         'publicly_queryable' => false,         'show_ui' => true,          'show_in_menu' => true,         'query_var' => true,         'rewrite' => true,         'capability_type' => 'page',         'has_archive' => true,          'hierarchical' => false,         'menu_position' => 21,         'supports' => array('title','excerpt','thumbnail', 'page-attributes', 'custom-fields')     );      register_post_type('cptbc', $args);     }               // Add theme support for featured images if not already present     // http://wordpress.stackexchange.com/questions/23839/using-add-theme-support-inside-a-plugin     function cptbc_addFeaturedImageSupport() {     $supportedTypes = get_theme_support( 'post-thumbnails' );     if( $supportedTypes === false )         add_theme_support( 'post-thumbnails', array( 'cptbc' ) );                    elseif( is_array( $supportedTypes ) ) {         $supportedTypes[0][] = 'cptbc';         add_theme_support( 'post-thumbnails', $supportedTypes[0] );     }     }     add_action( 'after_setup_theme', 'cptbc_addFeaturedImageSupport');          // FRONT END          // Shortcode     function cptbc_shortcode($atts, $content = null) {     // Set default shortcode attributes     $defaults = array(         'interval' => '5000',         'showcaption' => 'true',         'showcontrols' => 'true'     );          // Parse incomming $atts into an array and merge it with $defaults     $atts = shortcode_atts($defaults, $atts);          return cptbc_frontend($atts);     }     add_shortcode('image-carousel', 'cptbc_shortcode');          // Display latest WftC     function cptbc_frontend($atts){     $id = rand(0, 999); // use a random ID so that the CSS IDs work with multiple on one page     $args = array( 'post_type' => 'cptbc', 'orderby' => 'menu_order', 'order' => 'ASC');     $loop = new WP_Query( $args );     $images = array();     while ( $loop->have_posts() ) {         $loop->the_post();         if ( '' != get_the_post_thumbnail() ) {             $title = get_the_title();             $content = get_the_excerpt();             $image = get_the_post_thumbnail( get_the_ID(), 'full' );             $link = get_post_custom_values('link');             $images[] = array('title' => $title, 'content' => $content, 'image' => $image, 'link' => $link);         }     }     if(count($images) > 0){         ob_start();         ?>         <div id="cptbc_<?php echo $id; ?>" class="carousel slide">
             <?php foreach ($images as $key => $image) { ?>                 <li data-target="#cptbc_<?php echo $id; ?>" data-slide-to="<?php echo $key; ?>" data-interval="<?php echo $atts['interval']; ?>" <?php echo $key == 0 ? 'class="active"' : ''; ?>>
             <?php } ?>

             <?php foreach ($images as $key => $image) { ?>                 <div class="item <?php echo $key == 0 ? 'active' : ''; ?>">                     <?php echo $image['image']; ?>                     <?php if($atts['showcaption'] === 'true') { ?>

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

<?php echo $image['content']; ?>
                             <?php echo 'Läs mer';?>
                     <?php } ?>
             <?php } ?>
             <?php if($atts['showcontrols'] === 'true') { ?>                 <a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev">‹                 <a class="right carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="next">›             <?php } ?>
     <?php }     $output = ob_get_contents();     ob_end_clean();          // Restore original Post Data     wp_reset_postdata();              return $output;     }          // Call the carousel in javascript, else it won't start scrolling on its own     function cptbc_footer_js() {     ?>          <?php     }     add_action('wp_footer', 'cptbc_footer_js');          ?>


Restrict WordPress to Private

I want to set up a private WordPress site, with only 2 users, all I need is a simple private site functionality, with visitors unable to see anything when trying to login, only being redirected to the login page. RSS should also be blocked. I have found one plugin which does this, but it doesn't seem to be maintained, any others which do the same thing and are maintained? http://wordpress.org/extend/plugins/members-only/


page not updating with database

I have code which updates the database fine, but the page doesn't update correctly! I have to refresh the page a second time for it to update correctly. Here is the code below (`funcitons/admin-website-options`). The most important line is the `<input type="radio" ....` line:               <?php     add_action('admin_menu', 'add_website_menu');          function add_website_menu()     {             add_menu_page( 'website Options', 'website Options', 'administrator', 'website_options', 'echo_website_menu');     }          function echo_website_menu()     {             if(isset($_POST['submit-change-front-story']) )             {                        $new_post_id = intval($_POST['front']);                     global $post;                     $args = array('tag' => 'front-page');                     $posts = get_posts($args);                     function get_ids($post) {                             return $post->ID;                     }                        $posts = array_map("get_ids", $posts);                     untag_posts($posts,'front-page');                     wp_add_post_tags($new_post_id, 'front-page');             }                ?>

Manage Stories
                 <form action="<?php echo $_SERVER['REQUIEST_URI']?>" method="POST" class="story-admin-form">

Front Page Stories
                     <?php query_posts('cat=5'); // all posts with category of "story" ?>
                             <?php while ( have_posts() ) :                                     global $post;                                     $post = array();                                     the_post(); ?>                                     <input type="radio" name="front" value="<? echo the_id(); ?>" <? echo has_tag('front-page', get_the_id()) ? "checked":"" ?>/> <? echo the_title(); ?>
                             <?php endwhile;?>
                             <input name="submit-change-front-story" type="submit" id="submit-front-page-story" value="Change Front Page Story" />
                  </form>
              <?php     }     ?>      Every time I change the front-page story, both of the select options are "checked", but I can view the posts in the admin view and only one of them has the 'front-page' story. (???) And when I refresh the page, then the options have only one selected. Does anyone know what's happening?


Set custom name for generated thumbnails

Is there any filter available to set the naming convention of those auto generated thumbnails? Something like this:   * thumbnail_150x150.jpg -> thumbnail-s.jpg   * thumbnail_300x300.jpg -> thumbnail-m.jpg   * thumbnail_600x600.jpg -> thumbnail-l.jpg


qTranslate and forms

I am developing a bilingual website and I am using qTranslate that works fine for static pages, but for pages such as login, or submit job, etc it does not keep the chosen language and loads on a default language. Any clue about what can i change to keep the language, any function? I found a few people asking for similar help but I could not figure out how to use that help in my case. Thanks Andre


How to hide user posts?

I installed 'User Role Editor' plugin in a student journal site where students can submit their assignments and projects. The problem is if someone creates a new user, by default, posts by other users are also showing up in the posts section. Although with the help of the plugin I have made some changes, new users are not be able to edit or delete the posts submitted by other users. I was wondering if there's a solution to hide posts by other members in the dashboard so that the news users are not able to see the posts.


Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)

I update my permalink structure to /post/%post_id%/%postname%, but if someone uses a URL like /post/1234 instead of the full URL of /post/1234/bingo-rulz, WordPress shows the post without giving a 301 to the full URL. Isn't this poor SEO? Sites like tumblr and stackexchange auto 301 to the full URL. Any hacks/code/plugins/settings/etc to fix this? thanks p.s. /post/1234/blah does get a 301 to /post/1234/bingo-rulz but /post/1234 does not and ends up in two separate URLs to the same content.


Dynamic content in a widget

I have to make a widget from where the user will be able to add a few images and then I will show only some of them, randomly, and it will be automatically changed on page refresh. The problem is that the number of images is not known, it may be 2, it may be 5. I was thinking of using an "add more" jQuery button but I have problems with working on data from an array. Has somebody done something like this before? If you have another idea about doing this, I'd be glad to hear of it. Note: If you have knowledge about a widget which uses this kind of function do not hesitate to tell me, maybe I can get inspiration from there.


WP e-commerce sales-view

I'm helping a client out who's running Wordpress E-commerce 3.8.3 on WP 3.2.1 In the "sales" view, (where it shows all orders), you can see ID Date/Time Name Amount Details Status (Delete) and Track-ID My client wants to view the orderers e-mail and phone too. There are fields for this in the checkout, and the confirmation emails do include this information. But how can I make them show in the Sales-view too? WP E-commerce isn't my strongest side. Thanks for help!


Best Practice: Remove data on deactivation or uninstall?

When is it appropriate to remove a plugin's settings? On deactivation or uninstall?


Wordpress Resize Image and show as thumb in post

I have set crop in functions.php to resize Images for Posts. Codex from Wordpress: add_image_size, post_thumbnail                 add_theme_support('post-thumbnails');       set_post_thumbnail_size(100, 100, true); //size of thumbs       add_image_size( 'post-thumb', 180, 180, true ); //(cropped)      Usage is like below               <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'post-thumb' ); } ?>      But it will not resize the thumb and shows the original size. What am I doing wrong?