title: Custom permalinks with custom taxonomy children show 404 error

text: I'm having the following problem. I've made a custom post type which is called **Products**. **Products** has a slug of **"products"**. I've also created two custom taxonomies. One is **Product Category** (which acts as categories) with slug **"product-cat"** and the other one is **Product Application** (which acts as tags) with slug **"app"**. Well my problem is with the children of the Product Category when i add custom permalinks (so don't pay attention to Product Application). Lets say the url that I want to achieve is this               http://website.com/products/product-cat/product-cat-children/postname      But when i'm adding custom permalinks with the plugin **Custom Post Type Permalinks** with that structure `/%product-cat%/%postname%/` i'm getting 404. I tried to save again the permalinks, to add `flush_rewrite_rules` in the register post type, to add `with_front => false` and generally everything from this topic which the guys there have the same problem like me and some other topics but nothing. Any other method that i'm missing? If i leave the custom permalink in its default `/%postname%/` i dont get any 404 but the url is just the postname for the product. `http://website.com/products/postname` I want at least to show the category `http://website.com/products/product-cat/postname` Thank you :) My code for the custom post types is this:               // Products Section     function all_procucts_custom() {              $labels = array(             'name'                => _x( 'Products', 'Post Type General Name', 'text_domain' ),             'singular_name'       => _x( 'Product', 'Post Type Singular Name', 'text_domain' ),             'menu_name'           => __( 'Products', 'text_domain' ),             'parent_item_colon'   => __( 'Parent Item:', 'text_domain' ),             'all_items'           => __( 'All Products', 'text_domain' ),             'view_item'           => __( 'View Product', 'text_domain' ),             'add_new_item'        => __( 'Add New Product', 'text_domain' ),             'add_new'             => __( 'Add New Product', 'text_domain' ),             'edit_item'           => __( 'Edit Product', 'text_domain' ),             'update_item'         => __( 'Update Product', 'text_domain' ),             'search_items'        => __( 'Search Product', 'text_domain' ),             'not_found'           => __( 'Not found', 'text_domain' ),             'not_found_in_trash'  => __( 'Not found in Trash', 'text_domain' ),         );         $args = array(             'label'               => __( 'all_products', 'text_domain' ),             'description'         => __( 'All Products', 'text_domain' ),             'labels'              => $labels,             'supports'            => array( 'title', 'thumbnail', ),             'taxonomies'          => array( 'product-cat', 'app' ),             'hierarchical'        => false,             'public'              => true,             'rewrite' => array('slug' => 'products', 'with_front' => false),             'show_ui'             => true,             'show_in_menu'        => true,             'show_in_nav_menus'   => true,             'show_in_admin_bar'   => true,             'menu_position'       => 5,             'menu_icon'           => 'dashicons-forms',             'can_export'          => true,             'has_archive'         => true,             'exclude_from_search' => false,             'publicly_queryable'  => true,             'capability_type'     => 'page',         );         register_post_type( 'all_products', $args );          }          add_action( 'init', 'all_procucts_custom', 0 );          //Taxonomy for Products --Categories     function taxonomy_for_products_cat() {              $labels = array(             'name'                       => _x( 'Categories', 'Taxonomy General Name', 'text_domain' ),             'singular_name'              => _x( 'Category', 'Taxonomy Singular Name', 'text_domain' ),             'menu_name'                  => __( 'Products Categories', 'text_domain' ),             'all_items'                  => __( 'All Items', 'text_domain' ),             'parent_item'                => __( 'Parent Item', 'text_domain' ),             'parent_item_colon'          => __( 'Parent Item:', 'text_domain' ),             'new_item_name'              => __( 'New Item Name', 'text_domain' ),             'add_new_item'               => __( 'Add New Item', 'text_domain' ),             'edit_item'                  => __( 'Edit Item', 'text_domain' ),             'update_item'                => __( 'Update Item', 'text_domain' ),             'separate_items_with_commas' => __( 'Separate items with commas', 'text_domain' ),             'search_items'               => __( 'Search Items', 'text_domain' ),             'add_or_remove_items'        => __( 'Add or remove items', 'text_domain' ),             'choose_from_most_used'      => __( 'Choose from the most used items', 'text_domain' ),             'not_found'                  => __( 'Not Found', 'text_domain' ),         );         $args = array(             'labels'                     => $labels,             'hierarchical'               => true,             'public'                     => true,             'show_ui'                    => true,             'show_admin_column'          => true,             'show_in_nav_menus'          => true,             'has_archive'                => true,             'show_tagcloud'              => true,             'rewrite'           =>  array('slug' => 'product-cat', 'with_front' => false),         );         register_taxonomy( 'product-cat', array( 'all_products' ), $args );          }          add_action( 'init', 'taxonomy_for_products_cat', 0 );          //Taxonomy for Products --Tags     function taxonomy_for_products_tags() {              $labels = array(             'name'                       => _x( 'Applications', 'Taxonomy General Name', 'text_domain' ),             'singular_name'              => _x( 'Application', 'Taxonomy Singular Name', 'text_domain' ),             'menu_name'                  => __( 'Products Applications', 'text_domain' ),             'all_items'                  => __( 'All Items', 'text_domain' ),             'parent_item'                => __( 'Parent Item', 'text_domain' ),             'parent_item_colon'          => __( 'Parent Item:', 'text_domain' ),             'new_item_name'              => __( 'New Item Name', 'text_domain' ),             'add_new_item'               => __( 'Add New Item', 'text_domain' ),             'edit_item'                  => __( 'Edit Item', 'text_domain' ),             'update_item'                => __( 'Update Item', 'text_domain' ),             'separate_items_with_commas' => __( 'Separate items with commas', 'text_domain' ),             'search_items'               => __( 'Search Items', 'text_domain' ),             'add_or_remove_items'        => __( 'Add or remove items', 'text_domain' ),             'choose_from_most_used'      => __( 'Choose from the most used items', 'text_domain' ),             'not_found'                  => __( 'Not Found', 'text_domain' ),         );         $args = array(             'labels'                     => $labels,             'hierarchical'               => false,             'public'                     => true,             'rewrite' => array('slug' => 'app','with_front' => FALSE),             'show_ui'                    => true,             'has_archive'                => true,             'show_admin_column'          => true,             'show_in_nav_menus'          => true,             'show_tagcloud'              => true,         );         register_taxonomy( 'app', array( 'all_products' ), $args );          }          add_action( 'init', 'taxonomy_for_products_tags', 0 );


title: Taxonimies for custom post types

text: Hy guys, I have some problems with my taxonomies... here my code:                 define('REVIEWS_SLUG', 'review');       define('REVIEWS_CATEGORY_SLUG', 'review-category');            function create_reviews_section(){                                             $labels = array(           'name' => __('Reviews'),           'singular_name' => __('review'),           'add_new' => __('Add New'),           'add_new_item' => __('Add New Review'),           'edit' => __('Edit'),           'edit_item' => __('Edit Review'),           'new_item' => __('New Review'),           'view' => __('View'),           'view_item' => __('View Review'),           'search_items' => __('Search Reviews'),           'not_found' => __('No reviews found'),           'not_found_in_trash' => __('No reviews found in Trash'),         );              register_post_type('reviews', array(                 'labels' => $labels,           'description' => __('Reviews Section'),                 'public' => true,                 'show_ui' => true,                 'publicly_queryable' => true,                 'exclude_from_search' => false,                 'supports' => array('title', 'editor', 'custom-fields', 'excerpt', 'comments', 'author'),                 'rewrite' => array('slug' => REVIEWS_SLUG, 'with_front' => true),                 'query_var' => false,           'taxonomies' => array('review-category')                     )           );           }            function create_review_category(){          $labels = array(           'name' => _x('Review Categories', 'Review Categories'),           'singular_name' => _x('Review Category', 'Review Category'),           'search_items' =>  __('Search Review Categories'),           'popular_items' => __('Popular Review Categories'),           'all_items' => __('All Review Categories'),           'edit_item' => __('Edit Review Category'),            'update_item' => __('Update Review Category'),           'add_new_item' => __('Add New Review Category'),           'new_item_name' => __('New Review Category'),           'separate_items_with_commas' => __('Separate review categories with commas'),           'add_or_remove_items' => __('Add or remove review categories'),           'choose_from_most_used' => __('Choose from the most used review categories'),           'menu_name' => __('Categories')         );               register_taxonomy('review-category', array('reviews'), array(           'hierarchical' => true,           'labels' => $labels,           'show_ui' => true,           'query_var' => true,           'rewrite' => array('slug' => REVIEWS_CATEGORY_SLUG),         ));      First problem is that wordpress doesn't recognize this taxonomy as hierarhical. For example when I generate a dropdown with this taxonomy and depth="1", return all taxonomies (parents & childs). Second problem: when I'm trying to insert a new term (with wp_insert_term) is telling me that the taxonomy it's not valid. Third problem: I thought that child taxonomy url will be like: domain.com/review-category/parent-taxonomy/child-taxonomy/ but in my case is: domain.com/review-category/child-taxonomy/. How I can modify the url to something like that ? Thanks in advance ;) LE:                 add_action('init', 'create_reviews_section');       add_action('init', 'create_review_category', 0);                    $args = array(                                               'show_option_none' => 'Choose make',                                               'hide_empty' => 0,                                               'name' => 'vehicle_category',                                               'id' => 'vehicle_category',                                               'taxonomy' => 'review-category',                                               'hierarchical' => 0,                                               'class' => 'maxw',                                               'depth' => 1                                               );                               wp_dropdown_categories( $args );


title: Ability to download only after email supplied

text: I would like to have a page with downloadable items like PDFs, but I would like the user to be required to insert email details before being able to download the files, although he would be able to view the files available even before providing the email address. The system must also ask only once for the email, and then maybe keep a cookie so that it won't ask for each download requested. Is there a plugin or code hack available for this? Thanks


title: Improving WP_Query performance for multiple taxonomies

text: I have a site with several custom taxonomies, and have found that one of the slowest parts of the site is attempting to query with an OR across several of these at once. I'm using a `WP_Query` like so:               array(       'tax_query' => array(         'relation' => 'OR',         array('taxonomy' => 'tax1', 'field' => 'slug', 'terms' => 'term1'),         array('taxonomy' => 'tax2', 'field' => 'slug', 'terms' => 'term2'),         array('taxonomy' => 'tax3', 'field' => 'slug', 'terms' => 'term3'),         array('taxonomy' => 'tax4', 'field' => 'slug', 'terms' => 'term4'),       )     )      The SQL it generates takes an unacceptable 6 seconds to run:               SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts       INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)      INNER JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id)      INNER JOIN wp_term_relationships AS tt2 ON (wp_posts.ID = tt2.object_id)      INNER JOIN wp_term_relationships AS tt3 ON (wp_posts.ID = tt3.object_id)      WHERE 1=1 AND wp_posts.ID NOT IN (70)      AND (wp_term_relationships.term_taxonomy_id IN (23)        OR tt1.term_taxonomy_id IN (5)       OR tt2.term_taxonomy_id IN (11)       OR tt3.term_taxonomy_id IN (10) )      AND (wp_posts.post_status = 'publish')      GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 500      But this equivalent query takes a much nicer 0.29 seconds:               SELECT SQL_CALC_FOUND_ROWS  wp_posts.* FROM wp_posts     INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)     WHERE 1=1 AND wp_posts.ID NOT IN (70)     AND (wp_term_relationships.term_taxonomy_id IN (23, 5, 11, 10))      AND (wp_posts.post_status = 'publish')     GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 500      Clearly the multiple joins are making it slower than it needs to be. The SQL doesn't care that the terms come from different taxonomies, but `WP_Query` does because they're looked up by slug. Is there any way to persuade `WP_Query` to generate something closer to the second one? (Note the above has been anonymised to protect my client)


title: How can I use the Fresh & Clean theme for blogging?

text: > **Possible Duplicate:**   >  Limited blog support Fresh & Clean theme I'm using the Fresh & Clean theme and I am wondering how to use this theme for blogging. The theme only shows a summary of a post, you can only show the full text by using excerpts which is a very cumbersome way to compose posts. Is there an another to post full text posts using this theme?


title: Using Wordpress to make a "Product Search" type navigation drilldown

text: This is somewhat of a follow-up to a question I asked some time ago: Trying to design nice category drilldown with one "held" taxonomy and a repeatable list of categories I've sort of got a better idea of what I want, but only a vague idea of how to accomplish it and I was hoping to get some feedback. I'm going to be using wordpress as a CMS. Instead of posts with blog-type info, I'd be making Products with a number of shared properties (which I'd assign to taxonomies). I want to create a good search/navigation area for people to be able to find the Product Info/Review that they want. Really something like New Egg (www.newegg.com) has when you try and find a piece of computer equipment you want. Were you go in and start in say the Processor category, and then you can drilldown to what you want. All the posts with the 3GHZ taxonomy. The Search box would adjust then to show all those posts and the remaining taxonomies you could drill down by, socket type, AMD/Intel etc... and have it hold on to those properties as you pass through. I know I can use either cookies or a session to hold the values as I pass down through them, but not entire sure how to approach the rest of the code. I'm looking for any open source examples I might be able to look through where this has been done before that would help me develop something like this for my site. Thanks in advance!


