title: next_posts_link and previous_posts_link problem

text:
Below is the code from my author.php file. The problem is that `next_posts_link` and `previous_posts_link` only generate links based on the number of posts in the blog authored by the author in question, not the number of posts in the query ( which includes pages and events). I have used WP_Query to add the custom post type 'events' as recommended here. I find this behaviour strange because the page is displaying the results of the query but the `previous/next_posts_link's` are doing something completely different. Can anyone see my mistake or is this some problem with WordPress.               <?php get_header();      // add evemts post type to query               $query = new WP_Query( array(        'post_type' => array( 'post', 'page', 'events' )        ));            if($query->have_posts()) : ?>
Posted by : author

                                                   <?php while($query->have_posts()) : $query->the_post(); ?>                         <div class="archive-post" id="<?php the_ID(); ?>">

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

Entry meta here
                         <?php the_excerpt(); ?>
                                                                                <?php edit_post_link( 'Edit', '', '' ); ?>

                              <?php endwhile; endif; ?>

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

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

                 <?php get_sidebar(); ?>
     <?php get_footer(); ?>      **EDIT** : I have just found this page detailing the problem, however after implementing the solution, while it is definitely an improvement in that the links now show, still for some reason they point me to a 404 page


title: Upload multiple images in a custom metabox

text: I am new to theme development. I am trying to create a custom metabox that has the ability to upload a image. I am doing this on a page not a post. I want to output the images (multiple) onto the page in a unordered list. I have attempted to use WP alchemy, and I can only get as far as getting the metabox to show up but I have no idea on how to output the imgurl to the page. Is there a better way to upload multiple images to a page which is easy for a client and doesn't add images to the content editor (I just think it isn't user friendly) and then output them to a page in a unordered list. Some advice please.


title: How to retain responsive navigation menu in twentyeleven child theme

text:
I use TwentyTwelve as the parent theme for most of my site development. However, when i change any styling or positioning associated with the menu, the responsive nature of menu does not come into effect on small-screens. Instead, all the menu items are displayed in a vertical list. What i did: Created a new child theme Created header.php by copy pasting contents from original header.php file, Created a style.css and added style overrides here. Then i moved the site-navigation div into hgroup so that i could display menu at top, just after the logo. Tried to add some margins to .main-navigation and the menu does not fallback to responsive layout on small screen. This is how the menu looks on small screen: ![enter image description here](http://i.stack.imgur.com/OfjgC.png) Here is the header.php code:                           <?php                 /**                  * The Header for our theme.                  *                  * Displays all of the  section and everything up till
                  *                  * @package WordPress                  * @subpackage Twenty_Twelve                  * @since Twenty Twelve 1.0                  */                 ?><!DOCTYPE html>                                                                    <html <?php language_attributes(); ?>>                                                   <meta charset="<?php bloginfo( 'charset' ); ?>" />                 <meta name="viewport" content="width=device-width" />                 <title><?php wp_title( '|', true, 'right' ); ?></title>                 <link rel="profile" href="http://gmpg.org/xfn/11" />                 <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />                 <?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>                                  <?php wp_head(); ?>                                       <body <?php body_class(); ?>>
                                              <hgroup>
<?php _e( 'Menu', 'twentytwelve' ); ?>
                             <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?>                             <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>

<?php bloginfo( 'description' ); ?>

                         </hgroup>                              <?php $header_image = get_header_image();                         if ( ! empty( $header_image ) ) : ?>                             <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />                         <?php endif; ?>
      Style.css:                           /*                 Theme Name:     Bennys Salon                 Description:    Bennys Salon Child Theme                 Author:         MuMacro                 Template:       twentytwelve                      (optional values you can add: Theme URI, Author URI, Version)                 */                      @import url("../twentytwelve/style.css");                 @import url(http://fonts.googleapis.com/css?family=Acme);                 @import url(http://fonts.googleapis.com/css?family=PT+Sans:400,700italic);                           /* Fonts */                      .nav-menu{                     font-family: Acme, serif;                     color: #9C3F97;                     text-transform:uppercase;                 }                      .entry-header .entry-title {                     color: black;                     font-size: 1.57143rem;                     font-family: Acme, serif;                 }                      .entry-content p, .entry-summary p, .comment-content p, .mu_register p {                     color: black;                     line-height: 1.71429;                     margin: 0 0 1.71429rem;                 }                 /*Navigation*/                 .main-navigation li a {                     border-bottom: 0 none;                     color: #9C3F97;                     font-size: 13px;                     line-height: 3.69231;                     text-transform: uppercase;                     white-space: nowrap;                 }                      .main-navigation ul.nav-menu, .main-navigation div.nav-menu > ul {                     border-bottom: 0 solid #EDEDED;                     border-top: 0 solid #EDEDED;                     display: inline-block !important;                     margin-left: 28%;                     margin-top: 0;                     text-align: left;                     width: 100%;                 }                           /* Header */                 .site-header h2 {                     color: #9C3F97;                     font-size: 17px;                     font-weight: normal;                     line-height: 1.84615;                     font-style: italic;                     font-family: Acme;                 }                 .site-header h1 {                     font-size: 1.85714rem;                     line-height: 1.84615;                     margin-left: -27px;                 }                      .site-header {                     padding: 1% 0;                 }                           /*Navigation*/                 .main-navigation {                     margin-top: 0.714rem;                     text-align: center;                 }                      /* Content Background */                      .site{                     background: rgba(255,255,255, .5); /* Works on all modern browsers */                 }                      body .site {                     box-shadow: 37px 24px 51px rgba(205, 100, 100, 0.3);                     margin-bottom: 3.42857rem;                     margin-top: 3.42857rem;                     padding: 0 2.85714rem;                 }                      /*Footer Credits*/                      .site-info{                     float:right;                 }                      /* Font Colors */                 .site-header h2 {                     color: #9C3F97;                     font-size: 17px;                     font-style: italic;                     font-weight: normal;                     line-height: 1.84615;                 }                      /* Logo Image */                      .fplogoimg{                     height:130px;                 }                      /* Site Description*/                      .site-description {                     margin-left: 5%;                     position: relative;                 }                      /*Content Margins*/                      .site-content {                     margin: 0;                 }                      .widget-area {                     margin: 0;                 }                      body .site {                     box-shadow: 37px 24px 51px rgba(205, 100, 100, 0.3);                     margin-bottom: 1.429rem;                     margin-top: 1.429rem;                     padding: 0 2.85714rem;                 }      N.B. I am not good into HTML, CSS. I just find ways to hack a solution. Kindly help.


title: Using DePo Masthead with WP 3+

text: Does anyone have any experience with running DePo Masthead in WP3+? I'm thinking of changing the theme on my personal site and blog.


title: Get PHP Fatal error on globalized $wpdb: Call to a member function insert() on a non-object- I have no clue. What to do?

text: I am trying to utilize this function. I cannot figure out why I am still getting the PHP error. All I can figure out is that for some reason the template isn't able to access $wpdb. I don't know what line needs to be placed in the functions.php (in theme folder) file that contains this function. Please help me!!               function submitWeightUpdate( $userid, $weight ) {         global $wpdb;              $result = $wpdb->insert( 'wp_weights', array( 'user_id' => $userid, 'current_weight' => $weight ), array( '%d', '%d' ) );              if (empty($_POST['weight'])) {             $return['error'] = true;             $return['msg'] = 'You did not enter a weight.';         }         else {             $return['error'] = false;             $return['msg'] = 'You\'ve entered: ' . $weight . ' as your new weight.';         }              echo json_encode($return);     }       I also tried setting the theme to the default one and it still won't work, so I have no idea what could be wrong with it!


title: Pros and cons of using [taxonomy name] in place of [category name]?

text: We are currently in development on a new site. Categories (& tags) are pretty much meaningless for us because we've implemented custom posts & taxonomies. By default, because I have enabled pretty permalinks, if I create a post titled, "Mubarak steps down" without selecting a category, Wordpress will give me this: domain.com/uncategorized/mubarak-steps-down. Today, I installed the custom permalinks plugin which enables me to make the permalink virtually anything I want. I have a custom taxonomy called countries and one of the terms is Egypt so I re-wrote the above permalink to be domain.com/countries/egypt/mubarak-steps-down. domain.com/egypt/mubarak-steps- down would be better but there's nothing there & writing a re-direct for all countries would be a major pain. The pros, as I see them, in doing this: 1) A reader may realize that by removing the post title and re-submitting the url in the browser that they will see more content on the parent subject most relevant to the individual post, in this case, Egypt. Of course, this can also be done by making a link to the Egypt section on the page easy to see. 2) I think* it could be an effective white hat SEO strategy for communicating something more relevant in the url than 'uncategorized' or something else generic like 'events' or 'news.' What are the pros and cons of doing this with respect to WP database performance, etc.?


title: Ajax in wordpress

