Using 1 taxonomy for multiple post types?

I previously declared the taxonomy " artist " for a profile post type. Now i am creating a CD post type and would like to use the same artist list from the profile post type That is one example if i get a solution i will be using this to share a number of other taxonomies among-st post types :D Thanks in Advance. P.S. I use JW Custom Post Types https://github.com/JeffreyWay/Easy-WordPress- Custom-Post-Types/


How to have featured image show in standard RSS Widget

Is there a way of showing featured images in the standard RSS Widget in WordPress?


Adding a custom button to WordPress Add Post (and Edit Post too) screen, that can save the post

I am writing a plugin that hides the publish box from authors, so that I can have them click on a button in a custom meta box I created, to save their post. (This is not the sole purpose of the plugin, rest, I can't share. But this step is needed to do the rest.) I want WordPress to save the post to DB as it normally would, when I click on that button. How do I invoke WordPress' post save action from a custom button?


How to Display Custom Post Type's Gallery (images ) in Through WP_Query

I am trying to load an Image Slider images from a Custom Post Type image Gallery Feature. For example let say I have an Custom Post Type called banner which I can load images to it's Gallery and I have an HTML code like this:

         slide 1

         slide 1

      Can you please let me know how I can use the custom WP_Query to retrive the images from the custom post and load them into slider instead of above HTML? So far I have done something like this but it is not displaying any image!               <?php     $args = array( 'post_type' => 'banner');     $loop = new WP_Query( $args );     while ( $loop->have_posts() ) : $loop->the_post();         $gallery = get_post_gallery_images($post);     foreach( $gallery as $image ) {            echo '
';            echo '';            echo '
';         }     endwhile;     ?>      **Update:** The Result of `var_dump($POST)` ![enter image description here](http://i.stack.imgur.com/oZva3.png)


Custom select box meta field

For my custom post type i needed to add the Attribute Meta box, but i wanted to add an extra field to it. So here i have copied the Page Attribute meta box code and added my select options, but i need help rewriting the 'Module Type' select box so it functions properly when saving the page.                function page_attributes_meta_box2($post) {           $post_type_object = get_post_type_object($post->post_type);            if ( $post_type_object->hierarchical ) {                $pages = wp_dropdown_pages(array('post_type' => $post->post_type, 'exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column'=> 'menu_order, post_title', 'echo' => 0));                if ( ! empty($pages) ) {        ?>
<?php _e('Parent') ?>
        <?php _e('Parent') ?>        <?php echo $pages; ?>        <?php                } // end empty pages check            } // end hierarchical check.            ?>
<?php _e('Order') ?>

<?php _e('Order') ?><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr($post->menu_order) ?>" />

<?php if ( 'page' == $post->post_type ) _e( 'Need help? Use the Help tab in the upper right of your screen.' ); ?>

<?php _e('Module Type') ?>
        <?php _e('Module Type') ?>        <select id="_cnote_module_page_type" name="_cnote_module_page_type">             <option value="default">Default</option>             <option value="parent">Parent</option>             <option value="chat">Chat</option>        </select>        <?php        }          add_action('add_meta_boxes','add_post_template_metaboxr');     function add_post_template_metaboxr() {         add_meta_box('postparentdiv', __('Post Template'), 'page_attributes_meta_box2', 'module', 'side', 'high');     }      **note that i have not renamed everything yet, theres a lot of copy and pasting in here


Automate post update for all posts?

I have managed to fill custom fields with certain predefined values of all my post, but the changes don't take effect until I manually update the posts. Example:               // Predefined variable and value          $page_description = "This is a sample value that will be put (echo $page_description) into a custom field";               // Echo Variable into Custom Field          echo '<input type="text" name="custom-field-name" value="'.$page_description.'" />';      The above example works as I expected. It inserts the $page_description value into the custom field; so when I go to edit that post I will see the variable value. The issue is that in the current edit screen, without updating yet, if I look at the post on the front end of the site, that custom field has not been updated/saved with that variable value, even though I see in the edit screen. It is not until I update the post that the variable value is saved for good. I have 1,800+ posts that need to be updated. I need a solution to update them. Someone suggested using ajax to auto-update all existing posts so that the new custom field values are saved to the posts. I read an article about it, but not sure how to do it. Or if there is a plugin out there that I can use. I would like some assistance with this. Thanks for any input on this! **UDPATE 6-23-11:** This is the coding I inserting into my theme's custom field file:               $postauth = get_user_meta($post->post_author, 'nickname', true);          /********** UPDATE ALL POST FIELDS Function **********/              //check if data exists              if ($postauth){              //if it exists just echo it out                 echo $postauth;              }else{              //if not , update the post meta with your default value and the echo it out.            $update_author = get_user_meta($post->post_author, 'nickname', true);            update_post_meta($post->ID,'nickname',$update_author);            echo $update_author;         }              /********** End UPDATE ALL POST FIELDS Function **********/      I after inserting the code and adjusting my terms, I saved the file and refreshed my site. The code should update a custom field (Author) for all posts that belong to an author and save the author's nickname into that field. I have a basic search option separately installed that is set to search custom fields. So I tested if the update worked by searching for the nickname of a given author who has 8 posts published. Three of the eight were manually updated and they showed up in the custom field search I did for the author's nickname. Now the other 5 posts did not come up in the search results, which lets me know that all the posts were not updated. Are there any solutions to this? **UPDATE 6-24-11:** I have been searching everywhere in my theme to figure out where to place the solution provided by Bainternet, but no success. I am using the couponpress theme v6.1.4. I have placed the code below in: _header.php, _single.php, system_customfields.php.               //check if data exists. This is checking if the predefined field is empty or not.                                 if ($bizname_field != ''){                                      //if it exists just echo it out                                     echo 'existing value';                                      }else{                                      //if not , update the post meta with your default value and the echo it out.                                      // New Variable Value                                      $newvalue = 'New value here';                                      update_post_meta($post->ID,'custom-field-name',$newvalue);                                      echo $newvalue;                                 }       I am going around in circles and would appreciate some help. Thanks a lot.


wp_insert_post - How do I prevent incremental numbers on child pages?

I'm using `wp_insert_post` to dynamically generate child pages for a given page using a predefined array of values. The goal is to give each child page the same slug. For example, clicking "Generate Pages" on "example-page" loops through `wp_insert_post` and creates two child pages:               /example-page/about     /example-page/contact      The trouble is that WordPress is adding numbers after the slug on the child pages (because similar child pages have already been created for a different page). My guess is that it's doing a check on slug availability irrespective of the parent/child relationship. I've experimented with trying to run `wp_update_post` after the insertion but to no avail. Any ideas? **UPDATE** Here's a code sample:               $new_page = array(         'post_title' => $child_page["title"],         'post_parent' => $parent_id,         'post_name' => $child_page["slug"],          'post_content' => $child_page["content"],         'post_status' => 'publish',         'post_type' => 'territory'     );           $new_page_id = wp_insert_post($new_page);      Explanation: I am looping through an array of `$child_pages`, in which I've set the unique values for title, slug, and content.


Trigger language change in Wordpress

I have read this: http://blog-en.icanlocalize.com/installing-wordpress-for- multiple-language-blogs/how-to-localize-wordpress-themes-and-plugins-with- gettext/ Right now, I have qTranslate installed because I could not find a way to "Trigger" to switch to fr_FR. I use qTranslate to "switch" by using `http://mysite.com/page?lang=fr` So, the question is, how do you "trigger" the switch to another language without manually doing the following: `define ('WPLANG', 'fr_FR');`? Best Regards, W


PHP code to call image Caption, Alternative Text, and Decription?

Is there a Wordpress PHP code to call an image Caption, Alternative Text, and Decription? I have several images with Titles, captions, alt text and Description fields filled and would like to display these on the image. I know how to call the image title:
<?php the_title(); ?>
      How to do so with the other fields? Here's a sample of the rest of my code (this is for a slideshow)
              <?php if ( get_post_meta( $post->ID, "slide_url_value", $single = true ) != "" ): ?>         <a          href="<?php echo get_post_meta( $post->ID, " slide_url_value ", $single = true ); ?>"         title="<?php the_title(); ?>">             <?php the_post_thumbnail( 'featured-slide', array( 'title' => get_the_title() ) ); ?>                       <?php else: ?>         <?php the_post_thumbnail( 'featured-slide', array( 'title'=>get_the_title() ) ); ?>         <?php endif; ?>
<?php the_title(); ?>

      Is there a way to use `<?php the_field(''); ?>` or id slugs?


How to scroll through post thumbnails?

I have two custom post types that each have a post thumbnail. On my homepage, I have a section that I want to display the post thumbnail of each of the custom post types (http://i.imgur.com/pmZozrF.jpg). I would also like to allow users to scroll through each image by clicking on a "next" or "previous" button. If I use next_post_link(); the link will open up the next post's actual post page but I need it to only show the next posts post thumbnail. Here is my loop:               $query = new WP_Query( array( 'posts_per_page' => 4, 'post_type' => array( 'client', 'graduate' ) ));     if ( $query->have_posts() )     {         while ( $query->have_posts() )         {             $query->the_post();             if ( has_post_thumbnail() ) {                 the_post_thumbnail();             }              ?>
<?php the_title(); ?>
             <?php         }         wp_reset_postdata();     }     else     {         // show 404 error here     }


Generate Shortcodes by Taxonomy

Check this code:                 function slide_group() {                                 register_taxonomy('Group', 'slides', array(                'hierarchical' => true /*visualizza come le categorie*/, 'label' => 'Group',                'query_var' => true, 'rewrite' => true));}          add_action('init', 'slide_group', 0);               function square_slider_template() {                      // Query Arguments                 $args = array(                             'post_type' => 'slides',                             'posts_per_page'    => 5                         );                        // The Query                 $the_query = new WP_Query( $args );                      // Check if the Query returns any posts                 if ( $the_query->have_posts() ) {                      // Start the Slider ?>

                              <?php                                // The Loop                         while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                                  <?php // Check if there's a Slide URL given and if so let's a link to it                             if ( get_post_meta( get_the_id(), 'square_slideurl', true) != '' ) { ?>                                 <a href="<?php echo esc_url( get_post_meta( get_the_id(), 'square_slideurl', true ) ); ?>">                             <?php }                                  // The Slide's Image                             echo the_post_thumbnail();                                  // Close off the Slide's Link if there is one                             if ( get_post_meta( get_the_id(), 'square_slideurl', true) != '' ) { ?>                                                              <?php } ?>
                         <?php endwhile; ?>

                      <?php }                      // Reset Post Data                 wp_reset_postdata();             }              // Slider Shortcode                  function square_slider_shortcode() {                 ob_start();                 square_slider_template();                 $slider = ob_get_clean();                 return $slider;             }             add_shortcode( 'slider', 'square_slider_shortcode' );      This code is creating a slider based on "slider" custom post type using the thumbnail image. I created a custom taxonomy too.   What I would do is create a "foreach" loop based on the taxonomy-term that create a shortcode with the taxonomy-term name ( [design], [develop] etc.. OR [slider type=design], [slider type=develop] ) that contain only the posts of the taxonomy_term.   For example, [design] contains/displays only the post with design taxonomy, [develop] contains/displays only the post with develop taxonomy etc.         # EDIT/UPDATE #2   I'm at this step:                     function square_slider_shortcode( $atts = array(), $content = '' )     {         $atts = shortcode_atts( array(                             'type'      => '00', // default type                         ), $atts, 'square_slider' );              // Sanitize input:         $pid = sanitize_title( $atts['type'] );              // Output         return square_slider_template( $pid );         }          add_shortcode( 'slider', 'square_slider_shortcode' );          function square_slider_template( $pid = '' )     {     $args = array(         'post_type'       => 'slides',         'p'           => $pid,               );  ?>          <?php         // The Query         $query = new WP_Query( $args );              // Check if the Query returns any posts         if ( $query->have_posts() ) {              // Start the Slider ?>

                      <?php                        // The Loop                 while ( $query->have_posts() ) : $query->the_post();                     for ($i = 1; $i <= 10; $i++):                         $num_slide="slide_" . $i;                         $slide = get_field($num_slide);                         ?>                                                               <?php if (!empty($slide)): ?>
<img src="<?php echo $slide; ?>">
                         <?php endif; ?>                 <?php endfor; ?>                  <?php endwhile; ?>

              <?php }              // Reset Post Data         wp_reset_postdata();     }      I solved in this way, I create a loop with the slides and I'll create the slider. It's not a smart way or the proper way, but it works :)   UPDATE: everything works but the slider appear **always** at the top of the page, independently of the position inside the editor.   I tried to put it inside another shortcode like `[one_third][slider type="98"][/one_third][one_third_last]casual words[/one_third_last]` but it appear outside the div tag like you can see in the image ![enter image description here](http://i.stack.imgur.com/umMLx.png)


How to set the jpg image compression for specific thumbnail sizes?

This question was asked on Set JPEG compression for specific custom image sizes and answered very nicely by Ahmad M I'd of course comment to that thread but I don't have 50 point reputation... The code I'm using is pretty much the same as in Ahmed's answer, but the problem I'm still facing is if I'm using a specific thumbnail size in my theme. For example I have a grid of smaller boxes in my frontpage and they have a 260px wide images. If the uploaded image is originally smaller than what the image would get resized to by the function by Ahmed, it of course won't resize (nor should it) but also it doesn't compress the image. **Example:** If I upload a 1200x800 image and use it in my front page, it gets resized to to smaller size (520px wide, which is 260px *2 for retina displays) and the quality is compressed. Nice! But if I upload an image that is already let's say 500px wide (less than 520px), it won't get resized but it won't get compressed either. Very quickly my clients web site has lots of images with big file size and loads slowly. How should I change this function to always compress the images to whatever quality I want the thumbnails to be, regardless of their original dimensions? Code:                   //featured-image support         add_theme_support( 'post-thumbnails' );               add_image_size( 'newsbox-thumb', 520, 9999 ); // masonry news box-images =260px (520 retina) and unlimited height         add_image_size( 'fprelease-thumb', 112, 9999 ); // fprelese feed logo, 56px (112px retina)                   // http://wordpress.stackexchange.com/questions/74103/set-jpeg-compression-for-specific-custom-image-sizes         // set the quality to maximum         add_filter('jpeg_quality', create_function('$quality', 'return 100;'));              add_action('added_post_meta', 'ad_update_jpeg_quality', 10, 4);              function ad_update_jpeg_quality($meta_id, $attach_id, $meta_key, $attach_meta) {              if ($meta_key == '_wp_attachment_metadata') {                  $post = get_post($attach_id);                  if ($post->post_mime_type == 'image/jpeg' && is_array($attach_meta['sizes'])) {                      $pathinfo = pathinfo($attach_meta['file']);                 $uploads = wp_upload_dir();                 $dir = $uploads['basedir'] . '/' . $pathinfo['dirname'];                      foreach ($attach_meta['sizes'] as $size => $value) {                          $image = $dir . '/' . $value['file'];                     $resource = imagecreatefromjpeg($image);                          if ($size == 'newsbox-thumb') {                         // set the jpeg quality for 'newsbox-thumb' size                         imagejpeg($resource, $image, 60);                     } elseif ($size == 'fprelease-thumb') {                         // set the jpeg quality for the 'fprelease-thumb' size                         imagejpeg($resource, $image, 85);                     } else {                         // set the jpeg quality for the rest of sizes                         imagejpeg($resource, $image, 80);                     }                          // or you can skip a paticular image size                     // and set the quality for the rest:                     // if ($size == 'splash') continue;                          imagedestroy($resource);                 }             }         }     }


get_post_meta of multiple posts?

I'm trying to get the key values for multiple posts with get_post_meta but am having no luck so far. In short, I have a function that adds 'votes' and 'thevoters' to each post. I want to check to make sure if someone's UserID is in any one of the 'thevoters' fields (spanning across multiple posts) they will not be able to vote again. The following query gets the value of a specific post. I need to get the values across all posts with that key.               $voters = get_post_meta($id, 'thevoters', true);      My SQL query is:               SELECT * FROM `carcrazy_postmeta` WHERE meta_key='thevoters'      I am using this voting code as a reference - http://bavotasan.com/tutorials/simple-voting-for-wordpress-with-php-and- jquery/ Any ideas?


How to exlude posts that have certain meta_value?

I want to exclude some posts from the home page. So I want to use meta data, and filter all posts that are signed by meta_value=0. Like this:               $args = array(     'posts_per_page'=>28,     'meta_query' => array(     array(         'key' => 'show_on_home',         'value' => '0',         'compare' => 'NOT LIKE'         )     )                        );     $query = new WP_Query( $args );                               So, if I sign some post with meta_key=0 it will not apear.   The problem is that I have a lot off posts that don't have meta data at all, and I don't want to filter them.


Change post query onclick

I'm trying to build kind of a filtering system for the events displayed on my website. I've made a custom post type 'Event', with a 'City' field. On my 'calendar' template page, I'm gathering all the events like this :               $querystr = "         SELECT *         FROM $wpdb->posts wposts, $wpdb->postmeta metastart         WHERE wposts.ID = metastart.post_id         AND metastart.meta_key = '_cp_date'         AND wposts.post_type = 'Event'         AND wposts.post_status = 'publish'         AND metastart.meta_value >= DATE_FORMAT(CURRENT_DATE(), '%m/%d/%Y')         ORDER BY metastart.meta_value ASC         ";     $events = $wpdb->get_results($querystr, OBJECT);      And then, the loop displaying them. What I would like to do, is to have buttons that would, on click, run another SQL query with a match on the city, and then replace the content with the result of that new query. I'm wondering what would be the "best" way to achieve this. Wouldn't ajax be my solution ?


What is wrong with this Shortcode? I get it in a wrong place inside the content

Hi to the community,   i try to build a shortcode that prints the Creative Commons logo and some text, everything is working fine except that i put the shortcode at the end of the post but the shortcode goes to the top of the post content, i use the code bellow:               <?php // Creative Commons License Shortcode          function creativecommons( $atts, $content = null )     {         extract( shortcode_atts( array(           'type' => '',           'code' => '',           ), $atts ) );          { ?>

             <img src="<?php bloginfo('template_directory'); ?>/images/cc.png" width="32" height="32" alt="Creative Commons License" />

<?php echo $type ?>
             <?php echo $code ?>

     <?php }         return;     }     add_shortcode('cc1', 'creativecommons');     ?>      I'm missing something here or something else have to do with my problem?   Thanks a lot,   Philip


