title: Last post in loop - custom post types

text:
I added the below code to my index.php and it's working fine. Then I added it to my type-[post_type].php file and it's still displaying the code for the last post on the page. I can't figure out why. Should I be doing it a different way?                   <?php if( $wp_query->current_post < $wp_query->post_count-1 ): ?>         <img src="<?php bloginfo('template_directory'); ?>/images/fezhr.png" />         <?php endif; ?>      Here is my loop for one of the post types:                   <?php if (have_posts()) : ?>

Latest

EVERYTHING | GAMES | ENTERTAINMENT | TECH | PODCASTS

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

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

Posted by: <?php the_author_posts_link(); ?> on <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>

<?php if(function_exists('the_views')) { the_views(); } ?> | <a href="<?php comments_link(); ?>"><?php comments_number('0 Comments', '1 Comment', '% Comments'); ?>

                  <?php             if ( has_post_thumbnail() ) {                 $image_id = get_post_thumbnail_id();                 $image_url = wp_get_attachment_image_src($image_id, 'large', true);                 echo 'ID) . '" title="' . get_the_title($post->ID) . '">ID) . '" alt="' . get_the_title($post->ID) . '" class="aligncenter" />';             }             ?>                  <?php                ob_start();                the_content('Read the rest of this article...');                $postOutput = preg_replace('/]+./','', ob_get_contents());                ob_end_clean();                echo $postOutput;             ?>

             <?php if( $wp_query->current_post < $wp_query->post_count-1 ): ?>             <img src="<?php bloginfo('template_directory'); ?>/images/fezhr.png" class="fezHR" />             <?php endif; ?>                  <?php endwhile; ?>                           <?php wp_pagenavi(); ?>                        <?php else : ?>
             <img src="<?php bloginfo('template_directory'); ?>/images/FEZ404.png" />

God dammit! FEZ why do you always ruin all the fun. Sorry the page you requested has been eaten! You will just have to find something else, deal with it.
              <?php endif; ?>


title: How can I get rid of the the category suffix--NOT "prefix" (i.e. foo-1, foo-2, etc)

text: I just added a new category to my WordPress site, but the WP is adding a "-2" to the url as if there was an existing category with the same name. But there isn't. There was, but I deleted it. How can I resolve this? I'm don't mind mucking around with the database in order to manually change the values (if necessary) but I would appreciate some guidance form somebody who knows what they are doing.


title: How to show specific year archive into dropdown list

text: Here is my current code which shows a dropdown list of all years daily post archive.               <select name="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>        <option value=""><?php echo attribute_escape(__('Select Issue')); ?></option>        <?php wp_get_archives('type=daily&format=option'); ?> </select>      But i want to show a specific year daily post archive into dropdown list. (eg. only 2010 daily post archive will show into dropdown list) Pls help me. Thanks in advance, Onirban


title: Wordpress slugs and 404 handling takes preference over folders in site root?

text: I have wordpress installed and permalink structure set to /%postname%/ In addition to WordPress folders, I also have a public_html/beta folder where I wanted to copy the same site and test some unreleased features. However, whenever I navigate to http://mysite.com/beta , I get the WordPress message saying "Sorry, but you're looking for something that isn't there". So the question is how do I make the folder take higher priority/preference than the wordpress slugs? :/ Thanks! Edit: here's the .htaccess file:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress


title: Value from custom field is not being displayed?

text:
For some reason this custom field is not being shown in the page. This is the template file:               <?php          /**      * Template Name: bbPress - Topics (Newest)      *      * @package bbPress      * @subpackage Theme      */          ?>          <?php get_header(); ?>

                          <?php do_action( 'bbp_template_notices' ); ?>                          <?php while ( have_posts() ) : the_post(); ?>

                                     <?php the_content(); ?>
                                      <?php get_template_part( 'loop', 'bbp_topics' ); ?>

                          <?php endwhile; ?>                          <?php if ( get_post_meta($post->ID, 'note', true) ) : ?>

<?php echo get_post_meta($post->ID, 'note', true); ?>

                     <?php endif; ?>

          <?php get_sidebar(); ?>     <?php get_footer(); ?>      As you can see everything is set: ![enter image description here](http://i.stack.imgur.com/BAftU.png)


title: Featured Image Inherited from Parent Page

text: What I would like to do is have my parent page's featured images display, unless a child page has its own featured image, then I would like that image to become the featured image from that page and the rest of its children pages.               -Page 1     -Page 2       -Sub Page 1       -Sub Page 2         -Sub Sub Page 1          -Sub Sub Page 2      So in the example above:   **Page 1** and **Page 2** would have a featured image set that would display in the header.   **Sub Page 1** would inherit **Page 2** featured image.   **Sub Page 2** would have its own featured image, which **sub sub page 1** would inherit.   **Sub Sub Page 2** would have its own featured image.   I have tried placing this code in my header, where the image needs to go and it did not draw in any featured images, it just brought in the image slider.:               <?php if ( has_post_thumbnail($post->post_parent, 'pagethumb') ) {                      echo get_the_post_thumbnail($post->post_parent, 'pagethumb');                      } else {                      echo do_shortcode('[rev_slider header-slider-bw]');                  } ?>      I also tested to make sure the image was there and working with this code (and it was):               if ( has_post_thumbnail() ) {     the_post_thumbnail();     }       Does any one have an advice on how to make this happen? I appreciate any help. Thanks in advance!


title: Splitting One Big WordPress Site into Multiple Small Sites

text: I have a very big WordPress site and I am facing speed issue and server resources issues. Specially numbers of MySQL records are so high. So, I want to split the big WordPress site into multiple small sites. I have URL structure like this   1. `http://example.com/this-is-first-post.html` (category1)   2. `http://example.com/this-is-second-post.html` (category2)   3. `http://example.com/this-is-third-post.html` (category1 and category2) I want to separate the WordPress according to category, I am thinking about two solutions   1. Either I create two DBs for each categories, e.g. `db_cat1` and `db_cat2` and I divide the data using some logic.   2. Or I create subdomains and install different WP instances like this:     * `http://category1.example.com/this-is-first-post.html`     * `http://category2.example.com/this-is-second-post.html` My questions are:   1. If I try the first logic, then how can I divide the databases into different categories db?   2. If I try second logic, then how can I manage the URL structure and keep SEO juice there? How can I divide the common tags and categories?   3. How I will manage resources such as image etc after splitting the WordPress?   4. Is there any better way to do this job? I don't want change the server or work on server because I already tried different types of server and all servers have the MySQL resources issues. I prefer second logic because it is easy to handle.


title: Ajaxify Form That Submits To Same Page To Display Post Data

text: I have a drop down menu that submits one of several filter options. The options are submitted to the same page, where post titles are displayed based on these options. The form is working fine, but I want to make it AJAX, to only load the post titles, not the rest of the page. The only answers/tutorials I've found deal with submitted e-mails, or forms to ANOTHER page, and I can't seem to figure out how to do it on the same page. (This is WP specific because i know wordpress has a built-in AJAX functionality)


title: Problem with permalink structure for Wordpress custom post_type archive template

text: I have looked at other similar answers to this question but not finding my way. I am using Custom Post Types plugin for a custom post_type called 'product' and has_archive is set to 'true' in the settings I am using an archive template called archive-product.php The archive template is used and works as long as the permalink structure is default. However, I want it to be the postname permalink structure. If I change it to this in permalinks then the page for products uses the standard loop (maybe archive template or index loop) What is the fix for this? I have seen some posts talk about an issue with flush_rewrite_rules() ? but this is implemented anyway when you save the permalink page so how can that be the problem? Thanks in advance.


title: Database slowdown after update to 3.4.1

text: I own a wordpress installation, and Updated to 3.4.1. After the upgrade, I got a very strange slowdown to my wordpress. After all, I used the               define('SAVEQUERIES', true);      in my wp-config.php with combined with the following code in my theme footer.php               global $wpdb;     echo "<pre>";     print_r($wpdb->queries);     echo "</pre>";      and I found that while I don't have many queries (49 queries I got), there are   * 4 Quiries took more than 9''   * 3 Quiries took more than 8''   * 4 Quiries took more than 7''   * 4 Quiries took more than 6''   * 8 Quiries took more than 5''   * 1 Quiry took more than 4'' Here I will show you some of the queries:               /* Execution time 7.0095062E-5 */     SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category') AND tt.count > 0 ORDER BY t.name ASC          /* Execution time 5.3167343E-5 */     SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (77375,77379,77381)          /* Execution time 9.2029572E-5 */     SELECT wp_posts.* FROM wp_posts WHERE ID IN (77381,77379,77375)      In most of the queries there query is simple, with no complexity, and I cannot imagine why that queries are so slow. The WordPress database contains in about 60.000 records and running on percona. Any idea for that issue and how maybe can I fix it ?


title: How to get duplicate array count with custom post type

