title: Good practical way to do loop within loop to show child custom type using a template code

text:
I'm using Version WP e-Commerce plugin 3.8.12.1 I used a custom post type "event" with multiple value field "event_photos" and the field type is wpsc-product. To show a single "event" use single-event.php :               <?php while ( have_posts() ) : the_post(); ?>                 <?php                     /* Include the single view for the event.                       */                                  include TEMPLATEPATH.'/event-templates/single.php';                      <?php endwhile; // end of the loop. ?>      To show a list of products of a custom type "event" use "/event- templates/single.php" :
                 <?php $event_photos_obj = get_field('event_photos'); //Show product in a list                         if( $event_photos_obj ) :                             echo '
';                             foreach ($event_photos_obj as $products) :                                 setup_postdata($products);?>
                                     <?php                                     $target_product = get_field('event_picture_photo', $products->ID);                                     ?>
                                         <?php                                              if ( wpsc_the_product_thumbnail(0,0,$products->ID) ) : ?>                                                     <a rel="<?php echo wpsc_the_product_title(); ?>" class="<?php echo wpsc_the_product_image_link_classes(                                                     ); ?>" href="<?php echo esc_url( wpsc_the_product_image(0,0,$products->ID) ); ?>">                                                         <img class="product_image" id="product_image_<?php echo $products->ID ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(0,0,$products->ID); ?>"/>                                                                                <?php endif; ?>

                             <?php endforeach;                             echo '
';                         else :                                               echo "Δεν υπάρχει φωτογραφία";                         endif; ?>
      My question is how to tell wp to index in a specific product and then using the template code "wpsc-single_product.php" :
              <?php             // Breadcrumbs             wpsc_output_breadcrumbs();                  // Plugin hook for adding things to the top of the products page, like the live search             do_action( 'wpsc_top_of_products_page' );         ?>
     <?php             /**              * Start the product loop here.              * This is single products view, so there should be only one              */                  ?>
                             <?php if ( wpsc_the_product_thumbnail() ) : ?>                                     <a rel="<?php echo wpsc_the_product_title(); ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo esc_url( wpsc_the_product_image() ); ?>">                                         <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(); ?>"/>                                                                          <?php                                     if ( function_exists( 'gold_shpcrt_display_gallery' ) )                                         echo gold_shpcrt_display_gallery( wpsc_the_product_id() );                                     ?>                             <?php else: ?>                                         <a href="<?php echo esc_url( wpsc_the_product_permalink() ); ?>">                                         <img class="no-image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="No Image" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/noimage.png" width="<?php echo get_option('product_image_width'); ?>" height="<?php echo get_option('product_image_height'); ?>" />                                                                      <?php endif; ?>

                  <?php echo wpsc_product_comments(); ?>          <?php do_action( 'wpsc_theme_footer' ); ?>
      Is it better way to use WP_Query?


title: Form in WordPress : 404

text: In my WP site I've got a Contact page whose URL is mysite.com/contact/ and which contains a `<form>` with an action attribute set to action="/contact/" Clicking on the submit button brings me to this : mysite.com/contact/ This is the exact URL of my contact page (which works very well if I use this URL). Yet, it gives a 404 after having arrived to that URL via the submit button ! This doesn't make any sense to me, anybody can explain?


title: What's the proper way to use wp_enqueue_script/style?