title: Export csv and force download in template page

text:
I'm having trouble trying to build a page that let's someone download a .csv file containing data which is set in a variable from the frontend. My code is below, but the only thing that is happening is that the data is being shown in the page, but there is no prompt to download the .csv file. Can anyone see what the problem might be? Thanks Osu               <?php      /**      * CSV page template      *      */     ?>          <?php get_header(); ?>
                 <?php get_sidebar(); ?>

                 <?php get_template_part( '/loop', 'default' ); ?>
Export
                      <form action="" method="post">                     <input name="submit" type="submit" value="Export">                     <input type="hidden" name="submit" />                 </form>                      <?php                 // Check if form submitted before                 if($_SERVER['REQUEST_METHOD'] == "POST") {                          $fileName = date("d-m-y") . '-bv-directory.csv';                     $content = ""; // content added below                          // Title of the CSV                     $content = "Name,Address,Age,Phone \n";                          // Data in the CSV                     $content .= "\"John Doe\",\"New York, USA\",15,65465464 \n";                          // Create csv and force download                     header('Content-Type: application/csv');                      header("Content-length: " . filesize($NewFile));                      header('Content-Disposition: attachment; filename="' . $fileName . '"');                      echo $content;                 } ?>
           <?php get_footer(); ?>


title: php include not working in custom page

text: ### The Problem I have a `db.php` file which contains mysql login details. I want it in a separate file like this so it can be linked in several different pages for easier tracing later. This all works when not on a wordpress site, but I'm trying to convert everything over to wordpress now and I'm encountering a problem. The below doesn't work (echoes nothing on page), but if I copy the single line from `inc/db.php` into my `page-pricechanges.php` it works. What's the best way for me to link this? * * * ### Structure \THEMEFOLDER   * \page-pricechanges.php   * \header-pricechanges.php    * \inc\db.php * * * ### Page code **header-pricechanges.php**               <head>         <?php               include 'inc/db.php';              //I have also tried include get_bloginfo("template_url")'/inc/db.php';             //I have tried include 'db.php' and put db.php in root of site, root of theme folder.. nothing seems to pick it up.         ?>     </head>      **inc/db.php**               <?php         $con=mysqli_connect("localhost","root","", "dbname");     ?>      **page-pricechanges.php**               $query1 = mysqli_query($con, "SELECT * FROM dbname ORDER BY balance DESC")          or die(mysql_error());     while ($row = mysqli_fetch_assoc($query1))         {             $id = $row['id'];             $name = addslashes($row['name']);             echo $id." ".$name."<br>";         }


title: wp_query select if have comments

text: I previously asked and accepted a similar question here: wp_query and comment_parent - select only posts with top level comments So I'm trying to use wp_query to select only posts that have comments. The problem I'm facing now is I have numerous filters as part of an advanced search e.g. name, location (country, area), tags etc etc and it is becoming to difficult to select post ids in the method shown in the accepted answer. There are just to many possible combinations of searches and options. Ideally I need a way to exclude posts without a comment globally, in one hit. I was hoping for something nice and easy like:                $args = array(            'post_type' => 'films',            'have_comments' => true         );      But I cant seem to find anything like that. I thought maybe a filter in functions.php or with the use of have_comments() somehow? I dont really want to select all posts and hide in the have posts loop if I can help it as there could potentially be hundreds of rows returned in wp_query that are not needed. Sorry, I'm a beginner at this so I'm not really sure of a way forward.


title: How do I retrieve an image's width and height using Advanced Custom Fields?

text: Using a get_field('sampleImage'), how would I go about in order to get the image's width and height using the ACF plug-in? I need to be able to print out the img tag with width and height attributes because of a script.


title: Auto Gallery from folder contents

text: I need to be able if this is possible, (i am a newbie at this so please take that into consideration) I want to create a Wordpress shortcode that will add an automated gallery of the contents in a folder. I am currently trying to implement this to a site that publishes 12 annual magazine issues, so what this would do, is as soon as a new PDF and JPG is dropped into a folder, then it would be displayed on that specific gallery. Meaning: Archive   2013   Jan - Dec Months need to be displayed, in a 4x3 or 6x2 grid gallery   If we are in june, and the latest issue is june, then only 6 jpgs would be displayed. This way the client doesn't need to make any modifications in wordpress site, just drop the files to a specific folder via FTP, and the wordpress php function would auto populate the gallery according to what its able to fetch from that folders content. * * * unfortunately, this plugin is close but not god enough...as it does not read the contents of folders that sit outside the wp uploads folder, and we dont want to migrate the existant folder structure inside wordpress install folder. I also need it to open the links in a new window to the PDF of the magazine, and not a larger version of the picture in fancybox. Help :S


title: Upload in Media Library only shows a part of the picture (incomplete upload)