text: After printing array I am getting output like this:               Array     (         [0] => WP_Post Object             (                 [ID] => 8                 [post_author] => 1                 [post_date] => 2014-01-31 15:20:56                 [post_date_gmt] => 2014-01-31 15:20:56                 [post_content] =>                  [post_title] => Surin Beach                 [post_excerpt] =>                  [post_status] => publish                 [comment_status] => open                 [ping_status] => open                 [post_password] =>                  [post_name] => surin-beach                 [to_ping] =>                  [pinged] =>                  [post_modified] => 2014-01-31 15:20:56                 [post_modified_gmt] => 2014-01-31 15:20:56                 [post_content_filtered] =>                  [post_parent] => 0                 [guid] => http://localhost/wp/?post_type=destination&p=8                 [menu_order] => 0                 [post_type] => destination                 [post_mime_type] =>                  [comment_count] => 0                 [filter] => raw             )          )     Array     (         [0] => WP_Post Object             (                 [ID] => 10                 [post_author] => 1                 [post_date] => 2014-01-31 15:21:33                 [post_date_gmt] => 2014-01-31 15:21:33                 [post_content] =>                  [post_title] => Bangtao Beach                 [post_excerpt] =>                  [post_status] => publish                 [comment_status] => open                 [ping_status] => open                 [post_password] =>                  [post_name] => bangtao-beach                 [to_ping] =>                  [pinged] =>                  [post_modified] => 2014-01-31 15:21:33                 [post_modified_gmt] => 2014-01-31 15:21:33                 [post_content_filtered] =>                  [post_parent] => 0                 [guid] => http://localhost/wp/?post_type=destination&p=10                 [menu_order] => 0                 [post_type] => destination                 [post_mime_type] =>                  [comment_count] => 0                 [filter] => raw             )          )     Array     (         [0] => WP_Post Object             (                 [ID] => 9                 [post_author] => 1                 [post_date] => 2014-01-31 15:21:16                 [post_date_gmt] => 2014-01-31 15:21:16                 [post_content] =>                  [post_title] => Layan                 [post_excerpt] =>                  [post_status] => publish                 [comment_status] => open                 [ping_status] => open                 [post_password] =>                  [post_name] => layan                 [to_ping] =>                  [pinged] =>                  [post_modified] => 2014-01-31 15:21:16                 [post_modified_gmt] => 2014-01-31 15:21:16                 [post_content_filtered] =>                  [post_parent] => 0                 [guid] => http://localhost/wp/?post_type=destination&p=9                 [menu_order] => 0                 [post_type] => destination                 [post_mime_type] =>                  [comment_count] => 0                 [filter] => raw             )          )     Array     (         [0] => WP_Post Object             (                 [ID] => 10                 [post_author] => 1                 [post_date] => 2014-01-31 15:21:33                 [post_date_gmt] => 2014-01-31 15:21:33                 [post_content] =>                  [post_title] => Bangtao Beach                 [post_excerpt] =>                  [post_status] => publish                 [comment_status] => open                 [ping_status] => open                 [post_password] =>                  [post_name] => bangtao-beach                 [to_ping] =>                  [pinged] =>                  [post_modified] => 2014-01-31 15:21:33                 [post_modified_gmt] => 2014-01-31 15:21:33                 [post_content_filtered] =>                  [post_parent] => 0                 [guid] => http://localhost/wp/?post_type=destination&p=10                 [menu_order] => 0                 [post_type] => destination                 [post_mime_type] =>                  [comment_count] => 0                 [filter] => raw             )          )      Now I want to get duplicate count of `[post_title]`. I want output like this:               Surin Beach(1)     Bangtao Beach(2)     Layan (1)      My PHP Code:               <?php         // First lets set some arguments for the query:         // Optionally, those could of course go directly into the query,         // especially, if you have no others but post type.         $args = array(             'post_type' => 'book',             'posts_per_page' => -1             // Several more arguments could go here. Last one without a comma.         );              // Query the posts:         $obituary_query = new WP_Query($args);              // Loop through the obituaries:         while ($obituary_query->have_posts()) : $obituary_query->the_post();                  $name = get_field('name');                  echo "<pre>";                 print_r($name);             echo "</pre>";              endwhile;              // Reset Post Data         wp_reset_postdata();     ?>      I will appreciate if someone guide me.


title: Are transients private or public?

text: Are WP transients specific to the user-session or can they be accessed from any session anywhere? Since they are written to the DB, I would imagine they are public and accessible everywhere, but is there a way to limit their scope to only one user's session? The website I am building does not offer a login/memmbership option. By _user_ I mean anyone that is viewing the website - I'm **not** talking about `wp_users`! Example:   * I load the home page which generates a random number and stores it into a transient which should be accessible within that same session.   * However, even from the same computer, but from a different browser, or different IP, I should not be able to access this transient... Is this possible?


title: How to remove the category from post slug

text: I want to remove the category from post slug, for example a post slug like "http://my_site.com/uncategorized/hello-world/" would become "http://my_site.com/hello-world/". My search only gives results about how to remove the word "category" from slugs, which is a different problem.


title: Use menu class in walker function

text:
Is there anyway, using the custom menu css classes that are turned on in the option, to apply those via a walker function to the `span` instead of the `li's`? My custom walker:               class ik_walker extends Walker_Nav_Menu {              function start_lvl(&$output, $depth) {             $GLOBALS['ik_walker_counter'] = 0;             $output .= ''.                 '
';         }              function end_lvl(&$output, $depth) {             $output .= '
'.                 '<button id="menu" class="menu-button" type="button" role="button" aria-label="Menu Toggle">'.                 ''.                 '</button>'.                 '
';         }              function start_el(&$output, $item, $depth, $args) {             global $wp_query;             $GLOBALS['ik_walker_counter']++;             $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';             $class_names = $value = '';             $classes = empty( $item->classes ) ? array() : (array) $item->classes;             $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );             $class_names = ' class="' . esc_attr( $class_names ) . '"';             $output .= $indent . '
ID . '"' . $value . $class_names .'>';             $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';             $attributes .= ! empty( $item->target )  ? ' target="' . esc_attr( $item->target     ) .'"' : '';             $attributes .= ! empty( $item->xfn )        ? ' rel="'  . esc_attr( $item->xfn      ) .'"' : '';             $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';             $attributes .= ' class="c'.$GLOBALS['ik_walker_counter'].'"';             $item_output = $args->before;             $item_output .= '';             $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;             if(strlen($item->description)>2){ $item_output .= '
' . $item->description . ''; }             $item_output .= 'classes .'">';             $item_output .= '';             $item_output .= $args->after;             $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );         }     }      I was trying this:               $item_output .= 'classes .'">';      But i just get:                     This would enable me to control the class via the menu css option so that each can have a unique class. Any help would be much appreciated.


title: Custom Post Type Search

text: I am new to wordpress and need to modify the default search functionality. What file do I have to look for or provide me with some tutorials.. Any help would be much appreciated


title: Delete all the custom post types when deleting user

text: ![delete all custom post type when delete user](http://i.stack.imgur.com/bNDQS.png) I have a problem in custom post types, when I remove user, I can't deleted there post or attribute all posts.


title: How can create a pagination fpr my CPT Template

text:
I create a template for my book cpt archiv. How can creat a Pagination Page prev 1 2 3 next to the E-Paper Archiv Template? Twenty Ten Template                   <?PHP                 /*         Template Name: EPaper-Archive         */              // Wordpress Kopfbereich laden         get_header();                   /* Get the page content*/             the_post();              echo '
'. get_the_title() .'
';         echo '
'. get_the_content() .'
';             ?>

          <?php               // Intro Text (from page content)              $args = array(             'post_type' => 'book', // enter your custom post type             'orderby' => 'menu_order',             'order' => 'ASC',             'posts_per_page'=> '2',  // overrides posts per page in theme settings         );              $loop = new WP_Query( $args );              if( $loop->have_posts() ):                       while( $loop->have_posts() ): $loop->the_post(); global $post;                           $linktext1 = "Wanderführer zum Online durchbl&aumltern";                 $linktext2 = "Wanderführer als Download";                 $linktext3 = "Wanderführer Tourdaten ansehen";                       $my_content1    = get_post_meta( get_the_ID(), '_my_meta_value_key', true );                 $my_content2    = get_post_meta( get_the_ID(), 'pdfurl', true );                 $my_content3    = get_post_meta( get_the_ID(), 'artikelurl', true );                      $the_post       = get_post($post_id); //Gets post ID                      $the_excerpt    = $the_post->post_excerpt; // Auszug anzeigen                 $the_content    = $the_post->post_content; // Content anzeigen                  ?>

                                                       <?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?>
                         <?php the_title(); ?>

                              <?php if ( $the_excerpt != "" ) { ?>
<?PHP echo $the_excerpt ?>
                          <?php } else { ?>
<?PHP echo $the_content ?>
                          <?php } ?>                                   <?php if ( get_post_meta( get_the_ID(), '_my_meta_value_key', true ) ) : ?>                         <a href="<?PHP echo $my_content1 ?>"><?PHP echo $linktext1;  ?>
                         <?php endif; ?>                              <?php if ( get_post_meta( get_the_ID(), 'pdfurl', true ) ) : ?>                         <a href="<?PHP echo $my_content2 ?>"><?PHP echo $linktext2;  ?>
                         <?php endif; ?>                              <?php if ( get_post_meta( get_the_ID(), 'artikelurl', true ) ) : ?>                         <a href="?p=<?PHP echo $my_content3 ?>"><?PHP echo $linktext3;  ?>
                         <?php endif; ?>

                  <?PHP                  endwhile;              endif;              ?>

          <?php get_sidebar(); ?>     <?php get_footer(); ?>      Webpage: http://www.wandernimsaaletal.de/?page_id=705


title: Conditional config WP_HOME/WP_SITEURL does not update bloginfo('template_url')?

text: ## The scenario: This question relates to Wordpress theme development on a local environment via MAMP. In order to enable mobile device testing via xip.io, I have modified my local Wordpress `wp-config.php` file with the following:               require_once('b5f-browsers.php');     if( b5f_browser_check('mobile')) {         define('WP_HOME','http://mysite.dev.'.$_SERVER['SERVER_ADDR'].'.xip.io');         define('WP_SITEURL','http://mysite.dev.'.$_SERVER['SERVER_ADDR'].'.xip.io');     }      _NOTE: Credit for this solution goes tobrasofilo in this related post._ * * * ## The problem: My custom theme's HTML head and footer blocks contain calls to CSS and JavaScript files using the standard `bloginfo('template_url')` function. This works normally when browsing on the host computer. But on mobile devices, the main site base domain as defined under _WP Admin > Settings > General_ is used in the 'template_url' instead of the conditional override as specified in the `wp-config.php` file above. So I get lines like this:               <link rel="stylesheet" href="http://mysite.dev/wp-content/themes/mytheme/style.css">      Instead of this:               <link rel="stylesheet" href="http://mysite.dev.HOST-IP-ADDRESS.xip.io/wp-content/themes/mytheme/style.css">      * * * ## A workaround: Interestingly, I noticed that `bloginfo('wpurl')` returns the correct **xip.io** URL for mobile, and other core Wordpress functions such as `bloginfo('rss_url')` obey the URL override. But `bloginfo('template_url')` just doesn't seem to want to do it. So as a workaround, I am using `bloginfo('wpurl')` then adding the full path to the theme directory instead:               <link rel="stylesheet" href="<?php bloginfo('wpurl'); ?>/wp-content/themes/mytheme/style.css">      But this doesn't seem like the right way to go about it... * * * ## The question: Is there a better/correct way to handle this?


title: Trying to customize wordpress drop down categories

text: I'm having some problems on how to display the categories that i want in wp_dropdown_categories. Here is an image of the drop down - > > ![](http://i255.photobucket.com/albums/hh140/testament1234/customizeddropdown_zps8d2fe3c7.png) Here is the code for the dropdown - **HTML:**               <?php wp_dropdown_categories( $args ); ?>       **JS:**               <script type="text/javascript">     var dropdown = document.getElementById("cat");     function onCatChange() {         if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {             location.href = "<?php echo get_option('home');     ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;         }     }     dropdown.onchange = onCatChange;     </script>      I tried placing this code in my functions.php and customize it but it doesn't seem to work. PHP is not my strong point.               <?php $args = array(     'show_option_all'    => '',     'show_option_none'   => '',     'orderby'            => 'ID',      'order'              => 'ASC',     'show_count'         => 0,     'hide_empty'         => 1,      'child_of'           => 0,     'exclude'            => '',     'echo'               => 1,     'selected'           => 0,     'hierarchical'       => 0,      'name'               => 'cat',     'id'                 => '',     'class'              => 'postform',     'depth'              => 0,     'tab_index'          => 0,     'taxonomy'           => 'category',     'hide_if_empty'      => false,         'walker'             => ''     ); ?>


title: Woocommerce "read more" instead of "add to cart"

text: Right now my shop have this "add to cart" button. How can I replace this with a "read more" or "show more" button? The "read more" button should link to the product page instead of just add it to the cart. Can I add a something to the `functions.php` to call this? I guess this function is built into the system?


title: How make theme css be first and not plugin css

text: I have in theme `<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />` I had 3.6 wordpress with my own theme and plugins witch have css. Since on update changes in plugin css i made changed on plugin update then i put just what i change in theme css. Now i did wordpress 3.7.1 update and somehow now plugin css is overtaking my theme css changes. PS maybe helps. Also Previously admin menu on beeing logged in was just showing 25px space. Now this top admin menu shows up in my theme when im logged in.


title: Get wordpress page link with Post ID & Paged Number provided

text: how can i get page link with Post ID & Page number provided. our current way to get page link is just by using `get_pagenum_link` but this function only consume page number, and escape. is there any function that give ability to get page link with both post id & page number? Thank you


title: BuddyPress - Get a List of Defined xProfile fields

text: "How can I retrieve all xProfile fields?"


title: Add a button to users.php

text: I am working on a plugin that adds meta data for each user to the users.php table that is displayed by adding columns. I have that done but I would like to also add a button that will delete the meta data of the users when pressed. I'm not sure how I can add it. I would like it to be to the right of the 'change' button. I thought that the behavior would be to reload the page but when it does, I'll have it delete the meta data for each user. Where would I start to add that button to the page? Is this the best way to go about this? Thanks!


title: WooCommerce using wrong template - how do I change it?

text: I use the Responsive Child Theme - and its parent - for my website. It seems that WooCommerce is using the content with sidebar template for the store and product pages. I think it will look better using the full page template, but I cannot see where I select the template of choice. Can anyone direct me?


title: Manually Insert Title & Meta Description for Pagination pages?

text: This is second version of question Customized title tag for each page in pagination? answered by @joostvanhoof . I would like to add customized **title tag** `<title>` and different **meta description** `<meta name="description" content="this is description">` for each page in my pagination pages. Below are different pages i meant. Pagination for all Index pages (65+ pages) `http://abc.com/page/2/` Pagination for all Categories(22+ pages each in 4 categories)   `http://abc.com/this-is-category-no-1/page/2/`   `http://abc.com/this-is-my-cat-no-2/page/3/` Below is the code i will be using for index pagination pages.               function titles(){         if(is_home() && $paged == 2){ return 'Manually inserted title for Page 2'; }     else if(is_home() && $paged == 3){ return 'Manually inserted title for Page 3'; }     else if(is_home() && $paged == 4){ return 'Manually inserted title for Page 4'; }          if(is_category('category_title_here') && $paged == 2){ return 'title for Cat Page 2'; }     }      I can use it in the theme pages `<title><?php echo $titles; ?></title>`


title: jquery slider video

text: $(function(){ $('#slider1').bxSlider({ pager: true, buildPager: function(slideIndex){ switch (slideIndex){ case 0: return '![](/sites/all/themes/bx/images/pic_velvet1_thumb.jpg)'; case 1: return '![](/sites/all/themes/bx/images/pic_velvet2_thumb.jpg)'; case 2: return '![](/sites/all/themes/bx/images/pic_velvet3_thumb.jpg)'; case 3: return '![](/sites/all/themes/bx/images/pic_velvet4_thumb.jpg)'; } } }); });


title: the_post_thumbnail scaling not hard cropping

text: Lately I wanted to upgrade my blog with featured images/post thumbnails. I'm using a custom theme build on the roots theme (this is not a roots theme issue, I believe). The image I upload is 1024x768 and shall be cropped to letterbox format 1024x512. This is the code I'm using in the theme-file:               <?php         if ( has_post_thumbnail() ) {         the_post_thumbnail(array(1024, 512), array('class' => 'img-responsive')); // add post thumbnail             }         ?>      Now, the problem is, that on my local XAMPP box it works perfectly well. But on the webserver images aren't cropped and, they do not span the entire width of the primary content area, as they do on the local install. Checking the code with Firebug, the image is 682px wide and 512px tall (1024 x 512px on the XAMPP box). So what happens is that the image is scaled, not cropped. I re-uploaded the theme and I disabled all plugins. And of course I searched related topics, tried other code samples, checked that GD is enabled - it is and regenerated thumbs. None of this solved the problem. Any ideas greatly appreciated.


title: Can I use %category% like Templates in my Plugin?

text: I have seen that Wordpress uses `%category%` like strings to create url templates. Is there an easy way to allow such mechanism in a plugin? For example in the plugin's settings page user specifies an option               `<a href=%my_url%>Click here</a>`      And in my plugin I replace `%my_url%` with an actual URL before `echo`ing it. Is there a function/mechanism in wordpress that I can use to achieve this?


title: what code to add to search.php

text: what line of code can i add to my search page in order to display the results up to 3-5 pages per "search


title: Display Custom Post Type in Custom Taxonomy URL

text: I have created a custom post type with two custom taxonomies, which will eventually be used to filter the results in the custom post type. The problem I am having is that I would like the URL to read: site-url/custom-post-type/custom-taxonomy I've tried using some of the suggestions for people with similar problems on here, but I cannot get it working in this instance. This is the code I have at the moment, I've stripped it back as the attempts to get this working were in vain:               //Custom Post Types          add_action( 'init', 'create_post_type' );     function create_post_type() {     register_post_type( 'listing',         array(             'labels' => array(                 'name' => __( 'Listings' ),                 'singular_name' => __( 'Listing' )             ),         'public' => true,         'has_archive' => true,         'show_ui' => true,         'capability_type' => 'post',         'hierarchical' => false,         'rewrite' => array( 'slug' => 'directory', 'with_front' => false ),         'query_var' => false,         'supports' => array( 'title', 'editor' )         )     );     }          //Region Taxonomies          function region_taxonomy() {       register_taxonomy(       'region',       'listing',       array(           'hierarchical' => true,           'label' => 'Regions',           'query_var' => true,           'rewrite' => array('slug' => 'region', 'with_front' => true )       )       );       }            add_action( 'init', 'region_taxonomy' );          //Qualifications Taxonomies     function qualification_taxonomy() {       register_taxonomy(     'qualification',       'listing',       array(           'hierarchical' => true,           'label' => 'Qualifications',           'query_var' => true,           'rewrite' => array('slug' => 'qualification' )       )       );       }      Currently this produces: site-url/region/ or /qualification/ Would be great if someone can help me out with this, wasted hours going round in circles!


title: $wpdb doesn't appear to work on page inside of a plugin

text: I have a plugin folder foobar. Inside this plugin I have a page called foobar.php. Inside this page I have               global $wpdb;               $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'name'; //If no sort, default to title               $sql = "SELECT * FROM wp_nc_location ORDER BY " . $orderby;               $data = $wpdb->get_results($sql);       This query works inside of my foobar.php page. However, in the same folder I have another page called process.php, and when I include the _identical_ code:               global $wpdb;               $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'name'; //If no sort, default to title               $sql = "SELECT * FROM wp_nc_location ORDER BY " . $orderby;               $data = $wpdb->get_results($sql);       I get the error message:               Fatal error: Call to a member function get_results() on a non-object in...      Why doesn't the global $wpdb appear to work in the other page? (process.php)?


title: frontend image post uploader

text: I've set up image uploader on front end custom form for users with some text input, textareas etc .Everything works fine, untill I decide don't upload any image. Then my "thank you" page gets blank. No head data, no body content just                <html>        <head>        </head>        <body>        </body>      </html>      Here's the code                 //SAVE THE POST     $pid = wp_insert_post($new_post);         if (!function_exists('wp_generate_attachment_metadata')){                 require_once(ABSPATH . "wp-admin" . '/includes/image.php');                 require_once(ABSPATH . "wp-admin" . '/includes/file.php');                 require_once(ABSPATH . "wp-admin" . '/includes/media.php');             }              if (!empty($_FILES)) {                 foreach ($_FILES as $file => $array) {                     if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {                        return "upload error : " . $_FILES[$file]['error'];                         }                     $attach_id = media_handle_upload( $file, $pid );                 }                    }          if ($attach_id > 0){                 //and if you want to set that image as Post  then use:                 update_post_meta($pid,'_thumbnail_id',$attach_id);             }           I think It is related with image uploader validation, becouse when I deleted that part                  if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {                    return "upload error : " . $_FILES[$file]['error'];          It redirects me to "thank you" page and displays everything well, but in admin posts in thumbnail box I receive                    Catchable fatal error: Object of class WP_Error could not be converted to string in      But ther is nothing to be converted, becouse I didn't upload anything... Can anyone help me with this one :) ?


title: Duplicate a Multi-Site Subdomain

text: just 1 click ..and it duplicates ALL content, settings, css, plugins.. im looking for a plugin that adds a new link to Sites admin; Edit | Dashboard | Deactivate | Archive | Spam | Delete | Visit | **DUPLICATE**... it should copy ALL settings/configs. and create a new subdomain instance in the **existing** Multisite


title: Upgrading WordPress (File permission group owner)

text: I have a problem when i want to upgrade Wordpress or install plugin via the Admin. It's say that I don't have the permission to write. but I can upload images and other things... but i cannot install plugin and/or update plugin/WordPress. I know that my user server is not the file owner but is part of the group owner.


title: two active templates for one post

text: I wanna have   * `example.com/post-name` -> uses template1.php   * `example.com/post-name/details` -> uses template2.php I found this discussion, so I implemented the codes in my theme’s `functions.php`. I also made the changes from the older replies but I get this error > Warning: call_user_func_array() expects parameter 1 to be a valid callback, > function 'detail_rewrite_rules' not found or invalid function name in > /public_html/wp-includes/plugin.php on line 173 I didn’t edit `plugin.php` and on line 173 is:               $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));      I hope someone can help me, it seems a fairly easy job but I might be wrong.