text: I tried to write ajax with jquery to fetch data from database butajax doesn't return any data. I put that code in header and it return the whole html content in response. What is the code need to write in admin-ajax.php to use ajax?


title: Content not retrieving on .load jQuery function

text:
I`m trying to get posts from a wordpress query_posts external php file via .load jquery function. I`m getting the correct html code, but the wordpress loop part of the code is not loading. My code is: HTML:

      JQUERY:                         EXTERNAL FILE:
Temakis
          <?php     $args = array(         'post_type'      => 'post',         'category_name' => 'temakis');     query_posts($args);     while (have_posts()) : the_post();     ?>
       <img src="<?php the_field("imagem-produto");?>" width="150" height="150" title="<?php echo get_the_title(); ?> "/>

<?php echo get_the_title(); ?>

<? echo get_post_field('post_content'); ?>

R$ <? the_field("preco"); ?>

          <?php endwhile; ?>     <?php wp_reset_query(); ?>      The request is ok, because i`m getting the h3 correctly. Can anyone help me? Thanks!


title: What is the right way to include my Ajax script in wordpress

text: I've searched around for a solution to my issue to no avail. So here it is: I have created custom meta fields in the user section within the admin area. There are two fields in total, both select boxes. The first select box loads countries from a csv file, the second loads companies from the country selected in the first select box. I wrote and tested a script on my server which worked fine but when I transferred to my wordpress website things didn't go as planned. Which is probably due to my lack of knowledge using ajax in wordpress! (and ajax in general) Here is my process. I copied my javascript and ajax code directly into my functions.php within the function that creates the meta fields for users:               <?php                  <script language="javascript" type="text/javascript">                 <!--                  //Browser Support Code                 function ajaxFunction(){                   var ajaxRequest;                                       try{                     // Opera 8.0+, Firefox, Safari                     ajaxRequest = new XMLHttpRequest();                   } catch (e){                     // Internet Explorer Browsers                     try{                       ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");                     } catch (e) {                       try{                         ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");                       } catch (e){                              alert("failed");                         return false;                       }                     }                   }                   // Create a function that will receive data sent from the server                   ajaxRequest.onreadystatechange = function(){                     if(ajaxRequest.readyState == 4){                            //alert(ajaxRequest.responseText);                       //alert(getValue);                       document.getElementById("operator").innerHTML = ajaxRequest.responseText;                          }                   }                        var list = document.getElementById("countries");                   var getValue = getOperatorList(list);                        ajaxRequest.open("GET", "<?php echo get_template_directory_uri(); ?>/ajaxCompanies.php?o=" + getValue, true);                   ajaxRequest.send(null);                  }                      function getOperatorList(sel)                 {                     getValue = sel.options[sel.selectedIndex].text;                     return getValue;                 }                 //-->                 </script>     ?>      Then I added an onChange event to my select tag which is also in my functions.php file I'm showing just the tag but this sits within the meta fields function as well:               <select id="countries" name="opp_country" value="<?php echo esc_attr(get_the_author_meta( 'opp_country', $user->ID )); ?>" class="regular-text" onChange="ajaxFunction();" >      The above javascript/ajax snippet refers to this file when an option is selected: ajaxCompanies.php Here are that file's contents:                   <?php           //This hooks in my classes which consists of the database connection class and the                //csv parser class          require_once(TEMPLATEPATH."/includes/initialise.php"); ?>         <?php              //Creates an instance of the csv object              $csv = new parseCSV();              //Gets the name of the file from the database              $csv_query = "SELECT * FROM csv_files LIMIT 1";         $csv_file = Csv::find_by_sql($csv_query);                  $csv_file_filename = $csv_file[0]->filename;                  //Loads the file name             $csv->auto('csv/'.$csv_file_filename);                  $value_array = $csv->data;                         $number = count($value_array);         //Puts the operators(companies) from selected country into an array         if(isset($_GET["o"])) {                      for ($c=0; $c < $number; $c++) {                   if($_GET["o"] == $value_array[$c]['Country'])                   $operators[] = $value_array[$c]['Operator'];                 }                    }              ?>              //Outputs the operators(companies) in option tags              <?php                   for ($i = 0; $i < count($operators); $i ++) {               if (isset($operators[$i])) {                         echo("<option value='" . $operators[$i] . "'");                         if ($operators[$i] === $selected_operator) {                             echo(" selected='selected'");                         }                         echo(">" . $operators[$i] . "</option>");                     }               }                 ?>      So the issues are, `TEMPLATEPATH` isn't doing anything which means I don't have access to the classes necessary for me to get this working. I tried switching to absolute paths but when I do that nothing happens. The csv file doesn't get read and I can't access my databases. I get database connection errors. I know there is a better way to this but anything I find on the net refers to using ajax with plugins and with jQuery. If anyone can clue me in on the best way to achieve what I'm trying to do or point me in the right direction that would be great!


title: How to create query to get top 3 sticky/latest posts

text: I hope I will make sense, and if you have a better suggestion please let me know. I am just starting WordPress I want to layout my theme such that I get 3 sticky, not more than 1 month old, or latest posts at the top. Then render the rest of the posts latest 1st below. A picture (below) will explain better I hope. I think I will need custom queries, how might I achieve that ![](http://imgur.com/dK2vt.jpg)


title: How can I fetch loop of post titles via AJAX?

text:
I have a list of the most recent post titles in `sidebar.php`. Here is an example of how that code looks:               <?php $args = array('posts_per_page' => 20); ?>     <?php $sidebar = new WP_Query($args); ?>     <?php if ( $sidebar->have_posts() ) : ?>     <?php while ( $sidebar->have_posts() ) : $sidebar->the_post(); ?>
     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">       <?php the_title(); ?> - <?php the_time("F j, Y h:i A"); ?>
          <?php endwhile; ?>     <?php endif; ?>      That part works perfectly. It displays the 20 latest post titles and post times wrapped in permalinks. However, I am trying to do a bit more. I want to create a load more button at the bottom to fetch the next 20 post titles. I know my jQuery and that is not the issue. I need help with figuring out how to create a custom loop in a new custom `.php` template file that only generates the html above. That file needs to be able to accept a parameter for a page number, so that my `javascript` can fetch an incremented URL each time. I would appreciate any help, thanks!


title: Redirecting search to specific templates with $_GET["post_type"]

text: I'm using `$_GET["post_type"]` to direct my search to the correct templates and have used the following:               <?php $search_refer = $_GET["post_type"];     if ($search_refer == 'news') { load_template(TEMPLATEPATH . '/search-news.php'); }     elseif ($search_refer == 'members') { load_template(TEMPLATEPATH . '/search-members.php'); }; ?>      I need to add another `elseif` to this where the search refer is news but the posts have the status "future". Is it possible to do that? The current news search refer needs to only show posts with the status "published".


title: Performance and styles not working fine after changing permalink structure

text: Fist I was using default option of permalink and everything was fine (speed is ok, my own created theme is working fine) but now I change default structure to post name structure of permalink now I am not getting 404 error but the problems are : 1 - Whole website is loading very slow (pages,post) . 2 - My custom theme is not working fine means styles are not working on single page or single post. I checked my .htaccess file where the code is :               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /wordpress_1/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /wordpress_1/index.php [L]     </IfModule>          # END WordPress      **Note** : wordpress_1 is directory name.


title: list taxonomy based on taxonomy

text: Please, someone can help?! I'm fighting with this for weeks and nothing.... I'm quite new in wordpress and php... There is a way to list taxonomy terms based on another taxonomy? OR If is possible to list taxonomies based on post category. BUT, I'm doing this on homepage, not post page... The function above retrieve my **all** my taxonomy terms, but how or where filter this?               function dox_get_list_terms( $taxonomy = 'category', $term_id, $number, $orderby = 'ID', $order = 'ASC', $hide = '0' ) {                          global $dox_options;                  $terms = array();             $terms = explode(',', $term_id);             $count = count( $terms );                  $output = '';             foreach( $terms as $term ) {                 if ($term >= 0) {                     $options = get_terms( $taxonomy, 'number='.$number.'child_of='.$term.'&parent='.$term.'&hide_empty='.$hide.'&hierarchical=1&depth=1&orderby='.$orderby.'&order='.$order );                     if (! is_wp_error($options) ) {                         foreach ($options as $option) {                             $output .= '<li>'. $option->name .'</li>';                             }                         }                     }                 }             }                  return $output;     }


title: Outside the loop Category name with link

text: I want to display the category Name by using category ID with link to category page (out side the loop). here is my code...               <a href="<?php get_category_link('23'); ?>"><?php echo get_the_category_by_id(23); ?>      it's ok, but only think is it's go to home page... instead of category page... something missing... which i'hv not understand...


title: Optimize shortcode callbacks

text:
I created a plugin to add some shortcodes in my WordPress site. But I'm a PHP newbie, so I believe it may have some errors or ways to optimize it. It's working fine, and apparently there are no problems. Memory usage is at 00.04MByte. Could you please take a look? Thank you very much!               add_action( 'wp_enqueue_scripts', 'prefix_add_my_stylesheet' );              function prefix_add_my_stylesheet() {             // Respects SSL, Style.css is relative to the current file             wp_register_style( 'prefix-style', plugins_url('style.css', __FILE__) );             wp_enqueue_style( 'prefix-style' );         }          /* Adsesnse Shortcode */     function get_adsense($atts) {         return 'THE_ADSENSE_SCRIPT_GOES_HERE     ';     }     add_shortcode('adsense', 'get_adsense');          /*Padding Shortcodes*/      function get_pad5($atts) {         return '

';     }     add_shortcode('pad5', 'get_pad5');          function get_pad10($atts) {         return '

';     }     add_shortcode('pad10', 'get_pad10');          function get_pad20($atts) {         return '

';     }     add_shortcode('pad20', 'get_pad20');          function get_pad25($atts) {         return '

';     }     add_shortcode('pad25', 'get_pad25');          function get_pad50($atts) {         return '

';     }     add_shortcode('pad50', 'get_pad50');          function get_pad75($atts) {         return '

';     }     add_shortcode('pad75', 'get_pad75');          function get_pad100($atts) {         return '

';     }     add_shortcode('pad100', 'get_pad100');          function get_clr($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'clr', 'get_clr' );          /* Alert Boxes */     function get_alertblue($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'alertblue', 'get_alertblue' );          function get_alertgreen($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'alertgreen', 'get_alertgreen' );          function get_alertyellow($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'alertyellow', 'get_alertyellow' );          function get_alertred($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'alertred', 'get_alertred' );          function get_alertgray($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'alertgray', 'get_alertgray' );          /* Style Boxes */          function get_stylegreen($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'stylegreen', 'get_stylegreen' );          function get_styleblue($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'styleblue', 'get_styleblue' );          function get_styleyellow($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'styleyellow', 'get_styleyellow' );          function get_stylered($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'stylered', 'get_stylered' );          function get_stylegray($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'stylegray', 'get_stylegray' );          function get_stylewhite($atts, $content=null) {          return '
' . $content . '
';     }     add_shortcode( 'stylewhite', 'get_stylewhite' );


title: Showing user ID on user main page from screen options

text: On the user main page in the screen options, you have some choices for displaying user information e.g.. e-mail, role, posts etc.. Is there a way to be able to display the user's unique ID?


title: Get List of all the Authors

text: How could i get List of all the Authors? author.php file shows the Information about Individual Author. for example: http://domain.com/author/bj that returns the Bj's Profile. if i enter http://domain.com/author it returns **404 Not Found** Author page shows author's avatar, Author's Name and description. how can i list out all the authors? Need Help!


title: Extending Widgets - Exclude # of posts field from Recent Posts Widget

text:
I am currently using this code to extend WP_Widget_Recent_Posts, but I would like to exclude the field that gives the user the ability to show how many posts they want. I have a set number in my custom query to 4, so this box is useless and I don't want to confuse the user.               class JA_Recent_Work_Widget extends WP_Widget_Recent_Posts {          function __construct() {         $widget_ops = array('classname' => 'recent_work', 'description' => 'This widget will display 4 of your most recent works in the ART category Jay.');         $this->WP_Widget('ja_recent_work', 'Jay Alders Recent Work', $widget_ops);     }          function widget($args, $instance) {              extract( $args );              if( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )                     $number = 10;              $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);             $r = new WP_Query('category_name=art&posts_per_page=4');             if ($r->have_posts()) :         ?>             <?php echo $before_widget; ?>             <?php if ($title) echo $before_title . $title . $after_title; ?>
             <?php while ($r->have_posts()) : $r->the_post(); ?>
<a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title()); ?>"><?php echo the_title(); ?>             <a href="<?php the_permalink() ?>"><?php echo the_post_thumbnail(); ?>
             <?php endwhile; ?>
             <?php echo $after_widget ?>              <?php                     wp_reset_postdata();             endif;     }     }      function my_recent_widget_registration() {        unregister_widget('WP_Widget_Recent_Posts');        register_widget('JA_Recent_Work_Widget');     }        add_action('widgets_init', 'my_recent_widget_registration');


title: add_action in class and use it in theme

text: I'm programming a plugin in Wordpress and want to access some database functions with in my theme with the do_action feature. First I just included $fdb-> get_finaboo_footer(1); on my page for example but he couldnt find the object. I added global $fdb; Then it worked. But I dont want to globalize on every php file the $fdb. So I thought I do it with the do_action feature. The Problem is I just get "null" in my var dump.               <?php     /**     * Database Functions     */          class fdb {         public function __construct() {             global $wpdb;             $this->wpdb = &$wpdb;             add_action('finaboo_footer', array ( &$this, 'get_finaboo_footer'));         }                   public function get_finaboo_footer($footer_id) {             $sql =  $this->wpdb->prepare( "SELECT * FROM wp_finaboo_content_footer WHERE footer_id = '$footer_id' ORDER BY option_id ASC;" );             $results = $this->wpdb->get_results($sql, ARRAY_A );             return($results);         }     }          $fdb = new fdb();          ?>      And this would be my call in the theme php files:               <?php $footer1 = do_action('finaboo_footer', '1'); ?>      don't know why it dosent work :( Also I'm open for suggestions if this is not the smartest way in Wordpress :) Thanks for help


title: Conditional tag affecting taxonomy term and its children?

text: I am wondering how can I write a conditional tag that affects a custom taxonomy slug and its children? Found this in Wordpress Codex:               is_tax( 'flavor', 'mild')       > When the archive page for the flavor taxonomy with the slug of 'mild' is > being displayed. However with this code only 'mild' slug archive page is affected and not it's children taxonomy terms. Thanks!


title: Setting up a wordpress network with third level domains

text: I've been looking into setting up a WordPress network install. Everything has been going pretty smoothly until I get to the point where my desired domain layout doesn't fit well. I would like to have a layout as follows: blog.*.stackexchange.com so for example, I would like to have multiple sites in a network that look like: blog.wordpress.stackexchange.com   blog.apple.stackexchange.com   blog.$site.stackexchange.com I _think_ I could get this working with some creative re-write rules, and manual DNS intervention but I'd rather have a setup where I can hand off the creation of everything but the DNS to someone else (we already have a process for automatically creating all sub-domains needed in DNS) From my playing around and reading WP _really_ wants the sites to be the next level domain, so in my above example, it wants the main WP blog to be at stackexchange.com and the network blogs to be at wordpress.stackexchange.com. Is there any way to achieve my desired effect or should I just go the route of doing blog.stackexchange.com/$site ?


title: How to fix 404 page error on theme

text: I am using the MidMo Clean theme and for some reason the 404 error page isn't working. Parse error: syntax error, unexpected T_STRING in /home/wpversec/public_html/UXJobsLA.com/wp-content/themes/clean-home/404.php on line 14 http://uxjobsla.com/error Short of me disabling all my plugins and re-installing a out of the box version of the theme, anyone have any ideas please? Thanks!


title: Adding some HTMl code as posts doesn't work but it does if it is added directly in the file?

text:
I had some code in a template file. When I pasted it from the backend's post panel (HTML tab) as a post, and retrieved it as custom loop, the code didn't output well. Any suggestions? Adding them as posts:               <?php     /**      * Template Name: Lyrics Page      * @package WordPress      * @subpackage Prominent      * @since Prominent 1.0      */     get_header(); ?>

             <?php // Run main loop (The Loop). ?>             <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

             <?php endwhile; ?>

                 <?php $custom_posts = new WP_Query(); ?>                 <?php $custom_posts->query('category_name=Lyrics'); ?>                 <?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>                     <?php the_content(); ?>                 <?php endwhile; ?>

             <?php get_sidebar(); ?>

     <?php get_footer(); ?>      Directly on the file:               <?php     /**      * Template Name: Lyrics Page      * @package WordPress      * @subpackage Prominent      * @since Prominent 1.0      */     get_header(); ?>

             <?php // Run main loop (The Loop). ?>             <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
                 <?php the_content(); ?>
             <?php endwhile; ?>

                             There is one obvious advantage:

                                     You've seen it coming!
                                     Buy now and get nothing for free!
                                          Well, at least no free beer. Perhaps a bear,
                                     if you can afford it.

                             Now that you've got...

                                     your bear, you have to admit it!
                                          No, we aren't selling bears.

                             Rent one bear, ...

                                     get two for three beer.

                                          And now, for something completely different.
                                     And now, for something completely different.
                                     And now, for something completely different.
                                     And now, for something completely different.
                                     And now, for something completely different.
                                     And now, for something completely different.
                                          And now, for something completely different.
                                     And now, for something completely different.
                                     Period.

             <?php get_sidebar(); ?>

     <?php get_footer(); ?>      Output of the post when I add via admin panel:               <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">                      <meta name="generator" content=       "HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org" />            <title></title>

                 There is one obvious advantage:

You’ve seen it coming!

                   Buy now and get nothing for free!

Well, at least no free beer. Perhaps a bear,

                   if you can afford it.

Now that you’ve got…

your bear, you have to admit it!

No, we aren’t selling bears.

Rent one bear, …

get two for three beer.

And now, for something completely different.

                   And now, for something completely different.

                   And now, for something completely different.

                   And now, for something completely different.

                   And now, for something completely different.

                   And now, for something completely different.

And now, for something completely different.

                   And now, for something completely different.

                   Period.


title: Limit Amount of Pages users can create in Custom Post Types

text: Is there a way to limit how many pages a user can make inside a custom post type? This would be pretty effective for commercial WP plugins and I am making one, but have come across a little problem and I would need to figure out how to do this. Thanks.


title: Is codex right on deleting post?

text: The codex has this to say on wp_delete_post. > When the post and page goes, everything that is tied to it is deleted also. > This includes comments, post meta fields, and terms associated with the > post. Which kind of suggests that if a post that had the tags a,b,c attached to it gets deleted, then, all the a,b and the c tags are also deleted from the wp_terms, and wp_term_taxonomies tables **even if those tags were to be associated with some other living posts!*** - which I doubt is the case. Why would WP API delete the terms that are working for some other posts?


title: Test site pages go to main site

text: I have a test site installed on www.mydomain.com/testsite. The problem I have is that if I type in the url www.mydomain.com/testsite/about I get redirected to www.mydomain.com/about. My page for my test site gives me the permalink: www.mydomain.com/testsite/about If I click View Page from the page editing screen in the dashboard, I get redirected to www.mydomain.com/about instead of being sent to the permalink. My htaccess file is located in my root folder and is as follows:               # 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          ErrorDocument 404 /404.php          <Files delete.php>     order allow,deny     deny from all     </Files>      Can anyone help?


title: get_categories listing foreach with children

text:
My code for loop of categories               <?php     $categories = get_categories('hide_empty=1&exclude=1&orderby=slug&order=ASC');     foreach ($categories as $category) {         echo '
cat_ID.'">';         echo 'slug.'">';         echo $category->cat_name;         echo "";         echo ' ('.$category->category_count.')';         echo '
';     }     ?>      Preview the code above:

Category one

Category two

CHILDREN OF Category third

Category third

      I would like to stay:

Category one...

Children primary of Category one

Children second of Category one

Children third of Category one

Category two...

Category third...

Children primary of Category third

Children second of Category third

Children third of Category third

      understand?


title: Multiple versions of RSS feed? One with full content, one with the excerpt

text: I'm not sure how to word my question and I have been searching all day, to no avail. I am looking for a method to create two versions of my RSS feeds, one with the full content and one with only the excerpt. Mainly, I want to do this for the "Author" feeds. I would like two feeds created for each Author. One with the full content and one with the excerpt. If nothing else, I would like the author RSS feed to only have excerpts, but the main website RSS feed must ALWAYS be a full content feed. The reason? The website in question is a sports website. I want to offer the RSS in full content for those who want it, but I also automatically post my own articles on my personal website (a few others do as well). When the article is posted to my own website, I want to only include the excerpt, with a link to the full original article. I do not care the method used, whether code or plugin. **UPDATE** I have been working to try to get the methods described by Michael Ecklund and Ian Dunn to work. I have not been able to get either to work. Both methods still show the complete article in the RSS feed and not the excerpt. I'm not sure if it makes a difference, but I just remembered I use the Advanced Excerpt plugin to manage the excerpts on my website. I have not tried disabling this plugin, as it controls the homepage, category pages, tags pages, author pages and more.


title: On this day PHP code

text: I'm working with this code snippet for an "on this day" type post. However it is only showing 1 year in the past. I'm looking to automate this so it shows on this day in 2009, 2010, 2011... and as the years advance, keep these years showing. With the way it's written as a -1, -2, it will be a dynamic "year ago" rather than a static "in 2009". Is there a way to automate this to go back 2, 3 4 years without having to duplicate the code for (-2, -3, -4, etc)?               function on_this_day() {     $on_this_day = get_posts('year='.(date('Y')-1).'&monthnum='.date('n').'&day='.date('j'));     if( $on_this_day ) {         echo '';         echo 'On this day in '.(date('Y')-1);         echo '';     } else {         echo ''.'On this day in '.(date('Y')-1).'';     }


title: Fatal error: Call to undefined function term_exists()

text: In Which version of WordPress did term_exists() first appear?


title: Getting taxonomy terms used by custom post type

text:
I have a custom post type - **case** - for which I am building an archive page. There are three custom taxonomies for this type - **micro_organisms** , **infection_types** , and **antibiotic_types**. These taxonomies are hierarchical, and have a variety of terms, up to three levels deep. For the given post type, I'm wanting to list terms for, say, the **antibiotic_types** taxonomy, that are used by any **case** entries. While a term within the **antibiotic_types** taxonomy may be used by any of the **case** entries, I want to show the hierarchy leading to the selected term. So far, I've got the following working, which results in a flat list of just the selected terms, not reflecting the hierarchy the terms are in.               // sourced from:     // http://wordpress.stackexchange.com/questions/66015/how-to-get-a-list-of-taxonomy-terms-which-are-being-used-only-within-certain-pos     function get_terms_by_post_type( $taxonomies, $post_types ) {         global $wpdb;         $query = $wpdb->get_results( "SELECT t.*, COUNT(*) AS count from $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN $wpdb->term_relationships AS r ON r.term_taxonomy_id = tt.term_taxonomy_id INNER JOIN $wpdb->posts AS p ON p.ID = r.object_id WHERE p.post_type IN('" . join( "', '", $post_types ) . "') AND tt.taxonomy IN('" . join( "', '", $taxonomies ) . "') GROUP BY t.term_id");         return $query;     }     ?>     ...
     <?php     $terms = get_terms_by_post_type(array($tax), array('case'));          foreach ($terms as $term):         $termData = get_term_by('id', $term->term_id, $tax);         $termName = $termData->name;         $termUrl = get_term_link($termData);     ?>
<a href="<?php echo $termUrl; ?>?post_type=<?php echo $type; ?>"><?php echo $termName; ?> (<?php echo $term->count; ?>)
     <?php     endforeach;     ?>
      The output resembles:   * penicillin-g   * ceftriaxone   * amphotericin-b   * 5-flucytosine While the desired output is:   * beta-lactams      * cephalosporins        * ceftriaxone     * penicillins        * penicillin-g   * antifungals      * amphotericin-b     * 5-flucytosine I've also tried using the following:               wp_list_categories(         array(             'taxonomy' => 'antibiotic_types',             'hierarchical' => 1,             'hide_empty' => 1,             'title_li' => ''         )     );      Which shows _all_ of the terms for the given taxonomy, even those not used by any **case** entries. Having browsed the function reference, it doesn't look as if there is any built-in function for doing what I want to achieve, not directly anyway. I haven't done much with taxonomy queries until now. Any suggestions?


title: WP_Remote_Get feed from .php file

text: I have a bunch of wordpress sites which sit on different domains, and I want to track all the user data on one central site. I wrote a simple file for each wordpress site to display user counts in an xml file called `userxml.php` and uploaded it to my different site directories:               <?php     /* Open API */     $secretcode = 'mysecretcode1234';     if ($_POST['secretcode'] == $secretcode || $_GET['secretcode'] == $secretcode) {     define('WP_USE_THEMES', false);     require('wp-blog-header.php');     /* Variables */     $pending = count(get_users( array( 'role' => 'pending' ) ));     $subscriber = count(get_users( array( 'role' => 'subscriber' ) ));     $editor = count(get_users( array( 'role' => 'editor' ) ));     $author = count(get_users( array( 'role' => 'author' ) ));     $administrator = count(get_users( array( 'role' => 'administrator' ) ));     /* Start XML */         header("Content-type: text/xml");         $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";         $xml_output .= "<mysiteapi>\n";         $xml_output .= "<pending>".$pending."</pending>\n";         $xml_output .= "<subscriber>".$subscriber."</subscriber>\n";         $xml_output .= "<editor>".$editor."</editor>\n";         $xml_output .= "<author>".$author."</author>\n";         $xml_output .= "<administrator>".$administrator."</administrator>\n";         $xml_output .= "</mysiteapi>";         echo $xml_output;     /* Close API */     } else {         echo 'you are not supposed to be here, sad face :-(';     }     ?>      which outputs xml which is great and exactly what I need, but i can't seem to pull the data from the xml file because my xml data is in a php file. So far I've tried using both `fetch_feed()` and `wp_remote_get` like               <?php     define('WP_USE_THEMES', false);     require('wp-blog-header.php');          if (!file_exists('wp-blog-header.php')){      echo 'no file';     }          $url = 'http://www.mysite.com/mysiteapi.php?secretcode=mysecretcode1234';          $response = wp_remote_get($url);     $xml  = simplexml_load_string($response);     echo $xml->mysiteapi->pending;          echo $xml;      I used `fetch_feed()` and tried to echo out the items with a foreach loop with no success. Anyone have an idea on how I could retrieve simple statistics from one wordpress site into another? Or do I need to use php to create an actual `.xml` or `.html` file to read? Thanks


title: Is there any necessary to use tag plugins like simple tagging in wordpress 3.0+

text: As there is tagging feature built-in wordpress already, but why so many people recommend "simple tagging" plugin. Now i just need a feature of tags link. Is there the built-in a easy way to implement it by built-in tag system? I often feel confused there are two places to input tags before my eye when editing post. And i'm afraid my tags will lost if one day i do not use this plugin anymore for some reasons


title: How to expand picture to cover entire header area? (twenty-twelve theme)

text: I am running twenty-twelve theme and have applied a header background on the .site-title class. Header shows up but it's width is only 960px. How do I disable the left and right margins/padding of this theme so I can expand the picture to cover entire header area? ( I don't know what css code to add) Here's a picture if it makes more sense: http://imgur.com/yBdPmRT Thank you in advance!


title: How to get latest post excerpt from a specific category?

text:
I'm working on a theme homepage and would like to include an excerpt from the latest post in a specific category. In this case, the category slug is "gear". I've tried a couple options with `WP_Query` but am unable to get it to return only one post. Here's my current code:               <?php $latest1 = new WP_Query();     $args=array('category_name=gear','posts_per_page=1');     $latest1->query($args);     while ($latest1->have_posts()) : $latest1->the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?>

     <?php the_excerpt(); ?>
     <?php endwhile; wp_reset_query(); ?>      There are currently two posts in the "gear" category, and both are being returned. I must be misunderstanding the posts_per_page option. If there's a better way to do this than WP_Query (making this call three times on the page, once for each category), I'm open to that as well.


title: Additional form options based on category selected not working

text:
I have a conditional statement to show certain images to choose from (radio buttons) based on the category chosen, however when the category is chosen, the radio buttons don't show? What am I doing wrong?                   <fieldset class="category">                                  Post Category:                                  <?php wp_dropdown_categories( 'tab_index=3&taxonomy=category&hide_empty=0' ); ?>                      </fieldset>     <?php $categoryId = $_POST['cat']; ?>         <?php if ($categoryId == '3') { ?>                         <fieldset class="cat1">                              Please choose from 1 of the images below for your Post:
         <input type="radio" name="hate" value="<?php bloginfo('url'); ?>/wp-content/uploads/2012/08/hate1.jpg" id="hate1" /> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2012/08/hate1.jpg" alt="" height="167" />
         <input type="radio" name="hate" value="<?php bloginfo('url'); ?>/wp-content/uploads/2012/08/hate2.jpg" id="hate2" />          <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2012/08/hate2.jpg" alt="" height="167" />                         </fieldset>              <?php } elseif ($categoryId == '4') { ?>                         <fieldset class="cat2">                              Please choose from 1 of the images below for your Post:
         <input type="radio" name="love" value="<?php bloginfo('url'); ?>/wp-content/uploads/2012/08/love1.jpg" id="love1" /> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2012/08/love1.jpg" alt="" height="167" />
         <input type="radio" name="love" value="<?php bloginfo('url'); ?>/wp-content/uploads/2012/08/love2.jpg" id="love2" /> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2012/08/love2.jpg" alt="" height="167" />                          </fieldset>               <?php } else echo 'Damnit!'; ?>


title: Modify text after post count

text: On my Archives page, I list categories with post counts. I've modified the post count by removing the parentheses, wrapping them in a span that floats them to the right, and putting the word "Entries" after each post count. But I'd like the text after the count to change for categories with only a single post (i.e. "Entry" instead of "Entries"). My current code for this is:               <?php     $variable = wp_list_categories('title_li=&echo=0&show_count=1');     $variable = str_replace( '(', '', $variable);     $variable = str_replace( ')', ' Entries', $variable);     echo $variable;     ?>      How can I modify this so that categories with 1 post say "1 Entry" and those with more than 1 say "X Entries"? You can see my Archives page here


title: Display featured image file size, extension, filename, type, orientation?

text: How to display some information of featured image in post. I need to display: **1.** a. **Image file size (in kb or MB)** b. **Image type (.jpg,.gif...)** , c. **Bare image name, with and/or without image extension (some-image-file- name.jpg)**. Also, if it possible it would be nice to show this too: d. orientation of image (landscape, portrait) Maybe it will be helpful if I say that I do not have any image in post content, only as featured image. It would be great to have separate functions to display that info of "medium" and image in "full" size, or at least of "full" size. _Could you please give me some functions which I can put in my theme files to display that info of featured image?_ **2.** I managed to show image title, caption and description of featured post image with: `echo get_post(get_post_thumbnail_id())->post_title; echo get_post(get_post_thumbnail_id())->post_excerpt; echo get_post(get_post_thumbnail_id())->post_content;` _But, how to show image alt ("Alt Text") of featured image?_


title: How to show comments for a specific category of posts with a shortcode

text: Referring to this post category specific comments here Display category- specific comments in sidebar I need to ask 2 further related questions. 1/ Is this code still valid for WP3.9? 2/ How can I use this method so that I can create a page using a shortcode rendering a list of comments belonging to posts in any specific category 3/ with excerpt linking to the comment single post 4/ with comment excerpt of 'x' character/ words 5/ with shortcode that allows cat ID/slug to be called per iteration of the shortcode used on other pages Thank-you.


title: Using get_query_var() from a plugin

text: I'm trying to do a redirect feature in a plugin and i have an issue. First, the code:               add_action( 'init', function(){         add_rewrite_rule( 'go/([^/]+)/?$', 'index.php?redirect_to=$matches[1]', 'top' );         add_rewrite_tag( "%redirect_to%", '([^&]+)' );`     } );      Ok, so, the rule is set. The tag is set. If i'm using `get_query_var('redirect_to')` inside of `functions.php` (or anywhere in the theme actually) it works, but if i'm trying to use the same query var from the plugin files, it silently fails. And since it's a plugin, there is no way to ask users to edit their themes :) Things i did:   * i'm using it inside of `init` hook set as priority 999   * it works if i use `wp_head` instead of `init`, but this way i can't do the redirect anymore   * i flushed rewrite rules So, my question is: how do i use the damn `get_query_var('redirect_to')` inside of my plugin files? Thanks!