text: I have a wordpress application wherein I uploaded a picture using the media library. Unfortunately, my problem is that my picture is only uploaded half- way. My connection is fast. Can you give me tips on why is this happening? How to fix this? File type: PNG File size: 48 kB Dimensions: 542 × 437 ![enter image description here](http://i.stack.imgur.com/sPstY.png)


title: 'all' hook and add_action issue (class based plugin)

text: I am currently having a problem with my custom made plugin. It actually logs all the actions/filters fired to a file (or to screen). I need to update my options in the db somehow when submitting the form. Here's the code listing itself:               class WP_Test_Logging_Plugin {          //required for the file name     private $yymmddhhmmss;     private $data;          public function __construct() {         add_action( 'all', array( $this, 'log_to' ) );         add_action( 'admin_menu', array( $this, 'menu' ) );         add_action( 'admin_print_styles', array( $this, 'plugin_theme_style' ) );         add_action( 'template_redirect', array( $this, 'on_admin_form_submit' ) );         $this->yymmddhhmmss = date( 'YMDHis' );         if ( get_option( 'where_to_log_to' ) == false ) {             update_option( 'where_to_log_to', 1 );         }         $this->data = get_option( 'where_to_log_to' );     }      the method I use to process the form               public function on_admin_form_submit() {         if ( isset( $_POST['selection'] ) ) {             update_option( 'where_to_log_to', $_POST['selection'] );         }     }      Is there a way to go about it? Thanks!


title: How to use next_posts_link/previous_posts_link for custom post types paginate?

text: I have a question about usage of previous_posts_link/next_posts_link. Is it possible to use it for custom post types too? I like to hear from you. Thanks in advance. Casper


title: why the wp_register_script doesn't work for register_activation_hook

text: I want to register a script when my plugin is activated. So I wrote:               register_activation_hook(__FILE__, 'register_script');     function register_script(){        wp_register_script('addjs','http://example.com/exmple.js');     }      Next, I created a meta box and enqueued the script in the `add_meta_boxes` hook:               wp_enqueue_script('addjs');      But that doesn't work. Why? My js file is just a simple alert function. However, when I register my script using init hook or other hook, my code works - why?


title: Get all post attachments except featured image

text: $args = array(         'post_type' => 'attachment',         'numberposts' => null,         'post_status' => null,         'post_parent' => $post->ID     );     $attachments = get_posts($args);     if ($attachments) {         foreach ($attachments as $attachment) {             echo apply_filters('the_title', $attachment->post_title);             the_attachment_link($attachment->ID, false);         }     }      In the code above, theres exist a way to get:   1. All attachments links except featured image.   2. All PDF attachments links only. I was reading:   * http://www.wprecipes.com/how-to-show-wordpress-post-attachments   * http://johnford.is/programmatically-pull-attachments-from-wordpress-posts/


title: Differences Between WP_Query() and get_posts() for Querying Posts?

text: What are the differences between using `WP_Query()` and `get_posts()`? Which is better to use in what case and why?


title: Plugins to Enable Subscriptions of Digital Assets?

text: (@mikeschinkel: Before edit title was: _is there a plugin/set of plugins for providing subscription to digital assets on an individual or large scale?_ ) I'm trying to set up a site where a substantial amount of PDFs will be sold both individually and a subscription will be sold to a library - so anyone from that library can visit the site without a paywall (so, based on IP). does anything exist for wordpress like this? bonus points if its free/open-source and not paid...


title: Best way to strip the_content of html on the front end?

text: What is the best way to strip *the_content* of html tags and needless spaces on the front end? I'm building a special use theme that needs to allow users who can edit_post to make changes on the front end, but I only want this text area to support plain text. My current code:               <?php if ( !current_user_can( 'edit_post', $post_ID ) ) : the_content('Read more on "'.the_title('', '', false).'" »'); else: ?>             <textarea class="grid_22">                     <?php the_content('Read more on "'.the_title('', '', false).'" »'); ?>             </textarea>     <?php endif ?>      produces this: ![the_content wrapped in a textarea tag](http://i.stack.imgur.com/muQWg.png) How can I make it look like normal text? Users who edit copy on the front end will not use the backend WYSIWYG editor so I don't have to worry about formats being over written.


title: wpdb_prepare with multiple or condition

text: I want to execute a query like this:               $wpdb->prepare( "SELECT * ... from ... WHERE ( post_title LIKE '%%%s%%' or post_content LIKE '%%%s%%' )..., $string );      If I do the query with only one condition it works:               $wpdb->prepare( "SELECT * ... from ... WHERE ( post_title LIKE '%%%s%%' )..., $string );      What is the error in my first query?


title: Plugin for automated upgrade of WordPress core and it's plugins?

text: **Is it possible to get your WordPress site to upgrade itself automatically?** What I mean is, when plugins etc. needs to be upgraded, can you just press a button, or have a cron job, download the new update and handle whatever else is needed, so your WordPress site always is up to date?


title: Show single Child Category on Custom Post

text: Am hoping someone can help me pull out a single custom category name and show it on my custom post page. I've created a new custom post type 'Itinerary' as well as some new custom categories (terms): Experience   * Water Sports   * Hiking Adventures   * Mountain Biking ... Destination   * Australia   * Canada   * South America ... Each Itinerary has 2 categories applied to it, for example: Itinerary 'Coastal Walks' is categorised as Hiking Adventures and Australia. I would like to display in my single itinerary page the name of the child Destination e.g. Region: Australia (or whatever child destination is selected) I've tried using this:               <?php echo the_terms( $post->ID, 'trip_cat', 'Region: ', ', ', ' ' );   ?>      but this displays all the categories selected - I'm trying to display only the child of category Destinations. Can anyone please help? :)


title: wp_list_authors including custom post types

text: I am using wp_list_authors function to list all the users in my blog, however it doesn't display the users who wrote custom post types. it only displays the users who wrote regular posts. Is there a way of displaying all the users who wrote posts and also including the users who wrote custom post types in the same list? I was looking for such answer and could not find it anywhere on the web. any help will be appreciated Thanks, Gil


title: Downloads manager plugin

text: We're looking for a plugin which lets a user upload files in the admin UI, categorise them and then output a nice categorised list on a page with a sidebar widget to show new downloads. We've spent a fair while googling and not come up with much. This one says it should do what we want, but doesn't. http://wordpress.org/extend/plugins/downloads-manager/ Any suggestions?


title: Cannot modify headers

text: I absolutely hate this error. And do not understand it at all. So this is my code, what you want to focus on is the foreach loop:               public function reset_theme_options(){         if($this->is_theme_options_array()){             foreach($this->_theme_option['admin_options'] as $option_name=>$value){                 if($value != false){                     delete_option($option_name);                     $http = new AisisCore_Http_Http();                     wp_safe_redirect($http->get_current_url());                 }             }             $this->_update_option();         }else{             $this->_theme_option = array();             $this->_update_option();         }          }      Essentially all I am doing is getting the name of the options, so lets say you store all your options for your theme in 'My_theme', which is an array of settings. All I do is take that and delete it - it works as is. The problem is that I am then essentially (from `wp_safe_redirect()`) refreshing the page, I could do this through javascript and such but I think this way is better. So everything works, I get my success message, the options are reset with the following hitch: > Warning: Cannot modify header information - headers already sent by (output > started at /var/www/wordpress/wp-admin/menu-header.php:94) in > /var/www/wordpress/wp-includes/pluggable.php on line 876 Ok so I click the reset button again and everything works as it should. My steps in this error are: (first start with a clean slate, no options saved) - save some options, hit submit. Then after the page refreshes, click reset, boom error, options still saved, click reset again, boom options reset. Help?


title: Displaying terms by first letter

text:
I run a book review blog and I have multiple pages that lists the reviews by different things (rating, book title, and author) I have custom taxonomy for authors and I basically have my code list all the terms that have posts in them, then list the posts. They're all in alpha order by the first letter. What I want to do is have it grab the first letter and section everything off that way. Right now it looks like: **Bray, Libba**   * Beauty Queens **Elkeles, Simone**   * Chain Reaction and I want it to be like **B** Bray, Libba   * Beauty Queens **E** Elkeles, Simone   * Chain Reaction So basically just displaying the terms as I have it, but having a section for each letter THEN display the terms starting with that letter, then listing the posts.               <?php     $taxonomy = 'authors';//  e.g. post_tag, category     $param_type = 'authors'; //  e.g. tag__in, category__in     $term_args=array(       'orderby' => 'name',       'order' => 'ASC'     );     $terms = get_terms($taxonomy,$term_args);     if ($terms) {       foreach( $terms as $term ) {         $args=array(           "$param_type" => $term->slug,           'post_type' => 'reviews',           'post_status' => 'publish',           'posts_per_page' => -1,           'caller_get_posts'=> 1,           'meta_key' => 'booktitle',            'orderby' => 'meta_value',           'order' => 'ASC'           );         $my_query = null;         $my_query = new WP_Query($args);         if( $my_query->have_posts() ) {                echo '
'.$term->name.'
';           while ($my_query->have_posts()) : $my_query->the_post();        ?>             <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php echo c2c_get_custom('booktitle'); ?> by <?php echo c2c_get_custom('author'); ?>
            <?php           endwhile;         }       }     }     wp_reset_query();  // Restore global post data stomped by the_post().     ?>


title: Automatically create a default set of posts for each new registered user

text: Is there a plugin, or a way to automatically create a set of default posts for a new user when they register? I suspect that the answer might be to hook into the existing wordpress events - can anybody suggest a way to get started?


title: get comment data using comment id

text: I am using the `get_comments()` function which works well if I give it any array of parameters except if I give the following array:               $defaults = array('ID' => $comment_id);           $com=get_comments($defaults );      The resulting array contains all data for all comments of my website. I want to get only the data of the comment with id = $comment_id. Thank you for your feedbacks.


title: Prevent Admin user to edit/see super admin from users list

text: How do I hide my super admin from the users list? My client has to be the ability to create users, but not edit/see my super admin user. Is that possible?


title: Returning error with WP Insert without getting an error in error log

text: I'm checking if a key exists in my database using $wp_db->insert() and am executing code based on the result. I know that if a row already exists it will return false and I want to use that to execute some code. However when a row exists it will also write to the debug log and will note that it couldn't insert because there was a duplicate entry with the same key. The exact error writes, "WordPress database error Duplicate entry '5' for key 'PRIMARY'". Can I find out if the row has been added previously without getting this error? I know I can alternatively check if there is a row before trying to insert but I would like to try for it to work this way. Code               foreach ($users as $user) {         $result = $wpdb->insert($table, array(             'id' => $user->ID         ));         if($result != false){         echo 'Already Added';         }     }


title: Is wordpress written in MVC pattern?

text: Is WordPress written in MVC architect? How to understand a CMS is a MVC? A CMS that written in MVC must have directories with named "Model", "Controller", "View"? Sorry for my beginner question .


title: Execute shortcode within shortcode

text: I am using this plugin: http://wordpress.org/extend/plugins/worldcurrency/ Shortcode syntax:               [worldcurrency cur="EUR" value="25"]       However, I'm using Advanced custom fields and the shortcode for custom fields is not being executed within the shortcode for worldcurrency.               [worldcurrency curr="[acf field="fl_currency"]" value="25"]      Any remedies here? **Update**   I think I need to be using the               add_filter('xx','do_shortcode');      somehow?


title: How Can A Widget With Only One Instance Be Defined?

text: How can a widget which of which only one instance can be used?


title: What's the best way to create a theme friendly custom post type archive?

text: I have an events post type in a plugin I use for multiple Wordpress installations, so I'm looking for a way to implement an archive page for the event and a single page. I came across some ways of do this one, but it ruins half of my themes. What is the best way to create an archive page, so that it works in most themes?


title: From a security standpoint, should bloginfo() or get_bloginfo() be escaped?

text: I've been reviewing a lot of information about WP theme and plugin security and understand the concept that you should escape attributes and HTML values in themes and plugins. I've seen `bloginfo()` and `echo get_bloginfo()` used both standard and inside an `esc_html()` or `esc_attr()` function. _**Genesis_** and **__s_** , Automattic's base theme both escape these values but WP's own codex theme standards guide does not say anything about escaping these values. I've looked into the WP code (`wp-includes/option.php`) and it seems like that there's a little sanitization of values passed from `get_option()` but it also looks like there's a filter that a plugin could overwrite for certain values. It's this fact that leads me toward thinking that it should be escaped. Can anyone enlighten me on this?


