Top level parent taxonomy ID

At the top of a product archive page I am trying to display a list of product categories. The rule should be that the list always shows the direct children of the top level. There are several answers on WPA which I have been trying to implement (with my minimal skills) but I am missing something. Here's the query:                       <?php           $taxonomy     = 'product_cat';         $orderby      = 'name';         $order        = 'DESC';         $show_count   = 0;      // 1 for yes, 0 for no         $pad_counts   = 0;      // 1 for yes, 0 for no         $hierarchical = 1;      // 1 for yes, 0 for no         $title        = '';         $empty        = 0;             // So now I need to get the top parent id in a variable. I tried these 4 options               /*          // option 1          $queried_object = get_queried_object();         $term_id = $queried_object->term_id;                   // option 2         $thisCat = get_category( get_query_var( 'cat' ) );          while ( intval($thisCat->parent) > 0 ) {           $thisCat = get_category ( $thisCat->parent );          }          $term_id = $thisCat->term_id              //option 3         $parent  = get_term_by( 'id', $term_id, $taxonomy);         while ($parent->parent != 0){             $parent  = get_term_by( 'id', $parent->parent, $taxonomy);         }                   //option 4         while ($catid) {           $cat = get_category($catid); // get the object for the catid           $catid = $cat->category_parent; // assign parent ID (if exists) to $catid           // the while loop will continue whilst there is a $catid           // when there is no longer a parent $catid will be NULL so we can assign our $catParent           $catParent = $cat->cat_ID;          }         */                      // Testing if I have the correct value         echo 'The returned variable is:'; print_r($term_id);                        $args2 = array(           'taxonomy'     => $taxonomy,           'child_of'     => $term_id,           'orderby'      => $orderby,           'order'        => $order,           'show_count'   => $show_count,           'pad_counts'   => $pad_counts,           'hierarchical' => $hierarchical,           'title_li'     => $title,           'hide_empty'   => $empty         );              $sub_cats = get_categories( $args2 );              $args = array(             //'type'          => 'post',             'orderby'       => 'term_group',             'hide_empty'    => 0,             'hierarchical'  => 0,             'parent'        => 0,             'taxonomy'      => 'product_cat'         );         $test = get_categories( $args );          //print_r($test);              $cat_id = get_query_var('cat');         echo $cat_id;              if (!empty($sub_cats)) {               echo '
';               foreach($sub_cats as $sub_category) {                  //echo 'de variabele sub_category'; print_r($sub_category);                  if ($sub_cats->$sub_category == 0) {                 $thumbnail_id  = get_woocommerce_term_meta( $sub_category->term_id, 'thumbnail_id', true );                 $image = wp_get_attachment_url( $thumbnail_id );                 $name = $sub_category->name;                 $slug = $sub_category->slug;                      echo '
slug, 'product_cat') .'">'.$name.'
';                      }             }             echo '
';             get_product_search_form();             echo '
';              echo '
';               } //endif !empty ?>      Thanks! Juri


Pages half/not working.

If someone could please look at our website and have a look it'd be really appreciated. On one of our catergoires (rentals>sconces) page one works fine, but the remaining 3 dont. ive read in a couple places to just set the permalink back to default, but i wanted to confirm before i started trying to fix it. any help would be appreciated, ive provided a link to the first page below. http://lighthousevancouver.com/products-page/sconce/


Hardening wordpress: wp-content file permissions?

I'm writing a script to automatically check file permissions in all wordpress installations on a server. This document http://codex.wordpress.org/Hardening_WordPress is unclear on a certain point: > /wp-content/ > > User-supplied content: intended to be writable by your user account and the > web server process. Within /wp-content/ you will find: > > /wp-content/themes/ > > Theme files. If you want to use the built-in theme editor, all files need to > be writable by the web server process. If you do not want to use the built- > in theme editor, all files can be writable only by your user account. > > /wp-content/plugins/ > > Plugin files: all files should be writable only by your user account. Is that documentation above correct and complete (in all contexts) - can I trust it ? If so, what does it say:   * is _only_ the directory wp-content itself writable for both user and webserver, or    * is anything _inside_ wp-content writable for both, except plugins and optionally themes ? I think it says the first .. but the uploads folder isnt mentioned, and that should be writable by the webserver, for sure ? EDIT: slightly rephrased the question


Insert & Upload image into data base in wordpress without using media library & plugin?