text: First, let me tell you how I'm currently doing it. I have this function. It's purpose is to take the the string of a file system path (/root/web/dir/some/path/to/file) and return the equivalent URL (http://mydomain.com/some/path/to/file). In order for this function to work properly, it needs to know where the **root web directory** (RWD) is on the system. It does this by assuming $_SERVER['DOCUMENT_ROOT'] as the RWD.               function path_to_url($path)     {         $path = str_replace('\\', '/', $path);         $doc_root = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);              return 'http://'.$_SERVER['HTTP_HOST'].'/'.str_replace(' ', '%20', str_replace($doc_root, '', $path));     }      > Please learn this function and know what it does in order to understand what > I'm talking about in this post. With this function, all I would need to know in order to include a script/stylesheet on my page is it's path. I would be writing code that looks something like:               wp_enqueue_script('myscript', path_to_url(dirname(__FILE__).'/script.js'));      This worked fine, in fact, it worked so well that I started to use path_to_url in a lot of places in my theme. There's one reason why this solution doesn't work in some circumstances. Some shared hosting sites (bluehost) don't have $_SERVER['DOCUMENT_ROOT'] set to the RWD as I expected and assumed it to be. Bluehost seems to always have it set to "/usr/local/apache/htdocs" which does not correlate with the paths I use within PHP -- "/home1/demo/public_html/wp-content/themes/...". So I must either give a work around to those most unfortunate to have $_SERVER['DOCUMENT_ROOT'] set to something as incorrect (at least to my knowledge of it seeming to be incorrect) as the above, or I should figure out another means of doing what I want/need to do. The solution would be to somehow correct $_SERVER['DOCUMENT_ROOT']. But this doesn't seem like a valid solution for my customers. They would need to submit a support ticket notifying me that my theme isn't working. Then I would need to reply with a message on how they can fix the issue. But before I could simply reply to them with a solution, I will need to know their RWD somehow. This would be a very cumbersome solution and would require more time and effort then seems practical. So I'm left with the second solution -- figure out another means of doing what I _need_ to do. While writing this I figured that I could go with the hard- coded approach, and maybe that's the only way to go about this problem.               wp_enqueue_script('script', get_bloginfo('template_url').'/lib/framework/panel/script.js');      After all my explanation, this seems like a no-brainer. But the only quarrel I have with this is how rigid it is. For example, if I decide to move my script.js file around, I'll need to edit this code, no matter what. What I like about the above path_to_url solution, is that if I moved the script.js and the php template file, nothing breaks; so long as the script.js file stays in the same folder as the php template file. In fact, what I was doing with the path_to_url solution is making things relative again, relative to the php template file! Unfortunately though, I realize that it is not practical to expect there's one formula for converting _all_ file system paths on _all_ systems to URLs. This is due to the fact that there are different server configurations that make it impossible for one formula to know the RWD in a path. For example, one server could have a setup where wordpress is installed under http://example.com/~demo/ and the RWD would be /home1/demo/public_html/. Thus there's no way I can get the RWD our of __FILE__ with this kind of setup. How could I? I hope you found this post/question interesting. I'll leave you with this question: How can I make `wp_enqueue_script('script', get_bloginfo('template_url') . '/lib/framework/panel/script.js');` more relative and less rigid? Thanks guys. Peace!


title: How to get child category list post in one template?

text: Here is what I want to have My category Structure in WP admin               Cat Parent       -Cat Child 1       -Cat Child 2       -Cat Child 3       -Cat Child 1      This what I want to have in one template: It show the list of post in Cat Parent Children Category               Cat Child 1      -Post1 Child 1      -Post2 Child 1      -Post3 Child 1      -So on... .          Cat Child 2      -Post1 Child 2      -Post2 Child 2      -Post3 Child 2      -So on... .          Cat Child 3      -Post1 Child 3      -Post2 Child 3      -Post3 Child 3      -So on... .      Does anyone have done it before or anyone have an idea on how to code this? Thanks


title: Infinite scroll messing up nth:of-type

text:
I am using infinite scroll of my local theme here and it is causing some CSS issues. I was hoping if I ran this by some of you, you might have a solution to offer. This is pretty much the layout:               #wrap {     width: 938px;     overflow: hidden;     background-color: aqua;     border: 1px solid white;     padding: 5px 5px;     }          .one {     width: 33.04904051172708%;     float: left;     }          #wrap .one:nth-of-type(3n+1) {     margin-right: 4px;     }          #wrap .one:nth-of-type(3n) {     maring-left: 4px;     }

      With that, I pretty much have everything looking as I want. This is how the markup would look with the Infinite scroll:

      The issue is,Infinite Scroll loads a `<div>` called `infscr-loading` at every pagination break and this throws off my `:nth-of-type`. For some reason the `infscr-loading` is counting towards the `#wrap .one:nth-of-type` Perhaps I understand `nth-of-type` incorrectly, but shouldn't (with the way I have it set up) only `.one` classes count towards it? Is there any way to get `:nth-of-type` to ignore a div? As always, any help would be greatly appreciated.


title: WooCommerce Custom Product Validation

text: I'm attempting to build a membership system in WordPress that utilizes **_WooCommerce_** with **_Gravity Forms_** and integrates with **_SalesForce_**. Can somebody give me some direction on how to properly utilize the `woocommerce_add_to_cart_validation` filter? I'm simply not sure how to properly utilize this hook. Not matter what I do, if I try to perform any custom validation, the item is not added to the cart. Below is my code:               add_filter( 'woocommerce_add_to_cart_validation', 'validate_active_subscription', 10, 10 );          function validate_active_subscription( $valid, $product_id, $quantity, $variation_id, $variations ) {       global $woocommerce;       $cart_item_data = (array) apply_filters( 'woocommerce_add_cart_item_data', $cart_item_data, $product_id, $variation_id );       $item_data = $cart_item_data["_gravity_form_lead"];            //CAPTURE THE ID OF THE MEMBERSHIP CATEGORY       $idObj = get_term_by('slug','membership','product_cat');        $membership_id = $idObj->term_id;            $membership_purchased = false;       $terms = woocommerce_get_product_terms($product_id, 'product_cat' );       foreach ($terms as $term) {         if($term->term_id == $membership_id){           $membership_purchased = true;         }       }       if($membership_purchased){         //LET'S CHECK THAT, IF THIS EMAIL EXISTS WITHIN SALESFORCE, IT IS ASSOCATED WITH THE SAME INDIVIDUAL         try {           $mySforceConnection = SalesForce_Access::Connection();           $sf_contact = SalesForce_Access::Search_Contacts_Via_Email($mySforceConnection, $item_data[6]);           if( $sf_contact->FirstName == $item_data[3] && $sf_contact->LastName == $item_data[4]){             //$valid = true;           }else{             //$woocommerce->add_error("The email address you supplied already exists within our system. Please supply a different email");             //$valid = false;           }         }         catch (Exception $e)          {           //$woocommerce->add_error($e->faultstring);           //$valid = false;         }          }     }       Before the user adds the membership item to the cart, I want to check the email address, first name and last name to verify that the information properly matches an existing record (e.g. if the email exists, the supplied first name and last name should also match). However, how do I properly pass validation (or invalidation) back to WooCommerce so it can go back to standard operation. Everything I do seems to loop back to the single product page and remove my gravity form fields. Any thoughts would be appreciated.


title: excerpt in characters

text: I have code in functions.php:               function string_limit_words($string, $word_limit)     {       $words = explode(' ', $string, ($word_limit + 1));       if(count($words) > $word_limit)       array_pop($words);       return implode(' ', $words);     }      but i need to limit excerpt in number of characters, could you help me with that?


title: How can i limit the character length in excerpt?

text: > **Possible Duplicate:**   >  excerpt in characters I have a question after reading this post (http://wordpress.stackexchange.com/questions/16070/how-to-highlight-search- terms-without-plugin). I like this function(Search Term Without Plugin) very much but the character length is too long. What php code should i add to make the excerpt shorter? Would appreciate if someone can suggest it. Thank you!


title: The short content by characters

text: > **Possible Duplicate:**   >  excerpt in characters In some of our sites, we to show excerpts of posts (the content administrators don't enter excerpts).   We _could_ use the `the_excerpt` function, but from what I could see, I can only control the amount of words it extracts, and that's a little too general for us (a word could have 2 letters, or 10 letters...).   So we need a function that takes the number of characters and extracts that amount from the content. But we also don't want the words be cut in the middle. One last need is that the function work with the multy-byte version of the string functions of php (for examplel: use `mb_substr` instead of `substr`) Are there WP built in functions that would do this?


title: Why we do need wp_enqueue_script() function?

text: I only want to know what is the purpose of wp_enqueue_script function, if it is used to add javascript and jquery on header then we plugins options to add those files.. but what this function acutally do if I am developing a theme and I have jQuery featured slider on my theme.. do I need this function?


title: Email address or username used to login in wordpress

text: How can i allow users to login to my wordpress site using both email id and username? Currently it is allowing only username.


title: How to create a managed image repository in wordpress

text: I want to redesign my current website (www.ch3.gr) using wordpress. Since the content of my site will be 95% images, I am looking for a better way to manage them from within WP back end. What I have in mind at the moment, is a central and managed repository that every uploaded image goes into. This repository can be shorted by date, name, tags etc so I can easily find, edit and select my images to add into a post or a gallery. Every new image will probable be in its own post and part of the blog's stream. But then I also want to have some fixed pages with image galleries, that their content may change at any time. So I want to be able to do that easily and without having to re-upload the image. An image may also be part of more than one gallery. I've looked into many different plugIns but I haven't found one that offers this functionality. Have you maybe come across one that would do what I want? If not, do you have any other solution to suggest? Thank you


title: Connect to another WP install and grab post based on custom field

text: This is the set up: Two separate wordpress installs on two separate domains (not multi-site) This is what I want to do Query the posts from database one based on custom field and display them on the other Wordpress install This is what I have done: Created a metabox in the WP 1 install for custom field Created a template in WP 2 install with the following query $hbldb = new wpdb('username','password','dbasename','localhost'); $results = $hbldb->get_results( query_posts('meta_key=dbt_ffhpost&meta_value=on') ); LOOP The result: 404 - what you are looking for isn't here. I know the issue is in the query - just don't know what. Do I need to query the specific table, row, field etc? Any help greatly appreciated.


title: How to make previous_post_link into an image

text: I would like to make the previous and next post link into an image instead of a link text e.g.                      so whatever the size of the image it would be clickable i tried adding a css through filter but the image just stays as a background(not clickable)               function post_left_attributes($output) {         $injection = 'class="arrow_left"';              return str_replace('<a href=', '<a '.$injection.' href=', $output);     }          function post_right_attributes($output) {         $injection = 'class="arrow_right"';         return str_replace('<a href=', '<a '.$injection.' href=', $output);     }


title: How to get date for each post?

text:
while (have_posts()) : the_post();     //some html
<?php the_date('Y-m-d');?>

<?php the_date('H:i:s');?>
      With this code i am getting only date for first post - what is wrong?


title: How to create a category and sub-category sorted blogroll with all posts?

text:
I would like some help to post all the posts of my website into a blogroll sorted by categories and subcategories. The end-result HTML I would like to see displayed would be something like this:

post1

post2

post3

post4

post5

post6

post7

post8

post9

      The file-structure I foresaw for this would be something like this: `custom-category.php` //this file would pull out the categories, sort them and create the container divs for #category and #sub-category and call the post info from within it's loop/query with `get_template_part( 'content', get_post_format() );` `content.php` //this file would sort the ul#posts and all sorts of info I might want to add regarding the post itself Now the main issues I have right now, is not really knowing where to start looking to even try and figure this out by myself. I keep looking at the default `category.php` file and I feel it'll look nothing like it. I've tried looking at plugins but some only sort the categories in side-bars, others allow creating custom fields for categories but reviews mention you can't call on those values. I've tried the wp_list_categories(); function to try and start somewhere, but it doesn't even list the sub-categories. I've read about creating your own `query_posts();` or `get_posts();` but I don't really know where to start with those. Since this isn't really a single question, I'd like to try and point the questions out for clarity, but feel free to add other info you might feel would take care of the issue, cause I might ask the wrong questions xD 1- How do I start "the Loop" to obtain the categories/sub-categories?   2- How do I sort the categories and keep the sub-categories nested?   3- How will I make sure the posts will fall into the right divs? Just in case WP does something funny. Thank you for the help. **\--- Update ---** I've been poking the internet trying to find solutions and I'm starting to get somewhere, but not quite there yet. This is what I've got so far:               <?php             // get all the categories from the database             $args1 = array(               'orderby' => 'ID',               'order' => 'ASC',               'hierarchical' => true,               );             $cats = get_categories( $args1 );                            // loop through the categries                 foreach ($cats as $cat) {                     // setup the cateogory ID                     $cat_id= $cat->term_id;                     // Make a header for the cateogry                     echo "
".$cat->name."

".$cat->term_id."
";                     // create a custom wordpress query                     $args2 = 'cat=' . $cat_id . '&orderby=date&order=DESC&post_per_page=-1';                     query_posts( $args2 );                     // start the wordpress loop!                     if (have_posts()) : while (have_posts()) : the_post(); ?>                              <?php // create our link now that the post is setup ?>                         <a href="<?php the_permalink();?>"><?php the_title(); ?>                         <?php echo '
'; ?>                          <?php endwhile; endif; // done our wordpress loop. Will start again for each category ?>                 <?php } // done the foreach statement ?>      I found this piece of code on this website. It outputs all the categories and puts the posts under them, but it replicates the posts for the parent category like this:
Category1

2
          test0

Category2

3
         test2
          test1

Sub-category1

4
         test1

Sub-category2

5
         test2
       As you can see the posts, test1 and test2 are displayed in Category2 and that isn't quite what I wanted, as described in the initial question (end-result HTML). I believe I need to add a conditional statement to verify if the current category has children and if it does jump to the child categories, if not populate it. But I'm still trying to figure out how to do that. I haven't reached a point where I'm comfortable enough to start trying to implement the div's that I intend to have in the end-result HTML but I have a feeling I'll have an issue with that as well. At this point I'm basically trying to learn a bit more about this "loop stuff" till I get a decent result that will allow me to wrap my head around the whole thing. I am aware of these 2 links A and B but I'm still a novice and can't really get there quite yet, so I'm basically working with code I see is working and will try to get it improved as I move along. **\--- Update ---** This seems to output the posts in the correct order and without repeating themselves for parent categories.               <?php             // get all the categories from the database             $args1 = array(               'orderby' => 'ID',               'order' => 'ASC',               'hierarchical' => true               );             $cats = get_categories( $args1 );                       // loop through the categries                 foreach ($cats as $cat) {                     $cat_id= $cat->term_id;// setup the cateogory ID                     $cat_name= $cat->name;// setup the category name                     $parent= $cat->category_parent;// setup the category parent                     $cat_child= get_term_children( $cat_id, 'category' ); //the function I had get_category_children(); was deprecated... fixed that                          $has_child=bool; //                     if( empty($cat_child)) { $has_child= false; }                     else { $has_child= true; }                          if ( $parent == 0 && $has_child == true ) { //is parent && has child -> post title                         echo "
".$cat_name."
";                         echo '
'; }                     elseif ( $parent == 0 && $has_child == false ) { //is parent && no child -> loop posts                         echo "
".$cat_name."
";                         // create a custom wordpress query                         $args2 = 'cat=' . $cat_id . '&orderby=date&order=DESC&post_per_page=-1';                         query_posts( $args2 );                         // start the wordpress loop!                         if (have_posts()) : while (have_posts()) : the_post(); ?>                             <?php the_title(); ?>                             <?php echo '
'; ?>                         <?php endwhile; endif; }                     else { //is child -> loop posts                         echo "
".$cat_name."
";                         // create a custom wordpress query                         $args2 = 'cat=' . $cat_id . '&orderby=date&order=DESC&post_per_page=-1';                         query_posts( $args2 );                         // start the wordpress loop!                         if (have_posts()) : while (have_posts()) : the_post(); ?>                             <?php the_title(); ?>                             <?php echo '
'; ?>                         <?php endwhile; endif;   // done our wordpress loop. Will start again for each category ?>                 <?php }} // done the foreach statement ?>      I divided this into 3 conditions: `is parent and has child`, `is parent but no child` and `is child`. The function that allowed me to get here is `get_category_children();`. Reading the code now makes me think I could've just checked if `$cat_child` was empty directly in the main if/elseif statements, avoiding the `$has_child` run-a-round.


title: Images not showing after moving site (but path id OK)

text: I moved (actually copied) a wordpress site (http://inglesen100dias.com/) to a new server and domain (http://blog.inglesen100dias.com/). I followed the process described in Wordpress' website (codex.wordpress.org/Moving_WordPress#Moving_WordPress_to_a_New_Server) and also used a search and replace script (interconnectit.com/products/search-and- replace-for-wordpress-databases/) as recommended there to fix the path of the images, so they use the new URL of the site. Everything seems fine except the images, which they don't show (as you can see if you click in both links above). But looking at the path of the images, it seems to be fine, and even if I copy that path and paste it in the browser the image shows fine, but it doesn't when looking at the website. I've also removed the htaccess file but nothing... Any ideas?


title: List authors of site with link and gravatar

text:
I'm trying to do something I assumed would be easy. I assumed wrong. What I want to do is list all the authors of a site on the sidebar, with a link to their respective author page, number of posts written, and gravatar. wp_list_authors doesn't give me an option to include the gravatar at all. Here is what I have                       $blogusers = get_users_of_blog();             if ($blogusers) {               foreach ($blogusers as $bloguser) {                 $user = get_userdata($bloguser->user_id);             $post_count = count_user_posts($user->ID);                 if ($post_count) {             echo '
';             echo 'user_nicename . '">'.get_avatar($user->user_email, '36').'';             echo 'user_nicename . '">'.$user->display_name.' ('.$post_count.')
';                 }               }             }      Which works, albeit with two problems:   1. I can't find a way to have them sort by number of posts   2. the get_users_of_blog is a depreciated function. I really don't want to use it. I was able to create an explode with wp_list_authors, but didn't have a clue how to extract the data out of it to display in this manner. Help?


title: Posts from current category on custom page

text:
I have a problem - I want display posts from current category on page with custom template. I write something like this:               <?php include 'header.php' ?>
                  <?php if (have_posts()) : ?>

<?php echo get_the_title($post->post_parent);?>  - <?php the_title(); ?>

         <?php                 $catid = get_query_var('cat');                   $args = array(                 'posts_per_page' => 2,                 'category__in' => $catid,                 'paged' => get_query_var('paged')                 );                 query_posts( $args );                  ?>         <?php while (have_posts()) : the_post(); ?>

                 <?php if ( has_post_thumbnail()) : ?>                    <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >                         <?php the_post_thumbnail( array(218,181) ); ?>                                      <?php endif; ?>

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

                        <?php                         global $more;                         $more = 0;                         ?>                     <?php the_content(''); ?>

<?php $category = get_the_category(); echo $category[0]->cat_name; ?>
                 <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >>zobacz pozostałe produkty

         <?php endwhile; ?>         <?php endif; ?>
          <?php include 'footer.php' ?>       But it doesn't work. Where is the problem?


title: Display custom list of tags in post/page editor with hooks

text: I used the information posted on this blog post to display specific tags when editing a post. The editors on my site wanted the ability to display pre- specified tags instead of the most popular ones. We have a lot of tags and sometimes the ones they want to use are not being used because they are not seen and they don't remember what to search for. So in the `wp-admin/includes/ajax-actions.php` file I changed the **line 651** to               $tags = get_terms( $taxonomy, array(          'number' => 45,          'orderby' => 'name',          'order' => 'DESC',          'include' => array('21', '12')      ) );      where the `include` array is the selection of tags I want to display. and **line 665** to               $return = wp_generate_tag_cloud( $tags, array(         'largest' => 10,          'smallest' => 10,          'filter' => 0,          'format' => 'flat',          'separator' => "  "     ) );      This works fine for displaying a sequential list (I didn't want a tag cloud) of specific tags but these changes are to the wordpress core and on the next update I'll have to go in and re-do these. Is there any way to accomplish this with hooks so that I don't mess with the core? Thanks


title: Line of Tag information Is Formatted Strange

text: I'm placing a tag list in the post footers on a blog. You can go to this specific post: http://www.smallfryblog.com/2013/09/03/small-fry-films-midtown/ and scroll down to the post footer see what the tags looks like currently: "filmsvideoTags:," is what it looks like to me. I would like it to look like "Tags: films, videos" Here's my code:               <?php the_tags('Tags:', ', ', '<br/>'); ?>      which is according to the codex here: http://codex.wordpress.org/Function_Reference/the_tags I've tried all different kinds of things trying to figure out what the problem is...with no solution found yet. Help?


title: Get page->parent's name?

text: How can i get the name of a page's parent?   I can only get it's id.                       $page = get_queried_object();             $pageparent = $page->post_parent;


title: Linking beetween pages in wordpress

text: Hi I am trying to link to some custom templates I have created and I don't seem to know how to do it the right way.For example: I have created a custom contact page and named it contact.php.From the front- page I want to link to it.Now this is what I did but I don't think this is the best way:               <a href="<?php bloginfo('url') ?>/contact">      Now this works but only if the permalinks are set in the settings page to postname.If for example the page is set to default the links shows the 404.php. How can I set the links the right way? I noticed that when creating custom post types there is a way to rewrite the permalinks and define a slug for the new page.Is there a similar way to rewrite permalinks for custom templates?


title: How to sanitize uploaded file filename from a plugin?

text: There is a problem with WordPress Form Manager plugin that doesn't sanitize the uploaded file filename. So, when a user upload a photo with special characters in the filename, you will not be able to show it up on the front- end, for example. My question is, how can I sanitize that? Ps: I already shot the question to the plugin's author.


title: Add a hook to wp_mail() to track Google Analytics Event

text: I hope you'll be able to help me on this one: I'm trying to trigger a GA event for every email sent via a Wordpress site. My idea was to add the following code to my child theme's functions.php file:               add_action("wp_mail", "trigger_contact_event");     function trigger_contact_event(){     include "include/Galvanize.php"; //Galvanize is a php class able to trigger GA events server-side     $GA = new Galvanize('UA-XXXXXXX-XX');     $GA->trackEvent("Contact", "info request");     }      But unfortunately, this doesn't trigger anything. Would anyone have a solution? Even another way to trigger a GA event, as long as it is hooked to any email sent via the wordpress website. Thanks in advance!


title: Disable WYSIWYG editor only when creating a page

text: I read several articles about configuring the WordPress editor. For example, this snippet shows how to permanently set the editor to HTML or WYSIWYG _for all contents_. I'm wondering if it's possible to disable the WYSIWYG only when the user is creating a page, leaving it enabled for any other WordPress content type.


title: Get the Current Page Number

text: In a situation where one has 20 posts per page. I would like to get the current page number in order to make some nice page links at the bottom. How do you get the current page. I tried this               <?php echo '(Page '.$page.' of '.$numpages.')'; ?>      and it just says page 1 of 1 on every page. Any ideas, Marvellous


title: permalinks has -2 with post name structure. why?

text: I have set permalinks structure in my website as post name, then it supposed to come as:               http://example.com/newsite/page-name/      but it is coming as:               http://example.com/newsite/page-name-2/      I dont know why the -2 coming with some pages ? Thanks for help... :)


title: File available but giving 404 in wordpress

text: Hey, im not sure why but php files other then wordpress either redirects to homepage or gives a 404. for example i have a timthumb.php in directory /js/ it was working fine and generating thumnails for me.. but it started to give 404 on even running the direct url. You can take a look here : www.designzzz.com/js/ you will see timthumb.php available, but on clicking or running that file it gives 404 :( . Help is appreciated :) cheers Ayaz


title: Add query string to wp_link_pages links

text: I am attempting to add a query string to the output 'Next' and 'Previous' links that are produced from a modified `wp_link_pages`. In my functions.php I have:               add_filter('wp_link_pages_args','add_next_and_number');     function add_next_and_number($args){         if($args['next_or_number'] == 'next_and_number'){            global $page, $numpages, $multipage, $more, $pagenow;            $args['next_or_number'] = 'number';            $prev = '';            $next = '';            if ( $multipage ) {               if ( $more ) {                 $i = $page - 1;                 if ( $i && $more ) {                    $prev .= _wp_link_page($i);                    $prev .= $args['link_before'] .$args['previouspagelink'] . $args['link_after'] . '';                 }                 $i = $page + 1;                 if ( $i <= $numpages && $more ) {                    $next .= _wp_link_page($i);                    $next .= $args['link_before']. $args['nextpagelink'] . $args['link_after'] . '';                 }            }        }           $args['before'] = $args['before'].$prev;           $args['after'] = $next.$args['after'];         }     return $args;     }      To catch the query string I am currently using:               <?php if (isset($_GET) AND $_GET['src']=='querystring') { ?>         // specific code for this query string     <?php } ?>      So addressing my initial question. If the user comes from link `?src=querystring`, how would I in turn add that same query string to the 'Next' and 'Previous' links that get returned by my modified `wp_link_pages`?


title: Programmatically get images by URL and save in uploads folder

text: I am involved in a large migration from another CMS to WordPress. We have a copy of the database and have worked out how to extract the content and programmatically create WordPress posts from it using an instantiation of the `wpdb` class. However, there are a couple of thousand images which we would like to pull across automatically, generate the various sizes, and then attach to the posts, to save about a week's work! Is there a way I can get an image from a remote site by URL and save it in my wp-uploads folder? I guess this uses `wp_http` but I'm unfamiliar with that. Once I've got the image and saved it I'm ok as I can then use `wp_generate_attachment_metadata` to create the various sizes and `wp_insert_attachment` to attach it to a post. Thanks Simon


title: How can I use Page editor for two separate templates?

text: On some of my pages (not posts) in my Wordpress site, I need to include a sidebar that display s information relevant to the main content of the page the user is on. I can choose, using Edit Page in WP Admin, the page template I want to use for my page. This template includes the sidebar. No problems here. My question is: the sidebar content will vary page by page, so how do I make the sidebar content dynamic? I don't want to change the html in the sidebar template because that would reflect on all pages using the sidebar, so I can't put my page-specific content there. And, I don't want to create a million different sidebar templates with html content hard coded in to the template. My sidebar template contains the "shell" for the positioning, colors, font, etc. I just want to have a way to change the content in the sidebar on a page by page basis, without that change reflecting on any other page. It would be great if the Page editor would include a separate content input area for sidebar content. Is this possible, and is my question clear?


title: Hide third level nav items from side menu

text: I am using the following to list all child items of a main nav item in my sidebar:               <?php       if($post->post_parent) {       $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");       $titlenamer = get_the_title($post->post_parent);       }            else {       $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");       $titlenamer = get_the_title($post->ID);       }       if ($children) { ?>           <?php echo $children; ?>      Is there a way to alter this so only list the child items one level down show instead of children and grandchildren? Conversely, when I am on a grandchild page, how would i show only the links from one level up? In other words, I always want this nav to list out the children one level down from the main menu. Thanks!


title: Associate all Custom Post Types with Taxonomy

text: I have a custom post type `imagery`. I have a taxonomy `publications`. I need all present and future `imagery` post types have the taxonomy `publications`. Here's a simplified version of code in functions.php:               $args = array(         'taxonomy' => array('publications')     );     register_post_type( 'imagery', $args );      ..but it's not working. What am I doing wrong?


title: display random posts on index.php instead of latest

text: I have the settings so only one post (which is by default the most recent) displays with index.php my current working code               <?php if (have_posts()) : while (have_posts()) : the_post(); ?>      How could I change to code to display a random post from any category/date? It just needs to be one post if that makes a difference. many thanks


I turned on my Debugger and got this error...               Notice: register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead. in /home/content/19/9468119/html/wp-includes/functions.php on line 2705          Notice: register_widget_control is deprecated since version 2.8! Use wp_register_widget_control() instead. in /home/content/19/9468119/html/wp-includes/functions.php on line 2705      I went to the line of code in question...               function _deprecated_function( $function, $version, $replacement = null ) {              do_action( 'deprecated_function_run', $function, $replacement, $version );              // Allow plugin to filter the output error trigger         if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) {             if ( ! is_null($replacement) )                 trigger_error( sprintf( __('%1$s is deprecated since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );             else                 trigger_error( sprintf( __('%1$s is deprecated since version %2$s with no alternative available.'), $function, $version ) );         }     }      what exactly do I change here? Thanks, J


title: Override parent theme function that is not hooked or in the functions.php file

text: I need to remove a function from the parent theme and replace it within the child theme. The function is called print_meta($meta_box). The function is not pluggable and it located in a random file, not the functions.php file. The function adds options to a metabox that shows in a page or post. I need to add more options but to do this I re-write the function from within the child theme. I don't think I can use remove_filter() as the function is not hooked. I tried this: print_meta($meta_box)               function remove_parent_theme_functions( $meta_box ) {       remove_filter( 'init', 'print_meta' );     }     add_action( 'after_setup_theme', 'remove_parent_theme_functions' );      but I do not know what tag to use. I have tried all kinds. Since the function is vital to setting up the metabox option, I assume that if I successfully removed the function when I use metabox I should get an error or the options should not appear. So far I appear do matter what tag I use. Is this even possible?


title: Which directory in my plugin repo does Wordpress Plugin Directory package?

text: I am a little confused about that. If I want tags/1.2.3 to be available for download instead of the one in trunk, how do I do that? In the FAQ, it says that I should change stable tag to 1.2.3 in trunk/readme.txt. I did that but WPD is still showing the old version in the trunk. I thought it would automatically package tags/1.2.3 after changing stable tag in trunk/readme.txt. Or I am doing it wrong?


title: Don't repeat posts from children in parent taxonomy query

text: I have a query on a page and I want to prevent it from returning posts in the parent term that have one of the child terms of the parent. For example: Parent 1 Child 1   * Post 1   * Post 2 NOT Parent 1   * Post 1   * Post 2 Child 1   * Post 1   * Post 2 Here's the query I'm currently using, but I haven't figured out how to prevent repetition of posts at the parent level.               <?php     $taxonomy = 'seo_resource_topics';     // Gets every "category" (term) in this taxonomy to get the respective posts     $terms = get_terms( $taxonomy );     foreach( $terms as $term ) :        echo '<h3>'. $term->name. '</h3>';            $resourcequery = new WP_Query(array(         'post_type' => 'seo_resource',         'taxonomy' => $taxonomy,         'term' => $term->slug,         'posts_per_page' => -1         ));          if( $resourcequery->have_posts() ): while( $resourcequery->have_posts() ) : $resourcequery->the_post();      ?>      Thanks.


title: Plugin Redirect After Activation

text: I have create a plugin that I want to redirect to the options page of that plugin after the user activates it. This works fine when I test it locally. However, on a live installation of wordpress, it does not behave in the same manner. Here is my code below:                       register_activation_hook(__FILE__, 'srpt_plugin_activate');     add_action('admin_init', 'srpt_plugin_redirect');          function my_plugin_activate() {         add_option('srpt_activation_redirect', true);     }          function srpt_plugin_redirect() {         $srpt_url = admin_url( 'admin.php?page=plugin-options-page/plugin-options-page.php', 'http' );         if (get_option('srpt_activation_redirect', false)) {             delete_option('srpt_activation_redirect');             wp_redirect($srpt_url);         }      This is the substitution to the original uri:               plugin-options-page.php      Thank you for your time if I don't get a chance to thank you later. Wayne Hatter.


title: Load scripts based on post type

text: Is there a nice way to load a js file based on the post type being viewed? I have a supplier which has a map on it but I only want the load the js when a single one is being viewed. I load the script in my functions.php file.


title: How do you create a development site into a subdirectory of the live site?

text: I have a WordPress site at `http://example.com` and I want to create a clone development site at `http://example.com/test`. I want `http://example.com/test` to be its own root URL as well as the live one using the same database for both. How would I go about doing this? Daniel


How do I query_posts and only show results if a custom field is not empty or has a value. I want to put in a url in a custom field and only show these pages if there is a url? current code but I can't figure out the rest: $args = array( 'posts_per_page' => '10', 'post_type' => 'programmes', 'orderby' => 'meta_value_num', 'meta_key' => 'popularityfig', 'order' => 'DESC', );


title: Is there an "Add Page" hook?

text: I'm looking for the action hook corresponding to the click on the "Add page" link. Any idea? Thanks !


title: Notify Author of the post if admin deletes his post and perform some function

text: i am working on a theme in which points are added in user meta when he does a post... it works fine but the problem is when a post is deleted by the admin then the point should be reduced and the author should get intimation . The main problem is getting the author id of the post and doing function after the post is deleted.... the code i am trying is               function deletePointFromUser($post_ID) {     global $wpdb;     $authorid = $wpdb->get_var('SELECT post_author FROM wp_posts WHERE post_id = $post_ID');     $currentPointNumber = get_usermeta($authorid, 'points');          //Delete 1 to the current Point Score     $newPointNumber = $currentPointNumber - 1;       update_usermeta( $authorid, 'points', $newPointNumber);       }     add_action('deleted_post', 'deletePointFromUser');


title: How to stick custom post at the top in search results

text:
I'm trying to stick a post in the search results for the value and meta_key meta_value. If the search results in the post is meta_key - sticky and meta_value - fatured, the display on top of these posts. This is my search.php :               <?php get_header(); ?>          <?php if (is_paged()) $is_paged = true; ?>

              <?php         $is_search = 0;         global $wpdb;         $totalpost_count = 0;         $all_pids = $wpdb->get_var("SELECT group_concat(ID) FROM $wpdb->posts where post_status='publish'");         $all_pids_arr = explode(',',$all_pids);         if($_REQUEST['srch_location'])         {             $is_search = 1;             $srch_location = $_REQUEST['srch_location'];             //$location_pids = $wpdb->get_var("SELECT group_concat(tr.object_id) FROM $wpdb->term_taxonomy tt join $wpdb->term_relationships tr on tr.term_taxonomy_id=tt.term_taxonomy_id where tt.term_id=\"$srch_location\"");             $location_pids = $wpdb->get_var("select group_concat(post_id) from $wpdb->postmeta where meta_key like 'add_location' and meta_value like \"$srch_location\"");             $location_pids_arr = explode(',',$location_pids);             $all_pids_arr = array_intersect($all_pids_arr,$location_pids_arr);         }                   if($is_search && !$all_pids_arr)         {             $all_pids_arr[0] = 'nopost';         }         if($_REQUEST['srch_property_id'])         {             $post_ids_str = $_REQUEST['srch_property_id'];             $sub_cat_sql .= " and p.ID in ($post_ids_str) ";         }else         {             if($all_pids_arr)             {                 $post_ids_str = implode(',',$all_pids_arr);                 if($post_ids_str)                 {                     $sub_cat_sql .= " and p.ID in ($post_ids_str) ";                 }             }            }         $featurecat = get_cat_id_from_name(get_option('ptthemes_featuredcategory'));         if($featurecat)         {             $srch_feature_pids = $wpdb->get_var("SELECT group_concat(tr.object_id) FROM $wpdb->term_taxonomy tt join $wpdb->term_relationships tr on tr.term_taxonomy_id=tt.term_taxonomy_id where tt.term_id in ($featurecat)");             $srch_feature_pids = '';         }         $blogcat = get_cat_id_from_name(get_option('ptthemes_blogcategory'));         $blogcatcatids = get_sub_categories($blogcat,'string');         if($blogcatcatids)         {             $srch_blog_pids = $wpdb->get_var("SELECT group_concat(tr.object_id) FROM $wpdb->term_taxonomy tt join $wpdb->term_relationships tr on tr.term_taxonomy_id=tt.term_taxonomy_id where tt.term_id in ($blogcatcatids)");         }         if($srch_blog_pids && $srch_feature_pids)         {             $sub_cat_sql .= " and p.ID not in ($srch_blog_pids,$srch_feature_pids) ";         }elseif($srch_blog_pids && $srch_feature_pids=='')         {             $sub_cat_sql .= " and p.ID not in ($srch_blog_pids) ";         }elseif($srch_blog_pids=='' && $srch_feature_pids)         {             $sub_cat_sql .= " and p.ID not in ($srch_feature_pids) ";         }         $srch_sql = "select p.* from $wpdb->posts p $post_meta_join where p.post_status='publish' and p.post_type='post'  $sub_cat_sql";         if($srch_feature_pids)         {             $feature_srch_sql = "select p.* from $wpdb->posts p where p.post_status='publish' and p.post_type='post' and p.ID in ($srch_feature_pids)";             $srch_sql = " select * from (($feature_srch_sql) union ($srch_sql))";         }              $totalpost_count = $wpdb->get_var("select count(p.ID) from $wpdb->posts p $post_meta_join where p.post_status='publish' and p.post_type='post'  $sub_cat_sql");         global $posts_per_page,$paged;         if($paged==''){$paged=1;}         $startlimit = $posts_per_page*($paged-1);         $srch_sql .= "  order by p.ID desc limit $startlimit , $posts_per_page";         $post_info = $wpdb->get_results($srch_sql);              ?>

         <?php         if($_REQUEST['s'] == 'viewmore')         {             _e(LATEST_PROPERTIES_TEXT);         }         elseif(is_category() && $_REQUEST['search']=='')         {             echo single_cat_title();         }else         {             //echo __(SEARCH_TEXT). get_search_param();             echo get_search_param();         }            ?>
              <?php if($post_info) { ?>
         <?php         $count=0;         foreach($post_info as $post_info_obj)         {             $count++;             $post = $post_info_obj;             get_property_info_li($post);             if($count%3==0)             {             ?>

             <?php                }         }         ?>
         <?php             }else             {                 _e(NO_PROPERTY_AVAILABLE_MSG);                 if($_POST['search']=='search')                 {                     echo get_search_param();                 }             }             ?>         <?php if($post_info) { ?>
              <?php if (function_exists('wp_pagenavi')) { ?><?php wp_pagenavi(); ?><?php } ?>
         <?php }?>


title: One site, 2 distinct sections: two different top nav menus?

text: I have a site that is in two distinct halves. I'd like the same template to apply to the whole site (from a look & feel perspective), but for each 'half' of the site to have its own top nav menu. No side menus are in use. The home page is going to be a custom page that directs the user to one or other of the two sides. How might I go about achieving this? Many thanks Austen


title: Wordpress Shortcode wrap around div

text:
Is there a way to wrap a wordpress shortcode around a div in a template file? Here is my code:
     <?php do_shortcode('[subscribe]');?>
This is subscription text

      I've also tried
     <?php do_shortcode('[subscribe]');?>
This is subscription text
     <?php do_shortcode('[/subscribe]');?>


title: Loop through all tags & output posts in alphabetical list

text:
I have a bunch of posts that each have multiple tags, and I'm trying to find a way to output all of them on a single page, organized under an alphabetical listing of their respective tags. E.g. if Post1 has the tags A, B and D and Post2 has the tags A, C and D, the output would look like this: > _**Tag A_**   >  Post1   >  Post2 > > _**Tag B_**   >  Post 1 > > _**Tag C_**   >  Post2 > > _**Tag D_**   >  Post1   >  Post2 EDIT: I've gotten it working with categories, but I'd still love to have it work with tags instead. (All of the excluded IDs are because I'm technically using categories for other organization.) The functional code is:               <?php $cat_args = array(         'orderby' => 'title',         'order' => 'ASC',         'exclude' => '26,27,32,52,36,31,42,38,41'         );          $categories = get_categories($cat_args);         foreach ($categories as $category)         {         $catID = $category->term_id;         $catName = $category->name;         echo ''.$catName.'';             global $post; // required             $pArgs = array('category' => $catID,'post_type' => 'shows','orderby' => 'title', 'order' => 'ASC');             $custom_posts = get_posts($pArgs);             foreach($custom_posts as $post) : setup_postdata($post);  ?>
                 <a href="<?php the_permalink(); ?>">                                 <?php the_post_thumbnail("show"); ?>
<?php the_title(); ?>

             <?php endforeach; ?>             <?php } ?>


title: Custom Post Type: How to display all of same taxonomy?

text: Isn't there a permalink structure that will essentially list out all `categories` of a certain `post type`?               function create_faqs_post_type() {         register_post_type( 'faqs',             array(                 'labels' => array(                     'name' => __( 'FAQs' ),                     'singular_name' => __( 'FAQ' )                 ),             'public' => true,             'menu_position' => 5,             'rewrite' => array('slug' => 'the-faqs')             )         );     }     add_action( 'init', 'create_faqs_post_type' );          function create_faq_taxonomy() {         register_taxonomy(             'faqs_categories',             'faqs',             array(                 'hierarchical' => true,                 'label' => 'FAQs Categories',                 'query_var' => true             )         );     }     add_action( 'init', 'create_faq_taxonomy' );      This is the code I've using to register the custom post type `faqs` and then register a taxonomy for it. Isn't there a permalink structure that will essentially automatically list out all `faqs` of a certain taxonomy? Or do I need to create a custom template and query it specifically?


title: get_query_var not works

text: I would like to $_GET a parameter in the URL, for that I read I have to use query_vars. First I added the following lines to functions.php:               function add_query_vars_filter( $vars ){       $vars[] = "getvar";       return $vars;     }     add_filter( 'query_vars', 'add_query_vars_filter' );      after that:               if(get_query_var('getvar')) {         die('DIE');     }      If I type domain.com/?getvar=1, nothing happens. Where is the problem?


title: How to Create clean URL in WordPress custom plugin

text: I am new to wordpress, On the Login page I have one button onclick of the button I am making a cURL request to the Server. The Server response has to come to the other page which is like http://example.com/wordpress/firstdirectory/seonddirectory/index.php. How can I access this particluar index.php ? Please help me.


title: limit the words in the post content and add read more link

text:
As you can see into the code, the routine is to display the post which has an `id` of `266`. Now all I want is to limit the words displayed in the post content of that post. Let's say, I want to limit the words to a number of 300 and then add a read more link. This is the code I got so far:                   $post_id = 266;         echo "

";              $queried_post = get_post($post_id);          echo "
";         echo $queried_post->post_content;         echo '
';              echo "

";         ?>


title: ajax not working in plugin

text: The code below works beautifully outside of WordPress but as soon as I attempt to execute it inside of WordPress nothing happens:               var js = jQuery.noConflict();     js(document).ready(function(){         js('#ClientID').live('change', function() {             js.ajax({                 url     : 'includes/form.php',                 type    : 'POST',                 dataType: 'json',                 data    : js('#myform').serialize(),                 success: function( data ) {                        for(var id in data) {                                     js(id).val( data[id] );                                            }                      }             });         });     });      I have triple checked everything, I've put an alert just above js.ajax and it executes, however if it's inside of the js.ajax({ it doesnt do anything. I'm at a loss at why this isn't working.


title: WP load posts by ajax, count and update every time

text: I have used `Ajax load more` plugin to load my posts. I also need to display the total post count and update it after every time post load and append to the list. Can anyone give me any idea about that.


title: Add link on the top menu of the post table?

text: Is there any way to add links on the top, as pictured below? ![Post list views](http://i1109.photobucket.com/albums/h439/andregolvea/addlink.png)


title: URL mod rewriting for my custom links

text: My Actual link :-               http://nanhai.com/nanhai-overview/162/      I want it like :-               http://nanhai.com/nanhai-overview/xyz/      My code               add_action('init', 'add_actor_url');     function add_actor_url()     {         add_rewrite_rule(             '^nanhai-overview/?([0-9]{1,})/?$',             'index.php?&paged=$matches[1]',             'top'         );     }      This isn't working.


title: Using ajax with wordpress

text: I'm trying to get my head around ajax requests in Wordpress and am finding it hard to understand. Basically I have a form that has a number of steps and you move through these requests using ajax, posting the data each time and hiding and showing the div for the different steps that generally have form fields. Currently have a form that is executed in a plugin with a shortcode. This makes a ajax request in the following way:               function callAjaxsubmit() {       $("#form").serialize();       $.ajax({          type: "POST",          url: "/confirm.php",          data: $("#confirm").serialize(),          success: function(data) {              $( ".page-error-message" ).remove();              $("#step3").html(data);               $("#step2").empty(data);              $('html, body').animate({ scrollTop: 0 }, 'slow');          }       });       return false;     }      I am trying to do this in the frontend, I have looked at this: http://codex.wordpress.org/AJAX_in_Plugins and many tutorials but just not sure how to apply that to this. I guess I need to call a function rather then a url? **Update:** well, got it triggering the fucntion now, though having problems with the post data. I have a lot of fields and before I was doing toe ajax the proper wordpress way i was using serialize() to get all form data, but that doesn't seem to work properly, it seems to output it into one long string. is there a special way to serialize() the post data? **Update2:** sorted the serialize issue with the following:               var formData =  'action=wordpress_function&' + jQuery("#form").serialize();       jQuery.ajax({         type: "POST",         url: MyAjax.ajaxurl,         data: formData,             success: function(data) {                   //do stuff             }       });       return false;


title: Localization For Two Different Regions/Domains with the Same Language

text: I have a site which is based in US (ex. www.example.com). We've been tasked to create a UK/GB version of the site which has it's own domain (ex. www.example.co.uk), but shares the same common pages/posts/backend. About 75% of the pages are the same on both versions but there will be a few sections (like About and Contact) where they are different to account for regional differences. **Example** US site (www.example.com) has 4 Pages:   * **Home**   * **About**   * **Services**   * **Contact** UK Site (www.example.co.uk) also has 3 pages (2 different, 1 the same)   * **Home** (The same as US, but the URL should be www.example.co.uk)   * **About** (Different content, the URL should be www.example.co.uk/about)   * **Services** (The same as US, but URL should be www.example.co.uk/services)   * **Contact** (Different content, the URL should be www.example.co.uk/contact) How do I go about setting up the UK/GB version of the site which use the same backend and most of the same content from the base site, but has a few page differences and different domain?


title: woocommerce display product category on checkout page

text: I am trying to get product category on check out page for showing a special message for shipping for specific category. For this I have created action filter on `woocommerce_available_shipping_methods` in theme functions.php This is my code for getting category here -               global $post;     $args = array( 'taxonomy' => 'product_cat',);     $terms = wp_get_post_terms($post->ID,'product_cat', $args);     print_r($terms);      But it's not giving category on checkout page. Only product ID is one thing I am getting here. Any help please. Thanks is advance


title: Menu Structure with Links failure to update

text: Sorry if this sounds like a newbie question but this is driving me crazy and I can't seem to figure it out. I want to add a link called "About Me" to my Menu that redirects to another website. It seems like a basic concept. I go to Appearance and then Menu Structure and add in a custom link with a title "About Me". It looks like this: http://imgur.com/Q5Wyr7B I save the menu and hypothetically it should show up on the Menu as planned. Here is what happens after I refresh on my blog http://imgur.com/kvRGG84 Still does not update correctly - I can't figure this out, any help would be greatly appreciated. Is there anything obvious I'm doing wrong?


title: Displaying conditional content based on Woocommerce Attributes

text: I'm trying to display different content on product pages based on Woocommerce attributes. I have managed to get the following to work.....               <?php         $suit_enamel_acrylic = get_post_meta($id, '_product_attributes', true);         if (isset($suit_enamel_acrylic['pa_enamel'],$suit_enamel_acrylic['pa_acrylic'])):         if ( ! function_exists( 'woocommerce_template_suitable_enamel_acrylic' ) ) {             function woocommerce_template_suitable_enamel_acrylic() {                 wc_get_template( 'single-product/suitability-both.php' );             }         }         endif;         add_action( 'tubby_single_product_cart','woocommerce_template_suitable_enamel_acrylic', 1 );     ?>      ....but I have 2 attributes and therefore 3 possible bits of content to display. So I've tried this (and variations of it), but with no joy.               <?php         $suit_enamel_acrylic = get_post_meta($id, '_product_attributes', true);             if ( ! function_exists( 'woocommerce_template_suitable_enamel_acrylic' ) ) {                 function woocommerce_template_suitable_enamel_acrylic() {                     if ( isset ( $suit_enamel_acrylic['pa_enamel'],$suit_enamel_acrylic['pa_acrylic'] ) ):                         wc_get_template( 'single-product/suitability-both.php' );                     elseif ( isset ( $suit_enamel_acrylic['pa_enamel'] ) ):                         wc_get_template( 'single-product/suitability-enamel.php' );                     elseif (isset($suit_enamel_acrylic['pa_acrylic'])):                         wc_get_template( 'single-product/suitability-acrylic.php' );                     endif;                 }             }     add_action( 'tubby_single_product_cart', 'woocommerce_template_suitable_enamel_acrylic', 1 );     ?>      I may of course be approaching this the wrong way..


title: Get all posts WHERE custom_field is LIKE value

text: I'm trying to do a MySQL-style search with Wordpress' built-in functions for fetching posts. There's likely a simple way to do this and I'm probably just a little bit off from the solution. We have posts with custom fields in them. This is legacy data imported as a custom post type with custom_fields being the extra data from our older database. The custom fields are setup like this for each post in Wordpress right now:               key = subject     val = Subject One, Subject Two, Subject Three      I'm trying to fetch all posts where custom_field value is LIKE "Subject Two", as an example. There's probably an easy way to do this that just hasn't hit me yet. Thanks for your help! I already have a properly working MySQL query. Just wanted to use Wordpress' functions to handle the query instead of me having to do it manually for this theme view. Here's the working example:               // Get posts that match LIKE this subject     $cft_by_subject = $wpdb->get_results(         "SELECT             wp_posts.ID,             wp_posts.post_title,             wp_posts.post_date,             wp_posts.post_name,             wp_postmeta.meta_value          FROM             wp_posts,             wp_postmeta          WHERE             (wp_posts.ID = wp_postmeta.post_id) AND             (wp_posts.post_type = 'our-custom-post-type') AND             (wp_posts.post_status = 'Publish') AND             (wp_postmeta.meta_key = 'subject') AND             (wp_postmeta.meta_value LIKE '%".$this-is-our-subject."%')          ORDER BY             wp_posts.ID ASC         ",         ARRAY_A     );


title: adding meta tag without plugin

text: Is it possible to add meta title, meta description, meta keywords in every page without installing plugin? My client require not to install plugin. I am curious about this case, all I know is the admin should install the seo plugin in their wordpress to have an insertion of meta.


title: How to trigger $_GET request within admin plugin page?

text:
I have this form in my plugin function:               <form method="get" action="" enctype="multipart/form-data">
         <input type="hidden" name="do_it_hidden" value="run">         <input name="do_it" type="submit" class="button-primary" value="DO IT!">
     </form>      And this php condition earlier in my code:               if (isset($_GET['do_it_hidden'])) {        // some code to execute here     } else {        // just show the form        <form method="get" action="" enctype="multipart/form-data">
            <input type="hidden" name="do_it_hidden" value="run">            <input name="do_it" type="submit" class="button-primary" value="DO IT!">
        </form>     }      But after clicking on the button I am redirected to `wp-admin/options- general.php?do_it_hidden=run&do_it=DO+IT` which is not what I want to happen. After the click I just want to reload the page and check if the get condition is true or not. How to do that? **EDIT:** The problem is that after I click on the button I am redirected to completely different page. My plugin is located here: `options- general.php?page=DD_Awesome_Plugin/DD_awesome_plugin.php` but clicking on the button throws me here: `options-general.php?do_it_hidden=run&do_it=DO+IT`


title: Settings API - adding setting fields dynamically?

text: Is there a way of adding settings fields dynamically? I have my own Settings API options generator just like in Chip Bennet's Oenology Theme, everything works perfect but I can't find a way to create dynamic fields. Here's how I add option fields. ## 1\. First I describe all fields:                function my_options() {         $options = array(              array(                 'id' => '1',                 'title' => '1',                  'type' => 'foo',                 'description' =>  'bar',             ),               array(                 'id' => '2',                 'title' => '2',                  'type' => 'foo',                 'description' =>  'bar',             ),         );             return $options;      }      ## 2\. Then I generate fields:               foreach(my_options() as $field) {         add_settings_field(            $field['id'],            $field['title'],            "something",            "else",            "goes",            "there"         );     }      Then doing:                  <?php $opts = get_option('my_theme_settings_api');         var_dump($opts); ?>      Returns all the fields. But what If want to generate some of the fields "on the fly", eg. based on some other array, just like that:               function my_options() {             // $myarray = some array of elements taken from different source, like json data from other website etc.        $count = 0;        foreach($myarray as $something) {             $count++;             $options[] = array(                 'id' => 'something'. $count,                 'title' => $something['title'],                 'type' => 'type',                 'desription' => $something['description'],             );             return $options;      }      Then I'm getting the fields displayed using do_settings_sections() but I can't save them on admin pages and when I do `var_dump($opts);` just like in example above these options doesn't exist there. Any clues?


title: Not passing correct value to get_post_ancestors?

text: I've got a custom plugin that creates a menu in the sidebar. I need to be able to specify that, if a particular custom post type is current, the menu displays as if it were on a specific page (so that it looks as if the custom post is actually a child of the specified page.) Here's my code:                           global $wp-query;                      $thisid = $wp_query->post->ID;                      $type = get_post_type( $thisid );                      if($type == 'ia_dir'){                     $thisid = '19';                     }                      $thispost = get_post($thisid);                     if (!$thispost->post_parent) {                              // if top-level, display only the subpages of this top level page                         $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$thisid."&echo=0&depth=1");                         if($children) { // Get post ID to display section title only if this top level page has children                             $top_page = $thisid;                         }                          }else{ // if not, display the siblings of all ancestors and the siblings and children of the current post                              $ancestors = get_post_ancestors($thisid);                             // now you can get the ID of the top ancestor of this page;  wp is putting the ids DESC, thats why the top level ID is the last one, and that's why we use "end"                             $top_page = end($ancestors);                             //initialize pagelist variable to hold list of pages to include                             $pagelist = "";                                  //add the immediate children (no grandchildren) of each page in this page's ancestory to the list                             foreach ($ancestors as $ancestor) {                                 $pageset = get_posts('numberposts=-1&post_type=page&post_parent='.$ancestor);                                 foreach ($pageset as $apage) {                                     $pagelist = $pagelist.$apage->ID.",";                                     }                                 }                                  //add any children of the current page to the list                             $pageset = get_posts('numberposts=-1&post_type=page&post_parent='.$thisid);                             foreach ($pageset as $apage) {                                 $pagelist = $pagelist.$apage->ID.",";                                 }                                  //get the list of pages, including only those in our page list                             $children = wp_list_pages('title_li=&echo=0&sort_column=menu_order&include='.$pagelist);                              }      The Issue I'm having is in the "else" section of the "post parent" check. If the post is not specified as "ia_dir" post type, then everything works well, I can get the ancestors and create the list. If it _is_ an "ia_dir" post, however, (i.e., the id is passed manually to $thisid and then to the get_post_ancestors), then I get an empty $ancestors array. I've tried a bunch of different page ids in the type check, and nothing works. I can even specify a page id that I know works fine if I actually visit that page, but when I go to an "ia_dir" post and pass that page id manually, the array is empty. This is really odd. The only thing I'm doing differently is passing a specific manual page id number to $thisid. Why is this not working? Edit: The else statement is functioning either way - I get the $ancestors array always. If I visit post 19 (which is a page), I get the listing because the $ancestors array is populated. However, if I visit an 'ia_dir' post, I get an empty $ancestors array, as if I did not pass '19' to get post ancestors. So I assume I'm passing an incorrect value to get_post_ancestors. But after poring over the WP codex, I can't figure out why passing the post number, either by a string or as as an integer, won't work for me.


title: How do you List all Sidebars in a Metabox

text:
I know this question has been answered many times before, including here where i came from so it'll probably be real simple. I've registered my sidebars as normal               function wmw_sidebars() {         // Register default widgetized areas         $sidebars = array(             'primary' => array(                 'name' => __( 'Primary Widget Area', WMW_ADMIN_TEXTDOMAIN ),                 'desc' => __( 'The primary widget area', WMW_ADMIN_TEXTDOMAIN )             ),             'home' => array(                 'name' => __( 'Homepage Widget Area', WMW_ADMIN_TEXTDOMAIN ),                 'desc' => __( 'The homepage widget area', WMW_ADMIN_TEXTDOMAIN )             ),         );              foreach ( $sidebars as $type => $sidebar ){             register_sidebar(array(                 'name' => $sidebar['name'],                 'id'=> $type,                 'description' => $sidebar['desc'],                 'before_widget' => '
',                 'after_widget' => '
',                 'before_title' => '
',                 'after_title' => '
',             ));         }     }      I'm using the same CMB Metabox Class as fshequin and have the metaboxes showing up in in my posts and pages.                   $meta_boxes[] = array(         'id' => 'WMW_page_layout_meta',         'title' => __( 'Page Layout Options', WMW_ADMIN_TEXTDOMAIN ),         'pages' => get_post_types(),         'context' => 'side',         'priority' => 'default',         'show_names' => false, // Show field names on the left         'fields' => array(             array(                 'name' => __( 'Page Layout', WMW_ADMIN_TEXTDOMAIN ),                 'desc' => __( 'You can choose between a left, right, or no sidebar layout for your page.', WMW_ADMIN_TEXTDOMAIN ),                 'id' => '_layout',                 'type' => 'select',                 'options' => array(                     array('name' => 'Full Width (No Sidebar)', 'value' => 'full_width', ),                     array('name' => 'Sidebar on Left, Content on Right', 'value' => 'left_sidebar', ),                     array('name' => 'Sidebar on Right, Content on Left', 'value' => 'right_sidebar',)                 )             ),             array(                 'name' => __( 'Page Sidebar', WMW_ADMIN_TEXTDOMAIN ),                 'desc' => __( 'Choose the Sidebar to show on this page.', WMW_ADMIN_TEXTDOMAIN ),                 'id'   => '_page_sidebar',                 'type' => 'select',                 'options' => $sidebar_options             )         )     );      But for whatever the reason I cannot seem to get the select options to show. I Placed the array in the same functions file as registering the sidebars but not in a function.               $sidebars = $GLOBALS['wp_registered_sidebars'];          foreach ( $sidebars as $sidebar ){         $sidebar_options[] = array(             'name'  => $sidebar['name'],             'value' => $sidebar['id']         );     }     $sidebar_options = array();      Whatever I try, it is not happening, I changed the variable names to avoid conflict with sidebar register array but no dice. Any help would be MUCH APPRECIATED! \------------------------ EDITED --------------------------------------- Ok I broke it down and went to test each part of it.               $sidebar_ops = array();      $sidebar_ops[] = array(         'name' => __( 'Page Sidebar 1', WMW_ADMIN_TEXTDOMAIN ),         'value' => 'sidebar_1',         );     $sidebar_ops[] = array(         'name' => __( 'Page Sidebar 2', WMW_ADMIN_TEXTDOMAIN ),         'value' => 'sidebar_2',         );            //$GLOBALS['wp_registered_sidebars']       $sidebar_options = array();       foreach ( $sidebar_ops as $sidebar_op ){         $sidebar_options[] = array(             'name'  => $sidebar_op['name'],             'value' => $sidebar_op['id']         );       }      I compiled a bogus array and then used the foreach to test that. The problem appears to be with `$GLOBALS['wp_registered_sidebars']` and using that array. What the proper way to call this?


title: An archive page without post format (just standard post)

text: I'm trying to get posts with not marked with any type of post types (aside, audio etc). But I didn't find any solution to do this. I thought doing this with custom fields but site has a lot of posts...


title: How much faster is a tax query than a meta query?

text: I'm building a portfolio post type and I want to have a way to mark certain pieces as featured, some as normal (default) and others as archived. The pieces would only ever be one of these 3. Because of the singular value it makes sense to me that this be post meta. But, i've read that querying by taxonomy is supposedly faster, so I've built a solution where featured, normal and archived are 3 terms in a custom taxonomy. Should I stick with the taxonomies for this case, or switch to post meta. I realize that is an opinion question, so to make it more specific: is the query speed improvements worth the added complexity of creating a custom taxonomy and modifying it so that it can only ever have 1 term? Is a taxonomy where you can only have 1 term defeating the purpose of a taxonomy in the first place?


title: How to find time last viewed?

text: I want to run an update script on pages that haven't been viewed and updated within X days. I'm using post meta to cache some related RSS feed data, and I want it updated once a week or two, but only if the page has actually been viewed within the last two or three weeks, bots included. Is there an internal counter or whatnot that has this data, or am I going to have to build something that stores the UNIX timestamp as post meta upon page view?


title: Is there a plugin to make attaching images easier?

text: I am using the "attach" feature in the media library to link a set of images to specific pages. Our custom theme displays these attached images in a particular way. ![alt text](http://i.stack.imgur.com/iqj50.png) We are setting up Wordpress as a CMS for a client and we don't want them to have to attach images to posts / pages this way because it feels clunky to be editing page, then forcing the user to go to the media section and attach images to that page one by one. I would really like our client to be able to attach a set of images to a post or page in a manner similar to the "featured image" feature. The user should also be able to add, remove and sort the images without leaving the page. ![alt text](http://i.stack.imgur.com/i0xxi.png)


title: How to remove admin main menu name repetition

text: I have added an admin menu using add_menu_page. When there is a sub menu with add_submenu_page, The main menu name is repeating. How to remove this repeating menu ? ![wordpress admin sidebar menu](http://i.stack.imgur.com/KCkE9.jpg) This is my code               add_action('admin_menu', 'add_my_menu');     function add_my_menu(){         add_menu_page( 'Main Menu', 'Main Menu', 'manage_options', 'main-menu-settings', 'main_menu_settings');         add_submenu_page( 'main-menu-settings', 'Sub Menu', 'sub menu', 'manage_options', 'sub-menu', 'sub_menu_settings');     }


title: get_meta_data within a loop

text:
I'm trying to make a simple widget that displays a list of posts, and is followed by some metadata from each post. Here is my code: `$eventdate` contains the metadata i need to retrieve.               query_posts('');          if (have_posts()) :          echo "
";         while (have_posts()) : the_post();              $eventdate = get_post_meta($post->ID, 'event-date', true);             echo "
".get_the_title()." - ".$eventdate."
";         endwhile;         echo "
";     endif;      wp_reset_query();      I read an old post on the wordpress support forums about custom loops like this, and I'm fairly certain that I'm not calling the $post_id properly, because if I manually insert a post_id it calls the correct data.. but either way I'm unsure where to go from here. Any help would be appreciated.


title: How to display custom post type category?

text:
I have a custom post type taxonomy created:               function wps_register_paneltype_tax() {         $labels = array(             'name' => _x( 'Panel Category', 'taxonomy general name' ),             'singular_name' => _x( 'Panel Category', 'taxonomy singular name' ),             'add_new' => _x( 'Add New Panel Category', 'Panel Category'),             'add_new_item' => __( 'Add New Panel Category' ),             'edit_item' => __( 'Edit Panel Category' ),             'new_item' => __( 'New Panel Category' ),             'view_item' => __( 'View Panel Category' ),             'search_items' => __( 'Search Panel Category' ),             'not_found' => __( 'No Panel Category found' ),             'not_found_in_trash' => __( 'No Panel Category found in Trash' ),         );              $pages = array( 'panels' );              $args = array(             'labels' => $labels,             'singular_label' => __( 'Panel Category' ),             'public' => true,             'show_ui' => true,             'hierarchical' => false,             'show_tagcloud' => false,             'show_in_nav_menus' => true,             'rewrite' => array('slug' => 'panel-type'),          );         register_taxonomy( 'panel_type' , $pages , $args );     }     add_action( 'init' , 'wps_register_paneltype_tax' );      And I am calling it here:               function hac_class_template() {              // Query Arguments         $args = array(             'post_type' => 'panels',             'category' => 3,             'posts_per_page' => 3         );                // The Query         $the_query = new WP_Query( $args );              // Check if the Query returns any posts              if ( $the_query->have_posts() ) {                  // Load the Panels ?>                      <?php                 // The Loop                 while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                              <?php                               // The Classes's Image                         the_post_thumbnail( 'wpbs-class' );                                   ?>
                             <?php echo the_title( '
', '
' ); ?>                             <a class="button" href="<?php echo get_permalink(); ?>" title="Learn More">Learn More

                               <?php endwhile; ?>                <?php }              // Reset Post Data         wp_reset_postdata();       But I can't get it to display just that one category, it shows all. Any help? Thanks


title: PHP Syntax Error on get_posts

text:
I have the following coding:               <?php             global $post;             $args = array( 'numberposts' => 8);             $myposts = get_posts( $args );             foreach( $myposts as $post ) :  setup_postdata($post);             echo ''.the_title().'
';             endforeach;     ?>      Dreamweaver is highlighting a potential syntax error on line 6 & 7\. I'm sure it's something very very simple but can someone point me in the right direction to solve this error please?


title: action for 'contact form 7'?

text: I have a page outside of my standard Wordpress site and I want to use my header and footer on it so it looks like it's part of my site. In my footer, I have a CF7 form that I'm trying to replicate. However, in the action, it says `/#wpcf7-f1-t1-o1` however I'm not sure where that is in the plugins folder. Anybody know? Or is there an alternate action I can put in there?


title: Create a front page template and separate page for posts?

text: I'm building a WordPress theme. I need two type of pages, one is home page which will display on www.example.com. I also need a list of all my posts on www.example.com/blog/, but I need both in one WordPress theme. Is there the right way to use home.php or front-page.php? If no then please suggest me the right way to solve my problem. If yes then please suggest me how can I see all my blog post list on www.example.com/blog/


title: How to create virtual pages with information from user meta profile fields?

text:
Dave Jesch on his site presents a way to create virtual pages in WordPress. Dave created a class " _to do all the heavy lifting_ ", as he says. I think, for my purposes this class not require changes, so I do not put it here. Also, Dave created a function (see bellow) that calls the above mentioned class to create a virtual page when is needed. I tested this method and it just works. What I want, is to use the Dave's class and function to put on my site a list of department members with links to their virtual pages with some content from their profiles. Pages must be virtual, so I do not have to create for each new member a real page, it must be created automatically (virtually) from his profile. This is how I create and save some extra user profile fields:               /* Add Extra Fields to the User Profile */     add_action( 'show_user_profile', 'extra_user_profile_fields' );     add_action( 'edit_user_profile', 'extra_user_profile_fields' );          function extra_user_profile_fields( $user ) { ?>
<?php _e("Academic", "blank"); ?>

           <?php _e("Teaching position"); ?>	                      <input type="text" name="teaching_position" id="teaching_position" value="<?php echo esc_attr( get_the_author_meta( 'teaching_position', $user->ID ) ); ?>" class="regular-text" />
           <?php _e("Put here your teaching position"); ?>

     }          /* Save Extra User Profile Fields */     add_action( 'personal_options_update', 'save_extra_user_profile_fields' );     add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );          function save_extra_user_profile_fields( $user_id ) {        if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }        update_user_meta( $user_id, 'teaching_position', $_POST['teaching_position'] );     }      This is the Daves's function that calls his class to create virtual pages:               function dj_create_virtual()     {         $url = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');         if ($url == 'dave-virtual-page') {            $args = array('slug' => 'dave-virtual-page',               'title' => 'Dave\'s Virtual Page',               'content' => "This can be generated content, or static content
               Whatever you put here will appear on your virtual page.");            $pg = new DJVirtualPage($args);         }     }     add_action('init', 'dj_create_virtual');      And this is how I display currently the members list of specific department on my site (with a shortcode):               add_shortcode( 'list_of_members', 'members_listing' );     /* usage: [list_of_members department = 'psychology'] */          function members_listing( $department ) {             $members = get_users( array( 'meta_key' => 'department', 'meta_value' => $department ) );              usort($members, create_function('$a, $b', 'return strnatcasecmp($a->last_name, $b->last_name);'));             echo '

';        foreach ( $members as $member ) {           echo '
';           echo get_avatar($member->ID);           /* Bellow I want to put their names in a link to their virtual pages with some information from their profiles */           echo '
' . $member->first_name . ' ' . $member->last_name;           echo '

';        }        echo '

';     }      Now I want, with the Dave's class and function, to put in my (last) `members_listing` function the members names in links to their virtual pages with some information from their profiles. How to do this? **EDIT** Here are the functions in question as I have used them finally (many thanks to @g-m!):               function dj_create_virtual() {        $url = trim( parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ), '/');        if ( strpos( $url, 'users/' ) === 0 ) {           $user_nicename = str_replace('users/', '', $url );           $user = get_user_by( 'slug', $user_nicename );           $user_info = array_map( function( $a ){ return $a[0]; }, get_user_meta( $user->ID ) );           $args = array(              'slug' => 'users/' . $user_nicename,              'title' => $user_info['first_name'] . ' ' . $user_info['last_name'],              'content' => get_avatar( $user->ID ));           if( !empty( $user_info['teaching_position'] ) ) $args['content'] = $args['content'] . '
Teaching position
' . $user_info['teaching_position'];           /* heare are some more user meta profile fields */           $pg = new DJVirtualPage($args);        }     }     add_action('init', 'dj_create_virtual');      and the `members_listing` function:               add_shortcode( 'list_of_members', 'members_listing' );     /* usage: [list_of_members department = 'psychology'] */          function members_listing( $department ) {        $members = get_users( array( 'meta_key' => 'department', 'meta_value' => $department ) );         usort( $members, create_function( '$a, $b', 'return strnatcasecmp($a->last_name, $b->last_name);' ) );        echo '

';        foreach ( $members as $member ) {           echo '
';           printf( '
%s', home_url( '/users/' . $member->user_nicename ), get_avatar( $member->ID ) );           printf( '
%s', home_url( '/users/' . $member->user_nicename ), $member->display_name );           if( !empty( $member->teaching_position ) ) { echo '
' . mb_convert_case( $member->teaching_position, MB_CASE_LOWER, 'UTF-8' ); };           echo '

';        }        echo '

';     }


title: Sort query by author: 1 author, then others

text: I have a post type called 'article' and on the article archive page i'd like to show all the articles, sorted by author.               function kia_adjust_the_query( $query ) {              // change posts_per_page param         if ( is_post_type_archive( 'article' ) ) {              set_query_var('posts_per_archive_page',-1);              set_query_var('order','ASC');              set_query_var('orderby','author');         }               }     add_action('pre_get_posts', 'kia_adjust_the_query');      the above sets up the basic query adjustments. however, the blog is principally that of 1 author, say "Bob"... so ideally i'd like to pull all of the posts by Bob out into a first column for emphasis, and then continue on through the other authors. is this possible to do during the while loop somehow or do i need 2 separate queries? //EDIT for added complexity: i usually try to strip my questions down to the minimum, but in this case i think i went too far my client is the sole author on his blog. however, he uses a meta field ('guest_author') and filters get_the_author to create a pen name for guest posts that he didn't actually write, without creating accounts for other users. can i sort the author posts that are his posts (so no value in the meta field) and then, by the other authors (same author ID, but different 'guest_author' values). if this isn't possible, would the best way to approximate it be to create dummy accounts for the other authors?


title: Blank child theme - functions.php problem

text: I've created a child theme, and moved all the modifications I had in the parent theme functions.php into the child theme's functions.php. Now if I preview the theme, it is blank. I've got three things - changing the number of tags displayed in the cloud, hiding a product category and displaying a Google books preview. I can't see any errors in this code, and it works when it's in the parent. I would appreciate any help, I'm totally stuck!               <?php          function change_tag_cloud_widget() {         $args['number'] = 15;         return $args;     }     add_filter( 'widget_tag_cloud_args', 'change_tag_cloud_widget' );          add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );          function custom_pre_get_posts_query( $q ) {          if ( ! $q->is_main_query() ) return;     if ( ! $q->is_post_type_archive() ) return;     if ( ! is_admin() ) {          $q->set( 'tax_query', array(array(     'taxonomy' => 'product_cat',     'field' => 'slug',     'terms' => array( 'hands-on' ), // Don't display products in the hands-on category on the shop page     'operator' => 'NOT IN'     )));     }          remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' );              }          add_shortcode('gbooks', 'sc_embed_google_books');     function sc_embed_google_books( $atts ){         extract(shortcode_atts(array(                 "id" => '',                 "width"  => '600',                 "height" => '900',         ), $atts));         return '<script type="text/javascript" src="http://books.google.com/books/previewlib.js"></script>         <script type="text/javascript">         GBS_insertPreviewButtonPopup("'.$id.'", '.$width.','.$height.');         </script>';     }               function get_google_tag( $isbn_metadata ) {     return (         /* '<span class="post-meta-key">Preview: </span>' . */         '<script type="text/javascript" src="http://books.google.com/books/previewlib.js"></script>' .         '<script type="text/javascript">' .         'GBS_insertPreviewButtonPopup(\'ISBN:' . $isbn_metadata . '\');' .         '</script>'     );     }          ?>