title: Separate registration and login for different roles

text: I've set 2 new roles for my site using the "Members" plugin - "sellers" and "buyers". Each role should have its own registration page and login. A visitor can register as both a buyer and a seller but he can only be logged in as one of them. So, if a visitor has logged in as a seller and then goes to the buyer page he'll be able to login as a buyer and when he does so he will automatically be logged out as a seller. I've searched for hours for a plugin that will give me the option to do this but couldn't find one. Sounds like a pretty common configuration in websites with different role registrations. Does a plugin such as this even exist? And if not how can this be done?


title: Custom meta fields for specific custom type only

text:
I've got a custom post type `curiculum` and a metabox that saves a value to a custom field. However this custom field is added to another custom post type (created by an e-commerce plugin) `wpsc-product`. This is a snippet of the code that deals with the metabox. The question is, how to prevent the custom field being added to the `wpsc-product`?               /* Curiculum Date Metabox */     function curiculum_date_fields() {     if ( get_post_type() == 'curiculum'):         global $post;         $custom = get_post_custom( $post->ID );         $curiculum_date_from = $custom["curiculum_date_from"][0];         ?>
             Date:
             <input size="32" type="text" name="curiculum_date_from" id="curiculum_date_from" value="<?php echo $curiculum_date_from; ?>" />     <?php     endif;     }          function add_curiculum_date_box() {         add_meta_box("curiculum_date_info", "Event Date", "curiculum_date_fields", "curiculum", "side");     }          function save_curiculum_date() {         global $post;         update_post_meta($post->ID, "curiculum_date_from", $_POST["curiculum_date_from"]);     }     add_action('admin_init', 'add_curiculum_date_box');     add_action('save_post', 'save_curiculum_date');     add_action('publish_post', 'save_curiculum_date');      EDIT: Code for the `curiculum` custom post type:               add_action('init', 'curiculum_register');          function curiculum_register() {          $labels = array(         'name' => _x('CV Events', 'post type general name'),         'singular_name' => _x('CV Event', 'post type singular name'),         'add_new' => _x('Add New', 'testimonials item'),         'add_new_item' => __('Add New Event'),         'edit_item' => __('Edit Event'),         'new_item' => __('New Event'),         'view_item' => __('View Event'),         'search_items' => __('Search Events'),         'not_found' =>  __('Nothing found'),         'not_found_in_trash' => __('Nothing found in Trash'),         'parent_item_colon' => ''     );          $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,         'query_var' => true,         'rewrite' => true,         'capability_type' => 'post',         'hierarchical' => false,         'menu_position' => 7,         'exclude_from_search' => true,         'supports' => array('title','editor', 'custom-fields')           );              register_post_type( 'curiculum' , $args );      }