title: Wordpress get_avatar function not correct working

text:
My code doing this, listing which author have posted in the current category. But get_avatar function not correct working. Im Using Simple Local Avatar Plugin. It is working author.php don't have any problem. But when i use it my this code, it is listing same and wrong author picture(My latest author picture. You can look this picture) My Code:               <?php if (is_category()) {     $current_category = single_cat_title(“”, false);     $author_array = array();     $args = array(     'numberposts' => -1,     'category_name' => $current_category,     'orderby' => 'author',     'order' => 'ASC'     );     $cat_posts = get_posts($args);     foreach ($cat_posts as $cat_post) :     if (!in_array($cat_post->post_author,$author_array)) {     $author_array[] = $cat_post->post_author;     }     endforeach;     foreach ($author_array as $author) :     $auth = get_userdata($author)->display_name;     $autid= get_userdata($author)->ID;     echo get_avatar( get_the_author_email(), '32' );     echo "";     echo $auth;     echo "";     echo "
";     endforeach;     }?>


title: special XML to wordpress posts

text: I've got a difficult one: One of our customers have lots of XML files and wants to be created as posts for SEO reasons. How can I import XML and convert them to posts automatically? I've seen plugins but it's way to much time to just import a serie of XML files with multiple rows. How is the structure in the XML:               <Row>     <SRI_ID></SRI_ID>     <Author></Author>     <Mailing_Address></Mailing_address>     <Title></Title>     <Abstract></abstract>     <Source></Source>     </Row>


title: Is it possible to pass variables from add_user_page?

text: If have hooked into admin-menu like this:               function adminmenu_users_reserves(){             add_users_page('Reserver', 'Reserver', 'read', 'reserve_list', 'show_userlist');     }     add_action( 'admin_menu', 'adminmenu_users_reserves' );      and have a function               function show_userlist(show_reserves = true, $title) {        code...     }      Can I pass variables `$show_reserves` FROM `add_users_page()` somehow? (In one case I need `$show_reserves` to be true, in other case I need it to be false) Or would I have to solve my issue with two different functions like this? (for almost the same functionality)               function adminmenu_users_reserves(){             add_users_page('Reserves', 'Reserves', 'read', 'reserve_list', 'show_reservelist');     }     add_action( 'admin_menu', 'adminmenu_users_reserves' );          function adminmenu_users_registered(){             add_users_page('Registered', 'Registered', 'read', 'registered_list', 'show_registeredlist');     }     add_action( 'admin_menu', 'adminmenu_users_registered' );      **UPDATE** Because I've got such a great answer from toscho (http://wordpress.stackexchange.com/users/73/toscho) I want to share my solution - if someone else has the same issue in the future:               class userList     {         public $show_reserves = false;         public $title = 'Reserver';              //Show a list of all reserves/or registered users in the system ordered by register-date         function render() {                  $reserves = $this->show_reserves;             $title = $this->title;                          echo $title;             if ($reserves === true) {                 ....code...             }          }     }          function adminmenu_users_reserves(){             $userlist = new userList();         add_users_page('Reserver', 'Reserver', 'read', 'reserve_list', array( $userlist, 'render' ));     }     add_action( 'admin_menu', 'adminmenu_users_reserves' );          function adminmenu_users_registered(){             $userlist = new userList();         $userlist->show_reserves = false;         $userlist->title = 'Anmälda';         add_users_page('Anmälda', 'Anmälda', 'read', 'registered_list', array( $userlist, 'render' ));     }     add_action( 'admin_menu', 'adminmenu_users_registered' );


title: Posts 2 Posts Custom Admin Box Functionality

text: I’m using Posts 2 Posts plugin to connect 3 CPTs - Speaker, Session and Event. A user can create a new Session from the Event editor, but that only allows them to specify a title. I’d like them to be able to add the Session with all associated meta fields. I've read the "roll your own admin box". I can build a custom meta box that will display connected posts, but recreating the remaining functionality is where I'm stuck. Is there a way to tie into P2P's js/ajax, or does that need to be custom? I see how to create connections programmatically, but that's only one piece. I'm not looking for code, but an overview or 'roadmap' of the necessary steps would be very helpful.


title: Front End User(bloger) turn on and off his comments

text: I have a wordpress site with bunch of users, each of them having their own page with comments. I would like to implement a checkbox for users on the front end, to turn(toggle) on and off the comments. I know I can do it myself from the back end individually for each user page, but I need to let them to get their option. In another words....is that possible to make a clone of that checkbox(from the admin panel) with the same functionality on the front end(on the user page)? Can I have any idea on how to implement this? I will appreciate any help for this. Thanks


title: Filter Posts from the Main Query

text:
I want to conditionally merge a custom post type with my posts post type, based on a custom field. If the field's value is 1, then I want I need those custom posts to appear in the same loop as posts on the home page. I can combine the custom post type with the default posts post type, and I can create an array of post IDs to exclude with `post__not_in`, but I can't figure out how to apply that to the main loop. Here's my code for the index.php template below:               if (is_home()) {         $exclude = array();         $newsQuery = new WP_Query (array(             "post_type"      => "news",             "meta_key"       => "post_to_blog",             "meta_value"     => 1,             "meta_compare"   => "!=",             "posts_per_page" => "-1",         ));         while ($newsQuery->have_posts()) {             $newsQuery->the_post();             array_push($exclude, get_the_ID());         }         wp_reset_query();     }     if (have_posts()) {         while (have_posts()) {             the_post();             get_template_part("content", get_post_format());         }     }     if ($wp_query->max_num_pages > 1) {         echo "
";         kriesi_pagination();         echo "
";     }      And here's what I'm doing to show the custom post type in the main query in functions.php:               function custom_home_loop($query) {         if ($query->is_main_query() && is_home()) {             $query->set("post_type", array("post", "news"));         }     }     add_filter("pre_get_posts", "custom_home_loop");      Is there a way for me to merge these two? I'd like to do something like `$query->set("post__not_in",$exclude);`, but that doesn't work when I try it. No error, the posts just keep showing up. I tried moving the `$exclude` code in to the `custom_home_loop` function, but I keep getting a memory overflow error for some reason.


title: Filter categories used with Custom Structure Permalink

text: I'm using a "Custom Structure" permalink setting:               http://mysite.com/%category%/%postname%/      However, when the post belongs to uncategorized, or to more than one category, this produces unwanted URL structures. Basically, I want to find out if I can run a filter on this so that "Uncategorized" and any child categories of Uncategorized are removed from this URL pattern. Appreciate any help you can provide.


title: WordPress site displaying 404 for any page apart from index

text: My WordPress site is returning a 404 not found error on any page apart from the homepage and /wp-admin. I have no absolutely no idea why this is. My Permalinks are set up to use `/year/month/date/post-title/` (e.g `www.domain.com/2014/04/28/sample-post/`). When I change the permalinks to the default (`?p=123`) it works fine, but not on any of the other ones. Here is the contents of the `.htaccess` file:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>      I have also installed the plugin 'Debug This', which provides details on the Rewrite Rules. However because it's a pretty big list and unformatted it would look quite bad, I've put it in a jsfiddle, here: http://jsfiddle.net/k8PHD/embedded/result/ I think that's all the details I have, I've disabled all plugins and stuff like that. Thanks for any help. EDIT: ok so I've since discovered a bit more info. I also forgot to say that the host for the site is Heroku (I'm building for a client and for some reason he's insisting I use Heroku, which is bad choice for WP I know but I can't persuade him otherwise so that's life). I recently installed `heroku- buildpack-php-tyler`, which also installed Nginx. So I'm assuming that's whats broken my Permalinks. I then found this post, which seems to be about the issue I'm having, which links to this page on the Nginx Documentation. Problem is I've never used Nginx before so I don't know where to put all the code it's got in the first section entitled Abridged Basic Setup. Can someone help me out? Thank you :)


title: Accidentally messed up URLs

text: So I installed WordPress on my Apache server and I changed the URL in the WordPress Admin Control Panel to `http://website.com/` from `http://website.com/wordpress` and now it's taking me to my old `index.html` I made before I installed WordPress, even though I moved all my old stuff to a backup folder. Now I cannot get back into my WordPress admin CP. So my question is: How do I switch the URLs inside the WordPress files instead of the Admin CP (Cause I cannot get to it). How do I make the WordPress url to `http://website.com/` instead of `http://website.com/wordpress`? P.S. I didn't include http:// on the links because I can't post more than two links with my rep.


title: Use the same taxonomy twice on the same post type?

text: Hello there basically I am quite good with WP however it is not easy for me to find a solution to this problem:   * There is an taxonomy which will consist of hundreds and mayby thousands of items. This taxonomy is called "Stones".   * There is a custom post type called "item" (for sale) which consists of 1..n "stones" in the "main part" and of 1..n "stones" in the "additional part" In other words **the same taxonomy** should appear using **different labels** for the **same post type twice** (Stones contained in the main part and stones contained in the additional part). Of course it would be easy just to create two different custom taxonomies, but the challange here is that the items of the two taxonomies should be identical and should be identically inserted / updated / deleted. Can somebody think of an solution for this?


title: put the content of a single post into og:description

text: I'd like to have the content of the current single post loaded into the og:description meta property - but the `'. $content .'` doesn't output anything? This is what's in my header.php               if (is_single()) {          $content = get_the_content();     $desc='<meta property="og:description" content="'. $content .'" />';     echo $desc;     }      What could the problem be?


title: TinyMCE strips content while pasting. Possibly a bug

text: I have a shortcode that has a 'style' attribute for a theme that I'm creating, which looks like this:               [shortcode_name type="normal" style="fixed"]      Now if I paste this in the TinyMCE editor, I get this:               [shortcode_name type="normal"]      So it's stripping away the entire style attribute, and it does this only if I have a value for the style attribute, so it works fine if I paste this:               [shortcode_name type="normal" style=""]      I think this is related to the new feature of TinyMCE 4.0 that now supports the formatting of where the text was copied. Any way, please let me know what's wrong here, and what should I do about it. Thanks. **Edit:** Also, this is nothing to do with the shortcode. Even if I try pasting something like this:               foo style="sfdf" bar      Only this gets pasted:               foo      This is very weird. Can someone please try the above and tell me if I'm the only one with this?