title: Changing the search URL?

text: I want to change the search URL from `example.com/search/keyword` to `example.com/result` or `topic/keyword`.


title: How to show certain data on certain interval of period

text: I have three sets of period of time, each with several interval of date: Event A   Jan 1 - March 1   Dec 1 - Dec 31 Event B   Mar 2 - April 15   Jun 1 - Jul 15   Sept 1 - Oct 15   Event C   Apr 16 - May 31   Jul 16 - Aug 31   Oct 16 - Nov 30   I really would like to know how to show a custom field if today's date is fall between a certain period. Say today is April 22, then custom field to show is "Event C". Really appreciate if someone can help me resolve this issue.


title: Custom Taxonomy - Archive for the whole Custom Taxonomy (and not just single term)?

text: My question/problem is probably unclear/confusing, so here's an example what I would like to do. I have a custom post type for recipes and a custom taxonomy for ingredients. The following url works just fine: mywebsite.com/recipes/ingredients/fish/ Now what I would like to have is something like mywebsite.com/recipes/ingredients/ to show a list of the different taxonomies (ingredients). But I just get a 404. Somebody had a similar problem here: Creating a page for custom taxonomy archive and solved it by creating a page. I've created a "recipes" and "ingredients" page, but still get a 404 error when opening the "/recipes/ingredients" page (guess some sort of conflict due to the same slugs). I've also tried the different options of the template hierarchy (http://codex.wordpress.org/images/1/18/Template_Hierarchy.png), but hadn't any luck so far. I'm not sure if it can work at all, because there's no standard "/category/" page in wordpress either. But maybe there's a way? The code looks as follows:               // Register Custom Taxonomy     function ingredients() {          $labels = array(         'name'                       => _x( 'ingredients', 'Taxonomy General Name', 'text_domain' ),         'singular_name'              => _x( 'ingredient', 'Taxonomy Singular Name', 'text_domain' ),         'menu_name'                  => __( 'ingredients', 'text_domain' ),         'all_items'                  => __( 'All ingredients', 'text_domain' ),         'parent_item'                => __( 'zz ingredient', 'text_domain' ),         'parent_item_colon'          => __( 'zz ingredient:', 'text_domain' ),         'new_item_name'              => __( 'new ingredient', 'text_domain' ),         'add_new_item'               => __( 'ingredient hh', 'text_domain' ),         'edit_item'                  => __( 'ingredient bb', 'text_domain' ),         'update_item'                => __( 'ingredients bb', 'text_domain' ),         'separate_items_with_commas' => __( 'ingredients sep', 'text_domain' ),         'search_items'               => __( 'ingredients search', 'text_domain' ),         'add_or_remove_items'        => __( 'ingredient add delete', 'text_domain' ),         'choose_from_most_used'      => __( 'most used', 'text_domain' ),         'not_found'                  => __( 'not found', 'text_domain' ),     );     $rewrite = array(         'slug'                       => 'recipes/ingredients',         'with_front'                 => true,         'hierarchical'               => true,     );     $args = array(         'labels'                     => $labels,         'hierarchical'               => true,         'public'                     => true,         'show_ui'                    => true,         'show_admin_column'          => true,         'show_in_nav_menus'          => true,         'show_tagcloud'              => true,         'rewrite'                    => $rewrite,         'exclude_from_search' => false,     );     register_taxonomy( 'ingredients', array( 'recipes' ), $args );}     // Register Custom Post Type     function recipes_posts() {          $labels = array(         'name'                => _x( 'recipes', 'Post Type General Name', 'text_domain' ),         'singular_name'       => _x( 'recipe', 'Post Type Singular Name', 'text_domain' ),         'menu_name'           => __( 'recipes', 'text_domain' ),         'parent_item_colon'   => __( 'Übergeordnete recipe:', 'text_domain' ),         'all_items'           => __( 'All recipes', 'text_domain' ),         'view_item'           => __( 'recipe cc', 'text_domain' ),         'add_new_item'        => __( 'recipe bb', 'text_domain' ),         'add_new'             => __( 'ww hinzufügen', 'text_domain' ),         'edit_item'           => __( 'recipe zz', 'text_domain' ),         'update_item'         => __( 'recipe uu', 'text_domain' ),         'search_items'        => __( 'recipe ss', 'text_domain' ),         'not_found'           => __( 'not found', 'text_domain' ),         'not_found_in_trash'  => __( 'nf trash', 'text_domain' ),     );     $rewrite = array(         'slug'                => 'recipes',         'with_front'          => true,         'pages'               => true,         'feeds'               => true,     );     $args = array(         'label'               => __( 'recipes', 'text_domain' ),         'description'         => __( 'div. recipes.', 'text_domain' ),         'labels'              => $labels,         'supports'            => array( 'title', 'editor', 'thumbnail', 'comments', ),         'hierarchical'        => false,         'public'              => true,         'show_ui'             => true,         'show_in_menu'        => true,         'show_in_nav_menus'   => true,         'show_in_admin_bar'   => true,         'menu_position'       => 10,         'menu_icon'           => '',         'can_export'          => true,         'has_archive'         => true,         'exclude_from_search' => false,         'publicly_queryable'  => true,         'rewrite'             => $rewrite,         'capability_type'     => 'post',     );     register_post_type( 'recipes', $args );}