title: Add frontend "Restore" link

text: I am using `get_delete_posts_link($postid)` to let users send their posts to the trash from the frontend. Now I'm trying to replicate the same functionality for them to "untrash" or restore the posts as well. `get_delete_posts_link($postid)` seems to generate a URL like this: http://mysite.com/wordpress/wp- admin/post.php?post=555&action=trash&_wpnonce=0d6fc30f3b And when I go to wp-admin and look at what link the Restore link uses, it looks to be same EXCEPT that is uses action=untrash instead of action=trash. Since there doesn't seem to be a function the mirrors the delete post link function, I thought that perhaps manually creating the URL with variables and using the "untrash" action would do it, but it doesn't seem to work that way, restoring won't work. What's the best way to put a link to "restore" a post on the frontend? EDIT: This is the markup I am using the create the "restore" link (not working):               <?php     $untrashurl = get_bloginfo('wpurl') . '/wp-admin/post.php?post=' . $postid . '&action=untrash';     ?>     <a class="db-post-link" href="<?php echo wp_nonce_url($untrashurl); ?>">Untrash


title: Add buttons to "teeny" editor

text: I managed to create a TinyMCE plugin and add it to WordPress editor (which is the same as bbpress). So far so good. Using `$ args ['teeny'] = false;` config, my tinymce plugin’s button show normal. But, I need to be displayed in the default editor for bbpress, in teeny editor. Any ideas?


title: Can't get Category link inside get_posts

text: I created a simple function to display the latest posts. Inside the function there is a conditional to display the post category. I found that to display the category name, using               $category = get_the_category($post->post_ID);           $category[0]->cat_name; // I want to display only the first category      do the job, but can't find how to display the link to the category. Tried to use `get_category_link($post->post_ID)` but no changes, the link still redirects to the current page. The goal is to redirect to category archive. Appreciate any help.


title: Pagination when using multiple loops

text: I've populated my index.php with various post loops and I want to be able to get pagination working. The reason for multiple loops is because I'm pulling in posts from different categories in different locations. Here's an example (screenshot of the code): ![enter image description here](http://i.stack.imgur.com/3BCu3.png) How do I get a working pagination for this way of using loops? Hope I've explained myself adequately enough, and if anybody needs any more information please let me know. Thanks.


title: How do I override a parent theme's language files with a child theme?

text: I have a parent theme and a child theme, I would like to override the spanish .mo and .po files in the parent theme (or add them if they are not present in the parent theme) with the es_ES ones in my child theme. I added the folder with the modified mo and po files in the child theme with the same folder name as in the parent theme but this is not working. How can I come about this? Thanks!


title: add conditionals to a displayed external xml feed

