title: how can i add_option as array from a form with just a text input

text:
I have the following function:               function si_ad_call_models(){         // title of the page         echo '
Add new ad call model
';         ?>         <form action="" method="post">             Enter name of ad model:              <input type="text" name="new_model_name"/>             <input type="submit" name="submit" value="Add your new ad model"/>         </form>         <?php         if(isset($_POST['submit'])){              add_option('si_ad_call_model', serialize($_POST['new_model_name']));         }         $myopt =  unserialize(get_option('si_ad_call_model'));     }      The variable $myopt outputs the first thing that i enter in the text field. The question is how can i add the values in an array and every time i submit the form it should update the option value? Is that possible?


title: Reoccurring cron request

text: It appears that somehow my plugin on some wordpress installations causes a never ending stream of cron requests to occur. I believe the only place that we use code that interacts with cron is when we call wp_schedule_event. Any ideas why this code might make a site unusably slow?               register_activation_hook(__FILE__, 'plugin_activation');     register_deactivation_hook(__FILE__, 'plugin_deactivation');          function plugin_activation() {         wp_schedule_event(time(), 'daily', 'plugin_foo');     }          function plugin_deactivation() {         wp_clear_scheduled_hook('plugin_foo');     }          function plugin_foo() {         global $plugin_host;         global $wpdb;              // get recipe info         $web_data = array(             "body" => array(                 "foo" => json_encode(...),                 "bar" => json_encode(...)             ),             "timeout" => 60         );              // call         $response = wp_remote_post($plugin_host . "/foo", $web_data);              // update recipes         if (!is_wp_error($response)) {             // do stuff         }     }


title: Insert term description programmatically into hierarchical custom taxonomy

text: I have following code and I want to specify a term description for each actor and director in `$tmdb_actors_arr` and `$tmdb_directors_arr`:               // build array     $my_post = array(         'post_title' => $tmdb_title,         'post_name' => $wp_movie_slug,         'post_content' => $tmdb_plot,         'post_status' => 'publish',         'post_type' => 'post',         'tax_input' => array(             'tmdb2wp_year' => $tmdb_date,             'tmdb2wp_actor' => $tmdb_actors_arr,             'tmdb2wp_director' => $tmdb_directors_arr         ),     );     // insert post built from array above     $post_id = wp_insert_post($my_post);          // instert custom fields     add_post_meta($post_id, 'tmdb_id', $tmdb_id, true);     add_post_meta($post_id, 'imdb_id', $tmdb_imdb, true);     add_post_meta($post_id, 'backdrop', $tmdb_backdrop, true);     add_post_meta($post_id, 'poster', $tmdb_poster, true);     add_post_meta($post_id, 'original_title', $tmdb_orig_title, true);     add_post_meta($post_id, 'tagline', $tmdb_tagline, true);     add_post_meta($post_id, 'trailer', $tmdb_trailer, true);     add_post_meta($post_id, 'og-image', $tmdb_poster, true);     add_post_meta($post_id, 'og-title', $tmdb_title, true);     add_post_meta($post_id, 'og-description', $tmdb_plot, true);          // insert genres as categories     wp_set_post_terms($post_id, $tmdb_genres_arr, 'category');      So how and where do I insert term descriptions for director 'Stephen Spielberg' and actors 'Marlon Brando', 'Morgan Freeman'? Edit:               // Movie cast     $i = 0;     while ($i < count($tmdb_cast)) {         $tmdb_actors_arr[] = $tmdb_cast[$i]['name'];         $i++;     }          // Movie crew     $i = 0;     while ($i < count($tmdb_crew)) {         if ($tmdb_crew[$i]['job'] === "Director") {             $tmdb_directors_arr[] = $tmdb_crew[$i]['name'];         }         $i++;     }


title: Remove Twenty Twelve themes responsiveness in Internet Explorer

text: I've researched everywhere and I cannot find anything about my issue with Twenty Twelve theme: Is there a way to disable the responsive feature **ONLY** for IE and leave it active for the rest of the browsers? (it works perfectly in modern browsers).   I mean, it doesn't matter if IE shows always a fixed version of the site, in fact it's what I want if the visitor is using any version of IE.


title: Wordpress archives by custom field and date

text: I have a strange situation on my hand. I want to list my archives based on a custom field (numerical value) but also display something like a cover. We have specific posts in different categories but with a numeric custom field, that is unique to multiple posts (something like edition number). For every edition number i have a different number of posts and a cover image. I would like to display them with something like. The cover (image) - number of posts - and the date of the edition. I am able to query by custom value, but i am unable to get the date for them.. I'm not sure how i should approach this and therefore i'm asking here. LATER EDIT: What i'm trying to achieve is basically this:   1. Get a list of all unique meta_values for specific meta_key.   2. For each meta_value output the cover for it (this will be done based on the key)   3. For each meta_value list number of posts with a link to see them all (this will be also done based on the meta_value with something like ?meta_key=222.   4. Paginate so that the page won't get too big as i currently have ~600 unique keys..


title: Regenerating array key for wp_schedule_event args

text: I've been working on this the last day with no luck. Is there any way to update a stored args array key for an event scheduled? Reason I ask is I have array args that look like this when scheduling a payment:               Array     (         [customer] => Array             (                 [name] => ''                 [email] => ''                 [id] => ''                 [user_id] => ''                 [street] => ''                 [city] => ''                 [state] => ''                 [zip] => ''                 [phone] => ''             )              [payments] => Array             (             )              [recurring] => Array             (                 [user_id] => 70                 [amount] => 1600             )          )      Payments will get pushed to that array as they are processed, thus changing the array and changing how the key will be serialized. Is it possible to update the key of the array with the new serialized args?


title: Multisite plugin hiding on specific blogs

text: Is it possible to hide plugins on a per blog basis in WordPress multisite? I would like not to have plugins available on certain blogs.


title: Using OOP in themes

text: I see a lot of plugins making use of object-oriented coding when there isn't really necessary. But what's even worse is that theme developers are starting to do the same thing. Commercial themes and free popular themes like Suffusion, even my favorite theme - Hybrid, stuff all their functions inside a class, instantiate it once in functions.php and run its functions in a procedural manner :) Wtf? What's the point of doing this? Obviously you won't be using two or more instances of the same theme, at the same time. Let's assume that the plugins do this for the namespace (which is ridiculous), but what's the theme excuse? Am I missing something? What's the advantage of coding a theme like this?


title: How long does it take for a new plugin to be approved?

text: I've just submited my first wp plugin and i would like to know after how much time will my plugin be published to the wordpress plugin directory? Hou much did you actually waited?


title: How to get the post content after Wordpress post processing?

text: I have a plugin that will send tutorial emails to our users. These tutorials are created in wordpress and stored in wp_posts table in the database. Of course I could simply run a query to get the post and that's it. But is there a special built-in function that I can use to get the post content after Wordpress post processing? I am thing of using get_post but I'm not sure if this is the best thing to do:               <?php     $my_id = 7;     $post_id_7 = get_post($my_id);      $post_content = $post_id_7->post_content;     ?>       Thanks for any tips.


title: wordpress is adding a second backslash when I use addslashes

text: I don't know why but it seems like wordpress is adding a second backslash when I'm using the following functions:               addslashes($str_with_single_quotes)     addslashes(stripslashes($str_with_single_quotes));     esc_sql($str_with_single_quotes)     str_replace("'", "/'", $str_with_single_quotes)      What I'm doing is that I'm fetching data from different API's and then converting those data to a json string so I can access them later on:               $item_data = array(         'item_title' => __(addslashes(stripslashes($item_name))),         'product_review' => __(addslashes(stripslashes($product_review))),         'freebase_text' => __(addslashes(stripslashes($freebase_result['text'])))     );          $data = json_encode($item_data);      It doesn't seem like the localization function (`__()`) is the one that's causing the problem since the problem is still there even I completely remove it. I also tried `preg_replace_all` but I got a fatal error that the function wasn't recognize. I also tried using `str_replace`, `esc_sql`, and `str_replace` after the array was converted a json string but no luck. I've run out of ideas on how to solve this problem. Simply using `json_encode` without processing the strings doesn't actually do anything and the single quotes are left unescaped. Magic quotes are also disabled:               magic_quotes_gpc = Off     magic_quotes_runtime = Off     magic_quotes_sybase = Off      Thanks in advance.


title: Hierarchical permalinks for custom post type and taxonomy

text: I have registered the custom post type "word" and the custom taxonomy "wordcat". Now what I want is proper hierarchical permalinks. So I've been searching the web for quite some time with no result. No matter what I try I can't get WORKING hierarchical permalinks. Wordpress won't find the post page. Here is my code :   **Custom Post Type**               function create_word_post_types() {     $args = array(                 'labels'    => $labels,                 'public'    => true,                 'menu_position' => 25,                 'rewrite'   => array( 'slug' => 'word/%wordcat%'),                 'query_var' => true,                 'supports'  => array(                                 'title',                                 'editor',                                  'thumbnail',                                'excerpt',                                'revisions'                                ),                 'has_archive'   => false                 );         register_post_type( 'word', $args );     }     add_action( 'init', 'create_word_post_types' );         **Custom Taxonomy**               function word_taxonomy() {     $args = array(         'labels' => $labels,         'hierarchical' => true,         'query_var' => true,         'rewrite' => array( 'hierarchical' => true, 'slug' => 'word')     );     register_taxonomy( 'word-categories', 'word', $args );     }     add_action( 'init', 'word_taxonomy', 0 );         **Rewrite rules**   based on this link: How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type- name               add_filter('rewrite_rules_array', 'mmp_rewrite_rules');          function mmp_rewrite_rules($rules) {         $newRules  = array();         $newRules['word/(.+)/(.+)/(.+)/(.+)/?$'] = 'index.php?word=$matches[4]';         $newRules['word/(.+)/?$']                = 'index.php?word-categories=$matches[1]';               return array_merge($newRules, $rules);     }          function filter_post_type_link($link, $post)     {         if ($post->post_type != 'word')             return $link;              if ($cats = get_the_terms($post->ID, 'word-categories'))         {             $link = str_replace('%wordcat%', get_taxonomy_parents(array_pop($cats)->term_id, 'word-categories', false, '/', true), $link);         }         return $link;     }     add_filter('post_type_link', 'filter_post_type_link', 10, 2);          function get_taxonomy_parents($id, $taxonomy, $link = false, $separator = '/', $nicename = false, $visited = array()) {             $chain = '';            $parent = &get_term($id, $taxonomy);              if (is_wp_error($parent)) {             return $parent;         }              if ($nicename)                 $name = $parent -> slug;             else                 $name = $parent -> name;              if ($parent -> parent && ($parent -> parent != $parent -> term_id) && !in_array($parent -> parent, $visited)) {                 $visited[] = $parent -> parent;                 $chain .= get_taxonomy_parents($parent -> parent, $taxonomy, $link, $separator, $nicename, $visited);              }              if ($link) {             // nothing, can't get this working :(         } else                 $chain .= $name . $separator;             return $chain;         }         The result looks correct : **_www.mysite.com/word/adjective/annoying/_**   but doesn't display the post. Instead i get the dreaded 404 error.