title: What is the correct way for plugins to create tables with special charset/collation considerations?

text: I'm using WordPress >=3.8. The default charset/collation values in wp- config.php are               define('DB_CHARSET', 'utf8');     define('DB_COLLATE', ''); // Becomes utf8_general_ci      I am in a situation where `utf8_general_ci` would be _adequate_ , but something more specific (`utf8_danish_ci`) will always be able to describe my data better. It is also the case that the data, which is fetched from an external source, will always be UTF-8. I am developing a plugin that creates some table               CREATE TABLE plugin_table(         some_id INT NOT NULL,         some_data VARCHAR(100) NOT NULL,         PRIMARY KEY  (some_id)     ) ENGINE=InnoDB;      What is the correct way to handle charset and/or collation? One solution is to use the above statement, falling back on global configuration. As mentioned, this will work in my situation, and from a developer perspective I think it is reasonable to require that either `utf8` or `utf8mb4` is specified. The other solution is to explicitly set the charset/collation settings:               ...) ENGINE=InnoDB [DEFAULT CHARSET=utf8] [COLLATE utf8_danish_ci];      This will allow me to configure the table in the most appropriate way for the data I need to store, and in testing I have confirmed that the letter `Å`, which is treated differently by `utf8_general_ci` and `utf8_danish_ci`, is compared correctly. This _appears_ to work, but I don't know if it is good or bad practice, and, in particular, I don't know if this could cause complications elsewhere (e.g. should I be changing settings when querying the table?). This question has several cousins but this doesn't seem to be a duplicate. The answer that comes closest also mentions the explicit method above, with a comment that it may be more appropriate to use the default values "so the user can override them if they have good reason". If I were going to go out of my way to use the core configuration, then it seems silly to specify these settings in the first place. It is important to understand that there will never be a "good reason" to use non-UTF-8. With respect to collation, the question is less clear. The question boils down to the following: given some non-UTF-8 core configuration, which would be considered unsupported, should I take steps to make my plugin behave correctly?