text:
I found the following code online and customized it to pull the xml feeds from our online calendar software and display event information on several different WP pages.               function otpl_add_class_feed() {         if ( is_page(48) ) {             $url = "http://orion.lib.mi.us/evanced/lib/eventsxml.asp?ag=&et=Computer+Class&nd=31&dm=exml&alltime=1";             $xml = simplexml_load_file($url);             foreach($xml->item as$item)                 {                     echo "
";                     echo "
link."'>".$item->title."
";                     echo "
".$item->date." from ".$item->time." to ".$item->endtime."
";                     echo "
".$item->description."
";                     echo "
link."'>Register Online.
";                     echo "
";                 }         } // END IF     }      How can I include a conditional statement so that if $item->date. is populated the above code will run but if $item->date. is empty then another code stating that there are no events scheduled will run? I'm sure it's something simple but my understanding of syntax isn't very strong. My few attempts have broken my functions page.


title: Custom meta boxes for different custom post type on multisite WP

text:
I have two custom post type defined ('acting' and 'voiceover') and custom met boxes defined for both of them. I'm able to save, update and delete on the acting custom post type. But if I add the voiceover custom post type then I'll be not able to save the data on the acting anymore. The two piece of code are similar but not the same. I'll need to add more field to the voiceover. After many hours spent in looking for solution and trying many things, I'm asking your help. **Acting custom meta boxes**                  add_action ('admin_init','acting_meta_boxes');                   function acting_meta_boxes() {     add_meta_box( 'reels_form', 'Acting Details', 'reels_form', 'acting', 'normal', 'high' );         }              function reels_form() {     $post_id = get_the_ID();     $reel_data = get_post_meta( $post_id, '_reel', true );     $client_name = ( empty( $reel_data['client_name'] ) ) ? '' : $reel_data['client_name'];     $agency = ( empty( $reel_data['agency'] ) ) ? '' : $reel_data['agency'];     $production_company = ( empty( $reel_data['production_company'] ) ) ? '' : $reel_data['production_company'];     $director = ( empty( $reel_data['director'] ) ) ? '' : $reel_data['director'];     $video_id = ( empty( $reel_data['video_id'] ) ) ? '' : $reel_data['video_id'];            wp_nonce_field( 'acting', 'acting' );     ?>
         YouTube video ID
         <input type="text" value="<?php echo $video_id; ?>" name="reel[video_id]" size="20" />

         Client's Name (optional)
         <input type="text" value="<?php echo $client_name; ?>" name="reel[client_name]" size="80" />

         Agency Name (optional)
         <input type="text" value="<?php echo $agency; ?>" name="reel[agency]" size="80" />

         Production Company (optional)
         <input type="text" value="<?php echo $production_company; ?>" name="reel[production_company]" size="80" />

         Director (optional)
         <input type="text" value="<?php echo $director; ?>" name="reel[director]" size="80" />
          <?php          }              add_action( 'save_post', 'reels_save_post', 10, 2 );              function reels_save_post( $post_id ) {               if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )         return;          if ( ! empty( $_POST['acting'] ) && ! wp_verify_nonce( $_POST['acting'], 'acting' ) )         return;          if ( ! empty( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {         if ( ! current_user_can( 'edit_page', $post_id ) )             return;     } else {         if ( ! current_user_can( 'edit_post', $post_id ) )             return;     }          if ( ! wp_is_post_revision( $post_id ) && 'acting' == get_post_type( $post_id ) ) {         remove_action( 'save_post', 'reels_save_post' );              wp_update_post( array(             'ID' => $post_id,         ) );              add_action( 'wp_inset_post_data', 'reels_save_post' );     }          if ( ! empty( $_POST['acting'] ) ) {         $reel_data['client_name'] = ( empty( $_POST['reel']['client_name'] ) ) ? '' : sanitize_text_field( $_POST['reel']['client_name'] );         $reel_data['agency'] = ( empty( $_POST['reel']['agency'] ) ) ? '' : sanitize_text_field( $_POST['reel']['agency'] );         $reel_data['production_company'] = ( empty( $_POST['reel']['production_company'] ) ) ? '' : sanitize_text_field( $_POST['reel']['production_company'] );         $reel_data['director'] = ( empty( $_POST['reel']['director'] ) ) ? '' : sanitize_text_field( $_POST['reel']['director'] );         $reel_data['video_id'] = ( empty( $_POST['reel']['video_id'] ) ) ? '' : sanitize_text_field( $_POST['reel']['video_id'] );              update_post_meta( $post_id, '_reel', $reel_data );     } else {         delete_post_meta( $post_id, '_reel' );     }         }      **Voiceover custom meta boxes**                   add_action ('admin_init','voiceover_meta_boxes');                   function voiceover_meta_boxes() {             add_meta_box( 'reels_voiceover_form', 'Voiceover Details', 'reels_voiceover_form', 'voiceover', 'normal', 'high' );             }                       function reels_voiceover_form() {             $post_id = get_the_ID();             $reel_data = get_post_meta( $post_id, '_reel', true );             $client_name = ( empty( $reel_data['client_name'] ) ) ? '' : $reel_data['client_name'];             $agency = ( empty( $reel_data['agency'] ) ) ? '' : $reel_data['agency'];             $production_company = ( empty( $reel_data['production_company'] ) ) ? '' : $reel_data['production_company'];             $director = ( empty( $reel_data['director'] ) ) ? '' : $reel_data['director'];             $video_id = ( empty( $reel_data['video_id'] ) ) ? '' : $reel_data['video_id'];               $audio_id = ( empty( $reel_data['audio_id'] ) ) ? '' : $reel_data['audio_id'];                        wp_nonce_field( 'voiceover', 'voiceover' );             ?>
                 YouTube video ID
                 <input type="text" value="<?php echo $video_id; ?>" name="reel[video_id]" size="20" />

                 Soundcloud ID
                 <input type="text" value="<?php echo $audio_id; ?>" name="reel[audio_id]" size="20" />

                 Client's Name (optional)
                 <input type="text" value="<?php echo $client_name; ?>" name="reel[client_name]" size="80" />

                 Agency Name (optional)
                 <input type="text" value="<?php echo $agency; ?>" name="reel[agency]" size="80" />

                 Production Company (optional)
                 <input type="text" value="<?php echo $production_company; ?>" name="reel[production_company]" size="80" />

                 Director (optional)
                 <input type="text" value="<?php echo $director; ?>" name="reel[director]" size="80" />
                  <?php         }              add_action( 'save_post', 'reels_save_voiceover_post', 10, 2 );              function reels_save_voiceover_post( $post_id ) {             if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )                 return;                  if ( ! empty( $_POST['voiceover'] ) && ! wp_verify_nonce( $_POST['voiceover'], 'voiceover' ) )                 return;                  if ( ! empty( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {                 if ( ! current_user_can( 'edit_page', $post_id ) )                     return;             } else {                 if ( ! current_user_can( 'edit_post', $post_id ) )                     return;             }                  if ( ! wp_is_post_revision( $post_id ) && 'acting' == get_post_type( $post_id ) ) {                 remove_action( 'save_post', 'reels_save_voiceover_post' );                      wp_update_post( array(                     'ID' => $post_id,                 ) );                      add_action( 'save_post', 'reels_save_voiceover_post' );             }                  if ( ! empty( $_POST['voiceover'] ) ) {                 $reel_data['client_name'] = ( empty( $_POST['reel']['client_name'] ) ) ? '' : sanitize_text_field( $_POST['reel']['client_name'] );                 $reel_data['agency'] = ( empty( $_POST['reel']['agency'] ) ) ? '' : sanitize_text_field( $_POST['reel']['agency'] );                 $reel_data['production_company'] = ( empty( $_POST['reel']['production_company'] ) ) ? '' : sanitize_text_field( $_POST['reel']['production_company'] );                 $reel_data['director'] = ( empty( $_POST['reel']['director'] ) ) ? '' : sanitize_text_field( $_POST['reel']['director'] );                 $reel_data['video_id'] = ( empty( $_POST['reel']['video_id'] ) ) ? '' : sanitize_text_field( $_POST['reel']['video_id'] );                 $reel_data['audio_id'] = ( empty( $_POST['reel']['audio_id'] ) ) ? '' : sanitize_text_field( $_POST['reel']['audio_id'] );                            update_post_meta( $post_id, '_reel', $reel_data );             } else {                 delete_post_meta( $post_id, '_reel' );             }         }      I'm running the whole thing in a multisite WP environment. I hope somebody can help me to figure it out.


title: Hide custom image sizes from media library

text: I want to hide a few custom image sizes from the media uploader: ![enter image description here](http://i.stack.imgur.com/2Qm9q.png) The following code (posted here) works **only** for the default image sizes:               function remove_image_sizes($sizes) {         unset($sizes['image-name']);         return $sizes;     }     add_filter('image_size_names_choose', 'remove_image_sizes');      Is there a similar solution to unset custom image sizes?


title: Tag page only display 10 posts

text:
I've had a problem with this for quite some time now and cannot for the life of me figure it out. I am using Multi-site and not sure if that has anything to do with it or not, so keep that in mind. # Problem: When clicking on tags on a post or custom post type, I only get the default post count set by WP which is 10 posts as results. Pagination shows at the bottom for next post and older posts, but when I click on either link, page 2 is not found and it sends me to 404 page. There is a mix of regular posts and then custom posts types that should be showing, but regardless the post type, it only shows 10 even though there are hundreds. At first I was using the Twentyten way of showings tags which was using `get_template_part()` and redirecting to a loop.php page. I have sense eliminated that process and created my own tag.php page and use the default wordpress loop to query for posts.               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>      However I had to use this bit of code to query for all posts types and not just the regular ones.               global $wp_query;     $args = array_merge( $wp_query->query, array( 'post_type' => array('post, cool_tools, tribe_events') ) );     query_posts( $args );      My pagination code for the page reads :

<?php next_posts_link( __( '← Older posts', 'twentyten' ) ); ?>

<?php previous_posts_link( __( 'Newer posts →', 'twentyten' ) ); ?>

      The url to the missing page is:               /tag/tagname/page/2/      Can anyone tell me why WP wont find any more tags? ## **Update As per Chip's example, here is how I have it setup now.               $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;          $args = array(         'post_type' => 'post',         'tag_slug__and' => $tagname,         'paged' => $paged     );          $query = new WP_Query($args);          if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();      Yet when I click newer posts at the bottom, it still takes me to a 404 page and no page 2 found for tags.


title: Plugin or script to apply updated media settings to all featured images

text: I need to know if there exists a script or plugin that will add a button the "Settings > Media Settings" that will rebuild all thumbnails to match the current media size settings. The problem this seeks to solve is when the site owner decides he/she would like different thumbnail and featured image sizes after having uploaded several at the wordpress default settings of 150px, 300px, 1200px This solution would allow users to auto resize the images in one click to match the current settings.


title: Create a folder if it doesn't already exist

text: I've run into a few cases with wordpress installs with bluehost where I've encountered errors with my wordpress theme because the uploads folder (wp- content/uploads) was not present. Apparently the bluehost cpanel WP installer does not create this folder, though HostGator does. So I need to add code to my theme that checks for the folder and creates it otherwise.


title: loop not displaying posts on custom template page

text:
I have a site using a static homepage, and a posts page called Press(`press.php`). The template is being pulled up correctly, however no posts are shown. Any ideas why? Thanks in advance. Live site. **press.php**               <?php     /*     Template Name: Press     */     ?>               <?php get_header(); ?>
         <a href="<?php bloginfo('url'); ?>"><img src="<?php echo get_template_directory_uri(); ?>/img/parlour_side.png" alt="Parlour Salon logo" id="logo" />

             <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                 <?php the_content('read more...'); ?>
<?php the_date(); ?>
             <?php endwhile; ?>             <?php else : ?>
I'm not sure what you're looking for.
             <?php endif; ?>
          <?php get_footer(); ?>


title: Will deleting WP's code in .htaccess cause problems?

text: I need to use the following redirect on my site:               RewriteEngine on     RewriteCond %{HTTP_HOST} name.com     RewriteCond %{REQUEST_URI} ^/(1[0-9]{3}|200[0-9]|201[0-3])      RewriteCond %{REQUEST_URI} !/2013/12      RewriteRule ^([0-9]{4})/([0-9]{2})/(.*)$  http://v2.name.com/$1/$2/$3 [NC,R=301]      However, it only works if I delete the code Wordpress put in my .htaccess (I've tried putting it both before and after this code with no luck):               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      What sort of problems is this going to cause if I delete it permanently? And is there some way around this?


title: Custom Post Type Rewrite Rule

text: My theme uses the following code:               'rewrite' => array('slug' => $this->safe_name . '-detail'),      which produces this slug:               http://www.example.com/estate-detail/4-bedroom-property-for-sale/      I need to get rid of the 'estate-detail' part so I changed the rule to just:               'rewrite' => array('slug' => ' '),      This produces the slug as:               http://www.example.com//4-bedroom-property-for-sale/      How do I get rid of the double forward slash?


title: new_excerpt_more link not working properly

text: My "Read More" button is linking to the current page page instead of the excerpt page it is suppose to be linking to. Here is my function in function.php file:               function new_excerpt_more($more) {        global $post;     return ' ID) . '"> ...Read More';     }     add_filter('excerpt_more', 'new_excerpt_more');      This is occurring in in excerpts being displayed from a custom walker for wp_list_pages.


title: Vague Errors from VIP Scanner Plugin

text: I am building a site with WordPress 3.4.2, have made a child theme of WooTheme's Canvas 5 (http://www.woothemes.com/2012/06/canvas/) and am now using the VIP Scanner plugin (http://wordpress.org/extend/plugins/vip- scanner/). I managed to resolve the majority of the errors outputted for my child theme, but one or two of them are vaguely worded and I cannot figure out a way to solve them:   1. Warning: Possible output of restricted variables   2. Warning: Attribution link missing or not well formatted Any advice? Thanks


title: How to sort a custom wordpress query by combination of meta values?

text: I'm trying to build a custom query that's a combination of custom key values. For example, with the code below I'm able to sort my posts by how much money they've received (paidusd) and how much tips they've received (totaltips). This code is working great. But what I'd like to do is add another sort for "most profitable" which would be the ratio of paidusd to totaltips. Where would I perform that division equation? I'm stumped. Any help is greatly appreciated - thanks!!!!               if ( $_GET['sort'] == 'mostexpensive'){         //query_posts('&meta_key=paidbtc&orderby=meta_value');         $args = array(                        'meta_key' => 'paidusd',                        'orderby' => 'meta_value',                        'posts_per_page' => 10,                        'paged' => $paged                        );         query_posts($args);     }          if ( $_GET['sort'] == 'mosttipped'){         $args = array(                        'meta_key' => 'totaltips',                        'orderby' => 'meta_value',                        'posts_per_page' => 10,                        'paged' => $paged                        );         query_posts($args);     }


title: Display revision if post status is pending

text:
I'm trying to display the latest post revision if the page is "pending", by default the page displays a 404 if it is pending. But I want it to show the latest revision until the page is updated. The code below doesn't seem to display anything but the title, I have used a hook to the `wp_insert_post_data` function which changes the status of the post to "pending" if the users role isn't admin. The post is set to pending in the database, but I cannot get the below code to show the latest revision? I also don't know how to prevent it from redirecting to a 404 page? If I am logged in it will show the post otherwise a 404 page.                   <?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
                                       <?php              echo get_post_status(); //echo's pending             if(get_post_status() == 'pending') {                 $query = new WP_Query(array('post_type' => 'revision', 'post_parent' => '7', 'posts_per_page' => 1)); // 7 is the current page ID                 if ($query->have_posts()) {                                      while ($query->have_posts()) {                                               $query->the_post();                                              the_content();                         echo $post->ID;                     }                 }                 wp_reset_postdata();             } else {                 the_content();              }                            ?>                    <?php endwhile; ?>     <?php endif; ?>      Any advice? Is there an easier way to show the revision if the page is pending? Thanks ! **Edit:** Okay I seem to have it working using the code below:               if(get_post_status() == 'pending') {        $query = 'SELECT ID FROM `wp_posts` WHERE `post_parent` = '.$post->ID.' AND `post_type` = "revision" AND `post_status` = "pending" AND `post_title` <> "Auto Draft" AND TRIM(`post_content`) <> "" AND `post_name` NOT LIKE "%autosave%" ORDER BY `post_modified` DESC LIMIT 1';        $revision_id = $wpdb->get_var($query);        $revision = wp_get_post_revision($revision_id);        $content = $revision->post_content;                      $content = apply_filters('the_content', $content);        $content = str_replace(']]>', ']]>', $content);        echo $content;        wp_reset_postdata();     } else {        the_content();      }      So now the question is - **How can I prevent a page which is set as pending to redirecting to the 404 page?**


title: Theme deactived html and css styling on home page posts

text: I'm a designer trying to learn php, so I can't fully understand where the problem is coming from. That being said, I have a theme that has deactivated the use of css styling on the main page where posts are mainly displayed. This is the (f8) lite theme by the way. I want to create links useing divs and what not, but when i throw in the code it dosent show up. But when you enter the post the css is rendered out perfectly. I think the culprit has something to do with the plugin it comes ingrained with called "get the image". And no there arn't any options to turn off the plugin. Please if anyone has any ideas, please fire away. And TIA


title: Restrict the number of images to upload per post

text: Is there an easy way to limit to one (per post) the number of images to upload through media upload?


title: General advice on addressing content-centric pages

text: I'm looking to port a site into Wordpress that contains not just an About page, but an entire About section with various pages highlighting particular details about the company. Each of these pages vary in terms of layout and content but none are what could be described as being amendable to a custom post type. This is mainly because the site should only have one instance of each of these pages at any given time. So I'm looking for some advice on how to handle pages like these. As far as I know the two options are custom templates and custom post types, but both seem to have drawbacks:   * custom templates would allow the author to make pages and associate them to the appropriate template, but I'd like to add extra metaboxes for certain aspects of these pages. But it seems (correct me if I'm wrong) adding metaboxes to pages would apply them to all pages.   * custom post types - I could define a custom post type for each 'type' of about page. This would give me my metabox flexibility but this seems like a 'heavy' approach. Also, not sure I could establish parent/child pages within a CTP? Any advice on the best approach here? I'm leaning towards CTPs but would love to know of any best-practices for these types of pages. Thanks in advance


title: Unusual behaviour in my wordpress due to htaccess

text: I discovered that wordpress/buddypress stopped working (a blank page), and the problem is related to htaccess issues . I found that those lines were added may be automatically (I don't remember adding them) :               <IfModule mod_rewrite.c>     RewriteEngine On          RewriteRule ^wp-admin/includes/ - [F,L]     RewriteRule !^wp-includes/ - [S=3]     RewriteCond %{SCRIPT_FILENAME} !^(.*)wp-includes/ms-files.php     RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]     RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]     RewriteRule ^wp-includes/theme-compat/ - [F,L]          RewriteCond %{REQUEST_METHOD} POST     RewriteCond %{REQUEST_URI} ^(.*)wp-comments-post\.php*     RewriteCond %{HTTP_REFERER} !^(.*)myswebsiteadress.*     RewriteCond %{HTTP_REFERER} !^http://jetpack\.wordpress\.com/jetpack-comment/ [OR]     RewriteCond %{HTTP_USER_AGENT} ^$     RewriteRule ^(.*)$ - [F,L]          </IfModule>      Do you know where those lines come from ? If it is safe to remove them? If not, how can I modify them so wordpress continue working without problems .


title: Query connected posts from 2 diffrent post types (using posts2posts)

text:
Let's say I've got 3 post types: Posts, agenda and charity. I use the plugin Posts2posts from scribu to connect certain posts and certain agenda items to some charity items. On the single page of charity I want to display posts and agenda in the sidebar. I have two problems: **1st problem:** I want them mixed, but still sorted on date **2nd problem:** I want to display _only_ the posts and agenda items connected to my charity post. It will look something like -Last post item connected to this charity -Last agenda item connected to this charity -Forlast post item connected to this charity -Forlast agenda item connected to this charity When using wp_query, I have no idea how to mix those post types and let them display in the right order, only using connected ones. When using scribu's example, I still have no idea how to mix them... :( Does someone has an idea of how I can do this? * * * **UPDATE** I got the query working with jleander's answer. I used `'orderby' => 'date'` and `'order' => 'DESC'` to display the latest posted item first. But I want to display them alternatly, like: last post last agenda item forlast post forlast agenda item * * * Code after great help of jlaender:
         <?php             $post_types = array('post','agenda');             $connection_types = array('post_to_doel','agenda_to_doel');             $args = array(                 'connected_type' => $connection_types,                 'connected_items' => get_queried_object_id(),                 'post_type' => $post_types,                 'order'  => 'DESC',                 'orderby' => 'date'                 );             $connected_stuff = new WP_Query($args);             if ( $connected_stuff->have_posts() ) :             ?>
Related pages:
                  <?php                  $posts = array();             $agendas = array();             $results = array();             $posts[0] = 'first post';             $posts[1] = 'second post';             $posts[2] = 'third post';             $agendas[0] = 'first agenda';             $agendas[1] = 'second agenda';             $agendas[2] = 'third agenda';             while(!empty($posts) || !empty($agendas)) {                 if(!empty($posts)) {                     $results[] = array_shift($posts);                 }                 if(!empty($agendas)) {                 $results[] = array_shift($agendas);                 }             }             foreach($results as $result){                 echo $result; ?>

                  <?php } ?>                  <?php              // Prevent weirdness             wp_reset_postdata();             endif;         ?>


title: Add Incrementing ID to each paragraph in the_content

text: I need to loop through each paragraph in the_content and add an ID to each paragraph with an incremental value.               function incrementparagraphs( $content ) {         for ($i = 0; $i <count($content); $i++) {             return str_replace( "<p>", "<p data-section-id=" . $i . ">", $content );         }     }     add_filter( 'the_content', 'incrementparagraphs', 10, 1 );


title: Category checkboxes in upload modal

text: In a project I'm working on, I've enabled categories for attachments using:               register_taxonomy_for_object_type('category', 'attachment');      In the edit attachment screen in the Media Library you see the normal list of checkboxes, but in the upload modal categories are presented as a comma- separated list of slugs in a textfield, as if they were a non-hierarchical taxonomy. I'm wondering if it's possible to replace this textfield with a list of category chechboxes. I'm trying to do it myself, but there is little documentation about the 3.5 upload modal. Any ideas? Thanks in advance


title: How to publish some default pages in Multisite creation?

text: In multi site environment, I need to publish some pages by default while creating a new site , is this possible?


title: Posts Duplicating due to Pagination and Custom Query

text: I have a custom meta field named “price” and I would like my main query to order the posts from highest to lowest price. Currently I have it setup like this:               <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;      query_posts ("orderby=meta_value_num&meta_key=price&order=DESC&paged=".$paged); ?>              <?php if ( have_posts() ) : ?>                  <?php while ( have_posts() ) : the_post(); ?>                      <?php                     get_template_part( 'content', get_post_format() );                 ?>                  <?php endwhile; ?>                  <?php paging_nav(); ?>              <?php else : ?>                  <?php get_template_part( 'content', 'none' ); ?>              <?php endif; ?>      The issue I am running into is having a post duplicate when going to the second page Let’s say I have 6 posts in total and I have it setup to load 3 posts at a time.   1. $100   2. $90   3. $50   4. $50   5. $25   6. $10 It will load the first three posts no problem and in order by price descending. However when I go to the next page to get the next three posts, Post number 3 would sometimes repeat itself as post number 4 and the original post number 4 would not appear and 5 and 6 would follow like intended. How do I prevent the query from repeating post number 3 just because it have the same price value as post number 4 when I go to the next page? Note this only happens about 50% of the time and the order is usually correct. If post number 3 and 4 were different values, this issue would not happen and it would order correctly 100% of the time. The issue lies in the fact that they are the same value and are separated by pagination since I have it setup to only load 3 at a time. When retrieving the second page of posts, the query does not register the fact it already used post 3 and duplicates it as post 4 seeing they have the same price value. I have tried the "pre_get_posts" function as well as the "new Wp_Query" function, the problem still persists.


title: reducing the amount of wp_query calls

text:
I'm working on a site where we're introducing drop down panels from the menu which will display thumbnails from various tags on the site. Each panel has a left column displaying a featured post, and a right column displaying 6 thumbnails; on each tab then I'm doing two wp_query loops, the first to display the featured post image, and the second to display the 6 thumbnails (with featured post excluded). I'm wondering though if this is the most efficient way of doing things, as there are 10 tabs, so that's 20 uses of wp_query in the main menu. Example code for one of the tabs below:

                  <?php              global $quote_id;             $quote_id=array(); // setup an array to store post ids to exclude from future queries             $argsformainquotes=array(             'posts_per_page' => '1',             'post_status' => 'publish',             'tag' => 'quotes',                       );                       $mainquotes = new WP_Query($argsformainquotes);             while ($mainquotes->have_posts()) : $mainquotes ->the_post();     $idforquote=get_the_id(); $quote_id[]=$idforquote; // add the id of this post to exclusion array             $post_thumbnail_id = get_post_thumbnail_id();         $post_thumbnail_url = wp_get_attachment_image_src( $post_thumbnail_id,'bigfeature'); ?>
<a href="<?php the_permalink();?>" target="_blank"><img src="<?php echo $post_thumbnail_url[0];?>" alt=" <?php the_title();?>"  class="thumblist"  height="240" width="240" />
<a href="<?php the_permalink();?>" title="<?php the_title();?>" class="tablinktitles"><?php the_title();?>

<?php $small_excerpt=get_the_excerpt();echo substr($small_excerpt,0,100);?>

<a href="<?php the_permalink();?>" class="tablinktitles">read more...
<?php endwhile;?>

<?php $argsforquotes=array(             'posts_per_page' => '6',             'post_status' => 'publish',             'tag' => 'quotes',             'post__not_in' => $quote_id,                            );                       $quotes = new WP_Query($argsforquotes);             while ($quotes->have_posts()) : $quotes ->the_post();?>
<?php                             $post_thumbnail_id = get_post_thumbnail_id();         $post_thumbnail_url = wp_get_attachment_image_src( $post_thumbnail_id,'smallfeature' ); ?><a href="<?php the_permalink();?>" target="_blank"><img src="<?php echo $post_thumbnail_url[0];?>" alt=" <?php the_title();?>" height="140" width="140" class="thumblist" />
<a href="<?php the_permalink();?>"><?php $trunctitle=get_the_title();echo substr($trunctitle,0,20);?>...
<?php endwhile;?>

More Quotes...


title: Redirect year month day postname permalink structure to category postname structure

text: I have a Wordpress site with a `/%year%/%monthnum%/%day%/%postname%/` permalink structure, and now the client wants it changed to `/%category%/%postname%/`. How do I do a generic redirect for the old permalink structure to the new structure? I checked out https://yoast.com/wp-content/permalink-helper.php, but it creates redirect code for `/%year%/%monthnum%/%day%/%postname%/` to `/%postname%/`, instead of to `/%category%/%postname%/`


title: trying to use wp_handle_upload with ajax

text: I've used this tutorial to build an option page form with Ajax. Now, i want to use the wp_handle_upload to upload an image. i tried this http://pastebin.com/35HW8RSZ but with no success. help will be appreciated. Asaf.


title: How to work with AJAX and Wordpress?

text: I'm working on my first plugin. I would like to add a follow button for the posts, so the logged in users can follow the authors. I placed the following lines into functions.php               function add_query_vars_filter( $vars ){            $vars[] = "userID";            return $vars;       }     add_filter( 'query_vars', 'add_query_vars_filter' );          // The code to display the button     function show_follow_button() {         $author_ID = get_the_author_meta('ID');         $current_user = wp_get_current_user();         if ( is_user_logged_in() && $current_user->ID != $author_ID ) {             return 'Follow';         }     }          // The update function, I know I have to use array for the ids, it's for only test     $userID = (get_query_var('userID')) ? get_query_var('userID') : false;          if(is_numeric($userID)) {         $current_user = wp_get_current_user();         update_user_meta($current_user->ID, 'following', $userID);     }          // jQuery     $('.follow-user').click(function(e) {         e.preventDefault();         var userID = $(this).attr('href').slice(1);         $.ajax({                      type: "GET",                 url: "index.php",                 data: 'userID='+userID,                 success: function(msg){                     $('.follow-user').html('Followed');                 }                  });     });      After I click to the follow button I see on the net tab: index.php?userID=X, but nothing happens in the database. Where is the problem?


title: Using a rich text editor for category description?

text: is it possible in Wordpress to have the category description use a rich text editor rather than a standard text area? If so any idea how to make it use one? Thanks!


title: Custom random quote widget breaks when used in multiple sidebars

text: I've created a custom widget and placed it in functions.php. You can see the widget here: http://pastebin.com/3uWpeaFx (I've also created a similar widget that grabs a random image; it's included with the pastebin.) The widget allows users to plug in up to ten blocks of text/HTML, stores them in an array in JS, and displays one at random using JS. These are super simple widgets that are based on the default text widget that ships with WP. (I'm no PHP expert, so there's probably a more elegant way to create them, but they're simple to use, which is what the client needed.) The problem I'm having is this: Using more than one Random Text widget, even on multiple different sidebars displayed on different pages, causes all but the original to return 'undefined'. The text that you put in the box seems to store properly, and is editable through the WP admin interface; but when it comes to displaying it on the front-end, it doesn't echo the text properly. I'm sure it's something simple that I'm missing in the widget...any clues? Thanks!


title: Nginx WordPress Multisite Rewrite rules

text: I am having trouble with my rewrite rules with my new nginx install. If I access the image manually like here, incredible.devpreview.co/wp- content/blogs.dir/2/files/2011/05/stockvault-colorful-illustration108811.jpg It shows up But WordPress is looking for it here incredible.devpreview.co/files/2011/05/stockvault-colorful- illustration108811.jpg Here is what is in my nginx config file.               server {          listen   80;     server_name  www.devpreview.co;     rewrite ^/(.*) http://devpreview.co/$1 permanent;          }               server {          listen   80;     server_name devpreview.co *.devpreview.co;          access_log /var/www/devpreview.co/logs/access.log;     error_log /var/www/devpreview.co/logs/error.log;          location / {      root   /var/www/devpreview.co/public/;      index  index.html index.htm index.php;      if (!-e $request_filename) {             rewrite ^.+/?(/wp-.*) $1 last;             rewrite ^.+/?(/.*\.php)$ $1 last;             rewrite ^(.+)$ /index.php?q=$1 last;             }      }           location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$             {             root  /var/www/devpreview.co/public/;             rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;                  rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$/wp-includes/ms-files.php?file=$1 last;             expires 30d;             break;             }


title: wp_usermeta key problem

text:
I am trying to add a meta key to wp_usermeta but it does not work at all. The key would get value from a checkbox. I used the code from Wordpress codex tutorial and it's not adding anything. I will show you the code (it's from a woocommerce file, but I am adding this as a standard WordPress user meta data, so it really does not matter). I checked the database and there is no 'giodo' meta key in wp_usermeta. Could anyone show me what I am doing wrong?               <?php            //1. Add a new form element...         add_action('register_form','myplugin_register_form');         function myplugin_register_form (){             $giodo = ( isset( $_POST['giodo'] ) ) ? $_POST['giodo']: '';             ?>
                 <?php _e('First Name','mydomain') ?>
                     <input type="checkbox" name="giodo" id="giodo" class="input" value="<?php echo esc_attr(stripslashes($giodo)); ?>" size="25" />
             <?php         }              //2. Add validation. In this case, we make sure giodo is required.         add_filter('registration_errors', 'myplugin_registration_errors', 10, 3);         function myplugin_registration_errors ($errors, $sanitized_user_login, $user_email) {                  if ( empty( $_POST['giodo'] ) )                 $errors->add( 'giodo_error', __('ERROR: You must include a first name.','mydomain') );                  return $errors;         }              //3. Finally, save our extra registration user meta.         add_action('user_register', 'myplugin_user_register');         function myplugin_user_register ($user_id) {             if ( isset( $_POST['giodo'] ) )                 update_user_meta($user_id, 'giodo', $_POST['giodo']);         }     ?>


title: Two admins in Users and one in the database?

text: While moving a client's WP site to a new host (single site, not multi), I found that Dashboard>>Users lists two admin accounts (above the detailed shows All(2) Administrator (2) ) but only shows one in the detailed list below; and only one admin account shows in the wp_users table with the ID of 1. Where is this extra admin account? And how do I remove it? (No need to warn me about security: there are no signs of hacking to the account, and in moving to the new host, all passwords have been changed, security tweaked up, fresh 3.0.4 core files uploaded and the database dump shows only one admin.)


title: Set custom messages for post update/save

text: I am trying to make a custom message instead of the default message when i save a post, does anybody know how to do it!


title: Using wp_filesystem in Plugins

text: I wrote a plugin (https://github.com/bassjobsen/custom-bootstrap-editor) this plugin writes a stylesheet to `wp-content/uploads/cbe`. I will use something like the code below to do this:               $upload_dir = wp_upload_dir();     $this->folder = trailingslashit($upload_dir['basedir']).'cbe/';     if( !is_dir( $this->folder ) ) wp_mkdir_p( $this->folder );     if ( is_writable( $this->folder ) ){         file_put_contents( $this->folder.$this->filename, $css);     }      My first question about the above, what will be the best place to check if wp_upload_dir() is writable? Will there be a standard check (plus error) for this? After reading http://ottopress.com/2011/tutorial-using-the-wp_filesystem/ i got some other questions too. The post mentioned tell i should use the Filesystem API to replace the code above. Will this observation still be true? `request_filesystem_credentials` seems to work as expected but to login for every file change seems some kind of overkill. Could my plugin skip the login screen? Althought the credits seems valid my `$wp_filesystem->mkdir( $folder )` and `$wp_filesystem->put_contents( $folder.'/'.$filename, $css, FS_CHMOD_FILE)` seems always return false. How can i debug the Filesystem API calls? **update** thanks to @otto file writing works now:               if (isset($_POST['SaveCBESettings'])) {                  if ( !empty($_POST) && check_admin_referer( 'cbe-nonce') )              {                                $SaveCBESettings = 1;                 $in = true;                 $url = wp_nonce_url('options-general.php?page=filewriting','cbe-nonce');                 if (false === ($creds = request_filesystem_credentials($url, '', false, false, array('SaveCBESettings')) ) ) {                     $in = false;                 }                 if ($in && ! WP_Filesystem($creds) ) {                     // our credentials were no good, ask the user for them again                     request_filesystem_credentials($url, '', true, false,array('SaveCBESettings'));                     $in = false;                 }                 if($in)                 {                 // by this point, the $wp_filesystem global should be working, so let's use it to create a file                 global $wp_filesystem;                 $contentdir = trailingslashit( $wp_filesystem->wp_content_dir() );                  $wp_filesystem->mkdir( $contentdir. 'cbe' );                 if ( ! $wp_filesystem->put_contents(  $contentdir . 'cbe/test.txt', 'Test file contents', FS_CHMOD_FILE) )                  {                     echo "error saving file!";                 }                     unset($_POST);                 }             }     }


title: Conditionally load child themes

text: I am wondering how to conditionally load child themes? I have a site that is going to change with the seasons. The underlying architecture will remain the same, just different styles and a few minor changes. It seems that child themes is my best bet for this, vs using a bunch of conditional statements within my main theme and loading different stylesheets and what not. What I am stuck on is how to properly load a specific child theme based on a date?


title: How to pass a parameter to this add_filter example

text: I have a class with this function to provide a user language based on $user_id               function provide_user_language($user_id) {          return apply_filters('get_user_language',$user_id);          }      So in my script, I can simply get the user language by doing this:               $user_language=$this->provide_user_language($user_id);      But I need to associate this $user_language to a "set_current_language". I can do this by doing an add filter hook, but add_filter does not accept parameters. This is the add_filter line with the function itself but I don't know how to pass the $user_id or the $user_language so that set_current_language will be set to $user_language:               add_filter('set_current_language', array(&$this,'provide_user_language'));       I tried following this one but it won't work: Passing a parameter to filter and action functions I appreciate any tips. Probably there is an easy way.


title: Checking for existence of constants before defining them

text: I am seeing many plugins use the following format for defining their constant:               /* Set the constant path to the plugin's javascript directory. */     if( !defined( 'MY_ETS_JS' ) )         define( 'MY_ETS_JS', MY_ETS_URI . trailingslashit( 'js' ), true );          So basically there is a check before we define the constant. My question is why is this check necessary? What if I make a new version of the plugin and want to change the name of the javascript folder from 'js' to 'javascript'? I would have to include that change in an upgrade routine. Why not just define the constants without checking for their existence?


title: Display different header images based on current page

text: I want to display, based on the current page another header image. Short example:   * Home -> Image A    * PageId 1,2,3,4 -> Image B (2,3,4 are childs of page 1)    * PageId 5, 6 -> Image C   * ... I tried to edit the header.php of my theme, because there is the coding block which displays the header image:               <?php                         // The header image                         // Check if this is a post or page, if it has a thumbnail, and if it's a big one                         if ( is_singular() && has_post_thumbnail( $post->ID ) &&                                 ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) &&                                 $image[1] >= $header_image_width ) :                             // Houston, we have a new header image!                             echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );                         else :                             // Compatibility with versions of WordPress prior to 3.4.                             if ( function_exists( 'get_custom_header' ) ) {                                 $header_image_width  = get_custom_header()->width;                                 $header_image_height = get_custom_header()->height;                             } else {                                 $header_image_width  = HEADER_IMAGE_WIDTH;                                 $header_image_height = HEADER_IMAGE_HEIGHT;                             }                             // echo "here";                             ?>                              <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />                     <?php endif; // end check for featured image or standard header ?>      So I try to hook in with following elseif: _(I removed the`<?php ?>` for easier reading)_               if(is_home()){     <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />     }else if(is_page(1){     <img src="http://.../ImageB.png" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />     }else{     <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />     }      But that didn't work, instead no header image was shown. How can I achieve this? BR, mybecks


title: Post attachments doesn't show after manual db import

text: I have wp db exported from domain www.domain1.com. I did manual database import using phpmyadmin to domain www.domain2.com. In database for particular post on new domain I have attachment image link that points to www.domain1.com/wp-content/uploads/2014/01/1.jpg. In front end somehow that link is changed to www.domain2.com/wp-content/uploads/2014/01/1.jpg returning 404 for that image even if db has good link. What can I do to fix that issue? Just to be clear I need that link to point to old domain because I want to keep those images in one place


title: How to Javascript/jQuery

text: I am trying to turn an HTML 5 template into a Wordpress theme. The jQuery/Javascript combo seems not to be working, what should I do? (I just used `<?php echo get_template_directory_uri(); ?>` so the .js files are correctly linked)


title: How can I fix the even/odd child classes comments so that the comments are unaffected by the top-level even/odd?

text: Sorry if the title was confusing, I'm having a bit of trouble explaining here. I'm working on a theme for my site, and I'm using a slightly modified version of a custom comments template found here. The style I have in mind for comments is this:   1. Top Level comment 1 **1\. Child comment 1** _2\. child comment 2_ **3\. Child comment 3**   2. Top level comment 2   3. Top level comment 3 AKA I want the child comments to be even/odd, but I want the main thread comments all to be alike. My problem is that when a new comment is added at the top, the child comments get offset. So instead of being the above, it turns into:   1. Top Level comment 1 _1\. Child comment 1_ **2\. child comment 2** _3\. Child comment 3_   2. Top level comment 2   3. Top level comment 3 Which is undesirable. How can I make it so the child even/odd classes are unaffected by new main comments? Thanks.


title: Best way to extends core classes in theme?

text: I need to add functions to my WP_User objects, to be used like this :               <?php     // in my templates :     $user = new User($id);     $user->sendHelloWorldEmail();          // in my functions.php     class User extends WP_User {         public function sendHelloWorldEmail(){             // do stuff ...         }     }      My question is : what is the best way to overload Core Classes (WP_Post/WP_User...) ? And : is it a good idea, or is there a better way to achieve this (with objects programming) ?


title: An image on my site is showing as the wrong image

text: I have an image on my site, which is showing up as the wrong image. When I "inspect element" in chrome, and click on the link to the image, it shows up as the right image. How can this be? Here's the page: http://goinspire.com/israel-family-tours/ The image is the blue triangle that appears when you scroll down. The image: http://goinspire.com/wp-content/uploads/arrow2.gif Thanks!!