title: Wordpress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)

text: I have some code that uploads a file. I've tried both `wp_handle_upload` as well as regular PHP code and with both, it will claim it uploaded the files (`wp_handle_upload` returns an array with "url" and "file" filled) but the files are not in the folder! **NOTE: This is called via an "wp_ajax_nopriv_" function**               $uploadedFile = wp_handle_upload( $_FILE[ "thefile" ], array( "test_form" => false ) );          //It makes it past this     if ( !$this->isUploaded( $uploadedFile ) ) return false;          $filePath = $uploadedFile[ "file" ];     $fileType = wp_check_filetype( basename( $filePath ) );          $attachmentInfo = array(         "post_mime_type" => $fileType[ "type" ],         "post_title" => $title,         "post_status" => "inherit",         "post_content" => ""     );          $attachmentId = wp_insert_attachment( $attachmentInfo, $filePath, $postId );     if ( $attachmentId === 0 ) return false;     $attachmentData = wp_generate_attachment_metadata( $attachmentId, $filePath );     if ( wp_update_attachment_metadata( $attachmentId, $attachmentData ) === false ) return false;          return true;      **Pure PHP uploading works, it's only through wordpress that it won't upload!** Here's the code that works (but **only** if called outside WordPress):               if ( $_SERVER[ "REQUEST_METHOD" ] === "POST" )     {         foreach ( $_FILES as $file )         {             //This is never called             if ( $file[ "error" ] !== 0 ) throw new Exception( "Error: " . $file[ "name" ] );              $index = 0;         while ( file_exists( "/var/www/wp-content/uploads/" . $index . $file[ "name" ] ) ) $index++;         $name = "/var/www/wp-content/uploads/" . $index . $file[ "name" ];         move_uploaded_file( $file[ "tmp_name" ], $name );         }     }


title: Settings in 'Media > Settings' is ignored when inserting images

text: When I upload an image, it is automatically resized as I would expect, however the sizes for inserting the image seem to ignore the settings I've placed in Settings/Media. In my media settings I have:   Thumbnail: **150 x 150**   Medium: **300 x 300**   Large: **690 x 9999** I upload an image of: **2226 x 1663**.   Wordpress generates the correct image sizes, but gives me the following options for insertion: Thumbnail: **150 x 150** (as expected)   Medium: **300 x 224** (as expected)   Large: **640 x 447** (WTF?!) I looked on the forums and found a suggestion that I add the following to my functions.php file:   **update_option('large_size_w', 690);**   However, this did not work.


title: How can I set a meta value that will then affect other post meta values?

text: I have a metabox on my post type of 'ebrd_videos' that sets the video as a 'featured video' using a checkbox. I would like to limit the number of videos with the status of 'featured = on' to 1. So that when I set a video as featured, and publish/update that video, all other videos are set to 'featured = off'. If it helps, here is the code to create the meta box:               // Add the Top and Featured News Meta Boxes ----------------------------------------//          add_action( 'add_meta_boxes', 'ebrd_add_post_metaboxes' );          function ebrd_add_post_metaboxes() {         add_meta_box('ebrd_feat', 'Post status', 'ebrd_feat', 'ebrd_videos', 'side', 'default');     }          // Featured Metabox          function ebrd_feat(){         global $post;         $custom = get_post_custom($post->ID);         if(isset($custom["ebrd_home_feat"][0])) $ebrd_home_feat = $custom["ebrd_home_feat"][0];         else $ebrd_home_feat = 'off';              // We'll use this nonce field later on when saving.           wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );      ?>          <input type="checkbox" name="ebrd_home_feat" <?php if( $ebrd_home_feat != 'off' ) { ?>checked="checked"<?php } ?> />  Home feature?     <?php     }           add_action('save_post', 'save_details');          function save_details($post_ID = 0) {         $post_ID = (int) $post_ID;         $post_type = get_post_type( $post_ID );         $post_status = get_post_status( $post_ID );              // if our nonce isn't there, or we can't verify it, bail          if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;              // if our current user can't edit this post, bail           if( !current_user_can( 'edit_post' ) ) return;               if(isset($_POST["ebrd_home_feat"])) $ebrd_home_feat = $_POST["ebrd_home_feat"];         else $ebrd_home_feat = 'off';              if ($post_type) {             update_post_meta($post_ID, "ebrd_home_feat", $ebrd_home_feat);         }        return $post_ID;     }


title: How does one programmatically manage posts from a external php script?

text: How does one create a post, assign it to a category, add tags to it and set the featured image from a PHP script that exists somewhere on disk (say /usr/local/process.php) and isn't part of the Wordpress installation or infrastructure? I searched for a couple of hours and can't find anything particularly useful. The only thing I'm stuck on is how to create the POST and add its metadata. The rest (like getting the images, extracting the caption etc) is already done. **Background** I'd like to automate the process to create posts for images I have. Unlike traditional import stuff, I'd like to replace images and update their posts and metadata if they already exist. The latter is important since I manage all my image metadata in Aperture. Every image has a unique name in the form of AAA99999999 and versions (such as a B&W and cropped) of images may have the format "AAA99999999 - Version NNN". If possible, I'd like to indicate that the posts of say "AAA99999999" and "AAA99999999 - Version 1" are related. I have about 2000 photos I'd like to import. I'd like to use the script in the future to add and update new images.


title: Permalink opens attachment instead of page

text: I recently moved a blog from one host to another and now have a problem with a permalink - rather than opening up a page, it now opens an attachment. The blog is using WP 3.0.4, running on PHP 5 and IIS 7.0. The permalinks are set to use "/%postname%/" and the web.config is as suggested in the Codex. The blog was moved using the WP export and import tools. Previously http://site/blog/map opened up a page called map, but it is now opening http://site/blog/?attachment_id=xx. Does anyone know how to change this behaviour? Thanks, Jon.


title: Wordpress on a local machine redirecting to online url

text: i've downloaded a wordpress web to my local machine and tried setting it up. the problem: when trying to login, wordpress will always redirect to the online url. the only way i found was changing the siteurl manually in phpmyadmin to my local machine's ip address. is there a better solution? the problem about doing that is that permalinks won't work anymore locally. thanks


title: How to select a page within admin?

text: How does one apply an action to one particular page within admin? I've added a bunch of wysiwyg editors to one page ("Home") and now I don't need the main editor. But the function below - of course - removes the editor from all pages:               function remove_editor_from_home_page() {            remove_post_type_support( 'page', 'editor' );     }          add_action( 'init', 'remove_editor_from_home_page' );      How can I target the Home page within admin by name - "Home" - or by page_id? This other WPSE answer doesn't want to work for me: Target a certain page within wordpress backend


title: Wordpress subpages to custom post types

text: I have created a CPT like this:               add_action( 'init', 'create_media' );     function create_media() {       $labels = array(         'name' => _x('Media', 'post type general name'),         'singular_name' => _x('Media', 'post type singular name'),         'add_new' => _x('Add New', 'Media'),         'add_new_item' => __('Add New Media'),         'edit_item' => __('Edit Media'),         'new_item' => __('New Media'),         'view_item' => __('View Media'),         'search_items' => __('Search Media'),         'not_found' =>  __('No Media found'),         'not_found_in_trash' => __('No Media found in Trash'),               'parent_item_colon' => __( 'Parent Media' )       );            register_post_type( 'media',         array(           'labels' => $labels,           'public' => true,           'rewrite' => array('slug' => 'media'),           'capability_type' => 'page',           'hierarchical' => true,           'supports' => array( 'title', 'revisions' )         )       );     }      In my CPT, I have a custom taxonomy, created like that:               add_action( 'init', 'create_mediatype' );     function create_mediatype() {      $labels = array(         'name' => _x( 'Media types', 'taxonomy general name' ),         'singular_name' => _x( 'Media type', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Media types' ),         'all_items' => __( 'All Media types' ),         'parent_item' => __( 'Parent Media type' ),         'parent_item_colon' => __( 'Parent Media type' ),         'edit_item' => __( 'Edit Media type' ),         'update_item' => __( 'Update Media type' ),         'add_new_item' => __( 'Add New Media type' ),         'new_item_name' => __( 'New Media type Name' ),         'menu_name' => __( 'Media types' ),       );                register_taxonomy('mediatype',array('media'),array(         'hierarchical' => true,         'labels' => $labels,         'show_ui' => true,         'query_var' => true,         'rewrite' => array( 'slug' => 'media' ),       ));     }      I have 3 types of taxonomy: Photos, Videos and Audios. What is best way to set up to obtain subpages for each category like this: .../media/photos .../media/videos .../media/audios I've tried to create a page for each with a template page allocated and by setting media as parent. But this doesn't work. Thanks


title: Permalink Problems

text: I am having a problem. I am running WP 3.05 with one custom taxonomy. Here is the code to create the taxonomy:               function create_property_taxonomies()      {       // Add new taxonomy, make it hierarchical (like categories)       $labels = array(         'name' => _x( 'Property Types', 'taxonomy general name' ),         'singular_name' => _x( 'Property Type', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Property Types' ),         'all_items' => __( 'All Property Types' ),         'parent_item' => __( 'Parent Property Type' ),         'parent_item_colon' => __( 'Parent Property Type:' ),         'edit_item' => __( 'Edit Property Typee' ),          'update_item' => __( 'Update Property Type' ),         'add_new_item' => __( 'Add New Property Type' ),         'new_item_name' => __( 'New Property Type' ),         'menu_name' => __( 'Property Type' ),       );                register_taxonomy('property_type',array('sbproperty'), array(         'hierarchical' => true,         'labels' => $labels,         'show_ui' => true,         'query_var' => true,         'rewrite' => true,       ));     global $wp_rewrite;         $wp_rewrite->extra_permastructs['property_type'] = array('%property_type%', EP_NONE);     }      I have used the extra permastruct so the taxonomy just appears on the base url like site.com/taxonomy-slug instead of site.com/taxonomy/taxonomy-slug I am also using the top-level-cats plugin to do the same for original taxonomies. But this is causing a conflict with my pages. When I remove the permastruct the page loads on the pretty permalink, but with my permastruct on it does not, it gives a 404 for all top level pages.


title: Include multiple custom post types

text: Hi i want to include 2 different custom post types in my functions files:               include("portfolio/portfolio-post-type.php");      include("gallery/gallery-post-type.php");       But they seem to break WordPress, it only works if I include only one at a time, do I need to wrap this within a function?


title: Post Format Link Validation Error

text: For link post formats to appear in my archive.php I'm using the following code:               <a href="<?php echo wp_trim_words( get_the_content(), 100 ); ?>">     <?php the_content(); ?>     </a>      **Of course, this creates a validation error due to a`<p>` being inside an `<a>`. I'm seeking a solution to fix this validation error.** This is the most intuitive way I can dream up for easy link post formats (of course, I'm open to suggestions).


title: Adding an onchange event to a custom dropdown menu in Wordpress

text: I would like to add an onchange event to a dropdown menu I've created via my Wordpress plugin. As this is my first foray into Wordpress development, and the company I work for has a tall order for what they'd like, I'm struggling to understand how to do this. This is what I have: I have a plugin that embeds a base URL into a Wordpress site via a short code. The plugin has an admin settings page that allows the user to change the base URL. In my plugin's php file, I have a function that returns a dropdown menu and embeds the base URL:               function embed_url() {     $dropdown_menu = '<select><option>OptionDefault</option><option value="?id=1">Option1<option value="?id=2">Option2</option></select>';     $full_url = '<object type="text/html" data=' . $embed_this_url . ' style="width:100%; height:100%"><p> URL could not be loaded. </p> </object>';     return $dropdown_menu . $full_url;     }      The variable $embed_this_url is the value of an option saved in the WP database. For example, the value could be "http://www.mysite.com". What I want: I want my dropdown menu to change the website that's embedded. Using the code above, if the user selects Option 1, the embedded site would be $embed_this_url + '?id=1' (in other words: http://www.mysite.com?id=1). Therefore, I need to add some javascript to do an onchange function to refresh the with $embed_this_url plus the value of the selected. How would I implement this?


title: Pass WP post content to a jQuery plugin (Fancybox)

text: I'm building a portfolio WordPress. It only displays image thumbnails, with a video element that call the fancybox. In the `<a>` tags, the attributes have the information for the fancybox to load the content. The `"href="` is the url of the video to show, the `"title="` is the title of the post, etc. I want to somehow bring the content of the post to the fancybox window and display it as the title (caption under the video). My approach so far has been to bring the content of the post into the `<a>` tags and then passing than content into the `FBox.js` file. I've brought the post content (the_content) to a custom attribute for `<a>`, eventid= and also have brought it to INSIDE the `<a></a>` tags. I've got that working: the post content are loaded in the index page both as the "eventid=" attribute and as the text inside the `<a>` tags. This is how the Fbox calling element is loaded inside the WordPress loop in the index.               <a class="thumbnail-frame excerpt-text <?php      if($video_url !='' || $embeded_code != '') :      ?>video<?php      else:      ?>shots<?php      endif;      ?>" <?php      if($video_url !='' || $embeded_code != '') :      ?><?php else:      ?>rel="set-<?php the_ID(); ?>"<?php      endif; ?> href="<?php      if($video_url !='' || $embeded_code != '') :      ?>#embed-<?php the_ID(); ?><?php      else: ?><?php echo $upload_image_1; ?><?php      endif; ?>" title="<?php the_title(); ?>" eventid="<?php the_content(); ?>"><?php          the_content();      ?>      However, I'm still having trouble in sending that text into the FBox JavaScript plugin so that the content is grabbed from the index and loaded in the Fbox. The most I've done is:                'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {      return '' + jQuery("a.video").html() + '';      That posts the content of the FIRST post only inside the Fbox (it gets the content of the first a.video element it finds). I've tried with                'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {      return '' + jQuery(this).html() + '';      But it returns a null or undefined value and it prints it in the Fbox. I'm stuck, I don't know how to grab the specific text content for each post and bring it into the FBox. I was thinking maybe using a global variable? I'm a student so I'm clearly super novice, I just really want to surpass this obstacle. The blog is hosted here: http://realitynext.heliohost.org/wordpress/


title: Move Sticky Nav Menu Below WordPress Tool bar when tool bar enabled

text: I've created a sticky menu but its hidden behind the WordPress Toolbar when logged in. How do i move it below the toolbar when enabled and logged in? I was looking for a conditional tag but couldn't find one for this. I guess there's a WordPress hook or filter that i could use.


title: Subpages Permalinks Issues

text:
my site looks like: **Page-1** (`page.php`)   ... **Subpage-1** (`custom-collection.php`; Custom Post Type)   ...... **Filtering Output-Post** (`custom-collection-single.php`) When I open the filtering output-post by using `/%postname%` for permalinks I get 404 error page. Some code: **custom-collection.php**               <?php $args = array( 'post_type' => 'weine', 'posts_per_page' => -1, 'orderby' => 'rand' );          // ============================= WHITEWINE ===============================     if( is_page('147') ) {           $args = array(         'tax_query' => array(             array(                 'taxonomy' => 'sorte',                 'field' => 'slug',                 'terms' => array('weisswein')             )         )     );     }          // ============================= REDWINE ===============================      ...               // =========================== All WINES ==================================     else {}               $loop = new WP_Query( $args );     while ( $loop->have_posts() ) : $loop->the_post(); ?>              <a class="item" rel="wine" href="<?php the_permalink(); ?>" >         <?php the_post_thumbnail('wine-flow', array('class' => 'content')); ?>                            <?php endwhile; ?>      **custom-collection-single.php**               <?php get_template_part( 'loop', 'single-empty' ); ?>          <?php         echo '
';         the_post_thumbnail('wine-flow');                       echo '...';          ?>      **The Loop** (loop-single-empty.php)               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>          <?php endwhile; ?>      **I try to added this to my functions.php**               add_action('admin_init', 'flush_rewrite_rules');      When I use standard permalinks everything works fine for me.   .htaccess: `<IfModule mod_rewrite.c> ...` is active Thanks for your help.   Ogni


title: Can I query custom meta data through WP_Query

text: Ok, my question is a bit complex so I will try and give a general explanation and then go into details afterward. I am running WordPress 3.4.2 and I am using WCK Post Type Creator and WCK Custom Fields Creator to create my custom post type and custom fields. I am trying to query posts from the custom post type 'business' that have a custom field 'special' attached to it. My problem is that I would like to be more specific and only get a certain type of special ( which is set in the Custom Fields Creator plugin ) but I don't know if/how I can do this using meta_query argument for WP_Query. What I have now will pull posts from the post type but I then have to use get_post_meta() to find the custom fields and loop through them doing tests for what I want. Here is what I have right now:               <?php        $args = array(         'post_type' => 'business',         'meta_query'  => array(                     array(                         'key' => 'specials'                     )                 )              );     $loop = new WP_Query( $args );          while ( $loop->have_posts() ) : $loop->the_post();           $specials = get_post_meta( $post->ID, 'specials');           //Loop through array    of specials     foreach( $specials as $special){              //Loop through each special         foreach($special as $individual){              //Check to see is there is a drink special         if ($individual ['type-of-special'] == 'Drink' ) {              //Do stuff                        }//indivdual         }//special     } //specials          endwhile; ?>      So, what I am doing here is pulling the posts and then for each post getting the 'specials' meta data and looping through the different arrays to check what kind of special it is and then displaying stuff if it is the right kind of special. Is there a way to be more specific in my WP_query so I only return the posts that are of a certain type of special? The problem I seem to be running into is that I don't know how to dig down far enough into the multidimensional arrays that the 'specials' custom field has to check for values with the meta_query argument for WP_Query. If I print $special in the foreach($specials as $special) I get this:               Array     (         [0] => Array             (                 [type-of-special] => Drink                 [name-of-special] => Pumpkin Latte                 [price] => 2.00                 [day-of-the-week] => Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday             )     )      So I don't know how to get to [type-of-special] key to check its value through meta_query. I know this is a lot of information and I really appreciate any feedback and help to solve this issue. If you need more information or clarification on something please let me know. Thanks again!


title: How to reduce the number of revisions?

text: I some posts I have a lot of revisions, and I want only 2 revisions for each post.   I found this plugin http://wordpress.org/extend/plugins/revision-control/ that able to set that in the future WP will not store more then 2 revisions, but It does not remove existing revisions.   I found this plugin http://wordpress.org/extend/plugins/better-delete- revision/ that can remove all the revisions. But I can not set to leave 2 revisions.


title: enqueue script only if it is not already enqueue

text: I want to include a script in a shortcode output, so I am trying this:               function my_shortcode( $atts, $content = null ) {         extract(shortcode_atts(array(                 'title'  => '',                ), $atts));              wp_enqueue_script('custom-script');           }      I have registered the script already and enqueue it if the above shortcode is used. However I want to include the file only once, even if the shortcode is used multiple times. Currently, if the shortcode is used multiple times, it will include the script for each time. Is it possible?


title: Guaranteed Image Sizes

text: I am using the following line of code to create a new image size:               add_image_size('single-post-image', 600, 370, true);      However, this line of code does not guarantee that, the image will be of 600X370 size, it guarantees that, this is the maximum size, and smaller images will not be resized. In my case however, I need a guarantee that, every image I use will be of 600X370.


title: Displaying only specific galleries using shortcode on a custom page

text:
I have finally got the gallery working on my page, and following some previous advice on this site I researched the shortcode for the gallery on the codex. Now if I understood correctly if I set ID to say id="astrophoto" it should only read from that post, but when I call the page up it grabs images that are not included in the post gallery. Also comes a question of styling. I am using Foundation 4 as my framework and I was planning on using the modal included for displaying the full size images when clicked, but it has taken and I am hoping to save time on this part and get some help from here. gallery location: http://lab.nmjgraphics.com/astrophotography/ here is the shortcode I am using right now:               <?php     //Calling arguments for gallery. This is the place to change the information for which gallery is to be displayed     $gallery_shortcode = '[gallery id="astrophoto" columns="3" order="ASC" orderby="ID" gallery size="medium"]';     ?>          <?php get_header(); ?>
Astrophotography Gallery

     <?php print apply_filters( 'the_content', $gallery_shortcode ); ?>
          <?php get_footer(); ?>


title: How to join tables?

text: I know many posts is on the site about this but I can't understand how it work. This SQL works.               SELECT wp_category.id, wp_ogloszenia_kupione.kategoria, klient_id       FROM wp_category       JOIN wp_ogloszenia_kupione ON (wp_ogloszenia_kupione.kategoria = wp_category.id);      How this translate to Wordpress `$wpdb`?


title: All shortcodes not working on custom theme

text:
I'm using a custom theme not developed by myself that seems to have disabled/ or doesn't have the function for any and all Shortodes, whether its a WordPress shortcode or a plugin shortcode. I mostly need this function to work via a plugin generated shortcode. Ive checked several things to see what is causing it but have had no luck finding where the issues is. Here is what I have checked. When I switched back to the 2012 theme, the shortcodes worked fine. Ive disabled all my other plugins to checked to see if it was due to some incompatibility. no change. Ive made sure the page template has the correct loop per this post: plugin shortcodes not working on custom theme- unsure how to fix *Edit: Here is the code for the page template                   <?php get_header(); ?>

                <?php // while ( have_posts() ) : the_post();                  if(get_the_content()){               ?>                      <?php if(get_the_ID() == 1228) { ?>
Forms
                     <?php the_content(); ?>                 <?php }elseif(get_the_ID() == 1191){ ?>                                         <?php the_content(); ?>                 <?php }else{ ?>
<?php the_title(); ?>
             <?php                         function sup($text){                                  $true = preg_replace('#(\d+)(st|th|nd|rd)#', '$1$2', $text);                             return $true;                              }                     echo sup(get_the_content()); ?>                 <?php } ?>                 <?php }else{                     $arg = query_posts(array('post_parent' => get_the_ID(), 'post_type' => 'page', 'posts_per_page'=>1,  'orderby' => 'menu_order', 'order' => 'ASC' ));          //                    $arg[0]->guid;                     ?>                     <?php if($arg[0]->ID == 1811):?>                     <?php                     $ag = query_posts(array('post_parent' => $arg[0]->ID, 'post_type' => 'page','posts_per_page'=>1,  'orderby' => 'menu_order',  'order' => 'ASC' ));                     ?>
<?php echo $ag[0]->post_title; ?>
                     <?php echo $ag[0]->post_content; ?>                     <?php else:?>
<?php echo $arg[0]->post_title; ?>
                     <?php echo $arg[0]->post_content; ?>                     <?php endif;?>                     <?php }?>               <?php // endwhile; // end of the loop. ?>

                      <?php include('quick_links.php'); ?>                            <?php             $url = $_SERVER['REQUEST_URI'];             $url_parse = parse_url($url);             $level = explode('/', $url_parse['path']);                       if($level[1] == 'education' || $level[1] == 'fellowship'):?>             <?php             $catid = get_query_var('cat');                 $s = query_posts( array(                     'post_type' => 'post',                     'post_status' => 'publish',                     'category' => 'news',                     'posts_per_page' => 0,                      'orderby' => 'post_date',                     'order' => 'DESC'));             while( have_posts() ) : the_post();                 $newsList[] = array(                     'title' => get_the_title(),                     'link' => apply_filters('the_permalink', get_permalink()),                     'date' => apply_filters('the_time', get_the_time( 'F j, Y' ), 'F j, Y'),                     'expert' => apply_filters('the_excerpt', get_the_excerpt()),                     'author' => get_the_author(),                     );             endwhile;             wp_reset_query();                       ?>

News & Information

<a href="<?php echo $newsList[0]['link']; ?>"><?php echo $newsList[0]['title']; ?>

<?php echo $newsList[0]['expert']; ?>

<a href="<?php echo $newsList[0]['link']; ?>">Read More

                  <?php else:?>             <?php                      include('testimonials.php');                      ?>           <?php endif;?>

     <?php get_footer(); ?>      There is a possibility the original developer simply reused a theme developed for an older version of WordPress when shortcodes didn't exist. Any ideas where to look next?


title: Edit a post from frontend. post_tags get saved, but not separated

text:
I'm building a CRM-Theme for Wordpress. So i post, edit and delete posts from the Frontend. I'm on a good way to resolve all problems, i think. But there is one failure. At the index there is a "edit" and "delete" button. If i click on "edit" I'm getting to a form. I can change the post_tags there. Changes will be saved, but the single words don't get separated. All words in the input- field are one huge tag - i can see it in a widget at the sidebar. But i use separators... If you have 2 minutes: Here (in the index.php) i enable to delete a post:               if( 'POST' == $_SERVER['REQUEST_METHOD'] ) {        set_query_var( 'postid1', $_POST['postid'] );     /*  set the "postid" value from the delete button of the post we choose to delete into "postid1" */        wp_delete_post( get_query_var( 'postid1'), true );  /* delete the post we choosed */     };     get_header(); ?>      In the loop of the index you can find the following snippet. First form is for edit, second form for delete:               <form class="edit" action="<?php echo esc_url( home_url( '/' ) ); ?>editieren-formular/" method="post">         <input type="hidden" name="postid" value="<?php the_ID(); ?>" /> <?php /* get the post ID into "postid" and later pass it to "editieren-formular.php" */ ?>         <input type="submit" value="Edit" />     </form>     <form class="delete" action="" method="post">         <input type="hidden" name="postid" value="<?php the_ID(); ?>" /> <?php /* get the post ID into "postid" and later delete the post */ ?>         <input type="submit"  value="Delete" />     </form>      Everything fine. Now the editieren-formular.php, which is a page-template for a site, that is called "Editiere Formular". "editieren-formular" is the slug.               <?php     /*     Template Name: Editieren Formular     */          if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "edit_post" && isset($_POST['postid'])) {         $post_to_edit = array();         $post_to_edit = get_post($_POST['postid']);              /* these are the fields that we are editing in the form below. */         $title = $_POST['title'];         $description = $_POST['description'];         $vorname = $_POST['vorname'];         $name = $_POST['name'];              /* this code will save the title and description into the post_to_edit array */         $post_to_edit->post_title = $title;         $post_to_edit->post_content = $description;              /* honestly i can't really remember why i added this code but it is a must */         $pid = wp_update_post($post_to_edit);              /* save taxonomies: post ID, form name, taxonomy name, if it appends(true) or rewrite(false) */         wp_set_post_terms($pid, array($_POST['cat']),'firmen',false);         wp_set_post_terms($pid, array($_POST['post_tags']),'post_tag',false);              //UPDATE CUSTOM FIELDS WITH THE NEW INFO         //CHANGE TO YOUR CUSTOM FIELDS AND ADD AS MANY AS YOU NEED              update_post_meta($pid, 'vorname', $vorname);         update_post_meta($pid, 'name', $name);              //REDIRECT USER WHERE EVER YOU WANT AFTER DONE EDITING         wp_redirect( 'http://crm-wordpress-theme.wellseo.de' );          ...          } // END THE IF STATEMENT THAT STARTED THE WHOLE FORM               get_header();           $post_to_edit = get_post($_POST['postid']);      $terms = get_the_terms($post_to_edit->ID, 'firmen');      $tags = strip_tags( get_the_term_list( $post_to_edit->ID, 'post_tag', '', ', ', '' ) );           <?php $term_name = strip_tags( get_the_term_list( $post_to_edit->ID, 'category', '', ', ', '' ) ); ?>      <?php $term_obj = get_term_by('name', $term_name, 'category'); ?>      <?php $term_id = $term_obj->term_id ;?>      <?php $args = array(         'selected' => $term_id,         'name' => 'cat',         'class' => 'postform',         'tab_index' => 10,         'depth' => 2,         'hierarchical' => 1,         'hide_empty' => false );  /* array for wp_dropdown_category to display with the current post category selected by default */ ?>
          <form id="edit_post" name="edit_post" method="post" action="" enctype="multipart/form-data">         <fieldset name="title">             Title:
             <input type="text" id="title" value="<?php echo $post_to_edit->post_title; ?>" tabindex="5" name="title" />         </fieldset>              <fieldset id="category">             <?php wp_dropdown_categories( $args ); ?>         </fieldset>              <fieldset class="content">             Discount Description:
             <textarea id="description"  tabindex="15" name="description"><?php echo $post_to_edit->post_content; ?></textarea>         </fieldset>                        <fieldset class="vorname">             Vorname:
             <input type="text" value="<?php echo get_post_meta($post_to_edit->ID,'vorname', true); ?>" id="vorname" tabindex="20" name="vorname" />         </fieldset>              <fieldset class="name">             Name:
             <input type="text" value="<?php echo get_post_meta($post_to_edit->ID,'name', true); ?>" id="name" tabindex="20" name="name" />         </fieldset>              <fieldset class="tags">             Additional Keywords (comma separated):
             <input type="text" value="<?php echo $tags; ?>" tabindex="35" name="post_tags" id="post_tags" />         </fieldset>              <fieldset class="submit">             <input type="submit" value="Speichern" tabindex="40" id="submit" name="submit" />         </fieldset>         <input type="hidden" name="postid" value="<?php echo $post_to_edit->ID; ?>" />         <input type="hidden" name="action" value="edit_post" />         <input type="hidden" name="change_cat" value="" />         <?php // wp_nonce_field( 'new-post' ); ?>     </form>
          <?php get_sidebar(); ?>     <?php get_sidebar('two'); ?>     <?php get_footer(); ?>


title: Default WP search excluding specific characters, is it possible?

text: I would like to know if it possible to customize the default search module of Wordpress. I've a website dealing with teams and teams' news. Some of those teams has their names written like this   * H.M.S.    * L.A. Dream   * N.Y. Invaders I would like that the search modules could be able to manage those teams in the results even if i look for strings like **HMS** , or **LA Dream** , or **NY** , instead of filling the characters with dots. Does anybody has some suggestion, or know a WP trick that at the moment i'm not aware of? Thanks in advance


title: Full Calendar not showing accurate event in month view

text: I have a problem in the jquery-based fullcalendar FullCalendar that I am using in WordPress. I entered this date (in ISO8601 format) : Start Date : Aug 10, 2014, End Date : Aug 11, 2014 and Start Time : 3:00 AM, and End Date : 4:00 AM. it shows perfectly in agendaWeek view but when I turn into Month View, It's supposed to be occupying the two days of Aug 10 and Aug 11 right? but it does not. I tried to switch views from all the views, and in agendaWeek view it shows that it is displaying 3AM to 4AM of Aug 10 to Aug 11. but it does not woek in month view (default). Then I tried changing the end date to 8:00 AM in then it occupied the Aug 10 - Aug 11. I have a guess that this is something to do with the timezone maybe? Please do help me out :) I am still learning this things. TIA.


title: styles from child theme not loaded for file other than style.css

text: I have set up a Worpress page with Multisite and Multilingual Press to support english and german. Currently only working on the english version. I use the "definition" theme of WooThemes and have set up a child theme (following this manual) to customize the design to my needs. Basically this works fine, with some exceptions. I have created the child theme directory, adopted the example style.css to my needs (including the ../definition/style.css, Theme Name, Template). As long as I overwrite css definitions which are defined in the style.css, everthings is fine. The parent theme also defines styles in other files (e.g. themes/definition/css/layout.css). If I overwrite on of this styles, nothing happens. I have allready tried to create the same file on the same path in the child theme folder, but to no avail. When I check with Chrome element examination (?) in the css style section, I see it is still loading the style from the parent file. for classes in style.css it shows following url: "host/wp- content/themes/definition-child/style.css?ver=3.9.2:69" but for classes out of css/layout.css it shows a link to the parent theme: "host/definition/css/layout.css?3.9.2:87" to be exhaustive the style.css file:               /* Theme Name:   WooThemes Definition Calendr.it Child      Theme URI:    TODO to be defined.      Description:  WooThemes Definition Calendr.it Child Theme      Author:       Andras Scheucher      Author URI:   http://andreasscheucher.com      Template:     definition      Version:      1.5.0      Tags:         TODO to be defined      Text Domain:  definition-celendrit-child     */          @import url("../definition/style.css");               /* =Theme customization starts here     -------------------------------------------------------------- */          ....      After reading this article (and not fully understanding it) I also tried to load the css/layout.css with this functions.php:               <?php // register and enqueue the stylesheet.     add_action( ‘wp_enqueue_scripts’, ‘register_child_theme_styles’ );          function register_child_theme_styles() {       wp_register_style( ‘style’, get_stylesheet_uri() );       wp_enqueue_style( ‘style’ );       wp_register_style( ‘layout’, get_stylesheet_uri() + "/css" );       wp_enqueue_style( ‘layout’ );     } ?>      This did not help, but I assume it's not correct anyway. Any hints, what I could try else? If you need code parts, of the definition theme, I can give them of course...


title: Create special button on WP Tiny MCE Posts Editor for Shortcodes

text: I am trying to create a special button on the Tiny MCE editor on the Post Editor of Wordpress. I want to create a button for my created shortcode tooltips. Check out my desired output: http://prntscr.com/4cy6fd I have the following code for my Tooltip shortcode:               //Text tooltip     function tooltip($atts, $content = ''){         $atts = shortcode_atts(             array(               'class' => '',               'title' => ''             ), $atts);                    $html = '' . $content . ' ' .$atts['title']. ' ';         return $html;           }           add_shortcode('tooltip', 'tooltip');      Now when you execute this you will use the following codes for the shortcode:               [tooltips class="top_tooltip" title="Your Tooltip here"] Text here [/tooltip]      What I have done is that created some function to DISPLAY MY CREATED TOOLTIP SHORTCODE on the functions.php file on my theme using the following codes.               //Create Tiny MCE buttons     function mce_tooltip($button) {       $buttons[] = 'superscript';       return $button;     }     add_filter('mce_buttons_2', 'mce_tooltip');                    /*     * Callback function to filter the MCE settings     */          function mce_tooltip( $init_array ) {            // Define the style_formats array            $style_formats = array(           // Each array child is a format with it's own settings         array(             'class' => '',             'title' => ''             );         // Insert the array, JSON ENCODED, into 'style_formats'       $init_array['style_formats'] = json_encode( $style_formats );              return $init_array;            }      // Attach callback to 'tiny_mce_before_init'      add_filter( 'tiny_mce_before_init', 'mce_tooltip' );       I tried the code but it won't show up my CUSTOM button for my shortcode on the TINY MCE Editor on Wordpress. Any idea how to do it better? Here's the output I am trying to create: http://prntscr.com/4cy6fd


title: Get user ID when action row link is clicked

text: I have added an action row link to users.php so that when its clicked it links to a list table. To generate the data for the clicked user in my custom list table, I need to capture the user ID. I have all the code working but I don't know how to access the user ID of the user that was clicked. I am passing the user ID as user via the link so its show in my custom list table url. For example, admin.php?page=history_logger&user=3. http://screencast.com/t/ImZgcCUaR this might help.


title: Wordpress 404 Page displaying on a sub directory that has it's own 404 page

text: On a subdirectory such as http://website.com/sub/index.html that has it's own .htaccess is still for some reason showing the 404 page I have for Wordpress which is on the directory above this one. .htaccess for sub dir:               ErrorDocument 404 /404.html      .htaccess for main dir:               RewriteEngine on     RewriteCond %{HTTP_HOST} ^website.net$ [OR]     RewriteCond %{HTTP_HOST} ^www.website.net$     RewriteRule ^foghelper.php$ http://website.net/subdirone/ [R=301,L]     RewriteRule ^foghelper.php$ http://website.net/subdirtwo/ [R=301,L]     # DO NOT REMOVE THIS LINE AND THE LINES ABOVE jNLK5d:REDIRECTID               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      Links that were in the hta were censored in case your wondering.


title: Why is get_pages() returning a boolean?

text: I have created a custom post type that I want to use to allow people to add an arbitrary number of sections to the homepage of my theme. I want to loop through all posts of that type and include their contents in the page. My problem is that calling `get_pages()` with `'post_type' => 'home_section'` seems to be returning a boolean, not an array. Here is the code I'm using to test:               <?php        $hp_sections = get_pages(array('post_type' => 'home_section'));        echo '<!-- $hp_sections type: ', gettype($hp_sections), ', value: ', $hp_sections, ' -->';     ?>      When I view source on my page I get:               <!-- $hp_sections type: boolean, value:  -->      I'm pretty new to both PHP and Wordpress so I'm assuming I'm making some sort of dumb mistake. I'd like to know both what is wrong with the above code and what the recommended way to get all pages of a given type and iterate over them inside a template is.


title: What to do with unattached logos and header uploaded via native wordpress uploader?

text: Normally when we sort unattached images, they include logos and header images too. My question is simple. Is there any method to keep header and logos safe from deletion? Is it possible to attach them to a page (eg logo or header page) automatically when uploaded so that they will not appear unattached in media library.


title: How to secure files based on format and word in file name with wp-config or htaccess?

text: I have a wordpress site that I would like to secure specific files in the uploads directory, so that they can only be accessed by logged in users. The files either have the word "oneperson" or "twopeople" in the filename, and are of the format "zip" or "pdf". How do I do this?


title: index2.php in root causing 404 error

text: I put up a quick splash page with `index.php` and added a link in that splash page to index2.php and when I go to `index2.php`, I get a _"page not found"_ error. Getting rid of the splash is not an option right now. Is there anything I can do to get this to work?


title: contact form in template with jquery,validate and ajax

text:
I have a page-contact.php for my contact form in my template. I wanted to add jquery validation and some fancy ajax action to my form. This is already a working code in a simple PHP page, but getting it work in wordpress fails. My contact form:               <form id="contact_form" method="POST" action="" enctype="application/x-www-form-urlencoded" novalidate="novalidate">         <input type="text" name="name" maxlength="30" id="name" placeholder="Your name">         <input type="text" name="email" maxlength="30" id="email" placeholder="Your email">         <textarea rows="2" cols="40" name="message" id="message" placeholder="Your message"></textarea>         <input type="text" id="phone" name="phone" size="15" placeholder="Please do not fill your phone number">         <input type="submit" id="click" class="button" value="Submit">

     </form>      the ajax function in functions.php               add_action('wp_ajax_sendmail', 'sendmail');     add_action('wp_ajax_nopriv_sendmail', 'sendmail');         function sendmail() {             if(isset($_POST['Submit'])) {                 echo 'ajax success';             } else {                 echo "
nothing submitted
";             }         die();         }      And my javascript action:               $(document).ready(function(){         $("#contact_form").validate({             rules: {                 name: "required",                 email: {                     required: true,                     email: true                 },                 message: "required"             },             messages: {                 name: "Please enter your name",                 email: {                     required: "Please enter your email adress",                     email: "Please enter your valid email adress"                 },                 message: "Please enter a short message, what your inquiry is about"             },             submitHandler: function(form) {                 $('#loading_icon').show();                 $('#click').hide();                 var params = $(form).serialize();                 $.ajax ({                     type: 'POST',                     url: '<?php echo admin_url( 'admin-ajax.php' ); ?>',                     data: params,                     success: function(response) {                         $('#response').hide();                         $('#response').html(response);                         $('#response').fadeIn('slow');                         $('#loading_icon').hide();                                           }                 });             }              });     });      The needed files are loaded correctly (/1.10.1/jquery.min.js, jquery.validate.js) but, this code keeps returning 0 despite the fact that I have `wp_ajax_nopriv_sendmail` in functions.php. The console does not return any error. I believe that I am missing some wp-specific fact, but which? Thanks in advance


title: How to import content from WordPress.com to a self hosted WordPress installation?

text: On behalf of another, I'm trying to import content from a WordPress.com hosted site to a self-hosted installation of WordPress.com I've exported the XML file and imported it into the new site, but it looks completely different. Original: http://tbmsussex.wordpress.com new: http://tbmsussex.co.uk The pages are all over the place and lots of the images haven't imported. Any ideas how I can get an exact mirror?