title: Sort custom-posts in archive.php via meta-key?

text: this question is strongly related to this question where I already got a working answer. I have a custom-post-template named "wr_event" and a custom-taxonomy named "event_type". This "event-posts" have a meta-box where I set the event date and I use this …               function change_order_for_events( $query ) {         //only show future events and events in the last 24hours         $yesterday = time() - 24*60*60;               if ( $query->is_main_query() && is_tax('event_type') ) {             $query->set( 'meta_key', '_wr_event_date' );             $query->set( 'orderby', 'meta_value_num' );             $query->set( 'order', 'ASC' );             $query->set( 'meta_value', $yesterday );             $query->set( 'meta_compare', '>' );         }          }          add_action( 'pre_get_posts', 'change_order_for_events' );      … to sort all "event-posts" via its event-date. This works just fine and does exactly what I want. Only thing that doesn't work so far is the "archive.php" where I want the same to take effect. I added `'has_archive' => 'events'` to my custom-post-template. `/events` displays now my "archive.php" file where I already use `is_post_type_archive('wr_event')` for my headline. However I want my archived events also to be in its right date-order. So the same function above `change_order-for_events()` should work on my "archive.php" template. Of course in this case the function should show just old events that have already taken place. Any idea how I could do that? **update:** I'm storing the timestamp with the MetaBox and CustomFields Class               $meta_boxes[] = array(         'id'         => 'event_date',         'title'      => 'Event Date',         'pages'      => array( 'wr_event', ),         'context'    => 'normal',         'priority'   => 'high',         'fields'     => array(             array(                 'name' => 'Event Date Picker',                 'desc' => 'The date the event takes place',                 'id'   => $prefix . 'event_date',                 'type' => 'text_date_timestamp',             )         ),     );      I query it in my template files with               $wr_event_fields = get_post_custom();     $wr_event_fields['_wr_event_date'][0];


title: Integrate Bugzilla into WordPress

text: I am working on WordPress and Bugzilla. Now I want to integrate the Bugzilla into WordPress. That is, I am getting comments in Bugzilla and I want to show them in WordPress also. How do I integrate the Bugzilla into WordPress?


title: WordPress set custom field to true, sets all others to false?

text: So, if I'm publishing a post, and set a value for this posts custom field, can I set the custom field value of all other posts to false? * * * Well that's good to hear that it is possible, but maybe there is a better way to achieve my goal: I'm fairly new to WordPress, and the WordPress stack exchange site so I apologize if I'm not putting out all the required info. I have a "Designer" custom post type for creating profiles of designers, and I would like to have the option for "Featuring" 1 particular designer and un- featuring the previously "Featured" designer. I am using "Custompress" plugin for post types, taxonomies, and custom field, currently. Thoughts on how I might achieve this are all very welcome! * * * I like the sounds of mfields suggestion, but I have yet to discover what a "custom setting" is. Would you mind elaborating or pointing me in the right direction?


title: Add a page that appears in the backend admin that lists files to download? WP 3.3

text: I am currently using WP 3.3.1. Basically I just want a page for users who login via wp-login.php and see the backend admin panel to be able to see a page that shows a list of files they can download.   1. The files will either be .zip, .pdf, or .txt.    2. Would be awesome if the list of downloads had the same exact format as when you view Posts>> All Posts.    3. To get things started, it doesn't need a sort or filter functionality. Although one would be nice. Not exactly sure how I will upload the files. But whatever route would make the above easiest is the okay with me. Any tips or code snippets that will either do the above or get me started in the right direction would be awesome! Thank you in advance.


title: will post_id ever change? Can I safely use post_id for custom queries?

text: What are the best practices for using post_id? Can I use this safely in my templates to call specific posts, or will these post_id's ever change? The reason I ask is that randomly today the post_id's changed on my site, and I'm wondering what could have caused it. It didn't mess up any of the permalinks (thankfully!) but I did have to go switch some custom queries which were calling content specifically by the post_id (specifically in some custom_post_types I've created) So... should I use a different query to get a specific post? The query I'm using looks like this.               <?php query_posts('post_type=home_feature&p=36')?>      Just earlier today, post_id for this post was 139 and my query was:               <?php query_posts('post_type=home_feature&p=139')?>      Obviously, when the post_id changed, my query (and subsequently the custom home feature) broke. I'm just not sure what could have caused this change.. and if that means I shouldn't be using the post_id in custom queries.. Thoughts?


title: Clean database from unused tables

text: I used to have many plugins installed on one of my sites, and after deleting most of them, I still have a database full of extra tables, I am sure most of them are unused. How do I clean them off?


title: Image dimensions same as image size

text: So if I set the large image size in the media library to say 600x600 pixels, and then upload an image which is the same dimensions it won't get set as the 'large' image. There is talk on this question about it being the ratio, but I don't think this is the case. Also I don't want to setup another custom image size as its will just bloat the server with redundant images, when 'large' should work! Is there a filter or setting where I can change the logic of the images, so if the dimension is larger than , OR equal to the media library setting it gets set as the large image. At the moment the equal to seems to be missing. Thanks


title: Automatically determine minimum WordPress version required for a plugin?

text: When developing a plugin, is there a way to automatically determine the minimum version of WordPress that's required to run it? I want to make sure that the `Requires` header is accurate, but manually checking every time I call a new core function is tedious and error-prone. I'm thinking a script could figure it out easily enough:   1. Scan all the files in a plugin.   2. Parse out all the class instantiations and function calls based on the `new foo( [...] )`, `foo::bar( [...] )`, `bar( [...] )`, `call_user_func( [...] )`, etc syntax.   3. Parse the WP source to determine when each of those classes/functions were added to WordPress, using the `@since` phpDoc tag.   4. Generate a report listing each class/function and the version it was added, along with the earliest version of WordPress that includes all of the classes/functions. I've looked around but couldn't find anything like it, and don't have the time to write it myself. Does anyone know of an existing solution?


title: Wordpress WP_Query() Not working properly

text:
We would like to know that how we occur error when we implement this code in our sidebar.php               $categories = get_categories();      foreach($categories as $category)      {        printf('
%s

', $category->cat_name);       $posts = new WP_Query('cat='.$category->cat_ID);       while($posts->have_posts())       {              $posts->the_post();         echo '
', the_title(), '
';        }          print '
';       }      The error we are getting: > Fatal error: Cannot use object of type WP_Query as array in > C:\xampp\htdocs\wordpress\wp-includes\query.php on line 2374


title: Wordpress Contact Form 7

text: I have a simple contact form using CONTACT FORM 7 PLUGIN on a page on my site. I want user to be able to download a video file only after he/she fills out the form and the form submission is successful. How do i check whether the form is successfully submitted so that I can then put in the code for force download of the file?


title: Implementing an image hosting website using WordPress?

text: I am exploring the idea of implementing a (vertical) **image hosting service** on a self-hosted WordPress platform. I have found several php scripts that can be used for a basic image hosting service and I am trying out one of them - but WordPress is such a great platform, and I am more familiar with it, so I would prefer to use WP if possible. I have found some relevant plugins for WP (Cincopa, BuddyPress etc.), but when I look at their details, they don't look like they would deliver what they promise. How could I go about it?   What plugins could I perhaps combine to do this?   Do I need to use BuddyPress? I would like users to be able to post photos, arrange them in galleries/albums, comment/tag them, complete other custom fields relating to the photos - and, **CRUCIALLY** , be able to **_mark them as public, private or friend._** More advanced membership handling (including membership levels and payment options) would be desirable. I know there are several membership plugins that I could hopefully bring it or customize. Many thanks for any advice.


title: How can I automatically add child pages to pages in a WP menu?

text: In the WP menu creation GUI there's the `Automatically add top level pages` option. I would like to do the opposite, for any page that is in the menu, automatically add it's child pages. Is there a way to do that ?


title: Media Editor uppercase extensions to lowercase

text: What's the reason for making the extensions on uploaded images lowercase as soon as the upload is complete?


title: Display recent posts on front page

text:
I am new to theme development in wordpress i am working on a theme, i have a front page on which i want to display only the most recent 4 posts of any category to be displayed my code for this is               <?php $the_query = new WP_Query( ‘showposts=4′ ); ?>             <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
             <a href=”<?php the_permalink() ?>”><img src="<?php bloginfo('template_directory'); ?>/img/post-images/Adithi_Dinner_blog.jpg" class="border" alt="image" />
<?php the_title(); ?>

<?php echo substr(strip_tags($post->post_content), 0, 100);?>

             <?php endwhile;?>      but it gives me error that unexpected "=", if i remove 4 from the showposts=4 than it shows all the posts on that page, kindly help me how i fix it, thanks


title: Sorting meta box values by start- and enddate and all dates in between

text:
What I've been attempting to write is a function that will allow me to sort a list of WordPress posts by their meta values start date, end date and all dates in between. I've set up a custom metabox with three fields:   * Name of the event (ID `evenement-name`)   * Start date of event (ID `evenement-datum-start`), stored as YY-mm-dd   * End date of the event (ID `evenement-datum-end`), stored as YY-mm-dd What I'd like to have is a list of events that would take place in the future, grouped by year, month and day. Example:   * Event A takes place from 2013/11/24 till 2013/11/26   * Event B takes place on 2013/11/25 Example result: > 2013 > >> November >> >>> 24 >>> >>>> Event A >>> >>> 25 >>> >>>> Event A >>>> >>>> Event B >>> >>> 26 >>> >>>> Event A Unfortunately, that all sounds so much easier in theory. I did manage to get the metaboxes working and run query to return a list of posts of which the meta value `evenement-datum-end` is today or in the future. I even managed to get a list of all dates between `evenement-datum-start` and `evenement-datum-end`, so what I now have is this: > 2013/11/24 - Event A > > 2013/11/25 - Event A > > 2013/11/26 - Event A > > 2013/11/25 - Event B My code:               //This is the function I use to get all the dates between the start date and the end date:     function getDateRange($startDate, $endDate, $format="Y-m-d"){         //Create output variable         $datesArray = array();         //Calculate number of days in the range         $total_days = round(abs(strtotime($endDate) - strtotime($startDate)) / 86400, 0) + 1;              //Populate array of weekdays and counts         for($day=0; $day<$total_days; $day++)         {             $datesArray[] = date($format, strtotime("{$startDate} + {$day} days"));         }         //Return results array: de inhoud van de array wordt uitgelezen          return $datesArray;     }               //Query     $args = array (          'cat'               => '1,6',         'post_type'         => 'post',          'meta_key'          => 'evenement-datum-start',         'posts_per_page'    => -1,         'meta_query'        => array(             array(                 'key'       => 'evenement-datum-end',                 'value'     => date('Y-m-d'),                 'compare'   => '>=',                 'type'      => 'DATE'             )         ),      );          $agenda_query_full = new WP_Query ( $args );               if ( $agenda_query_full->have_posts() ) {     echo '
';              while ( $agenda_query_full->have_posts() ) {             $agenda_query_full->the_post();                  $meta_event_name    = get_post_meta( get_the_ID(), 'evenement-name', true );             $meta_event_start   = get_post_meta( get_the_ID(), 'evenement-datum-start', true );             $meta_event_end     = get_post_meta( get_the_ID(), 'evenement-datum-end', true );             $dateRange      = getDateRange($meta_event_start, $meta_event_end);                   asort($dateRange);             $today              = date('Y-m-d');                  foreach ($dateRange as $key => $val) {                 $datum      = date("d-m-Y", strtotime($val));                         if($val>=$today) {                          if(in_category( 'acties' ) ){                         echo '
'.$datum.' - ' . $meta_event_name . '
';                     }                     else {                         echo '
'.$datum.' - ' . $meta_event_name . '
';                     };                 };             }         }         echo '
';     } else {         echo 'No events found.';     }          wp_reset_postdata();      As I understand it, and I'm only a beginner at PHP, is that I can't query for a list of dates before I run the loop. But when I do run the loop, I can't get the dates to be sorted chronologically, because I've already retrieved a single post. Impasse reached. I've been working on this for several days now and getting desperate... Any help?


title: Compare "Main" post ID to ID inside wp_query loop

text: I have a video viewing section on my site. The single post template displays a large area where the video plays and then there's a column of thumbnails representing other videos along the right side. Much like YouTube. If the current video that is being displayed (let's say the post ID is 123) matches one of the thumbnail on the right (also ID 123) I want to give the thumbnail a different css class (represented by the inline style below) so I can highlight it, letting the user know this is the video currently playing. I'm using wp_query to grab the posts for the right sidebar portion and I can't figure out how to compare the two IDs while in the loop. Below is a simplified version of what I thought would work, but it just gives the class to all iterations of the loop instead of just the current one.               <?php while ( have_posts() ) : the_post();      $primaryid = get_the_ID(); ?>     <?php                  $args = array (                     'post_type' => 'post',                     'post_status' => 'publish',                     'orderby' => 'meta_value_number',                     'meta_key' => 'episode',                     'order' => 'ASC',                     );                 // The Query                 $query = new WP_Query( $args );                      // The Loop                 if ( $query->have_posts() ) { ?>                          <?php while ( $query->have_posts() ) {                         $query->the_post(); ?>                         <?php if (get_the_ID() == $primaryid) {                             $style = 'style="border: 1px solid #fff;"';                             } ?>     <?php endwhile; // end of the loop. ?>


title: How to disable "Audio Player" to show up on the main page

text: I have a post with audio player with autostart enabled, and i decided to put it in the beginning of the post, before putting "read more" excerpt feature. So the problem is, that audio player plays music on the main page, but i want it to work only on post page. Is it possible to do? I've put my post in drafts for now, until i solve this little problem...


title: unapprove comments on custom post type

text: I have registered a custom post type and I want to unapprove comments by default on this custom post type without affecting the default posts/pages which is set to approve. I've looked through the CODEX but I can not find anything related to what I'm trying to do. I've found just how can I display the un-approved comments. Code for registering custom post type:               // Register Custom Post Type          function debate_post_type() {                    $labels = array(         'name'                => _x( 'Debates', 'Post Type General Name', 'text_domain' ),         'singular_name'       => _x( 'Debate', 'Post Type Singular Name', 'text_domain' ),         'menu_name'           => __( 'Debate', 'text_domain' ),         'parent_item_colon'   => __( 'Parent Debate:', 'text_domain' ),         'all_items'           => __( 'All Debates', 'text_domain' ),         'view_item'           => __( 'View Debate', 'text_domain' ),         'add_new_item'        => __( 'Add New Debate', 'text_domain' ),         'add_new'             => __( 'New Debate', 'text_domain' ),         'edit_item'           => __( 'Edit Debate', 'text_domain' ),         'update_item'         => __( 'Update Debate', 'text_domain' ),         'search_items'        => __( 'Search debates', 'text_domain' ),         'not_found'           => __( 'No debates found', 'text_domain' ),         'not_found_in_trash'  => __( 'No debates found in Trash', 'text_domain' ),     );     $args = array(         'label'               => __( 'debate', 'text_domain' ),         'description'         => __( 'Here you can post your debates', 'text_domain' ),         'labels'              => $labels,         'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'custom-fields', 'page-attributes', 'post-formats', ),         'taxonomies'          => array( 'category', 'post_tag' ),         'hierarchical'        => true,         'public'              => true,         'show_ui'             => true,         'show_in_menu'        => true,         'show_in_nav_menus'   => true,         'show_in_admin_bar'   => true,         'menu_position'       => 5,         'menu_icon'           => '',         'can_export'          => true,         'has_archive'         => true,         'exclude_from_search' => false,         'publicly_queryable'  => true,         'capability_type'     => 'page',     );     register_post_type( 'debate', $args );     }     // Hook into the 'init' action     add_action( 'init', 'debate_post_type', 0 );      Any suggestions on how can I do this ? Thanks!


