title: Allow Editors to edit pending posts but not draft ones

text: I have a large number of users with Editor Capabilities that help to go through the post submissions. This is my current setup for this role: ![Editor Capabilities](http://i.stack.imgur.com/2QA2x.png) As you can see, they are allowed to `edit_posts` and `edit_others_posts` but they cannot `edit_published_posts`. This means that they can edit posts that are in _Draft_ and _Pending_ status. Now, I want to restrict them to **only** be able to edit pending posts. So, they won't have the ability to touch draft posts ( **unless** if they are the author of the post). Unfortunately there is no capability like `edit_pending_posts`... _there should be_. How do I solve this?


title: Cinema site, retrive the movies that actor play in

text: Hy, im building a cinema site in wp... For movies - I am using POST - The movies are post there.. For actors - I am using post_type : persoane , Taxonomy : lista. Ex: In post i add the movie, with title....etc..i'm usig custom field Picture: http://cinema.trancelevel.com/1.jpg For displayng the actors,regizor... i'm using relationship. When i introduce the actor in relationship field, i want automate to get the movie in Actor page... Ex: http://cinema.trancelevel.com/persoane/bruce-willis/ Now the big problem is how can i get the movies in actor page.


title: Is it possible to add taxonomies to user profiles?

text: I would like to know if it's possible to add taxonomies in the user profile, without hacks. So far I have been able to add taxonomies to custom post types and all, but now I would like to add it to the user profile. I know how to add custom fields to the user profile, but so far failed on taxonomies. The closest I got to find a solution was: http://wordpress.org/support/topic/applying-custom-taxonomies-to-user-profiles As a newbie trying to find it there is a better solution. Thank you for reading and helping out.


title: Allow tags between shortcode in comments

text: On my personal blog, I would like commentors to be able to post code using certain shortcodes (eg [html], [css], [js], [php]). I still want to strip tags for comments for security reasons, but allow them between those shortcodes. When I write a test comment, "`[html]<p>sample code</p>[/html]`" becomes "`[html]<p>sample code</p>[/html]`". To get around this, I came up with the following code but I cannot get it to work. Could someone tell me what I am doing wrong? Thanks!               function process_code_tags($comment)     {       $comment = preg_replace_callback('/(\[html\])(.*?)(\[\/html\])/imsu',  create_function('$matches', 'return $matches[0].htmlspecialchars_decode($matches[1]).$matches[2];'), $comment);             return $comment;     }     //add_filter('preprocess_comment', 'process_code_tags');     add_filter('comment_text', 'process_code_tags', 9);


title: Check child/parent categories if exists

text: i am serching a WP function that controls is there any child category/ies of current category (in category.php outside of the loop) and if there is, just add link list for that category/ies to page, otherwise (there is no child category for current) list all post(s) in this category. Thanks in advance...


title: Open posts in editor in the 'Text' mode by default

text: I have a few posts where there are some code segments. When I try to make small edits in the post, it opens in the 'Visual' mode and all the non- alphanumeric characters (e.g. `>`) are converted to their html equivalents (e.g. `>`). Also I lose all the indentation. I would like to open all posts in the 'Text' mode by default. Is it possible to do that?


title: Strange Behavior of Page Template Dropdown

text: My wordpress is updated to latest version 3.4.1 and I noticed a strange function of it - in the Page attributes block page template dropdown has the value:               (.*)\n)siU",$template_contents,$template_name)      ![screnshot](http://i.stack.imgur.com/H4TPS.png) Whay this is happening and how to get rid of that?


title: Fix threaded comments

text: http://anasianscreations.co.cc/jeffman/blog/uncategorized/hello-world/ I have looked all day for a solution but whenever you click on reply to this comment, instead of the comment box being displayed underneath you are redirected to the anchor. Also when I am in this theme, and you reply to a post, it does not register as a reply to a reply, instead it is just a regular reply. There is no doubt that I have missed something, can somebody point me in the right direction?


title: WP 3.1 upgrade breaks AutoFocus+ theme

text: I run WP for my photoblog ShutterScape using the awesome theme AutoFocus+. Recently, I upgraded to 3.1 and now, it refuses to show the featured images in the individual post pages. I am suspecting a jQuery conflict, as the Error Console shows this error.               Error: a.attributes is null      Can someone provide some pointers to fixing this error?


title: Wordpress plugin admin page breaking

text: I am developing one file uploading plugin for my wordpress site to upload posts along with taxonomy and post meta data. Functionality wise it is working fine but when file uploading is finishing after that it is showing my plugin's admin page without any CSS applied basically background is coming in white color and I am not able to see any wordpress admin option and in the end it is saying " **session Expired** ". But when I am going back and trying to access my wordpress admin it is working fine (means session expiration is not happening) **My Research on this issue** I searched for "wordpress whitw screen of death" issue and found that   1. It may memory problem. So I increased my wordpress memory limit to 64M and 256M in both cases it didn't make any difference. define('WP_MEMORY_LIMIT', '256M');   2. It may be extra space issue in my PHP files that also I have done.   3. I put my wordpress in debug mode and fixed all the issues on this page. I am doing ob_clean() after every operation to clean buffer memory. What should i do now? WHat can be the problem?


title: How to force login after user browses for a few minutes or browses a few pages?

text: I want users to be redirected to a custom login/registration page after they've got a taste for the site, by time passing or/and browsing a few pages. I found this code that forces users to login before they can access the site, but im looking for something more specific.               add_action('template_redirect', 'redirect_to_login');          function redirect_to_login(){      if(!is_user_logged_in()){        // user not logged in so redirect them to login page        $redirect_url = '' // you can determine where to redirect user after they login        wp_redirect( wp_login_url($redirect_url), 301 ); exit;      }     }      Thanks a bunch!


title: Choosing between Wordpress responsive frameworks

text: Hi I would like to choose a WordPress Responsive framework to start with on all my client projects. I have shortlisted to Roots and Bones http://www.rootstheme.com/ http://themble.com/bones/ I would like to know what are the main differences between the two, maybe from others who have used them, and any advice as to whether I should choose one over the other. I am also interested in whether it would be good to supplement these with something like Genesis.


title: Alter required message using comment form api

text: I prefer not to use asterisk markers on required fields in the comment form. So I'd like to remove or alter the 'required fields are marked (*)' message. Being a good wordpress user, I'd like to do it with my functions.php. I can work out how to filter most areas of the form, but not this. I'm guessing it will involve modifying the 'comment-notes-before' field of the 'defaults' array, but I can't quite see how to do that.


title: RSS feed widget for specific categories with latest posts?

text: Is there an alternative for default RSS widget? There is one detail that is not working properly. For example if you have more categories you can add default RSS widgets for each categories. They are displayed like this on the sidebar: (RSSIMAGE) (CATEGORY TITLE) (LATEST POSTS) The problem is that CATEGORY TITLE is hyperlinked - but not to the category page but to the HOME page. Any alternative solution to fix this? I tried with the "SPECIFIC CATEGORY RSS WIDGET" plugin but it can't show latest posts like with DEFAULT RSS widget. Best Regards.


title: How to setup a query to output posts by groups of five?

text:
I'd like to have a query that returns posts grouped five by five. Right now I have a simple query loop like this one :               <?php if( $query->have_posts() ) : ?>
             <?php while ( $query->have_posts() ) : $query->the_post(); ?>
                     <?php the_title(); ?>
              <?php endwhile; ?>
     <?php endif; ?>      It outputs :

post 1

post 2

post 3

post 4

post 5

post 6

post 7

post 8

post 9

post 10

      Instead, what I'd like to have is :

post 1

post 2

post 3

post 4

post 5

post 6

post 7

post 8

post 9

post 10

      How can this be done ?


title: How to Add a Sub Menu Page to a Custom Post Type?

text: I am trying to create a link under a custom post type I have named "portfolios". If I change "add_submenu_page" to "add_options_page" it correctly shows a new link under the "Settings" menu. But it won't seem to go in the portfolios menu, what am I doing wrong here?                   add_action('admin_menu', 'mt_add_pages');                   function mt_add_pages() {         add_submenu_page(__('portfolios','menu-test'), __('Test Settings','menu-test'), 'manage_options', 'testsettings', 'mt_settings_page');                   function mt_settings_page() {         echo "<h2>" . __( 'Test Settings', 'menu-test' ) . "</h2>";               }              }


title: Redirect user after logout

text: I am trying to create an unsubscribe page for my members, but in order to see the unsubscribe form, they have to be logged out, so the first link is:               /wp-login.php?action=logout&_wpnonce=ba51bbcdc3.       Once they are logged out, I need them redirected to the unsubscribe form, but I can't just set up a forward, because this is also the login page.


title: Load post shortcode content into fancybox

text: I'm wondering if it's possible to load shortcode content entered into a custom field into a fancybox overlay? And if so, could anyone maybe point me in the right direction as to how I might go about achieving it. I'm actually trying to use the shortcode from the PDF.js viewer plugin


title: Second comments section for one post/page

text: For a project, I need to have 2 comments sections related to the same post/page. Is there a way or a plugin to do that ? By default, Wordpress allow only one comment section for one post/page. Thanks a lot, Cédric


title: Wordpress custom upload field error

text: I'm creating a custom upload field for a wordpress theme that uploads pdf files.The code is:               function custom_news_meta_box($post)     {         $file_name = get_post_meta($post->ID, 'file_name', true);         $pdf = get_post_meta($post->ID, 'pdf', true);              wp_nonce_field('news_meta_nonce', 'news_nonce');         ?>         <p>             <label for="file_name">File Name: </label>             <input type="text" name="file_name" id="file_name" value="<?php echo $file_name; ?>"/>         </p>         <p>             <label for="pdf">PDF: </label>             <input type="file" name="pdf" id="pdf" value="<?php echo $pdf; ?>"/>         </p>     <?php     }          function save_news($post_id)     {         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;              if (!isset($_POST['news_nonce']) || !wp_verify_nonce($_POST['news_nonce'], 'news_meta_nonce')) return;              if (isset($_POST['file_name']) && !empty($_POST['file_name'])) {             update_post_meta($post_id, 'file_name', esc_html($_POST['file_name']));                  if ($_FILES['pdf']['name'] && !$_FILES['pdf']['error']) {                 if (strtolower($_FILES['extension']) != 'pdf') {                     $_SESSION['pdf_error'] = true;                     return;                 }                      if (!file_exists(THEMEROOT . '/downloads/' . $_FILES['pdf']['name'])) {                     move_uploaded_file($_FILES['pdf']['tmp_name'], $_POST['file_name']);                 }                      update_post_meta($post_id, 'pdf', esc_html($_POST['file_name']));             }         }     }      The problem is when i update the page the $_FILES is an empty array.I've tried to add multipart/form-data tag to the form               add_action('post_edit_form_tag', 'add_post_enctype');          function add_post_enctype() {         echo ' enctype="multipart/form-data"';     }      but when i update the page it redirect to post.php.Any solution to my problem?