Here i am trying to insert image into WordPress database with custom code but i am not able to insert and uplode i am very new to wordpress any body have any idea how to do it?Bellow is my code with HTML and php.               <form style="text-align:center" action=""  method="post"   enctype="multipart/form-data">          Select Image: <input type="file"    name="image"  >     <input type="submit"    name="upload"  value ="Upload Now">            </form>     <?php     $file=$_FILES['image']['tmp_name'];          if(!isset($file))             echo "please select an image";             else      {     $image = addslashes(file_get_contents($_FILES['image']['tmp_name']));     $image_name= addcslashes($_FILES['image']['name']);     $image_size = getimagesize($_FILES['image']['tmp_name']);          if($image_size == FALSE)     echo "this is not an image";      else     {     if (!$insert = mysql_query("insert into stores values('','$image_name',$image' )"))     echo "problem uploading image";     else      {     {      $last_id = mysql_insert_id();     echo "image uploaded.
 your image:
";     }        }     }     }     ?>


Custom taxonomy template for multiple custom post types

I've registered a custom taxonomy for 3 custom post types to share, this all works fine. My issue at the moment is defining a conditional statement within the custom taxonomy file. I want this taxonomy-{taxonomy}.php file to output different html depending on which custom post type the user is viewing. However, the taxonomy-{taxonomy}.php file seems to just grab all the posts which share that taxonomy. For example:               register_taxonomy( 'City', array('Hotel', 'Gym', 'Supermarket'), array(          'labels' => array(             'name' => __( 'Cities' ),             'singular_name' => __( 'City'  )),      'hierarchical' => true ) );      These 3 custom post types ('Hotel', 'Gym', 'Supermarket') will share the City taxonomy. Is it possible to display only Hotel posts and the Hotel sidebar when a user clicks the city taxonomy link from within a hotel post. At the moment it seems like having 1 taxonomy shared between various posts means that it's unable to detect which post type it should be displaying, and instead just outputs any post type which has the matching city taxonomy. Any help would be much appreciated!


Making update notification functionality for my themes

the question is simple :) I am making a theme that i will use in lots of sites. So, i don't want to go all the site and ftp the files every time i fix a bug or do a theme upgrade. Is there any way i can make a update system like the plugins hosted in wordpress plugin directory. Looking forward to your answer. Thanks! **Solved:** Thanks Chip Bennett for his excellent link. The update library for themes is now available in that site. You can find it here: http://w-shadow.com/blog/2011/06/02/automatic-updates-for-commercial-themes/ Always consider donation if you see some excellent work that made available for free.


Permalink Settings for Custom Post Type

I have a plugin that creates a custom post type. I am able to control the rewite rules and have also created a plugin settings for the archive url and taxonomy urls slugs. However if a user enter "category" for the taxonomy slug then it collides with a defauly wordpress naming convention and I get 404. I can deal with this by putting warning telling the user that they need to head on over to their permalink setting and change the "Category base" value in. Permalink Settings. I see some plugins have added what looks like custom post type fields in the Permalink Settings interface. Woo Commercefor example has "Product permalink base" section also has added some additional fields in "Optional" section of the Permalink Settings interface. How are they doing this? I have looked around and cannot fine any documentation on this.


Using Tags Instead of Categories for site structure

I noticed that huffingtonpost.com and some other websites are using tags instead of categories for blog structure. For example the last tag in this post (like every post) is redirecting to "technology news" section of the menu. Is it OK to use tags instead of categories in the wordpress menu? what's the advantage of doing this with tags?


How to recover the post ID earlier in the WP admin hook action "firing" sequence?

I am creating a WP plugin based around Custom Post Types (CPT), where you can dynamically specify a CPT, complete with any number of associated dynamic Meta Boxes and form elements such as radio buttons, textfields etc.., using the excellent Meta Box Script V3.1 from RilWis. The issue I am having is that I need to recover the post ID of a CPT "post" in WP-admin before I issue the `add_action` hook command to build the dynamic Meta Boxes. It appears that WP only starts allowing the recovery of the post ID (in admin) from the `parse_query` action hook command onwards in the firing sequence of WP. However the Meta Box script by Rilwis has a `save_post` action command (naturally), which only triggers up until the `admin_init` action hook. This means there is no overlap in the WP admin firing sequence to allow the postID to be recovered (to find the data required to build further CPT's dynamically) before the call to build them is needed. Short of abandoning Rilwis WP Meta Box class, and developing a Meta Box data save functionality of our own (or my lack of WP understanding), can anyone give me some thoughts on how I can recover the post ID earlier in the WP admin hook firing sequence? Or conversely whether we can trigger an action to save the Meta Box post data later in the WP firing sequence?


Why the dynamic_sidebar() call is putted into an ul tag?

I am pretty new in WordPress development and I have the following doubt about how the **sidebar** are putted into a WordPress theme. Looking into the official documentation: http://codex.wordpress.org/Function_Reference/dynamic_sidebar I see some example, as:               <?php if ( is_active_sidebar( 'left-sidebar' ) ) : ?>         <ul id="sidebar">             <?php dynamic_sidebar( 'left-sidebar' ); ?>         </ul>     <?php endif; ?>      Ok, my doubt is: why it put the **dynamic_sidebar()** call into an **ul** tag? Why inside an **ul** tag and not into a standard container as a **div**? Are there a specific reason? What am I missing? Tnx


Get WP Stats code no longer works

Up until recently, I have been using a code to grab the latest five most viewed posts on my WordPress from the last seven days:               <?php function get_stats_exclude_home($numDays,$numPosts) {       $numPostsPlus = $numPosts + 1;       $blnHasHome = false;       $intRowsLoop = 0;       $intRowFound;       $intRowsCount;       $most_read_posts;       $strArgs = 'days=' . $numDays . '&limit=' . $numPostsPlus;       if (function_exists('stats_get_csv')) {         $most_read_posts = stats_get_csv('postviews', $strArgs);       }       foreach ($most_read_posts as $single_post) {         $postTitle = $single_post['post_title'];         if($postTitle == 'Home page') {           $blnHasHome = true;           $intRowFound = $intRowsLoop;         }         $intRowsLoop = $intRowsLoop + 1;       }       $intRowsCount = $intRowsLoop + 1;       if($blnHasHome) {       unset($most_read_posts[$intRowFound]);       } else {         if($intRowsCount > $numPosts){      unset($most_read_posts[$numPosts]);         }       }       return $most_read_posts;     } ?><?php if ( function_exists('get_stats_exclude_home') && $top_posts = get_stats_exclude_home(7,5)) : ?>
<?php foreach ( $top_posts as $p ) : ?>
<a href="<?php echo $p['post_permalink']; ?>"><?php echo $p['post_title']; ?>
      I have been using this code for years, and likewise, have been using the same version of WP Stats, pre-Jetpack days, just fine. Although recently, the code to output the most popular posts has started showing something like "#xxxxxx loading title", xxxxxx being the post ID. I'm wondering if anyone has any ideas, the stats show up fine in the stat panel itself, just for some reason, this code apparently no longer works properly.


Gravity Forms - Edit entries in WP-Admin

Relatively new user here to Gravity Forms. The documentation reads the entries can be edited by using the "Entries Manager". I am using 1.8.9 and I don't see this entries manager. I am able to view, sort, filter entries from the view supplied within the forms hierachy. I would like to modify a handful of entries. Is this possible without going into the database?


Querying and Ordering Hierachical data

I am developing a WordPress site that requires the display of song lyrics. Here's the archive data that needs to be displayed:               [Released 2014] - Album Title          [Track 1] - Song Title          [Track 2] - Song Title          [Track 3] - Song Title          [Released 2013] - Album Title          [Track 1] - Song Title          [Track 2] - Song Title          [Track 3] - Song Title      This website is for a low-tech client so I need a data structure that the client can add/edit in the Wordpress admin. Currently my prototype structure is a custom taxonomy for the album and a custom post type for the lyrics. There a several forum threads that are similar in data requirements: (TV show, season, episode) TV Show database - Best way for structuring it? using custom taxonomies to create a movie database Using wp_query is it possible to orderby taxonomy? But none of them will help me in querying my data by a release date or track number. Aside from pure SQL queries, can someone tell me how to setup/query data of this requirement?


Order get_terms using a Custom Field

I have a custom taxonomy of "crb_issues" that has a custom field associated with it that is "issue_date" which outputs a date value for each term to looks a lot like "20140601" yearmonthday. I am trying to out put all the Taxonomies terms using get_terms and order them by that custom field. Below is the code I have been working on which outputs the Terms Name and the value of the "issue_date" just fine. But I am having a hard time getting what is outputting to order by that custom field.               $args = array(         'meta_key'          => 'issue_date',         'orderby'           => 'meta_value_num',          'order'             => 'DESC',         'hide_empty'        => true,         'number'            => '4',          'fields'            => 'all',      );           $terms = get_terms("crb_issues", $args);           if ( !empty( $terms ) && !is_wp_error( $terms ) ){         echo "
";         foreach ( $terms as $term ) {             echo "
" . $term->name . "
";             the_field('issue_date', $term);         }         echo "
";      }      Any help would be much appreciated.


Theme Development for a Newbie

**TL;DR, Skip to Trouble** I am a programmer and web developer by trade. I'm attempting to launch my own small business website in order to showcase my talents. As such, I've created subdomains for each of the major development Frameworks that I can use to develop customer sites. Each of these is successfully running.   1. DotNetNuke - ASP.NET - Main Site   2. Joomla   3. CodeIgnitor/CakePHP   4. WordPress   5. Drupal   6. PHPbb   7. WikiMedia   8. Custom - Catch All for Everything Else I'll admit that I'm old school. I used to prefer Notepad/Kate, and do it all by hand, but I understand _technology changes_. Up until recently, I was like every other "web guy," and would purchase a precanned theme, add a little content, make sure it all worked and resell it. In an effort to not look "Cookie Cutter", and not bankrupt my small bankroll by buying someone else's overpriced theme(s), I decided to show customer's my skills by theming each subdomain myself, which will hopefully set me apart.... * * * ## Not As Easy As I Thought   * I went to _s, and created a Starter Theme.   * I crossed over to the Darkside by integrating Bootstrap into my theme. I'm a sucker for eye candy, and I didn't want to recreate buttons and grids by hand, and _technology changes_.   * I decided on this blog example, as a base for my creative genius. Plain I know, but I'm starting off slow.   * The Trouble Starts... * * * ## Trouble I converted the code in the template to the Wordpress Section Files(header.php, footer.php, and sidebar.php) Hurdle 1 Jumped. Whoot. I could't get the customized NavMenus to work until I found the BootstrapNavWalker Helper. Hurdle 2 Jumped. Whoot. I added the following code to functions PHP to have a login link.               /**      * Add Login/Logout to Menu      */     function add_login_logout_link($items, $args) {         if( $args->theme_location == 'primary' ) {             $loginoutlink = wp_loginout('index.php', false);             $items .= '
'. $loginoutlink .'
';         }              return $items;     }     add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);      This Works, but I wanted a button, so I changed `$items` to:               $items .= '
<button type="button" class="btn btn-default">'. $loginoutlink .'</button>
';      It worked, so I thought, as I was developing in Chrome. I got home and tried in Firefox: Q: The Button is visible in Firefox, but clicking it does nothing. Clicking it in Chrome takes me to the login page, so What is the proper way to output `$items` so the button and/or all bootstrap items works in every browser? Q: I chose, the snippet above after reviewing a few dozen snippets from various places. In seeing these, I saw some that used the output buffer functions and some that didn't. What's the advantage of wrapping functions in the buffer before outputting them to the browser?


unable to access image attributes in wp_postmeta when looping through posts

I have an issue with accessing attributes of a library image, particularly the "Alternate Text" attribute. I use the ACF (Advanced Custom Fields) plugin to pull back the slideshow image which is attached to my post in this manner: `<img src="<?php the_field('slideshow_image'); ?>" />` The problem I appear to have is that the `post_ID` that is present when I iterate through the loop is not the same as the `post_ID` in the `wp_postmeta` table and I cannot understand why that is. `<?php foreach ($post_list as $post) : setup_postdata($post); error_log($post->ID); ?> <img src="<?php the_field('slideshow_image'); ?>" /> <?php endforeach ?>` I have an entry in `wp_postmeta` with a `meta_key` of `_wp_attachment_image_alt`, however it _doesn't_ match the post ID above, e.g. The URL to the image I am editing the alt text for. This is 100% the same image that is in the slideshow/carousel above: http://www.wrestlemaniamainevent.com/explore/wp- admin/media.php?attachment_id=60862&action=edit wp_postmeta:               Post ID              Meta Key                     Meta Value      60862                _wp_attachment_image_alt     Test Alt Text - CRMPICCO      Note the **attachment_id** is the same as the `post_id` \- is this correct or is this a bug (I am using WP 3.3.1)?


Allow contributors to moderate comments comments on posts they write

I run a multi-author wordpress site where we have a large number of contributors that can write articles, which are published after they are reviewed by an editor. (This is all standard wordpress behaviour). What I would like to do is give the contributors the ability to moderate comments on the posts which they write, but not on posts written by other people. I haven't found a way of doing this, either with a code snippet or plugin and am hoping that someone here knows how to make this work. Thanks **EDIT** : I forgot to mention that I am running multisite. Thanks again.


Background color and background image below element in Contact Form 7 - error tip

The idea was to make the not valid error tip that comes up when people fail to fill out a required field show up like a speech bubble. So the arrowhead image shows in the center and underneath the text and would point into the field that they missed. Fiddle here **HTML:**               Please fill the required field.      **CSS:**               .wpcf7-not-valid-tip {             background: red;             color: white;             padding: 10px;             width: 100px;             background-position: 0 0;              background-repeat: no-repeat;             background-image: url('http://s24.postimg.org/qacevkf7l/green_error_arrow.png');       }      As you can see I have a background color and the arrow image that needs to sit in the middle of the element and below it but, of course, if you position it using background-position, the image is hidden as it cannot overflow outside of the element itself. This would be easy if I could easily edit the HTML but I would prefer not to as I am using a plugin and want to be free to update the plugin in the future. **QUESTION:** Is there a pure CSS solution? If not (and I suspect there isnt) what is the cleanest way to solve this issue? Would I use add_filter to alter the html to put a div around the tooltip that i could then add the bg image to? Something with css "content:", a js solution?


2 dynamic sidebars registered, not showing up

My intention is to have a left and right sidebar on each page. I've registered both of them, implemented my desired widgets, and yet something isn't quite right. The left sidebar (`sidebar(1)`) loads correctly on the left side, but is stuck beneath page content. The right sidebar (`sidebar(2)`) does not show up on the page at all though it does appear to be active in Appearance > Widgets. What have I overlooked? What can be done to allow for the two sidebars to show and function properly? Thanks. Here's what I have: single.php               <?php get_header(); ?>

                  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>

Posted on <?php the_time('F j, Y'); ?> | <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?>

                 <?php the_content(__('Read more'));?>

Category: <?php the_category(', ') ?>
<?php the_tags('Tags: ',' > '); ?>

                                    <?php endwhile; else: ?>
<?php _e('Nothing found here, uh oh!'); ?>
<?php endif; ?>

                    <?php get_sidebar('l'); ?>     <?php get_sidebar('r'); ?>     <?php get_footer(); ?>      sidebar-l.php

             <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>

      sidebar-r.php

             <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?>

      functions.php               <?php     if ( function_exists('register_sidebars') )         register_sidebars(2);     ?>      css               #sidebar {         width: 200px;     }          #sidebar-left {         float: left;     }          #sidebar-right {         float: right;     }          p.sidebar {         font-size: 80%;     }


Custom Taxonomies Cababilities

Since 3.1 I've had an issue with custom taxonomies for a site. it seems that my user (admin level) can't edit the taxonomies from any screen. I see them on under the custom post type and can see them when adding a new post to the custom post type. I can even add currently available taxonomies to the post but I can't create new terms or access the custom taxonomy on it's edit page. Below is my code to set up the taxonomy.                <?php add_action( 'init', 'fvww_custom_taxonomies');          function fvww_custom_taxonomies() {              $labels = array(             'name'                  => __( 'River Classes', 'taxonomy general name' ),             'singular_name'         => __( 'River Class', 'taxonomy singular name' ),             'search_items'          => __( 'Search River Classes' ),             'all_items'             => __( 'All River Classes' ),             'parent_item'           => __( 'Parent Class' ),             'parent_item_colon'     => __( 'Parent Class:' ),             'edit_item'             => __( 'Edit River Class' ),             'update_item'           => __( 'Update River Class' ),             'add_new_item'          => __( 'Add New River Class' ),             'new_item_name'         => __( 'New River Class' ),             'menu_name'             => __( 'River Class' ),         );              register_taxonomy( 'Class', array( 'fvww-river-guide' ), array(             'hierarchical'              => true, //operates like a category             'labels'                    => $labels,             'rewrite'                   => true,             'public'                    => true,             'show_ui'                   => true,             )         ); // ends class taxonomy          } /* end function */ ?>      If I click on the 'Class' taxonomy under River Guides I get the 'Cheatin uh?' message from wp-admin/edit-tags.php line 12.


URL renaming issue

I am a non programmer using a wordpress site (riyachting.com) I just discoverd that sending folks to my page with a URL that inlcudes some other stuff in it gets stripped out so only the URL of the page remains.... i guess it's getting renamed. We want to use this link to launch a lightbox with content... http://www.riyachting.com#liteboxlive:station- box::href:http%3A%2F%2Fwww.marinemotion.com%2Fstations%2Friyachting%2Friy_sponsors%2Fblue- water-yachts-adds-jeanneau::referrer:http%3A%2F%2Fwww.riyachting.com Is there a way to turn off that function so the site will accept our links.. we plan to do this all the time.


Database for development

While building plugins one of my biggest annoyances is that my development machine does not match a real world install. What I mean here is that my databases are lacking. I'll code something thinking it'll work (since it does during development) then find out it doesn't because I neglected a minor detail missing from my local db. Even my own online install doesn't contain a full database. Is there available a set of db's pre-filled out with the usual WP content? Or even a script to auto add rows and columns? I'm looking for user's of varying roles, custom post types, taxonomies, comments etc, which can be dropped in for development purposes only? If not does anybody have a backup from an old site they would like to share?


How to remove row-actions from pages table?

I've already found out here how to remove the row-actions from the posts table in wordpress admin. Now I'd like to do the same in the pages table. I've looked in the core files but, well, I just don't get it. Anyone? Here's the code used in functions.php to remove row actions in posts:               function remove_row_actions( $actions )     {         if( get_post_type() === 'post' )             unset( $actions['edit'] );             unset( $actions['view'] );             unset( $actions['trash'] );             unset( $actions['inline hide-if-no-js'] );         return $actions;     }     add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 );      Thanks in advance!


Adding extra fields to front end signup form

I've been reading around and looking for a front-end signup form ( **not using plugins!** ) and came across this - http://net.tutsplus.com/tutorials/wordpress/quick-tip-making-a-fancy- wordpress-register-form-from-scratch/

Register your Account
             Sign Up with us and Enjoy!
             <form action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">             <input type="text" name="user_login" value="Username" id="user_login" class="input" />             <input type="text" name="user_email" value="E-Mail" id="user_email" class="input"  />                 <?php do_action('register_form'); ?>                 <input type="submit" value="Register" id="register" />

A password will be e-mailed to you.
                       </form>
      It's almost everything I need but there are a few things missing in terms of the fields. Is it possible to add extra fields to the front end signup form that will be saved in and displayed in the backend?


[Custom field template plugin] Upload limited to 20 inputs file

am running the CFT plugin version 1.9.2 on a 3.1.3 wordpress site and in the admin i did set up 30 input file fields related to a custom post type. It all works fine until the 21st field (and beyond) that does not save any file (small picture) that is selected. I did a local test on wamp, and it all works fine, all the 30 fields are saving (and displaying) well the pictures. I did another test online (different server) on a test installation. I uploaded the database used locally and all the files, checked the site and the post is displaying well the pictures: link and has obviously all 30 saved in the admin. So after that i tried to create a new post on this test site and uploaded the pictures from the admin and bam there goes the same problem, stuck at 20: link. The media upload works fine by the admin works fine, even with high res pics. Here's the beginning of my template's content in the CFT admin:               [project-introduction]     type = textarea     label = Introdução     cols = 50     rows = 6          [p-img-1]     type = file     label = Imagem projeto #1 (capa)          [p-img-2]     type = file     label = Imagem projeto #2          [p-img-3]     type = file     label = Imagem projeto #3      I also tried to add the `blank = true` to my `type= file` fields but didnt seem to help. I'd be glad to have your point of view on this cos am stuck. Thanks in advance.


Sort "get_pages" by menu order not ordering

I'm using this bit of code to generate a page full of items but they won't sort into the menu order, any ideas as to why?                  <?php $pages = get_pages(array('child_of', 'menu_order')); ?>


Custom Post not working as expected

> **NEW EDIT** I solved it, as written in answer, the problem where that > variables are 'forgotten' (not so techy I know, sorry for this) when > `function` starts. **EDIT:** I found the problem is this: `'name' => _x( $plurcpost, $singcpost ),` if I use text instead of a variable everything works properly.... So, How can I use a variable here? I am working on a new WordPress template using wptheming Option Framework. User can choose how many custom posts he want (between 1 to 5) using a radio select. The value of the radio is stored in DB and then, inside functions.php there is a require that 'includes' the proper PHP file. The 'include' works as expected ( I tryied to delete this: `<?php` at the beginning of each file and I can see the included files on top of my admin screen). I thought that the problem could be the option not saved but, I tryied to echo each of them and I had no problem. So I think that I am doing something wrong in the file that generates the cPosts. This is what I have in functions.php:               /* Include Custom-posts settings */     if (of_get_option('custom_custom_post_creator')){//this is working         $quanticpost = of_get_option('how_many_custom_posts');//this is working too     require_once MDCP_DIR . 'cpost/cpost_if_'.$quanticpost.'.php';//this is working too     };      This is cpost_if_5.php :               <?php         /* IF 1 Start */         $singcpost = of_get_option('custom_posts_name_s_n1');         $plurcpost = of_get_option('custom_posts_name_p_n1');         $desccpost = of_get_option('custom_posts_name_d_n1');         $imgcpost  = of_get_option('custom_posts_name_i_n1');     add_action( 'init', 'register_cpt_cpost_mdframework_1' );          function register_cpt_cpost_mdframework_1() {              $labels = array(              'name' => _x( $plurcpost, $singcpost ),             'singular_name' => _x( $singcpost, $singcpost ),             'add_new' => _x( 'Add New', $singcpost ),             'add_new_item' => _x( 'Add New '.$singcpost.'', $singcpost ),             'edit_item' => _x( 'Edit '.$singcpost.'', $singcpost ),             'new_item' => _x( 'New '.$singcpost.'', $singcpost ),             'view_item' => _x( 'View '.$singcpost.'', $singcpost ),             'search_items' => _x( 'Search '.$plurcpost.'', $singcpost ),             'not_found' => _x( 'No '.$plurcpost.' found', $singcpost ),             'not_found_in_trash' => _x( 'No '.$plurcpost.' found in Trash', $singcpost ),             'parent_item_colon' => _x( 'Parent '.$singcpost.':', $singcpost ),             'menu_name' => _x( $plurcpost, $singcpost ),         );              $args = array(              'labels' => $labels,             'hierarchical' => true,             'description' => $desccpost,             'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),             'taxonomies' => array( 'category', 'post_tag', 'page-category', 'customtax1', 'customtax2', 'customtax3' ),             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'menu_position' => 5,             'menu_icon' => $imgcpost,             'show_in_nav_menus' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'has_archive' => true,             'query_var' => true,             'can_export' => true,             'rewrite' => true,             'capability_type' => 'post'         );              register_post_type( $singcpost, $args );     }     /* IF 1 END */         /* IF 2 Start */         $singcpost = of_get_option('custom_posts_name_s_n2');         $plurcpost = of_get_option('custom_posts_name_p_n2');         $desccpost = of_get_option('custom_posts_name_d_n2');         $imgcpost  = of_get_option('custom_posts_name_i_n2');     add_action( 'init', 'register_cpt_cpost_mdframework_2' );          function register_cpt_cpost_mdframework_2() {              $labels = array(              'name' => _x( $plurcpost, $singcpost ),             'singular_name' => _x( $singcpost, $singcpost ),             'add_new' => _x( 'Add New', $singcpost ),             'add_new_item' => _x( 'Add New '.$singcpost.'', $singcpost ),             'edit_item' => _x( 'Edit '.$singcpost.'', $singcpost ),             'new_item' => _x( 'New '.$singcpost.'', $singcpost ),             'view_item' => _x( 'View '.$singcpost.'', $singcpost ),             'search_items' => _x( 'Search '.$plurcpost.'', $singcpost ),             'not_found' => _x( 'No '.$plurcpost.' found', $singcpost ),             'not_found_in_trash' => _x( 'No '.$plurcpost.' found in Trash', $singcpost ),             'parent_item_colon' => _x( 'Parent '.$singcpost.':', $singcpost ),             'menu_name' => _x( $plurcpost, $singcpost ),         );              $args = array(              'labels' => $labels,             'hierarchical' => true,             'description' => $desccpost,             'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),             'taxonomies' => array( 'category', 'post_tag', 'page-category', 'customtax1', 'customtax2', 'customtax3' ),             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'menu_position' => 5,             'menu_icon' => $imgcpost,             'show_in_nav_menus' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'has_archive' => true,             'query_var' => true,             'can_export' => true,             'rewrite' => true,             'capability_type' => 'post'         );              register_post_type( $singcpost, $args );     }     /* IF 2 END */         /* IF 3 Start */         $singcpost = of_get_option('custom_posts_name_s_n3');         $plurcpost = of_get_option('custom_posts_name_p_n3');         $desccpost = of_get_option('custom_posts_name_d_n3');         $imgcpost  = of_get_option('custom_posts_name_i_n3');     add_action( 'init', 'register_cpt_cpost_mdframework_3' );          function register_cpt_cpost_mdframework_3() {              $labels = array(              'name' => _x( $plurcpost, $singcpost ),             'singular_name' => _x( $singcpost, $singcpost ),             'add_new' => _x( 'Add New', $singcpost ),             'add_new_item' => _x( 'Add New '.$singcpost.'', $singcpost ),             'edit_item' => _x( 'Edit '.$singcpost.'', $singcpost ),             'new_item' => _x( 'New '.$singcpost.'', $singcpost ),             'view_item' => _x( 'View '.$singcpost.'', $singcpost ),             'search_items' => _x( 'Search '.$plurcpost.'', $singcpost ),             'not_found' => _x( 'No '.$plurcpost.' found', $singcpost ),             'not_found_in_trash' => _x( 'No '.$plurcpost.' found in Trash', $singcpost ),             'parent_item_colon' => _x( 'Parent '.$singcpost.':', $singcpost ),             'menu_name' => _x( $plurcpost, $singcpost ),         );              $args = array(              'labels' => $labels,             'hierarchical' => true,             'description' => $desccpost,             'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),             'taxonomies' => array( 'category', 'post_tag', 'page-category', 'customtax1', 'customtax2', 'customtax3' ),             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'menu_position' => 5,             'menu_icon' => $imgcpost,             'show_in_nav_menus' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'has_archive' => true,             'query_var' => true,             'can_export' => true,             'rewrite' => true,             'capability_type' => 'post'         );              register_post_type( $singcpost, $args );     }     /* IF 3 END */         /* IF 4 Start */         $singcpost = of_get_option('custom_posts_name_s_n4');         $plurcpost = of_get_option('custom_posts_name_p_n4');         $desccpost = of_get_option('custom_posts_name_d_n4');         $imgcpost  = of_get_option('custom_posts_name_i_n4');     add_action( 'init', 'register_cpt_cpost_mdframework_4' );          function register_cpt_cpost_mdframework_4() {              $labels = array(              'name' => _x( $plurcpost, $singcpost ),             'singular_name' => _x( $singcpost, $singcpost ),             'add_new' => _x( 'Add New', $singcpost ),             'add_new_item' => _x( 'Add New '.$singcpost.'', $singcpost ),             'edit_item' => _x( 'Edit '.$singcpost.'', $singcpost ),             'new_item' => _x( 'New '.$singcpost.'', $singcpost ),             'view_item' => _x( 'View '.$singcpost.'', $singcpost ),             'search_items' => _x( 'Search '.$plurcpost.'', $singcpost ),             'not_found' => _x( 'No '.$plurcpost.' found', $singcpost ),             'not_found_in_trash' => _x( 'No '.$plurcpost.' found in Trash', $singcpost ),             'parent_item_colon' => _x( 'Parent '.$singcpost.':', $singcpost ),             'menu_name' => _x( $plurcpost, $singcpost ),         );              $args = array(              'labels' => $labels,             'hierarchical' => true,             'description' => $desccpost,             'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),             'taxonomies' => array( 'category', 'post_tag', 'page-category', 'customtax1', 'customtax2', 'customtax3' ),             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'menu_position' => 5,             'menu_icon' => $imgcpost,             'show_in_nav_menus' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'has_archive' => true,             'query_var' => true,             'can_export' => true,             'rewrite' => true,             'capability_type' => 'post'         );              register_post_type( $singcpost, $args );     }     /* IF 4 END */         /* IF 5 Start */         $singcpost = of_get_option('custom_posts_name_s_n5');         $plurcpost = of_get_option('custom_posts_name_p_n5');         $desccpost = of_get_option('custom_posts_name_d_n5');         $imgcpost  = of_get_option('custom_posts_name_i_n5');     add_action( 'init', 'register_cpt_cpost_mdframework_5' );          function register_cpt_cpost_mdframework_5() {              $labels = array(              'name' => _x( $plurcpost, $singcpost ),             'singular_name' => _x( $singcpost, $singcpost ),             'add_new' => _x( 'Add New', $singcpost ),             'add_new_item' => _x( 'Add New '.$singcpost.'', $singcpost ),             'edit_item' => _x( 'Edit '.$singcpost.'', $singcpost ),             'new_item' => _x( 'New '.$singcpost.'', $singcpost ),             'view_item' => _x( 'View '.$singcpost.'', $singcpost ),             'search_items' => _x( 'Search '.$plurcpost.'', $singcpost ),             'not_found' => _x( 'No '.$plurcpost.' found', $singcpost ),             'not_found_in_trash' => _x( 'No '.$plurcpost.' found in Trash', $singcpost ),             'parent_item_colon' => _x( 'Parent '.$singcpost.':', $singcpost ),             'menu_name' => _x( $plurcpost, $singcpost ),         );              $args = array(              'labels' => $labels,             'hierarchical' => true,             'description' => $desccpost,             'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),             'taxonomies' => array( 'category', 'post_tag', 'page-category', 'customtax1', 'customtax2', 'customtax3' ),             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'menu_position' => 5,             'menu_icon' => $imgcpost,             'show_in_nav_menus' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'has_archive' => true,             'query_var' => true,             'can_export' => true,             'rewrite' => true,             'capability_type' => 'post'         );              register_post_type( $singcpost, $args );     }     /* IF 5 END */         ;?>      This is what I see in Back-end even if, in theory, 5 custom posts are active. ![This is what I can see in the backend](http://i.stack.imgur.com/dvaQu.png) This is the url if I try to add a custom post: > wp-admin/post-new.php?post_type= I think that the problem is related with my custom post code but I can't find what I did wrong. Maybe variables aren't read as I thought by custom post code?


Image upload appearing as broken images following server move

I've got the horrible task of moving a site from one hosting server to another and had no end of problems for DNS issues to temporary domain issues and FTP issues. However I've managed to install a new database and import the backup of the old wordpress site and all is looking fine - I've got everything hidden behind a holding page (script in the wp-blog-header.php file allows access only to logged in users) and testing things out. First issue I came across was the WYSIWYG editor was missing all the buttons for styling etc - so I re-uploaded all the wp files again and that solved the matter. Second issue is that when writing a post and uploading an image, the image uploads but doesn't appear - there is no thumbnail appearing afte crunching and if I click to insert image into post I just get a blank box with a broken file link icon in it. I checked to the uploads folder and the image has uploaded and crumched just fine - so don't understand why it's not appearing in the blog post. Any ideas of how to resolve this? Thanks E


Make a wordpress site similar to Hot Or Not - Image rating system

I'm wondering how I would go about implementing some kind of image voting system to wordpress. I've had a brief look at plugins but none are particularly great. I would also like users to be able to upload photos? I'm not great with wordpress so any advice would be great. I'm literally open to anything here. I was also thinking of adding in buddypress to give some kind of community behind it all. Any advice welcome at all. More the merrier in fact!


Get post category as a separate string and url

I need to figure out how to get post category as a string and link, both separate from each other. So the return would be something like: Uncategorized   http://link-to-the-category.com however both should be separate, because I need to put them in different parts of my markup.


Woocommerce products per page dropdown

I'm using the following code taken from here- http://designloud.com/how-to-add-products-per-page-dropdown-to- woocommerce/?showmodaldialog=1#comment-1554 to display a drop down selector so the user can select how many products to view per page. It all works except the pagination. Selecting next page returns a page not found 404 error. I think it something to do with the cookies. Can anyone help? Thanks               // Lets create the function to house our form     function woocommerce_catalog_page_ordering() {     ?>               <form action="" method="POST" name="results">     <select name="woocommerce-sort-by-columns" id="woocommerce-sort-by-columns" class="sortby" onchange="this.form.submit()">     <?php                  //  This is where you can change the amounts per page that the user will use  feel free to change the numbers and text as you want, in my case we had 4 products per row so I chose to have multiples of four for the user to select.          $shopCatalog_orderby = apply_filters('woocommerce_sortby_page', array(                     ''       => __('Results per page', 'woocommerce'),                     '2'    => __('2 per page', 'woocommerce'),                     '36'        => __('36 per page', 'woocommerce'),                     '48'        => __('48 per page', 'woocommerce'),                     '64'        => __('64 per page', 'woocommerce'),                 ));                      foreach ( $shopCatalog_orderby as $sort_id => $sort_name )                     echo '<option value="' . $sort_id . '" ' . selected( $_SESSION['sortby'], $sort_id, false ) . ' >' . $sort_name . '</option>';             ?>     </select>          </form>     <?php          }           // now we set our cookie if we need to     function dl_sort_by_page($count) {       if (isset($_COOKIE['shop_pageResults'])) { // if normal page load with cookie          $count = $_COOKIE['shop_pageResults'];       }       if (isset($_POST['woocommerce-sort-by-columns'])) { //if form submitted         setcookie('shop_pageResults', $_POST['woocommerce-sort-by-columns'], time()+1209600, '/', 'beadsnwire.lukeseall.co.uk/', false); //this will fail if any part of page has been output- hope this works!         $count = $_POST['woocommerce-sort-by-columns'];       }       // else normal page load and no cookie       return $count;     }          add_filter('loop_shop_per_page','dl_sort_by_page');     add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_page_ordering', 20 );


Custom Post Query Combined with Conditional Tags

Is it possible to combine displaying a list of custom post types on a single page depending on conditional tags? Below is what I have so far, basically if there are 4 posts or less show the posts, if there are more than 4 posts show another list. Currently it just shows the first list, though.               <?php $loop = new WP_Query( array( 'post_type' => 'cases','posts_per_page' => '-1') ); ?>          <?php if ($wp_query->found_posts <= 4) { ?>
                  <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>                 <li id="<?php the_ID(); ?>"><?php the_title(); ?>
             <?php endwhile; wp_reset_postdata();?>
          <?php } else { ?>
                  <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>                 <li id="<?php the_ID(); ?>"><?php the_title(); ?>
             <?php endwhile; wp_reset_postdata();?>
          <?php } ?>


Front end post form validation

I have a front end post from that works fine except for the validation that I need done before it's processed. Ultimately I'd like to be able to do this with ajax because I have to do some things like validate youtube url's with a php function but I want to start simple by showing errors for things like empty title. So here is what I have so far.                 <form id="new_post" name="new_post" method="post" action="" enctype="multipart/form-data">
           <input type="text" id="title" value="Video Title" tabindex="1" size="20" name="title" />

           <textarea id="description" tabindex="3" name="description" cols="50" rows="6">Video Description</textarea>

           <input type="text" id="video_url" value="Youtube URL" tabindex="1" size="20" name="video_url" />

           <input type="text" value="Tags" tabindex="5" size="16" name="post_tags" id="post_tags" />

<input type="submit" value="Publish" tabindex="6" id="submit" name="submit" />
              <input type="hidden" name="action" value="new_post" />              <?php wp_nonce_field( 'new-post' ); ?>            </form>      And then the PHP to process here which seems to check if the fields are set but doesn't do anything if they aren't.               function video_process_form( $query ) {      if ( $query->is_page( 'submit-video' ) && isset( $_POST['title'] ) ) {        if ( ! function_exists( 'wp_handle_upload' )) {                 require_once(ABSPATH . "wp-admin" . '/includes/image.php');                 require_once(ABSPATH . "wp-admin" . '/includes/file.php');                 require_once(ABSPATH . "wp-admin" . '/includes/media.php');        }        $file=$_FILES;        // Do some minor form validation to make sure there is content        if ( isset($_POST['title']) && !empty($_POST['title'])) {         $title =  $_POST['title'];        } else {         echo 'Please enter a game  title';        }        if (isset ($_POST['description'])) {         $description = $_POST['description'];        } else {         echo 'Please enter the content';        }        if (isset ($_POST['video_url'])) {         $video_url = $_POST['video_url'];        }        $tags = $_POST['post_tags'];             // Add the content of the form to $post as an array        $new_post = array(         'post_title'    => $title,         'post_content'  => $description,         'tags_input'    => array($tags),         'post_category' => array(12),         'post_status'   => 'publish',           // Choose: publish, preview, future, draft, etc.         'post_type' => fod_videos  // Use a custom post type if you want to        );        //save the new post and return its ID        if (isset($_POST['title']) && !empty($_POST['title'])) {         $pid = wp_insert_post($new_post);         update_post_meta($pid,'video_code',$video_url);         wp_redirect( get_permalink($pid));          exit();        }      }      do_action('wp_insert_post', 'wp_insert_post');     }     add_action( 'pre_get_posts', 'video_process_form' );          So how I am failing here and what is the correct way to show errors to the client on submission? Also no I am not down to use gravity forms to solve all my problems.


My plugin class doesn't work!

Long story short; I'm writing a plugin in OOP. The constructor is run, but the callback of my add_action does not run. I just can't find out why. I have added echo's on different spots to see what works and what not. The constructor is run, though the `pepare()` method is not. `WP_DEBUG` is enabled, though I'm not getting any warnings or errors.               <?php     /*     Plugin Name: Simplist slider     Description: My description     Version: 1.0     Author: Tim Severien     */          class SimplistSlider {         public function __construct() {             // something is wrong here             add_action('wp_enqueue_scripts', array($this, 'prepare'));         }              public function prepare() {             // registers             wp_register_style('simplist-slider', plugins_url('/css/simplist-slider.css', __FILE__), array(), '1');             wp_register_script('simplist-slider', plugins_url('/js/simplist-slider.js', __FILE__), array('jquery'), '1');                  // enqueues             wp_enqueue_style('simplist-slider');             wp_enqueue_script('simplist-slider');                  add_shortcode('slider', array($this, 'shortcode'));         }              public function shortcode($attr, $content = NULL) {             // format content, irrelevant         }     }          $simplist_slider = new SimplistSlider();     ?>      I'm running a fresh Wordpress 3.4.2 installation. Thanks in advance. * * * **edit** After modifying the code (you guys suggested), I have manage to get the shortcode working! Thanks! Problem is, that my style and script isn't loaded. Have a look at my updated code:               <?php     /*     Plugin Name: Simplist slider     Description: My description     Version: 1.0     Author: Tim Severien     */          class SimplistSlider {         public function __construct() {             // adding shortcode here             add_shortcode('slider', array($this, 'shortcode'));                  add_action('wp_enqueue_scripts', array($this, 'registerScripts'));         }              public function registerScripts() {             // registers             wp_register_style('simplist-slider', plugins_url('/css/simplist-slider.css', __FILE__), array(), '1');             wp_register_script('simplist-slider', plugins_url('/js/simplist-slider.js', __FILE__), array('jquery'), '1');                  // enqueues             wp_enqueue_style('simplist-slider');             wp_enqueue_script('simplist-slider');         }              public function shortcode($attr, $content = NULL) {             // format content, irrelevant         }     }          function simplist_slider_init() {         $simplist_slider = new SimplistSlider();     }          add_action('plugins_loaded', 'simplist_slider_init');          ?>      * * * **edit #2**   * Please drop whatever your holding in your primary hand   * Look at the palm of your hand   * Continue moving your hand towards your head until they make contact `facepalm();` I screwed up the theme and removed the `wp_head();` function. My sincere apologies! Everything works as expected now.


permalink and $_GET

i create a new post-type called servizi. I customize the permalink for this structure: /%post_id%/%postname%/ But there are a different width post link . For example the post link is www.mysite.it/site-wp/25/postname/ and the servizi's link is www.mysite.it/site-wp/servizi/postname/. I dont't understand what is the trouble . In details page how can take the post_id variable? I use $_GET or i customize my function.php with special function? Someone can i help me please?


Tag list & tag index for custom post type

Wordpress issue: I have a custom post type: `custom-post-type`.               register_post_type( 'custom-post-type', array(       'label' => __('Custom Post Type'),       'public' => true,       'show_ui' => true,       '_builtin' => false, // It's a custom post type, not built in       '_edit_link' => 'post.php?post=%d',       'capability_type' => 'post',       'hierarchical' => false,       'rewrite' => array("slug" => "custom-posts"), // Permalinks       'query_var' => "custom-post-type",       'menu_position' => 30,       'supports' => array('title', 'excerpt', 'editor', 'thumbnail',),       'taxonomies' => array('category', 'custom-taxonomy'),       'has_archives' => true,     ));      I have a taxonomy: `custom-taxonomy`               register_taxonomy(       'custom-taxonomy',       array('custom-taxonomy'),       array(         'hierarchical' => false,         'labels' => array (         'name' => _x( 'Custom Taxonomy', 'taxonomy general name' ),           'singular_name' => _x( 'Custom Taxonomy', 'taxonomy singular name' ),           'search_items' =>  __( 'Search Custom Taxonomy' ),           'all_items' => __( 'All Custom Taxonomy' ),           'edit_item' => __( 'Edit Custom Taxonomy' ),            'update_item' => __( 'Update Custom Taxonomy' ),           'add_new_item' => __( 'Add New Custom Taxonomy' ),           'new_item_name' => __( 'New Custom Taxonomy' ),           'menu_name' => __( 'Custom Taxonomy' ),         ),         'show_ui' => true,         'query_var' => true,         'rewrite' => array('slug' => 'custom-taxonomy', 'with_front' => true),       )     );      I need to be able to create a list of tags based on the tags assigned to `custom-post-type`. I would need each tag to link to an index page for that tag, specific to the custom post type. For example: `\tag\mytag` brings back each post with the tag `mytag`. `\custom- posts\tag\mytag` would bring back each posts of type `custom-posts` with the tag `mytag`. I'm hoping to turn any solution in to a Wordpress plugin. ============================================================= EDIT: Big breakthrough. Wordpress rewrites are a bit of a black-box mystery to me. I was suspicious that rewrite rules may be playing a part in my struggles, but I couldn't get a handle on debugging the rules. In steps The Monkeyman Rewrite Analyzer. This plugin details your Wordpress rewrite rules and lists them all in order of application. Furthermore, you may pass in a path to find out which rules match and in what order. After some tweaks and further investigation, I had changed the rewrite path for the taxonomy to "custom-posts/tag". This put in place the correct rewrite rule, but the rewrite analyzer suggested that `/custom-post/tag/mytag` was matching against post attachments, but the taxonomy rewrite was present further down the list. I tried swapping the order in which I declared my taxonomy and post type, and I changed some of the details such as the taxonomy rewrite rule. With the addition of a dummy taxonomy-custom-taxonomoy.php I have a page that does not 404.               register_taxonomy(       'custom-taxonomy',       array('custom-post-type'),       array(         'hierarchical' => false,         'labels' => array (           'name' => _x( 'Custom Taxonomy Tags', 'taxonomy general name' ),           'singular_name' => _x( 'Custom Taxonomy Tag', 'taxonomy singular name' ),           'search_items' =>  __( 'Search Custom Taxonomy Tags' ),           'all_items' => __( 'All Custom Taxonomy Tags' ),           'edit_item' => __( 'Edit Custom Taxonomy Tags' ),            'update_item' => __( 'Update Custom Taxonomy Tags' ),           'add_new_item' => __( 'Add New Custom Taxonomy Tags' ),           'new_item_name' => __( 'New Custom Taxonomy Tag' ),           'menu_name' => __( 'Custom Taxonomy Tags' ),         ),         'show_ui' => true,         'query_var' => true,         'rewrite' => array('slug' => 'custom-posts/tag', 'with_front' => true),       )     );     register_post_type( 'custom-post-type', array(         'label' => __('custom Post'),         'public' => true,         'show_ui' => true,         '_builtin' => false, // It's a custom post type, not built in         '_edit_link' => 'post.php?post=%d',         'capability_type' => 'post',         'hierarchical' => false,         'rewrite' => array("slug" => "custom-posts"), // Permalinks         'query_var' => "custom-posts",         'menu_position' => 30,         'supports' => array('title', 'excerpt', 'editor', 'thumbnail',),         'taxonomies' => array('category', 'custom-taxonomy'),         'has_archives' => true,     ));      Next I will figure how to make the template display the articles, but I am back in familiar territory! Maybe this won't need a plugin after all!


gallery option is not available in media upload box in costum theme option page

Hi everyone I am creating a theme in which I have to created a sponsor upload image gallery on the admin panel in theme option page and its slide show on the front panel for this I follow tutorial to http://www.webtutes.com created a theme option page on which a wordpress media upload button is there to upload the images and a text box to save the name of the image and the jquery code behind its functionality is as follow * * * `jQuery(document).ready(function($){ $('#upload_logo_button').click(function() { tb_show('Upload a logo', 'media-upload.php?referer=wptuts- settings&type=image&TB_iframe=true&post_id=0', false); return false; });` * * * but it only upload a single image by saving its value in one single option so the question is there a way to create a gallery in media upload box and save the gallery name in one single option and I have only seen the gallery option in media box with pages/post


How can I randomize a Nextgen Gallery Slideshow

Been googling for an hour now can't find the answer to what feels like a simple question. I have a very basic slideshow. I am using the shortcode to load it into the template page. [nggallery id=1] I have also customized the view file gallery.php. Pretty much I just pulled out all the extra stuff and just have the foreach loop. I have tried using the php shuffle on the $images array but that doesn't fix the problem.               shuffle($images);     foreach ( $images as $image ) :      Any other ideas?


What is the correct way to write this conditional statement?

I'd like to remove auto formatting 'wpautop' from specific pages. Here is what I've got, but it doesn't appear to work:               if ( is_page ( 'services' ) ) {     remove_filter( 'the_content', 'wpautop' );     remove_filter( 'the_excerpt', 'wpautop' );     };      I am quite new to php, I have done some research to see how to write this statement, but I have had trouble finding an example that addresses my need. What would be the correct way to write this conditional statement?


What's the most minimal way in which a page can be hooked into WP?

I do a fair bit with custom API's on WordPress-based sites, typically by creating page templates. However, creating a custom page template, then creating a WP Page that utilizes it is kind of a pain (not to mention the ugly names I have to use to keep users from deleting or changing them)*. I prefer the low overhead of plain php files, but then I obviously lose access to WP functions. Is there a better, more MVC-esque way to get custom logic that can call WP functions firing at specific URLs and yet keep it hidden from the admin? *I know I can manually un-register pages from the admin, but this is even more of a pain!


remove class "sub-menu" from wordpress drop down menu

I am building a wordpress website with dynamic wordpress menu + one level drop down menu (sub menu). since my drop down is a bit tricky and required special CSS I tried to remove the styling that wordpress automatically gives to menus by using this code:               function wp_nav_menu_remove_attributes( $menu ){         return $menu = preg_replace('/ id=\"(.*)\" class=\"(.*)\"/iU', '', $menu );     }     add_filter( 'wp_nav_menu', 'wp_nav_menu_remove_attributes' );      The code works pretty fine and removes all the stlying from the UL menu and leave pure UL LI HTML. Now. my drop down is a bit tricky and require special css. I was looking all over the web for an option which removes the **class="sub-menu"** completely from the ul and gives me the option to dynamically wrap this sub menu UL with a special DIV and give it a class (that accomplished using jquery) to try demonstrating what I am trying to accomplish please look at the follwoing HTML:

link

link

link

link

link

link

      explanation:   1. There is a main DIV with a class called: **"navigation"**   2. inside just a simple menu (ul li a)   3. drop down wrapped with a div with a class called: **"sub-nav"**   4. before the ul of the sub menu comes a span tag (that I am echoing using jquery) this is what actually happens:

link

link

link

link

link

link

      I cant get rid of: what so ever. tried many solutions. nothing worked. please help. Thanks, Gil


Slug for custom post type archive

I created a new custom post type 'Projects' and want the archive of all posts of this type to be available at mysite.com/projects. At the moment all project single posts are shown with a slug as follows mysite.com/projects/project- title, but when I go to mysite.com/projects I get a 404. Here is how I built the custom post type:                  /* Create the Project Custom Post Type ------------------------------------------*/      function create_post_type_project()       {     $labels = array(         'name' => __( 'Projects' ),         'singular_name' => __( 'Project' ),         'add_new' => __('Add New'),         'add_new_item' => __('Add New Project'),         'edit_item' => __('Edit Project'),         'new_item' => __('New Project'),         'view_item' => __('View Project'),         'search_items' => __('Search Project'),         'not_found' =>  __('No project found'),         'not_found_in_trash' => __('No project found in Trash'),          'parent_item_colon' => ''       );            $args = array(         'labels' => $labels,         'public' => true,         'exclude_from_search' => true,         'publicly_queryable' => true,         'show_ui' => true,          'query_var' => true,         'capability_type' => 'post',         'hierarchical' => false,         'menu_position' => null,         // Uncomment the following line to change the slug;          // You must also save your permalink structure to prevent 404 errors         'rewrite' => array( 'slug' => 'projects' ),         'has_archive' => true,         'supports' => array('title','editor','thumbnail'),            );             register_post_type(__( 'project' ),$args);         }


"HTTP error" randomly on image uploads

I have been getting "HTTP error." messages seemingly randomly when I upload images. The frustrating part is that if I get the error on an image, then try the same image again a few minutes later, it works. It's hard to debug when it's not consistent. Has anyone else had this problem?


WordPress last login foreach user

Trying to get the last login of each user and display it into the admin panel. Currently I can display the first user within the admin loop, however I can't pull out the remaining users. I think I need to loop through and pull out each user meta_value where it's equal to last_login but I've tried a standard query and its not working. Code is:                   function modify_user_column( $column_name, $user_id ) {          //get current user object         $current_user = wp_get_current_user();                   if( 'last_login' != $column_name ) {                      return get_last_login( $current_user->ID );         }          }     add_action( 'manage_users_custom_column', 'modify_user_column', 10, 2 );      And get_last_login() is:                   function get_last_login($user_id) {             $last_login = get_user_meta($user_id, 'last_login', false);                 $last_login = get_user_meta($user_id, 'last_login', true);     $date_format = get_option('date_format') . ' ' . get_option('time_format');     $the_last_login = mysql2date($date_format, $last_login, false);     return $the_last_login;          }      Thanks


Setting default image size

I'm using WpeMatico plugin which saves images in the post using: `$attach_id = wp_insert_attachment( $attachment, $filename, $postid );` I looked inside `wp-includes/post.php` > `wp_insert_attachment` function, but couldn't quite figure how to resize images. I want ALL/ANY images to have a max size of `1024` resize proportionately. I also have the resizing function, just not sure how to use it. Thanks!


Get shortcode attributes outside shortcode function

I'm writing a slideshow shortcode and need to grab the shortcode attributes in an external function so I can add the javascript to the footer. For example:               add_shortcode('test','test_function');     function test_function($atts) {              extract(shortcode_atts(array(             'arrows' => true,         ), $atts));              return '..............';     }      Now I want to pass the "arrows" attribute into the javascript which I want to include in the footer..               function add_slideshow_js() { ?>         <script>             jQuery("ID").slideshow({                 directionNav : <?php echo $arrows; ?>             });         </script>     <?php }     add_action('wp_footer','add_slideshow_js');      Of course, this is just a very simplistic version.. Can anybody point me in the right direction? Thanks!


How can I get information on who is downloading my plugin? (new to this)

I have a WP plugin that I contracted. We only have a front end developer/designer working on it. No real back end at all, yet. Right now, the only information we have is through the plugin directory. What are some simple solutions for being able to track who is downloading the plugin, who is activating it, and how the found it?


Dump custom post type database

I have a custom post type filled with 7k entries by mistake. I want to empty the database for that custom post type. What is the best way to do it?


How to set a unique WordPress theme for different pages?

I am new to wordpress. I am trying to build a custon website based on it. I know some php and quite good html \ css \ js. I wanted to know if it's possible to set a uinque theme for different pages? Thank you!


NextGen Gallery - automatically create gallery sub page?

In order to use Breadcrumbs NavXT to display the title of a gallery, you need to create a new gallery subpage that the gallery will link to. Is there a way to make NextGen automatically create this gallery subpage named by the title of the gallery?


foundation 4 reveal popup pass a variable

I have an Archive and there is a reveal popup button for "see brief information" on each posts. it's from foundation 4. When you click it shows the brief information of the post. so I need to pass $post_id to reveal popup. How can I make it?
Click to see Brief infomation
      when you click it, it shows brief reveal popup.
          <?php if ($post_id) {?>
<?php _e('Information', 'kcm_fr'); ?>

         <?php // here I need to get the post id to use "get_post or wp-query..";    ?>           Breif information is coming soon!
          <?php }else{ ?>         There is no post id!     <?php } ?>           ×
      How can I pass $post_id to reveal modal? Thanks,


Disable author pages for specific users

I want to disable author pages for certain users, for example the admin user doesn't post anything but still has an author page. Is that possible? Maybe a plugin that adds an option to the users page in the admin panel to enable/disable the author page?


Page-loop is looping content from custom loops on the same site. How to avoid that?

i've made a custom home-page (with a template) and i'm using three loops on this site: two category-loops and on the bottom of the site the main loop for the page (the page content). the problem is: the first loops are fine but the third (the main page loop) is looping the content from one of the other two loops, not from the actual site!?! i think this happens because the main page-loop is the last one on that page. how can i avoid that? here's my code: the first loop:               <?php     $posts = get_posts('category_name=slider');     foreach($posts as $post) :     setup_postdata($post);     ?>         <div class="startslide" style="background-image:url(<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 670,320 ), false, '' ); echo $src[0]; ?>)">
<?php the_title(); ?>

<?php the_content(); ?>

         <?php endforeach; ?>      the second one:               <?php     $posts = get_posts('category_name=meilensteine&numberposts=3');     foreach($posts as $post) :     setup_postdata($post);     ?>

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

<?php echo excerpt(14); ?>

              <?php endforeach; ?>      and the thir one (the main page loop):               <?php if (have_posts()) : ?>              <?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
             <?php the_content(); ?>             <?php endwhile; ?>         <?php endif; ?>


Changing 'view' link for custom post type on list post screen?

How can I change the page that the 'view' action links to on the list post screen for a custom post type? **Update** I've got it to work with normal post types using the below code but where do I define the custom post type?               function change_link($post_url,$post) {         return '/video?id='.$post->ID;     }     add_filter('post_link',"change_link",10,2);


How to determine the depth of a term in a custom taxonomy?

I'm building a `<select>` dropdown to display a list of terms for a custom hierarchical taxonomy. How do I know the depth of each term? I'd like to add some indentation for child-terms (the more deeply they're nested, the more indentation there should be). However I'm not able to retrieve the depth level from `get_terms()`. How to get the depth level as an integer?


Allow user to Edit Posts but not Add New?

For one of my custom post types I want a specific user to be able to edit existing posts created by admin but not be able to Add New posts. How can this be done? If I define the user role as not being able to Publish it still allows them to add a new post and submit for review.


rewrite rules for custom post-type with a custom taxonomy

I have a custom post type ('post' capabilities) called EVENTS and a custom taxonomy called VENUES (hierarchical). I want to be able to set the post's url to domain.com/my- events/%TAXONOMY%/%POST-TYPE% kind of like category/post-name, but it doesn't seem to work, the URL always render the %TAXONOMY% bit as is leaving the % signs.. Any ideas? ps. @John P Bloch, I'm using your plugin.


Require Login Redirect to Login Page

With the following function :               function require_login() {             if ( !is_user_logged_in() ) {                auth_redirect();             }         }      Which action should be used?               add_action('template_redirect', 'require_login');      or               add_action('get_header', 'require_login');      I've always used template_redirect in the past but lately it doesn't seem to always work.


How to cache WordPress posts without using plugins

In a normal PHP page, I can use the following code to save the current PHP page:               ob_start();     // write content     echo '
Hello world to cache
';     $content = ob_get_contents();     ob_end_clean();     file_put_contents($cacheFile,$content);     echo $content;      However, in WordPress, a post/page is loaded by assembling many separate PHP files. So how can I get the whole HTML content of the current post. I'm interested in saving the cache files for the post only (not the page, category, ...). I also don't want to use plugin because I want more degree of flexibility in processing the cached files.


Plugin Form Submission Best Practice

I have done a lot of researching and haven't found quite what I am looking for, so I am hoping that I can be pointed in the right direction. I am developing an Events plugin that will book a ticket from the frontend. This is no different than any other Form submission, but what I am getting confused with is how to handle that from a plugin that is written via OOP with a class. Most articles that I found say to put the $_POST handling within the template page. Ideally I would like to have this handled by a function within the plugin. The other thing that I am not sure about is when you submit the form on the frontend, how that actually gets passed to the function on the backend. I am hoping to completely abstract the form processing from any template details.               // events.php     if ( ! class_exists( 'Events' ) ) {              Class Events {             function __construct() {                 add_action( 'plugins_loaded', array( &$this, 'includes' ), 1 );             }                  function includes() {                 require_once( EVENTS_INCLUDES . 'functions.php' );             }         }     }          if ( class_exists( 'Events' ) ) {         $events_load = New Events();     }               // functions.php     function process_form() {         ...do form processing here...              ...insert booking...     }      I'm not sure what to hook into that would catch that, or where to send the form action too. Thanks for all the help! -Adam


Function to call either single post or category

I'm trying to display content depending on if a user is in a category or a single post. The function i'm using if this is a category is:               <?php if (is_category('')) { ?>      Similarly the function i'm using if this is a single post is:               <?php } elseif (is_single($post)) { ?>      How can I join these 2 functions creating a single function call to say if this is any category OR any single post?


How to enable all Tag Descriptions in loop?

As the title states all I'm trying to do is get the descriptions for all tags inside the loop on my INDEX.php page to show up. I know you can use code to call specific tag descriptions but I want to avoid that if possible since I'll have hundreds of tags all of which I want to show descriptions for. Is there a way to modify the `get_tags` tag in the loop to display descriptions following each tag?


Custom page html headings plugin?

Does anyone know of a plugin that lets you customize the heading area of each page or post with HTML? The heading area I refer to is directly above the main post content. An example is on http://www.woothemes.com/affiliates/ If you look in chrome developer tool or firebug, this div tag is their page- heading, below this is the main content area. For each page on their site it's unique.


How can I confirm I'm on the home page

I have the index.php in themes directory as my homepage. How can I confirm programmatically that the homepage was called in my functions.php? is_home() and is_front_page() is true for other pages and PHP_SELF always shows index.php. [More info] What I'm trying to do is show some Google Web Optimizer Control scripts only on the home page (http://example.com/). The B in the A/B test is index-3 (http://example.com/index-3). But what happens is that if I hit our blog pages (http://example.com/blogs) is_home() and is_front_page() is triggering true causing the script to show in the head. I'm not sure what is causing the blogs page to trigger. I'm using the wp_print_scripts event to trigger my function in the functions.php file. Settings>>Reading is set to "Your latest posts" the home page name is index.php located in the themes directory. So the final question is "Is there a method to know that the function called is for the home page (http://example.com/) and not another?"


Associate an image with a post to show it in a slideshow

I'm building a site with a slideshow at the top of the page. I've got a unique situation in which the post that the image in the slideshow links to is not necessarily in the post itself. There are two requirements:   1. Not all posts should go in the slide show. I need a way to designate a post for display in the slideshow. I was thinking of possibly assigning it a category. The problem with this is that we're already using categories for more traditional reasons. Using categories in this manner seems "hacky" to me, and I'd like to avoid it if possible   2. We need a way to associate an image to the post. This image may not necessarily be in the post itself. I was hoping there was a way to upload an image to a custom field, but I haven't been able to find that yet.  Thoughts? Thanks in advance!


Are there any hooks that alter the 404 logic?

Provided you have a 404 page defined in your theme, Wordpress will display a 404 page if "tag" is defined in $wp_query->query_vars, and there are no posts matching that tag. I'm writing a plugin that displays some information on each page, in addition to posts. I'd like to alter the 404 logic so that the 404 page gets displayed if there are no posts matching a tag _and_ the plugin cannot pull up any data matching that tag. If the plugin can find data, I'd like to show a normal page, regardless of whether there are posts on that page or not ... I've been Googling, reading code, reading the codex, and poking around here, and haven't been able to figure out where Wordpress triggers that 404, and how I can override it. (I have a feeling it might have something to do with status_header() in functions.php, but it's not clear how and when I need to hook into it). Any help/ideas/enlightenment appreciated. Thank you, ~ Patch


Get XAMPP to divert to my site automatically

When I enter my domain name into the web browser, eg. www.mysite.com, xampp automatically diverts to www.mysite.com/xampp How can I change it to go directly to my site folder eg. www.mysite.com/mysite Thanks and Regards


How do I change the text: Click on Event Name for description/registration

I am running Event Registration for the first time on a WP site and would like to be able to edit the phrase that shows up at the beginning of the Event Registration page: > Click on Event Name for description/registration I have searched all the templates but I can't find where that is located. Any assistance in finding that would be appreciated. Thanks.


What is the simplest way to disable multisite leaving one of the sites only?

I developed different versions of a wordpress site using multisite. Now I need to use only the second version out of three, that is blog_id=2 which is also pointed to a mydomain.com/dir2. What is the easiest way to disable multisite while leaving blog_id=2 pointing directly to mydomain.com


Custom Post Type Archives by Date and Taxonomy

Lets use the classic example of a custom post type called "movies", with its own taxonomy called "genre". By registering the custom post type (with a "movie" slug), the permalinks are already set up for               <domain>/movie/action/       ...to see all movies in the action genre. But, archives by date, like               <domain>/2010/09/      ...don't know about the custom post type. The closest date-based archive I'm able to get working is:               <domain>/2010/?post_type=movies      ...which lists all the custom post types posted during the current year (2010). For some reason, the month, taxonomy and a term cannot be added to the URL to get the expected result. What must be done to enable url's like these...               <domain>/2010/09/movie/action/      ...to work as expected, thus to list all action movies posted during September 2010?


Archive widget numbers translation?

I've translated my theme successfully. Yet, there are some part that I couldn't find out how to translate them. I've done a tutorial to Translate or convert WordPress date/time/comment number into my local language successfully. (see the blue arrow in screenshot below) ![translate date and time](http://i.stack.imgur.com/mQfFKm.jpg)   _click to enlarge_ ⤴ **I have some parts that need to also convert/translate such as:**   * The numbers (year) of archive widget; is it possible to convert/translate it into my local language?   * The word (on) in comment widget as well as in comment form; how could I translate it?   * The part that I rounded with red circle; how could I translate them?


How to set limit only on top levels of wp_nav_menu?

How can I set a limit to the **top level** menu items in `wp_nav_menu`? Example: I have this menu in my admin dashboard: ![Example menu](http://i.stack.imgur.com/dVNg9.png) I would like to count **ONLY** the top level items and display a limited number of them, let's say 5. So no matter if you're in the admin dashboard and you have 100's of top levels, it should only display 5. The sub-pages should be displayed as well, normally, without any limit. I searched for an answer here and on the web and I saw this answer but big problem is that this solution counts top and sub-pages altogether and I need to count only top pages. I would like to see some solution with a **custom walker class** if possible or PHP in general and not with CSS and jQuery tricks and hacks.


How to Display a menu only if it has Posts in Custom Menu?

I created a custom taxonomy as category and display it by wp_nav_menu. The problem is, so far there are some terms in the custom taxonomy has no post attached to it, but it still show in the menu. So when people click on the menu link, they will got to a Nothing Found page. How do I display the menu/term that only has post in it in wp_nav_menu?


Making post views as sortable

I am using custom field on wordpress admin posts page by adding the following code and then trying to sort the posts based on post views but the sorting does isn't working. Here is the code I have added in functions.php:               add_filter('manage_posts_columns', 'posts_column_views');     add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2);     function posts_column_views($defaults){         $defaults['post_views'] = __('Views');         return $defaults;     }     function posts_custom_column_views($column_name, $id){         if($column_name === 'post_views'){             echo getPostViews(get_the_ID());         }     }          // Register the column as sortable     function posts_column_register_sortable( $columns ) {     $columns['post_views'] = 'post_views';          return $columns;     }     add_filter( 'manage_edit-post_sortable_columns', 'posts_column_register_sortable' );               function posts_column_orderby( $vars ) {     if ( isset( $vars['orderby'] ) && 'post_views_count' == $vars['orderby'] ) {         $vars = array_merge( $vars, array(             'meta_key' => 'post_views',             'orderby' => 'meta_value_num'         ) );     }          return $vars;     }     add_filter( 'request', 'posts_column_orderby' );               function getPostViews($postID){         $count_key = 'post_views_count';         $count = get_post_meta($postID, $count_key, true);         if($count==''){             delete_post_meta($postID, $count_key);             add_post_meta($postID, $count_key, '0');             return "0";         }         return $count;     }     function setPostViews($postID) {     if (!current_user_can('level_7') ) :         $count_key = 'post_views_count';         $count = get_post_meta($postID, $count_key, true);         if($count==''){             $count = 0;             delete_post_meta($postID, $count_key);             add_post_meta($postID, $count_key, '0');         }else{             $count++;             update_post_meta($postID, $count_key, $count);         }     endif;     }      Now the problem is that I can see the post views in the wordpress admin edit.php page and the volumn Views is also sortable but clicking on Views column doesn't sort the posts based on views. Please help me to solve this problem.


How do i add LIGHTBOX to Attachments?

How do i add the light box function > rel="lightbox" to the code below               <a href="<?php echo wp_get_attachment_url($post->ID); ?>" title="<?php echo wp_specialchars( get_the_title($post->ID), 1 ) ?>"><?php echo wp_get_attachment_image($post->ID, 'large' ); ?>


Use Loop or direct database query?

In one of my form input, the options are a list of posts. I can use the loop to get the posts, but, getting things from database table is faster, right? I see plugins sometimes use db directly, sometimes use loop. I'm confused.


Comments system doesn't like International domains

Morning all, I'm trying to work out why the commenting system thinks .au, .ca and a couple of other international email address are being treating as invalid. Any ideas?


Front-end delete account in Wordpress

is there a way for a registered user in Wordpress to have in his author page an option to **delete** his account along with his posts without going to dahsboard? I need a front-end option in a form of a button for user to be able to delete his profile :) Thank You in advance for Your help guys!


Problem with custom post type search

I built a custom search with the following code: **functions.php**               function template_chooser($template)        {           global $wp_query;          $post_type = get_query_var('post_type');          if( $wp_query->is_search && $post_type == 'products' )          {         return locate_template('archive-search.php');  //  redirect to archive-search.php       }          return $template;        }     add_filter('template_include', 'template_chooser');       **search-archive.php**               <?php             /* Template Name: Custom Search */                     get_header(); ?>

Search Result for : <?php echo "$s"; ?>
                                 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                         <div id="post-<?php the_ID(); ?>" class="posts">

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

<?php the_exerpt(); ?>

<a href="<?php the_permalink(); ?>">Read     More
                              Post By <?php the_author(); ?>                              | Date : <?php echo date('j F Y'); ?>

                <?php get_sidebar(); ?>             <?php get_footer(); ?>      **search form**

Search Products
          <form role="search" action="<?php echo site_url('/'); ?>" method="get" id="searchform">            <input type="text" name="s" placeholder="Search Products"/>            <input type="hidden" name="post_type" value="products" />             <input type="submit" alt="Search" value="Search" />              </form>
      The problem is with that is when I submit an empty search form it shows all posts, but not with the search-archive template. How can I fix that?


Wordpress a template for subcategories fo a given category, but not for root category

I've found this simple yet elegant solution for make Wordpress using the same template category on every child and grandchild categories http://stackoverflow.com/a/3117202/391929 Full code:               function myTemplateSelect() {         if (is_category() && !is_feed()) {             if (is_category(get_cat_id('projects')) || cat_is_ancestor_of(get_cat_id('projects'), get_query_var('cat'))) {                 load_template(TEMPLATEPATH . '/category-projects.php');                 exit;             }         }     }          add_action('template_redirect', 'myTemplateSelect');      But I still have one problem: in my case the root category (on the above example the "projects" category) should not use the that template, but a different one, so I made this simple change in the snippet:               function myTemplateSelect() {             if (is_category() && !is_feed()) {                 if (cat_is_ancestor_of(get_cat_id('projects'), get_query_var('cat'))) {                     load_template(TEMPLATEPATH . '/category-projects-tree.php');                     exit;                 }             }         }      But for some reason this is not working, can anyone see why?


How to share WordPress core library

We have ten blogs running on a little EC2 instances, we want to see if all the blogs can share the same wordpress php code so   1. When I update the Wordpress, all the blogs get updated   2. Save memory in Apache/mod_php as no duplicated scripts or bytecode in the cache (in case of APC). We cant use MU as we need all the blogs in a separate DB, so when later when we need to move them it would be much more easier. Anyone have tried this before?


where to download bb-ratings plugin for wordpress?

Does anyone have any link for bb-ratings plugin ? the one Wordpress.org is currently using for their plugin rating (http://wordpress.org/extend/plugins- plugins/bb-ratings/star.gif) tried this link : http://bbpress.org/plugins/topic/bb-ratings/ but the download link does not work. simply I am looking for a rating plugin (star rating) that works for Google Rich snippets - if you search a plugin name in Google, the result from wordpress.org are shown with voting stars (like this : Rating: 3.6 - 5 votes - Free ) thanks in advance


Hourly WP schedule, do I need at least 1 visitor hourly?

I am planning to schedule an hourly task from my wp plugin, as I understand these tasks are triggered by visits to the website. So for an hourly task I will need at least one visitor hourly. Does it matter at what time of the hour the visitor comes? For example if there's a visitor at 1:05, and another at 2:55, the 1 and 2hs task wont be missed?


I'm trying to upgrade WordPress version of a blog and it fails. I input FTP info (host, user, pass and type) then I get the message: > Unable to locate WordPress Root directory. > > Installation Failed. This blog is running on Windows 2008 Enterprise host.(If it was up to me, no doubt it would be hosted on a Linux server.) My fisrt thought was that it was happening because the path is `E:\home\<host_username>\Web` I can't install or upgrade plugins from WordPress admin either. Does it happen because it's hosted on a Windows server? I've set WP_DEBUG to true on wp-config.php and tried to upgrade again. The following message repeated several times: > PHP Notice: Undefined variable: b in > E:\Home\<host_username>\Web\wordpress\wp-admin\includes\class-wp-filesystem- > ftpext.php on line 334 > > PHP Notice: Undefined variable: b in > E:\Home\<host_username>\Web\wordpress\wp-admin\includes\class-wp-filesystem- > ftpext.php on line 337 I've checked the wp-admin\includes\file class-wp-filesystem-ftpext.php to see what might be wrong on lines 334 and 337. Below is the code from line 334 to 337:               if ( $b['islink'] )       $b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] );          return &b;      The blog in question only has Akismet 2.5.8 active. Jetpack 2.3.3 is there, but it's not active. It's a new blog, started from WP 3.5.2. So definitely plugins must not be the cause of the problem. And of course I know that I can upgrade WordPress uploading files of the new version over FTP. My point is I want to solve the issue of not being able to upgrade WordPress and install/upgrade plugins from its own admin. Any ideas on how to fix it?


Change Site Title and Description html tags if not home page

For the purpose of good HTML structure, accessibility and SEO I'd like to change the site's title and description from H1 and H2 to P when appearing on any page other than the homepage. A conditional statement logic would be something like; when not homepage change site title and description to Site Title and Description . Thanks!


How do I create a random post that will last for a day

How do I create a random post but it shouldnt be change when the page is refreshed I want a random post that will last for a day and after 24 hours or a day, it will change randomly the post , will be that possible? or are there a plugin that exactly does that , actually what Im trying to create is like a "Random Tip For the Day", you know something like that I hope someone understand my question please help,any help will be appreciated.


WordPress wp_nav_menu within iFrame

EDIT 2: How would I iFrame wp_nav_menu contents while maintaining the styles and script associated with their display? (Please ignore all of the below seemingly confusing context of why someone would want to do this.) EDIT 1: This question is related to WordPress's wp_nav_menu. My client is very interested in sculpting their page rank by iframing internal links such as the entire header and footer. I've tried to accomplish this by creating a php file in the root of the site and in it, changing WP_USE_THEMES to false, requiring the wp-blog-header.php file, then calling that wp_nav_menu. This SORTA works, but I'm left with a 404 and the links aren't styled. Is there some elegant way to accomplish this? Just the idea of it feels very hackish and I've been adamant in sharing my thoughts. But maybe there's some SEO guru out there who's done this... ? I hope... ?


How do I create a magazine type menu - sub-menu setup using wp_nav_menu and child of twentyten?

I'm trying to create a menu and submenu with a child theme of twentyten, similar to this at the LA Times: http://www.latimes.com/ where when the site is first opened, it displays a set of childs, and then when other parents are hovered over, other childs are displayed. As I say, I'm trying to achieve this using the custom menu function built into WP 3.0. Thanks for you help.


Requires PHP version 5.3.0

When I try to install "Background Manager" plugin I am getting this error "The plugin "Background Manager" requires PHP version 5.3.0 or better, but version 5.2.17 was detected". Could anyone suggest me how to get rid of this error? Or else suggest me the plugin that suits my requirement. Requirement Display a random image as the website background at each visit or as a timed slideshow.