title: How to create a posts archive page showing only the date and the post title

text: I have the following question about how to create an archive page on my website. As you can see opening this link: http://lnx.asper-eritrea.com/ Under the header slideshow I have 3 boxes, the second one (names **Archivio** ) have to be linked to a page that show a list of all published posts (belonging to all the categories). My problem is: how can I create this page? If I go in the **administration panel ---> Appreance ---> Menus** I see that I can create a voice that open a page showing the posts belonging to a specific category (but not to all categories). What can I do to create an archive page that show all my posts (as in the homepage, but then I will set a different content visualization using an unordered list and showing only the posts title)? Can I create a static page and insert into it the posts loop? What is the best way to do it? Tnx


title: next gen gallery thumbnail problem

text: Does anyone know why nextgen gallery doesn't support thumbnails with png transparency??? I'm working on this project http://decolabel.andresmijares.com/smaakvolle- etiketten/ And as you can see the slideshow work the image properly, however the thumbnails have a black background. I'd really appreciated any kind of help :)!


title: body_class hook for admin pages

text: The body_class hook seem only to work with non-admin pages. When I do               add_filter('body_class', 'add_body_classes');     function add_body_classes($classes) {             $classes[] = 'myclass';             return $classes;     }      Is there another hook i should be using if i want to add a class to the body of an admin page?