Redirection to taxonomy posts list after post submit.

I am able to redirect the user back to the edit.php admin page after they have successfully created/updated a post. However, is it possible to redirect them to the taxonomy term posts page? This way, when a user creates a post, they will be redirected to the admin post list page that only shows that post and others with the same taxonomy term. Any help is appreciated. Thanks!


Is there a specific term for Plugins that are specified in a Wordpress Post using Comments?

What are plugins that are added to a post or page using comments...for instance I am aware of the   `<!--nextpage-->` tag, (it's part of Wordpress not a plugin...) but I'm assuming that there may be plugins out there with functionality that is placed in a post in a similar manner. What is the name of plugins that operate in this manner?


Wordpress Plugin for Maps of specific Tweets?

Is there a Wordpress Plugin that you can give it a list of old tweets (specified by url or tweet number (for example: http://twitter.com/#!/leeand00/status/20215977534820353) and put them on a map, which will slowly move between them (in demo mode) and then allow the user to click on those tweets? (Just figured I'd check before implementing one) P.S. Can someone please tag this post with "Google Maps" or "Maps" please.


How do you remove a Category-style (hierarchical) taxonomy metabox?

I was wondering if someone can help me with this. I'm currently following Shibashake's tutorial about creating custom meta-boxes that include taxonomy selection here: http://shibashake.com/wordpress-theme/wordpress-custom- taxonomy-input-panels . They show how to remove the standard metabox Wordpress automatically creates for taxonomies using the remove_meta_box function. Only problem is that the function for some reason doesn't seem to work on taxonomies that work as categories ie ones where the hierarchical option is set to true. I know I have the function working because the ones set up as tags disappear easily enough. I can't if it just isn't possible or if there is something special I need to add in one of the parameters to make it work. Example:               $args = array(          'hierarchical' => false,           'label' =>'People',           'query_var' => true,           'rewrite' => true            );     register_taxonomy('people', 'post',$args);          remove_meta_box('tagsdiv-people','post','side');      That works fine. If I set hierarchical to 'true, however, the meta box stays put. Can anyone shed some light?


Auto-add paragraphs to custom field?

hey guys, is it possible to format text in a custom field input box automatically with paragraphs? e.g. like the normal text-widget that has the option to say "auto-add paragraphs" when there is a linebreak. I just want my blogauthors to spare typing   at the end of every line in a custom field! is there a way to do so? update:               <?php if (have_posts()) : ?>                     <?php while (have_posts()) : the_post();                         $sidebar_title = get_post_meta($post->ID, 'sidebar-title', $single = true);                         $sidebar_text = get_post_meta($post->ID, 'sidebar-text', $single = true); ?>                              <?php if ( $sidebar_title !== '' && $sidebar_text !== '' ) { ?>

<?php echo wpautop($sidebar_title, $br); ?>
                                 <?php echo wpautop($sidebar_text, $br); ?>
                         <?php } ?>                          <?php endwhile; ?>                 <?php endif; ?>


user Profile meta value as custom field

I would like to add custom fields automatically to all my custom post types `weblogs` based on data from the author profile field. My code:               function add_custom_field_automatically($post_ID) {         global $wpdb;         $curauth = get_userdata($author->ID);         if(!wp_is_post_revision($post_ID)) {             $themevalue = get_the_author_meta('themeperauthor', $author->ID);             $themename = 'themeperauthor';             add_post_meta($post_ID, $themename, $themevalue);         }     }      Please help.


How do I create a custom wordpress slideshow plugin? I've been looking for the tutorials on google but I couldn't find one, would you guys mind giving a tutorial here or link to some other custom slideshow plugin tutorials?


How to automatically create an index of child sites at the root url for a multisite installation?

I have a Wordpress multisite with different child sites for different geographical locations. At the root url, I want to show an index page with links to the child sites. 1. How do I automatically populate links to the child sites? 2. How do I automatically populate site descriptions for the child sites? 3. How do I create a Google map with markers representing the child sites, assuming the locations of the child sites are entered in the site descriptions?


Wp_Nav_Menu - Identify the last menu item

I'm have a horizontal top menu with a solid border on the right hand side.               <?php wp_nav_menu( array('theme_location' => 'primary', 'container' => '', 'menu_class' => 'nav', 'fallback_cb' => '') ); ?>       My CSS looks like this:               body > header .nav li a {                     background: none;                     text-decoration: none;                     font-family: 'Open Sans', sans-serif;                     font-size: 13px;                     color: #000000;                     text-shadow: none;                     text-transform: uppercase;                     border-right: solid 1px #000000;                 }      Now, this works fine but as expected it creates a border on the right hand side of the my last menu item. This does not look good, is there anyway to specifically identify the last item in the menu so I can put a 'border: none' style on it. Regards, Stephen


Naming conventions when using (PHP5) namespaces?

Provided you are working on a php 5.3+ only package what are the namespace conventions when it comes to plugins               Funky_Monki\Banana_Blogger_Plugin\Admin::Banana_Tosser          Plugins\Funky_Monkey_Banana_Blogger\Admin::Banana_Tosser?


How to change a specific admin label

I'm trying to change on the backend from: Appearance -> Header To Appearance -> Logo But the Changing Admin Menu Labels answer didn't help so far. Any new tip? Thanks


Fixed home page

I am new to Wordpress. Forgive me if this is a simple question. How do I make a fixed (static) part (section) on the front page (home page) of WordPress site before the blog part? Thank you in advance.


Show all videos by tag name

I need to get all videos by tag name, im using code like that               $tax_terms = get_terms('media_category', 'orderby=count&order=DESC&hide_empty=0');          foreach ( $tax_terms as $tax_term ) {          $posts = get_posts(array(                     "meta_key" => 'select',                      "meta_value" => 1,                     "post_mime_type" => "video",                     "taxonomy" => $tax_term->taxonomy,                     "term" => $tax_term->slug,                     "numberposts" => 100,                      "posts_per_page" => 100));     ?>      But that query dont returns any elements, what's the problem is?


use another theme for just one page

I am a wordpress newbie. Been looking the whole day for a solution. http://codex.wordpress.org/Theme_Development and http://codex.wordpress.org/Template_Hierarchy#Visual_Overview did not give me what I need. There are theme1 - the general website theme and theme2 - the one I want to use for only one page. I have managed to make a template to use for that custom page that employs a the page.php, header.php and footer.php files from theme2 but no joy. The page became a mess. I think what needs changed is the page's .css file. Any way to import that too from theme2 ? thanks


Two plugins using the_title; one not passing second param.

I'm using two plugins which use the_title, but one (while still completely functional) is showing an error on certain pages. Missing argument 2 for pfund_handle_title() in ...wp-content/plugins/personal- fundraiser/includes/user.php on line 639 I'm told it's because it doesn't pass the second required parameter of the_title. Here's my original ? on the WP forums: http://wordpress.org/support/topic/plugin-personal-fundraiser-missing- argument-2-for-pfund_handle_title-in-userphp-on- line-639?replies=4#post-2682690 The second plugin is Blog in Blog. When deactivated, the error goes away, so I'm sure it's that one. I don't want to set the debugging in wp-config to false because, well, I don't want it to BE false. Here is the line from the Blog in Blog plugin which references the_title.               $data['post_title'] = apply_filters('the_title', $post->post_title);      Is there something I can do to make this work without also seeing the error?


Thumbnails to append content from database via ajax

**Completely re-edited question:** I am displaying music album covers as thumbnails in a page template. I would like to be able to click on an album thumbnail and pull the corresponding details for that album from the database and use them in a media player I have that will display at the top of the page. When you click a different album cover, it populates the player at the top with the different album information (artwork, title, tracks, streaming urls etc.) All of the album info is stored in the database as arrays that are accessible using PHP variables $dicography, $album, $track (usable in PHP loops as $album[$i] if that makes sense). I can get all the info I need using PHP but it loads all the players into the page at once, I would like to load only the one player/album data for the player corresponding to the album cover that is clicked via ajax if possible. So I guess my main question would be how to access the correct positions in the array to append the data to the now-playing section at the top of the page template when you click on an album cover. Some themes that do similar: reveal, yin-and-yang Thanks in advance!


How do you modify the HTML output of a Gallery item (using the gallery shortcode)?

Im a bit lost on this simple problem so i thought id come and ask the pros. Ive just been told by my client that on their sites gallery, the name and description are on the same line. so for example if the picture is called ABC, and the description is "123". the output is "ABC-123" all on one line.so itd look like:                --------     | Picture |      --------     ABC-123      She wants the name on one line, and the description on another, like so:                --------     | Picture |      --------     ABC          123      problem is that, i dont even know what im looking for as far as how to edit the code to make this simple change. On the output code id just enter a quick 'br' tag or something like that but again, i dont know where to make this change. As a work around, i went ahead on my local server and in the galleries picture caption area, i put "ABC   123 " and it worked. it put the name and description on 2 lines but there are A LOT of images on that gallery and im sure theres something more cleaner and elegant than this workaround lol. any ideas on where i can edit the code?? im using the latest build of WP and all although my theme is custom but its basically default and nothing crazy about it. im just wondering when you add the gallery code, for example [gallery link="file" orderby="rand"] , what page or code block is this referencing? Thanks in advanced


wp_list_categories with show_count, except for specific categories

I want to show post count for all child categories shown, but not for their parent categories. Or, since there are only 3 parent categories, this exclusion could be per category id. Is there a way to do that? Also, unfortunately, the number doesn't come wrapped in any element, so I can't think of any way of hiding it CSS wise.


Custom Contact Form Not Sending (but not giving error)

hope things are going well. I'm attempting to add a custom contact form to a section of home page. I came across a custom contact form at https://gist.github.com/hansspiess/6815875. I implemented the code into my home page to utilize the custom styling of the Zurb Foundation based theme I'm using. The form seems to be validating correctly and providing the appropriate error messages. Upon a "successful" submission, I receive a success alert, but am NOT actually receiving an e-mail at the admin e-mail address. I have also attempted to manually insert alternative email addresses in my $mailto variable. My hopes are that I may be missing some obvious, any help would greatly be appreciated. My site is ajinin.com Here is the php logic that I've placed above `<?php get_header(); ?>`:               <?php           /* response strings */     $missing_fields = 'Please fill out all fields.';     $email_invalid  = 'Your e-mail address is invalid.';     $trapped    = 'Please do not call this page via scripts.';     $error      = 'The message could not be sent.';     $success    = 'Thank you! The message has been sent';          /* process post vars, leave honeypot raw */     $submitted  = sanitize_text_field( $_POST['scf_submitted'] );     $name       = sanitize_text_field( $_POST['scf_name'] );     $email      = sanitize_text_field( $_POST['scf_email'] );     $message    = sanitize_text_field( $_POST['scf_message'] );     $honeypot   = $_POST['scf_message2'];          /* wp_mail vars */     $mailto     = get_option( 'admin_email' );     $subject    = 'Message from  ' . get_bloginfo('name');     $headers    = 'From: ' . $email . "\r\n" . 'Reply-To: ' . $email . "\r\n";          if ( $submitted ) {         if ( $honeypot != "" ) {             scf_response("alert-danger", $trapped);         } else {             if ( !$name || !$email || !$message ) {                 $alert[] = $missing_fields;             }             if ( !is_email( $email ) &&  $email ) {                 $alert[] = $email_invalid;             }             if ( empty( $alert ) ) {                 if ( wp_mail( $mailto, $subject, strip_tags( $message ), $headers ) ) {                     $alert[] = $success;                     scf_response("success", $alert);                      unset( $submitted, $name, $email, $message, $honeypot );                 } else {                     $alert[] = $error;                     scf_response("alert", $alert);                  }             } else {                 scf_response("warning", $alert);             }         }     }          /* output alert html */     function scf_response( $class, $alertArr ){              global $response;              $alertStr = implode( '
', $alertArr );         $response = '
' . $alertStr  . '×
';     }          ?>      Here is the html form:

QUESTIONS OR COMMENTS? LET US KNOW.

                             <?php echo $response ?>

                     <form role="form" action="<?php the_permalink(); ?>" method="post">

                                 Name                                 <input                                      type="text"                                      id="scf_name" name="scf_name"                                      value="<?php echo $name; ?>">

                                 Email                                 <input                                      type="text"                                      id="scf_email" name="scf_email"                                      value="<?php echo $email; ?>">

                                 Message                                 <textarea                                      rows="4"                                      id="scf_message" name="scf_message"><?php echo $message; ?></textarea>

                                 message2                                 <input type="text" name="scf_message2" name="scf_message2">

                                 <input type="hidden" name="scf_submitted" value="1">                                 <button type="submit" class="button medium blue">Send</button>

                       </form>

      Thank for any help that can be provided. If someone has an alternative method or know of a tutorial for a custom contact form they trust, please let me know. The most important thing for me is that I can finely control the html/css structure.


Removing default theme widgets

I am trying to remove the default widgets in a theme that I found here: http://top-wordpress.net/ The theme is Terapathy. In case of some of the most used themes, if I select the custom widgets, the default theme widgets disappear. But with Terapathy theme or any of the themes found in that site it is not possible. Is there anything I can do to remove those widgets.


Single Post Navigation Within Each Category

I have about 10 different category posts etc. As you know, withing each category there is the next and previous navigation to toggle between posts. When you reach the Last post in a category, the next navigation then takes you to the NEXT category... My question is, is there there a way to loop only withing the category with the next and previous?                   // The Category Loop                    if (function_exists('childtheme_override_category_loop'))  {         function thematic_category_loop() {             childtheme_override_category_loop();         }     } else {         function thematic_category_loop() {                  while (have_posts()) : the_post();                           thematic_abovepost(); ?>                          <div id="post-<?php the_ID();                         echo '" ';                         if (!(THEMATIC_COMPATIBLE_POST_CLASS)) {                             post_class();                             echo '>';                         } else {                             echo 'class="';                             thematic_post_class();                             echo '">';                         }                         thematic_postheader(); ?>
     <?php thematic_content(); ?>
                         <?php thematic_postfooter(); ?>
                      <?php                           thematic_belowpost();                  endwhile;         }     } // end category_loop


image upload/edit is broken: "Image data does not exist. Please re-upload the image."

Image uploads (slowly), and displays in the media window. But size shows " **(0 × 0)** " and if I try to use _Edit Image_ button I can't edit the image but instead get this message: _**"Image data does not exist. Please re-upload the image."_** I have 2 different WP installs each with unique plugins, and the problem exists on both installs _Is it WP 3.1 recent upgrade? Is it a plugin? Other?_


Where is get_header('shop') file in Woocommerce templates

I need to modify the **get_header('shop')** file in Woocommerce but don't know where it's located, if someone knows please help me out - thanks!


Looking for a related post plugin which slides-in like the one at inc.com does

Does anybody know a "related post" plugin with behavior like the one at inc.com. For a demo, visit any article at inc.com (ex: http://www.inc.com/guides/2010/10/how-to-design-a-great-about-us-page.html) scroll down to the end of the article and you will notice a box sliding in from the bottom right corner of the page. Although this is just like any other related post plugin, I feel its behavior increases site retention. Any pointers will be helpful. Thanks in advance


Removing comment option

I am working on a theme that I found here: http://top-wordpress.net/ The theme is Terapy. I turned off comment option in the admin panel, but the blog posts show that "commenting is not allowed". I want to completely turn off comments, so that the blog looks like a site (nothing about comments should appear in posts and pages). How can I turn off commenting in the above templates. In the index.php I removed this line:               <a href="<?php the_permalink() ?>#comments"><?php comments_number('0 Comments','1 Comment','% Comments'); ?>      Now the posts in the front page don't show how many comments are there. Now only thing that should be done is completely removing commenting option from the template. How can it be achieved? Edit: I misspelled the name of the theme. Here is the link to the demo


WordPress is adding rel="nofollow" and target="_blank" to internal links in posts and pages

For some reason WordPress started to add rel="nofollow" and target="_blank" to some of my links in my posts and pages. Not to all my links but randomly. I really dont know why because when I'm editing my post it is just a normal link without rel="nofollow" and target="_blank". Adding target="_self" or rel="dofollow" doesnt change anything. Why is this hapening and how can I solve this problem? Anyone got the same problem and knows a solution? Thanks in advance:) This is an example page and I'm taling about the link "control panels"


Customized landingpages for categories

When I click on a category now, it looks like.. > Category Archives: MyCategory > > first post > > second post > > third post.. I want to customize these landing pages for special categories, add text, pictures, html. How do I do that, easiest way, w/o plugins. There might be a file to be cloned, like content-category-mycategory.php?


How to remove tr field in a table in woocommerce?

I'm running woocommerce on my wordpress website. There in my order table I have a field in which says shipping = Free shiping. How do I remove this tr and where do I need to edit/change it ? Snapshot attached. ![enter image description here](http://i.stack.imgur.com/84kH4.png)


A problem in loading index.php

Instead of loading index.php, my page.php is loading.I cannot understand the problem.Please help me.The body of the content is not displaying.


2 weeks ago from meta query meta value

This is my meta query within my posts query.               'meta_query' => array(                          array(                         'key' => 'rw_membership_ends',                         'value' => ???????                         'compare' => '>=',                         'type' => 'DATETIME'                     ),           )      I want to select posts that have rw_membership_ends (in datetime format) older than the current value of the rw_membership_ends filed minus 14 days. What should I put in 'value' ? I need something like               'meta_query' => array(                          array(                         'key' => 'rw_membership_ends',                         'value' => 'rw_membership_ends_value' - 14 days                         'compare' => '>=',                         'type' => 'DATETIME'                     ),           )


Plugin generated virtual pages

I am currently devloping my first WP plugin. This plugin should generate dynamic pages on the fly if a fixed non-existing URL is requested. This means I want my installation to accept addresses like `http://www.mydomain.de/wordpress/mydatatool?page=format&format=mixed`. If such an URL is called a PHP script should be executed that generates a page showing an AJAX based JS user interface that allows analysis of database information. That page may not contain static content nor should it be added (automatically or manually) to the WP database. It should be created on demand as a volatile page. I suppose I know how I can catch the URL request (action parse_request). So the main problem to me is, how to generate the volatile pages in a way that they look exactly as normal WP pages including usage of theme, menus, header, footer, etc.               add_action('parse_request', array($this, 'custom_url_handler'));          public function custom_url_handler()     {       $url = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL);       if ($url==='/wordpress/mydatatool')       {          echo 'test'; // What to do to embed this into WP theme/menus/etc?          exit();       }     }      AFAIK something like this is not directly supported by WP currently. I did an extensive research and found a lot of code. Most of the code didn't work with current WP. Also some of the (simple) code snippets were able to deliver volatile pages but they actually did not look like a WP page missing parts of the menus/header/footer. Finally I found a gist link in a forum thread that provided a working code (see below). Since I am a beginner and the code isn't officially maintained I have concerns using it. Please give me some advice: - Should I use the code below? Can I consider it safe and reliable? Is there a good chance it will continue working after WP updates? - Is there an alternative that is maintained in a reliable way? - Is there a better way to solve my problem? UPDATE: This is the code that works for me:               <?php     /*      * Virtual Themed Page class      *      * This class implements virtual pages for a plugin.      *      * It is designed to be included then called for each part of the plugin      * that wants virtual pages.      *      * It supports multiple virtual pages and content generation functions.      * The content functions are only called if a page matches.      *      * The class uses the theme templates and as far as I know is unique in that.      * It also uses child theme templates ahead of main theme templates.      *      * Example code follows class.      *      * August 2013 Brian Coogan      *      */          // There are several virtual page classes, we want to avoid a clash!     //     class Virtual_Themed_Pages_BC     {         public $title = '';         public $body = '';         private $vpages = array();  // the main array of virtual pages         private $mypath = '';         public $blankcomments = "blank-comments.php";                   function __construct($plugin_path = null, $blankcomments = null)         {         if (empty($plugin_path))             $plugin_path = dirname(__FILE__);         $this->mypath = $plugin_path;              if (! empty($blankcomments))             $this->blankcomments = $blankcomments;              // Virtual pages are checked in the 'parse_request' filter.         // This action starts everything off if we are a virtual page         add_action('parse_request', array(&$this, 'vtp_parse_request'));         }              function add($virtual_regexp, $contentfunction)         {         $this->vpages[$virtual_regexp] = $contentfunction;         }                   // Check page requests for Virtual pages         // If we have one, call the appropriate content generation function         //         function vtp_parse_request(&$wp)         {         //global $wp;         if (empty($wp->query_vars['pagename']))             return; // page isn't permalink              //$p = $wp->query_vars['pagename'];         $p = $_SERVER['REQUEST_URI'];              $matched = 0;         foreach ($this->vpages as $regexp => $func)         {             if (preg_match($regexp, $p))             {             $matched = 1;             break;             }         }         // Do nothing if not matched         if (! $matched)             return;              // setup hooks and filters to generate virtual movie page         add_action('template_redirect', array(&$this, 'template_redir'));         add_filter('the_posts', array(&$this, 'vtp_createdummypost'));              // we also force comments removal; a comments box at the footer of         // a page is rather meaningless.         // This requires the blank_comments.php file be provided         add_filter('comments_template', array(&$this, 'disable_comments'), 11);              // Call user content generation function         // Called last so it can remove any filters it doesn't like         // It should set:         //    $this->body   -- body of the virtual page         //    $this->title  -- title of the virtual page         //    $this->template  -- optional theme-provided template         //          eg: page         //    $this->subtemplate -- optional subtemplate (eg movie)         // Doco is unclear whether call by reference works for call_user_func()         // so using call_user_func_array() instead, where it's mentioned.         // See end of file for example code.         $this->template = $this->subtemplate = null;         $this->title = null;         unset($this->body);         call_user_func_array($func, array(&$this, $p));              if (! isset($this->body)) //assert             wp_die("Virtual Themed Pages: must save ->body [VTP07]");              return($wp);         }                   // Setup a dummy post/page          // From the WP view, a post == a page         //         function vtp_createdummypost($posts)         {              // have to create a dummy post as otherwise many templates         // don't call the_content filter         global $wp, $wp_query;              //create a fake post intance         $p = new stdClass;         // fill $p with everything a page in the database would have         $p->ID = -1;         $p->post_author = 1;         $p->post_date = current_time('mysql');         $p->post_date_gmt =  current_time('mysql', $gmt = 1);         $p->post_content = $this->body;         $p->post_title = $this->title;         $p->post_excerpt = '';         $p->post_status = 'publish';         $p->ping_status = 'closed';         $p->post_password = '';         $p->post_name = 'movie_details'; // slug         $p->to_ping = '';         $p->pinged = '';         $p->modified = $p->post_date;         $p->modified_gmt = $p->post_date_gmt;         $p->post_content_filtered = '';         $p->post_parent = 0;         $p->guid = get_home_url('/' . $p->post_name); // use url instead?         $p->menu_order = 0;         $p->post_type = 'page';         $p->post_mime_type = '';         $p->comment_status = 'closed';         $p->comment_count = 0;         $p->filter = 'raw';         $p->ancestors = array(); // 3.6              // reset wp_query properties to simulate a found page         $wp_query->is_page = TRUE;         $wp_query->is_singular = TRUE;         $wp_query->is_home = FALSE;         $wp_query->is_archive = FALSE;         $wp_query->is_category = FALSE;         unset($wp_query->query['error']);         $wp->query = array();         $wp_query->query_vars['error'] = '';         $wp_query->is_404 = FALSE;              $wp_query->current_post = $p->ID;         $wp_query->found_posts = 1;         $wp_query->post_count = 1;         $wp_query->comment_count = 0;         // -1 for current_comment displays comment if not logged in!         $wp_query->current_comment = null;         $wp_query->is_singular = 1;              $wp_query->post = $p;         $wp_query->posts = array($p);         $wp_query->queried_object = $p;         $wp_query->queried_object_id = $p->ID;         $wp_query->current_post = $p->ID;         $wp_query->post_count = 1;              return array($p);         }                   // Virtual Movie page - tell wordpress we are using the given         // template if it exists; otherwise we fall back to page.php.         //         // This func gets called before any output to browser         // and exits at completion.         //         function template_redir()         {         //    $this->body   -- body of the virtual page         //    $this->title  -- title of the virtual page         //    $this->template  -- optional theme-provided template eg: 'page'         //    $this->subtemplate -- optional subtemplate (eg movie)         //              if (! empty($this->template) && ! empty($this->subtemplate))         {             // looks for in child first, then master:             //    template-subtemplate.php, template.php             get_template_part($this->template, $this->subtemplate);         }         elseif (! empty($this->template))         {             // looks for in child, then master:             //    template.php             get_template_part($this->template);         }         elseif (! empty($this->subtemplate))         {             // looks for in child, then master:             //    template.php             get_template_part($this->subtemplate);         }         else         {             get_template_part('page');         }              // It would be possible to add a filter for the 'the_content' filter         // to detect that the body had been correctly output, and then to         // die if not -- this would help a lot with error diagnosis.                  exit;         }                   // Some templates always include comments regardless, sigh.         // This replaces the path of the original comments template with a         // empty template file which returns nothing, thus eliminating         // comments reliably.         function disable_comments($file)         {         if (file_exists($this->blankcomments))            return($this->mypath.'/'.$blankcomments);         return($file);         }               } // class               // Example code - you'd use something very like this in a plugin     //     if (0)     {         // require 'BC_Virtual_Themed_pages.php';         // this code segment requires the WordPress environment              $vp =  new Virtual_Themed_Pages_BC();         $vp->add('#/mypattern/unique#i', 'mytest_contentfunc');              // Example of content generating function         // Must set $this->body even if empty string         function mytest_contentfunc($v, $url)         {         // extract an id from the URL         $id = 'none';         if (preg_match('#unique/(\d+)#', $url, $m))             $id = $m[1];         // could wp_die() if id not extracted successfully...              $v->title = "My Virtual Page Title";         $v->body = "Some body content for my virtual page test - id $id\n";         $v->template = 'page'; // optional         $v->subtemplate = 'billing'; // optional         }     }          // end


Calling an image within the theme folder from inside a post/page?

I am building a website for a client of mine who would like the ability to make minor layout changes themselves. Because of this I am coding some of the layout directly into pages using the text editor. The problem I am facing is dynamically including an image from the template directory into the posts/pages. Normally I would just use `<img src="<?php echo get_template_directory_uri(); ?>/images/image.png">` but that doesn't work when placing the code directly into a page/post since the raw text is outputted. Can anyone tell me how I can dynamically include an image through the post/page area without using the media library(since I'd like to keep site assets separate from attachments). Thanks!


How to pass a special CSS class into widget li

I have assigned a Sidebar into `functions.php`:               register_sidebar(             array (                 'name' => 'Footer Widgets Area',                 'id' => 'footer_widgets_area',                 'description' => 'Assign Maximum 3 widgets into this footer sidebar area.',                 'class' => 'my-class',                 'before_widget' => '
',                 'after_widget' => "
",                 'before_title' => '
',                 'after_title' => '
'             )         );      In footer I want to load specific CSS class into the widget container after the amount of widgets activated. So I used this:                           $our_sidebar = wp_get_sidebars_widgets();                 $widget_counter = count( $our_sidebar['footer_widgets_area'] );                      if( $widget_counter == 1 ) {                     $the_class = ' widen-full';                 } elseif( $widget_counter == 2 ){                     $the_class = ' widen-duo';                 } else {                     $the_class = ' widen-trio';                 }      What my footer is loading now is:

Archives
                 Archive Widget Content

                 Calendar Widget

                 Meta Widget

      Please note that if I can `echo` my class **`$the_class`** into the `<li>` then my problem is solved.
      Though I work a lot with WordPress, but I'm afraid of hooks and filters, and in most of the cases I understand them a little. It'd be my better achievement, if somebody can NOT just provide me a solution, but EXPLAIN the process associated with this. Then it'd be my future achievement. **PS:** Somehow, the class defined in `register_sidebar()` is not echoing. I don't know why.


How to handle a Wordpress blog with articles in different languages?

Most multilanguage plugins have the approach to provide each post in different languages. In that case, qTranslate or WPML are good plugins. But in my case, articles have one language and instead of translating them, there should be versions of the blog showing only the content in one language. For example the `en.example.com` should only show posts written in English language, and also display Theme texts in English, while `de.example.com` should only show German articles and also use German as system language for Wordpress. (URLs could also have the language code in slashes instead of using a subdomain, like `www.example.com/en/`.) Is there a good solution for this use case? I could think of using a plugin or integrating the concept into the theme. Or is the best solution to set up one Wordpress installation for each language?


Include one page/post into query which is already returning posts

I have my news query which is on my index file. I want to include a post into this query which is infact a page. Is there anyway to do this?               <?php query_posts(array(         'posts_per_page' => 5,         'paged' => $paged     )); if ( have_posts() ) : ?>      My page id is 6417 - If I use post__in then that is the only thing that shows. Can anyone advice please, do I need to do with a meta query? Thanks


Display Random Thumbnail from Category

I have a feeling that I'm on the right track, I just don't have enough solid PHP knowledge to get much further than where I'm currently at. I'm currently using the following code to return a list of child categories from a single category:               <?php         $taxonomyName = "category";         $terms = get_terms($taxonomyName,array('parent' => 79));         echo '
';         foreach($terms as $term) {             echo '
';             echo 'slug,$taxonomyName).'">'.$term->name.'
';                  $thumbnails = get_posts('numberposts=1&orderby=rand');             foreach ($thumbnails as $thumbnail) {             echo 'ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';                 if ( has_post_thumbnail($thumbnail->ID)) {                     echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail');                 } else {                 echo 'no thumbnail';                 }             echo '';             }             echo '
';         }         echo '
';     ?>      This code works somewhat. It returns a list of all six sub categories under the parent, ID 79. However, I want to also return one random thumbnail in each of the list items for each of the 6 sub categories. Unfortunately, this code returns a random thumbnail from all of my posts, not just ID 79 and it's specific child. I need it to return one thumbnail from the same category that is returned in it's parent `<li>`. Is there some easy way to do this? I'm thinking I need to sort through that array and return the category in the nested foreach loop. I just don't know how to do that. Thanks in advance for any help!


How to different style first 3 post on Category Archives Page

I searches lot of time but every one said first post. I need first 3 post different style with title , content.


get_template_part inside get_template_part?

Ever tried this?               // template file     do_action( 'my_hook' );          // ex. functions.php     function my_hooked_template_part() {       get_template_part( 'my_loop_part_file', 'default' );     }     add_action( 'my_hook', 'my_hooked_template_part' );          // my_loop_part_file-default.php     get_template_part( 'query', 'default' );     if ( have_posts() ) {     while ( have_posts() ) : the_post();     etc.          // query-default.php     $args = array( 'whatever' => 'and_so_on' );     query_posts( $args );      Maybe it's my setup, but it won't load the file. Could it be that it's too late for loading some other file inside? Can anyone confirm or this just a drawback of using the get_template_part() function (only one file - no nesting)?


WP_Redirect on User Region - GeoIP

I have a main homepage for my site and will have several other 'homepages' for different countries in the future. I am trying to redirect the user to the right 'homepage' for their country based on their IP, but also give them the option to view a different region for users stuck behind a proxy in a different country, for example. To do this I am setting 2 cookies; Country (for IP Lookup) and Region (for user's requested/preferred area). I have seen various posts on here relating to location redirection, but no-one has suggested using PHP's GeoIP tools. Is there any reason why I shouldn't use that method? I know that $_SERVER['REMOTE_ADDR'] isn't the most accurate, but surely it's a quick and easy method? Here is my current code:               // PSTV Regional Settings     add_action( 'init', 'pstv_set_country');     function pstv_set_country() {         $country = geoip_country_code3_by_name($_SERVER['REMOTE_ADDR']);         $expire = time()+60*60*24*30;         setcookie("country", $country, $expire, '/', '.plainandsimple.tv');              // Setup redirects for Country Homepages Here         if ($_COOKIE['country'] == "UAE") {             wp_redirect( 'http://plainandsimple.tv/uae/' );              exit;          }          else {             wp_redirect( home_url() );              exit;         }     }              add_action( 'template_redirect', 'pstv_set_uae_cookie');     function pstv_set_uae_cookie() {         // Set cookie if on UAE Home Page & redirect back         if (is_page('uae') && $_COOKIE['region'] !== "UAE") {             $expire = time()+60*60*24*30;             setcookie("region", "UAE", $expire, '/', '.plainandsimple.tv');             wp_redirect( 'http://plainandsimple.tv/uae/' );              exit;          }         if (is_page('home') && $_COOKIE['region'] == "UAE") {             $expire = time()+60*60*24*30;             setcookie("region", "UAE", $expire, '/', '.plainandsimple.tv');             wp_redirect( 'http://plainandsimple.tv/uae/' );              exit;          }     }      So the question is, does anyone see any issue in my approach to this or can someone give me and pointers to a better method?


customize color in WP child theme doesn't saved

I have a WP theme and I create for it a child version, child version has only style.css file. It loading fine, working normally like mother's theme. When I use Customize theme function to change color, font-size etc, saved but it doesnt work. Color doesnt load. It works only if I change back to mother's theme. So what is the reason? What I missing on child theme? ![Theme customize](http://i.stack.imgur.com/yLFyg.png) Thank you


HowTo to add my rewrite rules at the beginning, redirect to the right page and flush the rules on plugin activation?

Hi i am currently writing a WordPress plugin that i want to release to the public. I am having a few issues with URL rewrites however. I have got the plugin to redirect to the plugin page `add_action('template_redirect', 'myfuncdisplay')` to display custom output. I also have got the redirect working, `www.mydomain.com/index.php?form=contact2` for instance will cause the template_redirect code to be called. So far so good. However, if i go `mydomain.com/form/contact` it will actually redirect to an existing page `mydomain.com/products/contact-centres`. If i go to `mydomain.com/form/contact2` then it will redirect to my plugin. Checking on the cool plugin Rewrite Analyzer, i get the following:               form/([^/]+)/?$              formid: contact          (.+?)(/[0-9]+)?/?$            pagename: form/contact                page:       I was playing about the with code, and added the parameter to true... now it seems to work and ignore the fact that i have other pages listed with contact, it now just goes direct to my plugin:               add_permastruct( 'formid', 'form/%formid%', true );      Is the above correct? Does setting the 3rd parameter give priority to my permalink? As far as i can tell, Wordpress will try and match the post-name and disregard any /my/other/url/post-name... seems to do this on all sites which is a little confusing. Also, in order to get my plugin to work, i need to goto the Permalink options in the admin menu and click save... if i dont do that its as if my rules are not included. Is there any way around that, cant it be done by the plugin on activation or do i need to tell my plugin users to click on the Permalinks menu item in order to activate the plugin redirects? My code is below, appreciate the help and time for your replies. Chris               <?php               require_once('jFormer/jformer.php');          /*interface JFormerForWPFormClass     {       public function GetForm();       public function ProcessForm();     }*/          class JFormerForWP     {         static $errors = false; /* for debugging */              const DB_VERSION = 1; // This number represents the current version of the plugins table structure. Increment this every time you modify the scheme of the database tables that you create for your plugin.              static $pluginPath;           static $pluginUrl;           static $registry;              static $permastructString = 'form';              /*public static function RegisterForm($form)         {             $self::registry[$id] = $form();         }         */              public static function makeFormFactory($id,$class)         {             $classPath = self::$pluginPath . "/forms/{$class}.php";             require_once $classPath;              /*$this->registry[$id] = new $class();*/         }              /* called each request */         public static function init()         {             self::$pluginPath = dirname(__FILE__);  // Set Plugin Path               self::$pluginUrl = WP_PLUGIN_URL . '/jformer-for-wp/'; // Set Plugin URL                    /* During the admin_menu action we can add our own items into WordPress' Administration menu. */             // add_action('admin_menu', array($this,'InsertAdminMenuLink'));             // add_action('init', array($this,'RouteActions'));                  /* The next two functions run when our plugin is activated or deactivated. In these functions we run the code necessary to install, and possibly uninstall our plugin when the user activates or deactivates it from the Plugins page. */             register_activation_hook(__FILE__,'JFormerForWP::activate');             // Deactivation function             register_deactivation_hook(__FILE__,'JFormerForWP::deactivate');                  // This function runs on each page load to check if our plugin has been updated and, if so, what SQL functions we need to run to upgrade our plugin's tables to the most recent version             // add_action('init', array($this, 'Update'),1);                  JFormerForWP::setRewriteRules();             /* add_filter( 'query_vars', 'JFormerForWP::addQueryVars'); */             add_action( 'template_redirect', 'JFormerForWP::formDisplay'); /* used when rewrite tags are used */                  /* Often times, our plugins need to attach new javascript files or css files to our page. WordPress provides a very clean mechanism for doing so that helps prevent us from needlessly including the same file multiple times (which would slow down your page load time). Scroll down to the StylesAndScripts function to see how to properly attach a JavaScript or CSS file. */             add_action('wp_print_styles', 'JFormerForWP::styles');             add_action('wp_print_scripts', 'JFormerForWP::scripts');             add_shortcode('jformer', 'JFormerForWP::shortcodeHandler');                       /* for ajax functionality */             add_action('wp_ajax_nopriv_jFormerForWp', 'JFormerForWP::ajaxHandler');             add_action('wp_ajax_jFormerForWp', 'JFormerForWP::ajaxHandler');                  // add_action('wp_jformer-for-wp_ajax_get', array($this, 'handle_ajax'));             self::$errors = new WP_Error();         }              public static function ajaxHandler()         {                $formID = $_POST['jFormerId'];             echo JFormerForWP::getForm($formID);         }              public static function registerForms()         {         /*  $files = array();             $path = getcwd();             $supported_ext = array('gif', 'jpg', 'jpeg');             $dir = @opendir($path);             while ($file = @readdir($dir))             {               if (!is_dir($path.$file))               {                     $splitted = explode('.', $file);                     $ext = strtolower($splitted[count($splitted)-1]);                     if (in_array($ext, $supported_ext)) $files[] = $file;               }             }             @closedir($dir);             sort($files);*/         }              public static function getForm($id)         {             $formFileName = self::$pluginPath . '/forms/' . $id . '.php';                  if(file_exists($formFileName) == true)             {                 $contactForm = new JFormer($id, array('submitButtonText' => 'Submit', action => admin_url('admin-ajax.php')));                 include($formFileName);                 return $contactForm->processRequest();               }             else             {                 // echo 'warning from jformer-for-wp - ' . $formFileName . ' not found.';                 return -1;             }         }              public static function shortcodeHandler($atts, $content)         {             extract( shortcode_atts( array(             'id' => '0',             'class' => '',             'text' => ''             ), $atts ) );                  // echo 'dumping shortcode values. content: ' . $content . ', id: ' . $id . ', class: ' . $class . '
';                  if( $text == '' )              {                 return self::getForm($id); /* return the actual form */             }             else /* return a link to the form */             {                 if( $class=='' )                     return '' . $text . '';                 else                     return '' . $text . '';             }         }              public static function setRewriteRules()         {             // this two lines are to add external page             add_rewrite_tag( '%formid%', '([^/]+)');             add_permastruct( 'formid', 'form/%formid%', true );                  // this is to rewrite rule and direct to an internal page             // add_rewrite_rule( 'forms/?([^/]*)', 'index.php?pagename=forms-page&formid=$matches[1]', 'top' );         }              public static function addQueryVars($vars)         {             $vars[] = 'formid';             return $vars;              }              public static function formDisplay()         {             if( $formid = get_query_var( 'formid' ) )             {                 $formCode = self::getForm($formid);                 if($formCode != -1)                 {                     include ( self::$pluginPath . '/html/redirect-page-header.php' );                     echo $formCode;                     include ( self::$pluginPath . '/html/redirect-page-footer.php' );                     exit;                 }             }         }              public static function activate()          {             /* When you use the global keyword to define a variable, what you are saying is that you want to be able to access a variable that exists outside of our class. The $wpdb variable in WordPress allows us to easily interact with the database that WordPress is installed on. To learn more about how to use the $wpdb Object visit here: http://codex.wordpress.org/Function_Reference/wpdb_Class */             global $wpdb;                  setRewriteRules();             flush_rewrite_rules();         }              /* This function will run when the user deactivates the plugin from the WordPress Plugin screen. You might want to put some code in here to remove the tables and options that your plugin created, but, if you do that here, and the user reenables your plugin, they will lose all the data and settings they had previously set. Your alternative, is to create an uninstall.php file and place your cleanup code in there. This code is run when the user deletes your plugin. Open uninstall.php to see how this file works.  */            public static function deactivate()         {             flush_rewrite_rules();         }              /* load_plugin_textdomain simply tells WordPress the textdomain we set for our translation strings, and tells it where to look for our language files.  */         public static function setLanguage()         {             load_plugin_textdomain( 'JFormerForWP', null,  dirname( plugin_basename( __FILE__ ) ) . '/languages/');         }                   public static function insertAdminMenuLink()         {             /* Using the add_menu_page and add_submenu_page functions we can add our own pages to the Administration menu. More information about this function can be found here: http://codex.wordpress.org/Adding_Administration_Menus  */                  /* $page = add_submenu_page(                  'options-general.php' , // This is the parent page that we want to add our configuration page to                 __( 'jFormer Plugin' , 'JFormerForWP' ), // This will be the title of our configuration page                 __( 'jFormer Plugin' , 'JFormerForWP' ), // This will be the name of the link in the menu                 'edit_plugins' , // This is the minimum role that the user must have to be able to see and click on this link. You use this parameter to limit access to only certain WordPress users, i.e. authors cannot access the page but Administrators can. A complete list of user roles and capabilities can be found here: http://codex.wordpress.org/Roles_and_Capabilities                 'JFormerForWP' , // This is a unique string used to identify your configuration page. The URI of this admin page will be options-general.php?page=B2Template. If you have multiple configuration pages, remember that they should all have unique identifiers                 array( $this , 'ConfigPageHtml' ) // This is the function that will be run to genereate the page when the user clicks on the link.                   );      */                  // Add_submenu_page returns a unique identifier for our page. We can use that identifier in the hooks below so that these functions only run when the user visits our Administration page, and not other pages. This is helpful because we don't want to slow down the users loading time by including stylesheets and javascript across the entire WordPress admin, when it's only being used on our page.             //add_action( 'admin_print_scripts-'.$page , array( $this, 'AdminScripts' ) );             //add_action( 'admin_print_styles-'.$page , array( $this, 'AdminStyles' ) );                  // WordPress requires us to "register" our plugins settings before we can let the user update them. This is a security feature to prevent unauthorized addition of settings.              //add_action( 'admin_init' , array( $this,'RegisterAdminSettings' ) );              }              public static function registerAdminSettings()         {             /* The first parameter is the name of the Settings group that is going to be saved. As you can see I have two separate groups of settings that can be saved independently. The second parameter is the name of the setting you want to save. Notice that I've added the plugin name to the beginning of the setting to avoid a naming conflict in the database.*/             register_setting('JFormerForWPSettings', 'JFormerForWPSettings_option1');              }              /*  This is the callback function that we defined above to run when the user clicks on the link to get to our plugin's configuration page. You could simple us an echo statement in this function to output all of your html here, but in order to keep things a little cleaner and more organized, I use the following method to retrieve the html from an external file. */                public static function configPageHtml()         {             $content = '';             ob_start(); // This function begins output buffering, this means that any echo or output that is generated after this function will be captured by php instead of being sent directly to the user.             require_once('html/config.php'); // This function includes my configuration page html. Open the file html/config.php to see how to format a configuration page to save options.             $content = ob_get_contents(); // This function takes all the html retreived from html/config.php and stores it in the variable $content             ob_end_clean(); // This function ends the output buffering                  echo $content; // Now I simply echo the content out to the user              }              public static function adminScripts()         {         }              public static function adminStyles()         {         }              /* This filter lets us add or own links to this list. I'm using it to provide users with a shortcut to the Plugin's settings page, but it could be used for anything (e.g. to insert a donate link, or link to Plugin suppert forums). The function takes an array of links, adds our link to the array and then returns the modified array. */         public static function insertSettingsLink($links)         {             $settings_link = ''.__('Settings','JFormerForWP').'';               array_unshift( $links, $settings_link );               return $links;          }              /* This function adds JavaScript and CSS to the viewer facing side of WordPress. Scroll up to AdminStyles and AdminScripts() to see how these functions work */         public static function styles()         {                    wp_enqueue_style('jformer', self::$pluginUrl. 'css/style.css');         }              public static function scripts()         {             wp_enqueue_script('jformer', self::$pluginUrl . 'jFormer/jFormer.js',array('jquery'));                  /*wp_localize_script('JFormerForWP_SubmitForm','JFormerForWP',                 array(                     'AjaxError'=>__('An error occurred. Please try your action again. If the problem persists please contact the plugin developer.','B2Template')                 ));*/         }     }                    ?>


How to automatically install default Wordpress plugins?

I setup a decent number of Wordpress installations clients/friends. There are a number of plugins that I use on every instance. Is there a good way to automatically have these plugins installed on every instance? Does simply copying the plugins folder to a new installation do the job?


Why no images on a fresh Wordpress installation?

I've just installed Wordpress here at arun.sanspace.in But, don't know why, it doesn't display any images. I want to know why? I have another Wordpress installation on the same server which works great. What exactly is the problem here? Am I doing something wrong? While I copy the image location from the placeholder and open it alone, it displays the picture. It happens on IE and FF both.


Restrict Content for only Contributors via .htaccess

I have been using this code to restrict content download from wp- content/uploads for only logged in users:                RewriteEngine On      RewriteBase /      # Add these lines right after the preceding two      RewriteCond %{REQUEST_FILENAME} ^.*(pdf|docx)$      RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]      RewriteRule . - [R=403,L]      However, this will allow all logged in users to download the same. Is there any way that ONLY Contributors / Authors are able to download the files and not subscribers. Thanks for your help.


Conditional Content Display

I"m trying to replace the string "Something Nice will show up here" in the block of codes below with WordPress loop but it doesn't seem to be working. I'd like when Link1 is clicked on, let the post with the ID "intro-paragraphs" show. Any ideas on how to do that properly?               <?php             $longString = "Something Nice will show up here";              $link=$_GET['link'];         if ($link == '1'){              echo $longString;         }         if ($link == '2'){             include 'page2.php';         }         if ($link == '3'){             include 'page3.php';         }         if ($link == '4'){             include 'page4.php';         }             ?>      Like this               <?php          $longString = "<?php               $query = new WP_Query('category_name=intro-paragraphs');               if($query->have_posts()) : while($query->have_posts()) : $query->the_post();                ?>

             <?php the_title(); ?>
           <?php echo excerpt(40); ?>
           <a href="<?php echo get_permalink(); ?>">» read more...
                  <?php endwhile; ?>         <?php endif; ?>";


Unprotected page appears protected when posted to Facebook (S2Member)

I recently removed the restriction on the following page: http://www.boulderwritersworkshop.org/2012/10/21/david-jessup/ I can now view it without being logged in. However, if I post this URL to my Facebook wall, it shows the "Join" page, as if Facebook thinks I need to log in the view that content. I tried clearing Quick Cache and loading the page from a remote computer--it's definitely visible to all. Except Facebook apparently. Ideas?


Adding categories to custom post type in permalink

I know people have asked this before and have gone as far as adding the custom post type, and rewrite for permalink. The problem is I have 340 existing categories which I would like to continue using. I used to be able to see /category/subcategory/postname Now I have the slug of customposttype/postname. Selecting the category no longer shows up in permalink...I've not changed the permalink setting in admin to anything different. Is there something I'm missing or need to add to this code?               function jcj_club_post_types() {         register_post_type( 'jcj_club', array(             'labels' => array(                 'name' => __( 'Jazz Clubs' ),                 'singular_name' => __( 'Jazz Club' ),                 'add_new' => __( 'Add New' ),                 'add_new_item' => __( 'Add New Jazz Club' ),                 'edit' => __( 'Edit' ),                 'edit_item' => __( 'Edit Jazz Clubs' ),                 'new_item' => __( 'New Jazz Club' ),                 'view' => __( 'View Jazz Club' ),                 'view_item' => __( 'View Jazz Club' ),                 'search_items' => __( 'Search Jazz Clubs' ),                 'not_found' => __( 'No jazz clubs found' ),                 'not_found_in_trash' => __( 'No jazz clubs found in Trash' ),                 'parent' => __( 'Parent Jazz Club' ),             ),             'public' => true,             'show_ui' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'menu_position' => 5,             'query_var' => true,             'supports' => array(                  'title',                 'editor',                 'comments',                 'revisions',                 'trackbacks',                 'author',                 'excerpt',                 'thumbnail',                 'custom-fields',             ),             'rewrite' => array( 'slug' => 'jazz-clubs-in', 'with_front' => true ),             'taxonomies' => array( 'category','post_tag'),             'can_export' => true,         )     );


How to customize the symbols that appear in the Visual Editor insert custom character

The TinyMCE Editor has a great button in the kitchen sink to insert custom characters / symbols. Is there a way to control what symbols show up in this pop-up? (Specifically I need some unique Hawaiian language characters 'okina and macrons).               Code    Character     Ā  Ā     ā  ā     Ē  Ē     ē  ē     Ī  Ī     ī  ī     Ō  Ō     ō  ō     Ū  Ū     ū  ū     ʻ  ʻ      Hawaiian Diacritical mark reference: http://manoa.hawaii.edu/site/hawaiian_language.html


pagenavigation not showing the next page just linking back to the main page

Using this on my index.php               <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>      Using plugin: WP-PageNavi Wp Pagenavi Style Not sure what information you need to help me fix this. So please let me know. Site: http://www.slashgeek.net/ edit: code of index.php http://pastebin.com/hThDBcyC


How to add attachment in woo commerce send mail function

I am using woo-commerce plugin. After the checkout process, I am sending a mail to customer, it's working good but also, I want to attach the product image into the mail. I am not getting any idea how to do this.               function send( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = "", $content_type = 'text/html' ) {                  // Set content type             $this->_content_type = $content_type;                  // Filters for the email             add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );             add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );             add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );                  // Send             wp_mail( $to, $subject, $message, $headers, $attachments );                  // Unhook filters             remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );             remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );             remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );         }


Columnizing custom post type based on custom taxonomy

my first question here, so I'll try to be thorough. I have page on which I'm trying to sort a custom post type with around 350 different artists by a custom taxonomy. The custom taxonomy is basically the alphabet, so I'm able to index all of the custom posts by the respective letter in the custom taxonomy. E.g. the custom post with title 'olafur eliasson' is indexed under 'e' in the custom taxonomy (I want to sort the artists by their last name). What I'm trying to output is a layout like this: A D G   B E H   C F I   And so forth. I'm leveraging WP_Query_Columns in order to split the query into columns. This is the chunk of code I've been able to work up so far (and the code is currently running here http://jonasjulekort.dk/)               <?php     /** Get all terms from the 'alphabet' Taxonomy */     $terms = get_terms('alphabet', 'orderby=slug');         /** Loop through each term one by one and output the posts that are associated to it */     if(!empty($terms)) : foreach($terms as $term) :     /** Set the term name */     $term_name = $term->slug;     /** Set the query arguments and run the query*/     $args = array(         'alphabet' => $term_name,         'order' => DESC,         'post_type' => 'kunstner',         'posts_per_page' => -1     );     $term_posts = new WP_Query($args);     /** Do something with all of the posts */     foreach(new WP_Query_Columns($term_posts, 85) as $column_count) : ?>     <ul class="large-3 columns <?php echo $term->slug ?>">         <?php while ($column_count--) : $term_posts->the_post(); ?>         <li class="kunstner <?php echo $term->slug ?>"><?php the_title();?>
                <?php endwhile; ?>
     <?php endforeach;     /** Reset the postdata, just because it's neat and tidy to do so, even if you don't need it again */     wp_reset_postdata();     endforeach;     endif;     ?>      The sorting of the post through the taxonomy works fine and dandy, but the layout is causing mayor issues, what I'm getting is not like: A D G   B E H   C F I   but like this: A B C   D E F   G H I   What I'm not getting, is that this (see below) chunk of code layouts all the posts in the order I want, but it doesnt give me the control over each individual taxonomy-term ul, which I'm seeking.               <?php $terms = get_the_terms( $post->ID, 'alphabet' ); ?>     <?php $wp_query = new WP_Query('post_type=kunstner&showposts=9999&order=desc');?>         <?php foreach(new WP_Query_Columns($wp_query, 85) as $column_count) : ?>
             <?php while ($column_count--) : $wp_query->the_post(); ?>             <li class="kunstnere <?php  $terms = wp_get_post_terms($post->ID,'alphabet');       foreach ($terms as $term) {           echo $term->slug;       }        ?>"><?php the_title(); ?>
             <?php endwhile; ?>
     <?php endforeach; ?>      I hope, I've explained my issue and what I'm seeking in enough detail to get the point through. I'm not super sharp in php, which probably tells, so I'm hoping some wizard can spot where what I have to work on, in order to accomplish my goal.


Using existing widget code!

Maybe this was answered many times but I couldn't find my answers so here I go: Am I allowed to use widgets php code from other existing themes and modify it for my needs?


Changing the site URL

# Overview: I have a self-hosted WordPress installation _currently_ without a domain. Example: http://xx.xx.xxx.xxx/~someaccountname In a few days a domain will be pointing to this installation and I'll need to update the site URL. I'm not migrating. I'm simply changing the home/site URL from an IP-based URL to a domain-based URL. I've already read through the codex on the matter but apart from changing the Home URL and Site URL under General Settings, the codex appears to be outlining fixes rather than any other steps additional to changing the URLs via General Settings. # Questions:   1. In your experience, is it a straight forward process changing from an IP-based site URL to domain-based site URL? Is it a problematic affair that should be avoided by creating a fresh hosting account entirely?   2. Is anyone aware of potential problems this could create with plugins such as WooCommerce? Note: I have reviewed existing questions/answers on this website.


post_name empty after wp_insert_post

I'm writing an external tool that inserts post in wordpress (I'm using the wordpress functions). I read also this discussion: wp_insert_post does not write my post_name But my problem is a little different. I do the insert of post, but post_name is empty. The code is:               // Create post object     $my_post = array(     'post_title'    => $article_title,     'post_name'   => $article_title,     'post_content'  => $article_content,     'post_status'   => 'pending',     'post_author'   => 1,     'post_category' => array(8,39)     );          // Insert the post into the database     wp_insert_post( $my_post );      I tried with and without the post_name, but the result did not change. I also tried after:               $post_ID = (int) $wpdb->insert_id;     $post_name = wp_unique_post_slug($article_title, $post_ID, $post_status, $post_type, $post_parent);     $where = array( 'ID' => $post_ID );     $wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), $where );      But so for example, insert the post_name but:   1. isn't unique   2. not sanitize, for example "Test" doesn't became "test" What am i doing wrong?


Jetpack infinite scroll render - make different depending on post type?

I am currently working on a theme which has two post types - one is the normal "posts" post type, and the other is for portfolio posts - "mytheme_portfolio". I am using JetPack's infinite scroll to render new posts, as follows:               function mytheme_render_infinite_scroll() {         while ( have_posts() ) : the_post();                  get_template_part( 'content', 'archive-portfolio' );              endwhile;     }          function mytheme_jetpack_setup() {         add_theme_support( 'infinite-scroll', array(             'container' => 'content',             'type'  =>  'click',             'render' => 'mytheme_render_infinite_scroll',         ) );     }     add_action( 'after_setup_theme', 'mytheme_jetpack_setup' );      This is working fine but I am wondering how I can specify different `content-` template files to render depending on the which post type's archive/category/tag page you are currently viewing. As it happens now I am calling `content-archive-portfolio.php` when the infinite scroll is triggered, what I would like is to call `content-archive-portfolio.php` if portfolio posts are being viewed, but `content.php` if the blog is being viewed. Any help would be greatly appreciated, thanks! **EDIT:** I've just worked it out but someone else might have the same issue, or maybe someone else has some better suggestions? Replace the above `mytheme_render_infinite_scroll` function with this:               function mytheme_render_infinite_scroll() {         while ( have_posts() ) : the_post();             if ('mytheme_portfolio' == get_post_type()) :                 get_template_part( 'content', 'archive-portfolio' );             else :                 get_template_part( 'content', get_post_format() );             endif;         endwhile;     }


next_posts_link not working with custom query

I am trying to create a pagination system through my posts. Here my code:               <?php       $paged = (intval(get_query_var('paged'))) ? intval(get_query_var('paged')) : 1;       $args = array(         'post_type' => 'programma_mensile',         'paged' => $paged,         'posts_per_page' => 1,         'monthnum' => (date('n')-1),         'year' => date('Y')                );       query_posts($args);                if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php next_posts_link(''); ?>

<?php the_title(); ?>

<?php previous_posts_link(''); ?>

           <?php $eventIds = preg_split( "/[\s,]+/", get('lista_eventi') ); ?>           <?php endwhile; ?>               <?php endif; ?>      Everything works fine without these parameters:               'monthnum' => ( date('n') - 1),     'year' => date('Y')      With these two parameters the query works but i cant get the previous and the next post link. But i need them because want to show the post of the current month..even if a post for december is already pubblished.


Facebook comments widget - App ID

I have installed a Facebook comments widget that seems to be working just fine without the App ID. Is the App ID really necessary? What advantages will it give me if I add it?


Detect archive and category page

I would like to detect following pages: `http://192.168.1.100/wordpress/?m=201311` - blog archive `http://192.168.1.100/wordpress/?cat=1` - blog category For example, post type I can easly detect with: > $page_id = get_queried_object_id(); > > if (get_post_type( $page_id ) != 'slideshow') How about the above pages ? I mean any category or archive page.