title: Wordpress Visual Editor Stripping HTML Changes

text: When I use the WordPress HTML editor to add icomoon icons like this:                     and then switch to the visual editor and then back to the HTML editor, the icons disappear. I am trying to include this bit of Javascript to fix this. I looked at wp_enqueue_scripts and put this in functions.php, but it still doesn't fix the problem.               function oakwood_tinymcefix() {         wp_enqueue_script( 'tiny_mce' );         echo '';     }     add_action( 'admin_enqueue_scripts', 'oakwood_tinymcefix' );      How can I fix this?


title: Custom Sidebar only on single post

text:
I am developing a child theme for the new twenty thirteen theme and I am trying to add a sidebar (widget area) next to my content. I only want it to display in `single` posts. What I did: edit single.php (and add it to my child theme's folder) like so:               get_header(); ?>

                      <?php /* The loop */ ?>                 <?php while ( have_posts() ) : the_post(); ?>                          <?php get_template_part( 'content', get_post_format() ); ?>                          <?php get_sidebar('sidebar-3'); ?>                                           <?php twentythirteen_post_nav(); ?>                     <?php comments_template(); ?>                      <?php endwhile; ?>

          <?php get_sidebar(); ?>     <?php get_footer(); ?>      And registered the sidebar in functions.php, like so:               function mobiel_informatie_widgets_init() {         register_sidebar( array(             'name'          => __( 'Sidebar next to content', 'twentythirteen' ),             'id'            => 'sidebar-3',             'description'   => __( 'Wordt naast een single post weergegeven.', 'twentythirteen' ),             'before_widget' => '',             'after_widget'  => '',             'before_title'  => '
',             'after_title'   => '
',         ) );     }     add_action( 'widgets_init', 'mobiel_informatie_widgets_init' );      The thing is that I can see this widget area in Appearance >> widgets, but no matter what I add, nothing ever show in the template. I am guessing I'm doing something wrong with the `name` reference, but the docs aren't really clear on that in my opinion. ## EDIT1: Here are some images to illustrate my problem: _The code of my single.php_ ![The code of my single.php](http://i.stack.imgur.com/e8Wmk.png) * * * _The widget in WP, works fine_ ![The widget in WP, works fine](http://i.stack.imgur.com/V6jvg.png) * * * _The output -- nothing is outputted_. There should be something before the `/END` comment. ![The output -- nothing is outputted](http://i.stack.imgur.com/1Azb6.png) The only thing I can think of why this wouldn't work, is because of a conflict with the parent theme (twenty thirteen). It has twee sidebars, written in functions.php, like this:               /**      * Registers two widget areas.      *      * @since Twenty Thirteen 1.0      *      * @return void      */     function twentythirteen_widgets_init() {         register_sidebar( array(             'name'          => __( 'Main Widget Area', 'twentythirteen' ),             'id'            => 'sidebar-1',             'description'   => __( 'Appears in the footer section of the site.', 'twentythirteen' ),             'before_widget' => '',             'after_widget'  => '',             'before_title'  => '
',             'after_title'   => '
',         ) );              register_sidebar( array(             'name'          => __( 'Secondary Widget Area', 'twentythirteen' ),             'id'            => 'sidebar-2',             'description'   => __( 'Appears on posts and pages in the sidebar.', 'twentythirteen' ),             'before_widget' => '',             'after_widget'  => '',             'before_title'  => '
',             'after_title'   => '
',         ) );     }     add_action( 'widgets_init', 'twentythirteen_widgets_init' );


title: Child Pages and Custom Taxonomies

text:
I have been stressing over this for a while. I have figured out how to call pages in a loop using custom taxonomies. I have also figured out how to call child pages of a parent page in a loop. However, what I would like to do is call the child pages, then filter out the child pages that belong to a custom taxonomy, as to only show these ones. Thanks in advance for any help, I can offer any more information needed, The child page code:               <?php          $child_pages = $wpdb->get_results(         "SELECT * FROM $wpdb->posts WHERE post_parent = $post->ID AND post_type = 'page' ORDER BY menu_order"     );          if ( $child_pages ) :         foreach ( $child_pages as $pageChild ) :             setup_postdata( $pageChild );                  ?>

                         <?php echo get_the_post_thumbnail( $pageChild->ID, 'thumbnail' ) ?>

                                 <a class="comparisontitle" href="<?php echo get_permalink( $pageChild->ID ) ?>" rel="bookmark" title="<?php echo $pageChild->post_title ?>">                                     <?php echo $pageChild->post_title ?>

                                 <?php echo get_the_excerpt() ?>

              <?php endforeach ?>     <?php endif ?>      The custom taxonomy code:               <?php           if ( is_page() ) :         global $post;               $args = array(              'tax_query' => array(                 array(                     'taxonomy' => 'top5',                     'field' => 'name',                     'terms' => $post->post_title                 ),             ),         );              $My_Query = new WP_Query( $args );              if ( $My_Query->have_posts() ) :             while ( $My_Query->have_posts() ) :                 $My_Query->the_post();                 ?>

                                 <?php the_post_thumbnail( 'medium' ) ?>

                                         <a class="comparisontitle" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">                                             <?php the_title(); ?>

                                         <?php the_excerpt() ?>

                  <?php endwhile ?>              <?php wp_reset_postdata() ?>         <?php else : ?>              <?php endif ?>     <?php endif ?>      As far as I am aware I have copied all of the code into here, Sorry this is my first post so not exactly sure how you would like the code, so essentially I would like to combine these two pieces of code! Thanks again!


title: Wordpress multisite with sudomain install

text: I have tried to install wordpress subdomain using wordpress network feature Here I have a domain 'www.mydomain.com' and I have a couple of addon domains For example. 'www.addondomain1.com' Now I'm trying to setup subdomain 'www.test.addondomain1.com' here I did it using this The subdomain is working, but I have a few queries. 1) When I log in to my www.mydomain.com, it shows network in the dashboard. I am not getting it why it shows here 2) When I log in to www.addondomain1.com here, it shows primary domain as www.mydomain.com instead of www.addondomain1.com. Is it because of addon domain? 3) What is the use of blogs.dir here? Does the subdomain folder goes here?


title: Using WP functions inside javascript

text: I'm trying to use PHP variables inside a javascript function. What's a proper way to use a WP function like `get_current_user_id()` inside a script that get's enqueued via `wp_enqueue_script`? Right now I get this error > Error:Call to undefined function... **myscript.php**               <?php header('Content-Type', 'text/javascript');     ?>       jQuery(document).ready(function(){                   jQuery("#location option").each(function () {                  if (jQuery.inArray(jQuery(this).val(), locs) != -1) {                      jQuery(this).prop('selected', true);                  };              });                   if ( typeof jQuery.fn.chosen !== 'undefined' ){                   <?php               $userID=get_current_user_id();                 if($userID=='3') {                   $max=6;              } else {                 $max=3;              }              ?>              jQuery("#location").chosen({ max_selected_options: "<?php echo $max; ?>"                    });                 }               jQuery('select').each(function(index) {                 jQuery(this).chosen({                     disable_search_threshold: 1                 });             })              });      in functions.php:               add_action('wp_enqueue_scripts','wordpress_scripts');     function wordpress_scripts() {         wp_register_script( 'chosen', get_template_directory_uri() . '/assets/libraries/chosen/chosen.jquery.min.js', array( 'jquery' ),'',true);         wp_enqueue_script( 'chosen' );              wp_register_script('myscript', get_template_directory_uri().'/assets/js/myscript.php', array('jquery'),'',true);         wp_enqueue_script('myscript');     }      Any suggestions to make this work?


title: get_categories exclusion issues

text: In the script below i'm trying to pass category IDs to exclude, however, the category list still includes children of these categories and i can't figure what's wrong. Can anyone see what I could be doing wrong in this script?               $cat_args = get_option('show_empty_cats') ? 'exclude='.ce4_cat().'&exclude_tree='.ce4_cat().'&hide_empty=0' : 'exclude='.ce4_cat().'&exclude_tree='.ce4_cat().'';$categories=get_categories($cat_args);          //$cat_args = 'exclude=1,31&exclude_tree=1,31&hide_empty=0';     $categories = get_categories($cat_args);     for each..., etc


title: How to disable buddypress top mini adminbar

text: I am having trouble with adminbar in my site. I have buddypress installed on my site. i have disabled wordpress default admin bar using few lines of code. But it still showing i am pretty sure its coming from buddypress. is there any simeple lines of code that can remove top admin bar? I don't want to use plugin. Thanks in advance for help.


title: Problem with get_post_meta

text: I am using this code to retrieve post meta:               <?php if( get_post_meta($post->ID,'a',true) == ''){                             echo '';                         }else{                             echo get_post_meta($post->ID,'a',true);                          } ?>      My first block of if statement is always executing no matter whether the mete box text field is empty or not and else block is not executing in any case. I want to know if there is any flaw in this code or               echo get_post_meta($post->ID,'a',true)      is not a valid code. Your help will be highly appreciated.


title: Remove Content after <!--more-> tags

text: Here with the structure of content in text editor               Content Before          <!--more->          Content After      I wanted to remove the "Content Before" in my single post so instead I have this               Content Before     Content After      I will have the "Content After" on my single post only               Content After      How can I achieve this display?


title: Getting notices on fresh 3.6.1 install

text: I'm a relative newcomer to WP. I've been playing around for the past 3 months or so trying out themes, plugins etc. About a month ago I got to the point where I turned debug on and I started seeing error message and notices in my dashboard. So research suggested that at least some of these my have been the result of disabled plugins that didn't clean up after themselves. I'm at the point where I'm going to get serious about building a site so I blew away my install. Cleared my browser cache and cookies. Used phpmyadmin to recreate the database. Uploaded a fresh version of WP 3.6.1. Recreated the wp- config file. Logged in and I still see the following in the recent comments section: > Notice: Trying to get property of non-object in > /usr/home/mysitename/public_html/wp-includes/capabilities.php on line 1120 > > Notice: Trying to get property of non-object in > /usr/home/mysitename/public_html/wp-includes/capabilities.php on line 1124 > > Notice: Trying to get property of non-object in > /usr/home/mysitename/public_html/wp-includes/capabilities.php on line 1126 > > Notice: Trying to get property of non-object in > /usr/home/mysitename/public_html/wp-includes/capabilities.php on line 1127 > > Notice: Trying to get property of non-object in > /usr/home/mysitename/public_html/wp-includes/capabilities.php on line 1127 > > Notice: Trying to get property of non-object in > /usr/home/mysitename/public_html/wp-includes/capabilities.php on line 1130 > > Notice: Trying to get property of non-object in > /usr/home/mysitename/public_html/wp-includes/capabilities.php on line 1130 Can anyone help make this go away? What am I missing?


title: Blogroll - Different layout for first post

text: I would like to have my main blogroll show 10 posts per page, but the first post of each page to be setup on a different div above the rest and have a featured image. This is what I sued for the first post of the page:               // WP_Query arguments     $args = array (         'pagination'             => true,         'paged'                  => $paged,         'posts_per_page'         => '10',         'ignore_sticky_posts'    => true,         'order'                  => 'DESC',         'orderby'                => 'date',     );          // The Query     $query = new WP_Query( $args );          // The Loop     if ( $query->have_posts() ) {             $query->the_post();                     the_title();             the_content();         }      ?>      and this was for the second:               <?php          // WP_Query arguments     $args = array (         'pagination'             => true,         'paged'                  => $paged,         'posts_per_page'         => '9',         'offset'                 => '1',         'ignore_sticky_posts'    => true,         'order'                  => 'DESC',         'orderby'                => 'date',     );          // The Query     $query1 = new WP_Query( $args );          // The Loop     if ( $query1->have_posts() ) {         while ( $query1->have_posts() ) {             $query1->the_post();             the_title();             the_content();         }     }          // Restore original Post Data     wp_reset_postdata();          ?>      The first post changes when I page but the other 9 posts dont ever change even though they are getting the same paged arg as the first one. Also I am up for any alternative ways you might have to achieve this. I saw a post that talked about altering the first post with a variable to mark the first time the loop ran but that doesnt help me because the first post needs to be out of the normal loop and in its own section. Thank you ahead of time for any assistance you can give!


title: What shortcode should I use for <gcse:searchresults-only></gcse:searchresults-only>

text: I have the same issue as the question posted here : Is there a way to stop WP editor deleting <gcse:searchbox- only></gcse:searchbox-only> I have created a custom-function.php file where I put the shortcode required. It works for the search box. However, I would now like to do the same for the searchresults code `gcse:searchresults-only</gcse:searchresults-only>`. I tried editing the shortcode above but that doesn't work. What I want is have the search results appear in the same page as the search box, not in a separate one which the current shortcode does. Any suggestions to make this work?


title: I have over 4000 posts, will querying some of them cause performance issues?

text: I am wondering if querying posts like this:                   <?php $args = array('numberposts' => 19, 'orderby' => 'rand' );          $posts = get_posts( $args );         foreach($posts as $post) {               $url = get_the_title($post->ID);                     echo ''.$image_url.'';                     echo ''.$post->ID.'';           }          ?>      will cause any performance issues if I have over 4000 posts? I am not sure how the query works, but I imagine that it works by retrieving all 4000 posts, sorting them all into random positions and then lastly picks the first 19. It sounds kinda heavy hence my question. P.S. _4000+ posts might sound a lot, but they are actually just link posts with empty content and href's in the title._ **EDIT:** Final code from the answer (untested)               <?php            $randposts = $wpdb->get_results(           "          SELECT SQL_CALC_FOUND_ROWS wp_posts.*          FROM wp_posts           WHERE 1=1               AND wp_posts.post_type = 'post'               AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')          ORDER BY RAND() DESC           LIMIT 0, 19          "      );           foreach($randposts as $post) {            $url = get_the_title($post->ID);          echo ''.$image_url.'';          echo ''.$post->ID.'';        }       ?>


title: Sort wp post title with alphabetically and numerically?

text: Is there any possible way to sort a new Wordpress post query by the title, but numerically instead of alphabetically? I have some titles that have a lot of the same name alphabetically, then have a number afterwards, so of course for example Wordpress is putting `title12` ahead of `title1`.               $args = array( 'orderby'=> 'title', 'order' => 'ASC', ); $loop = new WP_Query( $args );      I know we have this functionality to sort titles in ascending order but it does not sort titles like that:- Title 1 Title 2 Please let me know if we any work around using wp query ? Thanks for your help in advance :)


title: Woocommerce Category hierarchy

text: I am building a store with different brands. I want the flow to go Store > (Brand) > (Gender) > Product. I know I could set each brand as a product category and then create Gender as a subcategory for each brand. That seems a bit much though. Is there a way I can create a custom taxonomy for Gender, create each one (Man, Woman) once, and then link that so it will always show up after brand? I just think it's too redundant to create Genders for every single Brand category and it seems like there should be a way so you only do it once.


title: Site showing dates incorrectly, and I cant find news feed source

text: I recently inherited a wordpress webpage. There is an issue with the news feed: ![enter image description here](http://i.stack.imgur.com/G8jTD.png) As you can see, as opposed to posting the date correctly, it seems to be sending the format the date is supposed to be in to the browser. I checked general settings and edited the date settings to no avail. I can't find where to manulate this page at all however. It's quite strange. The Url is: abc.com/category/recent-news/ There is no plugin related to this. I diabled all of them and it still works. There is no page with this content on it. Also, there are no widgets enabled on the site. I've looked everywhere and I don't know how this page is generated. Any help would be appreciated.


title: Page template query with WP_Query

text: I'd like to query only pages with a certain page template with WP_Query or a function that would return the post object, but I can't find any information about that on the officiel codex.


title: Function that returns all pages that uses a specific page template?

text: Is there a function that gets me all pages that uses a specific page template? Something like this maybe:               get_posts( array("type"=>"page", "page_template"=>"my-template.php") );


title: If the image variable is specified, show image, if not no code

text: This should be simple, and yet everything I'm trying blows the blog up. I want to be able to specify an image variable in a custom field (that works great) but if that's not specified, don't include the image code. It's creating a image missing error in some browsers (IE). Any ideas? Thanks, Bob


title: Post ids are incrementing by an unknown number?

text: It's really strange, but I've noticed that as I'm writing and publishing posts, the ids aren't incrementing by one, but rather by some arbitrary amount which I think is relative to the amount of times I hit preview. It's kind of annoying to have ids like 1, 11, 29, 37, etc. Is there a way to ensure that posts only increment by one?


title: Wordpress User Frontend Editing Custom Fields

text:
I'm using the plugin `Wordpress User Frontend` and editing the title and content of a post is nice (I managed to change it so I can edit custom post types), but there's no support for editing custom fields. So I have the following code below (not sure if it's too long to have to put on pastebin):               function wpuf_validate_post_edit_submit() {         global $userdata;              $errors = array();              $title      = trim($_POST['wpuf_post_title']);         $content    = trim($_POST['wpuf_post_content']);         $tags       = wpuf_clean_tags($_POST['wpuf_post_tags']);         $cat        = trim($_POST['cat']);         $post_location  = trim($_POST['wpuf_post_location']);         echo $post_location;              if (empty($title)) {             $errors[] = "Empty post title";         } else {             $title = trim(strip_tags($title));         }              if (empty($content)) {             $errors[] = "Empty post content";         } else {             $content = trim($content);         }              if (!empty($tags)) {             $tags = explode(',', $tags);         }              if (!$errors) {             $post_update = array(                     'ID'            => trim($_POST['post_id']),                     'post_title'    => $title,                     'post_content'  => $content,                     'post_category' => array($cat),                     'tags_input'    => $tags             );             $post_cf = update_post_meta($post->ID,'location',$post_location);             $post_id = wp_update_post($post_update);             //var_dump($post_update);                  if ($post_id && $post_cf) {                 echo '
Post updated succesfully.
';             }              } else {             echo wpuf_error_msg($errors);         }     }      `$post_cf` should update the location field that is grabbed from the top of the code (`$post_location`). Upon echoing the field, it echo's the updated field, but when saving the post (`$post_id`?) and refreshing the page, the custom field stays the same? Does anyone know what's going on? I've been at this for over an hour now.


title: Display a post attachment depending on the caption

text: I would like to display automatically a post attachment (PDF) depending on the language of my blog (french and english). When the post is displaying in french version, I would like display the french PDF, and when the post is displaying in english, the english one. I use the qtranslate plugin and I though to use the caption of the attachment ("fr" or "en") to create a sort of conditional tag. I tried the code below but it does'nt work. Do you have any idea to help me? Many thanks in advance, Dem.                    <?php if(qtrans_getLanguage()=='en'): ?>         <?php             if ( $attachments = get_children( array(                 'post_type' => 'attachment',                 'post_mime_type' => array('application/doc','application/pdf','application/msword'),                 'numberposts' => 1,                 'post_status' => null,                 'post_parent' => $post->ID,                 ))) ;                 foreach ($attachments as $attachment) {                 if ($attachment->post_excerpt == 'en') {                     echo 'ID ) . '">';                     echo '';                 }                 }         ?>     <?php endif; ?>          <?php if(qtrans_getLanguage()=='fr'): ?>         <?php             if ( $attachments = get_children( array(                 'post_type' => 'attachment',                 'post_mime_type' => array('application/doc','application/pdf','application/msword'),                 'numberposts' => 1,                 'post_status' => null,                 'post_parent' => $post->ID,                 ))) ;                 foreach ($attachments as $attachment) {                 if ($attachment->post_excerpt == 'fr') {                     echo 'ID ) . '">';                     echo '';                 }                 }         ?>     <?php endif; ?>


title: Put a wp_nav_menu inside another one

text: I've got two wp_nav_menu's defined - main and sub. The backend menu editor lets me add pages or categories or custom links to my menu, and I can place them under existing pages/categories/links. However, I want to add my sub pages to the sub menu, and then be able to add that sub menu as a whole item to my main menu. That way, if I change up what's in my sub menu, I don't also have to go change my main menu too, see what I mean. Nice and DRY. Useful if I have my submenu in multiple places (like as a drop down from the main menu, plus on a detail page in the sidebar.) Is this possible? Is there a plug in or custom function? Thanks.


title: How can I alter this code to accept a slug as well as an ID?

text: This code is from the codex.               /* ==  If In Parent Category... ==============================*/          if ( ! function_exists( 'post_is_in_descendant_category' ) ) {         function post_is_in_descendant_category( $cats, $_post = null ) {             foreach ( (array) $cats as $cat ) {                 // get_term_children() accepts integer ID only                 $descendants = get_term_children( (int) $cat, 'category' );                 if ( $descendants && in_category( $descendants, $_post ) )                     return true;             }             return false;         }     }      I use it in the theme like this: `if ( post_is_in_descendant_category( 11 ) ) ...` It only accepts the post ID (`11`), however, and I'd like it to accept the slug. Is there a way to alter this code somehow to accept the slug?


title: Exclude Custom Taxonomies

text: I'm trying to display recent posts from regular posts section and custom post types, excluding one custom taxonomy term from each custom post type. But the recent posts section doesn't show anything.                  <?php          // the query         $the_query = new WP_Query(          array(         'post_type' => array( 'post', 'miss_behave', 'emily_davies','gemma_patel','poppy_smythe' ),         'category__not_in' => 4,         'tax_query'          => array(         'taxonomy' => array('miss_behave_category','emily_category','gemma_category','poppy_category'),         'terms' => array(141,142,143,144),               'field' => 'id',         'operator' => 'NOT IN'              )             )         );?>


title: Selling a child-theme of twenty-thirteen is legal?

text: I built a child-theme based on twenty-thirteen theme, the basic ones that comes bulit-in wordpress. Can I sell it now on codecanyon and make a profit from the child-theme i built and developed? is it legal? Thanks in advance :)


title: Upload images with comment

text: EDIT: I finally got the right answer; see my own answer beneath this post for everyone that's interested. After searching for a couple of days and trying over and over again I really got stuck. I've a client who collects customer experiences on his website by using the comment form; all comments are displayed as a customer review. So far so good. But since it's company does a lot with traveling, he needs to give his customers to upload up to five images with there review. So what I need to do is find a way to let customers upload media along with there filled in comment form. I do know it's kind of risky, since there could be corrupt images uploaded and so on. But still, I would like to achieve it. Tried a lot a things but the point where I get stuck over and over again is the file upload handling, for a non-logged-in user which is posted with a comment form... Any thoughts will be very appreciated!


title: Random taxonomy category list

text:
I'm trying to display one of my custom taxonomy lists on a page. I want to show five but have them in different random orders when the page is refreshed. I've tried using shuffle, but it just shuffles the first 5 and you dont see any of the the others. I tried `orderby RAND` but it doesnt work. This is my code so far.               <?php     $all_artists = get_terms( 'artists', array(     "number" => 5,                                'hide_empty' => 1,     'exclude' => array($cat->term_id),                           ) );                    shuffle( $all_artists );     foreach ($all_artists as $cat) :?>
     <a href="<?php echo get_term_link($cat->slug, 'directors'); ?>">
          <img src="<?php echo z_taxonomy_image_url($cat->term_id, 'poster'); ?>" />

 <?php echo $cat->name; ?>

                <?php endforeach; ?>


title: Why doesn't WP update my .htaccess file?

text: Before I begin, I do _not_ have WordPress having permissions to update the `.htaccess` file. That's not what this is about. I'm full aware of that. My problem is WP generates the same file every time for me to copy to my `.htaccess` file. With default permissions: ("Post Name" setting:)               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /wordpress/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /wordpress/index.php [L]     </IfModule>      RewriteEngine On RewriteBase /wordpress/ RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wordpress/index.php [L] ("Numeric" setting:)               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /wordpress/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /wordpress/index.php [L]     </IfModule>      **_Same exact thing._** That setup works perfectly when the "default" setting is used, but it's not working now. I've tried copying it before and after I save the changes, but it's still the same. Why isn't this working? I believe this is the right file setup (I access it with `xxx.xxx.xxx.xxx/wordpress/`)... `/var/www/html/wordpress$ sudo nano .htaccess`


title: Default Custom Field User Data

text: I want to create a user meta that would either add or update In the user meta there are two custom field 'projects' and 'amount' so if user donated $1 to project A the user meta will create a row, same column **under Project** project A **Under Amount** 1 if the user donated again to the same project, it will just update the amount but if the user selected another project it will create another row for that project


title: How to get post or page excerpt using post_excerpt

text: I am using the following `foreach` loop:               $pages = get_pages(array ('post_type' => 'page','sort_column' => 'menu_order',));        foreach ($pages as $page) {          $apage = $page->post_name;          if ( $apage =='about') {                  echo apply_filters('the_content', $page->post_content)             } // if about page        } // foreach      I would like to be able to get the excerpt of the page or post instead of the whole content by using                $post->post_excerpt      Is this possible?


title: Move pagination numbers above plug-ins

text: I'm having the following problem: ![](http://i.stack.imgur.com/yFThq.png) I want to move the generated page numbers from `<!--nextpage-->` to appear below the post body, above the plugins (WordPress Related Posts, WP Author Box Lite & JetPack Share). Looking at `single.php`, `wp_link_pages()` comes right after `the_content()`. Are these plug-ins adding their content to `the_content()`? The documentation seems to give some alternative usage. Is this the only solution or is there a plug-in that will help with this problem? I'm using the BoldR Lite theme.


title: Pulling Total Count or all post ID's

text:
The following code displays the amount of supporters each of my authors has with my wordpress site. I am trying to display the total supporters on the home page for the whole entire website. I haven't had any luck.
<?php echo countSupportForcampaignAll($post->ID); ?>


title: Add management screens to post type

text: I am looking to build a theme that has an integrated resume, using custom post types. I have had a look at this question with regards to inserting post types within post types in the admin menu. The structure that I am planning is: Resume   * View Employment   * Add Employment   * View Qualifications   * Add Qualification   * View Memberships   * Add Membership   * Options How would I insert links to the appropriate post management screen in the menu? **[EDIT]** I have tried to create this in my local site, and have noticed that the menu only displays the post management page, not the editor (the opposite of what I assumed). I would like both to be displayed. Is this possible?


title: Modify search to display authors

text: I have been looking around the web but could not find a solution to this problem. Right now the search function in Wordpress - as I understand it - goes through the posts and looks for matching words. That is fine, however I am working on a site right now where I wont have many posts / any posts. I will however have a lot of users - let's call them authors even though they won't be writing anything. I want the normal search to go through the author pages and display results based on what is written there. Is this possible? I do understand a bit of code but mostly copy of tutorials. Thank you so much in advance!


title: Importing data from database to WP_list_table

text: How can I import data from a table where Ive got : ID, Name, LastName, Adress and class and by the way, how do I create this plug-in? Any examples?


title: Why is wp-login trying to send an email?

text: My host sent me the following message: > Below are the recently upload scripts that contain code to send email. You > may wish to inspect them to ensure they are not sending out SPAM. > > /home/swthief/public_html/wp-login.php:392: if ( $message && !wp_mail( > $user_email, wp_specialchars_decode( $title ), $message ) ) > /home/swthief/public_html/wp-login.php:393: wp_die( __('The e-mail could not > be sent.') . "   > \n" . __('Possible reason: your host may have disabled the mail() > function.') ); /home/swthief/public_html/wp-login.php:394: > > /home/swthief/public_html/wp-includes/class-smtp.php:612: */ > /home/swthief/public_html/wp-includes/class-smtp.php:613: public function > mail($from) /home/swthief/public_html/wp-includes/class-smtp.php:614: { > > /home/swthief/public_html/wp-includes/pluggable.php:434: > /home/swthief/public_html/wp-includes/pluggable.php:435: // Set to use PHP's > mail() /home/swthief/public_html/wp-includes/pluggable.php:436:   >  $phpmailer->IsMail(); > > /home/swthief/public_html/wp-includes/class-phpmailer.php:172: */ > /home/swthief/public_html/wp-includes/class-phpmailer.php:173:   >  public $Sendmail = '/usr/sbin/sendmail'; /home/swthief/public_html/wp- > includes/class-phpmailer.php:174: > > /home/swthief/public_html/wp-includes/class-phpmailer.php:175: /** > /home/swthief/public_html/wp-includes/class-phpmailer.php:176: * Whether > mail() uses a fully sendmail-compatible MTA. /home/swthief/public_html/wp- > includes/class-phpmailer.php:177: * One which supports sendmail's "-oi -f" > options. > > /home/swthief/public_html/wp-includes/class-phpmailer.php:585: /** > /home/swthief/public_html/wp-includes/class-phpmailer.php:586: * Call mail() > in a safe_mode-aware fashion. /home/swthief/public_html/wp-includes/class- > phpmailer.php:587: * Also, unless sendmail_path points to sendmail (or > something that > > /home/swthief/public_html/wp-includes/class-phpmailer.php:658: /** > /home/swthief/public_html/wp-includes/class-phpmailer.php:659: * Send > messages using PHP's mail() function. /home/swthief/public_html/wp- > includes/class-phpmailer.php:660: * @return void > > /home/swthief/public_html/wp-includes/class-phpmailer.php:962: > /home/swthief/public_html/wp-includes/class-phpmailer.php:963:   >  // To capture the complete message when using mail(), create > /home/swthief/public_html/wp-includes/class-phpmailer.php:964:   >  // an extra header list which createHeader() doesn't fold in > > /home/swthief/public_html/wp-includes/class-phpmailer.php:1081:   >  /** /home/swthief/public_html/wp-includes/class-phpmailer.php:1082:   >  * Send mail using the PHP mail() function. /home/swthief/public_html/wp- > includes/class-phpmailer.php:1083: * @param string $header The message > headers > > /home/swthief/public_html/wp-includes/class-phpmailer.php:1587: > /home/swthief/public_html/wp-includes/class-phpmailer.php:1588:   >  // To be created automatically by mail() /home/swthief/public_html/wp- > includes/class-phpmailer.php:1589:   >  if ($this->Mailer != 'mail') { > > /home/swthief/public_html/wp-includes/class-phpmailer.php:1604: > /home/swthief/public_html/wp-includes/class-phpmailer.php:1605:   >  // sendmail and mail() extract Cc from the header before sending > /home/swthief/public_html/wp-includes/class-phpmailer.php:1606:   >  if (count($this->cc) > 0) { > > /home/swthief/public_html/wp-includes/class-phpmailer.php:1609: > /home/swthief/public_html/wp-includes/class-phpmailer.php:1610:   >  // sendmail and mail() extract Bcc from the header before sending > /home/swthief/public_html/wp-includes/class-phpmailer.php:1611:   >  if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && > (count($this->bcc) > 0)) { > > /home/swthief/public_html/wp-includes/class-phpmailer.php:1618: > /home/swthief/public_html/wp-includes/class-phpmailer.php:1619:   >  // mail() sets the subject itself /home/swthief/public_html/wp- > includes/class-phpmailer.php:1620:   >  if ($this->Mailer != 'mail') { I am not a programmer, but it appears that wp-login is trying to send an email. This puzzles me. Is that truly what is going on here? And why is Wordpress trying to send an email? I have the Jetpack plugin installed (I saw the later the pluggable directory is referenced) so I wondered if someone tried to use the "email share" button on a post and this was the result. Obviously I want to make sure wordpress is not being hijacked to send spam. I did just reinstall wordpress from scratch yesterday on a new DB, new users, and new passwords. Any help would be much appreciated. Thank you!


title: Why does enabling Permalinks make pages not found?

text: I'm new to Wordpress and am creating a site using v3.9.1 of WordPress. When I create a new page, I can see it in edit mode, but the URL it is supposedly creating is not found when permalinks is used, but visible when permalinks is disabled. For example, if I try to create a page called `photos` right below the top level, the editor states the page will be visible at `http://example.com/photos/` when permalinks is `Post name`, but navigating to such page gives the error: > Not Found > > The requested URL /photos/ was not found on this server. But if I put Permalinks back to `Default` then it becomes visible at `http://example.com/?page_id=4`.


title: Dynamic CSS through PHP issue

text:
I am trying to create a dynamic style.php stylesheet. The most basic function I am testing is a color picker on my theme-options. The color picker works, but my dynamic css file does not. On Chrome I am receiving a 'Illegal string offset' error when I inspect the nav element. I can confirm that it is recognizing and echoing the string, but not the value. My dynamic css file:               <?php       $absolute_path = explode('wp-content', $_SERVER['SCRIPT_FILENAME']);       $wp_load = $absolute_path[0] . 'wp-load.php';       require_once($wp_load);            $novus_nav_color = get_option('novus_nav_color');            header('Content-type: text/css');       header('Cache-control: must-revalidate');     ?>          .contain-to-grid .top-bar {       background-color: <?php echo $novus_nav_color{'novus_nav_color'} ?>;     }      I am using Foundation 5 stock css. Site can be found here Can anyone direct me on what I am doing wrong? Full error string is below:               .contain-to-grid .top-bar {     background-color:
 Warning: Illegal string offset 'novus_nav_color' in     /home/flannelbeard/public_html/novus-theme/wp-content/themes/project.novus.theme/css/dynamic.style.php on line 13
 #;     }


title: Syntax error when I try to insert my loop into an unordered list?

text: I am very new in PHP and WordPress development and I have the following problem trying to insert some HTML code into the posts loop. I tried something like it:               <?php     if (have_posts()) :         <ul>         // Start the Loop.         while (have_posts()) : the_post();                  /*              * Include the post format-specific template for the content. If you want to              * use this in a child theme, then include a file called called content-___.php              * (where ___ is the post format) and that will be used instead.              */                  <li>             get_template_part('contentArchive', get_post_format());             </li>              endwhile;         </ul>                   endwhile;     ?>      As you can see I want an unordered list (the `< ul>`tag) and into it I want put the one list element (the `< li>` tag) for each iteration of the `while` cycle, but Aptana Studio give me a syntax error message on the `<ul>` and on the `<li>` Why? Where is the problem? How can I fix it? Tnx


title: WPAlchemy - Multiple TinyMCE editor blank (can't add text)

text:
Setup a basic WPAlchemy repeater field with a TinyMCE textbox inside. If repeated I am unable to select the new textbox and add text. If I remove TinyMCE it works fine however. Please help. functions.php:               // Tiny mce metaboxes     add_action('admin_print_footer_scripts','admin_print_footer_scripts',99);     function admin_print_footer_scripts()     {         ?><?php     }       metabox_template.php:
          <?php global $wpalchemy_media_access; ?>
Awards
                      <?php while($mb->have_fields_and_multi('awards2')): ?>                 <?php $mb->the_group_open(); ?>
Award
                               Awards Year:
                      <?php $mb->the_field('award-year2'); ?>                     <input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>" placeholder="2000" style="width:150px !important;" />                               Award Content:
                     <?php $mb->the_field('award-content2'); ?>                     <textarea style="width:100%;height: 50px;" class="temp_options_desc" name="<?php $mb->the_name(); ?>"><?php echo wp_richedit_pre($mb->get_the_value()); ?></textarea>                             X                           <?php $mb->the_group_close(); ?>                 <?php endwhile; ?>
Remove All Add Award


title: get_the_term_list give me a whitespace

text: I'm using this code to get my term list, It works fine, but it also give me a white space before my TERM name, Any thoughts?               <?php $terms_as_text = strip_tags( get_the_term_list( $wp_query->post->ID,'genre','',',',''));     echo $terms_as_text; ?>


title: wp_enqueue_script() not working

text:
I'm trying to add this social-network button:               Add in Svejo           to my blog posts. But loading this in every post would really slow my page so I've try to implement it with **wp_enqueue_script()** inside my **functions.php**               function socialNetworks(){         $opentag = '
';         $closetag = '
';              $socials['svejonet'] =             'Add in Svejo'.             wp_enqueue_script( 'none', 'http://svejo.net/javascripts/svejo-button.js', array(), false, true);              echo $opentag;         foreach ( $socials as $key=>$val ){            echo '
'.$val.'
';         }         echo $closetag;        }      However the script does not load.   Appreciate any help BR, Stephan


title: How to edit products page of wp ecommerce plugin?

text: The one problem that is always finds me again is that I cant find particular pages. Lets say I created a product from the admin panel. I have a link to the page, but now I need to edit the look of that page. Where I can find this page physicaly?


title: Taxonomies: display hierarchical parent list

text: I've been using WP for years, but this is my first time with taxonomies, so I need a little bit of help. Like in the question How to show a hierarchical terms list? I have a taxonomy called `places`, which contains a hierarchical list of places (first level for countries, second level for cities, etc...). A post can have an associated place: for example, we could take Berlin (child of Germany, child of Europe). Now, the output I want is something like this: Where: Berlin, Germany, Europe. I've tried some solutions, but none works. I'm pretty sure that there must be a simple and clean solution...


title: Complicated image name like flickr does and deny access just to original image

text: If I upload a given image like my-image.jpg, then following image resizes occurs: > http://www.mysite.com/wp-content/uploads/YEAR/MONTH/my-image-100x100.jpg > http://www.mysite.com/wp-content/uploads/YEAR/MONTH/my-image-200x150.jpg > http://www.mysite.com/wp-content/uploads/YEAR/MONTH/my-image-500x300.jpg also the original image is uploaded: > http://www.mysite.com/wp-content/uploads/YEAR/MONTH/my-image.jpg I have two question about which actions try to: # 1 Question Rename image name to a complicated long name like 5702703214_85bfb55948.jpg:               http://www.mysite.com/wp-content/uploads/YEAR/MONTH/5702703214_85bfb55948.jpg          http://www.mysite.com/wp-content/uploads/YEAR/MONTH/5702703214_85bfb55948-100x100.jpg     http://www.mysite.com/wp-content/uploads/YEAR/MONTH/5702703214_85bfb55948-200x150.jpg     http://www.mysite.com/wp-content/uploads/YEAR/MONTH/5702703214_85bfb55948-500x300.jpg      # 2 Question Avoid access to original image uploaded, let access to thumb, medium and large, but deny access just only to the original image uploaded? Thanks in advance


title: Front-end Image Upload with Preview - Is this Possible in WP?

text: I created a front-end form and have several image upload fields. I was able to create a post and have the images attached. But what I would like to do is have the user see a preview of the image they are about to upload before submitting the Post. I've read quite a few alternatives, Uploadify, Valums.com http://valums.com/ajax-upload, SWFupload and a few others I can't remember. But the problem with all of them is that once i implement them in the form, the images are no longer attached to the post, but only uploaded to the server. Any suggestion or code sample I can use to do this? I have scoured the net for an answer - perhaps it's just not possible in WP to preview an image and also attach it to a post in one form?


title: How to replace default rotating header images with my own

text: I'm using a child theme of twentyeleven, and I'd like to replace the default 8 images with my own - and have them rotate as the default images do with the twentyeleven theme. Some have recommended simply replacing the default images with my own. My concern about replacing the default images with the new ones in the twentyeleven/images/headers/ directory is that, if/when I were to update the twentyeleven theme, my custom images would be replaced with the defaults. Also, the twentyeleven_setup() function includes a section that registers the default headers. a) Am I right about the overwriting issue if/when I update twentyeleven? b) If so, I'd like to know how to designate a different directory (e.g., childtheme/images/headers/) as the repository of the custom images. I thought that simply creating that new directory and uploading an image would work; it didn't. TIA


title: looking for plugin to create restaurant menu (every post will be different)

text: I'm looking for a plugin (or any other easy way) to create restaurant menus. So every post will have specific (different) menu. Any ideas? pointers? Thanks! :P


title: wp_generate_attachment_metadata gives me an empty array

text:
I have a custom post type and a metabox with a file input. I can insert the attachment, but I can't update the attachment metadata and I don't know how to fix it because I don't receive any error. Here is my code:               $attach_id = wp_insert_attachment( $attachment, $filename, $post_id );     $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );     wp_update_attachment_metadata( $attach_id,  $attach_data );           echo $attach_id;     echo '
';     print_r($filename);     echo '
';     echo '
';     print_r($attach_data);     echo '
';      and here is the output:               96     Array     (         [name] => one.png         [type] => image/png         [tmp_name] => /tmp/phphQ0e2v         [error] => 0         [size] => 144555     )     Array     (     )      As you can see, $attach_data is empty :(


title: Can't get query string in ajax call

text: I'm developing a plugin that exports to a PDF your current posts view in the admin panel. Suppose you're in a post type "product", then the url must be: `edit.php?post_type=product`. What I want is to get that query string (can be something more difficult, `post_typeproduct&area=new-your` for example), and set a loop (in an ajax call) to create and show a PDF. The problem is that I'm trying with: `$wp->request, $wp->query_string, get_queried_object(), $_SERVER['QUERY_STRING'], $_GLOBALS['wp_query']`, but non of above works, all are empty. Any suggestions?


title: wp_remote_get(), downloading and saving files

text: From what I can see wp_remote_get() saves remote file contents to memory. The files that I need to download are compressed in either ZIP or GZIP and within which will either be a CVS or XMl file What I need to do first is download the remote file to the harddrive as ZIP either GZIP and then unzip them Is it possible to use wp_remote_get() to download the whole file and save it to a directory? A non-Wordpress solution I used before was cURL:               public function grab_file($url, $new_file) {              //get file         $ch = curl_init();         $fp = fopen(DIR_PATH."zip/$new_file", "w");              $options = array(CURLOPT_URL => $url, CURLOPT_HEADER => 0, CURLOPT_FAILONERROR =>             1, CURLOPT_AUTOREFERER => 1, CURLOPT_BINARYTRANSFER => 1, CURLOPT_RETURNTRANSFER =>             1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_TIMEOUT => 5, CURLOPT_FILE => $fp);              curl_setopt_array($ch, $options);         $file = curl_exec($ch);         curl_close($ch);         fclose($fp);              if (!$file) {             //$error = "cURL error number:" . curl_errno($ch);             //$error .= "cURL error:" . curl_error($ch);             return false;              } else {                  return true;              }     }


title: How to expire all wordpress user passwords instantly?

text: So I own an article directory website and recently a lot of bots have signed up and started posting spam. (I approve posts prior to publication) I've added a captcha to the user registration page now but for the users that are already registered I want to make their passwords expire so they have to set new ones and obviously the bots won't be able to do this. I've tried multiple plugins with no success. I don't really know what to do. I have over 1800 users so going through them 1 by 1 is not an option. Would appreciate this a lot! Thank you!


title: Toggle admin metabox based upon chosen page template

text: I'd like to have a custom field interface show up _only_ when a certain template is assigned to a particular WordPress page. Any ideas?


title: Custom dashboard widget search box

text: I'd like to create a custom dashboard widget that contains the search box from the posts edit screen. I know how to create the dashboard widget and how to display it, but I don't know how can I place the search box.


title: How to select one major category (or custom taxonomy) for a custom post type?

text: I've created a hierarchical custom taxonomy (genre) and want to use it for a custom post type (radio station). But I don't only want to assign some genres to a radio station. I also want to be able to select one major/main genre as "most important genre" for each radio station. Is it possible to do add a (native) "select only one [custom taxonomy]" field to the custom post type meta box in the admin area? Or is there even a more simple way to define one of the selected genres as the major/main genre? Thanks for your help! Regards,   René


title: Inserting terms in an Hierarchical Taxonomy

text: I'm really having a few issues with inserting terms. Here is my scenario: I have a taxonomy called veda_release_type:               //Release Type and Region             $labels = array(                 'name'=> _x('Release Types/Regions', 'taxonomy general name' ),                 'singular_name' => _x('Release Type/Region', 'taxonomy singular name'),                 'search_items' => __('Search Release Types/Regions'),                 'popular_items' => __('Popular Release Types/Regions'),                 'all_items' => __('All Release Types/Regions'),                 'edit_item' => __('Edit Release Type/Regions'),                 'edit_item' => __('Edit Release Type/Region'),                 'update_item' => __('Update Release Type/Region'),                 'add_new_item' => __('Add New Release Type/Region'),                 'new_item_name' => __('New Release Type/Region Name'),                 'separate_items_with_commas' => __('Seperate Release Types/Regions with Commas'),                 'add_or_remove_items' => __('Add or Remove Release Types/Regions'),                 'choose_from_most_used' => __('Choose from Most Used Release Types/Regions')             );             $args = array(                  'hierarchical' =>true,                   'labels' => $labels,                   'query_var' => true,                   'rewrite' => array('slug' =>'release_type')                  );             register_taxonomy('veda_release_type', 'veda_release',$args);      It's obviously hierchical. Top level contains release types ieDVD, blu-ray. The level under that are regions ie. Region 1, Region 2, etc. So, the Hierarchy that I want is: DVD --Region 0 --Region 1 --Region 2 --Region 3 --Region 4 --Region 5 --Region 6 Blu-Ray --Region A --Region B --Region C I created a function called insert_term in my class to check if a term exists then insert it if it doesn't:               public function insert_term ($term, $taxonomy, $args = array()) {             if (isset($args['parent'])) {                 $parent = $args['parent'];             } else {                 $parent = 0;             }             $result = term_exists($term, $taxonomy, $parent);             if ($result == false || $result == 0) {                 return wp_insert_term($term, $taxonomy, $args);                          } else {                 return (array) $result;             }            }      And then I call said function to insert the terms:                   $dvd = $this->insert_term('DVD','veda_release_type');         $this->insert_term('Region 0','veda_release_type',array('parent'=>$dvd['term_id']));         $this->insert_term('Region 1','veda_release_type',array('parent'=>$dvd['term_id']));         $this->insert_term('Region 2','veda_release_type',array('parent'=>$dvd['term_id']));         $this->insert_term('Region 3','veda_release_type',array('parent'=>$dvd['term_id']));         $this->insert_term('Region 4','veda_release_type',array('parent'=>$dvd['term_id']));         $this->insert_term('Region 5','veda_release_type',array('parent'=>$dvd['term_id']));         $this->insert_term('Region 6','veda_release_type',array('parent'=>$dvd['term_id']));              $bd = $this->insert_term('Blu-Ray', 'veda_release_type');         $this->insert_term('Region A','veda_release_type',array('parent'=>$bd['term_id']));         $this->insert_term('Region B','veda_release_type',array('parent'=>$bd['term_id']));         $this->insert_term('Region C','veda_release_type',array('parent'=>$bd['term_id']));      The problem I'm having is that even though the terms get inputed in the database, they don't show up on the taxonomy page. At most, the top level terms show up. I have to try various things until it sorta forces WordPress to recognize the sublevel terms. Has anyone run into this or can recommend a better way? EDIT: Noticed something else: I tried deleting the terms off the database then deactivating and reactivating the plugin that declares the terms. The two parent terms show up in the terms page, but the child terms do not. The child terms DO show up in the "Parent" drop down menu where you want to create a new term. When I add a term whose parent is one of the child terms and refresh the page, THEN the child terms show up. ![enter image description here](http://i.stack.imgur.com/sMpFO.jpg)


title: Order categories by most posts

text: How can I list the categories by most posts News(100) Updates(45) Alerts(20) and so on


title: help using get_option

text:
I got some code from this site which is going to work great for me. If ound it in another post. What I have modified it to do is add a text box in the category edit area so that the user can input the path to an image. It is working. I have checked the database and I do see the option called "paradiso_category_fields_option" in that option is an array entitled "image" and there is a path to an image. I have displayed this image in the admin area but have not been able to get it on the front of my site. I have tried like so                $cat_image = get_option(paradiso_category_fields_option);      <img src="<?php echo $cat_image;?>">      this gives me                      so I tried a foreach loop and get nothing that way either. Not sure what I am doing wrong here. Here is the line from the database                paradiso_category_fields_option      a:1:{i:7;a:1:{s:5:"image";s:67:"..wp-content/uploads/2010/12/menuItem1.jpg";}}      I shortened the url so that it would fit better on this page. here is the code I am using that make everything work in the admin area                // the option name      define('PARADISO_CATEGORY_FIELDS', 'paradiso_category_fields_option');           // your fields (the form)      add_filter('edit_category_form', 'PARADISO_CATEGORY_FIELDS');      function paradiso_category_fields($tag) {      $tag_extra_fields = get_option(PARADISO_CATEGORY_FIELDS);          ?>

      Full URL to image    	      <input name="_category_image" id="_category_image" type="text" size="40"      aria-required="false" value="<?php echo $tag_extra_fields[$tag->term_id]['image']; ?>" />
This needs the full path to the image you want to use.      Example,
http://www.mysite.com/wp-content/uploads/myImage.jpg.
      <img src="<?php echo $tag_extra_fields[$tag->term_id]['image'];  ?>" alt=""  />

     <?php      }                // when the form gets submitted, and the category gets updated (in your case the      option will get updated with the values of your custom fields above      add_filter('edited_terms', 'update_paradiso_category_fields');      function update_paradiso_category_fields($term_id) {        if($_POST['taxonomy'] == 'category'):         $tag_extra_fields = get_option(PARADISO_CATEGORY_FIELDS);         $tag_extra_fields[$term_id]['image'] = strip_tags($_POST['_category_image']);         update_option(PARADISO_CATEGORY_FIELDS, $tag_extra_fields);        endif;      }                // when a category is removed      add_filter('deleted_term_taxonomy', 'remove_paradiso_category_fields');      function remove_paradiso_category_fields($term_id) {        if($_POST['taxonomy'] == 'category'):          $tag_extra_fields = get_option(PARADISO_CATEGORY_FIELDS);          unset($tag_extra_fields[$term_id]);          update_option(PARADISO_CATEGORY_FIELDS, $tag_extra_fields);        endif;      }      EDIT - I have gotten closer to figuring this out. I have modified loop.php with this code                <?php foreach ((get_the_category()) as $category){      $cat_image = get_option('paradiso_category_fields_option'); ?>      <img src="<?php echo $cat_image[$category->cat_ID ]['image']; ?>" />      <?php } ?>      So that does return the two images it is suppose to but it also returns the first image a few more times. Once for each title in that specific category. Is there a way to target the main category instead of each child category?


title: Get Adjacent Post By Tag

text: In this answer -- How to Get Next or Previous Post in a Specific Tag? -- a working function is provided to generate "next/prev" links by tag rather than category. How could one make this so that you can specify exactly which tag to generate next/previous links for? As it is, it appears to only allow you to _exclude_ tags from consideration. As posts tend to have many tags, it's seems unreliable (with the function as-is) to reply on the in_same_tag option.


title: 2 Loops, Only Displaying 1 Loop in Both Loops

text:
I have 2 loops, movie trailers and gaming trailers but gaming trailers is displaying under both Movie Trailers and Gaming Trailer. Each loop displays the post tagged with either `Movie Trailer` or `Gaming Trailer`. How do I get posts tagged with "Movie Trailers" under the movies area and posts tagged with "Gaming Trailers" under the gaming area? **Heres the loops:**

Movie Trailers

Recent

More Movie Trailers

     <?php if ( have_posts() ) : ?>          <?php  ?>     <?php add_action( 'pre_get_posts', 'display_movie_trailers' ); ?>     <?php while ( have_posts() ) : the_post(); ?>         <?php             get_template_part( 'content-videos', get_post_format() );         ?>     <?php endwhile; ?>               <?php else : ?>              <?php get_template_part( 'no-results', 'index' ); ?>          <?php endif; ?>

Gaming Trailers

Recent

More Gaming Trailers

     <?php if ( have_posts() ) : ?>          <?php  ?>     <?php add_action( 'pre_get_posts', 'display_gaming_trailers' ); ?>     <?php while ( have_posts() ) : the_post(); ?>         <?php             get_template_part( 'content-videos', get_post_format() );         ?>     <?php endwhile; ?>               <?php else : ?>              <?php get_template_part( 'no-results', 'index' ); ?>          <?php endif; ?>      **Functions.php**               //Display Movie Trailers         function display_movie_trailers( $query ) {             if ( $query->is_category() && $query->query_vars['category_name'] == 'videos') {                 $query->set( 'tag', 'movie-trailers' );             }         }         add_action( 'pre_get_posts', 'display_movie_trailers' );              //Display Gaming Trailers         function display_gaming_trailers( $query ) {             if ( $query->is_category() && $query->query_vars['category_name'] == 'videos') {                 $query->set( 'tag', 'gaming-trailers' );             }         }         add_action( 'pre_get_posts', 'display_gaming_trailers' );


title: Check boxes for showing categories

text: Is there a way to list all categories with check boxes on side bar and when user presses "update" only posts within those categories will show on home page?


title: Are there any 'Coming Soon' themes for Wordpress 3.0?

text: I have a website I am starting to build on Wordpress, but I want a placeholder theme to put up while I develop the theme. I had some links to some good "Coming Soon" themes for 2.X, but I lost them. Any good "Coming Soon" themes for Wordpress 3.0? I would prefer it to have a place for the visitors to sign up for updates via email.


title: Adding Fields to the Category, Tag and Custom Taxonomy Edit Screen in the WordPress Admin?

text: The question is " ** _How do I add one or more fields to the Category, Tag and Custom Taxonomy Edit Screen in the WordPress Admin?_** " This question was asked on the wp-hackers list August 1st 2010 and I offered a solution later that day. The original asker discussed the issue again today (Aug 21) which reminded me of the solution. Since it could be a common need I decided to post the solution including code up here for others to find in the future.


title: My template won't apply, theme still fallback to index.php

text: I have a CPT that I want to list the post in the frontend of my website, so i've created a page that I assigned a template so i'll be able to modify the way it look. Here is my template declaration :               /*         Template Name: Book's author     */      Further I have my loop. In my wp-admin under page i've changed the template of my page to Book's author, but on the front-end it's still showing index.php What I don't understand, is that list the book's author, but with my index.php ! Thanks for your help. John.


title: Create an Options page with two image upload fields

text:
I’d like to build a simple and clean Options page with two upload fields and a preview of the uploaded images. I tried a lot of frameworks like NHP and UpThemes but they are way to heavy for my purpose (e.g. I don’t need several options tabs). I found this which fits to my needs but I don’t know how to add a second upload field. Any help would be appreciated!               <?php     function wptuts_get_default_options() {         $options = array(             'logo' => ''         );         return $options;     }               function wptuts_options_init() {          $wptuts_options = get_option( 'theme_wptuts_options' );               // Are our options saved in the DB?          if ( false === $wptuts_options ) {               // If not, we'll save our default options               $wptuts_options = wptuts_get_default_options();               add_option( 'theme_wptuts_options', $wptuts_options );          }           // In other case we don't need to update the DB     }     // Initialize Theme options     add_action( 'after_setup_theme', 'wptuts_options_init' );               function wptuts_options_setup() {         global $pagenow;         if ('media-upload.php' == $pagenow || 'async-upload.php' == $pagenow) {             // Now we'll replace the 'Insert into Post Button inside Thickbox'              add_filter( 'gettext', 'replace_thickbox_text' , 1, 2 );         }     }     add_action( 'admin_init', 'wptuts_options_setup' );               function replace_thickbox_text($translated_text, $text ) {           if ( 'Insert into Post' == $text ) {             $referer = strpos( wp_get_referer(), 'wptuts-settings' );             if ( $referer != '' ) {                 return __('I want this to be my logo!', 'wptuts' );             }         }         return $translated_text;     }               // Add "Options" link to the "Appearance" menu     function wptuts_menu_options() {         //add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function);          add_theme_page('WPTuts Options', 'Options', 'edit_theme_options', 'wptuts-settings', 'wptuts_admin_options_page');     }     // Load the Admin Options page     add_action('admin_menu', 'wptuts_menu_options');               function wptuts_admin_options_page() {         ?>

<?php _e( 'Options', 'wptuts' ); ?>
                                       <?php settings_errors( 'wptuts-settings-errors' ); ?>                      <form id="form-wptuts-options" action="options.php" method="post" enctype="multipart/form-data">                          <?php                         settings_fields('theme_wptuts_options');                         do_settings_sections('wptuts');                     ?>
                         <input name="theme_wptuts_options[submit]" id="submit_options_form" type="submit" class="button-primary" value="<?php esc_attr_e('Save Settings', 'wptuts'); ?>" />                         <input name="theme_wptuts_options[reset]" type="submit" class="button-secondary" value="<?php esc_attr_e('Reset Defaults', 'wptuts'); ?>" />
                      </form>
         <?php     }          function wptuts_options_validate( $input ) {         $default_options = wptuts_get_default_options();         $valid_input = $default_options;              $wptuts_options = get_option('theme_wptuts_options');              $submit = ! empty($input['submit']) ? true : false;         $reset = ! empty($input['reset']) ? true : false;         $delete_logo = ! empty($input['delete_logo']) ? true : false;              if ( $submit ) {             if ( $wptuts_options['logo'] != $input['logo']  && $wptuts_options['logo'] != '' )                 delete_image( $wptuts_options['logo'] );                  $valid_input['logo'] = $input['logo'];         }         elseif ( $reset ) {             delete_image( $wptuts_options['logo'] );             $valid_input['logo'] = $default_options['logo'];         }         elseif ( $delete_logo ) {             delete_image( $wptuts_options['logo'] );             $valid_input['logo'] = '';         }              return $valid_input;     }               function delete_image( $image_url ) {         global $wpdb;              // We need to get the image's meta ID..         $query = "SELECT ID FROM wp_posts where guid = '" . esc_url($image_url) . "' AND post_type = 'attachment'";           $results = $wpdb -> get_results($query);              // And delete them (if more than one attachment is in the Library         foreach ( $results as $row ) {             wp_delete_attachment( $row -> ID );         }        }               // JavaScript     function wptuts_options_enqueue_scripts() {         wp_register_script( 'wptuts-upload', get_template_directory_uri() .'/wptuts-options/js/wptuts-upload.js', array('jquery','media-upload','thickbox') );                if ( 'appearance_page_wptuts-settings' == get_current_screen() -> id ) {             wp_enqueue_script('jquery');                  wp_enqueue_script('thickbox');             wp_enqueue_style('thickbox');                  wp_enqueue_script('media-upload');             wp_enqueue_script('wptuts-upload');              }          }     add_action('admin_enqueue_scripts', 'wptuts_options_enqueue_scripts');               function wptuts_options_settings_init() {         register_setting( 'theme_wptuts_options', 'theme_wptuts_options', 'wptuts_options_validate' );              // Add a form section for the Logo         add_settings_section('wptuts_settings_header', __( 'Logo Options', 'wptuts' ), 'wptuts_settings_header_text', 'wptuts');              // Add Logo uploader         add_settings_field('wptuts_setting_logo',  __( 'Logo', 'wptuts' ), 'wptuts_setting_logo', 'wptuts', 'wptuts_settings_header');              // Add Current Image Preview          add_settings_field('wptuts_setting_logo_preview',  __( 'Logo Preview', 'wptuts' ), 'wptuts_setting_logo_preview', 'wptuts', 'wptuts_settings_header');     }     add_action( 'admin_init', 'wptuts_options_settings_init' );          function wptuts_setting_logo_preview() {         $wptuts_options = get_option( 'theme_wptuts_options' );  ?>
             <img style="max-width:100%;" src="<?php echo esc_url( $wptuts_options['logo'] ); ?>" />
         <?php     }               function wptuts_settings_header_text() {         ?>
<?php _e( 'Manage Logo Options', 'wptuts' ); ?>
         <?php     }               function wptuts_setting_logo() {         $wptuts_options = get_option( 'theme_wptuts_options' );         ?>             <input type="hidden" id="logo_url" name="theme_wptuts_options[logo]" value="<?php echo esc_url( $wptuts_options['logo'] ); ?>" />             <input id="upload_logo_button" type="button" class="button" value="<?php _e( 'Upload Logo', 'wptuts' ); ?>" />             <?php if ( '' != $wptuts_options['logo'] ): ?>                 <input id="delete_logo_button" name="theme_wptuts_options[delete_logo]" type="submit" class="button" value="<?php _e( 'Delete Logo', 'wptuts' ); ?>" />             <?php endif; ?>             <?php _e('Upload an image.', 'wptuts' ); ?>         <?php     }     ?>


title: Storing a DateTime Value in a Sortable Custom Field?

text: Is there a way to store a custom field value as a datetime so it can be used to order by?


title: Why does WordPress get posts from MySQL from a virtual hostname but not the direct hostname?

text: I'm developing a WordPress site on my Mac, running OS X 10.6.4. I'm using OS X's built-in Apache server to run the site locally during development. I've set up WordPress and connected it to OS X's MySQL with no problems. The site seems to work fine, and I can post, edit, etc. The WordPress installation is in a folder called `~/Sites/mysite.dev`. I've also customized my `.hosts` file and Apache's `httpd-vhosts.conf` file, to redirect requests for mysite.dev to this folder. So when I enter `http://mysite.dev` in a browser window, the site loads. No problems here. So I can access the site, in a browser, from two different addresses, `http://mysite.dev`, and `http://localhost/~Gabe/mysite.dev/`. Here's what's weird: When I go to `http://mysite.dev`, the WordPress site loads normally. When I go to `http://localhost/~Gabe/mysite.dev/`, WordPress can't find any posts from the database: It gives me the "Sorry, no posts met your criteria" message (which is built into the theme for when a search for posts returns nothing). N.B.: Apache processes the PHP code normally in both cases -- but in one case WordPress can get posts from MySQL, and in the other case it can't. My first thought was that this was a problem with WordPress's configuration, so I changed the WordPress URL to `http://localhost/~Gabe/mysite.dev/`, but this made no difference. I don't understand why using the two addresses produces different results. Any help appreciated. (Here's why I care, in case you're wondering: I want to preview the site in BBEdit's web preview window, and BBEdit will only load the site via the `http://localhost/~Gabe/mysite.dev/` address.)


title: How do wordpress hooks respond to user interaction?

text: **Embarrassingly big hole in my understanding!** When I've finished editing a post and click the big blue "Update" button, what happens next? In particular, how does the 'pre-post-update' hook (which, being php, exists only on the server) manage to intercept my request? I imagine that either there's something clever going on with Ajax, or - more likely? - that the button action reloads the page, giving the hook a chance to do its thing. **The practical application is as follows:** I have a metabox where (amongst other things) I allow the user to re-order the rows of a table using jQuery UI Sortable. Rather than update the database every time the user re-orders the table or by having a separate "Save changes" button, I'd prefer to have the updating happen when the blue WordPress "Update" button is pressed. The names of some of the WordPress hooks ('save_post', 'pre_post_update') seduced me into thinking I could use them to capture this client-side data - but if the page has to reload before they're called, this is presumably not possible. The nearest I've got to an answer is in this impressive labour of love: http://humanshell.net/2011/08/14/wordpress-initialization/ Now, if someone could do the same sort of explanation for what happens when the "Update" button is pressed... Many thanks if you can help to put me out of my ignorance!


title: Adding a Template to the Page Attributes Panel for both Posts and Pages?

text: I would like to keep my main theme as the active theme, but allow users to select a slightly different layout via the _"Page/Post Attributes"_ panel. Ideally, I'd like to store this layout under my main theme's _"styles"_ directory, in its own folder. > MyTheme > styles > My-special-Layout > style.css So that in the _"Page Attributes"_ panel, I see a template there called _"My- special-layout"_... However, I have two issues...   1. I can't seem to get the _"child"_ theme to appear in the _"Page Attributes"_ panel. (I'm simply adding a folder under my main theme directory and placing a `style.css` file there that has the value "`Template: my_main_theme_directory`"). But I never see any templates appear in the "page attributes" panel.   2. I can't get the _"Page Attributes"_ panel on the POST editor. I'd like to allow the template to be applied to _Posts_ as well as _Pages_. How to get this panel on the post editor?


title: One Page or Post, n Slugs

text: What would be the best option for serving up a page for any one of many slugs. Suppose I have the following:   * example.com/the-broken-slug   * example.com/thebrokenslug   * example.com/broken-slug   * example.com/brokenslug And I would like all of those to deliver up my page having the title "Broken Slug." My first impulse was to look for a plugin that would permit me to define custom routes and declare which posts or pages should be mapped. Does anybody know of a tested and trustworthy solution for this problem?


title: how to display an excerpt of the latest post on the homepage?

text: I've got a CMS-style wordpress setup where the homepage is not the main blog posts page. However, I would like to display the first paragraph of the latest blog post on the homepage, with a link to the post. How would I do that? I'd also like to display, above this excerpt, the first image within the post, but I'm guessing that might be harder... or I'll have to use the 'featured image' or a custom field...?


title: WordPress Settings API, Implementing Tabs On Custom Menu Page

text:
I've been following the WordPress Settings API tutorial series of this guy: http://wp.tutsplus.com/tutorials/theme-development/the-complete-guide-to-the- wordpress-settings-api-part-1/ So far, I've been successful at doing the basic thing. Now, when implementing tab, I'm facing problem. Problem 1: The Tabs are not working. All the fields are being displayed on both the tabs. Section 1, should be displayed on Tab One and Section 2 on Tab Two. Problem 2: Option 2 is not being saved. It was working fine before implementing tabs. ![enter image description here](http://i.stack.imgur.com/oRLlW.png) ![enter image description here](http://i.stack.imgur.com/54yLM.png) Code:               /* ----------------------------------------------------------------------------- */     /* Add Menu Page */     /* ----------------------------------------------------------------------------- */           function add_my_menu() {         add_menu_page (             'Page Title', // page title              'Menu Title', // menu title             'manage_options', // capability             'my-menu-slug',  // menu-slug             'my_menu_page',   // function that will render its output             get_template_directory_uri() . '/assets/ico/theme-option-menu-icon.png'   // link to the icon that will be displayed in the sidebar             //$position,    // position of the menu option         );     }     add_action('admin_menu', 'add_my_menu');     function my_menu_page() {             ?>             <?php               if( isset( $_GET[ 'tab' ] ) ) {                   $active_tab = $_GET[ 'tab' ];               } else {                 $active_tab = 'tab_one';             }             ?>

Menu Page Title

This is description of the page.
                 <?php settings_errors(); ?>
                       <a href="?page=my-menu-slug&tab=tab_one" class="nav-tab <?php echo $active_tab == 'tab_one' ? 'nav-tab-active' : ''; ?>">Tab One                       <a href="?page=my-menu-slug&tab=tab_two" class="nav-tab <?php echo $active_tab == 'tab_two' ? 'nav-tab-active' : ''; ?>">Tab Two
                        <form method="post" action="options.php">                  <?php                     if( $active_tab == 'tab_one' ) {                                settings_fields( 'setting-group-1' );                         do_settings_sections( 'my-menu-slug' );                          } elseif( $active_tab == 'tab_two' )  {                              settings_fields( 'setting-group-2' );                         do_settings_sections( 'my-menu-slug' );                          }                 ?>                          <?php submit_button(); ?>                  </form>
             <?php     }          /* ----------------------------------------------------------------------------- */     /* Setting Sections And Fields */     /* ----------------------------------------------------------------------------- */           function sandbox_initialize_theme_options() {           add_settings_section(               'page_1_section',         // ID used to identify this section and with which to register options               'Section 1',                  // Title to be displayed on the administration page               'page_1_section_callback', // Callback used to render the description of the section               'my-menu-slug'                           // Page on which to add this section of options                );              add_settings_section(               'page_2_section',         // ID used to identify this section and with which to register options               'Section 2',                  // Title to be displayed on the administration page               'page_2_section_callback', // Callback used to render the description of the section               'my-menu-slug'                           // Page on which to add this section of options           );              /* ----------------------------------------------------------------------------- */         /* Option 1 */         /* ----------------------------------------------------------------------------- */               add_settings_field (                'option_1',                      // ID used to identify the field throughout the theme               'Option 1',                           // The label to the left of the option interface element               'option_1_callback',   // The name of the function responsible for rendering the option interface               'my-menu-slug',                          // The page on which this option will be displayed               'page_1_section',         // The name of the section to which this field belongs               array(                              // The array of arguments to pass to the callback. In this case, just a description.                   'This is the description of the option 1',             )           );           register_setting(               //~ 'my-menu-slug',               'setting-group-1',               'option_1'           );              /* ----------------------------------------------------------------------------- */         /* Option 2 */         /* ----------------------------------------------------------------------------- */                   add_settings_field (                'option_2',  // ID -- ID used to identify the field throughout the theme               'Option 2', // LABEL -- The label to the left of the option interface element               'option_2_callback', // CALLBACK FUNCTION -- The name of the function responsible for rendering the option interface               'my-menu-slug', // MENU PAGE SLUG -- The page on which this option will be displayed               'page_2_section', // SECTION ID -- The name of the section to which this field belongs               array( // The array of arguments to pass to the callback. In this case, just a description.                   'This is the description of the option 2', // DESCRIPTION -- The description of the field.             )           );         register_setting(               'setting-group-2',               'option_2'           );          } // function sandbox_initialize_theme_options     add_action('admin_init', 'sandbox_initialize_theme_options');          function page_1_section_callback() {           echo '
Section Description here
';       } // function page_1_section_callback     function page_2_section_callback() {           echo '
Section Description here
';       } // function page_1_section_callback          /* ----------------------------------------------------------------------------- */     /* Field Callbacks */     /* ----------------------------------------------------------------------------- */           function option_1_callback($args) {           ?>         <input type="text" id="option_1" class="option_1" name="option_1" value="<?php echo get_option('option_1') ?>">
 <?php echo $args[0] ?>
         <?php           } // end sandbox_toggle_header_callback            function option_2_callback($args) {           ?>         <textarea id="option_2" class="option_2" name="option_2" rows="5" cols="50"><?php echo get_option('option_2') ?></textarea>
 <?php echo $args[0] ?>
         <?php           } // end sandbox_toggle_header_callback


title: Cache remote (HTTP) request with Transients API

text: I am trying to use `get_transient()` method in my word-press ,have read the document and seems like i am doing what has been described in the docs. I need to show Weather in my Website and i am using third part weather API which use to get updated in every 6 hours. we are creating a local cache of weather so that API should get call only after expiry time (other reason is number of call per hour to API) this is my code               $country   = 'India';     $API_Key  = 'xxxxxxxxxxxxxx';     $url        = 'http://weatherAPI.com/feed/weather.ashx?q='.$latlong.'&format=json&num_of_days=4&key='.$API_Key;          $weather = get_transient($location);     if (false === $weather) {             $ch = curl_init();             curl_setopt ($ch, CURLOPT_URL, $url);             curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);             curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);             $weather = curl_exec($ch);             curl_close($ch);             set_transient($location, $weather, 60*60*6);      }      When i am sending a location to get weather (`say delhi`) and if its not there in the cache, i was expecting that it will return me `false` while its returning me following string               '{ "data": { "error": [ {"msg": "Unable to find any matching weather location to the query submitted!" } ] }}'      i used `var_dump($weather );` to check value of `$weather` Can anyone correct me where i am doing wrong?