title: Using catch_the_image to get the thumbnail size

text: I use front end posting on my site so I don't get a chance to set a featured image for alot of my posts. So I use catch_the_image to get thumbs but it gets the original size and then scales it which is hurting page speed. Basically what I want to do is add "-150x150" into the string in the function so it pulls the smallest size of the 3 it stores in the uploads folder. So instead of picture.png it returns picture-150x150.png. Any idea how to add that to this function?               function catch_that_image() {      global $post, $posts;      $first_img = '';      ob_start();      ob_end_clean();      $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);      $first_img = $matches [1] [0];           return $first_img;     }


title: the_author_posts_link() for authors of custom post types

text: I have both regular blog posts and a custom post type in a blog. The page template shows the author posts link. If you click on that link for an author that has authored some posts, that page (blog/authors/mr-author) shows the expected bio information and a list of the author's posts. However, if you create a user that is an author, but who has only authored the custom post type, and no regular posts, the link generated by the_author_posts_link() (which is still the correct link: blog/authors/mr- author) shows an unpopulated page (ie: the fields are all empty, and the posts listing is the full list of all posts for all authors). Clearly, we're not getting the right data inside the $authordata global. But why? `author.php` is using standard template tags like `get_the_author_meta('display_name')` to display author information, but this is all showing blank results for an author that has no posts. I'm currently digging through core to figure out where and when $authordata gets populated to see if it's linked to a specific post type being present, but so far have yielded nothing useful. Anyone run into this before? EDIT: SOLUTION BASED ON CHIP'S ANSWER               add_action('pre_get_posts', 'hdb_add_custom_type_to_query');          function hdb_add_custom_type_to_query( $notused ){          if (! is_admin() ){             global $wp_query;             if ( is_author() || is_home() ){                 $wp_query->set( 'post_type',  array( 'post', CUSTOM_TYPE ) );             }          }     }      Assumes you've defined CUSTOM_TYPE constant at some point, probably when you declare the custom post type.