title: invisable position element

text: I have a weird ghost like element on my page which blocks other elements. Visually its positions alright, but it is larger then it appears. If did a hour of inspecting and can't find any source that could cause this. Giving it a height makes it do even weirder thing. See screenshots https://dl.dropboxusercontent.com/u/345640/weird.jpg https://dl.dropboxusercontent.com/u/345640/Screen%20Shot%202013-12-21%20at%2023.21.43.png The elements: content, main, home-tabs and articles also do this.


title: example of build_query function?

text: I have this resource: (http://codex.wordpress.org/Function_Reference/build_query), but it does not give full example. I have this URL: mypage/?page_id=87 and this array:               array('name' => 'me')      So, I need to add the array to the end of the URL. I know the build_query function will add the proper markup ( & ), but how do I connect the function to the URL. e.g.- How do I use the function?


title: How to make my wordpress site responds for 2 domains

text: I have a Wordpress Woocommerce site running on www.mydomain.com.br and I'd like it to also respond for the domain srougi.biz/mydomain because my return page (page that users go after payment) must have SSL. I only have SSL for srougi.biz not, for mydomain.com.br, so my return page would be https://srougi.biz/mydomain/return.


title: List ALL posts by author on author archive

text:
I'm having trouble setting up an author archive. I've come up with a few different loops, but I can't seem to get them quite right. I just want it to list _all_ posts by the _current author_. This shows posts by the current author, but `only 10 posts` (my default number, I guess):
         <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?>
         <?php endwhile; ?>         <?php endif; ?>
      This one lists _all_ post by _all_ authors.               <?php global $post;         $args = array('numberposts' => -1);         $custom_posts = get_posts($args);         foreach($custom_posts as $post) : setup_postdata($post); ?>             <li <?php post_class($custom_classes) ?> id="post-<?php the_ID(); ?>" role="article"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>
     <?php endforeach;?>      This doesn't seem that hard. I'm probably missing something obvious. It seems like I need to get the author into a variable and pass it, but I thought that was assumed on the author archive. My attempts to do that just haven't worked.


title: Adding a Custom 'Now' button under 'Published on' header to return current date and time

text: I want to add a new 'Now' button under the 'Published on' header so as to return the current date and time to the post update time. This would help people who want to update their post with a recent time, with ease than publishing with the original publishing time. It would work if, the action of 'Publish' button is given to the 'Now' button as, 'Publish' button returns current date and time to the 'Published On' column. Please help me with the code. I edited the templates.php and added the following code under the publishing action metabox :                   <input name="original_publish" type="hidden" id="original_publish"          value="<?php esc__attr_e('Publish') ?>" />         <?php submit_button( __( 'Now' ), 'primary button-small', 'publish',           false, array('accesskey' => 'p' ) ); ?>


title: Make 'Page' slug the 'index'

text: I want to have my Index page show posts from a certain Category ('news'). I have that functionality, but is there a way I can make a 'News' Page, where the slug just points to the index?


title: Adding Button to Shop Page in WooCommerce

text: Client has had me making tweaks to WooCommerce, most solutions through CSS. This one, despite being simple, has had me stumped. For each result that is returned on shop page client wants me to add a button next to "Add to Cart" that links to the product page (instead of just having clicking on the picture link to product page.) Any suggestions on CSS as well as which CSS files to edit?


title: How do I make Twenty Ten display comments on the home page?

text: The site is www.timhaighreadsbooks.com. I want any comments to display on the home page. How can I achieve that, please? Johnny


title: How can I add authors to my blog pages?

text: I use Wordpress as a school paper blog and I would like to have different authors for articles. How can I add some new authors other than my blog title?


title: POST to a REST API from a wordpress form

text: I dont want to use a REST API to publish to wordpress. I want to create a form on a wordpress page which will send a POST to an external REST API. Users will put in their information, and perhaps upload a file. When the press "submit" I want this information to be sent to a REST API on a different server (not wordpress). Are there any plugins that allow this? Has anyone done this? Of course, I might run into troubles with this: http://en.wikipedia.org/wiki/Same_origin_policy It looks like I want to do the reverse of this: http://wordpress.org/extend/plugins/json-api/ Instead of making a REST API for wordpress, I want to make wordpress communicate send a POST to an external REST API when a user presses a button on a form.


title: List Category Posts not showing posts marked private to logged-in users

text: I'm using the List Category Posts plugin, and it isn't listing posts marked private, even if the appropriate user is logged in. Is there a fix for this?


title: Customising Word press Admin - Add Post Page functionality to another similar page

text: We are Customising Wordpress Admin to build a biz application. WE are using Wordpress as a base to build our application. We used the Add Post page as Add Customer - customised some fields and we posted it to the db using wp_post . Now we want to add two more menu's like Add Vendor, Add Employees ( which should work very similar to the Post Page) and should go to different tables . We considered Wordpress Admin for Add customer because, we could automatically get Autodraft, commenting, Tag etc., Now we want the same for the other screens that we plan to add. Now, when we are writing code for the new screens, by default it is getting posted to wp_post table where as it has to go to our new tables that we have designed. We are not sure what is the right approach. Pls advice. Thanks in Advance


title: Insert media button will always add into the same tinyMCE editor

text: I have an issue with the insert-media button. I have 2 instances of tinyMCE with both Add Media button. When I add a media in one of the two tinyMCE, all my media will go in this after, whatever which insert-media button I click on. For instance, if I add a media in my tinyMCE-1 by clicking my media button of tinyMCE-1, it will add my media in it all is good. But if I now want to add another media in tinyMCE-2 by clicking on media button of tinyMCE-2, it will add on the tinyMCE-1 ! I don't unerstand why at all. I am stuck here for several days. I checked and the activeEditor is tinyMCE-1 when it has to be and same for tinyMCE-2... Thanks for helping me !


title: Add Dynamic Sidebar to Exisiting WordPress Theme

text:
I'm using the SoulVision WordPress theme, I'm trying to add a bottom sidebar to the already existing Top, Left and Right sidebars, however, I can't get it to successfully work. Any help would be appreciated. My coding is below. **style.css**               /*-- Sidebar settings --*/     #sidebar {         float:right;         width:400px;         color:#DEDABF;         margin-top:0px;         position:relative;         font-size:11px;     }     #sidebar a:hover {         color: #C58556;         text-decoration: none;     }     #sidebar h2 {         font-size:14px;         font-weight:bold;         border:1px solid #8E6140;         margin:0;         padding:3px 0 6px 8px;         background: url(images/h2-bg.jpg) repeat-x left top;     }     #sidebar ul li strong {         color:#FC0;     }     #sidebar-top {         width:390px;         padding:5px;     }     .sidebar-top-box {         margin-bottom:10px;         padding:0;         border-top: none;         border-right: 1px solid #8E6140;         border-bottom: 1px solid #8E6140;         border-left: 1px solid #8E6140;     }     .box-padding {         padding:7px;     }     .sidebar-top-box p {         margin-top:3px;         margin-bottom:3px;     }     #sidebar-top h2 {         margin-top:10px;         color:#CFA97E;     }     #sidebar-top .textwidget {         margin-bottom:10px;         padding:7px;         border-right: 1px solid #A1674F;         border-bottom: 1px solid #A1674F;         border-left: 1px solid #A1674F;     }     #sidebar-top ul ul {         list-style-type:none;         margin-bottom:10px;         padding:10px 7px 7px 12px;         border-right: 1px solid #8E6140;         border-bottom: 1px solid #8E6140;         border-left: 1px solid #8E6140;     }     #sidebar-top ul ul li {         padding-left:10px;         list-style-type:none;         background-image:url(images/lidot.gif);         background-repeat:no-repeat;         background-position:left top;         padding-bottom:3px;     }     #sidebar-top ul li a {         text-decoration:none;     }          #sidebar-top .box-ads a{         text-decoration:none;     }     #sidebar-left {         float:left;         width:215px;         padding:0 10px 0 5px;     }     #sidebar #sidebar-left h2, #sidebar #sidebar-right h2 {         margin:15px 0 10px;         color: #CFA97E;     }     #sidebar-right {         float:right;         width:153px;         padding:0 5px 0 10px;     }     #sidebar-left ul ul, #sidebar-right ul ul {         padding-left:5px;     }     html, #sidebar ul, #sidebar-wrap ul, .rel-posts ul {         margin:0;         padding:0;     }     #sidebar-right li, #sidebar-left li {         background:url(images/lidot.gif) no-repeat left top;         list-style:none;         margin:0;         padding:0 0 5px 8px;     }     #sidebar-left  .children, #sidebar-right  .children {         padding-top: 8px;     }     #sidebar-left  ul.children  li, #sidebar-right  ul.children  li {         padding-bottom: 3px;         padding-top: 0px;     }     #sidebar   h2  a.rsswidget {         color: #CFA97E;         text-decoration: none;     }     #sidebar .rsswidget img {         float: left;         margin-top: 2px;         margin-right: 7px;     }     /*-- Bottom Sidebar --*/     #sidebar-bottom {         width:390px;         padding:5px;     }     .sidebar-bottom-box {         margin-bottom:10px;         padding:0;         border-top: none;         border-right: 1px solid #8E6140;         border-bottom: 1px solid #8E6140;         border-left: 1px solid #8E6140;     }     .box-padding {         padding:7px;     }     .sidebar-bottom-box p {         margin-top:3px;         margin-bottom:3px;     }     #sidebar-bottom h2 {         margin-top:10px;         color:#CFA97E;     }     #sidebar-bottom .textwidget {         margin-bottom:10px;         padding:7px;         border-right: 1px solid #A1674F;         border-bottom: 1px solid #A1674F;         border-left: 1px solid #A1674F;     }     #sidebar-bottom ul ul {         list-style-type:none;         margin-bottom:10px;         padding:10px 7px 7px 12px;         border-right: 1px solid #8E6140;         border-bottom: 1px solid #8E6140;         border-left: 1px solid #8E6140;     }     #sidebar-bottom ul ul li {         padding-left:10px;         list-style-type:none;         background-image:url(images/lidot.gif);         background-repeat:no-repeat;         background-position:left top;         padding-bottom:3px;     }     #sidebar-bottom ul li a {         text-decoration:none;     }          #sidebar-bottom .box-ads a{         text-decoration:none;     }      **sidebar.php**

           <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_top') ) : else : ?>           <?php endif; ?>

           <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_left') ) : else : ?>           <?php endif; ?>

           <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_right') ) : else : ?>           <?php endif; ?>

           <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_bottom') ) : else : ?>           <?php endif; ?>

      With the following code, my sidebars display like this - i.imgur.com/omMfa.png But if I change the **sidebar.php** code to this

               <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_top') ) : else : ?>               <?php endif; ?>

               <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_bottom') ) : else : ?>               <?php endif; ?>

               <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_left') ) : else : ?>               <?php endif; ?>

               <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar_right') ) : else : ?>               <?php endif; ?>

      Then the sidebar will display like this - i.imgur.com/UATs6.png So, it appears to me that there's an issue when adding it below the existing ones. Any help would be wonderful. The site can be previewed live at http://www.itsdaniel0.com **Update** **functions.php**               // Widget Settings                         if ( function_exists('register_sidebar') )         register_sidebar(array(             'name' => 'Sidebar_top',             'before_widget' => '',             'after_widget' => '',              'before_title' => '
',             'after_title' => '
',         ));          if ( function_exists('register_sidebar') )         register_sidebar(array(             'name' => 'Sidebar_left',             'before_widget' => '',              'after_widget' => '',              'before_title' => '
',             'after_title' => '
',         ));          if ( function_exists('register_sidebar') )         register_sidebar(array(             'name' => 'Sidebar_right',             'before_widget' => '',             'after_widget' => '',              'before_title' => '
',             'after_title' => '
',         ));          if ( function_exists('register_sidebar') )         register_sidebar(array(             'name' => 'Sidebar_bottom',             'before_widget' => '',             'after_widget' => '',              'before_title' => '
',             'after_title' => '
',         ));          //GsL98DGtpo0W          add_theme_support( 'post-formats', array( 'aside', 'gallery', 'video' ) );          ?>


title: How to update page status from publish to draft and draft to publish

text: I am trying to figure out how to write the code that will allow me to do the following with pages of a WordPress blog? "To change a post status, you get the post, change its status field, then call wp_update_post with the new post object" The closest existing plugin is http://wordpress.org/extend/plugins/wp-hide- pages/ - Except that this plugin uses wp-list-pages and it only hides them and does not actually move them from publish to draft. I need to have something where I specify which page ID's I want to list (about 15 total) and then give the user the ability to select which ones will be published or which ones will be a draft - this will remove from menu and will also remove page from site as well...


title: Hooking a function onto the sidebar?

text: I'm looking for a way to add some content to the top of the sidebar when it get's loaded. I've tried hooking onto the get_sidebar action as referenced here, but it seems to override the sidebar call and load my function instead? Is there a better solution to doing this beside creating widgets? I'd like to avoid that if possible, but I'm not totally against the idea, a hook would be best :) Here's what my hook looks like: `add_action('get_sidebar', 'social_links');` _Note:_ the function called is just spitting a list of social media links, nothing too fancy... (Running latest version (3.1) on a MAMP server locally)


title: Various Wordpress Feeds for Same Blog

text: With http://blog.serverfault.com there are a couple of feed URLs:   * http://blog.serverfault.com/feed gives a normal feed with the full content of the post.   * http://blog.serverfault.com/rss gives only a summary and every post is listed twice What is the proper way to control these feeds? I want to eliminate the the double posting summary feed and redirect it to the /feed feed. Should I just do this with mod_rewrite or is there a way to mange these in wordpress?


title: Maintaining a separate posts page for certain categories and don't show those on home page

text: I have a personal blog where I write general posts. I decided I'd like to seldom post about some other topic (let's say it's cats), that interests a very different audience then my current one. So I want to sometimes write about cats, but I want those cats posts not to appear in the main posts page on my home page. I'd like to have a separate page where the cats posts all appear and where I control the page's URL (e.g. "site.com/cats"). One idea I had is to:   1. Tag all the cats posts with a certain tag (e.g. 'cats')   2. On the main posts page, filter out posts with the 'cats' tag, as well is in the "recent posts" appearing on my homepage   3. Somehow refer the page site.com/cats to the tag page of 'cats', only showing posts tagged with 'cats' My problem is that I couldn't find a simple way to do (2) and (3). Is there an out-of-the box way to achieve that? My site is here.


title: How do I create multiple page while active a theme

text: I want create 5 pages when user active my theme. I found a code from wpcanyon which can create one page only. From this code how do I create 5 pages without repeat it 5 times.               if (isset($_GET['activated']) && is_admin()){              $new_page_title = 'This is the page title';         $new_page_content = 'This is the page content';         $new_page_template = ''; //ex. template-custom.php. Leave blank if you don't want a custom page template.              //don't change the code bellow, unless you know what you're doing              $page_check = get_page_by_title($new_page_title);         $new_page = array(             'post_type' => 'page',             'post_title' => $new_page_title,             'post_content' => $new_page_content,             'post_status' => 'publish',             'post_author' => 1,         );         if(!isset($page_check->ID)){             $new_page_id = wp_insert_post($new_page);             if(!empty($new_page_template)){                 update_post_meta($new_page_id, '_wp_page_template', $new_page_template);             }         }          }      Let me know.


title: Showing relevant categories on custom taxonomy template

text: I an using two taxonomies with private posts.   1. category e.g. massage, travel   2. location e.g. new-york-city, boston etc. On a location page, I want to show categories that are relevant to that location. e.g. If I am on `?location=boston` page I would find all the posts that are in `boston`, then I would find a list of categories in which these posts are categorized. I want this list to be displayed on top of location page. Is there is a simple, built-in way to do all this?


title: Move Post to different category if post_meta field is 0 or is 2 days old?

text: Is it possible to move a post to an another category if post_meta field is 0 ?   I'm building a reverse order vote, every post have by default 10 votes and after a user vote, removes one vote by updating the post_meta, now i try to move the post to an another category if the votes field is 0 or 2 days old. I have found a solution here that moves a post to an another category if is a past date from this in the database.   It runs every hour to do the check               if (!wp_next_scheduled('sfn_expire_hook')){         wp_schedule_event( time(), 'hourly', 'sfn_expire_hook');     }          add_action( 'sfn_expire_hook', 'sfn_show_expire');     function sfn_show_expire(){         global $wpdb;         $server_time = date('mdy');         $result = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");         if( !empty($result)) foreach ($result as $a){             $show_time = get_the_time('mdy', $a->ID);             if ( $server_time > $show_time ){                $my_post = array();                $my_post['ID'] = $a->ID;                $my_post['post_status'] = 'draft';                wp_update_post( $my_post );             }         } // end foreach     }      can someone help me to extend this to check for 2 days old posts and if post_meta "votes" is "0" also? thanks a lot,   Philip


title: Relevanssi search not working in IE

text: I'm using Relevanssi 3.13 with WordPress 3.5 on my site, http://www.seiu32bj.org The search works fine in every browser but IE. It leads me to the search results page, with full search results When trying to search in IE, I just get kicked back to the homepage with /?s=&lang=en appended to the end of the link, so it looks like http://www.seiu32bj.org/?s=&lang=en Any idea what's causing the problem? Thanks David


title: Lost formatting after saving

text: I make basic formatting to the text in visual editor. When saving, everything got lost, formatting, spaces, paragraph.... everything got inline... I will go crazy !... why it's doing that ?.. i can make testing as request to gt out of this problem.. thanks in advance the DB and WP got reinstalled, and is hosted on hostpapa. I have others client on iweb and those work fine. I have no choice now, to make it work on hostpapa, the migration to iweb will be the LAST thing of last resort ! i am using qtranslate, wich can be the plugin the bug the editor


title: How to get category names in post_class?

text: I have this class for my posts:               <?php post_class( 'entry-image' ); ?>      I want to add the **category names** to get isotope work, i followed this guide http://www.acegoulet.com/2012/03/isotope-and-wordpress-how-i-did-it/ and i used this code to get category names:               $post_cats = get_the_category(); foreach( $post_cats as $category ) { echo $category->slug.' ';}      but this doesn't work. I tried to add a comma between the class and the category:               <?php post_class( 'entry-image', $post_cats = get_the_category(); foreach( $post_cats as $category ) { echo $category->slug.' ';} ); ?>      I checked the firebug but I don't see category name in loops (posts).   Why this doesn't work? Thank you for help!


title: Use a separate template for the home page only

text:
I use Pinboard theme (it has a very complicated structure, but it is nice). Image how it works Select a template in this way it changes for all posts, pages, etc. and do not give you more choice. I tried experimenting with index file but it is too confusing for me.               <?php get_header(); ?>     <?php if( is_home() && ! is_paged() ) : ?>         <?php if( pinboard_get_option( 'slider' ) ) : ?>             <?php get_template_part( 'slider' ); ?>         <?php endif; ?>         <?php get_sidebar( 'wide' ); ?>         <?php get_sidebar( 'boxes' ); ?>     <?php elseif( ( is_home() && is_paged() ) || ( ! is_home() && pinboard_get_option( 'location' ) ) ) : ?>         <?php pinboard_current_location(); ?>     <?php endif; ?>
         <section id="content" <?php pinboard_content_class(); ?>>             <?php if( is_category( pinboard_get_option( 'portfolio_cat' ) ) || ( is_category() && cat_is_ancestor_of( pinboard_get_option( 'portfolio_cat' ), get_queried_object() ) ) ) : ?>                 <?php pinboard_category_filter( pinboard_get_option( 'portfolio_cat' ) ); ?>             <?php endif; ?>             <?php if( have_posts() ) : ?>
                     <?php while( have_posts() ) : the_post(); ?>                         <?php get_template_part( 'content', get_post_format() ); ?>                     <?php endwhile; ?>
                 <?php pinboard_posts_nav(); ?>             <?php else : ?>                 <?php pinboard_404(); ?>             <?php endif; ?>
         <?php if( 'no-sidebars' != pinboard_get_option( 'layout' ) && 'full-width' != pinboard_get_option( 'layout' ) && ! is_category( pinboard_get_option( 'portfolio_cat' ) ) && ! ( is_category() && cat_is_ancestor_of( pinboard_get_option( 'portfolio_cat' ), get_queried_object() ) ) ) : ?>             <?php get_sidebar(); ?>         <?php endif; ?>

      I made front-page.php with the code from template-blog-full-width.php               <?php get_header(); ?>     <?php global $pinboard_page_template; ?>     <?php $pinboard_page_template = 'template-blog-full-width.php'; ?>     <?php if( pinboard_get_option( 'location' ) ) : ?>         <?php pinboard_current_location(); ?>     <?php endif; ?>

             <?php $args = array( 'posts_per_page' => get_option( 'posts_per_page' ), 'paged' => max( 1, get_query_var( 'paged' ) ) ); ?>             <?php if( pinboard_get_option( 'blog_exclude_portfolio' ) ) : ?>                 <?php $args['cat'] = '-' . pinboard_get_option( 'portfolio_cat' ); ?>             <?php endif; ?>             <?php global $wp_query, $wp_the_query; ?>             <?php $wp_query = new WP_Query( $args ); ?>             <?php if( $wp_query->have_posts() ) : ?>
                     <?php while( $wp_query->have_posts() ) : $wp_query->the_post(); ?>                         <?php get_template_part( 'content', get_post_format() ); ?>                     <?php endwhile; ?>
                 <?php pinboard_posts_nav(); ?>             <?php else : ?>                 <?php pinboard_404(); ?>             <?php endif; ?>             <?php wp_reset_postdata(); ?>             <?php $wp_query = $wp_the_query; ?>

      But it looks bad my site I would like to have a home page template: template-blog-full-width.php and the rest would be defined by the options. If anything is unclear, I'll try to explain.


title: Debugging an error: wp_enqueue_style was called incorrectly

text: I've just uploaded a new, custom theme to find that the container is a fraction of the intended width, and the sections below the home section(this is one single page, long site utilizing ids/anchors to navigate) are no longer showing. I turned on DEBUG to see if I could spot the problem, and after deactivating problematic plugins, I'm left with this error: > Notice: `wp_enqueue_style` was called incorrectly. Scripts and styles should > not be registered or enqueued until the `wp_enqueue_scripts`, > `admin_enqueue_scripts`, or init hooks. Please see Debugging in WordPress > for more information. (This message was added in version 3.3.) in > `/home/achenn/public_html/frshstudio.com/wp-includes/functions.php` on line > 2959 Problem is, the only thing on that particular line is:               trigger_error( sprintf( __( '%1$s was called incorrectly. %2$s %3$s' ), $function, $message, $version ) );      I've seen other blog posts and forums, but the line they are telling me to search for is non-existent in this file, much less on the given line. Any tips, ideas, etc on how to remedy this challenge are greatly appreciated. ![phrase in question is not in file](http://i.stack.imgur.com/6o3gK.png) Live site.


title: Image size filtering in Media uploader according to custom post type

text: I have three different custom post types which require an image upload in the admin post edit page. Each type has its own image size setting. Let's say:   * 'news' type => picture size required: 700x320px    * 'work' type => picture size required: 700x430px    * 'press' type => picture size required: 460x600px I succeeded in removing the default image size settings and in adding these 3 new ones in the Media Uploader but I don't need them to be displayed as radio buttons at all as I don't want the users to select anything regarding the sizes when uploading pictures. What I would like instead is to get the Media Uploader to set the accurate image size setting right away according to the custom type of the actual post, with no user intervention whatsoever. Is this possible? I tried to query the post_type from within the Media Uploader Iframe but it gives me at best the "attachment" post type (which makes sense as it is the post type of the picture it's trying to upload) while I try to get the custom type of the post I'm about to publish. And if I can't get the custom type of the post, I can't see how I can get the Media Uploader to set the size accordingly. I just don't know how to make it work. Any help would be appreciated. Here is my script so far:               function media_image_delete_sizes($sizes)      {         unset($sizes['thumbnail']);         unset($sizes['medium']);         unset($sizes['large']);              return $sizes;     }     add_filter('image_size_names_choose', 'media_image_delete_sizes');          add_image_size( 'news-size' , 700, 320,true);     add_image_size( 'work-size' , 700, 430,true);     add_image_size( 'press-size', 460, 600,true);          function media_image_add_sizes($sizes)      {         // I would like not to show any of these new image sizes          // (I will probably hide them via css or jQuery)             $addsizes = array(             "news-size"  => "News  (700x320)",             "work-size"  => "Works (700x430)",             "press-size" => "Press (460x600)"         );         $newsizes = array_merge($sizes, $addsizes);              return $newsizes;     }     add_filter('image_size_names_choose', 'media_image_add_sizes');               function theme_default_image_size()      {                //This variable will retrieve the post_type of the picture post, not the one of the          //underlying CPT post         global $post_type;              // Here is the place where I tried to place the conditional return         // but I just can't succeed in retrieving the CPT post_type as I always get "attachment".              if     ($post_type == "news" ){ return 'news-size';}         elseif ($post_type == "work" ){ return 'work-size';}         elseif ($post_type == "press"){ return 'press-size';}         else                          { return 'this-doesnt-work';};     }     add_filter( 'pre_option_image_default_size', 'theme_default_image_size' );      Thank you.


title: Add_rewrite_rule doesn't seem to work?

text: I am trying to get my two custom post types to work properly. Let's say the two Custom Post Types (CPT) are books and reviews. now i like               mydomain.com/books/the-great-gatsby/reviews/33      to show all the reviews for book the great gatsby. In general `mydomain.com/books/{title-book}/reviews/{book_id}` I have made bought CPT's and i have a two page templates (page-books.php and page-reviews.php). Page-books.php works as expected for page-reviews.php i am testing with a hardcoded $book_id and this works. But i need to make page- reviews.php dynamic. In my local setup page-reviews.php has a page_id=227. I am putting               echo 'Book id '.$_REQUEST['book_id'];      in page-reviews.php for testing purpose so i tried               add_rewrite_rule('^books/([^/]*)/reviews/([^/]*)/?','index.php?page_id=227&book_id=$matches[2]','top');      but i get a 404 page. Any tips?


title: Exclude specific terms from all queries using posts_where or something similar

text: Basically what I'm trying to do is exclude all posts that belong to a specific set of terms from showing in any and all queries across the board, EXCEPT when you're actually viewing that post or page. Basically like how YouTube's "unlisted" feature works with videos. I'm wondering what the best way to go about this would be. Below is what I'm using currently, though I feel like this could probably be improved on performance-wise (SQL isn't my strongest suit).               add_filter( 'posts_where', 'exclude_terms_posts_where' );     function exclude_terms_posts_where( $clause = '' ) {         global $wpdb;              // Returns an array of term IDs to exclude from         $excluded_terms = get_excluded_terms();              if ( empty( $excluded_terms ) ) {             return $clause;         }              // Filter out the current page / post         if ( false !== ( $key = array_search( $post->ID, $excluded_terms ) ) ) {             unset( $excluded_terms[$key] );         }              $excluded_terms = implode( ',', $excluded_terms );         $clause .= "             AND {$wpdb->posts}.ID NOT IN (                 SELECT {$wpdb->posts}.ID FROM {$wpdb->posts}                 INNER JOIN {$wpdb->term_relationships} ON (                     {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id                 )                 INNER JOIN $wpdb->term_taxonomy ON (                     {$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id                     AND {$wpdb->term_taxonomy}.taxonomy = 'placement'                     AND {$wpdb->term_taxonomy}.term_id IN ( {$excluded_terms} )                 )             )         ";              return $clause;     }      If anyone has any ideas or suggestions I'd greatly appreciate it. Thanks!


title: How can I add a class to a single menu item?

text: I'm trying to modify a non-WP theme to be compatible with my newest WP project, and one of the issues is a drop-down menu item. Since it's a totally custom theme, I want to replicate the behavior of this template 1:1, I require that the "Categories" nav menu item have the class "dropdown" included in it. I could use JavaScript to catch the ID and put a class name on it, but what if the ID changes later on? Using PHP, how can I insert the class on a single menu item? Thanks.


title: How to add a checkbox inside the "Publish post" widget?

text: I'm building post to email plugin and I need to add a checkbox to the publish post widget like this one: ![enter image description here](http://i.stack.imgur.com/xB8t2.png) My idea is to add a checkbox that says "Send this by email", and get that info inside the publish_post listener:               add_action('publish_post', function($post_id) {          // Was the checkbox checked?     }      How can this be done?


title: Archive comment w/o moving to spam/trash

text: How can I archive a comment so that it doesn't appear new, without moving it to spam or trash? The comment is interesting, so I want to keep it for myself, but not approve it.


title: How to optimize multiple WP_Query() calls on one page?

text: The current site I'm building has a homepage that is going to have around 10 instances of WP_Query(). Some of them are going to pull a series of posts, while others are targeted at one single post based on ID number. How should I optimize page load speeds when dealing with this many instances of WP_Query()? Is using a caching plugin enough? Is there something else I should be doing in addition? Or should I not even worry about it because 10 database queries will not result in a significant performance decrease?


title: Checking whether post is deleted or saved in edit_post

text: When deleting a custom post type, the function hooked to `edit_post` is fired. How can I check if the post is being deleted?


title: Can I use traits? Or will I cut out a large portion of the community?

text: If I restrict my theme framework to 5.4+ (min 5.4) php how much of the average community am I cutting out? All just so I can use traits to help with some inheritance issues I ran into in this question I asked. I am concerned that if I take the trait approach, close to 70% or higher of the community will be cut out. As most free hosting sites or "shared hosting" do not upgrade their php on a "omg 5.5.x is out lets upgrade" basis.


title: wp_enqueue_style in WordPress plugin class not working

text:
I'm trying to add a stylesheet for my plugin class settings page, but the CSS is not loading. I followed the 2nd example at http://codex.wordpress.org/Function_Reference/wp_register_style to create this simple test code :               class MyTestPlugin     {         public function __construct()          {                 add_action('admin_menu', array($this, 'add_menu'));                 add_action( 'wp_enqueue_scripts', array($this, 'register_plugin_styles' ));         }         public function register_plugin_styles() {                 wp_register_style( 'my-test-plugin', plugins_url('sbm-test.css', __FILE__) );                 wp_enqueue_style('my-test-plugin');         }         public function add_menu()         {                 add_options_page('SBM Test Settings', 'SBM Test', 'manage_options', 'sbm-test', array($this, 'sbm_test_options'));         }         public function sbm_test_options()         {                 echo "
SBM Test Options Page.
";                  echo "
" .  plugins_url('sbm-test.css', __FILE__) . " is not loaded.
";         }     }          if(class_exists('MyTestPlugin'))     {         $test = new MyTestPlugin();     }      The path to `sbm-test.css` is correct, but I think the function `register_plugin_styles` isn't being called. I have `WP_DEBUG_LOG` `true` but not seeing any errors in the log. I'm not sure why add_action isn't hooking it in so I'm hoping someone sees something I missed.


title: Can not manually change the permalink of a post in the EDIT secion

text: I have my site using a custom permalink structure, specifically category/post. Recently I noticed, once in the actual edit page interface I was unable to use the "EDIT" feature for the permalinks (i.e. the ones that are displayed under the post title.) I logged in using a different browser and it worked the first time I hit edit, then after that it stopped again. I am wondering if this is a JavaScript issue? Maybe a plugin problem? I can not edit the date option either on the top right either. Anybody have this issue?


title: How do I query by post format in WordPress 3.1

text:
I am trying to query for all posts with a post format of 'quote.' I have added the post formats to my functions.php with               add_theme_support( 'post-formats', array( 'image', 'video', 'gallery', 'quote' ) );      I have selected 'quote' as the format for the post in the admin. The last example under Taxonomy_Parameters shows how to display posts that have the 'quote' format but when I run it in my theme no posts are returned. Here is the code:               $args = array(       'tax_query' => array(         array(           'taxonomy' => 'post-format',           'field' => 'slug',           'terms' => 'post-format-quote'         )       )     );     query_posts( $args );      When I just query all posts and place               echo get_post_format();      in the loop it returns the word 'quote' on the front-end. Also, when I var_dump() the query I do not see anything in the array about post format. Does anyone know if it is possible to query by post format? If so how? EDIT - See 5 comment under Bainternet's answer: This is the code found on index.php of the twentyten theme of a fresh install trying to return format type quotes. I return 'no' instead of 'quote'. Can you see anything that I should change.               get_header(); ?>

         <?php $args = array(           'tax_query' => array(             array(               'taxonomy' => 'post-format',               'field' => 'slug',               'terms' => array('quote')             )           )         );         query_posts( $args );         if ( have_posts() ) : while ( have_posts() ) : the_post();           echo get_post_format();         endwhile; else:           echo 'no';         endif;         wp_reset_query();               ?>

     <?php get_sidebar(); ?>     <?php get_footer(); ?>      EDIT 2 - It appears that the WordPress Codex has now changed and the portion on Taxonomy Parameters is only found in Google cache. EDIT 3 - FINAL WORKING CODE               $args = array(       'tax_query' => array(         array(           'taxonomy' => 'post_format',           'field' => 'slug',           'terms' => 'post-format-quote'         )       )     );     query_posts( $args );      The twenty-ten edit form the first edit will be...               get_header(); ?>

         <?php $args = array(           'tax_query' => array(             array(               'taxonomy' => 'post_format',               'field'    => 'slug',               'terms'    => 'post-format-quote'             )           )         );         query_posts( $args );         if ( have_posts() ) : while ( have_posts() ) : the_post();           the_title();           echo get_post_format();           echo '
';         endwhile; else:           echo 'no';         endif;         wp_reset_query();               ?>

     <?php get_sidebar(); ?>     <?php get_footer(); ?>


title: How to get and edit custom fields if in Quick Edit

text: I've got some custom fields that I would like a user to be able to edit in Quick Edit, I can manage the columns but I'm unable to edit them if Quick Edit is clicked current code with custom fields I'd like to be able to edit:               /* custom columns */     add_filter("manage_edit-programmes_columns", "edit_columns" );     add_action("manage_posts_custom_column", "custom_columns");          function edit_columns($columns)     {         $columns = array(             "cb" => "<input type ='checkbox' />",             "title" => "Schedule id",             "programme" => "Programme",             "channel" => "Channel",              "onair" => "On Air",              "catchup" => "Catchup",              "popularity" => "Popularity",              "onair" => "On Air",              "date" => "Date"         );         return $columns;     }          function custom_columns( $column ) {              global $post;              switch ( $column )         {             case "programme":                 echo get_post_meta($post->ID, 'Programme Name', true);                 break;             case "channel":                 echo get_the_term_list($post->ID, 'channelnames', '', ', ', '');                 break;             case "onair":                 echo get_post_meta($post->ID, 'Date Time Start', true);                 break;             case "catchup":                 echo get_post_meta($post->ID, 'linktovideocatchup', true);                 break;             case "popularity":                 echo get_post_meta($post->ID, 'popularityfig', true);                 break;         }     }      Help very much appreciated.


title: Use wpdb->prepare for `order by` column name

text: In my current plugin, I am picking up the `order by` column as user input. So I thought of using `wpdb->prepare` to escape it.               $wpdb->get_results($wpdb->prepare("Select id from $wpdb->posts order by %s %s", $order_by_col, $order_by);      This is not working because it gets turned into               select id from wp_posts order by 'post_date' 'asc'      (Note the quotes) So is there way to remove the quotes? Also is this a proper way to use $wpdb->prepare()? Should I manually escape it myself?


title: How to change the structure of an image attachment in a post?

text: I'm trying to solve a problem with the attached images in a post. Somehow the structure is not working right on a theme i'm using. Instead of showing a div with the class "wp_attachment" is just a h6 tag with the img tag inside containing the image I want. maybe the attachment filter is broken? can somebody post the default attachment filter so I can add it to my functions.php? Thanks!!


title: ol children instead of ul children

text:
I've created a new walker class to display a custom layout when using the `wp_list_comments();` function and this is perfect, the only thing is that all replies to one comment are listed in a `<ul>` - `<ul class="children">`. I would like these to be in an `<ol>` bracket. Is there any way to change this using something like `start_lvl`? Heres my walker class - `<?php wp_list_comments('type=comment&callback=letsfixit_comment'); ?>`               function heres_my_comment($comment, $args, $depth) {             $GLOBALS['comment'] = $comment;             extract($args, EXTR_SKIP);          ?>
              <div class="oneComment" id="div-comment-<?php comment_ID() ?>">
             <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
             <?php printf(__('%s says:'), get_comment_author_link()) ?>             <?php /* translators: 1: date, 2: time */ printf( __('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),'  ','' );?>             <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>                  <?php if ($comment->comment_approved == '0') : ?>             <?php _e('Your comment is awaiting moderation.') ?>
             <?php endif; ?>
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">
                  <?php comment_text() ?>

     <?php             }


title: add new metabox to page editor with just page parent

text: I run a multisite install and I have removed the page attributes meta box from view for my users because I don't want them to be able to change templates. I would like them to be able to change the page parent though. I need to add a new meta box for pages that adds just the page parent selector back.


title: How to ensure "the_content" filter runs only for the main displayed content?

text: I have a plugin which adds the method to "the_content" filter. `add_filter('the_content', 'myFilteringFunction', 10000);` Within that function I want to add some links on the beginning and the end of the content. But I only need to do it for the "main" content of the displayed page so - not in the any of the widgets, not in the footer, header etc. Moreover I only want it to be included for the custom post type which I defined in the same plugin. So I figured out that kind of check, thinking it would be enough.               if( is_single() && get_query_var('post_type') == 'myCustomPostType' && is_main_query() )      Unfortunately it's not working as intended - at least not in every case. On the page the plugin WP Types is installed, it's not working (the links are added despite the condition). Why?


title: Woocommerce: change user role after completing order

text: :) I'm using wordpress with woocommerce, and I would like to automate the following step. When an order is completed, I would like to change the user role associated with that order id from 'customer' to 'subscriber'.    By searching around, I think I should be able to accomplish this by using a hook in functions.php:               add_action( 'woocommerce_order_status_completed', 'change_role_from_customer_to_subscriber' );      Then add the function:               function change_role_from_customer_to_subscriber($order_id){     // code to change role to subscriber     }      In the code, I think I need to do 2 things: 1) get the user id that is associated with that order id 2) change role of that user id to subscriber    I've tried a lot, but I couldn't get it to work (neither getting the right user id, nor changing the role of a user id). So any help would be appreciated! I've seen 2 related questions asked before on stack overflow, but unfortunately the answers there did not work for me. I hope someone can help me out! Thanks a lot! :)       Edit: Someone helped me out with the second part of the problem, so that's great news for me :) Unfortunately, I still haven't figured out the first part: how to get the user id that is associated with the order id. Any ideas?


title: Creating Custom user type just like custom post

text: Any method for creating custom user types just like custom post. am trying to achieve 2 different set of users with different user_meta fields.


title: Authorize users for specific pages and/or categories

text: I am managing a Wordpress website for a local sports club, the navigation is something like this:   * home   * division      * archery     * soccer        * youth       * senior     * volleyball   * ... I want to enable the people in charge of a division to edit the content of their divisions page and subpages (e.g. person responsible for soccer can change the pages soccer, soccer-youth and soccer-senior), but not the pages for other divisions. Is this possible with out of the box functionality? Or is there an extension I need? Bonus question: These users can write blog posts, too ... can I block some of the categories, so they don't see/can't choose them for their blog posts?


title: Imported thumbnails have incorrect URL

text: I have an older WordPress site that is going away but I am taking the content from the site and importing it into my new WordPress site. To do this, I used the WordPress Export tool, located in my dashboard, to create an export file that included all content, including images. The export process created the export file, which I successfully imported into my other WordPress site. I noticed that if an imported post that resulted from a search or linked in the sidebar had a thumbnail, the URL linked to that thumbnail linked back to the original WordPress site - The site were I created the export file. How do I fix this?


title: Control Users listed in Users List on dashboard

text: I have a user role "author" with a modified capability to add users and give them the role of subscriber. I'm trying to edit the Users List on the dashboard to display only the subscribers created by that user. I took a stab at implementing code from this article, but was unsuccessful. Remove Ability for Other Users to View Administrator in User List? Can someone point me in the right direction?


title: Large Woocommerce Site (83,000 items), What Can I Do?

text: So I have a really large woocommerce site (partsboss.co) that has around 83,000 items. It's on VPS hosting with digitalocean, and things were running super fast until around 50,000 items. Now the site is just draaaaaaaaaging. It's set up on Ubuntu with nginx, APC and Varnish caching. I'm not really sure where the bottle neck is or how to fix it, but as far as I can tell it's basically taking forever to query the mysql database and return results. So my question is, do I need to just optimize mysql more (if so, how? Not really a mysql expert) or do I need to split the database with something like Hyperdb? Again, if that's the case, I read the readme for Hyperdb and it wasn't too explicit... if you know of any good tutorials, throw them my way :) Any help would be much appreciated, thanks!


title: Wordpress 3.5 install error

text: Im trying to install the wordpress on my root folder but i got this message when i try to enter on url.               PHP Warning:  require(./wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in E:\home\businessinfo\web\index.php on line 17     PHP Fatal error:  require() [function.require]: Failed opening required './wp-blog-header.php' (include_path='.;c:\php5\includes') in E:\home\businessinfo\web\index.php on line 17      What is that?


title: array_replace throwing php_warning but working anyway

text: Hello I have a question which is maybe more PHP question than WordPress, but could be interesting in a WordPress context in case someone wants to add properties to an WP object. I have created a custom taxonomy and I'm using an option to add order to each terms. To get that order in my theme, i use those two functions : the first one retrieve the terms, and then they get ordered :                   // SORT BY ORDER          function cmp( $a, $b ) {              if(  $a->order ==  $b->order ){ return 0 ; }              return ($a->order < $b->order ) ? -1 : 1;         }               // FUNCTION TO INJECT ORDER ITEM IN TERM OBJECT         function inject_order( $term_objects ) {             if ( $term_objects ) {                 foreach ( $term_objects as $term_object ) {                     $term_id = $term_object->term_id;                     $term_order  = get_option( "taxonomy_term_$term_id" )['tax_order_nb'];                     $term_object->order = $term_order;                     array_replace( $term_objects, $term_object );                 }                 return $term_objects;             } else {                 return false;             }         }              // FUNCTION TO GET CHILDREN TERMS AND ORDER THEM         function get_children_and_order_terms( $term_id = '0' ) {             $term_children = get_terms( 'category_effectif', array( 'parent' => $term_id, 'hide_empty' => 0 ) );             if ( $term_children ) {                 $term_children = inject_order( $term_children );                  usort ( $term_children, 'cmp' );                 return $term_children;             }         }      It's working perfectly, but I have a PHP_Warning `array_replace(): Argument #2 is not an array` I would like to correct that error and make it better.


title: Issue with using .htaccess to redirect feedburner feed

text: I am using year/month/post-name permalinks, and also using the download- monitor plugin to handle file downloads. I added rewrite rules to the top of the .htaccess file following the instructions at perishable press. I just did this same thing at another blog and it worked just fine. The only differences are that blog did not use the download-monitor and the install was in the root of the domain, instead of a `/blog/` sub-directory. If I comment out this line:               RewriteCond %{REQUEST_URI} ^/?feed.* [NC]      It works. I am simply curious as to why would this line be in the instructions if it doesn't work? Does it have something to do with the sub-directory? **.htaccess:**               # temp redirect all wordpress feeds to feedburner     # from http://perishablepress.com/press/2008/03/25/redirect-wordpress-feeds-to-feedburner-via-htaccess-redux/     <IfModule mod_rewrite.c>     RewriteEngine on     RewriteBase /blog/     RewriteCond %{REQUEST_URI} ^/?feed.* [NC]     RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC]      RewriteRule ^feed/?.*$ http://feeds.feedburner.com/mysite [L,NC,R=302]     </IfModule>          # BEGIN WordPress          <IfModule mod_rewrite.c>     RewriteEngine on     RewriteBase /blog/     RewriteRule ^download/([^/]+)$ http://www.mysite.com/blog/wp-content/plugins/download-monitor/download.php?id=$1 [L]     </IfModule>          <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /blog/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /blog/index.php [L]     </IfModule>          # END WordPress


title: Do New_to_publish hooks work for custom post types

text: Do these hooks listed on the following site work for custom post types? http://www.wphub.com/custom-post-type-publish-action-hook/                   // function to be executed when a custom post type is published         function run_when_post_published()         {             // your function code here         }              // replace {custom_post_type_name} with the name of your post type         add_action('new_to_publish_{custom_post_type_name}', 'run_when_post_published');                 add_action('draft_to_publish_{custom_post_type_name}', 'run_when_post_published');               add_action('pending_to_publish_{custom_post_type_name}', 'run_when_post_published');      I cannot get them to work...


title: How to gather all the pages associated with a template on a register post type?

text: I am creating a menu in the admin of wordpress, I have pages that are catalogs on two user images load; example I have the catalog A where user pictures load and price of a product a catalog B where the same images and prices of products now and so I can keep adding N catalogs. These I made with advanced custom fields, a repeater, all these catalogs are associated with a page template where the title of the catalog is loaded and pictures and have that catalog prices. What I need to do is gather all the pages created as catalogs and who are associated with the 'template of catalogs' and put them into a 'post type' admin menu ![enter image description here](http://i.stack.imgur.com/QKQvf.png)


title: Custom query on Wordpress custom table

text: I am working with a custom table where some values will be inserted or updated if they already exists, I have checked and rechecked the syntax and it seems to be working fine, if I run the same query directly to the MySQL server it inserts just fine or updates when the records exist. My query is this               $query = "INSERT INTO `{$wpdb->base_prefix}apicalls` (`name`, `data`)      VALUES ('appid','{$appid}')     ON DUPLICATE KEY     UPDATE `data` = '{$appid}';";      Then I have tried               $wpdb->get_results($wpdb->prepare($query));     $wpdb->query($wpdb->prepare($query));      that is not inserting the records, however if I run only the insert statement it inserts fine, I have checked the methods at http://codex.wordpress.org/Class_Reference/wpdb and it does have an insert and also update one, but I could not find one that does both, it does not make sense to me to run two queries when one should suffice. Am I running the query in a way that wordpress does not support? Is there a wordpress document that I can read in regards to this? I have searched but the only two pages I could find were related to posts or if custom queries only to either insert or update, also when doing a google search many people have already asked for custom queries but I couldn't find any with this conditions. And I was under the assumption that `$wpdb->query()` should just run the query but for some reason is not going through as if there was a syntax error. I will keep on testing by modifying the query **Update** : I forgot to add a `var_dump($query)`               string(107) "INSERT INTO `wp_apicalls` (`name`, `data`) VALUES ('appid','12345') ON DUPLICATE KEY UPDATE data = '12345'";      The database prefix is `wp_` and the table exists with that exact name in the database.


title: Why does save_post action fire when creating a new post?

text:
I'm surprised by the fact that my function that I've tacked onto the `save_post` action fires when I click the "New Post" link in the Admin Dashboard. Note - this is before I've pressed `Save` or `Update`, and it fires immediately, not after an elapsed time or auto-update. On the other hand, when I then type in something and press the `Publish` or `Update` or `Save Draft` buttons, the echo statement I've put inside my action handler does not echo out, so it appears that the action is NOT firing at any other time. This may be unrelated. Here's my code:               add_action('save_post', 'MyNS\save_event_metabox', 10, 2);     function save_event_metabox($post_id, $post){       echo "
YES!
";     }      This YES echoes (at the top of the page) when I press the "New Post" link but does NOT echo when I type something and then press `Update` or `Publish` or `Save Draft`. This seems to contradict the documentation on the `save_post` action and the `wp_insert_post()` function. Can anyone clear this up for me?


title: Plugin init hook

text: Is there a plugin init hook that runs whenever the plugin is being loaded? I'd like to link the functions for requiring files and defining constants to such a hook if it exists.


title: Export all posts to import as product items

text: Up until now, my client has been using WordPress posts as his way to display his products. I now need to export all these posts into a CSV format so that I can format the CSV file and import it back into WP e-Commerce. I've looked at number of options including plugins to export the posts, exporting directly from phpMyAdmin and using the XML export option within WP but none is coming out as clean as I would like it. I think I basically need an SQL query that I can run to export only the information from the POSTS table, excluding any other rubbish such as ID numbers, ping status, guid etc. All I need is:   * Post Title   * Post Content   * Custom Fields   * Categories Here's the start of my Query                SELECT *       FROM  `wp_posts`       WHERE  `post_status` =  'publish'      **EDIT:** I am open to better solutions if anyone thinks there is a better way to do this? **EDIT** Here's a solution I found on SO but I am not sure where to use this?               <?php         function array2xml($array, $name='array', $standalone=TRUE, $beginning=TRUE)         {         global $nested;              if ($beginning)         {         if ($standalone) header("content-type:text/xml;charset=utf-8");         $output .= '<'.'?'.'xml version="1.0" encoding="UTF-8"'.'?'.'>' . PHP_EOL;         $output .= '<' . $name . '>' . PHP_EOL;         $nested = 0;         }              // This is required because XML standards do not allow a tag to start with a number or symbol, you can change this value to whatever you like:         $ArrayNumberPrefix = 'ARRAY_NUMBER_';              foreach ($array as $root=>$child)         {         if (is_array($child))         {         $output .= str_repeat(" ", (2 * $nested)) . '  <' . (is_string($root) ? $root : $ArrayNumberPrefix . $root) . '>' . PHP_EOL;         $nested++;         $output .= array2xml($child,NULL,NULL,FALSE);         $nested--;         $output .= str_repeat(" ", (2 * $nested)) . '  </' . (is_string($root) ? $root : $ArrayNumberPrefix . $root) . '>' . PHP_EOL;         }         else         {         $output .= str_repeat(" ", (2 * $nested)) . '  <' . (is_string($root) ? $root : $ArrayNumberPrefix . $root) . '><![CDATA[' . $child . ']]></' . (is_string($root) ? $root : $ArrayNumberPrefix . $root) . '>' . PHP_EOL;         }         }              if ($beginning)         $output .= '</' . $name . '>';              return $output;         }              //connect to database and select database (edit yourself)         mysql_connect("localhost", "username", "password");         mysql_select_db("databasename");              //Get all posts whose status us published.         $result = mysql_query("SELECT * FROM wp_posts WHERE post_status = 'publish'");         while($row = mysql_fetch_assoc($result))         $posts[] = $row;              //convert to array and print it on screen:         echo "<pre>";         echo htmlentities(array2xml($posts, 'posts', false));         echo "</pre>";     ?>      **EDIT:** Right, so I created a php file called pull-posts.php and dropped the above code into the file then saved the file in the root of my localhost installation. I then changed the DB details and ran the script. Here's the error I am getting: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in C:\inetpub\wwwroot\Xampp-1.7.7\htdocs\project\pull-posts.php on line 40 Line 40 has this on it: mysql_connect("localhost", "root", ""); mysql_select_db("DBName"); Any thoughts? Thanks.


title: Display specific WooCommerce products to different types of users

text: I'm creating an internal-use "Dealer Club" using WooCommerce. It will be accessible by our external dealers as well as internal salespeople and admin types. How do I show select products based on the different types of users (dealers, salespeople, other internal, etc.) and different geographic areas that the individual users service (East, West, all areas)? The idea that I have so far....   * Create the types of users and geographic areas using Cimy Extra User Fields plugin.   * Tag each product appropriately (type and area).   * Create a page for each product category that somehow queries only products with the correct tags to the users that match the "extra user fields". So only Eastern Salespeople would see items with tags "east" and "salespeople", for example.   * The problems I see are how to queries the products based on tags, how to use the Cimy Extra User Fields to determine the classification of the user, and how to deal with hierarchy issues (users marked as Salespeople should be able to see all Dealer products as well). However, if there is a "canned" solution that handles displaying certain products to certain groups, I'm all ears. Thanks for suggestions!


title: AZ Directory posts directory index

text: I would like to create an A to Z index of posts in a certain category. This must include a linkable directory of letters ABCDEF .... etc and a list of articles ordered by title grouped by letter. for example               A      A first article      A second article          B      B first article     B Second aericle           C      when some one clicks on the index (ABCDE .....) link him to the letter group.... Any ideas?


title: Custom Author Fields + Existing Taxonomy - Integrating the Two Dynamically?

text:
I am trying to integrate both the values from an existing custom taxonomy and custom author profile fields. I would like the values to be used as the options from which an author can select when updating/filling out her profile. The below works - kind of. (Found in functions.php file) It saves to the database (users table) but it the "checked" radio does not save. It also does not print properly in the profile section, and looks like this (immediately preceding the radio button) `checked="checked" />` ... Here is the full code
     <?php _e('What sorority are you in?'); ?>	                      <?php $sorority = get_the_author_meta( 'sorority', $user->ID ); ?>             <?php                  $terms = get_terms("sorority");                  $count = count($terms);                  echo '
';                         foreach ( $terms as $term ) {                                echo '
<input type="radio" value="' . esc_attr( $term->name ) . '" name="sorority" <?php if ($sorority == "' . esc_attr( $term->name ) . '") { ?>checked="checked"<?php }?> />'.$term->name.'
';                  }                  echo "
";                 ?>
      Any thoughts? I believe the problem is something with this line:                <?php if ($sorority == "' . esc_attr( $term->name ) . '") { ?>checked="checked"<?php }?>


title: finding whether request is for post, and post id

text: I need a hook such that when visitor lands on any of the post **(not page)** , I need to record a hit. How can I find whether the request is for post, and is there any hook to find if the loaded content is post, and if yes, what is post id


title: wp_redirect not working after submitting form

text: I'm using this redirect after inserting a post. It's not working, it only refreshes the page the form is on. I know the $pid is getting the post ID so what is the problem? This is the very end of my php code for handling the form submission.               $pid = wp_insert_post($new_post);          update_post_meta($pid,'domain',$domain);     update_post_meta($pid,'keywords',$keywords);          wp_redirect( get_permalink($pid) );     exit();      Here is a pastebin of the complete code Using Better HTTP Redirects it's output is, and it links the word `here` to the correct newly published post.               302 Found     The document has moved here.


title: Slide Menu not working?

text: How can i use this Slide Menu in my wordpress website. Only i need Right Side menu from all.here i paste what i tried.                       var menuRight = document.getElementById( 'cbp-spmenu-s2' ),                  body = document.body;                  showRight.onclick = function() {                 classie.toggle( this, 'active' );                 classie.toggle( menuRight, 'cbp-spmenu-open' );                 disableOther( 'showRight' );             };                      if( button !== 'showRight' ) {                     classie.toggle( showRight, 'disabled' );                 }                  }         </script>


title: Div around YouTube video

text:
My posts have YouTube embedded videos in the form of:               <object width="600" height="400" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/zN9mdItmoBs&vq=hd720" /><embed width="600" height="400" type="application/x-shockwave-flash" src="http://www.youtube.com/v/zN9mdItmoBs&vq=hd720" /></object>      How do I wrap a `<div>` around it? I've tried adding the following to the `functions.php` file:               add_filter('embed_oembed_html', 'my_embed_oembed_html', 99, 4);     function my_embed_oembed_html($html, $url, $attr, $post_id) {       return '
' . $html . '
';     }      It doesn't work. What do I do?


title: Search with filters and title

text: I would like to search in `custom_post` by title and by the ACF fields. So, I used the `WP_Query` WordPress function but I can't filter by the title, just by the filters. When I submit my form, I have this kind of URL:               http://example.com/?s=titre&filter1=condition1&filter2=condition2&filter3=condition3      My code:               $title = $_GET['s'];     $args = array(         'pagename' => $title,         'numberposts' => -1,         'post_type' => 'my_custom_post',         'meta_query' => array(             array(                 'key' => 'filter_1',                 'value' => $_GET['condition_1']             ),             array(                 'key' => 'filter_2',                 'value' => $_GET['condition_2']             ),             array(                 'key' => 'filter_3',                 'value' => $_GET['condition_3']             )         )     );     $the_query = new WP_Query($args);      Do you have any idea to include the title in the search ?


title: $wpdb->num_rows doesn't work

text: I'm trying to perform some checks on custom fields before they are saved on a db. So I decided to use an add_filter as it does this between browser and db. Here is my code               function fields_pre_check($post_id){          $errors = false;     $values = get_post_custom(get_the_ID());     $act_val = $_POST['checks_news'];      ...altri checks...               if(get_check_key($post_id, $act_val , $values)){                          $errors = true;         update_option('custom_token', $errors);         update_option('custom_admin_errors', $txt_err=error_text($errors, 2));              remove_action('save_post','update_fields');         wp_update_post(array('ID' => get_the_ID(), 'post_status' => 'draft'));         add_action('save_post', 'update_fields');              return false;     }     }     function update_fields($post_id){     $chk1 = $_POST['checks_news'];     update_post_meta($post_id, 'checks_news', $chk1);     }     function get_check_key($post, $checker, $val){     global $wpdb;     $wpdb->query("SELECT meta_value, meta_key                  FROM $wpdb->wp_postmeta                  WHERE meta_value = $checker");     if(get_post(get_the_ID())==NULL){              return ($wpdb->num_rows != 0);     }     else{         if($val['checks_news'][0] == $checker)             return false;         else{             return ($wpdb->num_rows != 0);         }     }     }     add_filter('wp_insert_post_data', 'fields_pre_check');     add_action('save_post', 'update_fields');      I choose add_filter because the function get_check_key has to verify the previous value $val['checks_news'][0] with the new one $checker( if I use add_action, which i tried, they are the same because $val['checks_news'][0] retrieves the value just saved so if wanna change that value from 1 to 2 and perform the check it returns 2 == 2). The problem comes when I want to use $wpdb->num_rows which returns always 0 even if the result should be 1. What am i doing wrong? Did I take the right way using add_filter instead of add_action?


title: Wordpress + Thesis Theme => WPTouch Post Thumbnails don't work?

text: Has anyone managed to get this combination to work and display post thumbnails on the mobile site?   * Wordpress 3.3.1   * Thesis Theme 1.8.3   * WPTouch 1.9.38 I've activated Thesis support for Post Thumbnails:               add_theme_support('post-thumbnails');     set_post_thumbnail_size( 96, 96, true );      I know the thumbnails are created, I can see them on the main site. Any idea why WPTouch is not picking these up and instead displaying a default "camera" icon? The site I'm testing this with is: http://fitness9000.com


title: Why is custom template not seen as page with is_page()?

text:
I created a couple of templates for a project, which is in fact a child theme of the Contrast theme. In the Wordpress CMS, I can select the templates I created: http://i.imgur.com/PYKqK.png (Can't post image, I'm too much of a newbie the site says...) In one of the functions of the theme (see background.php below), there is this check for conditions:               <?php if (is_page() || is_single()) { ?>      Which works on all my custom templates but two. I know for a fact that the two places where this fails are actually pages, but the value returned by `is_page()` is still empty, thus `false`. What should I look for in order to make sure these two templates are taken as pages? Or is it something else that I should look for? Below is the code for two templates. Keep in mind that I only touched the code relative to the content, not the if/elses at the beginning of the templates. At the bottom of the page is included a file that makes that check for the `is_page()`. Code for that file below as well. Textual Content Template (functional, returns a value for `is_page()`):               <?php     /*     Template Name: Textual Content Page     */     ?>          <?php get_header(); ?>              <?php             // transparent_layer             if(meta(array('id' => $post -> ID, 'meta' => 'transparent_layer')) == '0')             {                 if(option('transparent_layer') == '0')                 {                     $transparent = false;                 }                 elseif(option('transparent_layer') == '1')                 {                     $transparent = true;                 }             }             elseif(meta(array('id' => $post -> ID, 'meta' => 'transparent_layer')) == '1')             {                 $transparent = false;             }             elseif(meta(array('id' => $post -> ID, 'meta' => 'transparent_layer')) == '2')             {                 $transparent = true;             }                       // content_position             if(meta(array('id' => $post -> ID, 'meta' => 'content_position')) == '0')             {                 if(option('content_position') == '0')                 {                     $content_position = '0';                 }                 elseif(option('content_position') == '1')                 {                     $content_position = '1';                 }                 elseif(option('content_position') == '2')                 {                     $content_position = '2';                 }             }             elseif(meta(array('id' => $post -> ID, 'meta' => 'content_position')) == '1')             {                 $content_position = '0';             }             elseif(meta(array('id' => $post -> ID, 'meta' => 'content_position')) == '2')             {                 $content_position = '1';             }             elseif(meta(array('id' => $post -> ID, 'meta' => 'content_position')) == '3')             {                 $content_position = '2';             }                       //portrait_fit             if(meta(array('id' => $post -> ID, 'meta' => 'portrait_fit')) == '1')             {                 $portrait = '1';             }         ?>
             <?php get_sidebar(); ?>
                 <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_title(); ?>

                     <?php the_content(__('Read More »', THEMENAME)); ?>                          <?php endwhile; else: ?>
<?php _e('Nothing found.', THEMENAME); ?>
                     <?php endif; ?>

                       <?php require_once(TEMPLATEPATH . '/assets/includes/theme-background.php'); ?>          <?php get_footer(); ?>      News Template (not functional, returns no value for `is_page()`):               <?php     /*     Template Name: News Page     */     ?>          <?php get_header(); ?>              <?php             // transparent_layer             if(meta(array('id' => $post -> ID, 'meta' => 'transparent_layer')) == '0')             {                 if(option('transparent_layer') == '0')                 {                     $transparent = false;                 }                 elseif(option('transparent_layer') == '1')                 {                     $transparent = true;                 }             }             elseif(meta(array('id' => $post -> ID, 'meta' => 'transparent_layer')) == '1')             {                 $transparent = false;             }             elseif(meta(array('id' => $post -> ID, 'meta' => 'transparent_layer')) == '2')             {                 $transparent = true;             }                       // content_position             if(meta(array('id' => $post -> ID, 'meta' => 'content_position')) == '0')             {                 if(option('content_position') == '0')                 {                     $content_position = '0';                 }                 elseif(option('content_position') == '1')                 {                     $content_position = '1';                 }                 elseif(option('content_position') == '2')                 {                     $content_position = '2';                 }             }             elseif(meta(array('id' => $post -> ID, 'meta' => 'content_position')) == '1')             {                 $content_position = '0';             }             elseif(meta(array('id' => $post -> ID, 'meta' => 'content_position')) == '2')             {                 $content_position = '1';             }             elseif(meta(array('id' => $post -> ID, 'meta' => 'content_position')) == '3')             {                 $content_position = '2';             }                       // portrait_fit             if(meta(array('id' => $post -> ID, 'meta' => 'portrait_fit')) == '1')             {                 $portrait = '1';             }         ?>
             <?php get_sidebar(); ?>

<?php the_title(); ?>

                     <?php                         // loop through posts in news category                         // -1 means all posts... not really intuitive                         // see http://www.binarymoon.co.uk/2010/03/5-wordpress-queryposts-tips/                         $query = array  (                                             'posts_per_page' => -1,                                             'category_name' => 'news'                                         );                         query_posts($query);                         while(have_posts()) : the_post();                              // get post raw date                         $date = get_the_date();                     ?>                         <a                              href="<?php the_permalink(); ?>"                              class="news-link"                             >                             <?php the_title(); ?>                             <?php echo $date; ?>                                                   <?php                         endwhile;                     ?>

                       <?php require_once(TEMPLATEPATH . '/assets/includes/theme-background.php'); ?>          <?php get_footer(); ?>      As you can see, background.php is included at the bottom of these templates. This file comes from the parent theme, which I did not edit. Below is its code:
         <img src="<?php bloginfo('template_url'); ?>/assets/images/loading.gif" alt ="Loading" />

                  <?php if (is_page() || is_single()) { ?>                      <?php if (meta(array('id' => $post->ID, 'meta' => 'post_background')) == '1') { ?>                                                <?php } elseif (meta(array('id' => $post->ID, 'meta' => 'post_background')) == '2') { ?>                          <img src="<?php echo meta(array('id' => $post->ID, 'meta' => 'post_background_image')); ?>" alt="" class="background" />                      <?php } elseif (meta(array('id' => $post->ID, 'meta' => 'post_background')) == '3') { ?>                                                <?php } elseif (meta(array('id' => $post->ID, 'meta' => 'post_background')) == '4') { ?>                          <?php if (meta(array('id' => $post->ID, 'meta' => 'post_background_google_maps_gradient')) == '1') { ?>

                     <?php } ?>                          <iframe width="100%" height="100%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="<?php echo meta(array('id' => $post->ID, 'meta' => 'post_background_google_maps')); ?>">                      <?php } elseif (meta(array('id' => $post->ID, 'meta' => 'post_background')) == '5') { ?>

                      <?php } elseif (meta(array('id' => $post->ID, 'meta' => 'post_background')) == '6') { ?>                          <video id="video" class="background">                         <?php if (meta(array('id' => $post->ID, 'meta' => 'post_background_mp4_video')) != '') { ?>                         <source src="<?php echo meta(array('id' => $post->ID, 'meta' => 'post_background_mp4_video')); ?>" type="video/mp4" />                         <?php } ?>                         <?php if (meta(array('id' => $post->ID, 'meta' => 'post_background_webm_video')) != '') { ?>                         <source src="<?php echo meta(array('id' => $post->ID, 'meta' => 'post_background_webm_video')); ?>" type="video/webm" />                         <?php } ?>                         <?php if (meta(array('id' => $post->ID, 'meta' => 'post_background_ogv_video')) != '') { ?>                         <source src="<?php echo meta(array('id' => $post->ID, 'meta' => 'post_background_ogv_video')); ?>" type="video/ogg" />                         <?php } ?>                     </video>                                                <?php } ?>                      <?php if (meta(array('id' => $post->ID, 'meta' => 'post_background_image_pattern')) == '1') { ?>                     <div class="pattern pattern-0<?php echo meta(array('id' => $post->ID, 'meta' => 'post_background_pattern')); ?>">
                 <?php } ?>                  <?php } ?>