title: need to add attach thumbnail from my form

text: i need to add [attach thumbnail] to this form functions.php Code:               if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {              // Do some minor form validation to make sure there is content         $title =  $_POST['title'];         $ordertype = $_POST['ordertype'];         $price = $_POST['price'];         $ordertime = $_POST['ordertime'];              // Add the content of the form to $post as an array         $new_post = array(             'post_title'    => $title,             'post_content'  => $description,             'post_category' => array($_POST['category']),             'post_status'   => 'publish',             'post_type' => 'post'         );         //save the new post         $pid = wp_insert_post($new_post);          add_post_meta($pid, 'ordertype', $ordertype, true);         add_post_meta($pid, 'price', $price, true);         add_post_meta($pid, 'ordertime', $ordertime, true);         wp_redirect('/'); exit;         //insert taxonomies     }      source: Form to Add Posts to Custom Post Type


title: Getting categories to change appropriately when using $cat = ' ';

text:
The code below is based on a couple of forum posts from a couple of places. To a certain extent, it works. The issue I am having is that it only shows "Activities", no matter what parent category I'm in. I tried replacing "activities" with a number of very unsuccessful alternatives (conditionals, get functions, and others); nothing worked.               <?php $cat = 'Activities'; /* This is the problem area.        Trying to get $cat to equal the name of the selected parent categories; the rest of        the code seems to be working, at least for the Activities category. */          $catID = get_cat_ID($cat);     echo '
' . $cat . '
';     $subcats = get_categories('child_of=' . $catID);     foreach($subcats as $subcat)     {         echo '
' . $subcat->cat_name . '
';         echo '
';         $subcat_posts = get_posts('cat=' . $subcat->cat_ID);         foreach($subcat_posts as $subcat_post)         {             echo '
';             $postID = $subcat_post->ID;             echo '';             echo get_the_title($postID);             echo '';             echo '
';         }         echo '
';     }?>


title: How to make certain page templates visible to admin only

text: Making a site for a client, I have some pages that the client won't be able to edit or delete. These pages rely on specific page templates. However, I don't want these templates to be available for the client when creating new pages. Is there someway to hide these certain page template from the page attributes dropdown when creating new pages? Thanks


title: Show child pages when on a child page

text: On my site I have a number of parent pages with associated child pages. How can I show all the child pages of one particular parent when a visitor is either on the parent page or one of it's children? For example; If someone clicks onto the "Story" parent page, they'll see a list of "story" child pages in the sidebar (As well as a link to the parent page). Then if they click through to one of those child pages, they'll still be able to see the list in the sidebar